Re: [FFmpeg-devel] [PATCH 2/5] avformat/ffmdec: replace most codec uses by codecpar

2016-12-02 Thread Michael Niedermayer
On Sat, Dec 03, 2016 at 12:57:49AM +0100, Hendrik Leppkes wrote:
> On Sat, Dec 3, 2016 at 12:52 AM, Michael Niedermayer
>  wrote:
> > This is a bit messy as codecar does not support AVOptions so we need
> > to use AVCodecContext where AVOptions are required and copy back and forth.
> >
> 

> ffmenc can't really write any data that doesn't go into codecpar
> either, since thats all muxers get for stream info, so is this really
> required? Where do these come from?

ffmenc takes the string from AVStream.recommended_encoder_configuration
and stores it, ffmdec reads it back into
AVStream.recommended_encoder_configuration

It is just needed to make sure codecpar matches this, which would be
easier if AVOptions would work with codecpar as then it could be
directly set from the string description.

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/5] avformat/ffmdec: replace most codec uses by codecpar

2016-12-02 Thread Andreas Cadhalpun
On 03.12.2016 00:52, Michael Niedermayer wrote:
> This is a bit messy as codecar does not support AVOptions so we need
> to use AVCodecContext where AVOptions are required and copy back and forth.
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/ffmdec.c | 159 
> ++-
>  1 file changed, 82 insertions(+), 77 deletions(-)
> 
> diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
> index 9192bff507..25edeebb7e 100644
> --- a/libavformat/ffmdec.c
> +++ b/libavformat/ffmdec.c
> @@ -250,11 +250,6 @@ static void adjust_write_index(AVFormatContext *s)
>  
>  static int ffm_close(AVFormatContext *s)
>  {
> -int i;
> -
> -for (i = 0; i < s->nb_streams; i++)
> -av_freep(>streams[i]->codec->rc_eq);
> -
>  return 0;
>  }

Why not remove the entire function?

> @@ -514,9 +518,6 @@ static int ffm2_read_header(AVFormatContext *s)
>  avio_seek(pb, next, SEEK_SET);
>  }
>  
> -for (i = 0; i < s->nb_streams; i++)
> -avcodec_parameters_from_context(s->streams[i]->codecpar, 
> s->streams[i]->codec);
> -

This loop is the only place the variable i is used, so please remove it's
declaration, too.

> @@ -539,7 +542,8 @@ static int ffm_read_header(AVFormatContext *s)
>  FFMContext *ffm = s->priv_data;
>  AVStream *st;
>  AVIOContext *pb = s->pb;
> -AVCodecContext *codec;
> +AVCodecContext *codec, *dummy_codec = NULL;
> +AVCodecParameters *codecpar;
>  const AVCodecDescriptor *codec_desc;
>  int i, nb_streams, ret;
>  uint32_t tag;
> @@ -562,6 +566,7 @@ static int ffm_read_header(AVFormatContext *s)
>  } else {
>  ffm->file_size = (UINT64_C(1) << 63) - 1;
>  }
> +dummy_codec = avcodec_alloc_context3(NULL);
>  
>  nb_streams = avio_rb32(pb);
>  avio_rb32(pb); /* total bitrate */
> @@ -577,31 +582,31 @@ static int ffm_read_header(AVFormatContext *s)
>  
>  codec = st->codec;

Here should be:
   codecpar = st->codecpar;

>  /* generic info */
> -codec->codec_id = avio_rb32(pb);
> -codec_desc = avcodec_descriptor_get(codec->codec_id);
> +codecpar->codec_id = avio_rb32(pb);

Otherwise codecpar is uninitialized here.

Best regards,
Andreas

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


Re: [FFmpeg-devel] [PATCH 1/5] avformat/ffmdec: Remove some st->codec uses which set encoder parameters

2016-12-02 Thread Andreas Cadhalpun
On 03.12.2016 00:52, Michael Niedermayer wrote:
> Modern ffserver should not need these
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/ffmdec.c | 148 
> +--
>  1 file changed, 74 insertions(+), 74 deletions(-)
> 
> diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
> index 960e793220..9192bff507 100644
> --- a/libavformat/ffmdec.c
> +++ b/libavformat/ffmdec.c
> @@ -405,51 +405,51 @@ static int ffm2_read_header(AVFormatContext *s)
>  ret = av_image_check_size(codec->width, codec->height, 0, s);
>  if (ret < 0)
>  goto fail;
> -codec->gop_size = avio_rb16(pb);
> +avio_rb16(pb);

Please add a comment like /* gop_size */ here and similar ones below.
Otherwise it'll be rather mysterious what's the point of all these avio_rb* 
calls.

Best regards,
Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/5] avformat/ffmdec: replace most codec uses by codecpar

2016-12-02 Thread Hendrik Leppkes
On Sat, Dec 3, 2016 at 12:52 AM, Michael Niedermayer
 wrote:
> This is a bit messy as codecar does not support AVOptions so we need
> to use AVCodecContext where AVOptions are required and copy back and forth.
>

ffmenc can't really write any data that doesn't go into codecpar
either, since thats all muxers get for stream info, so is this really
required? Where do these come from?

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


Re: [FFmpeg-devel] [PATCH] avformat/utils: fix crashes in has_decode_delay_been_guessed

2016-12-02 Thread Michael Niedermayer
On Fri, Dec 02, 2016 at 05:05:29PM +0100, Timo Rothenpieler wrote:
> > Is it just me or is this completely inconsistent?
> > the codec id told to the user is h264 while we internally use a
> > mpeg2 decoder to analyze it ?
> > 
> > If its h264 (as forced by the user) we should use a h264 decoder
> > to internally analyze it
> > 
> 
> Yes, something is very wrong here.
> I also wasn't able to reproduce this with any self made sample. Only the
> one from Ticket 5985 makes it crash for me. In two separate ways even.
> In one case, the avctx->codec is NULL, because there are unknown codecs
> in that sample, and in other cases the codecs mismatch.
> 
> I don't have time to take an in depth look at what is going on there, so
> for now I decided to harden it against crashes, which is probably a good
> idea in any case.

I dont think its a good idea to leave the inconsistency


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 4/5] ffserver: remove one avcodec_context_copy()

2016-12-02 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 ffserver.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ffserver.c b/ffserver.c
index 19c3ceda1a..3ff761f68f 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -2854,7 +2854,8 @@ static int http_receive_data(HTTPContext *c)
 for (i = 0; i < s->nb_streams; i++) {
 LayeredAVStream *fst = feed->streams[i];
 AVStream *st = s->streams[i];
-avcodec_copy_context(fst->codec, st->codec);
+avcodec_parameters_to_context(fst->codec, st->codecpar);
+avcodec_parameters_from_context(fst->codecpar, fst->codec);
 }
 
 avformat_close_input();
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 2/5] avformat/ffmdec: replace most codec uses by codecpar

2016-12-02 Thread Michael Niedermayer
This is a bit messy as codecar does not support AVOptions so we need
to use AVCodecContext where AVOptions are required and copy back and forth.

Signed-off-by: Michael Niedermayer 
---
 libavformat/ffmdec.c | 159 ++-
 1 file changed, 82 insertions(+), 77 deletions(-)

diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index 9192bff507..25edeebb7e 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -250,11 +250,6 @@ static void adjust_write_index(AVFormatContext *s)
 
 static int ffm_close(AVFormatContext *s)
 {
-int i;
-
-for (i = 0; i < s->nb_streams; i++)
-av_freep(>streams[i]->codec->rc_eq);
-
 return 0;
 }
 
@@ -281,7 +276,7 @@ static int ffm_append_recommended_configuration(AVStream 
*st, char **conf)
 
 #define VALIDATE_PARAMETER(parameter, name, check) {   
   \
 if (check) {   
   \
-av_log(codec, AV_LOG_ERROR, "Invalid " name " %d\n", 
codec->parameter);   \
+av_log(codec, AV_LOG_ERROR, "Invalid " name " %d\n", 
codecpar->parameter);   \
 ret = AVERROR_INVALIDDATA; 
   \
 goto fail; 
   \
 }  
   \
@@ -292,7 +287,8 @@ static int ffm2_read_header(AVFormatContext *s)
 FFMContext *ffm = s->priv_data;
 AVStream *st;
 AVIOContext *pb = s->pb;
-AVCodecContext *codec;
+AVCodecContext *codec, *dummy_codec = NULL;
+AVCodecParameters *codecpar;
 const AVCodecDescriptor *codec_desc;
 int ret, i;
 int f_main = 0, f_cprv = -1, f_stvi = -1, f_stau = -1;
@@ -316,6 +312,7 @@ static int ffm2_read_header(AVFormatContext *s)
 } else {
 ffm->file_size = (UINT64_C(1) << 63) - 1;
 }
+dummy_codec = avcodec_alloc_context3(NULL);
 
 while(!avio_feof(pb)) {
 unsigned id = avio_rb32(pb);
@@ -346,27 +343,28 @@ static int ffm2_read_header(AVFormatContext *s)
 avpriv_set_pts_info(st, 64, 1, 100);
 
 codec = st->codec;
+codecpar = st->codecpar;
 /* generic info */
-codec->codec_id = avio_rb32(pb);
-codec_desc = avcodec_descriptor_get(codec->codec_id);
+codecpar->codec_id = avio_rb32(pb);
+codec_desc = avcodec_descriptor_get(codecpar->codec_id);
 if (!codec_desc) {
-av_log(s, AV_LOG_ERROR, "Invalid codec id: %d\n", 
codec->codec_id);
-codec->codec_id = AV_CODEC_ID_NONE;
+av_log(s, AV_LOG_ERROR, "Invalid codec id: %d\n", 
codecpar->codec_id);
+codecpar->codec_id = AV_CODEC_ID_NONE;
 ret = AVERROR_INVALIDDATA;
 goto fail;
 }
-codec->codec_type = avio_r8(pb);
-if (codec->codec_type != codec_desc->type) {
+codecpar->codec_type = avio_r8(pb);
+if (codecpar->codec_type != codec_desc->type) {
 av_log(s, AV_LOG_ERROR, "Codec type mismatch: expected %d, 
found %d\n",
-   codec_desc->type, codec->codec_type);
-codec->codec_id = AV_CODEC_ID_NONE;
-codec->codec_type = AVMEDIA_TYPE_UNKNOWN;
+   codec_desc->type, codecpar->codec_type);
+codecpar->codec_id = AV_CODEC_ID_NONE;
+codecpar->codec_type = AVMEDIA_TYPE_UNKNOWN;
 ret = AVERROR_INVALIDDATA;
 goto fail;
 }
-codec->bit_rate = avio_rb32(pb);
-if (codec->bit_rate < 0) {
-av_log(codec, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", 
codec->bit_rate);
+codecpar->bit_rate = avio_rb32(pb);
+if (codecpar->bit_rate < 0) {
+av_log(codec, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", 
codecpar->bit_rate);
 ret = AVERROR_INVALIDDATA;
 goto fail;
 }
@@ -380,11 +378,11 @@ static int ffm2_read_header(AVFormatContext *s)
 ret = AVERROR_INVALIDDATA;
 goto fail;
 }
-codec->extradata = av_mallocz(size + 
AV_INPUT_BUFFER_PADDING_SIZE);
-if (!codec->extradata)
+codecpar->extradata = av_mallocz(size + 
AV_INPUT_BUFFER_PADDING_SIZE);
+if (!codecpar->extradata)
 return AVERROR(ENOMEM);
-codec->extradata_size = size;
-avio_read(pb, codec->extradata, size);
+codecpar->extradata_size = size;
+avio_read(pb, codecpar->extradata, size);
 }
 break;
 case MKBETAG('S', 'T', 'V', 'I'):
@@ -400,16 +398,16 @@ static int ffm2_read_header(AVFormatContext *s)
 

[FFmpeg-devel] [PATCH 5/5] avformat/ffmdec: remove last use of st->codec

2016-12-02 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavformat/ffmdec.c | 32 +---
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index f3497e2b24..9b9373eae5 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -276,7 +276,7 @@ static int ffm_append_recommended_configuration(AVStream 
*st, char **conf)
 
 #define VALIDATE_PARAMETER(parameter, name, check) {   
   \
 if (check) {   
   \
-av_log(codec, AV_LOG_ERROR, "Invalid " name " %d\n", 
codecpar->parameter);   \
+av_log(s, AV_LOG_ERROR, "Invalid " name " %d\n", codecpar->parameter); 
  \
 ret = AVERROR_INVALIDDATA; 
   \
 goto fail; 
   \
 }  
   \
@@ -287,7 +287,7 @@ static int ffm2_read_header(AVFormatContext *s)
 FFMContext *ffm = s->priv_data;
 AVStream *st;
 AVIOContext *pb = s->pb;
-AVCodecContext *codec, *dummy_codec = NULL;
+AVCodecContext *dummy_codec = NULL;
 AVCodecParameters *codecpar;
 const AVCodecDescriptor *codec_desc;
 int ret, i;
@@ -319,6 +319,7 @@ static int ffm2_read_header(AVFormatContext *s)
 unsigned size = avio_rb32(pb);
 int64_t next = avio_tell(pb) + size;
 char rc_eq_buf[128];
+int flags;
 
 if(!id)
 break;
@@ -342,7 +343,6 @@ static int ffm2_read_header(AVFormatContext *s)
 
 avpriv_set_pts_info(st, 64, 1, 100);
 
-codec = st->codec;
 codecpar = st->codecpar;
 /* generic info */
 codecpar->codec_id = avio_rb32(pb);
@@ -364,14 +364,19 @@ static int ffm2_read_header(AVFormatContext *s)
 }
 codecpar->bit_rate = avio_rb32(pb);
 if (codecpar->bit_rate < 0) {
-av_log(codec, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", 
codecpar->bit_rate);
+av_log(s, AV_LOG_ERROR, "Invalid bit rate %"PRId64"\n", 
codecpar->bit_rate);
 ret = AVERROR_INVALIDDATA;
 goto fail;
 }
-codec->flags = avio_rb32(pb);
+flags = avio_rb32(pb);
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+st->codec->flags = flags;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 avio_rb32(pb);
 avio_rb32(pb);
-if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
+if (flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
 int size = avio_rb32(pb);
 if (size < 0 || size >= FF_MAX_EXTRADATA_SIZE) {
 av_log(s, AV_LOG_ERROR, "Invalid extradata size %d\n", 
size);
@@ -536,7 +541,7 @@ static int ffm_read_header(AVFormatContext *s)
 FFMContext *ffm = s->priv_data;
 AVStream *st;
 AVIOContext *pb = s->pb;
-AVCodecContext *codec, *dummy_codec = NULL;
+AVCodecContext *dummy_codec = NULL;
 AVCodecParameters *codecpar;
 const AVCodecDescriptor *codec_desc;
 int i, nb_streams, ret;
@@ -567,6 +572,7 @@ static int ffm_read_header(AVFormatContext *s)
 /* read each stream */
 for(i=0;icodec;
 /* generic info */
 codecpar->codec_id = avio_rb32(pb);
 codec_desc = avcodec_descriptor_get(codecpar->codec_id);
@@ -593,10 +598,15 @@ static int ffm_read_header(AVFormatContext *s)
 }
 codecpar->bit_rate = avio_rb32(pb);
 if (codecpar->bit_rate < 0) {
-av_log(codec, AV_LOG_WARNING, "Invalid bit rate %"PRId64"\n", 
codecpar->bit_rate);
+av_log(s, AV_LOG_WARNING, "Invalid bit rate %"PRId64"\n", 
codecpar->bit_rate);
 goto fail;
 }
-codec->flags = avio_rb32(pb);
+flags = avio_rb32(pb);
+#if FF_API_LAVF_AVCTX
+FF_DISABLE_DEPRECATION_WARNINGS
+st->codec->flags = flags;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 avio_rb32(pb);
 avio_rb32(pb);
 /* specific info */
@@ -665,7 +675,7 @@ static int ffm_read_header(AVFormatContext *s)
 default:
 goto fail;
 }
-if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
+if (flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
 int size = avio_rb32(pb);
 if (size < 0 || size >= FF_MAX_EXTRADATA_SIZE) {
 av_log(s, AV_LOG_ERROR, "Invalid extradata size %d\n", size);
-- 
2.11.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

[FFmpeg-devel] [PATCH 3/5] avformat/ffmdec: Drop flags2, debug and codec->time_base setting

2016-12-02 Thread Michael Niedermayer
It should still be possible to set these through 
recommended_encoder_configuration

Signed-off-by: Michael Niedermayer 
---
 libavformat/ffmdec.c | 27 ---
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index 25edeebb7e..f3497e2b24 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -369,8 +369,8 @@ static int ffm2_read_header(AVFormatContext *s)
 goto fail;
 }
 codec->flags = avio_rb32(pb);
-codec->flags2 = avio_rb32(pb);
-codec->debug = avio_rb32(pb);
+avio_rb32(pb);
+avio_rb32(pb);
 if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
 int size = avio_rb32(pb);
 if (size < 0 || size >= FF_MAX_EXTRADATA_SIZE) {
@@ -390,14 +390,8 @@ static int ffm2_read_header(AVFormatContext *s)
 ret = AVERROR(EINVAL);
 goto fail;
 }
-codec->time_base.num = avio_rb32(pb);
-codec->time_base.den = avio_rb32(pb);
-if (codec->time_base.num <= 0 || codec->time_base.den <= 0) {
-av_log(s, AV_LOG_ERROR, "Invalid time base %d/%d\n",
-   codec->time_base.num, codec->time_base.den);
-ret = AVERROR_INVALIDDATA;
-goto fail;
-}
+avio_rb32(pb);
+avio_rb32(pb);
 codecpar->width = avio_rb16(pb);
 codecpar->height = avio_rb16(pb);
 ret = av_image_check_size(codecpar->width, codecpar->height, 0, s);
@@ -603,18 +597,13 @@ static int ffm_read_header(AVFormatContext *s)
 goto fail;
 }
 codec->flags = avio_rb32(pb);
-codec->flags2 = avio_rb32(pb);
-codec->debug = avio_rb32(pb);
+avio_rb32(pb);
+avio_rb32(pb);
 /* specific info */
 switch(codecpar->codec_type) {
 case AVMEDIA_TYPE_VIDEO:
-codec->time_base.num = avio_rb32(pb);
-codec->time_base.den = avio_rb32(pb);
-if (codec->time_base.num <= 0 || codec->time_base.den <= 0) {
-av_log(s, AV_LOG_ERROR, "Invalid time base %d/%d\n",
-   codec->time_base.num, codec->time_base.den);
-goto fail;
-}
+avio_rb32(pb);
+avio_rb32(pb);
 codecpar->width = avio_rb16(pb);
 codecpar->height = avio_rb16(pb);
 if (av_image_check_size(codecpar->width, codecpar->height, 0, s) < 
0)
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 1/5] avformat/ffmdec: Remove some st->codec uses which set encoder parameters

2016-12-02 Thread Michael Niedermayer
Modern ffserver should not need these

Signed-off-by: Michael Niedermayer 
---
 libavformat/ffmdec.c | 148 +--
 1 file changed, 74 insertions(+), 74 deletions(-)

diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index 960e793220..9192bff507 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -405,51 +405,51 @@ static int ffm2_read_header(AVFormatContext *s)
 ret = av_image_check_size(codec->width, codec->height, 0, s);
 if (ret < 0)
 goto fail;
-codec->gop_size = avio_rb16(pb);
+avio_rb16(pb);
 codec->pix_fmt = avio_rb32(pb);
 if (!av_pix_fmt_desc_get(codec->pix_fmt)) {
 av_log(s, AV_LOG_ERROR, "Invalid pix fmt id: %d\n", 
codec->pix_fmt);
 codec->pix_fmt = AV_PIX_FMT_NONE;
 goto fail;
 }
-codec->qmin = avio_r8(pb);
-codec->qmax = avio_r8(pb);
-codec->max_qdiff = avio_r8(pb);
-codec->qcompress = avio_rb16(pb) / 1.0;
-codec->qblur = avio_rb16(pb) / 1.0;
-codec->bit_rate_tolerance = avio_rb32(pb);
+avio_r8(pb);
+avio_r8(pb);
+avio_r8(pb);
+avio_rb16(pb);
+avio_rb16(pb);
+avio_rb32(pb);
 avio_get_str(pb, INT_MAX, rc_eq_buf, sizeof(rc_eq_buf));
-codec->rc_eq = av_strdup(rc_eq_buf);
-codec->rc_max_rate = avio_rb32(pb);
-codec->rc_min_rate = avio_rb32(pb);
-codec->rc_buffer_size = avio_rb32(pb);
-codec->i_quant_factor = av_int2double(avio_rb64(pb));
-codec->b_quant_factor = av_int2double(avio_rb64(pb));
-codec->i_quant_offset = av_int2double(avio_rb64(pb));
-codec->b_quant_offset = av_int2double(avio_rb64(pb));
-codec->dct_algo = avio_rb32(pb);
-codec->strict_std_compliance = avio_rb32(pb);
-codec->max_b_frames = avio_rb32(pb);
-codec->mpeg_quant = avio_rb32(pb);
-codec->intra_dc_precision = avio_rb32(pb);
-codec->me_method = avio_rb32(pb);
-codec->mb_decision = avio_rb32(pb);
-codec->nsse_weight = avio_rb32(pb);
-codec->frame_skip_cmp = avio_rb32(pb);
-codec->rc_buffer_aggressivity = av_int2double(avio_rb64(pb));
+
+avio_rb32(pb);
+avio_rb32(pb);
+avio_rb32(pb);
+avio_rb64(pb);
+avio_rb64(pb);
+avio_rb64(pb);
+avio_rb64(pb);
+avio_rb32(pb);
+avio_rb32(pb);
+avio_rb32(pb);
+avio_rb32(pb);
+avio_rb32(pb);
+avio_rb32(pb);
+avio_rb32(pb);
+avio_rb32(pb);
+avio_rb32(pb);
+avio_rb64(pb);
 codec->codec_tag = avio_rb32(pb);
-codec->thread_count = avio_r8(pb);
-codec->coder_type = avio_rb32(pb);
-codec->me_cmp = avio_rb32(pb);
-codec->me_subpel_quality = avio_rb32(pb);
-codec->me_range = avio_rb32(pb);
-codec->keyint_min = avio_rb32(pb);
-codec->scenechange_threshold = avio_rb32(pb);
-codec->b_frame_strategy = avio_rb32(pb);
-codec->qcompress = av_int2double(avio_rb64(pb));
-codec->qblur = av_int2double(avio_rb64(pb));
-codec->max_qdiff = avio_rb32(pb);
-codec->refs = avio_rb32(pb);
+avio_r8(pb);
+avio_rb32(pb);
+avio_rb32(pb);
+avio_rb32(pb);
+avio_rb32(pb);
+avio_rb32(pb);
+avio_rb32(pb);
+avio_rb32(pb);
+avio_rb64(pb);
+avio_rb64(pb);
+avio_rb32(pb);
+avio_rb32(pb);
 break;
 case MKBETAG('S', 'T', 'A', 'U'):
 if (f_stau++) {
@@ -614,51 +614,51 @@ static int ffm_read_header(AVFormatContext *s)
 codec->height = avio_rb16(pb);
 if (av_image_check_size(codec->width, codec->height, 0, s) < 0)
 goto fail;
-codec->gop_size = avio_rb16(pb);
+avio_rb16(pb);
 codec->pix_fmt = avio_rb32(pb);
 if (!av_pix_fmt_desc_get(codec->pix_fmt)) {
 av_log(s, AV_LOG_ERROR, "Invalid pix fmt id: %d\n", 
codec->pix_fmt);
 codec->pix_fmt = AV_PIX_FMT_NONE;
 goto fail;
 }
-codec->qmin = avio_r8(pb);
-codec->qmax = avio_r8(pb);
-codec->max_qdiff = avio_r8(pb);
-codec->qcompress = avio_rb16(pb) / 1.0;
-codec->qblur = avio_rb16(pb) / 1.0;
-codec->bit_rate_tolerance = avio_rb32(pb);
+avio_r8(pb);
+avio_r8(pb);
+avio_r8(pb);
+avio_rb16(pb);
+

Re: [FFmpeg-devel] [PATCH] movenc: Tag files generated with strict experimental with a warning

2016-12-02 Thread wm4
On Fri, 2 Dec 2016 17:17:23 -0300
James Almer  wrote:

> On 12/2/2016 5:00 PM, Vittorio Giovara wrote:
> > This will simplify identifying files that were generated with
> > unfinished/incomplete/non-standard specifications.
> > 
> > Signed-off-by: Vittorio Giovara 
> > ---
> >  libavformat/movenc.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> > index dc19838..c46bea9 100644
> > --- a/libavformat/movenc.c
> > +++ b/libavformat/movenc.c
> > @@ -5756,6 +5756,7 @@ static int mov_init(AVFormatContext *s)
> > FF_COMPLIANCE_EXPERIMENTAL);
> >  return AVERROR_EXPERIMENTAL;
> >  }
> > +av_dict_set(>metadata, "WARNING", "This file was 
> > generated using an unfinished specification, please don't modify your 
> > demuxer to support it, should it not work", 0);
> >  }
> >  } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
> >  track->timescale = st->codecpar->sample_rate;
> > @@ -5802,6 +5803,7 @@ static int mov_init(AVFormatContext *s)
> > FF_COMPLIANCE_EXPERIMENTAL);
> >  return AVERROR_EXPERIMENTAL;
> >  }
> > +av_dict_set(>metadata, "WARNING", "This file was 
> > generated using an unfinished specification, please don't modify your 
> > demuxer to support it, should it not work", 0);
> >  }
> >  } else if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
> >  track->timescale = st->time_base.den;  
> 
> Maybe lavf and lavc should add "experimental" to the container and
> stream's metadata alongside the library version, much like how we're
> adding the name of the encoder alongside the lavc version to the
> stream's metadata.
> 
> A warning printed by the muxer not going to help once such a file
> is in the wild.

This patch or the suggestion above sounds like a good idea. I wish it'd
actually be possible to encode a watermark with the warning into the
video stream.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/3] configure: fail if autodetect-libraries are requested but not found

2016-12-02 Thread Andreas Cadhalpun
On 02.12.2016 19:20, Michael Niedermayer wrote:
> On Fri, Dec 02, 2016 at 12:44:41AM +0100, Andreas Cadhalpun wrote:
>> There is already va_va_h in vaapi_deps and I'm not sure, what else
>> you'd like to have there.
> 
> i see a "disable vaapi" here but that should be done by the dependency
> or why is it done here ?

Now I see what you mean.

>> However, it seems independent of this patch.
> 
> yes
> 
> 
> iam ok with the patch if other are and its tested

I've tested for all AUTODETECT_LIBS that enabling the when configure
doesn't find them triggers a configure failure after the patch.
I've also check for a few libs that all combinations of --enable,
--disable, no configure flag and library installed or not does the
right thing.

Do you think there is something else that should be tested?

Best regards,
Andreas

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


Re: [FFmpeg-devel] [PATCH 1/6] tests/ffserver.regression.ref: Update ffserver checksums

2016-12-02 Thread Andreas Cadhalpun
On 02.12.2016 04:27, Michael Niedermayer wrote:
> On Fri, Dec 02, 2016 at 12:59:41AM +0100, Andreas Cadhalpun wrote:
>> The test is unfortunately not very reproducible.
>> Right now I'm getting varying values like on one run:
>> -0c9639f09decbc54c9f091dcf1ca0e8f *ff-test_h.avi
>> -e28ba75853caf975e06d92955c9f7f73 *ff-test_l.avi
>> -a767dbdf5d1bded3450279f812f97b37 *ff-test.swf
>> +81c49d1bfcd43bcc43aa6aeed081126f *ff-test_h.avi
>> +2d642fbb77276ed1d12bf235a6a6bd57 *ff-test_l.avi
>> +daeee6c1418c5b2dcddded9b659e9fc2 *ff-test.swf

These files are truncated, probably because ffserver hadn't fully
started yet. Maybe the 'sleep 2' should be increased or a better
way to determine ffserver's readiness can be found?

>> And on the next:
>> -0c9639f09decbc54c9f091dcf1ca0e8f *ff-test_h.avi
>> -e28ba75853caf975e06d92955c9f7f73 *ff-test_l.avi
>> +5e7fc3d0b2f4866866ae4f268dc431ca *ff-test_h.avi
>> +6cc80ab0caec9499d1b82cd01fe7a861 *ff-test_l.avi
>>
>> I've no idea what the underlying problem is.
> 
> it works here almost always i remember just one failure

The bigger problem is that I almost always get the 5e/6c files,
but not once got the checksums you added.

> but you could try to use diff the ffprobe output showing as much as
> ffprobe supports to see what differs.
> binary compare (if they match in size) or ffmpeg -c copy -f framecrc -
> 
> also please upload some different files somewhere

As they're quite small, I've just attached the 5e/6c files to this mail.
Maybe you can figure out where the difference comes from, when you compare
them with the files you get.

> it also could be some timeout issue if you have a slow box and maybe
> run this under valgrind

It's not a particularly slow box, but when run under valgrind, the 2
seconds sleep is definitely not long enough, but with 5 seconds I also
get the 5e/6c files.

Best regards,
Andreas


ff-test_h.avi
Description: MS Video


ff-test_l.avi
Description: MS Video
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] configure: add -fPIE instead of -pie to C flags for ThreadSanitizer

2016-12-02 Thread Wan-Teh Chang
-pie was added to C flags for ThreadSanitizer in commit
19f251a2882a8d0779b432e63bf282e4d9c443bb. Under clang 3.8.0, the -pie
flag causes a compiler warning and a linker error when running configure
--toolchain=clang-tsan. Here is an excerpt from config.log:

clang ... -fsanitize=thread -pie -std=c11 -fomit-frame-pointer -pthread -c -o 
/tmp/ffconf.hL61stP9.o /tmp/ffconf.YO6ZaSFG.c
clang: warning: argument unused during compilation: '-pie'
clang -fsanitize=thread -pie -Wl,--as-needed -Wl,-z,noexecstack -o 
/tmp/ffconf.W5c2e41l /tmp/ffconf.hL61stP9.o -lbz2 -pthread
/usr/bin/ld: /tmp/ffconf.hL61stP9.o: relocation R_X86_64_PC32 against undefined 
symbol `atan2f@@GLIBC_2.2.5' can not be used when making a shared object; 
recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
clang: error: linker command failed with exit code 1 (use -v to see invocation)

To be conservative, I changed -pie to -fPIE. But the documentation seems
to imply just -fsanitize=thread is enough:

http://clang.llvm.org/docs/ThreadSanitizer.html
https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual

Signed-off-by: Wan-Teh Chang 
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index ee473b9..0e1ae61 100755
--- a/configure
+++ b/configure
@@ -3523,7 +3523,7 @@ case "$toolchain" in
 ;;
 *-tsan)
 cc_default="${toolchain%-tsan}"
-add_cflags  -fsanitize=thread -pie
+add_cflags  -fsanitize=thread -fPIE
 add_ldflags -fsanitize=thread -pie
 case "$toolchain" in
 gcc-tsan)
-- 
2.8.0.rc3.226.g39d4020

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


Re: [FFmpeg-devel] [PATCH] movenc: Tag files generated with strict experimental with a warning

2016-12-02 Thread James Almer
On 12/2/2016 5:00 PM, Vittorio Giovara wrote:
> This will simplify identifying files that were generated with
> unfinished/incomplete/non-standard specifications.
> 
> Signed-off-by: Vittorio Giovara 
> ---
>  libavformat/movenc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index dc19838..c46bea9 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -5756,6 +5756,7 @@ static int mov_init(AVFormatContext *s)
> FF_COMPLIANCE_EXPERIMENTAL);
>  return AVERROR_EXPERIMENTAL;
>  }
> +av_dict_set(>metadata, "WARNING", "This file was 
> generated using an unfinished specification, please don't modify your demuxer 
> to support it, should it not work", 0);
>  }
>  } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
>  track->timescale = st->codecpar->sample_rate;
> @@ -5802,6 +5803,7 @@ static int mov_init(AVFormatContext *s)
> FF_COMPLIANCE_EXPERIMENTAL);
>  return AVERROR_EXPERIMENTAL;
>  }
> +av_dict_set(>metadata, "WARNING", "This file was 
> generated using an unfinished specification, please don't modify your demuxer 
> to support it, should it not work", 0);
>  }
>  } else if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
>  track->timescale = st->time_base.den;

Maybe lavf and lavc should add "experimental" to the container and
stream's metadata alongside the library version, much like how we're
adding the name of the encoder alongside the lavc version to the
stream's metadata.

A warning printed by the muxer not going to help once such a file
is in the wild.

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


[FFmpeg-devel] [PATCH] swresample/resample: do not rebuild filter when sample_delta is zero

2016-12-02 Thread Muhammad Faiz
Signed-off-by: Muhammad Faiz 
---
 libswresample/resample.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libswresample/resample.c b/libswresample/resample.c
index e65a57a..71dffb9 100644
--- a/libswresample/resample.c
+++ b/libswresample/resample.c
@@ -449,7 +449,7 @@ static int 
rebuild_filter_bank_with_compensation(ResampleContext *c)
 static int set_compensation(ResampleContext *c, int sample_delta, int 
compensation_distance){
 int ret;
 
-if (compensation_distance) {
+if (compensation_distance && sample_delta) {
 ret = rebuild_filter_bank_with_compensation(c);
 if (ret < 0)
 return ret;
-- 
2.5.0

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


[FFmpeg-devel] [PATCH] movenc: Tag files generated with strict experimental with a warning

2016-12-02 Thread Vittorio Giovara
This will simplify identifying files that were generated with
unfinished/incomplete/non-standard specifications.

Signed-off-by: Vittorio Giovara 
---
 libavformat/movenc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index dc19838..c46bea9 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5756,6 +5756,7 @@ static int mov_init(AVFormatContext *s)
FF_COMPLIANCE_EXPERIMENTAL);
 return AVERROR_EXPERIMENTAL;
 }
+av_dict_set(>metadata, "WARNING", "This file was generated 
using an unfinished specification, please don't modify your demuxer to support 
it, should it not work", 0);
 }
 } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
 track->timescale = st->codecpar->sample_rate;
@@ -5802,6 +5803,7 @@ static int mov_init(AVFormatContext *s)
FF_COMPLIANCE_EXPERIMENTAL);
 return AVERROR_EXPERIMENTAL;
 }
+av_dict_set(>metadata, "WARNING", "This file was generated 
using an unfinished specification, please don't modify your demuxer to support 
it, should it not work", 0);
 }
 } else if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) {
 track->timescale = st->time_base.den;
-- 
2.10.0

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


Re: [FFmpeg-devel] [PATCH 1/4] Add a compat stdatomic.h implementation based on windows atomics

2016-12-02 Thread James Almer
On 11/29/2016 9:12 AM, wm4 wrote:
> On Mon, 28 Nov 2016 15:29:53 -0800
> Wan-Teh Chang  wrote:
> 
>> From: Anton Khirnov 
>>
>> Adapted from the code by Rémi Denis-Courmont from VLC
>>
>> This merges libav commit c2755864afadfbaa349e8d583665c86fe99fa90b.
>>
>> Signed-off-by: Wan-Teh Chang 
>> ---
> 
> Patchset seems ok. No changes to the actual ffmpeg code yet. I assume
> the patches are unchanged from Libav.

Patchset applied.

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


Re: [FFmpeg-devel] [PATCH] avformat/matroskadec: use mastering display metadata's own alloc function

2016-12-02 Thread James Almer
On 12/2/2016 4:43 PM, wm4 wrote:
> On Fri,  2 Dec 2016 16:09:25 -0300
> James Almer  wrote:
> 
>> Signed-off-by: James Almer 
>> ---
>>  libavformat/matroskadec.c | 14 +-
>>  1 file changed, 9 insertions(+), 5 deletions(-)
>>
>> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
>> index 017a533..7b070ff 100644
>> --- a/libavformat/matroskadec.c
>> +++ b/libavformat/matroskadec.c
>> @@ -1841,14 +1841,11 @@ static int mkv_parse_video_color(AVStream *st, const 
>> MatroskaTrack *track) {
>>  // Use similar rationals as other standards.
>>  const int chroma_den = 5;
>>  const int luma_den = 1;
>> -AVMasteringDisplayMetadata *metadata =
>> -(AVMasteringDisplayMetadata*) av_stream_new_side_data(
>> -st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
>> -sizeof(AVMasteringDisplayMetadata));
>> +int ret;
>> +AVMasteringDisplayMetadata *metadata = 
>> av_mastering_display_metadata_alloc();
>>  if (!metadata) {
>>  return AVERROR(ENOMEM);
>>  }
>> -memset(metadata, 0, sizeof(AVMasteringDisplayMetadata));
> 
> ok...
> 
>>  if (has_mastering_primaries) {
>>  metadata->display_primaries[0][0] = av_make_q(
>>  round(mastering_meta->r_x * chroma_den), chroma_den);
>> @@ -1875,6 +1872,13 @@ static int mkv_parse_video_color(AVStream *st, const 
>> MatroskaTrack *track) {
>>  round(mastering_meta->min_luminance * luma_den), luma_den);
>>  metadata->has_luminance = 1;
>>  }
>> +
>> +ret = av_stream_add_side_data(st, 
>> AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
>> +  (uint8_t *)metadata, 
>> sizeof(AVMasteringDisplayMetadata));
>> +if (ret < 0) {
>> +av_freep();
>> +return ret;
>> +}
>>  }
>>  return 0;
>>  }
> 
> Uh what? Am I missing something, or do you rely on
> sizeof(AVMasteringDisplayMetadata) being part of the ABI? Because the
> alloc function only exists because the struct size is not part of the
> ABI.

I know, i mentioned as much in another email. Notice how sizeof() is
already being used above, in the code I'm removing.

This is mostly cosmetic, until either the size of the struct is defined
as public or a new function that returns said size is introduced.

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


Re: [FFmpeg-devel] [PATCH] avformat/matroskadec: use mastering display metadata's own alloc function

2016-12-02 Thread wm4
On Fri,  2 Dec 2016 16:09:25 -0300
James Almer  wrote:

> Signed-off-by: James Almer 
> ---
>  libavformat/matroskadec.c | 14 +-
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 017a533..7b070ff 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -1841,14 +1841,11 @@ static int mkv_parse_video_color(AVStream *st, const 
> MatroskaTrack *track) {
>  // Use similar rationals as other standards.
>  const int chroma_den = 5;
>  const int luma_den = 1;
> -AVMasteringDisplayMetadata *metadata =
> -(AVMasteringDisplayMetadata*) av_stream_new_side_data(
> -st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
> -sizeof(AVMasteringDisplayMetadata));
> +int ret;
> +AVMasteringDisplayMetadata *metadata = 
> av_mastering_display_metadata_alloc();
>  if (!metadata) {
>  return AVERROR(ENOMEM);
>  }
> -memset(metadata, 0, sizeof(AVMasteringDisplayMetadata));

ok...

>  if (has_mastering_primaries) {
>  metadata->display_primaries[0][0] = av_make_q(
>  round(mastering_meta->r_x * chroma_den), chroma_den);
> @@ -1875,6 +1872,13 @@ static int mkv_parse_video_color(AVStream *st, const 
> MatroskaTrack *track) {
>  round(mastering_meta->min_luminance * luma_den), luma_den);
>  metadata->has_luminance = 1;
>  }
> +
> +ret = av_stream_add_side_data(st, 
> AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
> +  (uint8_t *)metadata, 
> sizeof(AVMasteringDisplayMetadata));
> +if (ret < 0) {
> +av_freep();
> +return ret;
> +}
>  }
>  return 0;
>  }

Uh what? Am I missing something, or do you rely on
sizeof(AVMasteringDisplayMetadata) being part of the ABI? Because the
alloc function only exists because the struct size is not part of the
ABI.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/matroskadec: use mastering display metadata's own alloc function

2016-12-02 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/matroskadec.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 017a533..7b070ff 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1841,14 +1841,11 @@ static int mkv_parse_video_color(AVStream *st, const 
MatroskaTrack *track) {
 // Use similar rationals as other standards.
 const int chroma_den = 5;
 const int luma_den = 1;
-AVMasteringDisplayMetadata *metadata =
-(AVMasteringDisplayMetadata*) av_stream_new_side_data(
-st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
-sizeof(AVMasteringDisplayMetadata));
+int ret;
+AVMasteringDisplayMetadata *metadata = 
av_mastering_display_metadata_alloc();
 if (!metadata) {
 return AVERROR(ENOMEM);
 }
-memset(metadata, 0, sizeof(AVMasteringDisplayMetadata));
 if (has_mastering_primaries) {
 metadata->display_primaries[0][0] = av_make_q(
 round(mastering_meta->r_x * chroma_den), chroma_den);
@@ -1875,6 +1872,13 @@ static int mkv_parse_video_color(AVStream *st, const 
MatroskaTrack *track) {
 round(mastering_meta->min_luminance * luma_den), luma_den);
 metadata->has_luminance = 1;
 }
+
+ret = av_stream_add_side_data(st, 
AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
+  (uint8_t *)metadata, 
sizeof(AVMasteringDisplayMetadata));
+if (ret < 0) {
+av_freep();
+return ret;
+}
 }
 return 0;
 }
-- 
2.10.2

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


Re: [FFmpeg-devel] [PATCH 2/6] avformat/ffmenc: Replace some st->codec use by codecpar

2016-12-02 Thread Michael Niedermayer
On Thu, Dec 01, 2016 at 05:37:35PM +0100, Michael Niedermayer wrote:
> Note, this temporarly drops the ability to set ffmpeg encoder debug and 
> flags2 via ffserver.conf
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/ffmenc.c | 24 +---
>  1 file changed, 13 insertions(+), 11 deletions(-)

patchset applied

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No snowflake in an avalanche ever feels responsible. -- Voltaire


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/3] configure: fail if autodetect-libraries are requested but not found

2016-12-02 Thread Michael Niedermayer
On Fri, Dec 02, 2016 at 12:44:41AM +0100, Andreas Cadhalpun wrote:
> On 01.12.2016 01:34, Michael Niedermayer wrote:
> > On Thu, Dec 01, 2016 at 12:22:50AM +0100, Andreas Cadhalpun wrote:
> >> @@ -6381,6 +6410,11 @@ for thread in $THREADS_LIST; do
> >>  fi
> >>  done
> >>  
> >> +# Check if requested libraries were found.
> >> +for lib in $AUTODETECT_LIBS; do
> >> +requested $lib && ! enabled $lib && die "ERROR: $lib requested but 
> >> not found";
> >> +done
> > 
> > This must be after check_deps as that can disable vaapi
> 
> I agree, but...
> 
> > unless i miss something
> 
> ...it is already after check_deps. ;)
> 

> > also in the same light i think things like:
> > 
> > enabled vaapi &&
> > check_lib va/va.h vaInitialize -lva ||
> > disable vaapi
> > 
> > should disable vaapi through having a entry in vaapi_deps= ...
> 
> There is already va_va_h in vaapi_deps and I'm not sure, what else
> you'd like to have there.

i see a "disable vaapi" here but that should be done by the dependency
or why is it done here ?


> However, it seems independent of this patch.

yes


iam ok with the patch if other are and its tested

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avformat/udp: Replace use of pthread_cancel.

2016-12-02 Thread Nicolas George
Le duodi 12 frimaire, an CCXXV, Matt Oliver a écrit :
> Which changes would those be?

The fix of errno / return value for pthread_cond_timedwait() for
example.

>   This function is already set as nonblocking

I think you read this specific part of the code wrong. Unfortunately,
since this is a pivotal part of your reasoning, it ruins everything
else.

recv() can not be in non-blocking mode here because it would cause the
whole thread to behave in busy-wait, which is completely unacceptable.

Remember that pthread_cancel() was introduced here to eliminate polling.
Please do not bring it back. The way forward is to implement an event
loop for all protocols.

Regards,

-- 
  Nicolas George


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] travis: setup for automated coverity builds

2016-12-02 Thread Timo Rothenpieler
> That has been done my Michael as I can see.
> 
> So one question: will this .travis.yml be applied to the main FFmpeg repo
> or the newly created FFmpeg-Coverity repo?

That's a good point, it doesn't even need to be in the main repo,
specially as there already is a travis.yml there.
Would probably be better to just put it alongside the Docker files.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] travis: setup for automated coverity builds

2016-12-02 Thread Timothy Gu
On Fri, Dec 2, 2016 at 3:22 AM Timo Rothenpieler 
wrote:

> On 12/2/2016 4:14 AM, Timothy Gu wrote:
> > On Thu, Dec 1, 2016 at 1:23 PM Timo Rothenpieler 
> > wrote:
> >
> >> Travis can only run scheduled builds daily, weekly or monthly.
> >
> > So we run them daily, and use a bit of logic in the .travis.yml to
> >> cancel out early on 3 days per week.
> >>
> >
> > Nice! Didn't know Travis CI could do this.
> >
>
> It needs to be explicitly requested, but I don't think that will be an
> issue if we explain them our usecase:
> https://docs.travis-ci.com/user/cron-jobs/


Agreed.

>
> > A few nits: indent the array, just as you did for `services`; the
> official
> > Travis CI-Coverity bridge uses COVERITY_SCAN_NOTIFICATION_EMAIL and
> > COVERITY_SCAN_TOKEN, so for consistency you might want to change that.
>
> Updated the image to use those, updated this patch locally to do the same.


> > Another thing is that currently https://github.com/BtbN/FFmpeg-Coverity
> (the
> > source of "ffmpeg/coverity" image) belongs to your GitHub account. Maybe
> we
> > should think of transferring that to github.com/FFmpeg?
>
> I can't create that repository myself, but so if someone could import it
> from my Account, that would be nice.
>

That has been done my Michael as I can see.

So one question: will this .travis.yml be applied to the main FFmpeg repo
or the newly created FFmpeg-Coverity repo?

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


Re: [FFmpeg-devel] [PATCH] Save FFmpeg colorspace info in openh264 video files.

2016-12-02 Thread Gregory J Wolfe
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf Of James Almer
> Sent: Friday, December 02, 2016 9:31 AM
> 
> On 12/1/2016 6:26 PM, Gregory J. Wolfe wrote:
> > As of version 1.6, libopenh264 saves (in the output video file)
> > information about the color primaries, transfer characteristics,
> > and color matrix used when the video pixel data was created.
> > This patch sets the required libopenh264 data structures using
> > the FFmpeg colorspace information so that video players will
> > know how to properly decode video files created using FFmpeg
> > and libopenh264.
> >
> > Signed-off-by: Gregory J. Wolfe 
> > ---
> >  libavcodec/libopenh264enc.c | 49
> +
> >  1 file changed, 49 insertions(+)
> >
> > diff --git a/libavcodec/libopenh264enc.c
> b/libavcodec/libopenh264enc.c
> > index e84de27..3b019b8 100644
> > --- a/libavcodec/libopenh264enc.c
> > +++ b/libavcodec/libopenh264enc.c
> > @@ -205,6 +205,55 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >  }
> >  }
> >
> > +#if OPENH264_VER_AT_LEAST(1, 6)
> > +// set video signal type information
> > +param.sSpatialLayers[0].bVideoSignalTypePresent = true;
> > +param.sSpatialLayers[0].uiVideoFormat = VF_UNDEF; // default;
> choices are VF_: COMPONENT, PAL, NTSC, SECAM, MAC, UNDEF
> > +param.sSpatialLayers[0].bFullRange = avctx->color_range ==
> AVCOL_RANGE_JPEG;
> > +param.sSpatialLayers[0].bColorDescriptionPresent = true;
> > +switch (avctx->color_primaries) {
> > +case AVCOL_PRI_BT709:
> param.sSpatialLayers[0].uiColorPrimaries  = CP_BT709; break;
> > +case AVCOL_PRI_UNSPECIFIED:
> param.sSpatialLayers[0].uiColorPrimaries  = CP_UNDEF; break;
> > +case AVCOL_PRI_BT470M:
> param.sSpatialLayers[0].uiColorPrimaries  = CP_BT470M;break;
> > +case AVCOL_PRI_BT470BG:
> param.sSpatialLayers[0].uiColorPrimaries  = CP_BT470BG;   break;
> > +case AVCOL_PRI_SMPTE170M:
> param.sSpatialLayers[0].uiColorPrimaries  = CP_SMPTE170M;
> break;
> > +case AVCOL_PRI_SMPTE240M:
> param.sSpatialLayers[0].uiColorPrimaries  = CP_SMPTE240M;
> break;
> > +case AVCOL_PRI_FILM:
> param.sSpatialLayers[0].uiColorPrimaries  = CP_FILM;  break;
> > +case AVCOL_PRI_BT2020:
> param.sSpatialLayers[0].uiColorPrimaries  = CP_BT2020;break;
> > +default: param.sSpatialLayers[0].uiColorPrimaries  
> > =
> CP_UNDEF; break;
> > +}
> > +switch (avctx->color_trc) {
> > +case AVCOL_TRC_BT709:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_BT709;
> break;
> > +case AVCOL_TRC_UNSPECIFIED:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_UNDEF;
> break;
> > +case AVCOL_TRC_GAMMA22:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_BT470M;
> break;
> > +case AVCOL_TRC_GAMMA28:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_BT470BG;
> break;
> > +case AVCOL_TRC_SMPTE170M:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_SMPTE170M;
> break;
> > +case AVCOL_TRC_SMPTE240M:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_SMPTE240M;
> break;
> > +case AVCOL_TRC_LINEAR:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_LINEAR;
> break;
> > +case AVCOL_TRC_LOG:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_LOG100;
> break;
> > +case AVCOL_TRC_LOG_SQRT:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_LOG316;
> break;
> > +case AVCOL_TRC_IEC61966_2_4:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_IEC61966_2_4;
> break;
> > +case AVCOL_TRC_BT1361_ECG:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_BT1361E;
> break;
> > +case AVCOL_TRC_IEC61966_2_1:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_IEC61966_2_1;
> break;
> > +case AVCOL_TRC_BT2020_10:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_BT2020_10;
> break;
> > +case AVCOL_TRC_BT2020_12:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_BT2020_12;
> break;
> > +default:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_UNDEF;
> break;
> > +}
> > +switch (avctx->colorspace) {
> > +case AVCOL_SPC_RGB:
> param.sSpatialLayers[0].uiColorMatrix = CM_GBR;   break;
> > +case AVCOL_SPC_BT709:
> param.sSpatialLayers[0].uiColorMatrix = CM_BT709; break;
> > +case AVCOL_SPC_UNSPECIFIED:
> param.sSpatialLayers[0].uiColorMatrix = CM_UNDEF; break;
> > +case AVCOL_SPC_FCC:  param.sSpatialLayers[0].uiColorMatrix
> = CM_FCC;   break;
> > +case AVCOL_SPC_BT470BG:
> param.sSpatialLayers[0].uiColorMatrix = CM_BT470BG;   break;
> > +case AVCOL_SPC_SMPTE170M:
> param.sSpatialLayers[0].uiColorMatrix = CM_SMPTE170M;
> break;
> > +case 

Re: [FFmpeg-devel] [PATCH] avformat/utils: fix crashes in has_decode_delay_been_guessed

2016-12-02 Thread Timo Rothenpieler
> Is it just me or is this completely inconsistent?
> the codec id told to the user is h264 while we internally use a
> mpeg2 decoder to analyze it ?
> 
> If its h264 (as forced by the user) we should use a h264 decoder
> to internally analyze it
> 

Yes, something is very wrong here.
I also wasn't able to reproduce this with any self made sample. Only the
one from Ticket 5985 makes it crash for me. In two separate ways even.
In one case, the avctx->codec is NULL, because there are unknown codecs
in that sample, and in other cases the codecs mismatch.

I don't have time to take an in depth look at what is going on there, so
for now I decided to harden it against crashes, which is probably a good
idea in any case.

If this patch gets merged, it should also be backported to at least 3.2
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/utils: fix crashes in has_decode_delay_been_guessed

2016-12-02 Thread Michael Niedermayer
On Fri, Dec 02, 2016 at 01:51:24PM +0100, Timo Rothenpieler wrote:
> These paths can be taken when the actual underlying codec is not h264,
> but the user forces, for example via ffmpeg command line, a specific
> input decoder that happens to be a h264 decoder.
> 

> In that case, the codecpar codec_id is set to h264, but the internal
> avctx is the one of, for example, an mpeg2 decoder, thus crashing in
> this function.

Is it just me or is this completely inconsistent?
the codec id told to the user is h264 while we internally use a
mpeg2 decoder to analyze it ?

If its h264 (as forced by the user) we should use a h264 decoder
to internally analyze it

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Save FFmpeg colorspace info in openh264 video files.

2016-12-02 Thread James Almer
On 12/1/2016 6:26 PM, Gregory J. Wolfe wrote:
> As of version 1.6, libopenh264 saves (in the output video file)
> information about the color primaries, transfer characteristics,
> and color matrix used when the video pixel data was created.
> This patch sets the required libopenh264 data structures using
> the FFmpeg colorspace information so that video players will
> know how to properly decode video files created using FFmpeg
> and libopenh264.
> 
> Signed-off-by: Gregory J. Wolfe 
> ---
>  libavcodec/libopenh264enc.c | 49 
> +
>  1 file changed, 49 insertions(+)
> 
> diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> index e84de27..3b019b8 100644
> --- a/libavcodec/libopenh264enc.c
> +++ b/libavcodec/libopenh264enc.c
> @@ -205,6 +205,55 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  }
>  }
>  
> +#if OPENH264_VER_AT_LEAST(1, 6)
> +// set video signal type information
> +param.sSpatialLayers[0].bVideoSignalTypePresent = true;
> +param.sSpatialLayers[0].uiVideoFormat = VF_UNDEF; // default; choices 
> are VF_: COMPONENT, PAL, NTSC, SECAM, MAC, UNDEF
> +param.sSpatialLayers[0].bFullRange = avctx->color_range == 
> AVCOL_RANGE_JPEG;
> +param.sSpatialLayers[0].bColorDescriptionPresent = true;
> +switch (avctx->color_primaries) {
> +case AVCOL_PRI_BT709:param.sSpatialLayers[0].uiColorPrimaries
>   = CP_BT709; break;
> +case AVCOL_PRI_UNSPECIFIED:  param.sSpatialLayers[0].uiColorPrimaries
>   = CP_UNDEF; break;
> +case AVCOL_PRI_BT470M:   param.sSpatialLayers[0].uiColorPrimaries
>   = CP_BT470M;break;
> +case AVCOL_PRI_BT470BG:  param.sSpatialLayers[0].uiColorPrimaries
>   = CP_BT470BG;   break;
> +case AVCOL_PRI_SMPTE170M:param.sSpatialLayers[0].uiColorPrimaries
>   = CP_SMPTE170M; break;
> +case AVCOL_PRI_SMPTE240M:param.sSpatialLayers[0].uiColorPrimaries
>   = CP_SMPTE240M; break;
> +case AVCOL_PRI_FILM: param.sSpatialLayers[0].uiColorPrimaries
>   = CP_FILM;  break;
> +case AVCOL_PRI_BT2020:   param.sSpatialLayers[0].uiColorPrimaries
>   = CP_BT2020;break;
> +default: param.sSpatialLayers[0].uiColorPrimaries
>   = CP_UNDEF; break;
> +}
> +switch (avctx->color_trc) {
> +case AVCOL_TRC_BT709:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_BT709;break;
> +case AVCOL_TRC_UNSPECIFIED:  
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_UNDEF;break;
> +case AVCOL_TRC_GAMMA22:  
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_BT470M;   break;
> +case AVCOL_TRC_GAMMA28:  
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_BT470BG;  break;
> +case AVCOL_TRC_SMPTE170M:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_SMPTE170M;break;
> +case AVCOL_TRC_SMPTE240M:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_SMPTE240M;break;
> +case AVCOL_TRC_LINEAR:   
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_LINEAR;   break;
> +case AVCOL_TRC_LOG:  
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_LOG100;   break;
> +case AVCOL_TRC_LOG_SQRT: 
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_LOG316;   break;
> +case AVCOL_TRC_IEC61966_2_4: 
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_IEC61966_2_4; break;
> +case AVCOL_TRC_BT1361_ECG:   
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_BT1361E;  break;
> +case AVCOL_TRC_IEC61966_2_1: 
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_IEC61966_2_1; break;
> +case AVCOL_TRC_BT2020_10:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_BT2020_10;break;
> +case AVCOL_TRC_BT2020_12:
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_BT2020_12;break;
> +default: 
> param.sSpatialLayers[0].uiTransferCharacteristics = TRC_UNDEF;break;
> +}
> +switch (avctx->colorspace) {
> +case AVCOL_SPC_RGB:  param.sSpatialLayers[0].uiColorMatrix   
>   = CM_GBR;   break;
> +case AVCOL_SPC_BT709:param.sSpatialLayers[0].uiColorMatrix   
>   = CM_BT709; break;
> +case AVCOL_SPC_UNSPECIFIED:  param.sSpatialLayers[0].uiColorMatrix   
>   = CM_UNDEF; break;
> +case AVCOL_SPC_FCC:  param.sSpatialLayers[0].uiColorMatrix   
>   = CM_FCC;   break;
> +case AVCOL_SPC_BT470BG:  param.sSpatialLayers[0].uiColorMatrix   
>   = CM_BT470BG;   break;
> +case AVCOL_SPC_SMPTE170M:param.sSpatialLayers[0].uiColorMatrix   
>   = CM_SMPTE170M; break;
> +case AVCOL_SPC_SMPTE240M:

Re: [FFmpeg-devel] [PATCH] matroskadec: partly revert "demux relevant subtitle packets after a seek" c16582579b1c6f66a86615c5808cd5b2bf17be73

2016-12-02 Thread Rainer Hochecker
absolutely. thanks!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] avutil/thread: Add pthread_cond_timedwait function.

2016-12-02 Thread James Almer
On 12/2/2016 5:21 AM, Matt Oliver wrote:
> Signed-off-by: Matt Oliver 
> ---
>  compat/os2threads.h  | 24 
>  compat/w32pthreads.h | 50 ++
>  libavutil/thread.h   |  6 ++
>  3 files changed, 80 insertions(+)
> 
> diff --git a/compat/os2threads.h b/compat/os2threads.h
> index 40a119f..a8b7824 100644
> --- a/compat/os2threads.h
> +++ b/compat/os2threads.h
> @@ -31,11 +31,13 @@
>  
>  #undef __STRICT_ANSI__  /* for _beginthread() */
>  #include 
> +#include 
>  
>  #include 
>  #include 
>  
>  #include "libavutil/attributes.h"
> +#include "libavutil/time.h"
>  
>  typedef struct {
>  TID tid;
> @@ -161,6 +163,28 @@ static av_always_inline int 
> pthread_cond_broadcast(pthread_cond_t *cond)
>  return 0;
>  }
>  
> +static av_always_inline int pthread_cond_timedwait(pthread_cond_t *cond,
> +   pthread_mutex_t *mutex,
> +   const struct timespec 
> *abstime)
> +{
> +int64_t abs_milli = abstime->tv_nsec * 1000LL + abstime->tv_nsec / 1.0e6;
> +ULONG t = FFMAX(abs_milli - av_gettime(), 0LL);
> +
> +__atomic_increment(>wait_count);
> +
> +pthread_mutex_unlock(mutex);
> +
> +APIRET ret = DosWaitEventSem(cond->event_sem, t);
> +
> +__atomic_decrement(>wait_count);
> +
> +DosPostEventSem(cond->ack_sem);
> +
> +pthread_mutex_lock(mutex);
> +
> +return (ret == ERROR_TIMEOUT) ? ETIMEDOUT : 0;
> +}
> +
>  static av_always_inline int pthread_cond_wait(pthread_cond_t *cond,
>pthread_mutex_t *mutex)
>  {
> diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
> index 4ac2a99..abd54b2 100644
> --- a/compat/w32pthreads.h
> +++ b/compat/w32pthreads.h
> @@ -38,6 +38,7 @@
>  #define WIN32_LEAN_AND_MEAN
>  #include 
>  #include 
> +#include 
>  
>  #if _WIN32_WINNT < 0x0600 && defined(__MINGW32__)
>  #undef MemoryBarrier
> @@ -48,6 +49,7 @@
>  #include "libavutil/common.h"
>  #include "libavutil/internal.h"
>  #include "libavutil/mem.h"
> +#include "libavutil/time.h"
>  
>  typedef struct pthread_t {
>  void *handle;
> @@ -171,6 +173,17 @@ static inline int pthread_cond_wait(pthread_cond_t 
> *cond, pthread_mutex_t *mutex
>  return 0;
>  }
>  
> +static inline int pthread_cond_timedwait(pthread_cond_t *cond, 
> pthread_mutex_t *mutex,
> + const struct timespec *abstime)
> +{
> +int64_t abs_milli = abstime->tv_nsec * 1000LL + abstime->tv_nsec / 1.0e6;
> +DWORD t = FFMAX(abs_milli - av_gettime(), 0LL);
> +
> +if (SleepConditionVariableCS(cond, mutex, t) == WAIT_TIMEOUT)
> +return ETIMEDOUT;
> +return 0;
> +}
> +
>  static inline int pthread_cond_signal(pthread_cond_t *cond)
>  {
>  WakeConditionVariable(cond);
> @@ -367,6 +380,43 @@ static av_unused int pthread_cond_wait(pthread_cond_t 
> *cond, pthread_mutex_t *mu
>  return pthread_mutex_lock(mutex);
>  }
>  
> +static inline int pthread_cond_timedwait(pthread_cond_t *cond, 
> pthread_mutex_t *mutex,
> + const struct timespec *abstime)
> +{
> +win32_cond_t *win32_cond = cond->Ptr;
> +int last_waiter;
> +int64_t abs_milli = abstime->tv_nsec * 1000LL + abstime->tv_nsec / 1.0e6;
> +DWORD t = FFMAX(abs_milli - av_gettime(), 0LL);
> +if (cond_wait) {
> +cond_wait(cond, mutex, t);
> +return 0;

This is not doing the same as the native version above. Is that intended?

> +}
> +
> +/* non native condition variables */
> +pthread_mutex_lock(_cond->mtx_broadcast);
> +pthread_mutex_lock(_cond->mtx_waiter_count);
> +win32_cond->waiter_count++;
> +pthread_mutex_unlock(_cond->mtx_waiter_count);
> +pthread_mutex_unlock(_cond->mtx_broadcast);
> +
> +// unlock the external mutex
> +pthread_mutex_unlock(mutex);
> +DWORD ret = WaitForSingleObject(win32_cond->semaphore, t);
> +
> +pthread_mutex_lock(_cond->mtx_waiter_count);
> +win32_cond->waiter_count--;
> +last_waiter = !win32_cond->waiter_count || !win32_cond->is_broadcast;
> +pthread_mutex_unlock(_cond->mtx_waiter_count);
> +
> +if (last_waiter)
> +SetEvent(win32_cond->waiters_done);
> +
> +// lock the external mutex
> +pthread_mutex_lock(mutex);
> +
> +return (ret == WAIT_TIMEOUT) ? ETIMEDOUT : 0;
> +}
> +
>  static av_unused int pthread_cond_signal(pthread_cond_t *cond)
>  {
>  win32_cond_t *win32_cond = cond->Ptr;
> diff --git a/libavutil/thread.h b/libavutil/thread.h
> index 32ddf40..9d611f2 100644
> --- a/libavutil/thread.h
> +++ b/libavutil/thread.h
> @@ -108,6 +108,12 @@ static inline int 
> strict_pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t
>  ASSERT_PTHREAD(pthread_cond_wait, cond, mutex);
>  }
>  
> +static inline int strict_pthread_cond_timedwait(pthread_cond_t *cond, 
> pthread_mutex_t 

Re: [FFmpeg-devel] [PATCH] Save FFmpeg colorspace info in openh264 video files.

2016-12-02 Thread Gregory J Wolfe
> > +switch (avctx->color_primaries) {
> > +case AVCOL_PRI_BT709:
> param.sSpatialLayers[0].uiColorPrimaries  = CP_BT709; break;
> > +case AVCOL_PRI_UNSPECIFIED:
> param.sSpatialLayers[0].uiColorPrimaries  = CP_UNDEF; break;
> 
> [ignore]
> Please align vertically.
> [/ignore]
> Is it possible to convince gmail to always use a fixed-width font?
> The patch looks ugly here on gmail but I suspect it was aligned nicely...
> 
> Thank you, Carl Eugen

I verified that my original edited file was aligned using vim.  Also,
I copied/pasted the code lines from your reply into notepad and
THAT is also aligned.

Greg W.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] matroskadec: partly revert "demux relevant subtitle packets after a seek" c16582579b1c6f66a86615c5808cd5b2bf17be73

2016-12-02 Thread wm4
On Sat, 26 Nov 2016 08:27:44 +0100
Rainer Hochecker  wrote:

> From: Rainer Hochecker 
> 
> 
> Alternative patch. Revert the original code because it does more harm than 
> any good.
> 
> 
> Signed-off-by: Rainer Hochecker 
> ---
>  libavformat/matroskadec.c | 12 
>  1 file changed, 12 deletions(-)
> 
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index f79511e..cf3de96 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -3398,18 +3398,6 @@ static int matroska_read_seek(AVFormatContext *s, int 
> stream_index,
>  tracks[i].audio.sub_packet_cnt = 0;
>  tracks[i].audio.buf_timecode   = AV_NOPTS_VALUE;
>  tracks[i].end_timecode = 0;
> -if (tracks[i].type == MATROSKA_TRACK_TYPE_SUBTITLE &&
> -tracks[i].stream &&
> -tracks[i].stream->discard != AVDISCARD_ALL) {
> -index_sub = av_index_search_timestamp(
> -tracks[i].stream, st->index_entries[index].timestamp,
> -AVSEEK_FLAG_BACKWARD);
> -while (index_sub >= 0 &&
> -  index_min > 0 &&
> -  tracks[i].stream->index_entries[index_sub].pos < 
> st->index_entries[index_min].pos &&
> -  st->index_entries[index].timestamp - 
> tracks[i].stream->index_entries[index_sub].timestamp < 300 / 
> matroska->time_scale)
> -index_min--;
> -}
>  }
>  
>  avio_seek(s->pb, st->index_entries[index_min].pos, SEEK_SET);

Pushed. I heavily edited the commit message to provide context - I hope
that is ok.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/utils: fix crashes in has_decode_delay_been_guessed

2016-12-02 Thread wm4
On Fri,  2 Dec 2016 13:51:24 +0100
Timo Rothenpieler  wrote:

> These paths can be taken when the actual underlying codec is not h264,
> but the user forces, for example via ffmpeg command line, a specific
> input decoder that happens to be a h264 decoder.
> 
> In that case, the codecpar codec_id is set to h264, but the internal
> avctx is the one of, for example, an mpeg2 decoder, thus crashing in
> this function.
> 
> Checking for the codec actually being h264 is not strictly neccesary to
> fix the crash, but a precaution to catch potential other unexpected
> codepaths.
> 
> Fixes #5985
> ---
>  libavformat/utils.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 345bbfe5fe..8e23c0c6ec 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -966,11 +966,14 @@ static int is_intra_only(enum AVCodecID id)
>  
>  static int has_decode_delay_been_guessed(AVStream *st)
>  {
> -if (st->codecpar->codec_id != AV_CODEC_ID_H264) return 1;
> +if (st->codecpar->codec_id != AV_CODEC_ID_H264 ||
> +   st->internal->avctx->codec_id != AV_CODEC_ID_H264)
> +return 1;
>  if (!st->info) // if we have left find_stream_info then 
> nb_decoded_frames won't increase anymore for stream copy
>  return 1;
>  #if CONFIG_H264_DECODER
> -if (st->internal->avctx->has_b_frames &&
> +if (st->internal->avctx->codec && 
> !strcmp(st->internal->avctx->codec->name, "h264") &&
> +   st->internal->avctx->has_b_frames &&
> avpriv_h264_has_num_reorder_frames(st->internal->avctx) == 
> st->internal->avctx->has_b_frames)
>  return 1;
>  #endif

That looks ok, but: can someone explain to me why Libav does apparently
not need this shitshow?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/utils: fix crashes in has_decode_delay_been_guessed

2016-12-02 Thread Timo Rothenpieler
These paths can be taken when the actual underlying codec is not h264,
but the user forces, for example via ffmpeg command line, a specific
input decoder that happens to be a h264 decoder.

In that case, the codecpar codec_id is set to h264, but the internal
avctx is the one of, for example, an mpeg2 decoder, thus crashing in
this function.

Checking for the codec actually being h264 is not strictly neccesary to
fix the crash, but a precaution to catch potential other unexpected
codepaths.

Fixes #5985
---
 libavformat/utils.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 345bbfe5fe..8e23c0c6ec 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -966,11 +966,14 @@ static int is_intra_only(enum AVCodecID id)
 
 static int has_decode_delay_been_guessed(AVStream *st)
 {
-if (st->codecpar->codec_id != AV_CODEC_ID_H264) return 1;
+if (st->codecpar->codec_id != AV_CODEC_ID_H264 ||
+   st->internal->avctx->codec_id != AV_CODEC_ID_H264)
+return 1;
 if (!st->info) // if we have left find_stream_info then nb_decoded_frames 
won't increase anymore for stream copy
 return 1;
 #if CONFIG_H264_DECODER
-if (st->internal->avctx->has_b_frames &&
+if (st->internal->avctx->codec && 
!strcmp(st->internal->avctx->codec->name, "h264") &&
+   st->internal->avctx->has_b_frames &&
avpriv_h264_has_num_reorder_frames(st->internal->avctx) == 
st->internal->avctx->has_b_frames)
 return 1;
 #endif
-- 
2.11.0.rc2

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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/udp: Replace use of pthread_cancel.

2016-12-02 Thread Matt Oliver
On 2 December 2016 at 22:16, Nicolas George  wrote:

> Le duodi 12 frimaire, an CCXXV, Matt Oliver a écrit :
> > ---
> >  configure |  6 --
> >  libavformat/udp.c | 48 +++-
> >  2 files changed, 19 insertions(+), 35 deletions(-)
>
> It looks like there are unrelated changes in this patch.
>

Which changes would those be? all of them are just what is required to
enable threading on non posix systems with pthread_cancel


> Can you explain how it achieves the same result as pthread_cancel()? It
> looks to me it does not.
>

For one currently pthread_cancel is only called for the read thread which
uses the circular_buffer_task_rx function. pthread_cancel is never called
on the transmit thread so the pthread_setcancelstate calls in
circular_buffer_task_tx dont actually do anything. In fact the pthread
cancel state is only enabled in the rx function on either side of the recv
function. This function is already set as nonblocking and so it wont hold
up the thread which can then continue back to the s->close_req check and
terminate cleanly. So functionally I dont think the the pthread_cancel
functionality is even needed as I dont think there is any advantage to
having it and removing it allows the functionality to be enabled on more
systems.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] travis: setup for automated coverity builds

2016-12-02 Thread Timo Rothenpieler
On 12/2/2016 4:14 AM, Timothy Gu wrote:
> On Thu, Dec 1, 2016 at 1:23 PM Timo Rothenpieler 
> wrote:
> 
>> Travis can only run scheduled builds daily, weekly or monthly.
> 
> So we run them daily, and use a bit of logic in the .travis.yml to
>> cancel out early on 3 days per week.
>>
> 
> Nice! Didn't know Travis CI could do this.
> 

It needs to be explicitly requested, but I don't think that will be an
issue if we explain them our usecase:
https://docs.travis-ci.com/user/cron-jobs/


> 
> A few nits: indent the array, just as you did for `services`; the official
> Travis CI-Coverity bridge uses COVERITY_SCAN_NOTIFICATION_EMAIL and
> COVERITY_SCAN_TOKEN, so for consistency you might want to change that.

Updated the image to use those, updated this patch locally to do the same.

> Another thing is that currently https://github.com/BtbN/FFmpeg-Coverity (the
> source of "ffmpeg/coverity" image) belongs to your GitHub account. Maybe we
> should think of transferring that to github.com/FFmpeg?

I can't create that repository myself, but so if someone could import it
from my Account, that would be nice.

> I also have a few comments on your current build scripts, but we can change
> those once this patch is in.
> 
> Timothy
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avformat/udp: Replace use of pthread_cancel.

2016-12-02 Thread Nicolas George
Le duodi 12 frimaire, an CCXXV, Matt Oliver a écrit :
> ---
>  configure |  6 --
>  libavformat/udp.c | 48 +++-
>  2 files changed, 19 insertions(+), 35 deletions(-)

It looks like there are unrelated changes in this patch.

Can you explain how it achieves the same result as pthread_cancel()? It
looks to me it does not.

Regards,

-- 
  Nicolas George
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avformat/udp: Replace use of pthread_cancel.

2016-12-02 Thread Hendrik Leppkes
On Fri, Dec 2, 2016 at 9:22 AM, Matt Oliver  wrote:
> ---
>  configure |  6 --
>  libavformat/udp.c | 48 +++-
>  2 files changed, 19 insertions(+), 35 deletions(-)
>
> diff --git a/configure b/configure
> index b5bfad6..cec94c4 100755
> --- a/configure
> +++ b/configure
> @@ -1934,7 +1934,6 @@ SYSTEM_FUNCS="
>  nanosleep
>  PeekNamedPipe
>  posix_memalign
> -pthread_cancel
>  sched_getaffinity
>  SetConsoleTextAttribute
>  SetConsoleCtrlHandler
> @@ -5623,11 +5622,6 @@ if ! disabled pthreads && ! enabled w32threads && !
> enabled os2threads; then
>  check_code cc "pthread.h" "static pthread_mutex_t atomic_lock =
> PTHREAD_MUTEX_INITIALIZER" || disable pthreads
>  fi
>
> -
> -if enabled pthreads; then
> -  check_func pthread_cancel
> -fi
> -
>  enabled pthreads &&
>  check_builtin sem_timedwait semaphore.h "sem_t *s; sem_init(s,0,0);
> sem_timedwait(s,0); sem_destroy(s)"
>
> diff --git a/libavformat/udp.c b/libavformat/udp.c
> index 3835f98..857a979 100644
> --- a/libavformat/udp.c
> +++ b/libavformat/udp.c
> @@ -60,12 +60,8 @@
>  #define IPPROTO_UDPLITE  136
>  #endif
>
> -#if HAVE_PTHREAD_CANCEL
> -#include 
> -#endif
> -
> -#ifndef HAVE_PTHREAD_CANCEL
> -#define HAVE_PTHREAD_CANCEL 0
> +#if HAVE_THREADS
> +#include "libavutil/thread.h"
>  #endif
>
>  #ifndef IPV6_ADD_MEMBERSHIP
> @@ -100,7 +96,7 @@ typedef struct UDPContext {
>  int64_t bitrate; /* number of bits to send per second */
>  int64_t burst_bits;
>  int close_req;
> -#if HAVE_PTHREAD_CANCEL
> +#if HAVE_THREADS
>  pthread_t circular_buffer_thread;
>  pthread_mutex_t mutex;
>  pthread_cond_t cond;
> @@ -495,14 +491,13 @@ static int udp_get_file_handle(URLContext *h)
>  return s->udp_fd;
>  }
>
> -#if HAVE_PTHREAD_CANCEL
> +#if HAVE_THREADS
>  static void *circular_buffer_task_rx( void *_URLContext)
>  {
>  URLContext *h = _URLContext;
>  UDPContext *s = h->priv_data;
>  int old_cancelstate;
>
> -pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, _cancelstate);
>  pthread_mutex_lock(>mutex);
>  if (ff_socket_nonblock(s->udp_fd, 0) < 0) {
>  av_log(h, AV_LOG_ERROR, "Failed to set blocking mode");
> @@ -511,14 +506,11 @@ static void *circular_buffer_task_rx( void
> *_URLContext)
>  }
>  while(1) {
>  int len;
> +if (s->close_req)
> +goto end;
>
>  pthread_mutex_unlock(>mutex);
> -/* Blocking operations are always cancellation points;
> -   see "General Information" / "Thread Cancelation Overview"
> -   in Single Unix. */
> -pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, _cancelstate);
>  len = recv(s->udp_fd, s->tmp+4, sizeof(s->tmp)-4, 0);
> -pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, _cancelstate);

pthread_cancel can unblock operations like these on Linux/Unix, so I
don't think some manual logic is going to solve the same problem.

On Windows this happens to work because closing the socket on another
thread unblocks any calls to it. I have had a local patch for years
that just defines pthread_cancel/setcancelstate to do nothing there.

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


Re: [FFmpeg-devel] [PATCH] lavc/vaapi_h26[45]: add crop info support in vaapi_h26[4, 5]

2016-12-02 Thread wm4
On Fri, 2 Dec 2016 16:15:10 +0800
Jun Zhao  wrote:

> On 2016/12/1 19:03, wm4 wrote:
> > On Wed, 30 Nov 2016 18:25:59 +0100
> > Michael Niedermayer  wrote:
> >   
>  AVFrame had a pan_scan parameter to store one or more croping
>  rectangles.
>  That is now available as side data
> 
>  I remember the intend that this could be used for multiple rectangles
>  of different sizes for example for storing recommanded display
>  rectangles for a 4:3 and a 16:9 display device, but it seems only a
>  single size per frame is supported in the API
> 
>  [...]
> >>>
> >>> This one is very "special" - I don't know if I'd want to further its
> >>> existence. What's it used for at all?
> >>
> >> I only know whats written in the specs, i dont remember having
> >> investigated what real world files do with it, and my knowledge of the
> >> specs is many years old so the spec would be a better place than my
> >> memory of it for further research ...  
> > 
> > If we're going to have a crop rectangle, lots of code (including many
> > video filters) will need to be able to interpret them. Considering
> > this, the pan scan side data is prohibitively complex. Maybe it
> > accurately reflects some standard (mpeg1/2 apparently?), but I'd say
> > it's not simple enough for general use.
> > _  
> 
> I don't think software dec/enc/filter have the crop issue, so I guess
> we just need a general solution for HWAccel dec/enc/hwcontext_xxx_filter.

For software filters, there is the issue that cropping left/right can
make the plane pointers unaligned (e.g. crop 1 pixel -> the pointer is
not aligned to 16 bytes anymore). Which can cause performance issues.
Also, cropping subsampled yuv by non-mod-2 width/height (as jpg
decoding requires it) is really messy.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] avutil/thread: Add pthread_cond_timedwait function.

2016-12-02 Thread Matt Oliver
Signed-off-by: Matt Oliver 
---
 compat/os2threads.h  | 24 
 compat/w32pthreads.h | 50
++
 libavutil/thread.h   |  6 ++
 3 files changed, 80 insertions(+)

diff --git a/compat/os2threads.h b/compat/os2threads.h
index 40a119f..a8b7824 100644
--- a/compat/os2threads.h
+++ b/compat/os2threads.h
@@ -31,11 +31,13 @@

 #undef __STRICT_ANSI__  /* for _beginthread() */
 #include 
+#include 

 #include 
 #include 

 #include "libavutil/attributes.h"
+#include "libavutil/time.h"

 typedef struct {
 TID tid;
@@ -161,6 +163,28 @@ static av_always_inline int
pthread_cond_broadcast(pthread_cond_t *cond)
 return 0;
 }

+static av_always_inline int pthread_cond_timedwait(pthread_cond_t *cond,
+   pthread_mutex_t *mutex,
+   const struct timespec
*abstime)
+{
+int64_t abs_milli = abstime->tv_nsec * 1000LL + abstime->tv_nsec /
1.0e6;
+ULONG t = FFMAX(abs_milli - av_gettime(), 0LL);
+
+__atomic_increment(>wait_count);
+
+pthread_mutex_unlock(mutex);
+
+APIRET ret = DosWaitEventSem(cond->event_sem, t);
+
+__atomic_decrement(>wait_count);
+
+DosPostEventSem(cond->ack_sem);
+
+pthread_mutex_lock(mutex);
+
+return (ret == ERROR_TIMEOUT) ? ETIMEDOUT : 0;
+}
+
 static av_always_inline int pthread_cond_wait(pthread_cond_t *cond,
   pthread_mutex_t *mutex)
 {
diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
index 4ac2a99..abd54b2 100644
--- a/compat/w32pthreads.h
+++ b/compat/w32pthreads.h
@@ -38,6 +38,7 @@
 #define WIN32_LEAN_AND_MEAN
 #include 
 #include 
+#include 

 #if _WIN32_WINNT < 0x0600 && defined(__MINGW32__)
 #undef MemoryBarrier
@@ -48,6 +49,7 @@
 #include "libavutil/common.h"
 #include "libavutil/internal.h"
 #include "libavutil/mem.h"
+#include "libavutil/time.h"

 typedef struct pthread_t {
 void *handle;
@@ -171,6 +173,17 @@ static inline int pthread_cond_wait(pthread_cond_t
*cond, pthread_mutex_t *mutex
 return 0;
 }

+static inline int pthread_cond_timedwait(pthread_cond_t *cond,
pthread_mutex_t *mutex,
+ const struct timespec *abstime)
+{
+int64_t abs_milli = abstime->tv_nsec * 1000LL + abstime->tv_nsec /
1.0e6;
+DWORD t = FFMAX(abs_milli - av_gettime(), 0LL);
+
+if (SleepConditionVariableCS(cond, mutex, t) == WAIT_TIMEOUT)
+return ETIMEDOUT;
+return 0;
+}
+
 static inline int pthread_cond_signal(pthread_cond_t *cond)
 {
 WakeConditionVariable(cond);
@@ -367,6 +380,43 @@ static av_unused int pthread_cond_wait(pthread_cond_t
*cond, pthread_mutex_t *mu
 return pthread_mutex_lock(mutex);
 }

+static inline int pthread_cond_timedwait(pthread_cond_t *cond,
pthread_mutex_t *mutex,
+ const struct timespec *abstime)
+{
+win32_cond_t *win32_cond = cond->Ptr;
+int last_waiter;
+int64_t abs_milli = abstime->tv_nsec * 1000LL + abstime->tv_nsec /
1.0e6;
+DWORD t = FFMAX(abs_milli - av_gettime(), 0LL);
+if (cond_wait) {
+cond_wait(cond, mutex, t);
+return 0;
+}
+
+/* non native condition variables */
+pthread_mutex_lock(_cond->mtx_broadcast);
+pthread_mutex_lock(_cond->mtx_waiter_count);
+win32_cond->waiter_count++;
+pthread_mutex_unlock(_cond->mtx_waiter_count);
+pthread_mutex_unlock(_cond->mtx_broadcast);
+
+// unlock the external mutex
+pthread_mutex_unlock(mutex);
+DWORD ret = WaitForSingleObject(win32_cond->semaphore, t);
+
+pthread_mutex_lock(_cond->mtx_waiter_count);
+win32_cond->waiter_count--;
+last_waiter = !win32_cond->waiter_count || !win32_cond->is_broadcast;
+pthread_mutex_unlock(_cond->mtx_waiter_count);
+
+if (last_waiter)
+SetEvent(win32_cond->waiters_done);
+
+// lock the external mutex
+pthread_mutex_lock(mutex);
+
+return (ret == WAIT_TIMEOUT) ? ETIMEDOUT : 0;
+}
+
 static av_unused int pthread_cond_signal(pthread_cond_t *cond)
 {
 win32_cond_t *win32_cond = cond->Ptr;
diff --git a/libavutil/thread.h b/libavutil/thread.h
index 32ddf40..9d611f2 100644
--- a/libavutil/thread.h
+++ b/libavutil/thread.h
@@ -108,6 +108,12 @@ static inline int
strict_pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t
 ASSERT_PTHREAD(pthread_cond_wait, cond, mutex);
 }

+static inline int strict_pthread_cond_timedwait(pthread_cond_t *cond,
pthread_mutex_t *mutex,
+const struct timespec
*abstime)
+{
+ASSERT_PTHREAD(pthread_cond_timedwait, cond, mutex, abstime);
+}
+
 static inline int strict_pthread_once(pthread_once_t *once_control, void
(*init_routine)(void))
 {
 ASSERT_PTHREAD(pthread_once, once_control, init_routine);
-- 
2.10.2.windows.1


0001-avutil-thread-Add-pthread_cond_timedwait-function.patch
Description: Binary data

[FFmpeg-devel] [PATCH 2/2] avformat/udp: Replace use of pthread_cancel.

2016-12-02 Thread Matt Oliver
---
 configure |  6 --
 libavformat/udp.c | 48 +++-
 2 files changed, 19 insertions(+), 35 deletions(-)

diff --git a/configure b/configure
index b5bfad6..cec94c4 100755
--- a/configure
+++ b/configure
@@ -1934,7 +1934,6 @@ SYSTEM_FUNCS="
 nanosleep
 PeekNamedPipe
 posix_memalign
-pthread_cancel
 sched_getaffinity
 SetConsoleTextAttribute
 SetConsoleCtrlHandler
@@ -5623,11 +5622,6 @@ if ! disabled pthreads && ! enabled w32threads && !
enabled os2threads; then
 check_code cc "pthread.h" "static pthread_mutex_t atomic_lock =
PTHREAD_MUTEX_INITIALIZER" || disable pthreads
 fi

-
-if enabled pthreads; then
-  check_func pthread_cancel
-fi
-
 enabled pthreads &&
 check_builtin sem_timedwait semaphore.h "sem_t *s; sem_init(s,0,0);
sem_timedwait(s,0); sem_destroy(s)"

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 3835f98..857a979 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -60,12 +60,8 @@
 #define IPPROTO_UDPLITE  136
 #endif

-#if HAVE_PTHREAD_CANCEL
-#include 
-#endif
-
-#ifndef HAVE_PTHREAD_CANCEL
-#define HAVE_PTHREAD_CANCEL 0
+#if HAVE_THREADS
+#include "libavutil/thread.h"
 #endif

 #ifndef IPV6_ADD_MEMBERSHIP
@@ -100,7 +96,7 @@ typedef struct UDPContext {
 int64_t bitrate; /* number of bits to send per second */
 int64_t burst_bits;
 int close_req;
-#if HAVE_PTHREAD_CANCEL
+#if HAVE_THREADS
 pthread_t circular_buffer_thread;
 pthread_mutex_t mutex;
 pthread_cond_t cond;
@@ -495,14 +491,13 @@ static int udp_get_file_handle(URLContext *h)
 return s->udp_fd;
 }

-#if HAVE_PTHREAD_CANCEL
+#if HAVE_THREADS
 static void *circular_buffer_task_rx( void *_URLContext)
 {
 URLContext *h = _URLContext;
 UDPContext *s = h->priv_data;
 int old_cancelstate;

-pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, _cancelstate);
 pthread_mutex_lock(>mutex);
 if (ff_socket_nonblock(s->udp_fd, 0) < 0) {
 av_log(h, AV_LOG_ERROR, "Failed to set blocking mode");
@@ -511,14 +506,11 @@ static void *circular_buffer_task_rx( void
*_URLContext)
 }
 while(1) {
 int len;
+if (s->close_req)
+goto end;

 pthread_mutex_unlock(>mutex);
-/* Blocking operations are always cancellation points;
-   see "General Information" / "Thread Cancelation Overview"
-   in Single Unix. */
-pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, _cancelstate);
 len = recv(s->udp_fd, s->tmp+4, sizeof(s->tmp)-4, 0);
-pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, _cancelstate);
 pthread_mutex_lock(>mutex);
 if (len < 0) {
 if (ff_neterrno() != AVERROR(EAGAIN) && ff_neterrno() !=
AVERROR(EINTR)) {
@@ -564,7 +556,6 @@ static void *circular_buffer_task_tx( void *_URLContext)
 int64_t burst_interval = s->bitrate ? (s->burst_bits * 100 /
s->bitrate) : 0;
 int64_t max_delay = s->bitrate ?  ((int64_t)h->max_packet_size * 8 *
100 / s->bitrate + 1) : 0;

-pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, _cancelstate);
 pthread_mutex_lock(>mutex);

 if (ff_socket_nonblock(s->udp_fd, 0) < 0) {
@@ -599,7 +590,6 @@ static void *circular_buffer_task_tx( void *_URLContext)
 av_fifo_generic_read(s->fifo, s->tmp, len, NULL);

 pthread_mutex_unlock(>mutex);
-pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, _cancelstate);

 if (s->bitrate) {
 timestamp = av_gettime_relative();
@@ -645,7 +635,6 @@ static void *circular_buffer_task_tx( void *_URLContext)
 }
 }

-pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, _cancelstate);
 pthread_mutex_lock(>mutex);
 }

@@ -730,7 +719,7 @@ static int udp_open(URLContext *h, const char *uri, int
flags)
 /* assume if no digits were found it is a request to enable it
*/
 if (buf == endptr)
 s->overrun_nonfatal = 1;
-if (!HAVE_PTHREAD_CANCEL)
+if (!HAVE_THREADS)
 av_log(h, AV_LOG_WARNING,
"'overrun_nonfatal' option was set but it is not
supported "
"on this build (pthread support is required)\n");
@@ -758,14 +747,14 @@ static int udp_open(URLContext *h, const char *uri,
int flags)
 }
 if (av_find_info_tag(buf, sizeof(buf), "fifo_size", p)) {
 s->circular_buffer_size = strtol(buf, NULL, 10);
-if (!HAVE_PTHREAD_CANCEL)
+if (!HAVE_THREADS)
 av_log(h, AV_LOG_WARNING,
"'circular_buffer_size' option was set but it is
not supported "
"on this build (pthread support is required)\n");
 }
 if (av_find_info_tag(buf, sizeof(buf), "bitrate", p)) {
 s->bitrate = strtoll(buf, NULL, 10);
-if (!HAVE_PTHREAD_CANCEL)
+if (!HAVE_THREADS)
 

Re: [FFmpeg-devel] [PATCH] lavc/vaapi_h26[45]: add crop info support in vaapi_h26[4, 5]

2016-12-02 Thread Jun Zhao


On 2016/12/1 19:03, wm4 wrote:
> On Wed, 30 Nov 2016 18:25:59 +0100
> Michael Niedermayer  wrote:
> 
 AVFrame had a pan_scan parameter to store one or more croping
 rectangles.
 That is now available as side data

 I remember the intend that this could be used for multiple rectangles
 of different sizes for example for storing recommanded display
 rectangles for a 4:3 and a 16:9 display device, but it seems only a
 single size per frame is supported in the API

 [...]  
>>>
>>> This one is very "special" - I don't know if I'd want to further its
>>> existence. What's it used for at all?  
>>
>> I only know whats written in the specs, i dont remember having
>> investigated what real world files do with it, and my knowledge of the
>> specs is many years old so the spec would be a better place than my
>> memory of it for further research ...
> 
> If we're going to have a crop rectangle, lots of code (including many
> video filters) will need to be able to interpret them. Considering
> this, the pan scan side data is prohibitively complex. Maybe it
> accurately reflects some standard (mpeg1/2 apparently?), but I'd say
> it's not simple enough for general use.
> _

I don't think software dec/enc/filter have the crop issue, so I guess
we just need a general solution for HWAccel dec/enc/hwcontext_xxx_filter.
 
__
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel