[FFmpeg-cvslog] dashdec: Only free url string if being reused

2018-01-20 Thread Brendan McGrath
ffmpeg | branch: master | Brendan McGrath  | Sun 
Jan 21 13:20:02 2018 +0800| [1f48c5c0671bb4f39c9dc3ec44c727f1680547b3] | 
committer: Steven Liu

dashdec: Only free url string if being reused

If no representation bandwidth value is set, the url value returned
by get_content_url is corrupt (as it has been freed).
This change ensures the url string is not freed unless it is about
to be reused
Changes since v1:
 1 removed the unneeded 'if' statement (as pointed out by Michael Niedermayer
 2 added comment to make it clear why the av_free was required
Signed-off-by: Brendan McGrath 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1f48c5c0671bb4f39c9dc3ec44c727f1680547b3
---

 libavformat/dashdec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index a080bf3584..7d960670b9 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -483,9 +483,10 @@ static char *get_content_url(xmlNodePtr *baseurl_nodes,
 return NULL;
 }
 av_strlcpy(tmp_str, url, sizeof(tmp_str));
-av_free(url);
 }
 if (rep_bandwidth_val && tmp_str[0] != '\0') {
+// free any previously assigned url before reassigning
+av_free(url);
 url = av_strireplace(tmp_str, "$Bandwidth$", (const 
char*)rep_bandwidth_val);
 if (!url) {
 return NULL;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] libavformat/dashdec: Fix for ticket 6856 (filename limited to 1024)

2018-01-20 Thread Colin NG
ffmpeg | branch: master | Colin NG  | Sun Jan 21 13:56:57 
2018 +0800| [78e884f3fb1d0471dbe2c89fec0d0f274f7c8350] | committer: Steven Liu

libavformat/dashdec: Fix for ticket 6856 (filename limited to 1024)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=78e884f3fb1d0471dbe2c89fec0d0f274f7c8350
---

 libavformat/dashdec.c | 94 ++-
 1 file changed, 63 insertions(+), 31 deletions(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 3aac89c4ab..f4cbb065e9 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -148,13 +148,20 @@ typedef struct DASHContext {
 char *headers;   ///< holds HTTP headers set as an 
AVOption to the HTTP protocol context
 char *allowed_extensions;
 AVDictionary *avio_opts;
+int max_url_size;
 } DASHContext;
 
-static int ishttp(char *url) {
+static int ishttp(char *url)
+{
 const char *proto_name = avio_find_protocol_name(url);
 return av_strstart(proto_name, "http", NULL);
 }
 
+static int aligned(int val)
+{
+return ((val + 0x3F) >> 6) << 6;
+}
+
 static uint64_t get_current_time_in_sec(void)
 {
 return  av_gettime() / 100;
@@ -453,6 +460,7 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
const char *url,
 
 static char *get_content_url(xmlNodePtr *baseurl_nodes,
  int n_baseurl_nodes,
+ int max_url_size,
  char *rep_id_val,
  char *rep_bandwidth_val,
  char *val)
@@ -460,10 +468,12 @@ static char *get_content_url(xmlNodePtr *baseurl_nodes,
 int i;
 char *text;
 char *url = NULL;
-char tmp_str[MAX_URL_SIZE];
-char tmp_str_2[MAX_URL_SIZE];
+char *tmp_str = av_mallocz(max_url_size);
+char *tmp_str_2 = av_mallocz(max_url_size);
 
-memset(tmp_str, 0, sizeof(tmp_str));
+if (!tmp_str || !tmp_str_2) {
+return NULL;
+}
 
 for (i = 0; i < n_baseurl_nodes; ++i) {
 if (baseurl_nodes[i] &&
@@ -471,33 +481,36 @@ static char *get_content_url(xmlNodePtr *baseurl_nodes,
 baseurl_nodes[i]->children->type == XML_TEXT_NODE) {
 text = xmlNodeGetContent(baseurl_nodes[i]->children);
 if (text) {
-memset(tmp_str, 0, sizeof(tmp_str));
-memset(tmp_str_2, 0, sizeof(tmp_str_2));
-ff_make_absolute_url(tmp_str_2, MAX_URL_SIZE, tmp_str, text);
-av_strlcpy(tmp_str, tmp_str_2, sizeof(tmp_str));
+memset(tmp_str, 0, max_url_size);
+memset(tmp_str_2, 0, max_url_size);
+ff_make_absolute_url(tmp_str_2, max_url_size, tmp_str, text);
+av_strlcpy(tmp_str, tmp_str_2, max_url_size);
 xmlFree(text);
 }
 }
 }
 
 if (val)
-av_strlcat(tmp_str, (const char*)val, sizeof(tmp_str));
+av_strlcat(tmp_str, (const char*)val, max_url_size);
 
 if (rep_id_val) {
 url = av_strireplace(tmp_str, "$RepresentationID$", (const 
char*)rep_id_val);
 if (!url) {
-return NULL;
+goto end;
 }
-av_strlcpy(tmp_str, url, sizeof(tmp_str));
+av_strlcpy(tmp_str, url, max_url_size);
 }
 if (rep_bandwidth_val && tmp_str[0] != '\0') {
 // free any previously assigned url before reassigning
 av_free(url);
 url = av_strireplace(tmp_str, "$Bandwidth$", (const 
char*)rep_bandwidth_val);
 if (!url) {
-return NULL;
+goto end;
 }
 }
+end:
+av_free(tmp_str);
+av_free(tmp_str_2);
 return url;
 }
 
@@ -582,9 +595,11 @@ static int parse_manifest_segmenturlnode(AVFormatContext 
*s, struct representati
  char *rep_id_val,
  char *rep_bandwidth_val)
 {
+DASHContext *c = s->priv_data;
 char *initialization_val = NULL;
 char *media_val = NULL;
 char *range_val = NULL;
+int max_url_size = c ? c->max_url_size: MAX_URL_SIZE;
 
 if (!av_strcasecmp(fragmenturl_node->name, (const char 
*)"Initialization")) {
 initialization_val = xmlGetProp(fragmenturl_node, "sourceURL");
@@ -597,6 +612,7 @@ static int parse_manifest_segmenturlnode(AVFormatContext 
*s, struct representati
 return AVERROR(ENOMEM);
 }
 rep->init_section->url = get_content_url(baseurl_nodes, 4,
+ max_url_size,
  rep_id_val,
  rep_bandwidth_val,
  initialization_val);
@@ -621,6 +637,7 @@ static int parse_manifest_segmenturlnode(AVFormatContext 
*s, struct representati
 return AVERROR(ENOMEM);
   

[FFmpeg-cvslog] avformat/dashdec.c: Download dash content with byte range info

2018-01-20 Thread Colin NG
ffmpeg | branch: master | Colin NG  | Sun Jan 21 13:27:48 
2018 +0800| [8db4ef3e6d9377d131e7051dcebf41fa6cc9ac81] | committer: Steven Liu

avformat/dashdec.c: Download dash content with byte range info

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8db4ef3e6d9377d131e7051dcebf41fa6cc9ac81
---

 libavformat/dashdec.c | 36 ++--
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 7d960670b9..6bf0fcfaff 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -552,6 +552,23 @@ static enum AVMediaType get_content_type(xmlNodePtr node)
 return type;
 }
 
+static struct fragment * get_Fragment(char *range)
+{
+struct fragment * seg =  av_mallocz(sizeof(struct fragment));
+
+if (!seg)
+return NULL;
+
+seg->size = -1;
+if (range) {
+char *str_end_offset;
+char *str_offset = av_strtok(range, "-", _end_offset);
+seg->url_offset = strtoll(str_offset, NULL, 10);
+seg->size = strtoll(str_end_offset, NULL, 10) - seg->url_offset;
+}
+return seg;
+}
+
 static int parse_manifest_segmenturlnode(AVFormatContext *s, struct 
representation *rep,
  xmlNodePtr fragmenturl_node,
  xmlNodePtr *baseurl_nodes,
@@ -560,13 +577,16 @@ static int parse_manifest_segmenturlnode(AVFormatContext 
*s, struct representati
 {
 char *initialization_val = NULL;
 char *media_val = NULL;
+char *range_val = NULL;
 
 if (!av_strcasecmp(fragmenturl_node->name, (const char 
*)"Initialization")) {
 initialization_val = xmlGetProp(fragmenturl_node, "sourceURL");
-if (initialization_val) {
-rep->init_section = av_mallocz(sizeof(struct fragment));
+range_val = xmlGetProp(fragmenturl_node, "range");
+if (initialization_val || range_val) {
+rep->init_section = get_Fragment(range_val);
 if (!rep->init_section) {
 xmlFree(initialization_val);
+xmlFree(range_val);
 return AVERROR(ENOMEM);
 }
 rep->init_section->url = get_content_url(baseurl_nodes, 4,
@@ -576,17 +596,20 @@ static int parse_manifest_segmenturlnode(AVFormatContext 
*s, struct representati
 if (!rep->init_section->url) {
 av_free(rep->init_section);
 xmlFree(initialization_val);
+xmlFree(range_val);
 return AVERROR(ENOMEM);
 }
-rep->init_section->size = -1;
 xmlFree(initialization_val);
+xmlFree(range_val);
 }
 } else if (!av_strcasecmp(fragmenturl_node->name, (const char 
*)"SegmentURL")) {
 media_val = xmlGetProp(fragmenturl_node, "media");
-if (media_val) {
-struct fragment *seg = av_mallocz(sizeof(struct fragment));
+range_val = xmlGetProp(fragmenturl_node, "mediaRange");
+if (media_val || range_val) {
+struct fragment *seg = get_Fragment(range_val);
 if (!seg) {
 xmlFree(media_val);
+xmlFree(range_val);
 return AVERROR(ENOMEM);
 }
 seg->url = get_content_url(baseurl_nodes, 4,
@@ -596,11 +619,12 @@ static int parse_manifest_segmenturlnode(AVFormatContext 
*s, struct representati
 if (!seg->url) {
 av_free(seg);
 xmlFree(media_val);
+xmlFree(range_val);
 return AVERROR(ENOMEM);
 }
-seg->size = -1;
 dynarray_add(>fragments, >n_fragments, seg);
 xmlFree(media_val);
+xmlFree(range_val);
 }
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avformat/hlsenc: Check that data is set

2018-01-20 Thread Brendan McGrath
ffmpeg | branch: master | Brendan McGrath  | Sun 
Jan 21 13:16:42 2018 +0800| [2472dbc7a770a908a2f511ec337ec392ca3e3afa] | 
committer: Steven Liu

avformat/hlsenc: Check that data is set

If codecpar->extradata is not set (for example, when the stream goes
through the 'tee' muxer), then a segfault occurs.
This patch ensures the data variable is not null before attempting
to access it
Before the var_stream_map option was available - I was using the tee
muxer to create each resolution as an individual stream.
When running this configuration after the most recent hlsenc change
I hit a segfault
The most simple command which recreates the segfault is:
ffmpeg -i in.ts -map 0:a -map 0:v -c:a aac -c:v h264 -f tee 
[select=\'a,v\':f=hls]tv_hls_hd.m3u8

Signed-off-by: Brendan McGrath 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2472dbc7a770a908a2f511ec337ec392ca3e3afa
---

 libavformat/hlsenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 8ad906a480..42e437f5d1 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -308,7 +308,7 @@ static void write_codec_attr(AVStream *st, VariantStream 
*vs) {
 
 if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
 uint8_t *data = st->codecpar->extradata;
-if ((data[0] | data[1] | data[2]) == 0 && data[3] == 1 && (data[4] & 
0x1F) == 7) {
+if (data && (data[0] | data[1] | data[2]) == 0 && data[3] == 1 && 
(data[4] & 0x1F) == 7) {
 snprintf(attr, sizeof(attr),
  "avc1.%02x%02x%02x", data[5], data[6], data[7]);
 } else {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] libavformat/dashdec: Fix for ticket 6658 (Dash demuxer segfault)

2018-01-20 Thread Colin NG
ffmpeg | branch: master | Colin NG  | Sun Jan 21 13:35:30 
2018 +0800| [7a63da891023767824af75ff1c9fe681c156ac19] | committer: Steven Liu

libavformat/dashdec: Fix for ticket 6658 (Dash demuxer segfault)

1 Add function 'resolve_content_path' to propagate the baseURL from
upper level nodes.
 * if no baseURL is available, the path of mpd file will be set as the baseURL.
2 Remove checking for newly established connection.
3 Establish the communication protocol in each connection rather than
 applying one protocol to all connection.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7a63da891023767824af75ff1c9fe681c156ac19
---

 libavformat/dashdec.c | 128 +-
 1 file changed, 115 insertions(+), 13 deletions(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 6bf0fcfaff..3aac89c4ab 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -150,6 +150,11 @@ typedef struct DASHContext {
 AVDictionary *avio_opts;
 } DASHContext;
 
+static int ishttp(char *url) {
+const char *proto_name = avio_find_protocol_name(url);
+return av_strstart(proto_name, "http", NULL);
+}
+
 static uint64_t get_current_time_in_sec(void)
 {
 return  av_gettime() / 100;
@@ -421,7 +426,8 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
const char *url,
 else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5))
 return AVERROR_INVALIDDATA;
 
-ret = s->io_open(s, pb, url, AVIO_FLAG_READ, );
+av_freep(pb);
+ret = avio_open2(pb, url, AVIO_FLAG_READ, c->interrupt_callback, );
 if (ret >= 0) {
 // update cookies on http response with setcookies.
 char *new_cookies = NULL;
@@ -566,6 +572,7 @@ static struct fragment * get_Fragment(char *range)
 seg->url_offset = strtoll(str_offset, NULL, 10);
 seg->size = strtoll(str_end_offset, NULL, 10) - seg->url_offset;
 }
+
 return seg;
 }
 
@@ -593,6 +600,7 @@ static int parse_manifest_segmenturlnode(AVFormatContext 
*s, struct representati
  rep_id_val,
  rep_bandwidth_val,
  initialization_val);
+
 if (!rep->init_section->url) {
 av_free(rep->init_section);
 xmlFree(initialization_val);
@@ -667,6 +675,105 @@ static int parse_manifest_segmenttimeline(AVFormatContext 
*s, struct representat
 return 0;
 }
 
+static int resolve_content_path(AVFormatContext *s, const char *url, 
xmlNodePtr *baseurl_nodes, int n_baseurl_nodes) {
+
+char *tmp_str = NULL;
+char *path = NULL;
+char *mpdName = NULL;
+xmlNodePtr node = NULL;
+char *baseurl = NULL;
+char *root_url = NULL;
+char *text = NULL;
+
+int isRootHttp = 0;
+char token ='/';
+int start =  0;
+int rootId = 0;
+int updated = 0;
+int size = 0;
+int i;
+int max_url_size = strlen(url);
+
+for (i = n_baseurl_nodes-1; i >= 0 ; i--) {
+text = xmlNodeGetContent(baseurl_nodes[i]);
+if (!text)
+continue;
+max_url_size += strlen(text);
+if (ishttp(text)) {
+xmlFree(text);
+break;
+}
+xmlFree(text);
+}
+
+text = av_mallocz(max_url_size);
+if (!text) {
+updated = AVERROR(ENOMEM);
+goto end;
+}
+av_strlcpy(text, url, strlen(url)+1);
+while (mpdName = av_strtok(text, "/", ))  {
+size = strlen(mpdName);
+}
+
+path = av_mallocz(max_url_size);
+tmp_str = av_mallocz(max_url_size);
+if (!tmp_str || !path) {
+updated = AVERROR(ENOMEM);
+goto end;
+}
+
+av_strlcpy (path, url, strlen(url) - size + 1);
+for (rootId = n_baseurl_nodes - 1; rootId > 0; rootId --) {
+if (!(node = baseurl_nodes[rootId])) {
+continue;
+}
+if (ishttp(xmlNodeGetContent(node))) {
+break;
+}
+}
+
+node = baseurl_nodes[rootId];
+baseurl = xmlNodeGetContent(node);
+root_url = (av_strcasecmp(baseurl, "")) ? baseurl : path;
+if (node) {
+xmlNodeSetContent(node, root_url);
+updated = 1;
+}
+
+size = strlen(root_url);
+isRootHttp = ishttp(root_url);
+
+if (root_url[size - 1] != token) {
+av_strlcat(root_url, "/", size + 2);
+size += 2;
+}
+
+for (i = 0; i < n_baseurl_nodes; ++i) {
+if (i == rootId) {
+continue;
+}
+text = xmlNodeGetContent(baseurl_nodes[i]);
+if (text) {
+memset(tmp_str, 0, strlen(tmp_str));
+if (!ishttp(text) && isRootHttp) {
+av_strlcpy(tmp_str, root_url, size + 1);
+}
+start = (text[0] == token);
+av_strlcat(tmp_str, text + start, max_url_size);
+xmlNodeSetContent(baseurl_nodes[i], tmp_str);

[FFmpeg-cvslog] dashdec: Make use of frame rate specified in Representation

2018-01-20 Thread sfan5
ffmpeg | branch: master | sfan5  | Sun Jan 21 13:14:51 2018 
+0800| [777d6c677b1d70e9267c5e31c2c2473fa064076b] | committer: Steven Liu

dashdec: Make use of frame rate specified in Representation

If the manifest provides this, setting r_frame_rate
avoids warnings regarding frame rate estimation.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=777d6c677b1d70e9267c5e31c2c2473fa064076b
---

 libavformat/dashdec.c | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 2492f1d266..a080bf3584 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -86,6 +86,7 @@ struct representation {
 enum AVMediaType type;
 char id[20];
 int bandwidth;
+AVRational framerate;
 AVStream *assoc_stream; /* demuxer stream associated with this 
representation */
 
 int n_fragments;
@@ -674,6 +675,7 @@ static int parse_manifest_representation(AVFormatContext 
*s, const char *url,
 xmlNodePtr representation_node = node;
 char *rep_id_val = xmlGetProp(representation_node, "id");
 char *rep_bandwidth_val = xmlGetProp(representation_node, "bandwidth");
+char *rep_framerate_val = xmlGetProp(representation_node, "frameRate");
 enum AVMediaType type = AVMEDIA_TYPE_UNKNOWN;
 
 // try get information from representation
@@ -843,6 +845,13 @@ static int parse_manifest_representation(AVFormatContext 
*s, const char *url,
 rep->fragment_timescale = 1;
 rep->bandwidth = rep_bandwidth_val ? atoi(rep_bandwidth_val) : 0;
 strncpy(rep->id, rep_id_val ? rep_id_val : "", sizeof(rep->id));
+rep->framerate = av_make_q(0, 0);
+if (type == AVMEDIA_TYPE_VIDEO && rep_framerate_val) {
+ret = av_parse_video_rate(>framerate, rep_framerate_val);
+if (ret < 0)
+av_log(s, AV_LOG_VERBOSE, "Ignoring invalid frame rate 
'%s'\n", rep_framerate_val);
+}
+
 if (type == AVMEDIA_TYPE_VIDEO) {
 rep->rep_idx = video_rep_idx;
 dynarray_add(>videos, >n_videos, rep);
@@ -861,6 +870,8 @@ end:
 xmlFree(rep_id_val);
 if (rep_bandwidth_val)
 xmlFree(rep_bandwidth_val);
+if (rep_framerate_val)
+xmlFree(rep_framerate_val);
 
 return ret;
 }
@@ -1571,7 +1582,7 @@ static int reopen_demux_for_component(AVFormatContext *s, 
struct representation
 AVInputFormat *in_fmt = NULL;
 AVDictionary  *in_fmt_opts = NULL;
 uint8_t *avio_ctx_buffer  = NULL;
-int ret = 0;
+int ret = 0, i;
 
 if (pls->ctx) {
 close_demux_for_component(pls);
@@ -1618,6 +1629,13 @@ static int reopen_demux_for_component(AVFormatContext 
*s, struct representation
 if (ret < 0)
 goto fail;
 if (pls->n_fragments) {
+#if FF_API_R_FRAME_RATE
+if (pls->framerate.den) {
+for (i = 0; i < pls->ctx->nb_streams; i++)
+pls->ctx->streams[i]->r_frame_rate = pls->framerate;
+}
+#endif
+
 ret = avformat_find_stream_info(pls->ctx, NULL);
 if (ret < 0)
 goto fail;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec/hevc_parser: use ff_hevc_uninit_parameter_sets()

2018-01-20 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Jan 20 16:55:00 
2018 -0300| [2159d4bbc3e69d04242e87bac13ebea8b942d94d] | committer: James Almer

avcodec/hevc_parser: use ff_hevc_uninit_parameter_sets()

Reviewed-by: Michael Niedermayer 
Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2159d4bbc3e69d04242e87bac13ebea8b942d94d
---

 libavcodec/hevc_parser.c | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index ff7e8a49d6..88d3d9a22f 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -359,17 +359,8 @@ static int hevc_split(AVCodecContext *avctx, const uint8_t 
*buf, int buf_size)
 static void hevc_parser_close(AVCodecParserContext *s)
 {
 HEVCParserContext *ctx = s->priv_data;
-int i;
-
-for (i = 0; i < FF_ARRAY_ELEMS(ctx->ps.vps_list); i++)
-av_buffer_unref(>ps.vps_list[i]);
-for (i = 0; i < FF_ARRAY_ELEMS(ctx->ps.sps_list); i++)
-av_buffer_unref(>ps.sps_list[i]);
-for (i = 0; i < FF_ARRAY_ELEMS(ctx->ps.pps_list); i++)
-av_buffer_unref(>ps.pps_list[i]);
-
-ctx->ps.sps = NULL;
 
+ff_hevc_ps_uninit(>ps);
 ff_h2645_packet_uninit(>pkt);
 ff_hevc_reset_sei(>sei);
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec/hevc_ps: add a function to uninitialize parameter set buffers

2018-01-20 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Jan 20 16:54:15 
2018 -0300| [9462b2b8205397ea5972b2365c2e8db6872ef3e9] | committer: James Almer

avcodec/hevc_ps: add a function to uninitialize parameter set buffers

Reviewed-by: Michael Niedermayer 
Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9462b2b8205397ea5972b2365c2e8db6872ef3e9
---

 libavcodec/hevc_ps.c | 16 
 libavcodec/hevc_ps.h |  2 ++
 2 files changed, 18 insertions(+)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index a4f7ed60f7..4787312cfa 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -1704,6 +1704,22 @@ err:
 return ret;
 }
 
+void ff_hevc_ps_uninit(HEVCParamSets *ps)
+{
+int i;
+
+for (i = 0; i < FF_ARRAY_ELEMS(ps->vps_list); i++)
+av_buffer_unref(>vps_list[i]);
+for (i = 0; i < FF_ARRAY_ELEMS(ps->sps_list); i++)
+av_buffer_unref(>sps_list[i]);
+for (i = 0; i < FF_ARRAY_ELEMS(ps->pps_list); i++)
+av_buffer_unref(>pps_list[i]);
+
+ps->sps = NULL;
+ps->pps = NULL;
+ps->vps = NULL;
+}
+
 int ff_hevc_compute_poc(const HEVCSPS *sps, int pocTid0, int poc_lsb, int 
nal_unit_type)
 {
 int max_poc_lsb  = 1 << sps->log2_max_poc_lsb;
diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
index 477ee4299a..9873754389 100644
--- a/libavcodec/hevc_ps.h
+++ b/libavcodec/hevc_ps.h
@@ -421,6 +421,8 @@ int ff_hevc_decode_nal_sps(GetBitContext *gb, 
AVCodecContext *avctx,
 int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
HEVCParamSets *ps);
 
+void ff_hevc_ps_uninit(HEVCParamSets *ps);
+
 int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx,
   ShortTermRPS *rps, const HEVCSPS *sps, int 
is_slice_header);
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec/hevcdec: use ff_hevc_uninit_parameter_sets()

2018-01-20 Thread James Almer
ffmpeg | branch: master | James Almer  | Sat Jan 20 16:54:51 
2018 -0300| [1f0cf1b2f4ef6304c343d53508193ac4b5d9c1d2] | committer: James Almer

avcodec/hevcdec: use ff_hevc_uninit_parameter_sets()

Reviewed-by: Michael Niedermayer 
Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1f0cf1b2f4ef6304c343d53508193ac4b5d9c1d2
---

 libavcodec/hevcdec.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 4bfae8c12b..8f1c1f1953 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -3277,15 +3277,7 @@ static av_cold int hevc_decode_free(AVCodecContext 
*avctx)
 av_frame_free(>DPB[i].frame);
 }
 
-for (i = 0; i < FF_ARRAY_ELEMS(s->ps.vps_list); i++)
-av_buffer_unref(>ps.vps_list[i]);
-for (i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++)
-av_buffer_unref(>ps.sps_list[i]);
-for (i = 0; i < FF_ARRAY_ELEMS(s->ps.pps_list); i++)
-av_buffer_unref(>ps.pps_list[i]);
-s->ps.sps = NULL;
-s->ps.pps = NULL;
-s->ps.vps = NULL;
+ff_hevc_ps_uninit(>ps);
 
 av_freep(>sh.entry_point_offset);
 av_freep(>sh.offset);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] lavf/rawdec: Also probe the last byte of mjpeg streams.

2018-01-20 Thread Carl Eugen Hoyos
ffmpeg | branch: master | Carl Eugen Hoyos  | Sat Jan 20 
16:07:25 2018 +0100| [251f0bcb7be9e42af91c1beb346d752185bbcbb9] | committer: 
Carl Eugen Hoyos

lavf/rawdec: Also probe the last byte of mjpeg streams.

Fixes ticket #6957.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=251f0bcb7be9e42af91c1beb346d752185bbcbb9
---

 libavformat/rawdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
index e926549a60..b38a4b5e5d 100644
--- a/libavformat/rawdec.c
+++ b/libavformat/rawdec.c
@@ -130,7 +130,7 @@ static int mjpeg_probe(AVProbeData *p)
 int nb_invalid = 0;
 int nb_frames = 0;
 
-for (i=0; ibuf_size-2; i++) {
+for (i = 0; i < p->buf_size - 1; i++) {
 int c;
 if (p->buf[i] != 0xFF)
 continue;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec: v4l2_m2m: fix races around freeing data on close

2018-01-20 Thread Mark Thompson
ffmpeg | branch: master | Mark Thompson  | Tue Jan  9 23:56:41 
2018 +0100| [a0c624e299730c8c5800375c2f5f3c6c200053ff] | committer: Mark 
Thompson

avcodec: v4l2_m2m: fix races around freeing data on close

Refcount all of the context information. This also fixes a potential
segmentation fault when accessing freed memory  (buffer returned after
the codec has been closed).

Tested-by: Jorge Ramirez-Ortiz 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a0c624e299730c8c5800375c2f5f3c6c200053ff
---

 libavcodec/v4l2_buffers.c | 32 ++--
 libavcodec/v4l2_buffers.h |  6 +++
 libavcodec/v4l2_m2m.c | 93 +--
 libavcodec/v4l2_m2m.h | 35 ++
 libavcodec/v4l2_m2m_dec.c | 22 +++
 libavcodec/v4l2_m2m_enc.c | 22 +++
 6 files changed, 140 insertions(+), 70 deletions(-)

diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c
index ba70c5d14b..4e68f901b3 100644
--- a/libavcodec/v4l2_buffers.c
+++ b/libavcodec/v4l2_buffers.c
@@ -207,20 +207,17 @@ static void v4l2_free_buffer(void *opaque, uint8_t 
*unused)
 V4L2Buffer* avbuf = opaque;
 V4L2m2mContext *s = buf_to_m2mctx(avbuf);
 
-atomic_fetch_sub_explicit(>refcount, 1, memory_order_acq_rel);
-if (s->reinit) {
-if (!atomic_load(>refcount))
-sem_post(>refsync);
-return;
-}
+if (atomic_fetch_sub(>context_refcount, 1) == 1) {
+atomic_fetch_sub_explicit(>refcount, 1, memory_order_acq_rel);
 
-if (avbuf->context->streamon) {
-ff_v4l2_buffer_enqueue(avbuf);
-return;
-}
+if (s->reinit) {
+if (!atomic_load(>refcount))
+sem_post(>refsync);
+} else if (avbuf->context->streamon)
+ff_v4l2_buffer_enqueue(avbuf);
 
-if (!atomic_load(>refcount))
-ff_v4l2_m2m_codec_end(s->avctx);
+av_buffer_unref(>context_ref);
+}
 }
 
 static int v4l2_buf_to_bufref(V4L2Buffer *in, int plane, AVBufferRef **buf)
@@ -236,6 +233,17 @@ static int v4l2_buf_to_bufref(V4L2Buffer *in, int plane, 
AVBufferRef **buf)
 if (!*buf)
 return AVERROR(ENOMEM);
 
+if (in->context_ref)
+atomic_fetch_add(>context_refcount, 1);
+else {
+in->context_ref = av_buffer_ref(s->self_ref);
+if (!in->context_ref) {
+av_buffer_unref(buf);
+return AVERROR(ENOMEM);
+}
+in->context_refcount = 1;
+}
+
 in->status = V4L2BUF_RET_USER;
 atomic_fetch_add_explicit(>refcount, 1, memory_order_relaxed);
 
diff --git a/libavcodec/v4l2_buffers.h b/libavcodec/v4l2_buffers.h
index e28a4a650d..dc5cc9e267 100644
--- a/libavcodec/v4l2_buffers.h
+++ b/libavcodec/v4l2_buffers.h
@@ -24,6 +24,7 @@
 #ifndef AVCODEC_V4L2_BUFFERS_H
 #define AVCODEC_V4L2_BUFFERS_H
 
+#include 
 #include 
 
 #include "avcodec.h"
@@ -41,6 +42,11 @@ typedef struct V4L2Buffer {
 /* each buffer needs to have a reference to its context */
 struct V4L2Context *context;
 
+/* This object is refcounted per-plane, so we need to keep track
+ * of how many context-refs we are holding. */
+AVBufferRef *context_ref;
+atomic_uint context_refcount;
+
 /* keep track of the mmap address and mmap length */
 struct V4L2Plane_info {
 int bytesperline;
diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
index 1d7a8521d8..fd989ce601 100644
--- a/libavcodec/v4l2_m2m.c
+++ b/libavcodec/v4l2_m2m.c
@@ -222,8 +222,6 @@ int ff_v4l2_m2m_codec_reinit(V4L2m2mContext* s)
 }
 
 /* 5. complete reinit */
-sem_destroy(>refsync);
-sem_init(>refsync, 0, 0);
 s->draining = 0;
 s->reinit = 0;
 
@@ -241,24 +239,26 @@ int ff_v4l2_m2m_codec_full_reinit(V4L2m2mContext *s)
 if (atomic_load(>refcount))
 while(sem_wait(>refsync) == -1 && errno == EINTR);
 
-/* close the driver */
-ff_v4l2_m2m_codec_end(s->avctx);
+ret = ff_v4l2_context_set_status(>output, VIDIOC_STREAMOFF);
+if (ret) {
+av_log(s->avctx, AV_LOG_ERROR, "output VIDIOC_STREAMOFF\n");
+goto error;
+}
+
+ret = ff_v4l2_context_set_status(>capture, VIDIOC_STREAMOFF);
+if (ret) {
+av_log(s->avctx, AV_LOG_ERROR, "capture VIDIOC_STREAMOFF\n");
+goto error;
+}
+
+/* release and unmmap the buffers */
+ff_v4l2_context_release(>output);
+ff_v4l2_context_release(>capture);
 
 /* start again now that we know the stream dimensions */
 s->draining = 0;
 s->reinit = 0;
 
-s->fd = open(s->devname, O_RDWR | O_NONBLOCK, 0);
-if (s->fd < 0)
-return AVERROR(errno);
-
-ret = v4l2_prepare_contexts(s);
-if (ret < 0)
-goto error;
-
-/* if a full re-init was requested - probe didn't run - we need to populate
- * the format for each context
- */
 ret = ff_v4l2_context_get_format(>output);
 if (ret) {
 av_log(log_ctx, AV_LOG_DEBUG, "v4l2 

[FFmpeg-cvslog] avcodec: v4l2_m2m: remove unnecessary timeout.

2018-01-20 Thread Jorge Ramirez-Ortiz
ffmpeg | branch: master | Jorge Ramirez-Ortiz  
| Tue Jan  9 23:56:42 2018 +0100| [5d5de3eba4c7890c2e8077f5b4ae569671d11cf8] | 
committer: Mark Thompson

avcodec: v4l2_m2m: remove unnecessary timeout.

Qualcomm's db410c/db820 Venus driver currently present in mainline
kernel has a bug which mishandles the CMD_STOP requests causing the
decoder to block while draining [1].

This patch removes the workaround that was used to prevent that
situation.

Encoding/Decoding tested on db820c.

[1] on CMD_STOP, the driver is flushing all buffers and never raising
IPIPE which ends up in blocking on poll.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5d5de3eba4c7890c2e8077f5b4ae569671d11cf8
---

 libavcodec/v4l2_buffers.c | 10 ++--
 libavcodec/v4l2_context.c | 61 ---
 2 files changed, 44 insertions(+), 27 deletions(-)

diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c
index 4e68f901b3..8e4d4d1c9f 100644
--- a/libavcodec/v4l2_buffers.c
+++ b/libavcodec/v4l2_buffers.c
@@ -213,8 +213,14 @@ static void v4l2_free_buffer(void *opaque, uint8_t *unused)
 if (s->reinit) {
 if (!atomic_load(>refcount))
 sem_post(>refsync);
-} else if (avbuf->context->streamon)
-ff_v4l2_buffer_enqueue(avbuf);
+} else {
+if (s->draining) {
+/* no need to queue more buffers to the driver */
+avbuf->status = V4L2BUF_AVAILABLE;
+}
+else if (avbuf->context->streamon)
+ff_v4l2_buffer_enqueue(avbuf);
+}
 
 av_buffer_unref(>context_ref);
 }
diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c
index 4c169928fa..dde97d0d1f 100644
--- a/libavcodec/v4l2_context.c
+++ b/libavcodec/v4l2_context.c
@@ -217,6 +217,7 @@ static int v4l2_stop_decode(V4L2Context *ctx)
 {
 struct v4l2_decoder_cmd cmd = {
 .cmd = V4L2_DEC_CMD_STOP,
+.flags = 0,
 };
 int ret;
 
@@ -234,6 +235,7 @@ static int v4l2_stop_encode(V4L2Context *ctx)
 {
 struct v4l2_encoder_cmd cmd = {
 .cmd = V4L2_ENC_CMD_STOP,
+.flags = 0,
 };
 int ret;
 
@@ -256,10 +258,26 @@ static V4L2Buffer* v4l2_dequeue_v4l2buf(V4L2Context *ctx, 
int timeout)
 .events =  POLLIN | POLLRDNORM | POLLPRI | POLLOUT | POLLWRNORM, /* 
default blocking capture */
 .fd = ctx_to_m2mctx(ctx)->fd,
 };
-int ret;
+int i, ret;
+
+/* if we are draining and there are no more capture buffers queued in the 
driver we are done */
+if (!V4L2_TYPE_IS_OUTPUT(ctx->type) && ctx_to_m2mctx(ctx)->draining) {
+for (i = 0; i < ctx->num_buffers; i++) {
+if (ctx->buffers[i].status == V4L2BUF_IN_DRIVER)
+goto start;
+}
+ctx->done = 1;
+return NULL;
+}
 
+start:
 if (V4L2_TYPE_IS_OUTPUT(ctx->type))
 pfd.events =  POLLOUT | POLLWRNORM;
+else {
+/* no need to listen to requests for more input while draining */
+if (ctx_to_m2mctx(ctx)->draining)
+pfd.events =  POLLIN | POLLRDNORM | POLLPRI;
+}
 
 for (;;) {
 ret = poll(, 1, timeout);
@@ -267,11 +285,6 @@ static V4L2Buffer* v4l2_dequeue_v4l2buf(V4L2Context *ctx, 
int timeout)
 break;
 if (errno == EINTR)
 continue;
-
-/* timeout is being used to indicate last valid bufer when draining */
-if (ctx_to_m2mctx(ctx)->draining)
-ctx->done = 1;
-
 return NULL;
 }
 
@@ -286,7 +299,7 @@ static V4L2Buffer* v4l2_dequeue_v4l2buf(V4L2Context *ctx, 
int timeout)
 ret = v4l2_handle_event(ctx);
 if (ret < 0) {
 /* if re-init failed, abort */
-ctx->done = EINVAL;
+ctx->done = 1;
 return NULL;
 }
 if (ret) {
@@ -325,23 +338,25 @@ dequeue:
 ret = ioctl(ctx_to_m2mctx(ctx)->fd, VIDIOC_DQBUF, );
 if (ret) {
 if (errno != EAGAIN) {
-ctx->done = errno;
+ctx->done = 1;
 if (errno != EPIPE)
 av_log(logger(ctx), AV_LOG_DEBUG, "%s VIDIOC_DQBUF, errno 
(%s)\n",
 ctx->name, av_err2str(AVERROR(errno)));
 }
-} else {
-avbuf = >buffers[buf.index];
-avbuf->status = V4L2BUF_AVAILABLE;
-avbuf->buf = buf;
-if (V4L2_TYPE_IS_MULTIPLANAR(ctx->type)) {
-memcpy(avbuf->planes, planes, sizeof(planes));
-avbuf->buf.m.planes = avbuf->planes;
-}
+return NULL;
 }
+
+avbuf = >buffers[buf.index];
+avbuf->status = V4L2BUF_AVAILABLE;
+avbuf->buf = buf;
+if (V4L2_TYPE_IS_MULTIPLANAR(ctx->type)) {
+memcpy(avbuf->planes, planes, sizeof(planes));
+avbuf->buf.m.planes = avbuf->planes;
+}
+return 

[FFmpeg-cvslog] avcodec: v4l2_m2m: context: fix raising warning on POLLERR

2018-01-20 Thread Jorge Ramirez-Ortiz
ffmpeg | branch: master | Jorge Ramirez-Ortiz  
| Tue Jan  9 23:56:43 2018 +0100| [0b9b7f0b46a80b848b19ebbb624cc7dc06bd33b7] | 
committer: Mark Thompson

avcodec: v4l2_m2m: context: fix raising warning on POLLERR

During the initialization stage, the codec attempts to get free
buffers from the driver before any have been queued (this is to keep
the code simple and generic)

When the kernel driver detects this situation, it returns POLLERR in
revents and ffmpeg therefore raises a warning.

This commit disables the warning since no buffers were queued to the
driver yet.

Signed-off-by: Jorge Ramirez-Ortiz 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0b9b7f0b46a80b848b19ebbb624cc7dc06bd33b7
---

 libavcodec/v4l2_context.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c
index dde97d0d1f..e0431b1b3e 100644
--- a/libavcodec/v4l2_context.c
+++ b/libavcodec/v4l2_context.c
@@ -290,7 +290,17 @@ start:
 
 /* 0. handle errors */
 if (pfd.revents & POLLERR) {
-av_log(logger(ctx), AV_LOG_WARNING, "%s POLLERR\n", ctx->name);
+/* if we are trying to get free buffers but none have been queued yet
+   no need to raise a warning */
+if (timeout == 0) {
+for (i = 0; i < ctx->num_buffers; i++) {
+if (ctx->buffers[i].status != V4L2BUF_AVAILABLE)
+av_log(logger(ctx), AV_LOG_WARNING, "%s POLLERR\n", 
ctx->name);
+}
+}
+else
+av_log(logger(ctx), AV_LOG_WARNING, "%s POLLERR\n", ctx->name);
+
 return NULL;
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avfilter/drawtext - implement fix_bounds

2018-01-20 Thread Gyan Doshi
ffmpeg | branch: master | Gyan Doshi  | Thu Jan 11 
18:48:16 2018 +0530| [6c1c6c6c71fc776c6dd25d13861b036dad2cdc1b] | committer: 
Kyle Swanson

avfilter/drawtext - implement fix_bounds

When enabled, text, including effects like shadow or box, will be
completely bound within the video frame.

Default value changed to false to keep continuity of behaviour.

Fixes #6960.

Signed-off-by: Kyle Swanson 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6c1c6c6c71fc776c6dd25d13861b036dad2cdc1b
---

 libavfilter/vf_drawtext.c | 28 +++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index f6151443bb..f97a741b50 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -238,7 +238,7 @@ static const AVOption drawtext_options[]= {
 {"rate","set rate (timecode only)", OFFSET(tc_rate),   
AV_OPT_TYPE_RATIONAL, {.dbl=0},   0,  INT_MAX, FLAGS},
 {"reload", "reload text file for each frame",   
OFFSET(reload), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
 { "alpha",   "apply alpha while rendering", OFFSET(a_expr),  
AV_OPT_TYPE_STRING, { .str = "1" },  .flags = FLAGS },
-{"fix_bounds", "check and fix text coords to avoid clipping", 
OFFSET(fix_bounds), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS},
+{"fix_bounds", "check and fix text coords to avoid clipping", 
OFFSET(fix_bounds), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS},
 {"start_number", "start frame number for n/frame_num variable", 
OFFSET(start_number), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS},
 
 #if CONFIG_LIBFRIBIDI
@@ -1401,6 +1401,32 @@ static int draw_text(AVFilterContext *ctx, AVFrame 
*frame,
 box_w = FFMIN(width - 1 , max_text_line_w);
 box_h = FFMIN(height - 1, y + s->max_glyph_h);
 
+if (s->fix_bounds) {
+
+/* calculate footprint of text effects */
+int boxoffset = s->draw_box ? FFMAX(s->boxborderw, 0) : 0;
+int borderoffset  = s->borderw  ? FFMAX(s->borderw, 0) : 0;
+
+int offsetleft = FFMAX3(boxoffset, borderoffset,
+(s->shadowx < 0 ? FFABS(s->shadowx) : 0));
+int offsettop = FFMAX3(boxoffset, borderoffset,
+(s->shadowy < 0 ? FFABS(s->shadowy) : 0));
+
+int offsetright = FFMAX3(boxoffset, borderoffset,
+ (s->shadowx > 0 ? s->shadowx : 0));
+int offsetbottom = FFMAX3(boxoffset, borderoffset,
+  (s->shadowy > 0 ? s->shadowy : 0));
+
+
+if (s->x - offsetleft < 0) s->x = offsetleft;
+if (s->y - offsettop < 0)  s->y = offsettop;
+
+if (s->x + box_w + offsetright > width)
+s->x = FFMAX(width - box_w - offsetright, 0);
+if (s->y + box_h + offsetbottom > height)
+s->y = FFMAX(height - box_h - offsetbottom, 0);
+}
+
 /* draw box */
 if (s->draw_box)
 ff_blend_rectangle(>dc, ,

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec/ulti: Check number of blocks at init

2018-01-20 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Jan 15 19:03:48 2018 +0100| [725353525e73bbe5b6b4d01528252675f2417a02] | 
committer: Michael Niedermayer

avcodec/ulti: Check number of blocks at init

Fixes: Timeout
Fixes: 4832/clusterfuzz-testcase-4699096590843904

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=725353525e73bbe5b6b4d01528252675f2417a02
---

 libavcodec/ulti.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/ulti.c b/libavcodec/ulti.c
index e6f4374981..9e4c088b10 100644
--- a/libavcodec/ulti.c
+++ b/libavcodec/ulti.c
@@ -50,6 +50,8 @@ static av_cold int ulti_decode_init(AVCodecContext *avctx)
 s->width = avctx->width;
 s->height = avctx->height;
 s->blocks = (s->width / 8) * (s->height / 8);
+if (s->blocks == 0)
+return AVERROR_INVALIDDATA;
 avctx->pix_fmt = AV_PIX_FMT_YUV410P;
 s->ulti_codebook = ulti_codebook;
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec/snowdec: Fix integer overflow before htaps check

2018-01-20 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Jan 15 03:03:36 2018 +0100| [2eecf3cf8eeae67697934df326e98df2149881e5] | 
committer: Michael Niedermayer

avcodec/snowdec: Fix integer overflow before htaps check

Fixes: runtime error: signed integer overflow: -1094995529 * 2 cannot be 
represented in type 'int'
Fixes: 4828/clusterfuzz-testcase-minimized-5100849937252352

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2eecf3cf8eeae67697934df326e98df2149881e5
---

 libavcodec/snowdec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c
index a9bdb8da5e..0146a2a4c9 100644
--- a/libavcodec/snowdec.c
+++ b/libavcodec/snowdec.c
@@ -363,9 +363,10 @@ static int decode_header(SnowContext *s){
 int htaps, i, sum=0;
 Plane *p= >plane[plane_index];
 p->diag_mc= get_rac(>c, s->header_state);
-htaps= get_symbol(>c, s->header_state, 0)*2 + 2;
-if((unsigned)htaps >= HTAPS_MAX || htaps==0)
+htaps= get_symbol(>c, s->header_state, 0);
+if((unsigned)htaps >= HTAPS_MAX/2 - 1)
 return AVERROR_INVALIDDATA;
+htaps = htaps*2 + 2;
 p->htaps= htaps;
 for(i= htaps/2; i; i--){
 p->hcoeff[i]= get_symbol(>c, s->header_state, 0) * 
(1-2*(i&1));

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avformat/lrcdec: Fix memory leak in lrc_read_header()

2018-01-20 Thread Nikolas Bowe
ffmpeg | branch: master | Nikolas Bowe  | Fri 
Jan 19 13:17:07 2018 -0800| [ef5994e09d07ace62a672fcdc84761231288edad] | 
committer: Michael Niedermayer

avformat/lrcdec: Fix memory leak in lrc_read_header()

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ef5994e09d07ace62a672fcdc84761231288edad
---

 libavformat/lrcdec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/lrcdec.c b/libavformat/lrcdec.c
index 12f74b22a0..f4e9a4efa9 100644
--- a/libavformat/lrcdec.c
+++ b/libavformat/lrcdec.c
@@ -212,6 +212,7 @@ static int lrc_read_header(AVFormatContext *s)
 }
 ff_subtitles_queue_finalize(s, >q);
 ff_metadata_conv_ctx(s, NULL, ff_lrc_metadata_conv);
+av_bprint_finalize(, NULL);
 return 0;
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] x86inc: Support creating global symbols from local labels

2018-01-20 Thread Henrik Gramner
ffmpeg | branch: master | Henrik Gramner  | Wed Aug 16 
15:59:16 2017 +0200| [6b6edd121699a87c17bd5eca9e94cdd125088c0e] | committer: 
Henrik Gramner

x86inc: Support creating global symbols from local labels

On ELF platforms such symbols needs to be flagged as functions with the
correct visibility to please certain linkers in some scenarios.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6b6edd121699a87c17bd5eca9e94cdd125088c0e
---

 libavutil/x86/x86inc.asm | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm
index 57cd4d80de..de048f863d 100644
--- a/libavutil/x86/x86inc.asm
+++ b/libavutil/x86/x86inc.asm
@@ -4,9 +4,9 @@
 ;* Copyright (C) 2005-2017 x264 project
 ;*
 ;* Authors: Loren Merritt 
+;*  Henrik Gramner 
 ;*  Anton Mitrofanov 
 ;*  Fiona Glaser 
-;*  Henrik Gramner 
 ;*
 ;* Permission to use, copy, modify, and/or distribute this software for any
 ;* purpose with or without fee is hereby granted, provided that the above
@@ -743,6 +743,16 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, 
jge, jng, jnge, ja, jae,
 %endif
 %endmacro
 
+; Create a global symbol from a local label with the correct name mangling and 
type
+%macro cglobal_label 1
+%if FORMAT_ELF
+global current_function %+ %1:function hidden
+%else
+global current_function %+ %1
+%endif
+%1:
+%endmacro
+
 %macro cextern 1
 %xdefine %1 mangle(private_prefix %+ _ %+ %1)
 CAT_XDEFINE cglobaled_, %1, 1

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] x86inc: Use .rdata instead of .rodata on Windows

2018-01-20 Thread Henrik Gramner
ffmpeg | branch: master | Henrik Gramner  | Tue Aug 15 
16:11:32 2017 +0200| [9e4b3675f226238ae132cada2bb82bcb00110aa6] | committer: 
Henrik Gramner

x86inc: Use .rdata instead of .rodata on Windows

The standard section for read-only data on Windows is .rdata. Nasm will
flag non-standard sections as executable by default which isn't ideal.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9e4b3675f226238ae132cada2bb82bcb00110aa6
---

 libavutil/x86/x86inc.asm | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm
index 3b43dbc2e0..57cd4d80de 100644
--- a/libavutil/x86/x86inc.asm
+++ b/libavutil/x86/x86inc.asm
@@ -90,6 +90,10 @@
 SECTION .text
 %elifidn __OUTPUT_FORMAT__,coff
 SECTION .text
+%elifidn __OUTPUT_FORMAT__,win32
+SECTION .rdata align=%1
+%elif WIN64
+SECTION .rdata align=%1
 %else
 SECTION .rodata align=%1
 %endif

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] x86inc: Enable AVX emulation for floating-point pseudo-instructions

2018-01-20 Thread Henrik Gramner
ffmpeg | branch: master | Henrik Gramner  | Sat Aug  5 
00:09:52 2017 +0200| [3a02cbe3faccad9e346d63cf40c009e664657304] | committer: 
Henrik Gramner

x86inc: Enable AVX emulation for floating-point pseudo-instructions

There are 32 pseudo-instructions for each floating-point comparison
instruction, but only 8 of them are actually valid in legacy-encoded mode.
The remaining 24 requires the use of VEX-encoded (v-prefixed) instructions
and can therefore be disregarded for this purpose.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3a02cbe3faccad9e346d63cf40c009e664657304
---

 libavutil/x86/x86inc.asm | 32 
 1 file changed, 32 insertions(+)

diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm
index 196374c348..3b43dbc2e0 100644
--- a/libavutil/x86/x86inc.asm
+++ b/libavutil/x86/x86inc.asm
@@ -1297,10 +1297,42 @@ AVX_INSTR blendpd, sse4, 1, 1, 0
 AVX_INSTR blendps, sse4, 1, 1, 0
 AVX_INSTR blendvpd, sse4 ; can't be emulated
 AVX_INSTR blendvps, sse4 ; can't be emulated
+AVX_INSTR cmpeqpd, sse2, 1, 0, 1
+AVX_INSTR cmpeqps, sse, 1, 0, 1
+AVX_INSTR cmpeqsd, sse2, 1, 0, 0
+AVX_INSTR cmpeqss, sse, 1, 0, 0
+AVX_INSTR cmplepd, sse2, 1, 0, 0
+AVX_INSTR cmpleps, sse, 1, 0, 0
+AVX_INSTR cmplesd, sse2, 1, 0, 0
+AVX_INSTR cmpless, sse, 1, 0, 0
+AVX_INSTR cmpltpd, sse2, 1, 0, 0
+AVX_INSTR cmpltps, sse, 1, 0, 0
+AVX_INSTR cmpltsd, sse2, 1, 0, 0
+AVX_INSTR cmpltss, sse, 1, 0, 0
+AVX_INSTR cmpneqpd, sse2, 1, 0, 1
+AVX_INSTR cmpneqps, sse, 1, 0, 1
+AVX_INSTR cmpneqsd, sse2, 1, 0, 0
+AVX_INSTR cmpneqss, sse, 1, 0, 0
+AVX_INSTR cmpnlepd, sse2, 1, 0, 0
+AVX_INSTR cmpnleps, sse, 1, 0, 0
+AVX_INSTR cmpnlesd, sse2, 1, 0, 0
+AVX_INSTR cmpnless, sse, 1, 0, 0
+AVX_INSTR cmpnltpd, sse2, 1, 0, 0
+AVX_INSTR cmpnltps, sse, 1, 0, 0
+AVX_INSTR cmpnltsd, sse2, 1, 0, 0
+AVX_INSTR cmpnltss, sse, 1, 0, 0
+AVX_INSTR cmpordpd, sse2 1, 0, 1
+AVX_INSTR cmpordps, sse 1, 0, 1
+AVX_INSTR cmpordsd, sse2 1, 0, 0
+AVX_INSTR cmpordss, sse 1, 0, 0
 AVX_INSTR cmppd, sse2, 1, 1, 0
 AVX_INSTR cmpps, sse, 1, 1, 0
 AVX_INSTR cmpsd, sse2, 1, 1, 0
 AVX_INSTR cmpss, sse, 1, 1, 0
+AVX_INSTR cmpunordpd, sse2, 1, 0, 1
+AVX_INSTR cmpunordps, sse, 1, 0, 1
+AVX_INSTR cmpunordsd, sse2, 1, 0, 0
+AVX_INSTR cmpunordss, sse, 1, 0, 0
 AVX_INSTR comisd, sse2
 AVX_INSTR comiss, sse
 AVX_INSTR cvtdq2pd, sse2

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] x86inc: Correctly set mmreg variables

2018-01-20 Thread Henrik Gramner
ffmpeg | branch: master | Henrik Gramner  | Sat Jan  6 
17:47:42 2018 +0100| [eb5f063e7ccc93062a70faac2402a533bb9669fd] | committer: 
Henrik Gramner

x86inc: Correctly set mmreg variables

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eb5f063e7ccc93062a70faac2402a533bb9669fd
---

 libavutil/x86/x86inc.asm | 87 
 1 file changed, 36 insertions(+), 51 deletions(-)

diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm
index de048f863d..438863042f 100644
--- a/libavutil/x86/x86inc.asm
+++ b/libavutil/x86/x86inc.asm
@@ -1,7 +1,7 @@
 ;*
 ;* x86inc.asm: x264asm abstraction layer
 ;*
-;* Copyright (C) 2005-2017 x264 project
+;* Copyright (C) 2005-2018 x264 project
 ;*
 ;* Authors: Loren Merritt 
 ;*  Henrik Gramner 
@@ -892,6 +892,36 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, 
jge, jng, jnge, ja, jae,
 %undef %1%2
 %endmacro
 
+%macro DEFINE_MMREGS 1 ; mmtype
+%assign %%prev_mmregs 0
+%ifdef num_mmregs
+%assign %%prev_mmregs num_mmregs
+%endif
+
+%assign num_mmregs 8
+%if ARCH_X86_64 && mmsize >= 16
+%assign num_mmregs 16
+%if cpuflag(avx512) || mmsize == 64
+%assign num_mmregs 32
+%endif
+%endif
+
+%assign %%i 0
+%rep num_mmregs
+CAT_XDEFINE m, %%i, %1 %+ %%i
+CAT_XDEFINE nn%1, %%i, %%i
+%assign %%i %%i+1
+%endrep
+%if %%prev_mmregs > num_mmregs
+%rep %%prev_mmregs - num_mmregs
+CAT_UNDEF m, %%i
+CAT_UNDEF nn %+ mmtype, %%i
+%assign %%i %%i+1
+%endrep
+%endif
+%xdefine mmtype %1
+%endmacro
+
 ; Prefer registers 16-31 over 0-15 to avoid having to use vzeroupper
 %macro AVX512_MM_PERMUTATION 0-1 0 ; start_reg
 %if ARCH_X86_64 && cpuflag(avx512)
@@ -908,23 +938,12 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, 
jge, jng, jnge, ja, jae,
 %assign avx_enabled 0
 %define RESET_MM_PERMUTATION INIT_MMX %1
 %define mmsize 8
-%define num_mmregs 8
 %define mova movq
 %define movu movq
 %define movh movd
 %define movnta movntq
-%assign %%i 0
-%rep 8
-CAT_XDEFINE m, %%i, mm %+ %%i
-CAT_XDEFINE nnmm, %%i, %%i
-%assign %%i %%i+1
-%endrep
-%rep 24
-CAT_UNDEF m, %%i
-CAT_UNDEF nnmm, %%i
-%assign %%i %%i+1
-%endrep
 INIT_CPUFLAGS %1
+DEFINE_MMREGS mm
 %endmacro
 
 %macro INIT_XMM 0-1+
@@ -936,22 +955,9 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, 
jge, jng, jnge, ja, jae,
 %define movh movq
 %define movnta movntdq
 INIT_CPUFLAGS %1
-%define num_mmregs 8
-%if ARCH_X86_64
-%define num_mmregs 16
-%if cpuflag(avx512)
-%define num_mmregs 32
-%endif
-%endif
-%assign %%i 0
-%rep num_mmregs
-CAT_XDEFINE m, %%i, xmm %+ %%i
-CAT_XDEFINE nnxmm, %%i, %%i
-%assign %%i %%i+1
-%endrep
+DEFINE_MMREGS xmm
 %if WIN64
-; Swap callee-saved registers with volatile registers
-AVX512_MM_PERMUTATION 6
+AVX512_MM_PERMUTATION 6 ; Swap callee-saved registers with volatile 
registers
 %endif
 %endmacro
 
@@ -964,19 +970,7 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, 
jge, jng, jnge, ja, jae,
 %undef movh
 %define movnta movntdq
 INIT_CPUFLAGS %1
-%define num_mmregs 8
-%if ARCH_X86_64
-%define num_mmregs 16
-%if cpuflag(avx512)
-%define num_mmregs 32
-%endif
-%endif
-%assign %%i 0
-%rep num_mmregs
-CAT_XDEFINE m, %%i, ymm %+ %%i
-CAT_XDEFINE nnymm, %%i, %%i
-%assign %%i %%i+1
-%endrep
+DEFINE_MMREGS ymm
 AVX512_MM_PERMUTATION
 %endmacro
 
@@ -984,21 +978,12 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, 
jge, jng, jnge, ja, jae,
 %assign avx_enabled 1
 %define RESET_MM_PERMUTATION INIT_ZMM %1
 %define mmsize 64
-%define num_mmregs 8
-%if ARCH_X86_64
-%define num_mmregs 32
-%endif
 %define mova movdqa
 %define movu movdqu
 %undef movh
 %define movnta movntdq
-%assign %%i 0
-%rep num_mmregs
-CAT_XDEFINE m, %%i, zmm %+ %%i
-CAT_XDEFINE nnzmm, %%i, %%i
-%assign %%i %%i+1
-%endrep
 INIT_CPUFLAGS %1
+DEFINE_MMREGS zmm
 AVX512_MM_PERMUTATION
 %endmacro
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] x86inc: Drop cpuflags_slowctz

2018-01-20 Thread Henrik Gramner
ffmpeg | branch: master | Henrik Gramner  | Thu Jan 18 
23:20:33 2018 +0100| [6f62b0bd4ff2bd4333d899b697f82643d14ff560] | committer: 
Henrik Gramner

x86inc: Drop cpuflags_slowctz

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6f62b0bd4ff2bd4333d899b697f82643d14ff560
---

 libavutil/x86/x86inc.asm | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm
index 438863042f..5044ee86f0 100644
--- a/libavutil/x86/x86inc.asm
+++ b/libavutil/x86/x86inc.asm
@@ -827,9 +827,8 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, jge, 
jng, jnge, ja, jae,
 
 %assign cpuflags_cache32  (1<<21)
 %assign cpuflags_cache64  (1<<22)
-%assign cpuflags_slowctz  (1<<23)
-%assign cpuflags_aligned  (1<<24) ; not a cpu feature, but a function variant
-%assign cpuflags_atom (1<<25)
+%assign cpuflags_aligned  (1<<23) ; not a cpu feature, but a function variant
+%assign cpuflags_atom (1<<24)
 
 ; Returns a boolean value expressing whether or not the specified cpuflag is 
enabled.
 %definecpuflag(x) (cpuflags & (cpuflags_ %+ x)) ^ (cpuflags_ %+ x)) - 
1) >> 31) & 1)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avdevice/decklink: addition of absolute wallclock option for pts source

2018-01-20 Thread Vishwanath Dixit
ffmpeg | branch: master | Vishwanath Dixit  | Mon Jan 15 
14:10:26 2018 +0530| [fc93eca126aa4d68dd37c3e1b9d15bf05565ef04] | committer: 
Marton Balint

avdevice/decklink: addition of absolute wallclock option for pts source

Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fc93eca126aa4d68dd37c3e1b9d15bf05565ef04
---

 doc/indevs.texi |  6 --
 libavdevice/decklink_common_c.h |  1 +
 libavdevice/decklink_dec.cpp| 16 
 libavdevice/decklink_dec_c.c|  1 +
 libavdevice/version.h   |  2 +-
 5 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index 36aef49108..0bc8e6a9b1 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -298,11 +298,13 @@ Sets the audio input source. Must be @samp{unset}, 
@samp{embedded},
 
 @item video_pts
 Sets the video packet timestamp source. Must be @samp{video}, @samp{audio},
-@samp{reference} or @samp{wallclock}. Defaults to @samp{video}.
+@samp{reference}, @samp{wallclock} or @samp{abs_wallclock}.
+Defaults to @samp{video}.
 
 @item audio_pts
 Sets the audio packet timestamp source. Must be @samp{video}, @samp{audio},
-@samp{reference} or @samp{wallclock}. Defaults to @samp{audio}.
+@samp{reference}, @samp{wallclock} or @samp{abs_wallclock}.
+Defaults to @samp{audio}.
 
 @item draw_bars
 If set to @samp{true}, color bars are drawn in the event of a signal loss.
diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h
index 18097e2d5f..08e9f9bbd5 100644
--- a/libavdevice/decklink_common_c.h
+++ b/libavdevice/decklink_common_c.h
@@ -28,6 +28,7 @@ typedef enum DecklinkPtsSource {
 PTS_SRC_VIDEO = 2,
 PTS_SRC_REFERENCE = 3,
 PTS_SRC_WALLCLOCK = 4,
+PTS_SRC_ABS_WALLCLOCK = 5,
 PTS_SRC_NB
 } DecklinkPtsSource;
 
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 1fd40caaf5..a69e28680b 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -585,6 +585,7 @@ ULONG decklink_input_callback::Release(void)
 static int64_t get_pkt_pts(IDeckLinkVideoInputFrame *videoFrame,
IDeckLinkAudioInputPacket *audioFrame,
int64_t wallclock,
+   int64_t abs_wallclock,
DecklinkPtsSource pts_src,
AVRational time_base, int64_t *initial_pts,
int copyts)
@@ -607,13 +608,18 @@ static int64_t get_pkt_pts(IDeckLinkVideoInputFrame 
*videoFrame,
 res = videoFrame->GetHardwareReferenceTimestamp(time_base.den, 
_pts, _duration);
 break;
 case PTS_SRC_WALLCLOCK:
+/* fall through */
+case PTS_SRC_ABS_WALLCLOCK:
 {
 /* MSVC does not support compound literals like AV_TIME_BASE_Q
  * in C++ code (compiler error C4576) */
 AVRational timebase;
 timebase.num = 1;
 timebase.den = AV_TIME_BASE;
-pts = av_rescale_q(wallclock, timebase, time_base);
+if (pts_src == PTS_SRC_WALLCLOCK)
+pts = av_rescale_q(wallclock, timebase, time_base);
+else
+pts = av_rescale_q(abs_wallclock, timebase, time_base);
 break;
 }
 }
@@ -637,7 +643,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
 void *audioFrameBytes;
 BMDTimeValue frameTime;
 BMDTimeValue frameDuration;
-int64_t wallclock = 0;
+int64_t wallclock = 0, abs_wallclock = 0;
 struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
 
 if (ctx->autodetect) {
@@ -652,6 +658,8 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
 ctx->frameCount++;
 if (ctx->audio_pts_source == PTS_SRC_WALLCLOCK || ctx->video_pts_source == 
PTS_SRC_WALLCLOCK)
 wallclock = av_gettime_relative();
+if (ctx->audio_pts_source == PTS_SRC_ABS_WALLCLOCK || 
ctx->video_pts_source == PTS_SRC_ABS_WALLCLOCK)
+abs_wallclock = av_gettime();
 
 // Handle Video Frame
 if (videoFrame) {
@@ -698,7 +706,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
 no_video = 0;
 }
 
-pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, 
ctx->video_pts_source, ctx->video_st->time_base, _video_pts, 
cctx->copyts);
+pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, 
abs_wallclock, ctx->video_pts_source, ctx->video_st->time_base, 
_video_pts, cctx->copyts);
 pkt.dts = pkt.pts;
 
 pkt.duration = frameDuration;
@@ -789,7 +797,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
 pkt.size = audioFrame->GetSampleFrameCount() * 
ctx->audio_st->codecpar->channels * (ctx->audio_depth / 8);
 audioFrame->GetBytes();
 audioFrame->GetPacketTime(_pts, ctx->audio_st->time_base.den);
-pkt.pts = 

[FFmpeg-cvslog] avdevice/decklink: Fix compilation of module on OSX

2018-01-20 Thread Devin Heitmueller
ffmpeg | branch: master | Devin Heitmueller  | Mon 
Jan  8 20:16:58 2018 -0500| [b5b48685043e4761335c4ab7086eba3b24a9c03d] | 
committer: Marton Balint

avdevice/decklink: Fix compilation of module on OSX

Clang applies the missing-prototypes warning on C++ files, whereas
gcc only applies it to C.  As a result, the decklink_common.cpp file
fails to build because of missing prototypes in DecklinkDispatch.cpp
(which is #included by decklink_common.cpp).

We don't want to change the actual Blackmagic SDK sources, so
suppress the warning just for that one #include.

Signed-off-by: Devin Heitmueller 
Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b5b48685043e4761335c4ab7086eba3b24a9c03d
---

 libavdevice/decklink_common.cpp | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index 6ef2c529f4..d1576b8553 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -29,7 +29,18 @@ extern "C" {
 #ifdef _WIN32
 #include 
 #else
+/* The file provided by the SDK is known to be missing prototypes, which 
doesn't
+   cause issues with GCC since the warning doesn't apply to C++ files.  However
+   Clang does complain (and warnings are treated as errors), so suppress the
+   warning just for this one file */
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wmissing-prototypes"
+#endif
 #include 
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
 #endif
 
 extern "C" {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avdevice/decklink: addition of PTS_SRC_NB in enum DecklinkPtsSource

2018-01-20 Thread Vishwanath Dixit
ffmpeg | branch: master | Vishwanath Dixit  | Mon Jan 15 
14:10:11 2018 +0530| [dfa2523bdd820348634325edaf6e3ae2afb8c218] | committer: 
Marton Balint

avdevice/decklink: addition of PTS_SRC_NB in enum DecklinkPtsSource

Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dfa2523bdd820348634325edaf6e3ae2afb8c218
---

 libavdevice/decklink_common_c.h | 1 +
 libavdevice/decklink_dec_c.c| 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h
index ac6563a317..18097e2d5f 100644
--- a/libavdevice/decklink_common_c.h
+++ b/libavdevice/decklink_common_c.h
@@ -28,6 +28,7 @@ typedef enum DecklinkPtsSource {
 PTS_SRC_VIDEO = 2,
 PTS_SRC_REFERENCE = 3,
 PTS_SRC_WALLCLOCK = 4,
+PTS_SRC_NB
 } DecklinkPtsSource;
 
 struct decklink_cctx {
diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c
index f65b177276..accae53050 100644
--- a/libavdevice/decklink_dec_c.c
+++ b/libavdevice/decklink_dec_c.c
@@ -64,8 +64,8 @@ static const AVOption options[] = {
 { "analog_xlr",NULL,  0,  
AV_OPT_TYPE_CONST, { .i64 = 4}, 0, 0,DEC, "audio_input"},
 { "analog_rca",NULL,  0,  
AV_OPT_TYPE_CONST, { .i64 = 5}, 0, 0,DEC, "audio_input"},
 { "microphone",NULL,  0,  
AV_OPT_TYPE_CONST, { .i64 = 6}, 0, 0,DEC, "audio_input"},
-{ "audio_pts", "audio pts source",   OFFSET(audio_pts_source),
AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_AUDIO}, 1, 4, DEC, "pts_source"},
-{ "video_pts", "video pts source",   OFFSET(video_pts_source),
AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_VIDEO}, 1, 4, DEC, "pts_source"},
+{ "audio_pts", "audio pts source",   OFFSET(audio_pts_source),
AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_AUDIO}, 1, PTS_SRC_NB-1, DEC, 
"pts_source"},
+{ "video_pts", "video pts source",   OFFSET(video_pts_source),
AV_OPT_TYPE_INT,   { .i64 = PTS_SRC_VIDEO}, 1, PTS_SRC_NB-1, DEC, 
"pts_source"},
 { "audio", NULL,  0,  
AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_AUDIO}, 0, 0, DEC, "pts_source"},
 { "video", NULL,  0,  
AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_VIDEO}, 0, 0, DEC, "pts_source"},
 { "reference", NULL,  0,  
AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_REFERENCE}, 0, 0, DEC, "pts_source"},

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avdevice/decklink: Suppress warning about misuse of struct instead of class

2018-01-20 Thread Devin Heitmueller
ffmpeg | branch: master | Devin Heitmueller  | Mon 
Jan  8 20:16:56 2018 -0500| [5409f065f2c48ad9c4baf787d08384176cbc62a4] | 
committer: Marton Balint

avdevice/decklink: Suppress warning about misuse of struct instead of class

When building with Clang, the following warning is shown:

warning: struct 'IDeckLinkVideoFrame' was previously declared as a
class [-Wmismatched-tags]

The function incorrectly casts IDeckLinkVideoFrame as a struct
instead of a class pointer.

Signed-off-by: Devin Heitmueller 
Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5409f065f2c48ad9c4baf787d08384176cbc62a4
---

 libavdevice/decklink_enc.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp
index c06ca4668f..89b03f2bd5 100644
--- a/libavdevice/decklink_enc.cpp
+++ b/libavdevice/decklink_enc.cpp
@@ -321,7 +321,7 @@ static int decklink_write_video_packet(AVFormatContext 
*avctx, AVPacket *pkt)
 pthread_mutex_unlock(>mutex);
 
 /* Schedule frame for playback. */
-hr = ctx->dlo->ScheduleVideoFrame((struct IDeckLinkVideoFrame *) frame,
+hr = ctx->dlo->ScheduleVideoFrame((class IDeckLinkVideoFrame *) frame,
   pkt->pts * ctx->bmd_tb_num,
   ctx->bmd_tb_num, ctx->bmd_tb_den);
 /* Pass ownership to DeckLink, or release on failure */

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avdevice/decklink: addition of copyts option

2018-01-20 Thread Vishwanath Dixit
ffmpeg | branch: master | Vishwanath Dixit  | Mon Jan 15 
14:09:46 2018 +0530| [7c27bbd590e6d9da5b7b33163e7dce7876ef2b58] | committer: 
Marton Balint

avdevice/decklink: addition of copyts option

Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7c27bbd590e6d9da5b7b33163e7dce7876ef2b58
---

 doc/indevs.texi |  5 +
 libavdevice/decklink_common_c.h |  1 +
 libavdevice/decklink_dec.cpp| 18 +++---
 libavdevice/decklink_dec_c.c|  1 +
 4 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index 56066bf23a..36aef49108 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -317,6 +317,11 @@ Defaults to @samp{1073741824}.
 Sets the audio sample bit depth. Must be @samp{16} or @samp{32}.
 Defaults to @samp{16}.
 
+@item decklink_copyts
+If set to @option{true}, timestamps are forwarded as they are without removing
+the initial offset.
+Defaults to @option{false}.
+
 @end table
 
 @subsection Examples
diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h
index 368ac259e4..ac6563a317 100644
--- a/libavdevice/decklink_common_c.h
+++ b/libavdevice/decklink_common_c.h
@@ -52,6 +52,7 @@ struct decklink_cctx {
 char *format_code;
 int raw_format;
 int64_t queue_size;
+int copyts;
 };
 
 #endif /* AVDEVICE_DECKLINK_COMMON_C_H */
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 94dae26003..1fd40caaf5 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -586,7 +586,8 @@ static int64_t get_pkt_pts(IDeckLinkVideoInputFrame 
*videoFrame,
IDeckLinkAudioInputPacket *audioFrame,
int64_t wallclock,
DecklinkPtsSource pts_src,
-   AVRational time_base, int64_t *initial_pts)
+   AVRational time_base, int64_t *initial_pts,
+   int copyts)
 {
 int64_t pts = AV_NOPTS_VALUE;
 BMDTimeValue bmd_pts;
@@ -619,10 +620,12 @@ static int64_t get_pkt_pts(IDeckLinkVideoInputFrame 
*videoFrame,
 if (res == S_OK)
 pts = bmd_pts / time_base.num;
 
-if (pts != AV_NOPTS_VALUE && *initial_pts == AV_NOPTS_VALUE)
-*initial_pts = pts;
-if (*initial_pts != AV_NOPTS_VALUE)
-pts -= *initial_pts;
+if (!copyts) {
+if (pts != AV_NOPTS_VALUE && *initial_pts == AV_NOPTS_VALUE)
+*initial_pts = pts;
+if (*initial_pts != AV_NOPTS_VALUE)
+pts -= *initial_pts;
+}
 
 return pts;
 }
@@ -635,6 +638,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
 BMDTimeValue frameTime;
 BMDTimeValue frameDuration;
 int64_t wallclock = 0;
+struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
 
 if (ctx->autodetect) {
 if (videoFrame && !(videoFrame->GetFlags() & bmdFrameHasNoInputSource) 
&&
@@ -694,7 +698,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
 no_video = 0;
 }
 
-pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, 
ctx->video_pts_source, ctx->video_st->time_base, _video_pts);
+pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, 
ctx->video_pts_source, ctx->video_st->time_base, _video_pts, 
cctx->copyts);
 pkt.dts = pkt.pts;
 
 pkt.duration = frameDuration;
@@ -785,7 +789,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
 pkt.size = audioFrame->GetSampleFrameCount() * 
ctx->audio_st->codecpar->channels * (ctx->audio_depth / 8);
 audioFrame->GetBytes();
 audioFrame->GetPacketTime(_pts, ctx->audio_st->time_base.den);
-pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, 
ctx->audio_pts_source, ctx->audio_st->time_base, _audio_pts);
+pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, 
ctx->audio_pts_source, ctx->audio_st->time_base, _audio_pts, 
cctx->copyts);
 pkt.dts = pkt.pts;
 
 //fprintf(stderr,"Audio Frame size %d ts %d\n", pkt.size, pkt.pts);
diff --git a/libavdevice/decklink_dec_c.c b/libavdevice/decklink_dec_c.c
index 1c6d826945..f65b177276 100644
--- a/libavdevice/decklink_dec_c.c
+++ b/libavdevice/decklink_dec_c.c
@@ -73,6 +73,7 @@ static const AVOption options[] = {
 { "draw_bars", "draw bars on signal loss" , OFFSET(draw_bars),
AV_OPT_TYPE_BOOL,  { .i64 = 1}, 0, 1, DEC },
 { "queue_size","input queue buffer size",   OFFSET(queue_size),   
AV_OPT_TYPE_INT64, { .i64 = (1024 * 1024 * 1024)}, 0, INT64_MAX, DEC },
 { "audio_depth",   "audio bitdepth (16 or 32)", OFFSET(audio_depth),  
AV_OPT_TYPE_INT,   { .i64 = 16}, 16, 32, DEC },
+{ "decklink_copyts", "copy timestamps, do not remove the initial offset", 
OFFSET(copyts), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
 { NULL },
 };
 

___

[FFmpeg-cvslog] avfilter/formats: remove support for deprecated channel count specification

2018-01-20 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Sat Jan  6 22:04:21 
2018 +0100| [e3acba0d5d7b5b35b779b25ec3a76a4d80a405ea] | committer: Marton 
Balint

avfilter/formats: remove support for deprecated channel count specification

Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e3acba0d5d7b5b35b779b25ec3a76a4d80a405ea
---

 libavfilter/formats.c | 12 ++--
 tests/ref/fate/filter-formats |  2 +-
 2 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 20a2c89719..31ee445c49 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -662,20 +662,12 @@ int ff_parse_sample_rate(int *ret, const char *arg, void 
*log_ctx)
 int ff_parse_channel_layout(int64_t *ret, int *nret, const char *arg,
 void *log_ctx)
 {
-char *tail;
 int64_t chlayout;
 int nb_channels;
 
 if (av_get_extended_channel_layout(arg, , _channels) < 0) {
-/* [TEMPORARY 2016-12 -> 2017-12]*/
-nb_channels = strtol(arg, , 10);
-if (!errno && *tail == 'c' && *(tail + 1) == '\0' && nb_channels > 0 
&& nb_channels < 64) {
-chlayout = 0;
-av_log(log_ctx, AV_LOG_WARNING, "Deprecated channel count 
specification '%s'. This will stop working in releases made in 2018 and 
after.\n", arg);
-} else {
-av_log(log_ctx, AV_LOG_ERROR, "Invalid channel layout '%s'\n", 
arg);
-return AVERROR(EINVAL);
-}
+av_log(log_ctx, AV_LOG_ERROR, "Invalid channel layout '%s'\n", arg);
+return AVERROR(EINVAL);
 }
 if (!chlayout && !nret) {
 av_log(log_ctx, AV_LOG_ERROR, "Unknown channel layout '%s' is not 
supported.\n", arg);
diff --git a/tests/ref/fate/filter-formats b/tests/ref/fate/filter-formats
index ea85eed23d..17ff5b222f 100644
--- a/tests/ref/fate/filter-formats
+++ b/tests/ref/fate/filter-formats
@@ -75,7 +75,7 @@ quad(side)
 0 = ff_parse_channel_layout(0004,  1, 1c);
 0 = ff_parse_channel_layout(0003,  2, 2c);
 -1 = ff_parse_channel_layout(, -1, -1c);
-0 = ff_parse_channel_layout(, 60, 60c);
+-1 = ff_parse_channel_layout(, -1, 60c);
 -1 = ff_parse_channel_layout(, -1, 65c);
 0 = ff_parse_channel_layout(,  2, 2C);
 0 = ff_parse_channel_layout(, 60, 60C);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] lavf/swfdec: Reduce score when auto-detecting swf files.

2018-01-20 Thread Carl Eugen Hoyos
ffmpeg | branch: master | Carl Eugen Hoyos  | Thu Jan 18 
21:25:49 2018 +0100| [7652af9df06ddcdb6f6fdf52919c2d6260b51ca1] | committer: 
Carl Eugen Hoyos

lavf/swfdec: Reduce score when auto-detecting swf files.

Not more than 32bit are tested.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7652af9df06ddcdb6f6fdf52919c2d6260b51ca1
---

 libavformat/swfdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
index 57b619fb20..212157f54a 100644
--- a/libavformat/swfdec.c
+++ b/libavformat/swfdec.c
@@ -95,7 +95,7 @@ static int swf_probe(AVProbeData *p)
 if (p->buf[3] >= 20 || xmax < 16 || ymax < 16)
 return AVPROBE_SCORE_MAX / 4;
 
-return AVPROBE_SCORE_MAX;
+return AVPROBE_SCORE_EXTENSION + 1;
 }
 
 #if CONFIG_ZLIB

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog