Re: [FFmpeg-devel] [PATCH 1/2] lavfi/opencl: Use filter device if no input device is available

2018-01-02 Thread Jun Zhao


On 2018/1/3 7:12, Mark Thompson wrote:
> This allows implementing sources as well as filters.
> ---
>  libavfilter/opencl.c | 39 +--
>  1 file changed, 33 insertions(+), 6 deletions(-)
>
> diff --git a/libavfilter/opencl.c b/libavfilter/opencl.c
> index 005ad089e2..37afc41f8b 100644
> --- a/libavfilter/opencl.c
> +++ b/libavfilter/opencl.c
> @@ -42,11 +42,29 @@ int ff_opencl_filter_query_formats(AVFilterContext *avctx)
>  return ff_set_common_formats(avctx, formats);
>  }
>  
> +static int opencl_filter_set_device(AVFilterContext *avctx,
> +AVBufferRef *device)
> +{
> +OpenCLFilterContext *ctx = avctx->priv;
> +
> +av_buffer_unref(>device_ref);
> +
> +ctx->device_ref = av_buffer_ref(device);
> +if (!ctx->device_ref)
> +return AVERROR(ENOMEM);
> +
> +ctx->device = (AVHWDeviceContext*)ctx->device_ref->data;
> +ctx->hwctx  = ctx->device->hwctx;
> +
> +return 0;
> +}
> +
>  int ff_opencl_filter_config_input(AVFilterLink *inlink)
>  {
>  AVFilterContext   *avctx = inlink->dst;
>  OpenCLFilterContext *ctx = avctx->priv;
>  AVHWFramesContext *input_frames;
> +int err;
>  
>  if (!inlink->hw_frames_ctx) {
>  av_log(avctx, AV_LOG_ERROR, "OpenCL filtering requires a "
> @@ -59,15 +77,12 @@ int ff_opencl_filter_config_input(AVFilterLink *inlink)
>  return 0;
>  
>  input_frames = (AVHWFramesContext*)inlink->hw_frames_ctx->data;
> -
>  if (input_frames->format != AV_PIX_FMT_OPENCL)
>  return AVERROR(EINVAL);
>  
> -ctx->device_ref = av_buffer_ref(input_frames->device_ref);
> -if (!ctx->device_ref)
> -return AVERROR(ENOMEM);
> -ctx->device = input_frames->device_ctx;
> -ctx->hwctx  = ctx->device->hwctx;
> +err = opencl_filter_set_device(avctx, input_frames->device_ref);
> +if (err < 0)
> +return err;
>  
>  // Default output parameters match input parameters.
>  if (ctx->output_format == AV_PIX_FMT_NONE)
> @@ -90,6 +105,18 @@ int ff_opencl_filter_config_output(AVFilterLink *outlink)
>  
>  av_buffer_unref(>hw_frames_ctx);
>  
> +if (!ctx->device_ref) {
I  think AVFilter framework call ff_opencl_filter_config_input first, is
it need to check !ctx->device_ref?
> +if (!avctx->hw_device_ctx) {
> +av_log(avctx, AV_LOG_ERROR, "OpenCL filtering requires an "
> +   "OpenCL device.\n");
> +return AVERROR(EINVAL);
> +}
> +
> +err = opencl_filter_set_device(avctx, avctx->hw_device_ctx);
> +if (err < 0)
> +return err;
> +}
> +
>  output_frames_ref = av_hwframe_ctx_alloc(ctx->device_ref);
>  if (!output_frames_ref) {
>  err = AVERROR(ENOMEM);

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


Re: [FFmpeg-devel] [PATCH v4] lavc/audiotoolboxenc: fix noise in encoded audio

2018-01-02 Thread Bang He
maybe you should  return 1, not return ret

On Wed, Jan 3, 2018 at 12:54 PM,  wrote:

> From: Jiejun Zhang 
>
> This fixes #6940
>
> Although undocumented, AudioToolbox seems to require the data supplied
> by the callback (i.e. ffat_encode_callback) being unchanged until the
> next time the callback is called. In the old implementation, the
> AVBuffer backing the frame is recycled after the frame is freed, and
> somebody else (maybe the decoder) will write into the AVBuffer and
> change the data. AudioToolbox then encodes some wrong data and noise
> is produced. Retaining a frame reference solves this problem.
> ---
>  libavcodec/audiotoolboxenc.c | 14 ++
>  1 file changed, 14 insertions(+)
>
> diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
> index 71885d1530..4d8130af96 100644
> --- a/libavcodec/audiotoolboxenc.c
> +++ b/libavcodec/audiotoolboxenc.c
> @@ -48,6 +48,8 @@ typedef struct ATDecodeContext {
>  AudioFrameQueue afq;
>  int eof;
>  int frame_size;
> +
> +AVFrame* encoding_frame;
>  } ATDecodeContext;
>
>  static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile)
> @@ -442,6 +444,10 @@ static av_cold int ffat_init_encoder(AVCodecContext
> *avctx)
>
>  ff_af_queue_init(avctx, >afq);
>
> +at->encoding_frame = av_frame_alloc();
> +if (!at->encoding_frame)
> +return AVERROR(ENOMEM);
> +
>  return 0;
>  }
>
> @@ -453,6 +459,7 @@ static OSStatus ffat_encode_callback(AudioConverterRef
> converter, UInt32 *nb_pac
>  AVCodecContext *avctx = inctx;
>  ATDecodeContext *at = avctx->priv_data;
>  AVFrame *frame;
> +int ret;
>
>  if (!at->frame_queue.available) {
>  if (at->eof) {
> @@ -475,6 +482,12 @@ static OSStatus ffat_encode_callback(AudioConverterRef
> converter, UInt32 *nb_pac
>  if (*nb_packets > frame->nb_samples)
>  *nb_packets = frame->nb_samples;
>
> +av_frame_unref(at->encoding_frame);
> +if ((ret = av_frame_ref(at->encoding_frame, frame)) < 0) {
> +*nb_packets = 0;
> +return ret;
> +}
> +
>  ff_bufqueue_add(avctx, >used_frame_queue, frame);
>
>  return 0;
> @@ -565,6 +578,7 @@ static av_cold int ffat_close_encoder(AVCodecContext
> *avctx)
>  ff_bufqueue_discard_all(>frame_queue);
>  ff_bufqueue_discard_all(>used_frame_queue);
>  ff_af_queue_close(>afq);
> +av_frame_free(>encoding_frame);
>  return 0;
>  }
>
> --
> 2.14.3 (Apple Git-98)
>
> ___
> 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] avformat/hls: fix seek accuracy problem

2018-01-02 Thread Wu Zhiqiang
On Wed, Jan 3, 2018 at 1:00 PM, Aman Gupta  wrote:

> On Tue, Jan 2, 2018 at 7:27 PM Wu Zhiqiang  wrote:
>
> > On Wed, Jan 3, 2018 at 2:03 AM, Aman Gupta  wrote:
> >
> > > On Tue, Jan 2, 2018 at 3:05 AM Steven Liu 
> > wrote:
> > >
> > > > 2018-01-02 18:28 GMT+08:00  :
> > > > > From: Wu Zhiqiang 
> > > > >
> > > > > HLS demuxer seeking use dts instead of pts.
> > > > > Demuxer skip some frame when dts is before pts in special case.
> > > > > And it is impossible to re-seek back to start time after playing.
> > > > > ---
> > > > >  libavformat/hls.c | 18 ++
> > > > >  1 file changed, 14 insertions(+), 4 deletions(-)
> > > > >
> > > > > diff --git a/libavformat/hls.c b/libavformat/hls.c
> > > > > index 950cc4c3bd..069e7b06e9 100644
> > > > > --- a/libavformat/hls.c
> > > > > +++ b/libavformat/hls.c
> > > > > @@ -2086,6 +2086,7 @@ static int hls_read_packet(AVFormatContext
> *s,
> > > > AVPacket *pkt)
> > > > >   * stream */
> > > > >  if (pls->needed && !pls->pkt.data) {
> > > > >  while (1) {
> > > > > +int64_t pkt_ts;
> > > > >  int64_t ts_diff;
> > > > >  AVRational tb;
> > > > >  ret = av_read_frame(pls->ctx, >pkt);
> > > > > @@ -2101,9 +2102,17 @@ static int hls_read_packet(AVFormatContext
> *s,
> > > > AVPacket *pkt)
> > > > >  fill_timing_for_id3_
> timestamped_stream(pls);
> > > > >  }
> > > > >
> > > > > +if (pls->pkt.pts != AV_NOPTS_VALUE)
> > > > > +pkt_ts =  pls->pkt.pts;
> > > > > +else if (pls->pkt.dts != AV_NOPTS_VALUE)
> > > > > +pkt_ts =  pls->pkt.dts;
> > > > > +else
> > > > > +pkt_ts = AV_NOPTS_VALUE;
> > > > > +
> > > > > +
> > > > >  if (c->first_timestamp == AV_NOPTS_VALUE &&
> > > > > -pls->pkt.dts   != AV_NOPTS_VALUE)
> > > > > -c->first_timestamp =
> > > av_rescale_q(pls->pkt.dts,
> > > > > +pkt_ts   != AV_NOPTS_VALUE)
> > > > > +c->first_timestamp = av_rescale_q(pkt_ts,
> > > > >  get_timebase(pls), AV_TIME_BASE_Q);
> > > > >  }
> > > > >
> > > > > @@ -2113,15 +2122,16 @@ static int hls_read_packet(AVFormatContext
> > *s,
> > > > AVPacket *pkt)
> > > > >  if (pls->seek_stream_index < 0 ||
> > > > >  pls->seek_stream_index ==
> > pls->pkt.stream_index) {
> > > > >
> > > > > -if (pls->pkt.dts == AV_NOPTS_VALUE) {
> > > > > +if (pkt_ts == AV_NOPTS_VALUE) {
> > > > >  pls->seek_timestamp = AV_NOPTS_VALUE;
> > > > >  break;
> > > > >  }
> > > > >
> > > > >  tb = get_timebase(pls);
> > > > > -ts_diff = av_rescale_rnd(pls->pkt.dts,
> > > AV_TIME_BASE,
> > > > > +ts_diff = av_rescale_rnd(pkt_ts, AV_TIME_BASE,
> > > > >  tb.den,
> AV_ROUND_DOWN) -
> > > > >  pls->seek_timestamp;
> > > > > +
> > > > >  if (ts_diff >= 0 && (pls->seek_flags  &
> > > > AVSEEK_FLAG_ANY ||
> > > > >  pls->pkt.flags &
> > > > AV_PKT_FLAG_KEY)) {
> > > > >  pls->seek_timestamp = AV_NOPTS_VALUE;
> > > > > --
> > > > > 2.15.0
> > > > >
> > > >
> > > >
> > > > LGTM , This patch can fix ticket : https://trac.ffmpeg.org/
> ticket/6850
> > > >
> > >
> > > LGTM, I've experienced this bug also.
> > >
> > >
> > > >
> > > > Thanks
> > > >
> > > > Steven
> > > > ___
> > > > 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
> > >
> > I found another problem of seeking.
> > Example:http://devimages.apple.com.edgekey.net/
> > streaming/examples/bipbop_4x3/gear1/prog_index.m3u8,
> > return EIO error when seek to beginning.
>
>
> I experienced this problem a few months ago also, and decided to remove the
> EIO error. What do you think?
>
> @@ -2240,9 +2239,12 @@ static int hls_read_seek(AVFormatContext *s,
> int stream_index,
>  }
>  /* check if the timestamp is valid for the playlist with the
>   * specified stream index */
> -if (!seek_pls || !find_timestamp_in_playlist(c, seek_pls,
> seek_timestamp, _no))
> +if (!seek_pls)
>  return AVERROR(EIO);
>
> +/* find the closest timestamp */
> +

Re: [FFmpeg-devel] [PATCH] avformat/hls: fix seek accuracy problem

2018-01-02 Thread Aman Gupta
On Tue, Jan 2, 2018 at 7:27 PM Wu Zhiqiang  wrote:

> On Wed, Jan 3, 2018 at 2:03 AM, Aman Gupta  wrote:
>
> > On Tue, Jan 2, 2018 at 3:05 AM Steven Liu 
> wrote:
> >
> > > 2018-01-02 18:28 GMT+08:00  :
> > > > From: Wu Zhiqiang 
> > > >
> > > > HLS demuxer seeking use dts instead of pts.
> > > > Demuxer skip some frame when dts is before pts in special case.
> > > > And it is impossible to re-seek back to start time after playing.
> > > > ---
> > > >  libavformat/hls.c | 18 ++
> > > >  1 file changed, 14 insertions(+), 4 deletions(-)
> > > >
> > > > diff --git a/libavformat/hls.c b/libavformat/hls.c
> > > > index 950cc4c3bd..069e7b06e9 100644
> > > > --- a/libavformat/hls.c
> > > > +++ b/libavformat/hls.c
> > > > @@ -2086,6 +2086,7 @@ static int hls_read_packet(AVFormatContext *s,
> > > AVPacket *pkt)
> > > >   * stream */
> > > >  if (pls->needed && !pls->pkt.data) {
> > > >  while (1) {
> > > > +int64_t pkt_ts;
> > > >  int64_t ts_diff;
> > > >  AVRational tb;
> > > >  ret = av_read_frame(pls->ctx, >pkt);
> > > > @@ -2101,9 +2102,17 @@ static int hls_read_packet(AVFormatContext *s,
> > > AVPacket *pkt)
> > > >  fill_timing_for_id3_timestamped_stream(pls);
> > > >  }
> > > >
> > > > +if (pls->pkt.pts != AV_NOPTS_VALUE)
> > > > +pkt_ts =  pls->pkt.pts;
> > > > +else if (pls->pkt.dts != AV_NOPTS_VALUE)
> > > > +pkt_ts =  pls->pkt.dts;
> > > > +else
> > > > +pkt_ts = AV_NOPTS_VALUE;
> > > > +
> > > > +
> > > >  if (c->first_timestamp == AV_NOPTS_VALUE &&
> > > > -pls->pkt.dts   != AV_NOPTS_VALUE)
> > > > -c->first_timestamp =
> > av_rescale_q(pls->pkt.dts,
> > > > +pkt_ts   != AV_NOPTS_VALUE)
> > > > +c->first_timestamp = av_rescale_q(pkt_ts,
> > > >  get_timebase(pls), AV_TIME_BASE_Q);
> > > >  }
> > > >
> > > > @@ -2113,15 +2122,16 @@ static int hls_read_packet(AVFormatContext
> *s,
> > > AVPacket *pkt)
> > > >  if (pls->seek_stream_index < 0 ||
> > > >  pls->seek_stream_index ==
> pls->pkt.stream_index) {
> > > >
> > > > -if (pls->pkt.dts == AV_NOPTS_VALUE) {
> > > > +if (pkt_ts == AV_NOPTS_VALUE) {
> > > >  pls->seek_timestamp = AV_NOPTS_VALUE;
> > > >  break;
> > > >  }
> > > >
> > > >  tb = get_timebase(pls);
> > > > -ts_diff = av_rescale_rnd(pls->pkt.dts,
> > AV_TIME_BASE,
> > > > +ts_diff = av_rescale_rnd(pkt_ts, AV_TIME_BASE,
> > > >  tb.den, AV_ROUND_DOWN) -
> > > >  pls->seek_timestamp;
> > > > +
> > > >  if (ts_diff >= 0 && (pls->seek_flags  &
> > > AVSEEK_FLAG_ANY ||
> > > >  pls->pkt.flags &
> > > AV_PKT_FLAG_KEY)) {
> > > >  pls->seek_timestamp = AV_NOPTS_VALUE;
> > > > --
> > > > 2.15.0
> > > >
> > >
> > >
> > > LGTM , This patch can fix ticket : https://trac.ffmpeg.org/ticket/6850
> > >
> >
> > LGTM, I've experienced this bug also.
> >
> >
> > >
> > > Thanks
> > >
> > > Steven
> > > ___
> > > 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
> >
> I found another problem of seeking.
> Example:http://devimages.apple.com.edgekey.net/
> streaming/examples/bipbop_4x3/gear1/prog_index.m3u8,
> return EIO error when seek to beginning.


I experienced this problem a few months ago also, and decided to remove the
EIO error. What do you think?

@@ -2240,9 +2239,12 @@ static int hls_read_seek(AVFormatContext *s,
int stream_index,
 }
 /* check if the timestamp is valid for the playlist with the
  * specified stream index */
-if (!seek_pls || !find_timestamp_in_playlist(c, seek_pls,
seek_timestamp, _no))
+if (!seek_pls)
 return AVERROR(EIO);

+/* find the closest timestamp */
+find_timestamp_in_playlist(c, seek_pls, seek_timestamp, _no);
+
 /* set segment now so we do not need to search again below */
 seek_pls->cur_seq_no = seq_no;
 seek_pls->seek_stream_index = stream_subdemuxer_index;





> Calculating first_timestamp only using first packet timestamp may cause
> problem
> when streams 

[FFmpeg-devel] [PATCH v4] lavc/audiotoolboxenc: fix noise in encoded audio

2018-01-02 Thread zhangjiejun1992
From: Jiejun Zhang 

This fixes #6940

Although undocumented, AudioToolbox seems to require the data supplied
by the callback (i.e. ffat_encode_callback) being unchanged until the
next time the callback is called. In the old implementation, the
AVBuffer backing the frame is recycled after the frame is freed, and
somebody else (maybe the decoder) will write into the AVBuffer and
change the data. AudioToolbox then encodes some wrong data and noise
is produced. Retaining a frame reference solves this problem.
---
 libavcodec/audiotoolboxenc.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
index 71885d1530..4d8130af96 100644
--- a/libavcodec/audiotoolboxenc.c
+++ b/libavcodec/audiotoolboxenc.c
@@ -48,6 +48,8 @@ typedef struct ATDecodeContext {
 AudioFrameQueue afq;
 int eof;
 int frame_size;
+
+AVFrame* encoding_frame;
 } ATDecodeContext;
 
 static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile)
@@ -442,6 +444,10 @@ static av_cold int ffat_init_encoder(AVCodecContext *avctx)
 
 ff_af_queue_init(avctx, >afq);
 
+at->encoding_frame = av_frame_alloc();
+if (!at->encoding_frame)
+return AVERROR(ENOMEM);
+
 return 0;
 }
 
@@ -453,6 +459,7 @@ static OSStatus ffat_encode_callback(AudioConverterRef 
converter, UInt32 *nb_pac
 AVCodecContext *avctx = inctx;
 ATDecodeContext *at = avctx->priv_data;
 AVFrame *frame;
+int ret;
 
 if (!at->frame_queue.available) {
 if (at->eof) {
@@ -475,6 +482,12 @@ static OSStatus ffat_encode_callback(AudioConverterRef 
converter, UInt32 *nb_pac
 if (*nb_packets > frame->nb_samples)
 *nb_packets = frame->nb_samples;
 
+av_frame_unref(at->encoding_frame);
+if ((ret = av_frame_ref(at->encoding_frame, frame)) < 0) {
+*nb_packets = 0;
+return ret;
+}
+
 ff_bufqueue_add(avctx, >used_frame_queue, frame);
 
 return 0;
@@ -565,6 +578,7 @@ static av_cold int ffat_close_encoder(AVCodecContext *avctx)
 ff_bufqueue_discard_all(>frame_queue);
 ff_bufqueue_discard_all(>used_frame_queue);
 ff_af_queue_close(>afq);
+av_frame_free(>encoding_frame);
 return 0;
 }
 
-- 
2.14.3 (Apple Git-98)

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


Re: [FFmpeg-devel] [PATCH v3] lavc/audiotoolboxenc: fix noise in encoded audio

2018-01-02 Thread James Almer
On 1/3/2018 1:02 AM, Jiejun Zhang wrote:
> On Wed, Jan 3, 2018 at 10:02 AM, James Almer  wrote:
>> On 1/2/2018 1:24 PM, zhangjiejun1...@gmail.com wrote:
>>> From: Jiejun Zhang 
>>>
>>> This fixes #6940
>>>
>>> Although undocumented, AudioToolbox seems to require the data supplied
>>> by the callback (i.e. ffat_encode_callback) being unchanged until the
>>> next time the callback is called. In the old implementation, the
>>> AVBuffer backing the frame is recycled after the frame is freed, and
>>> somebody else (maybe the decoder) will write into the AVBuffer and
>>> change the data. AudioToolbox then encodes some wrong data and noise
>>> is produced. Retaining a frame reference solves this problem.
>>> ---
>>>  libavcodec/audiotoolboxenc.c | 12 
>>>  1 file changed, 12 insertions(+)
>>>
>>> diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
>>> index 71885d1530..5d3a746348 100644
>>> --- a/libavcodec/audiotoolboxenc.c
>>> +++ b/libavcodec/audiotoolboxenc.c
>>> @@ -48,6 +48,8 @@ typedef struct ATDecodeContext {
>>>  AudioFrameQueue afq;
>>>  int eof;
>>>  int frame_size;
>>> +
>>> +AVFrame* encoding_frame;
>>>  } ATDecodeContext;
>>>
>>>  static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile)
>>> @@ -442,6 +444,10 @@ static av_cold int ffat_init_encoder(AVCodecContext 
>>> *avctx)
>>>
>>>  ff_af_queue_init(avctx, >afq);
>>>
>>> +at->encoding_frame = av_frame_alloc();
>>> +if (!at->encoding_frame)
>>> +return AVERROR(ENOMEM);
>>> +
>>>  return 0;
>>>  }
>>>
>>> @@ -453,6 +459,7 @@ static OSStatus ffat_encode_callback(AudioConverterRef 
>>> converter, UInt32 *nb_pac
>>>  AVCodecContext *avctx = inctx;
>>>  ATDecodeContext *at = avctx->priv_data;
>>>  AVFrame *frame;
>>> +int ret;
>>>
>>>  if (!at->frame_queue.available) {
>>>  if (at->eof) {
>>> @@ -475,6 +482,10 @@ static OSStatus ffat_encode_callback(AudioConverterRef 
>>> converter, UInt32 *nb_pac
>>>  if (*nb_packets > frame->nb_samples)
>>>  *nb_packets = frame->nb_samples;
>>>
>>> +av_frame_unref(at->encoding_frame);
>>> +if ((ret = av_frame_ref(at->encoding_frame, frame)) < 0)
>>> +return ret;
>>
>> Wouldn't you have to set nb_packets to 0 in case of failure? And for a
>> non libav* callback function maybe this shouldn't return an AVERROR(),
>> but just 1 instead.
> 
> Yeah, will fix it. For the return value, according to Apple's doc: "If
> your callback returns an error, it must return zero packets of data.
> Upon receiving zero packets, the AudioConverterFillComplexBuffer
> function delivers any pending output, stops producing further output,
> and returns the error code.", the return value will be finally
> returned to ffat_encode. So I think it's fine to return an AVERROR
> here, sounds good?

Sure.

> 
>>
>> Also, look at audiotoolboxdec.c, where the reference (packet there
>> instead of frame) is created right before calling
>> AudioConverterFillComplexBuffer(), as it can fail. Maybe you can do
>> something like that instead.
>>
> 
> This might not be possible since a buffer queue is used while
> encoding. There's no way to know which frame is currently being
> encoded outside the callback. According to a previous commit the
> callback is not always called by AudioConverterFillComplexBuffer.
> ___
> 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 v3] lavc/audiotoolboxenc: fix noise in encoded audio

2018-01-02 Thread Jiejun Zhang
On Wed, Jan 3, 2018 at 10:02 AM, James Almer  wrote:
> On 1/2/2018 1:24 PM, zhangjiejun1...@gmail.com wrote:
>> From: Jiejun Zhang 
>>
>> This fixes #6940
>>
>> Although undocumented, AudioToolbox seems to require the data supplied
>> by the callback (i.e. ffat_encode_callback) being unchanged until the
>> next time the callback is called. In the old implementation, the
>> AVBuffer backing the frame is recycled after the frame is freed, and
>> somebody else (maybe the decoder) will write into the AVBuffer and
>> change the data. AudioToolbox then encodes some wrong data and noise
>> is produced. Retaining a frame reference solves this problem.
>> ---
>>  libavcodec/audiotoolboxenc.c | 12 
>>  1 file changed, 12 insertions(+)
>>
>> diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
>> index 71885d1530..5d3a746348 100644
>> --- a/libavcodec/audiotoolboxenc.c
>> +++ b/libavcodec/audiotoolboxenc.c
>> @@ -48,6 +48,8 @@ typedef struct ATDecodeContext {
>>  AudioFrameQueue afq;
>>  int eof;
>>  int frame_size;
>> +
>> +AVFrame* encoding_frame;
>>  } ATDecodeContext;
>>
>>  static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile)
>> @@ -442,6 +444,10 @@ static av_cold int ffat_init_encoder(AVCodecContext 
>> *avctx)
>>
>>  ff_af_queue_init(avctx, >afq);
>>
>> +at->encoding_frame = av_frame_alloc();
>> +if (!at->encoding_frame)
>> +return AVERROR(ENOMEM);
>> +
>>  return 0;
>>  }
>>
>> @@ -453,6 +459,7 @@ static OSStatus ffat_encode_callback(AudioConverterRef 
>> converter, UInt32 *nb_pac
>>  AVCodecContext *avctx = inctx;
>>  ATDecodeContext *at = avctx->priv_data;
>>  AVFrame *frame;
>> +int ret;
>>
>>  if (!at->frame_queue.available) {
>>  if (at->eof) {
>> @@ -475,6 +482,10 @@ static OSStatus ffat_encode_callback(AudioConverterRef 
>> converter, UInt32 *nb_pac
>>  if (*nb_packets > frame->nb_samples)
>>  *nb_packets = frame->nb_samples;
>>
>> +av_frame_unref(at->encoding_frame);
>> +if ((ret = av_frame_ref(at->encoding_frame, frame)) < 0)
>> +return ret;
>
> Wouldn't you have to set nb_packets to 0 in case of failure? And for a
> non libav* callback function maybe this shouldn't return an AVERROR(),
> but just 1 instead.

Yeah, will fix it. For the return value, according to Apple's doc: "If
your callback returns an error, it must return zero packets of data.
Upon receiving zero packets, the AudioConverterFillComplexBuffer
function delivers any pending output, stops producing further output,
and returns the error code.", the return value will be finally
returned to ffat_encode. So I think it's fine to return an AVERROR
here, sounds good?

>
> Also, look at audiotoolboxdec.c, where the reference (packet there
> instead of frame) is created right before calling
> AudioConverterFillComplexBuffer(), as it can fail. Maybe you can do
> something like that instead.
>

This might not be possible since a buffer queue is used while
encoding. There's no way to know which frame is currently being
encoded outside the callback. According to a previous commit the
callback is not always called by AudioConverterFillComplexBuffer.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2, 1/2] avformat/hls: fix seek accuracy problem

2018-01-02 Thread mymoeyard
From: Wu Zhiqiang 

HLS demuxer seeking use dts instead of pts.
Demuxer skip some frame when dts is before pts in special case.
And it is impossible to re-seek back to start time after playing.
---
 libavformat/hls.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 950cc4c3bd..069e7b06e9 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -2086,6 +2086,7 @@ static int hls_read_packet(AVFormatContext *s, AVPacket 
*pkt)
  * stream */
 if (pls->needed && !pls->pkt.data) {
 while (1) {
+int64_t pkt_ts;
 int64_t ts_diff;
 AVRational tb;
 ret = av_read_frame(pls->ctx, >pkt);
@@ -2101,9 +2102,17 @@ static int hls_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 fill_timing_for_id3_timestamped_stream(pls);
 }
 
+if (pls->pkt.pts != AV_NOPTS_VALUE)
+pkt_ts =  pls->pkt.pts;
+else if (pls->pkt.dts != AV_NOPTS_VALUE)
+pkt_ts =  pls->pkt.dts;
+else
+pkt_ts = AV_NOPTS_VALUE;
+
+
 if (c->first_timestamp == AV_NOPTS_VALUE &&
-pls->pkt.dts   != AV_NOPTS_VALUE)
-c->first_timestamp = av_rescale_q(pls->pkt.dts,
+pkt_ts   != AV_NOPTS_VALUE)
+c->first_timestamp = av_rescale_q(pkt_ts,
 get_timebase(pls), AV_TIME_BASE_Q);
 }
 
@@ -2113,15 +2122,16 @@ static int hls_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 if (pls->seek_stream_index < 0 ||
 pls->seek_stream_index == pls->pkt.stream_index) {
 
-if (pls->pkt.dts == AV_NOPTS_VALUE) {
+if (pkt_ts == AV_NOPTS_VALUE) {
 pls->seek_timestamp = AV_NOPTS_VALUE;
 break;
 }
 
 tb = get_timebase(pls);
-ts_diff = av_rescale_rnd(pls->pkt.dts, AV_TIME_BASE,
+ts_diff = av_rescale_rnd(pkt_ts, AV_TIME_BASE,
 tb.den, AV_ROUND_DOWN) -
 pls->seek_timestamp;
+
 if (ts_diff >= 0 && (pls->seek_flags  & AVSEEK_FLAG_ANY ||
 pls->pkt.flags & AV_PKT_FLAG_KEY)) {
 pls->seek_timestamp = AV_NOPTS_VALUE;
-- 
2.15.0

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


[FFmpeg-devel] [PATCH v2, 2/2] avformat/hls: fix start time seek error

2018-01-02 Thread mymoeyard
From: Wu Zhiqiang 

Calculate first_timestamp based on first packet timestamp.
Some m3u8 have streams that second one has smaller timestamp
in first packet of this stream.
Start/seek from start time may fail due to EIO error.
It should be based on start_time of AvFormatContext.

Signed-off-by: Wu Zhiqiang 
---
 libavformat/hls.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 069e7b06e9..125f68ca4e 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -2110,10 +2110,8 @@ static int hls_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 pkt_ts = AV_NOPTS_VALUE;
 
 
-if (c->first_timestamp == AV_NOPTS_VALUE &&
-pkt_ts   != AV_NOPTS_VALUE)
-c->first_timestamp = av_rescale_q(pkt_ts,
-get_timebase(pls), AV_TIME_BASE_Q);
+c->first_timestamp = s->start_time != AV_NOPTS_VALUE ? 
s->start_time : 0;
+
 }
 
 if (pls->seek_timestamp == AV_NOPTS_VALUE)
-- 
2.15.0

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


Re: [FFmpeg-devel] [PATCH] avformat/hls: fix seek accuracy problem

2018-01-02 Thread Wu Zhiqiang
On Wed, Jan 3, 2018 at 2:03 AM, Aman Gupta  wrote:

> On Tue, Jan 2, 2018 at 3:05 AM Steven Liu  wrote:
>
> > 2018-01-02 18:28 GMT+08:00  :
> > > From: Wu Zhiqiang 
> > >
> > > HLS demuxer seeking use dts instead of pts.
> > > Demuxer skip some frame when dts is before pts in special case.
> > > And it is impossible to re-seek back to start time after playing.
> > > ---
> > >  libavformat/hls.c | 18 ++
> > >  1 file changed, 14 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/libavformat/hls.c b/libavformat/hls.c
> > > index 950cc4c3bd..069e7b06e9 100644
> > > --- a/libavformat/hls.c
> > > +++ b/libavformat/hls.c
> > > @@ -2086,6 +2086,7 @@ static int hls_read_packet(AVFormatContext *s,
> > AVPacket *pkt)
> > >   * stream */
> > >  if (pls->needed && !pls->pkt.data) {
> > >  while (1) {
> > > +int64_t pkt_ts;
> > >  int64_t ts_diff;
> > >  AVRational tb;
> > >  ret = av_read_frame(pls->ctx, >pkt);
> > > @@ -2101,9 +2102,17 @@ static int hls_read_packet(AVFormatContext *s,
> > AVPacket *pkt)
> > >  fill_timing_for_id3_timestamped_stream(pls);
> > >  }
> > >
> > > +if (pls->pkt.pts != AV_NOPTS_VALUE)
> > > +pkt_ts =  pls->pkt.pts;
> > > +else if (pls->pkt.dts != AV_NOPTS_VALUE)
> > > +pkt_ts =  pls->pkt.dts;
> > > +else
> > > +pkt_ts = AV_NOPTS_VALUE;
> > > +
> > > +
> > >  if (c->first_timestamp == AV_NOPTS_VALUE &&
> > > -pls->pkt.dts   != AV_NOPTS_VALUE)
> > > -c->first_timestamp =
> av_rescale_q(pls->pkt.dts,
> > > +pkt_ts   != AV_NOPTS_VALUE)
> > > +c->first_timestamp = av_rescale_q(pkt_ts,
> > >  get_timebase(pls), AV_TIME_BASE_Q);
> > >  }
> > >
> > > @@ -2113,15 +2122,16 @@ static int hls_read_packet(AVFormatContext *s,
> > AVPacket *pkt)
> > >  if (pls->seek_stream_index < 0 ||
> > >  pls->seek_stream_index == pls->pkt.stream_index) {
> > >
> > > -if (pls->pkt.dts == AV_NOPTS_VALUE) {
> > > +if (pkt_ts == AV_NOPTS_VALUE) {
> > >  pls->seek_timestamp = AV_NOPTS_VALUE;
> > >  break;
> > >  }
> > >
> > >  tb = get_timebase(pls);
> > > -ts_diff = av_rescale_rnd(pls->pkt.dts,
> AV_TIME_BASE,
> > > +ts_diff = av_rescale_rnd(pkt_ts, AV_TIME_BASE,
> > >  tb.den, AV_ROUND_DOWN) -
> > >  pls->seek_timestamp;
> > > +
> > >  if (ts_diff >= 0 && (pls->seek_flags  &
> > AVSEEK_FLAG_ANY ||
> > >  pls->pkt.flags &
> > AV_PKT_FLAG_KEY)) {
> > >  pls->seek_timestamp = AV_NOPTS_VALUE;
> > > --
> > > 2.15.0
> > >
> >
> >
> > LGTM , This patch can fix ticket : https://trac.ffmpeg.org/ticket/6850
> >
>
> LGTM, I've experienced this bug also.
>
>
> >
> > Thanks
> >
> > Steven
> > ___
> > 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
>
I found another problem of seeking.
Example:http://devimages.apple.com.edgekey.net/
streaming/examples/bipbop_4x3/gear1/prog_index.m3u8,
return EIO error when seek to beginning.
Calculating first_timestamp only using first packet timestamp may cause
problem
when streams have each  different start time.
It is possible that second stream has smaller start time.
I try to fix it by using start_time of AVformatContext.
I am not not sure why not directly use start time.

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


Re: [FFmpeg-devel] [PATCH v3] lavc/audiotoolboxenc: fix noise in encoded audio

2018-01-02 Thread James Almer
On 1/2/2018 1:24 PM, zhangjiejun1...@gmail.com wrote:
> From: Jiejun Zhang 
> 
> This fixes #6940
> 
> Although undocumented, AudioToolbox seems to require the data supplied
> by the callback (i.e. ffat_encode_callback) being unchanged until the
> next time the callback is called. In the old implementation, the
> AVBuffer backing the frame is recycled after the frame is freed, and
> somebody else (maybe the decoder) will write into the AVBuffer and
> change the data. AudioToolbox then encodes some wrong data and noise
> is produced. Retaining a frame reference solves this problem.
> ---
>  libavcodec/audiotoolboxenc.c | 12 
>  1 file changed, 12 insertions(+)
> 
> diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
> index 71885d1530..5d3a746348 100644
> --- a/libavcodec/audiotoolboxenc.c
> +++ b/libavcodec/audiotoolboxenc.c
> @@ -48,6 +48,8 @@ typedef struct ATDecodeContext {
>  AudioFrameQueue afq;
>  int eof;
>  int frame_size;
> +
> +AVFrame* encoding_frame;
>  } ATDecodeContext;
>  
>  static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile)
> @@ -442,6 +444,10 @@ static av_cold int ffat_init_encoder(AVCodecContext 
> *avctx)
>  
>  ff_af_queue_init(avctx, >afq);
>  
> +at->encoding_frame = av_frame_alloc();
> +if (!at->encoding_frame)
> +return AVERROR(ENOMEM);
> +
>  return 0;
>  }
>  
> @@ -453,6 +459,7 @@ static OSStatus ffat_encode_callback(AudioConverterRef 
> converter, UInt32 *nb_pac
>  AVCodecContext *avctx = inctx;
>  ATDecodeContext *at = avctx->priv_data;
>  AVFrame *frame;
> +int ret;
>  
>  if (!at->frame_queue.available) {
>  if (at->eof) {
> @@ -475,6 +482,10 @@ static OSStatus ffat_encode_callback(AudioConverterRef 
> converter, UInt32 *nb_pac
>  if (*nb_packets > frame->nb_samples)
>  *nb_packets = frame->nb_samples;
>  
> +av_frame_unref(at->encoding_frame);
> +if ((ret = av_frame_ref(at->encoding_frame, frame)) < 0)
> +return ret;

Wouldn't you have to set nb_packets to 0 in case of failure? And for a
non libav* callback function maybe this shouldn't return an AVERROR(),
but just 1 instead.

Also, look at audiotoolboxdec.c, where the reference (packet there
instead of frame) is created right before calling
AudioConverterFillComplexBuffer(), as it can fail. Maybe you can do
something like that instead.

> +
>  ff_bufqueue_add(avctx, >used_frame_queue, frame);
>  
>  return 0;
> @@ -565,6 +576,7 @@ static av_cold int ffat_close_encoder(AVCodecContext 
> *avctx)
>  ff_bufqueue_discard_all(>frame_queue);
>  ff_bufqueue_discard_all(>used_frame_queue);
>  ff_af_queue_close(>afq);
> +av_frame_free(>encoding_frame);
>  return 0;
>  }
>  
> 

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


Re: [FFmpeg-devel] [PATCH] avcodec/opus: Add {} over multiline if() body

2018-01-02 Thread Rostislav Pehlivanov
On 2 January 2018 at 22:34, Michael Niedermayer 
wrote:

> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/opus.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/opus.c b/libavcodec/opus.c
> index 9cbf4aed92..d00a17a7f1 100644
> --- a/libavcodec/opus.c
> +++ b/libavcodec/opus.c
> @@ -566,12 +566,12 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder
> *rc, int encode)
>  int bits2[CELT_MAX_BANDS];
>
>  /* Spread */
> -if (opus_rc_tell(rc) + 4 <= f->framebits)
> +if (opus_rc_tell(rc) + 4 <= f->framebits) {
>  if (encode)
>  ff_opus_rc_enc_cdf(rc, f->spread, ff_celt_model_spread);
>  else
>  f->spread = ff_opus_rc_dec_cdf(rc, ff_celt_model_spread);
> -else
> +} else
>  f->spread = CELT_SPREAD_NORMAL;
>
>  /* Initialize static allocation caps */
> --
> 2.15.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Add brackets after the } else and it'll look good to me.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 6/6] lavf: add avpriv function to register devices

2018-01-02 Thread Josh de Kock
---
 libavdevice/alldevices.c |  6 +-
 libavformat/allformats.c | 44 +++-
 libavformat/avformat.h   |  4 
 3 files changed, 48 insertions(+), 6 deletions(-)

diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index 6b2a512..041eb85 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -105,6 +105,8 @@ static void av_device_init_next(void)
 }
 if (previn)
 previn->next = NULL;
+
+avpriv_register_devices(outdev_list, indev_list);
 }
 
 void avdevice_register_all(void)
@@ -115,9 +117,11 @@ void avdevice_register_all(void)
 static void *device_next(void *prev, int output,
  AVClassCategory c1, AVClassCategory c2)
 {
-pthread_once(_device_next_init, av_device_init_next);
 const AVClass *pc;
 AVClassCategory category = AV_CLASS_CATEGORY_NA;
+
+pthread_once(_device_next_init, av_device_init_next);
+
 if (!prev && !(prev = (output ? (void*)outdev_list[0] : 
(void*)indev_list[0])))
 return NULL;
 
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index fa72acd..52b7088 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -20,6 +20,7 @@
  */
 
 #include "libavutil/thread.h"
+#include "libavdevice/avdevice.h"
 #include "avformat.h"
 #include "rtp.h"
 #include "rdt.h"
@@ -482,6 +483,7 @@ const AVOutputFormat *av_muxer_iterate(void **opaque)
 {
 uintptr_t i = (uintptr_t)*opaque;
 const AVOutputFormat *f = muxer_list[i];
+
 if (f)
 *opaque = (void*)(i + 1);
 return f;
@@ -499,45 +501,77 @@ const AVInputFormat *av_demuxer_iterate(void **opaque){
 #if FF_API_NEXT
 pthread_once_t av_format_next_init = PTHREAD_ONCE_INIT;
 
+static AVInputFormat **indev_list = NULL;
+static AVOutputFormat **outdev_list = NULL;
+
 static void av_format_init_next(void)
 {
 AVOutputFormat *prevout = NULL, *out;
 AVInputFormat *previn = NULL, *in;
 void *i = 0;
-while ((out = (AVOutputFormat*)av_muxer_iterate())) {
+
+for (i = 0; (out = (AVOutputFormat*)av_muxer_iterate());) {
 if (prevout)
 prevout->next = out;
 prevout = out;
 }
+
+if (outdev_list) {
+for (i = 0; (out = (AVOutputFormat*)outdev_list[(int)i]); i = 
(void*)(i + 1)) {
+if (prevout)
+prevout->next = out;
+prevout = out;
+}
+}
+
 if (prevout)
 prevout->next = NULL;
 
-i = 0;
-while ((in = (AVInputFormat*)av_demuxer_iterate())) {
+for (i = 0; (in = (AVInputFormat*)av_demuxer_iterate());) {
 if (previn)
 previn->next = in;
 previn = in;
 }
+
+if (indev_list) {
+for (i = 0; (in = (AVInputFormat*)indev_list[(int)i]); i = (void*)(i + 
1)) {
+if (previn)
+previn->next = in;
+previn = in;
+}
+}
+
 if (previn)
 previn->next = NULL;
 }
 
+void avpriv_register_devices(AVOutputFormat *o[], AVInputFormat *i[])
+{
+outdev_list = o;
+indev_list = i;
+av_format_init_next();
+}
+
 AVInputFormat *av_iformat_next(const AVInputFormat *f)
 {
+void *i = 0;
 pthread_once(_format_next_init, av_format_init_next);
 if (f)
 return f->next;
 else
-return demuxer_list[0];
+/* If there are no demuxers but input devices, then return the first input 
device.
+ * This will still return null if both there are both no demuxers or input 
devices. */
+return demuxer_list[0] ? (AVInputFormat*)demuxer_list[0] : 
(AVInputFormat*)av_indev_iterate();
 }
 
 AVOutputFormat *av_oformat_next(const AVOutputFormat *f)
 {
+void *i = 0;
 pthread_once(_format_next_init, av_format_init_next);
 if (f)
 return f->next;
 else
-return muxer_list[0];
+return muxer_list[0] ? (AVOutputFormat*)muxer_list[0] : 
(AVOutputFormat*)av_outdev_iterate();
 }
 
 void av_register_all(void)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index d38ca4e..56ec41a 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2014,6 +2014,10 @@ int avformat_network_deinit(void);
 
 #if FF_API_NEXT
 /**
+  * Register devices in deprecated format linked list.
+  */
+void avpriv_register_devices(AVOutputFormat *o[], AVInputFormat *i[]);
+/**
  * If f is NULL, returns the first registered input format,
  * if f is non-NULL, returns the next registered input format after f
  * or NULL if f is the last one.
-- 
2.7.4
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 4/6] lavf: move fifo test muxer into separate file

2018-01-02 Thread Josh de Kock
This fixes the fate-fifo-muxer test.
---
 libavformat/Makefile   |   2 +-
 libavformat/allformats.c   |   1 +
 libavformat/fifo_test.c| 150 +
 libavformat/tests/fifo_muxer.c | 115 +--
 4 files changed, 154 insertions(+), 114 deletions(-)
 create mode 100644 libavformat/fifo_test.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index cb70eac..e959cdc 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -165,7 +165,7 @@ OBJS-$(CONFIG_FFM_DEMUXER)   += ffmdec.o
 OBJS-$(CONFIG_FFM_MUXER) += ffmenc.o
 OBJS-$(CONFIG_FFMETADATA_DEMUXER)+= ffmetadec.o
 OBJS-$(CONFIG_FFMETADATA_MUXER)  += ffmetaenc.o
-OBJS-$(CONFIG_FIFO_MUXER)+= fifo.o
+OBJS-$(CONFIG_FIFO_MUXER)+= fifo.o fifo_test.o
 OBJS-$(CONFIG_FILMSTRIP_DEMUXER) += filmstripdec.o
 OBJS-$(CONFIG_FILMSTRIP_MUXER)   += filmstripenc.o
 OBJS-$(CONFIG_FITS_DEMUXER)  += fitsdec.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index c6fdbce..fa72acd 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -127,6 +127,7 @@ extern AVOutputFormat ff_ffm_muxer;
 extern AVInputFormat  ff_ffmetadata_demuxer;
 extern AVOutputFormat ff_ffmetadata_muxer;
 extern AVOutputFormat ff_fifo_muxer;
+extern AVOutputFormat ff_fifo_test_muxer;
 extern AVInputFormat  ff_filmstrip_demuxer;
 extern AVOutputFormat ff_filmstrip_muxer;
 extern AVInputFormat  ff_fits_demuxer;
diff --git a/libavformat/fifo_test.c b/libavformat/fifo_test.c
new file mode 100644
index 000..d889326
--- /dev/null
+++ b/libavformat/fifo_test.c
@@ -0,0 +1,150 @@
+/*
+ * FIFO test pseudo-muxer
+ * Copyright (c) 2016 Jan Sebechlebsky
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with FFmpeg; if not, write to the Free Software * Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include "libavutil/opt.h"
+#include "libavutil/time.h"
+#include "libavutil/avassert.h"
+#include "libavformat/avformat.h"
+#include "libavformat/url.h"
+#include "libavformat/network.h"
+
+/* Implementation of mock muxer to simulate real muxer failures */
+
+#define MAX_TST_PACKETS 128
+#define SLEEPTIME_50_MS 5
+#define SLEEPTIME_10_MS 1
+
+/* Implementation of mock muxer to simulate real muxer failures */
+
+/* This is structure of data sent in packets to
+ * failing muxer */
+typedef struct FailingMuxerPacketData {
+int ret; /* return value of write_packet call*/
+int recover_after;   /* set ret to zero after this number of recovery 
attempts */
+unsigned sleep_time; /* sleep for this long in write_packet to simulate 
long I/O operation */
+} FailingMuxerPacketData;
+
+
+typedef struct FailingMuxerContext {
+AVClass *class;
+int write_header_ret;
+int write_trailer_ret;
+/* If non-zero, summary of processed packets will be printed in deinit */
+int print_deinit_summary;
+
+int flush_count;
+int pts_written[MAX_TST_PACKETS];
+int pts_written_nr;
+} FailingMuxerContext;
+
+static int failing_write_header(AVFormatContext *avf)
+{
+FailingMuxerContext *ctx = avf->priv_data;
+return ctx->write_header_ret;
+}
+
+static int failing_write_packet(AVFormatContext *avf, AVPacket *pkt)
+{
+FailingMuxerContext *ctx = avf->priv_data;
+int ret = 0;
+if (!pkt) {
+ctx->flush_count++;
+} else {
+FailingMuxerPacketData *data = (FailingMuxerPacketData*) pkt->data;
+
+if (!data->recover_after) {
+data->ret = 0;
+} else {
+data->recover_after--;
+}
+
+ret = data->ret;
+
+if (data->sleep_time) {
+int64_t slept = 0;
+while (slept < data->sleep_time) {
+if (ff_check_interrupt(>interrupt_callback))
+return AVERROR_EXIT;
+av_usleep(SLEEPTIME_10_MS);
+slept += SLEEPTIME_10_MS;
+}
+}
+
+if (!ret) {
+ctx->pts_written[ctx->pts_written_nr++] = pkt->pts;
+av_packet_unref(pkt);
+}
+}
+return ret;
+}
+
+static int failing_write_trailer(AVFormatContext *avf)
+{
+FailingMuxerContext *ctx = avf->priv_data;
+return ctx->write_trailer_ret;
+}
+
+static void 

[FFmpeg-devel] [PATCH 5/6] lavd: add new API for iterating input and output devices

2018-01-02 Thread Josh de Kock
---
 configure|  27 ++--
 libavdevice/alldevices.c | 172 +++
 libavdevice/avdevice.c   |  46 -
 libavdevice/avdevice.h   |  28 
 libavdevice/version.h|   4 ++
 5 files changed, 184 insertions(+), 93 deletions(-)

diff --git a/configure b/configure
index 7b46e5c..79eb95a 100755
--- a/configure
+++ b/configure
@@ -569,6 +569,12 @@ add_suffix(){
 for v; do echo ${v}${suffix}; done
 }
 
+remove_suffix(){
+suffix=$1
+shift
+for v; do echo ${v%$suffix}; done
+}
+
 set_all(){
 value=$1
 shift
@@ -3525,17 +3531,18 @@ find_things(){
 sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" 
"$file"
 }
 
-OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
-INDEV_LIST=$(find_thingsindev_IN  libavdevice/alldevices.c)
 FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
 
 find_things_extern(){
 thing=$1
 pattern=$2
 file=$source_path/$3
-sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file"
+out=${4:-$thing}
+sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$out/p" "$file"
 }
 
+OUTDEV_LIST=$(find_things_extern muxer AVOutputFormat libavdevice/alldevices.c 
outdev)
+INDEV_LIST=$(find_things_extern demuxer AVInputFormat libavdevice/alldevices.c 
indev)
 MUXER_LIST=$(find_things_extern muxer AVOutputFormat libavformat/allformats.c)
 DEMUXER_LIST=$(find_things_extern demuxer AVInputFormat 
libavformat/allformats.c)
 ENCODER_LIST=$(find_things_extern encoder AVCodec libavcodec/allcodecs.c)
@@ -7032,7 +7039,17 @@ print_enabled_components(){
 shift 3
 echo "static const $struct_name * const $name[] = {" > $TMPH
 for c in $*; do
-enabled $c && printf "_%s,\n" $c >> $TMPH
+if enabled $c; then
+case $name in
+indev_list)
+c=$(add_suffix _demuxer $(remove_suffix _indev $c))
+;;
+outdev_list)
+c=$(add_suffix _muxer $(remove_suffix _outdev $c))
+;;
+esac
+printf "_%s,\n" $c >> $TMPH
+fi
 done
 echo "NULL };" >> $TMPH
 cp_if_changed $TMPH $file
@@ -7041,6 +7058,8 @@ print_enabled_components(){
 print_enabled_components libavcodec/codec_list.c AVCodec codec_list $CODEC_LIST
 print_enabled_components libavcodec/parser_list.c AVCodecParser parser_list 
$PARSER_LIST
 print_enabled_components libavcodec/bsf_list.c AVBitStreamFilter 
bitstream_filters $BSF_LIST
+print_enabled_components libavdevice/indev_list.c AVInputFormat indev_list 
$INDEV_LIST
+print_enabled_components libavdevice/outdev_list.c AVOutputFormat outdev_list 
$OUTDEV_LIST
 print_enabled_components libavformat/demuxer_list.c AVInputFormat demuxer_list 
$DEMUXER_LIST
 print_enabled_components libavformat/muxer_list.c AVOutputFormat muxer_list 
$MUXER_LIST
 print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols 
$PROTOCOL_LIST
diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index b767b6a..6b2a512 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -22,57 +22,143 @@
 #include "libavutil/thread.h"
 #include "avdevice.h"
 
-#define REGISTER_OUTDEV(X, x)   \
-{   \
-extern AVOutputFormat ff_##x##_muxer;   \
-if (CONFIG_##X##_OUTDEV)\
-av_register_output_format(_##x##_muxer); \
+/* devices */
+extern AVInputFormat  ff_alsa_demuxer;
+extern AVOutputFormat ff_alsa_muxer;
+extern AVInputFormat  ff_avfoundation_demuxer;
+extern AVInputFormat  ff_bktr_demuxer;
+extern AVOutputFormat ff_caca_muxer;
+extern AVInputFormat  ff_decklink_demuxer;
+extern AVOutputFormat ff_decklink_muxer;
+extern AVInputFormat  ff_libndi_newtek_demuxer;
+extern AVOutputFormat ff_libndi_newtek_muxer;
+extern AVInputFormat  ff_dshow_demuxer;
+extern AVInputFormat  ff_fbdev_demuxer;
+extern AVOutputFormat ff_fbdev_muxer;
+extern AVInputFormat  ff_gdigrab_demuxer;
+extern AVInputFormat  ff_iec61883_demuxer;
+extern AVInputFormat  ff_jack_demuxer;
+extern AVInputFormat  ff_kmsgrab_demuxer;
+extern AVInputFormat  ff_lavfi_demuxer;
+extern AVInputFormat  ff_openal_demuxer;
+extern AVOutputFormat ff_opengl_muxer;
+extern AVInputFormat  ff_oss_demuxer;
+extern AVOutputFormat ff_oss_muxer;
+extern AVInputFormat  ff_pulse_demuxer;
+extern AVOutputFormat ff_pulse_muxer;
+extern AVOutputFormat ff_sdl2_muxer;
+extern AVInputFormat  ff_sndio_demuxer;
+extern AVOutputFormat ff_sndio_muxer;
+extern AVInputFormat  ff_v4l2_demuxer;
+extern AVOutputFormat ff_v4l2_muxer;
+extern AVInputFormat  ff_vfwcap_demuxer;
+extern AVInputFormat  ff_xcbgrab_demuxer;
+extern AVOutputFormat ff_xv_muxer;
+
+/* external libraries */
+extern 

[FFmpeg-devel] [PATCH 2/6] lavf/rtp: replace linked list with array

2018-01-02 Thread Josh de Kock
---
 libavformat/allformats.c |   4 --
 libavformat/rdt.c|   8 +--
 libavformat/rdt.h|   3 +
 libavformat/rtpdec.c | 157 ++-
 libavformat/rtpdec.h |  29 -
 libavformat/version.h|   4 +-
 6 files changed, 136 insertions(+), 69 deletions(-)

diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 6a9b988..593baf3 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -283,10 +283,6 @@ static void register_all(void)
 REGISTER_DEMUXER (SDR2, sdr2);
 REGISTER_DEMUXER (SDS,  sds);
 REGISTER_DEMUXER (SDX,  sdx);
-#if CONFIG_RTPDEC
-ff_register_rtp_dynamic_payload_handlers();
-ff_register_rdt_dynamic_payload_handlers();
-#endif
 REGISTER_DEMUXER (SEGAFILM, segafilm);
 REGISTER_MUXER   (SEGMENT,  segment);
 REGISTER_MUXER   (SEGMENT,  stream_segment);
diff --git a/libavformat/rdt.c b/libavformat/rdt.c
index b69827f..4d6321e 100644
--- a/libavformat/rdt.c
+++ b/libavformat/rdt.c
@@ -554,7 +554,7 @@ rdt_close_context (PayloadContext *rdt)
 }
 
 #define RDT_HANDLER(n, s, t) \
-static RTPDynamicProtocolHandler rdt_ ## n ## _handler = { \
+RTPDynamicProtocolHandler ff_rdt_ ## n ## _handler = { \
 .enc_name = s, \
 .codec_type   = t, \
 .codec_id = AV_CODEC_ID_NONE, \
@@ -570,10 +570,8 @@ RDT_HANDLER(live_audio, "x-pn-multirate-realaudio-live", 
AVMEDIA_TYPE_AUDIO);
 RDT_HANDLER(video,  "x-pn-realvideo",AVMEDIA_TYPE_VIDEO);
 RDT_HANDLER(audio,  "x-pn-realaudio",AVMEDIA_TYPE_AUDIO);
 
+#if FF_API_RTP_NEXT
 void ff_register_rdt_dynamic_payload_handlers(void)
 {
-ff_register_dynamic_payload_handler(_video_handler);
-ff_register_dynamic_payload_handler(_audio_handler);
-ff_register_dynamic_payload_handler(_live_video_handler);
-ff_register_dynamic_payload_handler(_live_audio_handler);
 }
+#endif
diff --git a/libavformat/rdt.h b/libavformat/rdt.h
index ce6026f..a87057d 100644
--- a/libavformat/rdt.h
+++ b/libavformat/rdt.h
@@ -59,10 +59,13 @@ void ff_rdt_parse_close(RDTDemuxContext *s);
 void ff_rdt_calc_response_and_checksum(char response[41], char chksum[9],
const char *challenge);
 
+#if FF_API_RTP_NEXT
 /**
  * Register RDT-related dynamic payload handlers with our cache.
  */
+attribute_deprecated
 void ff_register_rdt_dynamic_payload_handlers(void);
+#endif
 
 /**
  * Add subscription information to Subscribe parameter string.
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 4acb1ca..2e777c9 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -22,6 +22,7 @@
 #include "libavutil/mathematics.h"
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/thread.h"
 #include "libavutil/time.h"
 
 #include "avformat.h"
@@ -69,88 +70,130 @@ static RTPDynamicProtocolHandler t140_dynamic_handler = { 
/* RFC 4103 */
 .codec_id   = AV_CODEC_ID_TEXT,
 };
 
-static RTPDynamicProtocolHandler *rtp_first_dynamic_payload_handler = NULL;
+extern RTPDynamicProtocolHandler ff_rdt_video_handler;
+extern RTPDynamicProtocolHandler ff_rdt_audio_handler;
+extern RTPDynamicProtocolHandler ff_rdt_live_video_handler;
+extern RTPDynamicProtocolHandler ff_rdt_live_audio_handler;
+
+static const RTPDynamicProtocolHandler *rtp_dynamic_protocol_handler_list[] = {
+/* rtp */
+_ac3_dynamic_handler,
+_amr_nb_dynamic_handler,
+_amr_wb_dynamic_handler,
+_dv_dynamic_handler,
+_g726_16_dynamic_handler,
+_g726_24_dynamic_handler,
+_g726_32_dynamic_handler,
+_g726_40_dynamic_handler,
+_g726le_16_dynamic_handler,
+_g726le_24_dynamic_handler,
+_g726le_32_dynamic_handler,
+_g726le_40_dynamic_handler,
+_h261_dynamic_handler,
+_h263_1998_dynamic_handler,
+_h263_2000_dynamic_handler,
+_h263_rfc2190_dynamic_handler,
+_h264_dynamic_handler,
+_hevc_dynamic_handler,
+_ilbc_dynamic_handler,
+_jpeg_dynamic_handler,
+_mp4a_latm_dynamic_handler,
+_mp4v_es_dynamic_handler,
+_mpeg_audio_dynamic_handler,
+_mpeg_audio_robust_dynamic_handler,
+_mpeg_video_dynamic_handler,
+_mpeg4_generic_dynamic_handler,
+_mpegts_dynamic_handler,
+_ms_rtp_asf_pfa_handler,
+_ms_rtp_asf_pfv_handler,
+_qcelp_dynamic_handler,
+_qdm2_dynamic_handler,
+_qt_rtp_aud_handler,
+_qt_rtp_vid_handler,
+_quicktime_rtp_aud_handler,
+_quicktime_rtp_vid_handler,
+_rfc4175_rtp_handler,
+_svq3_dynamic_handler,
+_theora_dynamic_handler,
+_vc2hq_dynamic_handler,
+_vorbis_dynamic_handler,
+_vp8_dynamic_handler,
+_vp9_dynamic_handler,
+_dynamic_handler,
+_dynamic_handler,
+_dynamic_handler,
+_mp3_dynamic_handler,
+_dynamic_handler,
+_dynamic_handler,
+/* rdt */
+_rdt_video_handler,
+_rdt_audio_handler,
+

[FFmpeg-devel] [PATCH 3/6] lavf: add new API for iterating muxers and demuxers

2018-01-02 Thread Josh de Kock
---
 configure|   6 +-
 doc/APIchanges   |   5 +
 libavformat/allformats.c | 870 ---
 libavformat/avformat.h   |  31 ++
 libavformat/format.c |  56 +--
 libavformat/version.h|   3 +
 6 files changed, 564 insertions(+), 407 deletions(-)

diff --git a/configure b/configure
index bfe4bdf..7b46e5c 100755
--- a/configure
+++ b/configure
@@ -3525,8 +3525,6 @@ find_things(){
 sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" 
"$file"
 }
 
-MUXER_LIST=$(find_thingsmuxer_MUX libavformat/allformats.c)
-DEMUXER_LIST=$(find_things  demuxer  DEMUXlibavformat/allformats.c)
 OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
 INDEV_LIST=$(find_thingsindev_IN  libavdevice/alldevices.c)
 FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
@@ -3538,6 +3536,8 @@ find_things_extern(){
 sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file"
 }
 
+MUXER_LIST=$(find_things_extern muxer AVOutputFormat libavformat/allformats.c)
+DEMUXER_LIST=$(find_things_extern demuxer AVInputFormat 
libavformat/allformats.c)
 ENCODER_LIST=$(find_things_extern encoder AVCodec libavcodec/allcodecs.c)
 DECODER_LIST=$(find_things_extern decoder AVCodec libavcodec/allcodecs.c)
 CODEC_LIST="
@@ -7041,6 +7041,8 @@ print_enabled_components(){
 print_enabled_components libavcodec/codec_list.c AVCodec codec_list $CODEC_LIST
 print_enabled_components libavcodec/parser_list.c AVCodecParser parser_list 
$PARSER_LIST
 print_enabled_components libavcodec/bsf_list.c AVBitStreamFilter 
bitstream_filters $BSF_LIST
+print_enabled_components libavformat/demuxer_list.c AVInputFormat demuxer_list 
$DEMUXER_LIST
+print_enabled_components libavformat/muxer_list.c AVOutputFormat muxer_list 
$MUXER_LIST
 print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols 
$PROTOCOL_LIST
 
 # Settings for pkg-config files
diff --git a/doc/APIchanges b/doc/APIchanges
index 3d28d85..4e82213 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,11 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2018-xx-xx - xxx - lavf 58.9.100 - avformat.h
+  Deprecate use of av_register_input_format(), av_register_output_format(),
+  avformat_register_all(), av_iformat_next(), av_oformat_next().
+  Add av_demuxer_iterate(), and av_muxer_iterate().
+
 2018-xx-xx - xxx - lavc 58.9.100 - avcodec.h
   Deprecate use of avcodec_register(), avcodec_register_all(), and
   av_codec_next(). Add av_codec_iterate().
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 593baf3..c6fdbce 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -26,371 +26,531 @@
 #include "url.h"
 #include "version.h"
 
-#define REGISTER_MUXER(X, x)\
-{   \
-extern AVOutputFormat ff_##x##_muxer;   \
-if (CONFIG_##X##_MUXER) \
-av_register_output_format(_##x##_muxer); \
-}
+/* (de)muxers */
+extern AVOutputFormat ff_a64_muxer;
+extern AVInputFormat  ff_aa_demuxer;
+extern AVInputFormat  ff_aac_demuxer;
+extern AVInputFormat  ff_ac3_demuxer;
+extern AVOutputFormat ff_ac3_muxer;
+extern AVInputFormat  ff_acm_demuxer;
+extern AVInputFormat  ff_act_demuxer;
+extern AVInputFormat  ff_adf_demuxer;
+extern AVInputFormat  ff_adp_demuxer;
+extern AVInputFormat  ff_ads_demuxer;
+extern AVOutputFormat ff_adts_muxer;
+extern AVInputFormat  ff_adx_demuxer;
+extern AVOutputFormat ff_adx_muxer;
+extern AVInputFormat  ff_aea_demuxer;
+extern AVInputFormat  ff_afc_demuxer;
+extern AVInputFormat  ff_aiff_demuxer;
+extern AVOutputFormat ff_aiff_muxer;
+extern AVInputFormat  ff_aix_demuxer;
+extern AVInputFormat  ff_amr_demuxer;
+extern AVOutputFormat ff_amr_muxer;
+extern AVInputFormat  ff_amrnb_demuxer;
+extern AVInputFormat  ff_amrwb_demuxer;
+extern AVInputFormat  ff_anm_demuxer;
+extern AVInputFormat  ff_apc_demuxer;
+extern AVInputFormat  ff_ape_demuxer;
+extern AVInputFormat  ff_apng_demuxer;
+extern AVOutputFormat ff_apng_muxer;
+extern AVInputFormat  ff_aptx_demuxer;
+extern AVOutputFormat ff_aptx_muxer;
+extern AVInputFormat  ff_aqtitle_demuxer;
+extern AVInputFormat  ff_asf_demuxer;
+extern AVOutputFormat ff_asf_muxer;
+extern AVInputFormat  ff_asf_o_demuxer;
+extern AVInputFormat  ff_ass_demuxer;
+extern AVOutputFormat ff_ass_muxer;
+extern AVInputFormat  ff_ast_demuxer;
+extern AVOutputFormat ff_ast_muxer;
+extern AVOutputFormat ff_asf_stream_muxer;
+extern AVInputFormat  ff_au_demuxer;
+extern AVOutputFormat ff_au_muxer;
+extern AVInputFormat  ff_avi_demuxer;
+extern AVOutputFormat ff_avi_muxer;
+extern AVInputFormat  ff_avisynth_demuxer;
+extern AVOutputFormat ff_avm2_muxer;
+extern AVInputFormat  ff_avr_demuxer;
+extern AVInputFormat  

[FFmpeg-devel] [PATCH v2 1/6] lavc: add new API for iterating codecs and codec parsers

2018-01-02 Thread Josh de Kock
Also replace linked list with an array.
---
 configure  |   12 +-
 doc/APIchanges |4 +
 libavcodec/allcodecs.c | 1473 
 libavcodec/avcodec.h   |   31 +
 libavcodec/parser.c|   87 ++-
 libavcodec/utils.c |  105 
 libavcodec/version.h   |3 +
 7 files changed, 974 insertions(+), 741 deletions(-)

diff --git a/configure b/configure
index 606cdd0..bfe4bdf 100755
--- a/configure
+++ b/configure
@@ -3525,9 +3525,6 @@ find_things(){
 sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" 
"$file"
 }
 
-ENCODER_LIST=$(find_things  encoder  ENC  libavcodec/allcodecs.c)
-DECODER_LIST=$(find_things  decoder  DEC  libavcodec/allcodecs.c)
-PARSER_LIST=$(find_things   parser   PARSER   libavcodec/allcodecs.c)
 MUXER_LIST=$(find_thingsmuxer_MUX libavformat/allformats.c)
 DEMUXER_LIST=$(find_things  demuxer  DEMUXlibavformat/allformats.c)
 OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
@@ -3541,6 +3538,13 @@ find_things_extern(){
 sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file"
 }
 
+ENCODER_LIST=$(find_things_extern encoder AVCodec libavcodec/allcodecs.c)
+DECODER_LIST=$(find_things_extern decoder AVCodec libavcodec/allcodecs.c)
+CODEC_LIST="
+$ENCODER_LIST
+$DECODER_LIST
+"
+PARSER_LIST=$(find_things_extern parser AVCodecParser libavcodec/parser.c)
 BSF_LIST=$(find_things_extern bsf AVBitStreamFilter 
libavcodec/bitstream_filters.c)
 HWACCEL_LIST=$(find_things_extern hwaccel AVHWAccel libavcodec/hwaccels.h)
 PROTOCOL_LIST=$(find_things_extern protocol URLProtocol 
libavformat/protocols.c)
@@ -7034,6 +7038,8 @@ print_enabled_components(){
 cp_if_changed $TMPH $file
 }
 
+print_enabled_components libavcodec/codec_list.c AVCodec codec_list $CODEC_LIST
+print_enabled_components libavcodec/parser_list.c AVCodecParser parser_list 
$PARSER_LIST
 print_enabled_components libavcodec/bsf_list.c AVBitStreamFilter 
bitstream_filters $BSF_LIST
 print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols 
$PROTOCOL_LIST
 
diff --git a/doc/APIchanges b/doc/APIchanges
index 3c9f237..3d28d85 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2018-xx-xx - xxx - lavc 58.9.100 - avcodec.h
+  Deprecate use of avcodec_register(), avcodec_register_all(), and
+  av_codec_next(). Add av_codec_iterate().
+
 2017-xx-xx - xxx - lavc 58.9.100 - avcodec.h
   Deprecate av_lockmgr_register(). You need to build FFmpeg with threading
   support enabled to get basic thread-safety (which is the default build
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index ed1e7ab..a7ea772 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -29,641 +29,864 @@
 #include "avcodec.h"
 #include "version.h"
 
-#define REGISTER_ENCODER(X, x)  \
-{   \
-extern AVCodec ff_##x##_encoder;\
-if (CONFIG_##X##_ENCODER)   \
-avcodec_register(_##x##_encoder);\
-}
+extern AVCodec ff_a64multi_encoder;
+extern AVCodec ff_a64multi5_encoder;
+extern AVCodec ff_aasc_decoder;
+extern AVCodec ff_aic_decoder;
+extern AVCodec ff_alias_pix_encoder;
+extern AVCodec ff_alias_pix_decoder;
+extern AVCodec ff_amv_encoder;
+extern AVCodec ff_amv_decoder;
+extern AVCodec ff_anm_decoder;
+extern AVCodec ff_ansi_decoder;
+extern AVCodec ff_apng_encoder;
+extern AVCodec ff_apng_decoder;
+extern AVCodec ff_asv1_encoder;
+extern AVCodec ff_asv1_decoder;
+extern AVCodec ff_asv2_encoder;
+extern AVCodec ff_asv2_decoder;
+extern AVCodec ff_aura_decoder;
+extern AVCodec ff_aura2_decoder;
+extern AVCodec ff_avrp_encoder;
+extern AVCodec ff_avrp_decoder;
+extern AVCodec ff_avrn_decoder;
+extern AVCodec ff_avs_decoder;
+extern AVCodec ff_avui_encoder;
+extern AVCodec ff_avui_decoder;
+extern AVCodec ff_ayuv_encoder;
+extern AVCodec ff_ayuv_decoder;
+extern AVCodec ff_bethsoftvid_decoder;
+extern AVCodec ff_bfi_decoder;
+extern AVCodec ff_bink_decoder;
+extern AVCodec ff_bmp_encoder;
+extern AVCodec ff_bmp_decoder;
+extern AVCodec ff_bmv_video_decoder;
+extern AVCodec ff_brender_pix_decoder;
+extern AVCodec ff_c93_decoder;
+extern AVCodec ff_cavs_decoder;
+extern AVCodec ff_cdgraphics_decoder;
+extern AVCodec ff_cdxl_decoder;
+extern AVCodec ff_cfhd_decoder;
+extern AVCodec ff_cinepak_encoder;
+extern AVCodec ff_cinepak_decoder;
+extern AVCodec ff_clearvideo_decoder;
+extern AVCodec ff_cljr_encoder;
+extern AVCodec ff_cljr_decoder;
+extern AVCodec ff_cllc_decoder;
+extern AVCodec ff_comfortnoise_encoder;
+extern AVCodec ff_comfortnoise_decoder;
+extern AVCodec ff_cpia_decoder;
+extern AVCodec ff_cscd_decoder;
+extern AVCodec ff_cyuv_decoder;
+extern 

Re: [FFmpeg-devel] [PATCH 3/7] avfilter/vf_framerate: factorize blend_frames

2018-01-02 Thread Marton Balint


On Tue, 2 Jan 2018, Michael Niedermayer wrote:


On Sun, Dec 10, 2017 at 11:11:18PM +0100, Marton Balint wrote:

Signed-off-by: Marton Balint 
---
 libavfilter/vf_framerate.c | 54 ++
 1 file changed, 7 insertions(+), 47 deletions(-)


This broke fate-filter-framerate-up on x86-32 (gcc 4.8 (Ubuntu 
4.8.5-2ubuntu1~14.04.1))

--- tests/ref/fate/filter-framerate-up  2017-12-31 19:27:30.039451874 +0100
+++ tests/data/fate/filter-framerate-up 2018-01-02 02:12:56.151674862 +0100
@@ -4,12 +4,12 @@
#dimensions 0: 320x240
#sar 0: 1/1
0,  0,  0,1,   115200, 0x3744b3ed
-0,  1,  1,1,   115200, 0xc44bdc65
-0,  2,  2,1,   115200, 0xa17f0d74
-0,  3,  3,1,   115200, 0xb0c83274
-0,  4,  4,1,   115200, 0x232d6368
+0,  1,  1,1,   115200, 0x3744b3ed
+0,  2,  2,1,   115200, 0x3744b3ed
+0,  3,  3,1,   115200, 0x3744b3ed
+0,  4,  4,1,   115200, 0x6e318ba0
0,  5,  5,1,   115200, 0x6e318ba0
-0,  6,  6,1,   115200, 0x247e846e
-0,  7,  7,1,   115200, 0x89e27599
-0,  8,  8,1,   115200, 0x31c5704e
-0,  9,  9,1,   115200, 0x97e45fec
+0,  6,  6,1,   115200, 0x6e318ba0
+0,  7,  7,1,   115200, 0x6e318ba0
+0,  8,  8,1,   115200, 0x6e318ba0
+0,  9,  9,1,   115200, 0x48d65876
Test filter-framerate-up failed. Look at 
tests/data/fate/filter-framerate-up.err for details.
make: *** [fate-filter-framerate-up] Error 1

in master the diff now looks like this:
--- tests/ref/fate/filter-framerate-up  2017-12-31 19:27:30.039451874 +0100
+++ tests/data/fate/filter-framerate-up 2018-01-02 02:42:46.103712572 +0100
@@ -4,12 +4,12 @@
#dimensions 0: 320x240
#sar 0: 1/1
0,  0,  0,1,   115200, 0x3744b3ed
-0,  1,  1,1,   115200, 0xc44bdc65
+0,  1,  1,1,   115200, 0x3744b3ed
0,  2,  2,1,   115200, 0xa17f0d74
0,  3,  3,1,   115200, 0xb0c83274
0,  4,  4,1,   115200, 0x232d6368
0,  5,  5,1,   115200, 0x6e318ba0
-0,  6,  6,1,   115200, 0x247e846e
+0,  6,  6,1,   115200, 0x6e318ba0
0,  7,  7,1,   115200, 0x89e27599
0,  8,  8,1,   115200, 0x31c5704e
0,  9,  9,1,   115200, 0x97e45fec
Test filter-framerate-up failed. Look at 
tests/data/fate/filter-framerate-up.err for details.
make: *** [fate-filter-framerate-up] Error 1


Does not happen if compiled with -O1 or -O0. With -O2 and -O3 
fabsf(intepolate) becomes NaN.


I am guessing that some floating point state is lost because of the SAD 
MMX instructions, but I don't know if this is a compiler bug or something 
should be done differently.


Do you have an idea how to proceeed?

Thanks,
Marton


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


[FFmpeg-devel] [PATCH 1/2] lavfi/opencl: Use filter device if no input device is available

2018-01-02 Thread Mark Thompson
This allows implementing sources as well as filters.
---
 libavfilter/opencl.c | 39 +--
 1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/libavfilter/opencl.c b/libavfilter/opencl.c
index 005ad089e2..37afc41f8b 100644
--- a/libavfilter/opencl.c
+++ b/libavfilter/opencl.c
@@ -42,11 +42,29 @@ int ff_opencl_filter_query_formats(AVFilterContext *avctx)
 return ff_set_common_formats(avctx, formats);
 }
 
+static int opencl_filter_set_device(AVFilterContext *avctx,
+AVBufferRef *device)
+{
+OpenCLFilterContext *ctx = avctx->priv;
+
+av_buffer_unref(>device_ref);
+
+ctx->device_ref = av_buffer_ref(device);
+if (!ctx->device_ref)
+return AVERROR(ENOMEM);
+
+ctx->device = (AVHWDeviceContext*)ctx->device_ref->data;
+ctx->hwctx  = ctx->device->hwctx;
+
+return 0;
+}
+
 int ff_opencl_filter_config_input(AVFilterLink *inlink)
 {
 AVFilterContext   *avctx = inlink->dst;
 OpenCLFilterContext *ctx = avctx->priv;
 AVHWFramesContext *input_frames;
+int err;
 
 if (!inlink->hw_frames_ctx) {
 av_log(avctx, AV_LOG_ERROR, "OpenCL filtering requires a "
@@ -59,15 +77,12 @@ int ff_opencl_filter_config_input(AVFilterLink *inlink)
 return 0;
 
 input_frames = (AVHWFramesContext*)inlink->hw_frames_ctx->data;
-
 if (input_frames->format != AV_PIX_FMT_OPENCL)
 return AVERROR(EINVAL);
 
-ctx->device_ref = av_buffer_ref(input_frames->device_ref);
-if (!ctx->device_ref)
-return AVERROR(ENOMEM);
-ctx->device = input_frames->device_ctx;
-ctx->hwctx  = ctx->device->hwctx;
+err = opencl_filter_set_device(avctx, input_frames->device_ref);
+if (err < 0)
+return err;
 
 // Default output parameters match input parameters.
 if (ctx->output_format == AV_PIX_FMT_NONE)
@@ -90,6 +105,18 @@ int ff_opencl_filter_config_output(AVFilterLink *outlink)
 
 av_buffer_unref(>hw_frames_ctx);
 
+if (!ctx->device_ref) {
+if (!avctx->hw_device_ctx) {
+av_log(avctx, AV_LOG_ERROR, "OpenCL filtering requires an "
+   "OpenCL device.\n");
+return AVERROR(EINVAL);
+}
+
+err = opencl_filter_set_device(avctx, avctx->hw_device_ctx);
+if (err < 0)
+return err;
+}
+
 output_frames_ref = av_hwframe_ctx_alloc(ctx->device_ref);
 if (!output_frames_ref) {
 err = AVERROR(ENOMEM);
-- 
2.11.0
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] lavfi: Add filters to run arbitrary OpenCL programs

2018-01-02 Thread Mark Thompson
---
E.g. with Beignet + i965:

./ffmpeg_g -y -init_hw_device vaapi=va:/dev/dri/renderD129 -init_hw_device 
opencl=ocl@va -hwaccel vaapi -hwaccel_output_format vaapi -i in.mp4 -an 
-filter_hw_device ocl -filter_complex '[0:v]hwmap[i1]; 
openclsrc=source=test.cl:kernel=ramp:w=1920:h=1080:format=nv12:rate=30[i2]; 
[i1][i2]program_opencl=inputs=2:source=test.cl:kernel=blend_images,hwmap=reverse=1:derive_device=vaapi'
 -c:v h264_vaapi -b:v 5M out.mp4

with test.cl:

"""
__kernel void blend_images(__write_only image2d_t dst,
   unsigned int index,
   __read_only  image2d_t src1,
   __read_only  image2d_t src2)
{
  const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
 CLK_FILTER_NEAREST);

  float blend = (cos((float)index / 50) + 1.0f) / 2.0f;

  int2  dst_loc = (int2)(get_global_id(0), get_global_id(1));
  int2 src1_loc = dst_loc * get_image_dim(src1) / get_image_dim(dst);
  int2 src2_loc = dst_loc * get_image_dim(src2) / get_image_dim(dst);

  float4 val1 = read_imagef(src1, sampler, src1_loc);
  float4 val2 = read_imagef(src2, sampler, src2_loc);

  write_imagef(dst, dst_loc, val1 * blend + val2 * (1.0f - blend));
}

__kernel void ramp(__write_only image2d_t dst,
   unsigned int index)
{
  int2 loc = (int2)(get_global_id(0), get_global_id(1));

  float4 val;
  val.xy = convert_float2(loc) / convert_float2(get_image_dim(dst));

  write_imagef(dst, loc, val);
}
"""


 configure   |   1 +
 libavfilter/Makefile|   2 +
 libavfilter/allfilters.c|   2 +
 libavfilter/vf_program_opencl.c | 443 
 4 files changed, 448 insertions(+)
 create mode 100644 libavfilter/vf_program_opencl.c

diff --git a/configure b/configure
index 606cdd0004..f58a7b999c 100755
--- a/configure
+++ b/configure
@@ -3249,6 +3249,7 @@ perspective_filter_deps="gpl"
 phase_filter_deps="gpl"
 pp7_filter_deps="gpl"
 pp_filter_deps="gpl postproc"
+program_opencl_filter_deps="opencl"
 pullup_filter_deps="gpl"
 removelogo_filter_deps="avcodec avformat swscale"
 repeatfields_filter_deps="gpl"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 8bde542163..02f808e08c 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -272,6 +272,7 @@ OBJS-$(CONFIG_PP_FILTER) += vf_pp.o
 OBJS-$(CONFIG_PP7_FILTER)+= vf_pp7.o
 OBJS-$(CONFIG_PREMULTIPLY_FILTER)+= vf_premultiply.o framesync.o
 OBJS-$(CONFIG_PREWITT_FILTER)+= vf_convolution.o
+OBJS-$(CONFIG_PROGRAM_OPENCL_FILTER) += vf_program_opencl.o opencl.o
 OBJS-$(CONFIG_PSEUDOCOLOR_FILTER)+= vf_pseudocolor.o
 OBJS-$(CONFIG_PSNR_FILTER)   += vf_psnr.o framesync.o
 OBJS-$(CONFIG_PULLUP_FILTER) += vf_pullup.o
@@ -367,6 +368,7 @@ OBJS-$(CONFIG_LIFE_FILTER)   += vsrc_life.o
 OBJS-$(CONFIG_MANDELBROT_FILTER) += vsrc_mandelbrot.o
 OBJS-$(CONFIG_MPTESTSRC_FILTER)  += vsrc_mptestsrc.o
 OBJS-$(CONFIG_NULLSRC_FILTER)+= vsrc_testsrc.o
+OBJS-$(CONFIG_OPENCLSRC_FILTER)  += vf_program_opencl.o opencl.o
 OBJS-$(CONFIG_RGBTESTSRC_FILTER) += vsrc_testsrc.o
 OBJS-$(CONFIG_SMPTEBARS_FILTER)  += vsrc_testsrc.o
 OBJS-$(CONFIG_SMPTEHDBARS_FILTER)+= vsrc_testsrc.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 67c073091f..ff76f2c747 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -281,6 +281,7 @@ static void register_all(void)
 REGISTER_FILTER(PP7,pp7,vf);
 REGISTER_FILTER(PREMULTIPLY,premultiply,vf);
 REGISTER_FILTER(PREWITT,prewitt,vf);
+REGISTER_FILTER(PROGRAM_OPENCL, program_opencl, vf);
 REGISTER_FILTER(PSEUDOCOLOR,pseudocolor,vf);
 REGISTER_FILTER(PSNR,   psnr,   vf);
 REGISTER_FILTER(PULLUP, pullup, vf);
@@ -375,6 +376,7 @@ static void register_all(void)
 REGISTER_FILTER(MANDELBROT, mandelbrot, vsrc);
 REGISTER_FILTER(MPTESTSRC,  mptestsrc,  vsrc);
 REGISTER_FILTER(NULLSRC,nullsrc,vsrc);
+REGISTER_FILTER(OPENCLSRC,  openclsrc,  vsrc);
 REGISTER_FILTER(RGBTESTSRC, rgbtestsrc, vsrc);
 REGISTER_FILTER(SMPTEBARS,  smptebars,  vsrc);
 REGISTER_FILTER(SMPTEHDBARS,smptehdbars,vsrc);
diff --git a/libavfilter/vf_program_opencl.c b/libavfilter/vf_program_opencl.c
new file mode 100644
index 00..4de0ffd268
--- /dev/null
+++ b/libavfilter/vf_program_opencl.c
@@ -0,0 +1,443 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) 

Re: [FFmpeg-devel] [PATCH] avcodec/opus: Add {} over multiline if() body

2018-01-02 Thread Derek Buitenhuis
On 1/2/2018 10:34 PM, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/opus.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Looks reasonable.

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


[FFmpeg-devel] [PATCH] avcodec/opus: Add {} over multiline if() body

2018-01-02 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavcodec/opus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/opus.c b/libavcodec/opus.c
index 9cbf4aed92..d00a17a7f1 100644
--- a/libavcodec/opus.c
+++ b/libavcodec/opus.c
@@ -566,12 +566,12 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, 
int encode)
 int bits2[CELT_MAX_BANDS];
 
 /* Spread */
-if (opus_rc_tell(rc) + 4 <= f->framebits)
+if (opus_rc_tell(rc) + 4 <= f->framebits) {
 if (encode)
 ff_opus_rc_enc_cdf(rc, f->spread, ff_celt_model_spread);
 else
 f->spread = ff_opus_rc_dec_cdf(rc, ff_celt_model_spread);
-else
+} else
 f->spread = CELT_SPREAD_NORMAL;
 
 /* Initialize static allocation caps */
-- 
2.15.1

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


Re: [FFmpeg-devel] [PATCH 1/2] vf_paletteuse: Add error checking to apply_palette

2018-01-02 Thread Derek Buitenhuis
On 1/2/2018 10:16 PM, Clément Bœsch wrote:
> I don't think you'll be much off by always assuming ENOMEM  here when
> getting a NULL out frame, I think that's the common idiom when a function
> supposed to return allocated stuff returns NULL.
> 
> But that's not very important, feel free to push as is if you prefer that
> way.

I'll change it to ENOMEM before push, then.

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


Re: [FFmpeg-devel] [PATCH 1/2] vf_paletteuse: Add error checking to apply_palette

2018-01-02 Thread Clément Bœsch
On Tue, Jan 02, 2018 at 10:02:25PM +, Derek Buitenhuis wrote:
> On 1/2/2018 9:52 PM, Clément Bœsch wrote:
> > not exactly sure why you haven't just checked if `out` wasn't NULL, but it
> > should be fine that way too if you prefer it.
> > 
> > I guess that's only to provide a finer grain error handling? It would make
> > sense if ff_get_video_buffer was returning a meaningful error, but so far
> > you're just assuming EINVAL when it could be ENOMEM, so I don't really get
> > it.
> 
> s->set_frame can return ENOMEM, which is why I made it finer grained.
> 
> I'm not really sure what to return for ff_get_video_buffer failure, since
> it wasn't designed with any error mechanism for some reason.
> 

I don't think you'll be much off by always assuming ENOMEM  here when
getting a NULL out frame, I think that's the common idiom when a function
supposed to return allocated stuff returns NULL.

But that's not very important, feel free to push as is if you prefer that
way.

-- 
Clément B.


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


Re: [FFmpeg-devel] [PATCH 1/2] vf_paletteuse: Add error checking to apply_palette

2018-01-02 Thread Derek Buitenhuis
On 1/2/2018 9:52 PM, Clément Bœsch wrote:
> not exactly sure why you haven't just checked if `out` wasn't NULL, but it
> should be fine that way too if you prefer it.
> 
> I guess that's only to provide a finer grain error handling? It would make
> sense if ff_get_video_buffer was returning a meaningful error, but so far
> you're just assuming EINVAL when it could be ENOMEM, so I don't really get
> it.

s->set_frame can return ENOMEM, which is why I made it finer grained.

I'm not really sure what to return for ff_get_video_buffer failure, since
it wasn't designed with any error mechanism for some reason.

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


Re: [FFmpeg-devel] [PATCH 2/2] vf_paletteuse: Don't free the second frame from ff_framesync_dualinput_get_writable on error

2018-01-02 Thread Derek Buitenhuis
On 1/2/2018 9:53 PM, Clément Bœsch wrote:
> That's some weird ownership semantic for the error-path, but Nicolas knows
> better this API so I'll trust him on this one.

Yeah it was weird for me to, but I looked into its implementation to find out.

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


Re: [FFmpeg-devel] [PATCH 1/2] vf_paletteuse: Add error checking to apply_palette

2018-01-02 Thread Clément Bœsch
On Mon, Jan 01, 2018 at 11:28:36AM -0500, Derek Buitenhuis wrote:
> This fixes a segfault caused by passing NULL to ff_filter_frame
> when an error occurs.
> 
> Signed-off-by: Derek Buitenhuis 
> ---
>  libavfilter/vf_paletteuse.c | 25 -
>  1 file changed, 16 insertions(+), 9 deletions(-)
> 
> diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c
> index 1980907..ede2e2e 100644
> --- a/libavfilter/vf_paletteuse.c
> +++ b/libavfilter/vf_paletteuse.c
> @@ -894,9 +894,9 @@ static void set_processing_window(enum diff_mode 
> diff_mode,
>  *hp = height;
>  }
>  
> -static AVFrame *apply_palette(AVFilterLink *inlink, AVFrame *in)
> +static int apply_palette(AVFilterLink *inlink, AVFrame *in, AVFrame **outf)
>  {
> -int x, y, w, h;
> +int x, y, w, h, ret;
>  AVFilterContext *ctx = inlink->dst;
>  PaletteUseContext *s = ctx->priv;
>  AVFilterLink *outlink = inlink->dst->outputs[0];
> @@ -904,7 +904,8 @@ static AVFrame *apply_palette(AVFilterLink *inlink, 
> AVFrame *in)
>  AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
>  if (!out) {
>  av_frame_free();
> -return NULL;
> +*outf = NULL;
> +return AVERROR(EINVAL);
>  }
>  av_frame_copy_props(out, in);
>  
> @@ -918,21 +919,25 @@ static AVFrame *apply_palette(AVFilterLink *inlink, 
> AVFrame *in)
>  av_frame_make_writable(s->last_in) < 0) {
>  av_frame_free();
>  av_frame_free();
> -return NULL;
> +*outf = NULL;
> +return AVERROR(EINVAL);
>  }
>  
>  ff_dlog(ctx, "%dx%d rect: (%d;%d) -> (%d,%d) [area:%dx%d]\n",
>  w, h, x, y, x+w, y+h, in->width, in->height);
>  
> -if (s->set_frame(s, out, in, x, y, w, h) < 0) {
> +ret = s->set_frame(s, out, in, x, y, w, h);
> +if (ret < 0) {
>  av_frame_free();
> -return NULL;
> +*outf = NULL;
> +return ret;
>  }
>  memcpy(out->data[1], s->palette, AVPALETTE_SIZE);
>  if (s->calc_mean_err)
>  debug_mean_error(s, in, out, inlink->frame_count_out);
>  av_frame_free();
> -return out;
> +*outf = out;
> +return 0;
>  }
>  
>  static int config_output(AVFilterLink *outlink)
> @@ -1011,7 +1016,7 @@ static int load_apply_palette(FFFrameSync *fs)
>  AVFilterContext *ctx = fs->parent;
>  AVFilterLink *inlink = ctx->inputs[0];
>  PaletteUseContext *s = ctx->priv;
> -AVFrame *master, *second, *out;
> +AVFrame *master, *second, *out = NULL;
>  int ret;
>  
>  // writable for error diffusal dithering
> @@ -1025,7 +1030,9 @@ static int load_apply_palette(FFFrameSync *fs)
>  if (!s->palette_loaded) {
>  load_palette(s, second);
>  }
> -out = apply_palette(inlink, master);
> +ret = apply_palette(inlink, master, );
> +if (ret < 0)
> +goto error;
>  return ff_filter_frame(ctx->outputs[0], out);
>  

not exactly sure why you haven't just checked if `out` wasn't NULL, but it
should be fine that way too if you prefer it.

I guess that's only to provide a finer grain error handling? It would make
sense if ff_get_video_buffer was returning a meaningful error, but so far
you're just assuming EINVAL when it could be ENOMEM, so I don't really get
it.

-- 
Clément B.


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


Re: [FFmpeg-devel] [PATCH 2/2] vf_paletteuse: Don't free the second frame from ff_framesync_dualinput_get_writable on error

2018-01-02 Thread Clément Bœsch
On Mon, Jan 01, 2018 at 11:28:37AM -0500, Derek Buitenhuis wrote:
> This fixes a double free in he error case.
> 
> Signed-off-by: Derek Buitenhuis 
> ---
> This does fix the double free, but I am unsure if it is the correct free
> to removed to fix it. Comments welcome.
> ---
>  libavfilter/vf_paletteuse.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c
> index ede2e2e..c2d0c6b 100644
> --- a/libavfilter/vf_paletteuse.c
> +++ b/libavfilter/vf_paletteuse.c
> @@ -1037,7 +1037,6 @@ static int load_apply_palette(FFFrameSync *fs)
>  
>  error:
>  av_frame_free();
> -av_frame_free();
>  return ret;
>  }

That's some weird ownership semantic for the error-path, but Nicolas knows
better this API so I'll trust him on this one.

-- 
Clément B.


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


Re: [FFmpeg-devel] [PATCH 1/1] mpeg: add experimental support for PSMF audio.

2018-01-02 Thread Michael Niedermayer
On Mon, Jan 01, 2018 at 08:32:22PM +1100, mi...@brew.sh wrote:
> From: Maxim Poliakovski 
> 
> Changes by Misty De Meo :
> 
> atrac3plus_parser: remove return statements for invalid data
> 
> atrac3plus_parser: use libavcodec's oma
> 
> atrac3plus_parser: pass along unexpected data unaltered
> 
> atrac3plus_parser: adjust bytes_remain type
> 
> Change by Michael "Bazz" Bazzinotti :
> 
> atrac3plus_parser: don't always fail video for "2nd frame portion found"
> 
> Signed-off-by: Misty De Meo 
> 

> wip parser

so this is unfinished code that work in progress ?
if so, what is missing ?
if not, then please write a better commit message

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

Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- Plato


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


Re: [FFmpeg-devel] [PATCH 4/6] Fix detecting ATRAC3 audio from MPS files

2018-01-02 Thread Michael Niedermayer
On Sun, Dec 31, 2017 at 05:46:05PM +0800, mi...@brew.sh wrote:
> From: Misty De Meo 
> 
> MPS files are MPEG files used on PSP Video discs. They lack
> the PSMF header used by .pms files, and so the special casing
> in the original patch fails to support their audio. This patch
> fixes this by unconditionally reading a new byte for the startcode
> for PRIVATE_STREAM_1 sections, and doing the comparison on that
> to find ATRAC-3 streams. In my testing, it works fine for both MPS
> and PSMF files.
> ---
>  Changelog  |  1 +
>  libavformat/mpeg.c | 38 ++
>  libavformat/mpeg.h |  1 +
>  3 files changed, 16 insertions(+), 24 deletions(-)
> 
> diff --git a/Changelog b/Changelog
> index ee48876128..67f28ea839 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -27,6 +27,7 @@ version :
>  - video setrange filter
>  - nsp demuxer
>  - support LibreSSL (via libtls)
> +- ATRAC-3 support for Sony PSP MPEG files
>  
>  
>  version 3.4:
> diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
> index 895c6fb231..a366ece0ed 100644
> --- a/libavformat/mpeg.c
> +++ b/libavformat/mpeg.c
> @@ -128,7 +128,6 @@ typedef struct MpegDemuxContext {
>  int sofdec;
>  int dvd;
>  int imkh_cctv;
> -int sony_psmf; // true if Play Station Movie file signature is present
>  #if CONFIG_VOBSUB_DEMUXER
>  AVFormatContext *sub_ctx;
>  FFDemuxSubtitlesQueue q[32];
> @@ -148,8 +147,6 @@ static int mpegps_read_header(AVFormatContext *s)
>  avio_get_str(s->pb, 6, buffer, sizeof(buffer));
>  if (!memcmp("IMKH", buffer, 4)) {
>  m->imkh_cctv = 1;
> -} else if (!memcmp("PSMF00", buffer, 6)) {
> -m->sony_psmf = 1;
>  } else if (!memcmp("Sofdec", buffer, 6)) {
>  m->sofdec = 1;
>  } else
> @@ -444,7 +441,7 @@ redo:
>  goto redo;
>  }
>  
> -if (startcode == PRIVATE_STREAM_1 && !m->sony_psmf) {
> +if (startcode == PRIVATE_STREAM_1) {
>  startcode = avio_r8(s->pb);
>  len--;
>  }
> @@ -544,28 +541,21 @@ redo:
>  else
>  request_probe= 1;
>  type = AVMEDIA_TYPE_VIDEO;
> -} else if (startcode == PRIVATE_STREAM_1 && m->sony_psmf) {
> -uint8_t stream_id;
> -
> -if (len < 2)
> -goto skip;
> -stream_id = avio_r8(s->pb);
> +// Sony PSP video with ATRAC-3 audio

> +} else if (!(startcode & STREAM_TYPE_AUDIO_ATRAC3)) {

this looks a bit odd
shouldnt this test more than 4 bits of startcode ?

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

Avoid a single point of failure, be that a person or equipment.


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


Re: [FFmpeg-devel] Global options to compile FFmpeg with only audio-related features

2018-01-02 Thread wm4
On Tue, 2 Jan 2018 19:41:39 +0100
"Cyber Sinh"  wrote:

> Nobody has an idea?
> 
> Thanks.

> 
> Checking AVMEDIA_TYPE seems to be the best way to split audio and video 
> codecs.
> But what is the best way to exclude demuxers and parsers which have no sense 
> for audio (because they are intended to be used only with video/image without 
> audio for example)?


To be honest, I don't think there are many interesting formats that do
not support audio at all. Maybe some game formats or almost-raw
demuxers. But most containers probably support audio in some form
(since the point of container formats is to mux audio _and_ video in
the first place). Especially all the complex formats (which will
inflate the size of the libavformat binary) will support audio too.

The best you can do is probably picking a list of formats that make
most sense for most formats associated with storing music or whatever
(the list would start with things like flac and mp3). I know that's
exactly what you want to avoid, but in the end there's no single answer
to what an "audio" demuxer is, so everyone has to answer that
themselves.

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


Re: [FFmpeg-devel] [PATCH 1/6] fate: add atrac3p conversion test

2018-01-02 Thread Michael Niedermayer
On Sun, Dec 31, 2017 at 05:46:02PM +0800, mi...@brew.sh wrote:
> From: Misty De Meo 
> 
> ---
>  tests/fate/atrac.mak | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tests/fate/atrac.mak b/tests/fate/atrac.mak
> index acf79a539c..1707373890 100644
> --- a/tests/fate/atrac.mak
> +++ b/tests/fate/atrac.mak
> @@ -31,6 +31,10 @@ FATE_ATRAC3P += fate-atrac3p-2
>  fate-atrac3p-2: CMD = pcm -i 
> $(TARGET_SAMPLES)/atrac3p/sonateno14op27-2-cut.aa3
>  fate-atrac3p-2: REF = $(SAMPLES)/atrac3p/sonateno14op27-2-cut.pcm
>  
> +FATE_ATRAC3P += fate-atrac3p-3
> +fate-atrac3p-3: CMD = pcm -i $(TARGET_SAMPLES)/atrac3p/bgm01.at3
> +fate-atrac3p-3: REF = $(SAMPLES)/atrac3p/bgm01.s16

the reference file is a bit big but test works andf LGTM 


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

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 


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


Re: [FFmpeg-devel] [PATCH 1/1] psmf: add FATE tests

2018-01-02 Thread Michael Niedermayer
On Mon, Jan 01, 2018 at 08:29:31PM +1100, mi...@brew.sh wrote:
> From: Misty De Meo 
> 
> ---
>  tests/Makefile  |  1 +
>  tests/fate/psmf.mak | 23 +++
>  2 files changed, 24 insertions(+)
>  create mode 100644 tests/fate/psmf.mak

LGTM & works

thx

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

Modern terrorism, a quick summary: Need oil, start war with country that
has oil, kill hundread thousand in war. Let country fall into chaos,
be surprised about raise of fundamantalists. Drop more bombs, kill more
people, be surprised about them taking revenge and drop even more bombs
and strip your own citizens of their rights and freedoms. to be continued


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


Re: [FFmpeg-devel] Global options to compile FFmpeg with only audio-related features

2018-01-02 Thread Ronald S. Bultje
Hi,

On Tue, Jan 2, 2018 at 1:41 PM, Cyber Sinh  wrote:

> Nobody has an idea?


Please don't top-post.

I think you know how to do codecs. As for muxers, that's up to you, there's
no generic way and I don't think we'd want one on our side. Whether you
generate the enable/disable list for audio-only builds on your end or on
our end isn't so relevant, in both cases it should be trivial.

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


Re: [FFmpeg-devel] Global options to compile FFmpeg with only audio-related features

2018-01-02 Thread Cyber Sinh
Nobody has an idea?

Thanks.

-Message d'origine-
De : ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] De la part de Cyber 
Sinh
Envoyé : samedi 30 décembre 2017 21:03
À : 'FFmpeg development discussions and patches' 
Objet : Re: [FFmpeg-devel] Global options to compile FFmpeg with only 
audio-related features

Hi Ronald,

Checking AVMEDIA_TYPE seems to be the best way to split audio and video codecs.
But what is the best way to exclude demuxers and parsers which have no sense 
for audio (because they are intended to be used only with video/image without 
audio for example)?

Thanks! 

-Message d'origine-
De : ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] De la part de Ronald 
S. Bultje Envoyé : samedi 30 décembre 2017 18:15 À : FFmpeg development 
discussions and patches  Objet : Re: [FFmpeg-devel] 
Global options to compile FFmpeg with only audio-related features

Hi,

On Sat, Dec 30, 2017 at 11:28 AM, Derek Buitenhuis < 
derek.buitenh...@gmail.com> wrote:

> On 12/30/2017 4:00 PM, Cyber Sinh wrote:
> > What do you think?
>
> That patches are welcome :).


Just to be clear: I'm not OK with a list of audio or video thingies in 
configure. Similar to the scraping of allcodecs.c, we should be able to 
classify them based on their AVMEDIA_TYPE and use that classification 
automatically in configure to do what you say.

Just to prevent you from doing a lot of work that won't be upstreamable for 
maintenance reasons.

Ronald
___
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

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


Re: [FFmpeg-devel] [PATCH] avformat/hls: fix seek accuracy problem

2018-01-02 Thread Aman Gupta
On Tue, Jan 2, 2018 at 3:05 AM Steven Liu  wrote:

> 2018-01-02 18:28 GMT+08:00  :
> > From: Wu Zhiqiang 
> >
> > HLS demuxer seeking use dts instead of pts.
> > Demuxer skip some frame when dts is before pts in special case.
> > And it is impossible to re-seek back to start time after playing.
> > ---
> >  libavformat/hls.c | 18 ++
> >  1 file changed, 14 insertions(+), 4 deletions(-)
> >
> > diff --git a/libavformat/hls.c b/libavformat/hls.c
> > index 950cc4c3bd..069e7b06e9 100644
> > --- a/libavformat/hls.c
> > +++ b/libavformat/hls.c
> > @@ -2086,6 +2086,7 @@ static int hls_read_packet(AVFormatContext *s,
> AVPacket *pkt)
> >   * stream */
> >  if (pls->needed && !pls->pkt.data) {
> >  while (1) {
> > +int64_t pkt_ts;
> >  int64_t ts_diff;
> >  AVRational tb;
> >  ret = av_read_frame(pls->ctx, >pkt);
> > @@ -2101,9 +2102,17 @@ static int hls_read_packet(AVFormatContext *s,
> AVPacket *pkt)
> >  fill_timing_for_id3_timestamped_stream(pls);
> >  }
> >
> > +if (pls->pkt.pts != AV_NOPTS_VALUE)
> > +pkt_ts =  pls->pkt.pts;
> > +else if (pls->pkt.dts != AV_NOPTS_VALUE)
> > +pkt_ts =  pls->pkt.dts;
> > +else
> > +pkt_ts = AV_NOPTS_VALUE;
> > +
> > +
> >  if (c->first_timestamp == AV_NOPTS_VALUE &&
> > -pls->pkt.dts   != AV_NOPTS_VALUE)
> > -c->first_timestamp = av_rescale_q(pls->pkt.dts,
> > +pkt_ts   != AV_NOPTS_VALUE)
> > +c->first_timestamp = av_rescale_q(pkt_ts,
> >  get_timebase(pls), AV_TIME_BASE_Q);
> >  }
> >
> > @@ -2113,15 +2122,16 @@ static int hls_read_packet(AVFormatContext *s,
> AVPacket *pkt)
> >  if (pls->seek_stream_index < 0 ||
> >  pls->seek_stream_index == pls->pkt.stream_index) {
> >
> > -if (pls->pkt.dts == AV_NOPTS_VALUE) {
> > +if (pkt_ts == AV_NOPTS_VALUE) {
> >  pls->seek_timestamp = AV_NOPTS_VALUE;
> >  break;
> >  }
> >
> >  tb = get_timebase(pls);
> > -ts_diff = av_rescale_rnd(pls->pkt.dts, AV_TIME_BASE,
> > +ts_diff = av_rescale_rnd(pkt_ts, AV_TIME_BASE,
> >  tb.den, AV_ROUND_DOWN) -
> >  pls->seek_timestamp;
> > +
> >  if (ts_diff >= 0 && (pls->seek_flags  &
> AVSEEK_FLAG_ANY ||
> >  pls->pkt.flags &
> AV_PKT_FLAG_KEY)) {
> >  pls->seek_timestamp = AV_NOPTS_VALUE;
> > --
> > 2.15.0
> >
>
>
> LGTM , This patch can fix ticket : https://trac.ffmpeg.org/ticket/6850
>

LGTM, I've experienced this bug also.


>
> Thanks
>
> Steven
> ___
> 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 v4] lavr: deprecate the entire library

2018-01-02 Thread James Almer
On 1/2/2018 2:48 PM, Rostislav Pehlivanov wrote:
> On 2 January 2018 at 17:01, wm4  wrote:
> 
>> On Tue, 2 Jan 2018 16:47:14 +
>> Rostislav Pehlivanov  wrote:
>>
>>> On 30 December 2017 at 14:59, Rostislav Pehlivanov 
>>> wrote:
>>>
 Deprecate the entire library. Merged years ago to provide compatibility
 with Libav, it remained unmaintained by the FFmpeg project and
>> duplicated
 functionality provided by libswresample.
>>
 2.15.1.620.gb9897f4670


>>> Going to push this tomorrow.
>>
>> I'm still against it.
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
> 
> And I'm still going to push it. I'm not going to listen to your uninformed
> biased irrational ravings on this topic.
> Call a vote if you want though you probably know you'll be the only one for
> it and you'll just delay it and piss everyone off.

Can you drop the aggressiveness? It's the second time in this thread alone.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [RFC] avcodec/avcodec.h: Add encryption info side data

2018-01-02 Thread Jacob Trimble
On Wed, Dec 20, 2017 at 4:31 PM, wm4  wrote:
> On Wed, 20 Dec 2017 15:10:43 -0800
> Jacob Trimble  wrote:
>
>> From 1508d19e9f7acf43d76010ce54d59ff204613601 Mon Sep 17 00:00:00 2001
>> From: Jacob Trimble 
>> Date: Tue, 5 Dec 2017 14:52:22 -0800
>> Subject: [PATCH] avcodec/avcodec.h: Add encryption info side data.
>>
>> This new side-data will contain info on how a packet is encrypted.
>> This allows the app to handle packet decryption.
>>
>> Signed-off-by: Jacob Trimble 
>> ---
>
> Looks generally good to me, a few minor cosmetic comments below.
>
>>  libavcodec/Makefile  |   2 +
>>  libavcodec/avcodec.h |  13 
>>  libavcodec/encryption_info.c | 139 
>> +++
>>  libavcodec/encryption_info.h | 121 +
>>  4 files changed, 275 insertions(+)
>>  create mode 100644 libavcodec/encryption_info.c
>>  create mode 100644 libavcodec/encryption_info.h
>>
>> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
>> index ab7893f560..11ad642c6c 100644
>> --- a/libavcodec/Makefile
>> +++ b/libavcodec/Makefile
>> @@ -10,6 +10,7 @@ HEADERS = ac3_parser.h 
>>  \
>>dirac.h   \
>>dv_profile.h  \
>>dxva2.h   \
>> +  encryption_info.h \
>>jni.h \
>>mediacodec.h  \
>>qsv.h \
>> @@ -36,6 +37,7 @@ OBJS = ac3_parser.o
>>  \
>> dirac.o  \
>> dv_profile.o \
>> encode.o \
>> +   encryption_info.o\
>> imgconvert.o \
>> jni.o\
>> mathtables.o \
>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>> index 5db6a81320..b43638ebc5 100644
>> --- a/libavcodec/avcodec.h
>> +++ b/libavcodec/avcodec.h
>> @@ -1327,6 +1327,19 @@ enum AVPacketSideDataType {
>>   */
>>  AV_PKT_DATA_A53_CC,
>>
>> +/**
>> + * This side data is encryption "initialization data".
>> + * For MP4 this is the entire 'pssh' box.
>> + * For WebM this is the key ID.
>> + */
>> +AV_PKT_DATA_ENCRYPTION_INIT_DATA,
>> +
>> +/**
>> + * This side data contains encryption info for how to decrypt the 
>> packet.
>> + * The format is not part of ABI, use av_encryption_info_* methods to 
>> access.
>> + */
>> +AV_PKT_DATA_ENCRYPTION_INFO,
>> +
>>  /**
>>   * The number of side data types.
>>   * This is not part of the public API/ABI in the sense that it may
>> diff --git a/libavcodec/encryption_info.c b/libavcodec/encryption_info.c
>> new file mode 100644
>> index 00..59ee4c41a9
>> --- /dev/null
>> +++ b/libavcodec/encryption_info.c
>> @@ -0,0 +1,139 @@
>> +/**
>> + * This file is part of FFmpeg.
>> + *
>> + * FFmpeg is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU Lesser General Public
>> + * License as published by the Free Software Foundation; either
>> + * version 2.1 of the License, or (at your option) any later version.
>> + *
>> + * FFmpeg is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with FFmpeg; if not, write to the Free Software
>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
>> USA
>> + */
>> +
>> +#include "encryption_info.h"
>> +#include "libavutil/avassert.h"
>> +#include "libavutil/intreadwrite.h"
>> +
>> +#define FF_ENCRYPTION_INFO_EXTRA 24
>> +
>> +// The format of the side data:
>> +// u32be scheme
>> +// u32be crypt_byte_block
>> +// u32be skip_byte_block
>> +// u32be key_id_size
>> +// u32be iv_size
>> +// u32be subsample_count
>> +// u8[key_id_size] key_id
>> +// u8[iv_size] iv
>> +// {
>> +//   u32be bytes_of_clear_data
>> +//   u32be bytes_of_protected_data
>> +// }[subsample_count]
>> +
>> +AVEncryptionInfo* av_encryption_info_alloc(uint32_t subsample_count, 
>> uint32_t 

Re: [FFmpeg-devel] [PATCH v4] lavr: deprecate the entire library

2018-01-02 Thread Rostislav Pehlivanov
On 2 January 2018 at 17:01, wm4  wrote:

> On Tue, 2 Jan 2018 16:47:14 +
> Rostislav Pehlivanov  wrote:
>
> > On 30 December 2017 at 14:59, Rostislav Pehlivanov 
> > wrote:
> >
> > > Deprecate the entire library. Merged years ago to provide compatibility
> > > with Libav, it remained unmaintained by the FFmpeg project and
> duplicated
> > > functionality provided by libswresample.
>
> > > 2.15.1.620.gb9897f4670
> > >
> > >
> > Going to push this tomorrow.
>
> I'm still against it.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

And I'm still going to push it. I'm not going to listen to your uninformed
biased irrational ravings on this topic.
Call a vote if you want though you probably know you'll be the only one for
it and you'll just delay it and piss everyone off.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] libopus wrapper not supporting inband FEC

2018-01-02 Thread Derek Buitenhuis
On 1/2/2018 4:45 PM, Amit Gandhi wrote:
> Does anyone happen to know why inband FEC option is not supported by libopus 
> wrapper in ffmpeg while the packet_loss option is supported?

Probably no other reason than the fact that nobody mapped it to
an AVOption yet.

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


[FFmpeg-devel] libopus wrapper not supporting inband FEC

2018-01-02 Thread Amit Gandhi
Hi,

Does anyone happen to know why inband FEC option is not supported by libopus 
wrapper in ffmpeg while the packet_loss option is supported?

Looking into the code of encoder wrapper ~/libavcodec/libopusenc.c the line
ret = opus_multistream_encoder_ctl(enc, 
OPUS_SET_PACKET_LOSS_PERC(opts->packet_loss));

sets up the packet loss percentage in libopus but there is no reference to 
OPUS_SET_INBAND_FEC(...) libopus control in the wrapper.

Also looking into libopus the packet loss is used in conjunction with FEC 
settings i.e from opus-1.1.3/src/opus_encoder.c


/* When FEC is enabled and there's enough packet loss, use SILK */
if (st->silk_mode.useInBandFEC && st->silk_mode.packetLossPercentage > 
(128-voice_est)>>4)
  st->mode = MODE_SILK_ONLY;


Any help would be appreciated.

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


[FFmpeg-devel] [PATCH] avformat/aiffdec: AIFF fix in case of ANNO

2018-01-02 Thread endushka
From: Author Name 

Apple's AIFF protocol clearly states that each chucnk which is odd sized a 
padding should be added.
In the old version of aiffdec adding of padding was done in `get_meta`. And in 
case of unknown chunk name it was done in defalut case.
The new version has deleted the padding in default case and added padding 
adding after the switch.
But the new version didn't removed the padding adding in the `get_meta` 
function so in some cases padding was added twice which leaded to a bug.
---
 libavformat/aiffdec.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
index 99e05c7..20decc5 100644
--- a/libavformat/aiffdec.c
+++ b/libavformat/aiffdec.c
@@ -81,11 +81,10 @@ static void get_meta(AVFormatContext *s, const char *key, 
int size)
 av_free(str);
 return;
 }
-size += (size&1)-res;
+size -= res;
 str[res] = 0;
 av_dict_set(>metadata, key, str, AV_DICT_DONT_STRDUP_VAL);
-}else
-size+= size&1;
+}
 
 avio_skip(s->pb, size);
 }
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH v4] lavr: deprecate the entire library

2018-01-02 Thread wm4
On Tue, 2 Jan 2018 16:47:14 +
Rostislav Pehlivanov  wrote:

> On 30 December 2017 at 14:59, Rostislav Pehlivanov 
> wrote:
> 
> > Deprecate the entire library. Merged years ago to provide compatibility
> > with Libav, it remained unmaintained by the FFmpeg project and duplicated
> > functionality provided by libswresample.

> > 2.15.1.620.gb9897f4670
> >
> >  
> Going to push this tomorrow.

I'm still against it.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v4] lavr: deprecate the entire library

2018-01-02 Thread Rostislav Pehlivanov
On 30 December 2017 at 14:59, Rostislav Pehlivanov 
wrote:

> Deprecate the entire library. Merged years ago to provide compatibility
> with Libav, it remained unmaintained by the FFmpeg project and duplicated
> functionality provided by libswresample.
>
> In order to improve consistency and reduce attack surface, as well as to
> ease
> burden on maintainers, it has been deprecated. Users of this library are
> asked
> to migrate to libswresample, which, as well as providing more
> functionality,
> is faster and has higher accuracy.
>
> Signed-off-by: Rostislav Pehlivanov 
> ---
> I've kept the deprecations on the enums - they can't hurt.
>  configure  |   4 +-
>  doc/APIchanges |   9 
>  libavresample/avresample.h | 106 ++
> ---
>  3 files changed, 110 insertions(+), 9 deletions(-)
>
> diff --git a/configure b/configure
> index 688f6ab803..f2fdb93668 100755
> --- a/configure
> +++ b/configure
> @@ -133,7 +133,7 @@ Component options:
>--disable-swscaledisable libswscale build
>--disable-postproc   disable libpostproc build
>--disable-avfilter   disable libavfilter build
> -  --enable-avresample  enable libavresample build [no]
> +  --enable-avresample  enable libavresample build (deprecated) [no]
>--disable-pthreads   disable pthreads [autodetect]
>--disable-w32threads disable Win32 threads [autodetect]
>--disable-os2threads disable OS/2 threads [autodetect]
> @@ -6521,7 +6521,7 @@ check_deps $CONFIG_LIST   \
> $ALL_COMPONENTS\
>
>  enabled threads && ! enabled pthreads && ! enabled atomics_native && die
> "non pthread threading without atomics not supported, try adding
> --enable-pthreads or --cpu=i486 or higher if you are on x86"
> -
> +enabled avresample && warn "Building with deprecated library
> libavresample"
>
>  if test $target_os = "haiku"; then
>  disable memalign
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 3c9f237596..38c1be61c7 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,15 @@ libavutil: 2017-10-21
>
>  API changes, most recent first:
>
> +2017-xx-xx - xxx - lavr 4.0.0 - avresample.h
> +  Deprecate the entire library. Merged years ago to provide compatibility
> +  with Libav, it remained unmaintained by the FFmpeg project and
> duplicated
> +  functionality provided by libswresample.
> +
> +  In order to improve consistency and reduce attack surface, it has been
> deprecated.
> +  Users of this library are asked to migrate to libswresample, which, as
> well as
> +  providing more functionality, is faster and has higher accuracy.
> +
>  2017-xx-xx - xxx - lavc 58.9.100 - avcodec.h
>Deprecate av_lockmgr_register(). You need to build FFmpeg with threading
>support enabled to get basic thread-safety (which is the default build
> diff --git a/libavresample/avresample.h b/libavresample/avresample.h
> index 193443e2a6..440e1a16e7 100644
> --- a/libavresample/avresample.h
> +++ b/libavresample/avresample.h
> @@ -103,24 +103,33 @@
>
>  #define AVRESAMPLE_MAX_CHANNELS 32
>
> -typedef struct AVAudioResampleContext AVAudioResampleContext;
> +typedef attribute_deprecated struct AVAudioResampleContext
> AVAudioResampleContext;
>
> -/** Mixing Coefficient Types */
> -enum AVMixCoeffType {
> +/**
> + * @deprecated use libswresample
> + *
> + * Mixing Coefficient Types */
> +enum attribute_deprecated AVMixCoeffType {
>  AV_MIX_COEFF_TYPE_Q8,   /** 16-bit 8.8 fixed-point
>   */
>  AV_MIX_COEFF_TYPE_Q15,  /** 32-bit 17.15 fixed-point
>   */
>  AV_MIX_COEFF_TYPE_FLT,  /** floating-point
>   */
>  AV_MIX_COEFF_TYPE_NB,   /** Number of coeff types. Not part of ABI
>   */
>  };
>
> -/** Resampling Filter Types */
> -enum AVResampleFilterType {
> +/**
> + * @deprecated use libswresample
> + *
> + * Resampling Filter Types */
> +enum attribute_deprecated AVResampleFilterType {
>  AV_RESAMPLE_FILTER_TYPE_CUBIC,  /**< Cubic */
>  AV_RESAMPLE_FILTER_TYPE_BLACKMAN_NUTTALL,   /**< Blackman Nuttall
> Windowed Sinc */
>  AV_RESAMPLE_FILTER_TYPE_KAISER, /**< Kaiser Windowed
> Sinc */
>  };
>
> -enum AVResampleDitherMethod {
> +/**
> + * @deprecated use libswresample
> + */
> +enum attribute_deprecated AVResampleDitherMethod {
>  AV_RESAMPLE_DITHER_NONE,/**< Do not use dithering */
>  AV_RESAMPLE_DITHER_RECTANGULAR, /**< Rectangular Dither */
>  AV_RESAMPLE_DITHER_TRIANGULAR,  /**< Triangular Dither*/
> @@ -130,22 +139,37 @@ enum AVResampleDitherMethod {
>  };
>
>  /**
> + *
> + * @deprecated use libswresample
> + *
>   * Return the LIBAVRESAMPLE_VERSION_INT constant.
>   */
> +attribute_deprecated
>  unsigned avresample_version(void);
>
>  /**
> + *
> + * @deprecated use libswresample
> + *
>   * Return the libavresample build-time configuration.
>   * @return  configure string
>   */
> 

Re: [FFmpeg-devel] [PATCH] avfilter: add arbitrary audio IIR filter

2018-01-02 Thread Rostislav Pehlivanov
On 2 January 2018 at 16:18, Paul B Mahol  wrote:

> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi |  14 +++
>  libavfilter/Makefile |   1 +
>  libavfilter/af_aiir.c| 232 ++
> +
>  libavfilter/allfilters.c |   1 +
>  4 files changed, 248 insertions(+)
>  create mode 100644 libavfilter/af_aiir.c
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index f651f1234d..ff911ad92e 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -1059,6 +1059,20 @@ the reduction.
>  Default is @code{average}. Can be @code{average} or @code{maximum}.
>  @end table
>
> +@section aiir
> +
> +Apply an arbitrary Infinite Impulse Response filter.
> +
> +It accepts the following parameters:
> +
> +@table @option
> +@item a
> +Set denominator coefficients.
> +
> +@item b
> +Set nominator coefficients.
> +@end table
> +
>  @section alimiter
>
>  The limiter prevents an input signal from rising over a desired threshold.
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 8bde542163..1fe58ed3d2 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -43,6 +43,7 @@ OBJS-$(CONFIG_AFFTFILT_FILTER)   +=
> af_afftfilt.o
>  OBJS-$(CONFIG_AFIR_FILTER)   += af_afir.o
>  OBJS-$(CONFIG_AFORMAT_FILTER)+= af_aformat.o
>  OBJS-$(CONFIG_AGATE_FILTER)  += af_agate.o
> +OBJS-$(CONFIG_AIIR_FILTER)   += af_aiir.o
>  OBJS-$(CONFIG_AINTERLEAVE_FILTER)+= f_interleave.o
>  OBJS-$(CONFIG_ALIMITER_FILTER)   += af_alimiter.o
>  OBJS-$(CONFIG_ALLPASS_FILTER)+= af_biquads.o
> diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
> new file mode 100644
> index 00..d1be9afa5e
> --- /dev/null
> +++ b/libavfilter/af_aiir.c
> @@ -0,0 +1,232 @@
> +/*
> + * Copyright (c) 2018 Paul B Mahol
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> + */
> +
> +#include "libavutil/avassert.h"
> +#include "libavutil/avstring.h"
> +#include "libavutil/opt.h"
> +#include "audio.h"
> +#include "avfilter.h"
> +#include "internal.h"
> +
> +typedef struct AudioIIRContext {
> +const AVClass *class;
> +char *a_str, *b_str;
> +
> +int nb_a, nb_b;
> +double *a, *b;
> +AVFrame *input, *output;
> +} AudioIIRContext;
> +
> +static int query_formats(AVFilterContext *ctx)
> +{
> +AVFilterFormats *formats;
> +AVFilterChannelLayouts *layouts;
> +static const enum AVSampleFormat sample_fmts[] = {
> +AV_SAMPLE_FMT_DBLP,
> +AV_SAMPLE_FMT_NONE
> +};
> +int ret;
> +
> +layouts = ff_all_channel_counts();
> +if (!layouts)
> +return AVERROR(ENOMEM);
> +ret = ff_set_common_channel_layouts(ctx, layouts);
> +if (ret < 0)
> +return ret;
> +
> +formats = ff_make_format_list(sample_fmts);
> +if (!formats)
> +return AVERROR(ENOMEM);
> +ret = ff_set_common_formats(ctx, formats);
> +if (ret < 0)
> +return ret;
> +
> +formats = ff_all_samplerates();
> +if (!formats)
> +return AVERROR(ENOMEM);
> +return ff_set_common_samplerates(ctx, formats);
> +}
> +
> +static int config_output(AVFilterLink *outlink)
> +{
> +AVFilterContext *ctx = outlink->src;
> +AudioIIRContext *s = ctx->priv;
> +AVFilterLink *inlink = ctx->inputs[0];
> +
> +s->input  = ff_get_audio_buffer(inlink, s->nb_b);
> +s->output = ff_get_audio_buffer(inlink, s->nb_a);
> +if (!s->input || !s->output)
> +return AVERROR(ENOMEM);
> +return 0;
> +}
> +
> +static int filter_frame(AVFilterLink *inlink, AVFrame *in)
> +{
> +AVFilterContext  *ctx = inlink->dst;
> +AudioIIRContext *s = ctx->priv;
> +AVFilterLink *outlink = ctx->outputs[0];
> +AVFrame *out;
> +int ch, n;
> +
> +if (av_frame_is_writable(in)) {
> +out = in;
> +} else {
> +out = ff_get_audio_buffer(outlink, in->nb_samples);
> +if (!out) {
> +av_frame_free();
> +return AVERROR(ENOMEM);
> +}
> +av_frame_copy_props(out, in);
> +}
> +
> +for (ch = 0; ch < out->channels; ch++) {
> +const double *src = 

[FFmpeg-devel] [PATCH v3] lavc/audiotoolboxenc: fix noise in encoded audio

2018-01-02 Thread zhangjiejun1992
From: Jiejun Zhang 

This fixes #6940

Although undocumented, AudioToolbox seems to require the data supplied
by the callback (i.e. ffat_encode_callback) being unchanged until the
next time the callback is called. In the old implementation, the
AVBuffer backing the frame is recycled after the frame is freed, and
somebody else (maybe the decoder) will write into the AVBuffer and
change the data. AudioToolbox then encodes some wrong data and noise
is produced. Retaining a frame reference solves this problem.
---
 libavcodec/audiotoolboxenc.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
index 71885d1530..5d3a746348 100644
--- a/libavcodec/audiotoolboxenc.c
+++ b/libavcodec/audiotoolboxenc.c
@@ -48,6 +48,8 @@ typedef struct ATDecodeContext {
 AudioFrameQueue afq;
 int eof;
 int frame_size;
+
+AVFrame* encoding_frame;
 } ATDecodeContext;
 
 static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile)
@@ -442,6 +444,10 @@ static av_cold int ffat_init_encoder(AVCodecContext *avctx)
 
 ff_af_queue_init(avctx, >afq);
 
+at->encoding_frame = av_frame_alloc();
+if (!at->encoding_frame)
+return AVERROR(ENOMEM);
+
 return 0;
 }
 
@@ -453,6 +459,7 @@ static OSStatus ffat_encode_callback(AudioConverterRef 
converter, UInt32 *nb_pac
 AVCodecContext *avctx = inctx;
 ATDecodeContext *at = avctx->priv_data;
 AVFrame *frame;
+int ret;
 
 if (!at->frame_queue.available) {
 if (at->eof) {
@@ -475,6 +482,10 @@ static OSStatus ffat_encode_callback(AudioConverterRef 
converter, UInt32 *nb_pac
 if (*nb_packets > frame->nb_samples)
 *nb_packets = frame->nb_samples;
 
+av_frame_unref(at->encoding_frame);
+if ((ret = av_frame_ref(at->encoding_frame, frame)) < 0)
+return ret;
+
 ff_bufqueue_add(avctx, >used_frame_queue, frame);
 
 return 0;
@@ -565,6 +576,7 @@ static av_cold int ffat_close_encoder(AVCodecContext *avctx)
 ff_bufqueue_discard_all(>frame_queue);
 ff_bufqueue_discard_all(>used_frame_queue);
 ff_af_queue_close(>afq);
+av_frame_free(>encoding_frame);
 return 0;
 }
 
-- 
2.14.3 (Apple Git-98)

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


[FFmpeg-devel] [PATCH v2 1/2] http: block while waiting for reconnecting

2018-01-02 Thread wm4
It makes no sense to return an error after the first reconnect, and then
somehow resume the next time it's called. Usually this will lead to
demuxer errors. Make reconnecting block instead, until it has either
successfully reconnected, or given up.

Also make the wait reasonably interruptible. Since there is no mechanism
for this in the API, polling is the best we can do. This behaves roughly
the same as other interruptible network functions in libavformat.

(The original code would work if it returned AVERROR(EAGAIN) or so,
which would make retry_transfer_wrapper() repeat the read call. But I
think having an explicit loop for this is better anyway.)

I also snuck in a fix for reconnect_at_eof. It has to check for
AVERROR_EOF, not 0.
---
 libavformat/http.c| 19 ++-
 libavformat/network.c | 18 ++
 libavformat/network.h |  9 +
 3 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index 8f7e56de54..5eff87f8bb 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -117,7 +117,6 @@ typedef struct HTTPContext {
 int reconnect;
 int reconnect_at_eof;
 int reconnect_streamed;
-int reconnect_delay;
 int reconnect_delay_max;
 int listen;
 char *resource;
@@ -1433,6 +1432,7 @@ static int http_read_stream(URLContext *h, uint8_t *buf, 
int size)
 HTTPContext *s = h->priv_data;
 int err, new_location, read_ret;
 int64_t seek_ret;
+int reconnect_delay = 0;
 
 if (!s->hd)
 return AVERROR_EOF;
@@ -1448,25 +1448,26 @@ static int http_read_stream(URLContext *h, uint8_t 
*buf, int size)
 return http_buf_read_compressed(h, buf, size);
 #endif /* CONFIG_ZLIB */
 read_ret = http_buf_read(h, buf, size);
-if (   (read_ret  < 0 && s->reconnect&& (!h->is_streamed || 
s->reconnect_streamed) && s->filesize > 0 && s->off < s->filesize)
-|| (read_ret == 0 && s->reconnect_at_eof && (!h->is_streamed || 
s->reconnect_streamed))) {
+while ((read_ret  < 0   && s->reconnect&& (!h->is_streamed 
|| s->reconnect_streamed) && s->filesize > 0 && s->off < s->filesize)
+|| (read_ret == AVERROR_EOF && s->reconnect_at_eof && (!h->is_streamed 
|| s->reconnect_streamed))) {
 uint64_t target = h->is_streamed ? 0 : s->off;
 
-if (s->reconnect_delay > s->reconnect_delay_max)
+if (reconnect_delay > s->reconnect_delay_max)
 return AVERROR(EIO);
 
 av_log(h, AV_LOG_INFO, "Will reconnect at %"PRIu64" error=%s.\n", 
s->off, av_err2str(read_ret));
-av_usleep(1000U*1000*s->reconnect_delay);
-s->reconnect_delay = 1 + 2*s->reconnect_delay;
+err = ff_network_sleep_interruptible(1000U*1000*reconnect_delay, 
>interrupt_callback);
+if (err != AVERROR(ETIMEDOUT))
+return err;
+reconnect_delay = 1 + 2*reconnect_delay;
 seek_ret = http_seek_internal(h, target, SEEK_SET, 1);
-if (seek_ret != target) {
+if (seek_ret >= 0 && seek_ret != target) {
 av_log(h, AV_LOG_ERROR, "Failed to reconnect at %"PRIu64".\n", 
target);
 return read_ret;
 }
 
 read_ret = http_buf_read(h, buf, size);
-} else
-s->reconnect_delay = 0;
+}
 
 return read_ret;
 }
diff --git a/libavformat/network.c b/libavformat/network.c
index 6c3d9def3b..e9eb4b443a 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -103,6 +103,24 @@ int ff_network_wait_fd_timeout(int fd, int write, int64_t 
timeout, AVIOInterrupt
 }
 }
 
+int ff_network_sleep_interruptible(int64_t timeout, AVIOInterruptCB *int_cb)
+{
+int64_t wait_start = av_gettime_relative();
+
+while (1) {
+int64_t time_left;
+
+if (ff_check_interrupt(int_cb))
+return AVERROR_EXIT;
+
+time_left = timeout - (av_gettime_relative() - wait_start);
+if (time_left <= 0)
+return AVERROR(ETIMEDOUT);
+
+av_usleep(FFMIN(time_left, POLLING_TIME * 1000));
+}
+}
+
 void ff_network_close(void)
 {
 #if HAVE_WINSOCK2_H
diff --git a/libavformat/network.h b/libavformat/network.h
index b78e3ad6ed..a663115541 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -96,6 +96,15 @@ int ff_network_wait_fd(int fd, int write);
  */
 int ff_network_wait_fd_timeout(int fd, int write, int64_t timeout, 
AVIOInterruptCB *int_cb);
 
+/**
+ * Waits for up to 'timeout' microseconds. If the usert's int_cb is set and
+ * triggered, return before that.
+ * @timeout Timeout in microseconds. Maybe have lower actual precision.
+ * @param int_cb Interrupt callback, is checked regularly.
+ * @return AVERROR(ETIMEDOUT) if timeout expirted, AVERROR_EXIT if interrupted 
by int_cb
+ */
+int ff_network_sleep_interruptible(int64_t timeout, AVIOInterruptCB *int_cb);
+
 int ff_inet_aton (const char * str, struct in_addr * add);
 
 #if !HAVE_STRUCT_SOCKADDR_STORAGE
-- 
2.15.1


Re: [FFmpeg-devel] [PATCH v2] lavc/audiotoolboxenc: fix noise in encoded audio

2018-01-02 Thread Jiejun Zhang
>
> Can't you instead create a new reference for the frame buffer? Or will
> making it non writable break things further into the process? It would
> save you a memcpy per frame.

Great idea. It works. Making it non-writable should be enough. I'm
submitting v3. Please take a look.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 2/2] http: bump message level for reconnect message and log timeout

2018-01-02 Thread wm4
---
 libavformat/http.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index 5eff87f8bb..eb029e33a0 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -1455,7 +1455,7 @@ static int http_read_stream(URLContext *h, uint8_t *buf, 
int size)
 if (reconnect_delay > s->reconnect_delay_max)
 return AVERROR(EIO);
 
-av_log(h, AV_LOG_INFO, "Will reconnect at %"PRIu64" error=%s.\n", 
s->off, av_err2str(read_ret));
+av_log(h, AV_LOG_WARNING, "Will reconnect at %"PRIu64" in %d 
second(s), error=%s.\n", s->off, reconnect_delay, av_err2str(read_ret));
 err = ff_network_sleep_interruptible(1000U*1000*reconnect_delay, 
>interrupt_callback);
 if (err != AVERROR(ETIMEDOUT))
 return err;
-- 
2.15.1

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


[FFmpeg-devel] [PATCH] avfilter: add arbitrary audio IIR filter

2018-01-02 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi |  14 +++
 libavfilter/Makefile |   1 +
 libavfilter/af_aiir.c| 232 +++
 libavfilter/allfilters.c |   1 +
 4 files changed, 248 insertions(+)
 create mode 100644 libavfilter/af_aiir.c

diff --git a/doc/filters.texi b/doc/filters.texi
index f651f1234d..ff911ad92e 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1059,6 +1059,20 @@ the reduction.
 Default is @code{average}. Can be @code{average} or @code{maximum}.
 @end table
 
+@section aiir
+
+Apply an arbitrary Infinite Impulse Response filter.
+
+It accepts the following parameters:
+
+@table @option
+@item a
+Set denominator coefficients.
+
+@item b
+Set nominator coefficients.
+@end table
+
 @section alimiter
 
 The limiter prevents an input signal from rising over a desired threshold.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 8bde542163..1fe58ed3d2 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -43,6 +43,7 @@ OBJS-$(CONFIG_AFFTFILT_FILTER)   += af_afftfilt.o
 OBJS-$(CONFIG_AFIR_FILTER)   += af_afir.o
 OBJS-$(CONFIG_AFORMAT_FILTER)+= af_aformat.o
 OBJS-$(CONFIG_AGATE_FILTER)  += af_agate.o
+OBJS-$(CONFIG_AIIR_FILTER)   += af_aiir.o
 OBJS-$(CONFIG_AINTERLEAVE_FILTER)+= f_interleave.o
 OBJS-$(CONFIG_ALIMITER_FILTER)   += af_alimiter.o
 OBJS-$(CONFIG_ALLPASS_FILTER)+= af_biquads.o
diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
new file mode 100644
index 00..d1be9afa5e
--- /dev/null
+++ b/libavfilter/af_aiir.c
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2018 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/avassert.h"
+#include "libavutil/avstring.h"
+#include "libavutil/opt.h"
+#include "audio.h"
+#include "avfilter.h"
+#include "internal.h"
+
+typedef struct AudioIIRContext {
+const AVClass *class;
+char *a_str, *b_str;
+
+int nb_a, nb_b;
+double *a, *b;
+AVFrame *input, *output;
+} AudioIIRContext;
+
+static int query_formats(AVFilterContext *ctx)
+{
+AVFilterFormats *formats;
+AVFilterChannelLayouts *layouts;
+static const enum AVSampleFormat sample_fmts[] = {
+AV_SAMPLE_FMT_DBLP,
+AV_SAMPLE_FMT_NONE
+};
+int ret;
+
+layouts = ff_all_channel_counts();
+if (!layouts)
+return AVERROR(ENOMEM);
+ret = ff_set_common_channel_layouts(ctx, layouts);
+if (ret < 0)
+return ret;
+
+formats = ff_make_format_list(sample_fmts);
+if (!formats)
+return AVERROR(ENOMEM);
+ret = ff_set_common_formats(ctx, formats);
+if (ret < 0)
+return ret;
+
+formats = ff_all_samplerates();
+if (!formats)
+return AVERROR(ENOMEM);
+return ff_set_common_samplerates(ctx, formats);
+}
+
+static int config_output(AVFilterLink *outlink)
+{
+AVFilterContext *ctx = outlink->src;
+AudioIIRContext *s = ctx->priv;
+AVFilterLink *inlink = ctx->inputs[0];
+
+s->input  = ff_get_audio_buffer(inlink, s->nb_b);
+s->output = ff_get_audio_buffer(inlink, s->nb_a);
+if (!s->input || !s->output)
+return AVERROR(ENOMEM);
+return 0;
+}
+
+static int filter_frame(AVFilterLink *inlink, AVFrame *in)
+{
+AVFilterContext  *ctx = inlink->dst;
+AudioIIRContext *s = ctx->priv;
+AVFilterLink *outlink = ctx->outputs[0];
+AVFrame *out;
+int ch, n;
+
+if (av_frame_is_writable(in)) {
+out = in;
+} else {
+out = ff_get_audio_buffer(outlink, in->nb_samples);
+if (!out) {
+av_frame_free();
+return AVERROR(ENOMEM);
+}
+av_frame_copy_props(out, in);
+}
+
+for (ch = 0; ch < out->channels; ch++) {
+const double *src = (const double *)in->extended_data[ch];
+double *ic = (double *)s->input->extended_data[ch];
+double *oc = (double *)s->output->extended_data[ch];
+double *dst = (double *)out->extended_data[ch];
+const double *a = s->a;
+const double *b = s->b;
+
+for (n = 0; n < in->nb_samples; n++) {
+double sample = 0.;
+  

Re: [FFmpeg-devel] [PATCH v2] lavc/audiotoolboxenc: fix noise in encoded audio

2018-01-02 Thread James Almer
On 1/2/2018 12:03 PM, zhangjiejun1...@gmail.com wrote:
> From: Jiejun Zhang 
> 
> This fixes #6940
> 
> Although undocumented, AudioToolbox seems to require the data supplied
> by the callback (i.e. ffat_encode_callback) being unchanged until the
> next time the callback is called. In the old implementation, the
> AVBuffer backing the frame is recycled after the frame is freed, and
> somebody else (maybe the decoder) will write into the AVBuffer and
> change the data. AudioToolbox then encodes some wrong data and noise
> is produced. Copying the data to a separate buffer solves this
> problem.
> ---
>  libavcodec/audiotoolboxenc.c | 32 +++-
>  1 file changed, 27 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
> index 71885d1530..dcac88cdde 100644
> --- a/libavcodec/audiotoolboxenc.c
> +++ b/libavcodec/audiotoolboxenc.c
> @@ -48,6 +48,9 @@ typedef struct ATDecodeContext {
>  AudioFrameQueue afq;
>  int eof;
>  int frame_size;
> +
> +uint8_t* audio_data_buf;
> +uint32_t audio_data_buf_size;
>  } ATDecodeContext;
>  
>  static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile)
> @@ -442,6 +445,9 @@ static av_cold int ffat_init_encoder(AVCodecContext 
> *avctx)
>  
>  ff_af_queue_init(avctx, >afq);
>  
> +at->audio_data_buf_size = 0;
> +at->audio_data_buf = NULL;

The entire ATDecodeContext struct is zero initialized when allocated, so
this is not needed.

> +
>  return 0;
>  }
>  
> @@ -465,13 +471,27 @@ static OSStatus ffat_encode_callback(AudioConverterRef 
> converter, UInt32 *nb_pac
>  }
>  
>  frame = ff_bufqueue_get(>frame_queue);
> -
> +int audio_data_size = frame->nb_samples *
> +  av_get_bytes_per_sample(avctx->sample_fmt) *
> +  avctx->channels;
> +if (at->audio_data_buf_size < audio_data_size) {
> +av_log(avctx, AV_LOG_INFO, "Increasing audio data buffer size to 
> %d\n",

Verbose or debug level, please.

> +   audio_data_size);
> +av_free(at->audio_data_buf);
> +at->audio_data_buf_size = audio_data_size;
> +at->audio_data_buf = av_malloc(at->audio_data_buf_size);
> +if (!at->audio_data_buf) {
> +at->audio_data_buf_size = 0;
> +data->mNumberBuffers = 0;
> +*nb_packets = 0;
> +return AVERROR(ENOMEM);
> +}
> +}
>  data->mNumberBuffers  = 1;
>  data->mBuffers[0].mNumberChannels = avctx->channels;
> -data->mBuffers[0].mDataByteSize   = frame->nb_samples *
> -
> av_get_bytes_per_sample(avctx->sample_fmt) *
> -avctx->channels;
> -data->mBuffers[0].mData   = frame->data[0];
> +data->mBuffers[0].mDataByteSize   = audio_data_size;
> +data->mBuffers[0].mData   = at->audio_data_buf;
> +memcpy(at->audio_data_buf, frame->data[0], 
> data->mBuffers[0].mDataByteSize);

Can't you instead create a new reference for the frame buffer? Or will
making it non writable break things further into the process? It would
save you a memcpy per frame.

>  if (*nb_packets > frame->nb_samples)
>  *nb_packets = frame->nb_samples;
>  
> @@ -565,6 +585,8 @@ static av_cold int ffat_close_encoder(AVCodecContext 
> *avctx)
>  ff_bufqueue_discard_all(>frame_queue);
>  ff_bufqueue_discard_all(>used_frame_queue);
>  ff_af_queue_close(>afq);
> +at->audio_data_buf_size = 0;
> +av_freep(>audio_data_buf);
>  return 0;
>  }
>  
> 

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


[FFmpeg-devel] [PATCH v2] lavc/audiotoolboxenc: fix noise in encoded audio

2018-01-02 Thread zhangjiejun1992
From: Jiejun Zhang 

This fixes #6940

Although undocumented, AudioToolbox seems to require the data supplied
by the callback (i.e. ffat_encode_callback) being unchanged until the
next time the callback is called. In the old implementation, the
AVBuffer backing the frame is recycled after the frame is freed, and
somebody else (maybe the decoder) will write into the AVBuffer and
change the data. AudioToolbox then encodes some wrong data and noise
is produced. Copying the data to a separate buffer solves this
problem.
---
 libavcodec/audiotoolboxenc.c | 32 +++-
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
index 71885d1530..dcac88cdde 100644
--- a/libavcodec/audiotoolboxenc.c
+++ b/libavcodec/audiotoolboxenc.c
@@ -48,6 +48,9 @@ typedef struct ATDecodeContext {
 AudioFrameQueue afq;
 int eof;
 int frame_size;
+
+uint8_t* audio_data_buf;
+uint32_t audio_data_buf_size;
 } ATDecodeContext;
 
 static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile)
@@ -442,6 +445,9 @@ static av_cold int ffat_init_encoder(AVCodecContext *avctx)
 
 ff_af_queue_init(avctx, >afq);
 
+at->audio_data_buf_size = 0;
+at->audio_data_buf = NULL;
+
 return 0;
 }
 
@@ -465,13 +471,27 @@ static OSStatus ffat_encode_callback(AudioConverterRef 
converter, UInt32 *nb_pac
 }
 
 frame = ff_bufqueue_get(>frame_queue);
-
+int audio_data_size = frame->nb_samples *
+  av_get_bytes_per_sample(avctx->sample_fmt) *
+  avctx->channels;
+if (at->audio_data_buf_size < audio_data_size) {
+av_log(avctx, AV_LOG_INFO, "Increasing audio data buffer size to %d\n",
+   audio_data_size);
+av_free(at->audio_data_buf);
+at->audio_data_buf_size = audio_data_size;
+at->audio_data_buf = av_malloc(at->audio_data_buf_size);
+if (!at->audio_data_buf) {
+at->audio_data_buf_size = 0;
+data->mNumberBuffers = 0;
+*nb_packets = 0;
+return AVERROR(ENOMEM);
+}
+}
 data->mNumberBuffers  = 1;
 data->mBuffers[0].mNumberChannels = avctx->channels;
-data->mBuffers[0].mDataByteSize   = frame->nb_samples *
-
av_get_bytes_per_sample(avctx->sample_fmt) *
-avctx->channels;
-data->mBuffers[0].mData   = frame->data[0];
+data->mBuffers[0].mDataByteSize   = audio_data_size;
+data->mBuffers[0].mData   = at->audio_data_buf;
+memcpy(at->audio_data_buf, frame->data[0], 
data->mBuffers[0].mDataByteSize);
 if (*nb_packets > frame->nb_samples)
 *nb_packets = frame->nb_samples;
 
@@ -565,6 +585,8 @@ static av_cold int ffat_close_encoder(AVCodecContext *avctx)
 ff_bufqueue_discard_all(>frame_queue);
 ff_bufqueue_discard_all(>used_frame_queue);
 ff_af_queue_close(>afq);
+at->audio_data_buf_size = 0;
+av_freep(>audio_data_buf);
 return 0;
 }
 
-- 
2.14.3 (Apple Git-98)

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


Re: [FFmpeg-devel] [PATCH] lavc/audiotoolboxenc: fix noise in encoded audio

2018-01-02 Thread Jiejun Zhang
On Tue, Jan 2, 2018 at 10:37 PM, wm4  wrote:
> On Tue, 2 Jan 2018 22:27:49 +0800
> Jiejun Zhang  wrote:
>
>> On Tue, Jan 2, 2018 at 8:03 PM, Carl Eugen Hoyos  wrote:
>> > 2018-01-02 8:52 GMT+01:00  :
>> >
>> >> @@ -565,6 +579,10 @@ static av_cold int ffat_close_encoder(AVCodecContext 
>> >> *avctx)
>> >>  ff_bufqueue_discard_all(>frame_queue);
>> >>  ff_bufqueue_discard_all(>used_frame_queue);
>> >>  ff_af_queue_close(>afq);
>> >> +if (at->audio_data_buf_size > 0) {
>> >> +at->audio_data_buf_size = 0;
>> >> +av_free(at->audio_data_buf);
>> >> +}
>> >
>> > The if() looks unnecessary.
>>
>> Yes. I'll remove it. Thanks for pointing it out.
>>
>> > Could you explain what this patch changes?
>> > From a quick look, until now a buffer a was used with a calculated size x.
>> > After the patch, a buffer b with the same calculated size x is allocated,
>> > and x bytes are copied from a to b.
>> > What do I miss?
>>
>> Although undocumented, AudioToolbox seems to require the data supplied
>> by the callback (i.e. ffat_encode_callback) being unchanged until the
>> next time the callback is called. In the old implementation, the
>> AVBuffer backing the frame is recycled after the frame is freed, and
>> somebody else (maybe the decoder) will write into the AVBuffer and
>> change the data. AudioToolbox then encodes some wrong data and noise
>> is produced. Copying the data to a separate buffer solves this
>> problem.
>
> This should be in the commit message.

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


Re: [FFmpeg-devel] [PATCH][RFC]lavu/mem: Allow allocations close to max_alloc_size with av_fast_realloc()

2018-01-02 Thread Bang He
what is the mean:   min_size + min_size / 16 + 32

On Tue, Jan 2, 2018 at 9:00 AM, Carl Eugen Hoyos  wrote:

> 2018-01-02 1:14 GMT+01:00 Michael Niedermayer :
> > On Mon, Jan 01, 2018 at 11:10:57PM +0100, Carl Eugen Hoyos wrote:
> >> Hi!
> >>
> >> Similar reason as last mem.c patch: av_fast_realloc() can currently
> >> fail in situations where the allocation is possible and allowed.
> >> The patch does not change behaviour for the failure case, if this is
> >> wanted, it should be done separately.
> >>
> >> Please comment, Carl Eugen
> >
> >>  mem.c |5 -
> >>  1 file changed, 4 insertions(+), 1 deletion(-)
> >> 7529e1d584c62ece463f4461279ea6e3973162c9  0001-lavu-mem-Allow-
> allocations-close-to-max_alloc_size-w.patch
> >> From ac69f4e8402f7c7ee6df09c0450354e2bb900e5a Mon Sep 17 00:00:00 2001
> >> From: Carl Eugen Hoyos 
> >> Date: Mon, 1 Jan 2018 23:04:58 +0100
> >> Subject: [PATCH] lavu/mem: Allow allocations close to max_alloc_size
> with
> >>  av_fast_realloc().
> >>
> >> ---
> >>  libavutil/mem.c |5 -
> >>  1 file changed, 4 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/libavutil/mem.c b/libavutil/mem.c
> >> index 0729e1d..934987f 100644
> >> --- a/libavutil/mem.c
> >> +++ b/libavutil/mem.c
> >> @@ -466,7 +466,10 @@ void *av_fast_realloc(void *ptr, unsigned int
> *size, size_t min_size)
> >>  if (min_size <= *size)
> >>  return ptr;
> >>
> >> -min_size = FFMAX(min_size + min_size / 16 + 32, min_size);
> >> +if (min_size > (max_alloc_size - 32))
> >> +return NULL;
> >
> > This failure mode differs from the existing in what it does with *size
>
> New patch attached.
>
> Thank you, Carl Eugen
>
> ___
> 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] lavc/audiotoolboxenc: fix noise in encoded audio

2018-01-02 Thread wm4
On Tue, 2 Jan 2018 22:27:49 +0800
Jiejun Zhang  wrote:

> On Tue, Jan 2, 2018 at 8:03 PM, Carl Eugen Hoyos  wrote:
> > 2018-01-02 8:52 GMT+01:00  :
> >  
> >> @@ -565,6 +579,10 @@ static av_cold int ffat_close_encoder(AVCodecContext 
> >> *avctx)
> >>  ff_bufqueue_discard_all(>frame_queue);
> >>  ff_bufqueue_discard_all(>used_frame_queue);
> >>  ff_af_queue_close(>afq);
> >> +if (at->audio_data_buf_size > 0) {
> >> +at->audio_data_buf_size = 0;
> >> +av_free(at->audio_data_buf);
> >> +}  
> >
> > The if() looks unnecessary.  
> 
> Yes. I'll remove it. Thanks for pointing it out.
> 
> > Could you explain what this patch changes?
> > From a quick look, until now a buffer a was used with a calculated size x.
> > After the patch, a buffer b with the same calculated size x is allocated,
> > and x bytes are copied from a to b.
> > What do I miss?  
> 
> Although undocumented, AudioToolbox seems to require the data supplied
> by the callback (i.e. ffat_encode_callback) being unchanged until the
> next time the callback is called. In the old implementation, the
> AVBuffer backing the frame is recycled after the frame is freed, and
> somebody else (maybe the decoder) will write into the AVBuffer and
> change the data. AudioToolbox then encodes some wrong data and noise
> is produced. Copying the data to a separate buffer solves this
> problem.

This should be in the commit message.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavc/audiotoolboxenc: fix noise in encoded audio

2018-01-02 Thread Jiejun Zhang
On Tue, Jan 2, 2018 at 8:03 PM, Carl Eugen Hoyos  wrote:
> 2018-01-02 8:52 GMT+01:00  :
>
>> @@ -565,6 +579,10 @@ static av_cold int ffat_close_encoder(AVCodecContext 
>> *avctx)
>>  ff_bufqueue_discard_all(>frame_queue);
>>  ff_bufqueue_discard_all(>used_frame_queue);
>>  ff_af_queue_close(>afq);
>> +if (at->audio_data_buf_size > 0) {
>> +at->audio_data_buf_size = 0;
>> +av_free(at->audio_data_buf);
>> +}
>
> The if() looks unnecessary.

Yes. I'll remove it. Thanks for pointing it out.

> Could you explain what this patch changes?
> From a quick look, until now a buffer a was used with a calculated size x.
> After the patch, a buffer b with the same calculated size x is allocated,
> and x bytes are copied from a to b.
> What do I miss?

Although undocumented, AudioToolbox seems to require the data supplied
by the callback (i.e. ffat_encode_callback) being unchanged until the
next time the callback is called. In the old implementation, the
AVBuffer backing the frame is recycled after the frame is freed, and
somebody else (maybe the decoder) will write into the AVBuffer and
change the data. AudioToolbox then encodes some wrong data and noise
is produced. Copying the data to a separate buffer solves this
problem.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add DECLARE_ASM_ALIGNED macro for DJGPP architecture.

2018-01-02 Thread Thomas Köppe
Oh, very true, I must have missed that -- thank you!

On 2 January 2018 at 14:08, James Almer  wrote:

> On 1/2/2018 10:59 AM, Thomas Köppe wrote:
> > Hello,
> >
> > Friendly ping, can I interest you in this patch? It seems like it fixes
> an
> > oversight that would be annoying for anyone trying to build FFMPEG for
> > DJGPP.
> >
> > Thanks!
>
> This seems to have been applied already. See commit
> 53c492640c6b4690715793372454194379093d21
> ___
> 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] Add DECLARE_ASM_ALIGNED macro for DJGPP architecture.

2018-01-02 Thread James Almer
On 1/2/2018 10:59 AM, Thomas Köppe wrote:
> Hello,
> 
> Friendly ping, can I interest you in this patch? It seems like it fixes an
> oversight that would be annoying for anyone trying to build FFMPEG for
> DJGPP.
> 
> Thanks!

This seems to have been applied already. See commit
53c492640c6b4690715793372454194379093d21
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add DECLARE_ASM_ALIGNED macro for DJGPP architecture.

2018-01-02 Thread Thomas Köppe
Hello,

Friendly ping, can I interest you in this patch? It seems like it fixes an
oversight that would be annoying for anyone trying to build FFMPEG for
DJGPP.

Thanks!

On 14 November 2017 at 18:26, Thomas Köppe  wrote:

> The macro was added in 43171a2a738f5114768d34a7278e56e5fde714bc, but I
> forgot to add it to the DJGPP architecture in that change.
> ---
>  libavutil/mem.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libavutil/mem.h b/libavutil/mem.h
> index 9e344bd2c3..7e0b12a8a7 100644
> --- a/libavutil/mem.h
> +++ b/libavutil/mem.h
> @@ -106,6 +106,7 @@
>  #define DECLARE_ASM_CONST(n,t,v)const t __attribute__ ((aligned
> (n))) v
>  #elif defined(__DJGPP__)
>  #define DECLARE_ALIGNED(n,t,v)  t __attribute__ ((aligned
> (FFMIN(n, 16 v
> +#define DECLARE_ASM_ALIGNED(n,t,v)  t av_used __attribute__ ((aligned
> (FFMIN(n, 16 v
>  #define DECLARE_ASM_CONST(n,t,v)static const t av_used
> __attribute__ ((aligned (FFMIN(n, 16 v
>  #elif defined(__GNUC__) || defined(__clang__)
>  #define DECLARE_ALIGNED(n,t,v)  t __attribute__ ((aligned (n))) v
> --
> 2.15.0.448.gf294e3d99a-goog
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] lavfi/framesync: document frame ownership for dualinput.

2018-01-02 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/framesync.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavfilter/framesync.h b/libavfilter/framesync.h
index 9fdc4d1ae2..abf3bf552b 100644
--- a/libavfilter/framesync.h
+++ b/libavfilter/framesync.h
@@ -286,6 +286,9 @@ int ff_framesync_init_dualinput(FFFrameSync *fs, 
AVFilterContext *parent);
  * @param f0  used to return the main frame
  * @param f1  used to return the second frame, or NULL if disabled
  * @return  >=0 for success or AVERROR code
+ * @note  The frame returned in f0 belongs to the caller (get = 1 in
+ * ff_framesync_get_frame()) while the frame returned in f1 is still owned
+ * by the framesync structure.
  */
 int ff_framesync_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1);
 
-- 
2.15.1

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


[FFmpeg-devel] [PATCH 2/2] lavfi/framesync: remove an invalid free.

2018-01-02 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/framesync.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


Not actually experienced a problem, but similar to Derek's fix.


diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c
index 82d715750c..da12c58a61 100644
--- a/libavfilter/framesync.c
+++ b/libavfilter/framesync.c
@@ -406,7 +406,7 @@ int ff_framesync_dualinput_get_writable(FFFrameSync *fs, 
AVFrame **f0, AVFrame *
 ret = ff_inlink_make_frame_writable(fs->parent->inputs[0], f0);
 if (ret < 0) {
 av_frame_free(f0);
-av_frame_free(f1);
+*f1 = NULL;
 return ret;
 }
 return 0;
-- 
2.15.1

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


Re: [FFmpeg-devel] [PATCH 2/2] vf_paletteuse: Don't free the second frame from ff_framesync_dualinput_get_writable on error

2018-01-02 Thread Nicolas George
Derek Buitenhuis (2018-01-01):
> This fixes a double free in he error case.
> 
> Signed-off-by: Derek Buitenhuis 
> ---
> This does fix the double free, but I am unsure if it is the correct free
> to removed to fix it. Comments welcome.
> ---
>  libavfilter/vf_paletteuse.c | 1 -
>  1 file changed, 1 deletion(-)

I confirm it is correct with regard to the framesync API. But I do not
maintain vf_paletteuse.

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] [FFmpeg-cvslog] w32pthreads: always use Vista+ API, drop XP support

2018-01-02 Thread wm4
On Tue, 2 Jan 2018 03:55:18 +0100
Michael Niedermayer  wrote:

> On Tue, Dec 26, 2017 at 01:50:08AM +, wm4 wrote:
> > ffmpeg | branch: master | wm4  | Thu Dec 21 20:23:14 
> > 2017 +0100| [9b121dfc32810250938021952aab4172a988cb56] | committer: wm4
> > 
> > w32pthreads: always use Vista+ API, drop XP support
> > 
> > This removes the XP compatibility code, and switches entirely to SWR
> > locks, which are available starting at Windows Vista.
> > 
> > This removes CRITICAL_SECTION use, which allows us to add
> > PTHREAD_MUTEX_INITIALIZER, which will be useful later.
> > 
> > Windows XP is hereby not a supported build target anymore. It was
> > decided in a project vote that this is OK.
> >   
> > > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b121dfc32810250938021952aab4172a988cb56
> > >   
> > ---
> > 
> >  Changelog  |   2 +
> >  compat/w32pthreads.h   | 266 
> > ++---
> >  configure  |  13 ++-
> >  libavcodec/pthread_frame.c |   4 -
> >  libavcodec/pthread_slice.c |   4 -
> >  libavfilter/pthread.c  |   4 -
> >  libavutil/slicethread.c|   4 -
> >  7 files changed, 19 insertions(+), 278 deletions(-)  
> 
> This breaks mingw32 / wine support on ubuntu 14.04
> the code simply crashes at runtime
> 
> [...]

wine usually doesn't implement the full win32 API, so it's a given that
some programs fail.

InitializeConditionVariable in particular can not fail according to MSDN.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [FFmpeg-cvslog] w32pthreads: always use Vista+ API, drop XP support

2018-01-02 Thread Michael Niedermayer
On Tue, Jan 02, 2018 at 02:14:15PM +0100, Hendrik Leppkes wrote:
> On Tue, Jan 2, 2018 at 2:05 PM, Michael Niedermayer
>  wrote:
> > On Tue, Jan 02, 2018 at 10:36:44AM +0100, Hendrik Leppkes wrote:
> >> On Tue, Jan 2, 2018 at 4:28 AM, Michael Niedermayer
> >>  wrote:
> >> > On Tue, Jan 02, 2018 at 03:58:14AM +0100, Michael Niedermayer wrote:
> >> >> On Tue, Jan 02, 2018 at 03:55:18AM +0100, Michael Niedermayer wrote:
> >> >> > On Tue, Dec 26, 2017 at 01:50:08AM +, wm4 wrote:
> >> >> > > ffmpeg | branch: master | wm4  | Thu Dec 21 
> >> >> > > 20:23:14 2017 +0100| [9b121dfc32810250938021952aab4172a988cb56] | 
> >> >> > > committer: wm4
> >> >> > >
> >> >> > > w32pthreads: always use Vista+ API, drop XP support
> >> >> > >
> >> >> > > This removes the XP compatibility code, and switches entirely to SWR
> >> >> > > locks, which are available starting at Windows Vista.
> >> >> > >
> >> >> > > This removes CRITICAL_SECTION use, which allows us to add
> >> >> > > PTHREAD_MUTEX_INITIALIZER, which will be useful later.
> >> >> > >
> >> >> > > Windows XP is hereby not a supported build target anymore. It was
> >> >> > > decided in a project vote that this is OK.
> >> >> > >
> >> >> > > > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b121dfc32810250938021952aab4172a988cb56
> >> >> > > ---
> >> >> > >
> >> >> > >  Changelog  |   2 +
> >> >> > >  compat/w32pthreads.h   | 266 
> >> >> > > ++---
> >> >> > >  configure  |  13 ++-
> >> >> > >  libavcodec/pthread_frame.c |   4 -
> >> >> > >  libavcodec/pthread_slice.c |   4 -
> >> >> > >  libavfilter/pthread.c  |   4 -
> >> >> > >  libavutil/slicethread.c|   4 -
> >> >> > >  7 files changed, 19 insertions(+), 278 deletions(-)
> >> >> >
> >> >> > This breaks mingw32 / wine support on ubuntu 14.04
> >> >> > the code simply crashes at runtime
> >> >>
> >> >> Heres what wine provides as debug info:
> >> >>
> >> >> Unhandled exception: unimplemented function 
> >> >> KERNEL32.dll.InitializeConditionVariable called in 32-bit code 
> >> >> (0x7bc4e590).
> >> >
> >> > and thats mingw64:
> >> > Unhandled exception: unimplemented function 
> >> > KERNEL32.dll.InitializeConditionVariable called in 64-bit code 
> >> > (0x2ae6eb445e38).
> >> > Register dump:
> >> >  rip:2ae6eb445e38 rsp:0032e150 rbp:00099840 
> >> > eflags:0206 (   - --  I   - -P- )
> >> >  rax:2ae6eb445df0 rbx:0032e170 rcx:0032e170 
> >> > rdx:000140c31e80
> >> >  rsi:00014199182c rdi:000141992788  r8:000f  
> >> > r9: r10:2ae6eb6dfd6f
> >> >  r11:2ae6eb1ae510 r12: r13:000b4580 
> >> > r14:7b8883b0 r15:0033
> >> > Stack dump:
> >> > 0x0032e150:  0032e170 7b888429
> >> > 0x0032e160:  416e6f6974706972 4474654770616300
> >> > 0x0032e170:  00018100 
> >> > 0x0032e180:  2ae6eb445e38 0002
> >> > 0x0032e190:  000141992788 00014199182c
> >> > 0x0032e1a0:   
> >> > 0x0032e1b0:   
> >> > 0x0032e1c0:   
> >> > 0x0032e1d0:   
> >> > 0x0032e1e0:   
> >> > 0x0032e1f0:   
> >> > 0x0032e200:  000b44c0 000b44c0
> >> > Backtrace:
> >> > =>0 0x2ae6eb445e38 in ntdll (+0x35e38) (0x00099840)
> >> >   1 0x000140c31e80 in ffmpeg (+0xc31e7f) (0x00099840)
> >> >   2 0x00014003e6dd in ffmpeg (+0x3e6dc) (0x00099840)
> >> >   3 0x0001400364ba in ffmpeg (+0x364b9) (0x00099840)
> >> >   4 0x00014002f8b3 in ffmpeg (+0x2f8b2) (0x00099840)
> >> >   5 0x000140030355 in ffmpeg (+0x30354) (0x0032e4b0)
> >> >   6 0x00014000d478 in ffmpeg (+0xd477) (0x0001)
> >> >
> >>
> >> Yeah the compilation environment doesn't matter if Wine doesn't
> >> implement the function, so both mingw32 and mingw64 behave the same.
> >> I don't think (old) Wine is something we should worry too much about,
> >> considering you can just use native Linux builds, I doubt any real
> >> usage occurs for FFmpeg through Wine.
> >
> > Almost all windows testing i did over the years is through mingw + wine.
> > If that doesnt work anymore, then i cannot (easily) test windows anymore.
> >
> > Someone else should in this case do that testing in the future.
> > That means in practice, testing as many patches as possible and HEAD
> > bisecting found issues and reporting them to the developers whos commits
> > where the first to show an issue.
> >
> 
> Upgrading Wine is not an option? The wine project itself provides
> Ubuntu packages for 

Re: [FFmpeg-devel] [FFmpeg-cvslog] w32pthreads: always use Vista+ API, drop XP support

2018-01-02 Thread Hendrik Leppkes
On Tue, Jan 2, 2018 at 2:05 PM, Michael Niedermayer
 wrote:
> On Tue, Jan 02, 2018 at 10:36:44AM +0100, Hendrik Leppkes wrote:
>> On Tue, Jan 2, 2018 at 4:28 AM, Michael Niedermayer
>>  wrote:
>> > On Tue, Jan 02, 2018 at 03:58:14AM +0100, Michael Niedermayer wrote:
>> >> On Tue, Jan 02, 2018 at 03:55:18AM +0100, Michael Niedermayer wrote:
>> >> > On Tue, Dec 26, 2017 at 01:50:08AM +, wm4 wrote:
>> >> > > ffmpeg | branch: master | wm4  | Thu Dec 21 
>> >> > > 20:23:14 2017 +0100| [9b121dfc32810250938021952aab4172a988cb56] | 
>> >> > > committer: wm4
>> >> > >
>> >> > > w32pthreads: always use Vista+ API, drop XP support
>> >> > >
>> >> > > This removes the XP compatibility code, and switches entirely to SWR
>> >> > > locks, which are available starting at Windows Vista.
>> >> > >
>> >> > > This removes CRITICAL_SECTION use, which allows us to add
>> >> > > PTHREAD_MUTEX_INITIALIZER, which will be useful later.
>> >> > >
>> >> > > Windows XP is hereby not a supported build target anymore. It was
>> >> > > decided in a project vote that this is OK.
>> >> > >
>> >> > > > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b121dfc32810250938021952aab4172a988cb56
>> >> > > ---
>> >> > >
>> >> > >  Changelog  |   2 +
>> >> > >  compat/w32pthreads.h   | 266 
>> >> > > ++---
>> >> > >  configure  |  13 ++-
>> >> > >  libavcodec/pthread_frame.c |   4 -
>> >> > >  libavcodec/pthread_slice.c |   4 -
>> >> > >  libavfilter/pthread.c  |   4 -
>> >> > >  libavutil/slicethread.c|   4 -
>> >> > >  7 files changed, 19 insertions(+), 278 deletions(-)
>> >> >
>> >> > This breaks mingw32 / wine support on ubuntu 14.04
>> >> > the code simply crashes at runtime
>> >>
>> >> Heres what wine provides as debug info:
>> >>
>> >> Unhandled exception: unimplemented function 
>> >> KERNEL32.dll.InitializeConditionVariable called in 32-bit code 
>> >> (0x7bc4e590).
>> >
>> > and thats mingw64:
>> > Unhandled exception: unimplemented function 
>> > KERNEL32.dll.InitializeConditionVariable called in 64-bit code 
>> > (0x2ae6eb445e38).
>> > Register dump:
>> >  rip:2ae6eb445e38 rsp:0032e150 rbp:00099840 
>> > eflags:0206 (   - --  I   - -P- )
>> >  rax:2ae6eb445df0 rbx:0032e170 rcx:0032e170 
>> > rdx:000140c31e80
>> >  rsi:00014199182c rdi:000141992788  r8:000f  
>> > r9: r10:2ae6eb6dfd6f
>> >  r11:2ae6eb1ae510 r12: r13:000b4580 
>> > r14:7b8883b0 r15:0033
>> > Stack dump:
>> > 0x0032e150:  0032e170 7b888429
>> > 0x0032e160:  416e6f6974706972 4474654770616300
>> > 0x0032e170:  00018100 
>> > 0x0032e180:  2ae6eb445e38 0002
>> > 0x0032e190:  000141992788 00014199182c
>> > 0x0032e1a0:   
>> > 0x0032e1b0:   
>> > 0x0032e1c0:   
>> > 0x0032e1d0:   
>> > 0x0032e1e0:   
>> > 0x0032e1f0:   
>> > 0x0032e200:  000b44c0 000b44c0
>> > Backtrace:
>> > =>0 0x2ae6eb445e38 in ntdll (+0x35e38) (0x00099840)
>> >   1 0x000140c31e80 in ffmpeg (+0xc31e7f) (0x00099840)
>> >   2 0x00014003e6dd in ffmpeg (+0x3e6dc) (0x00099840)
>> >   3 0x0001400364ba in ffmpeg (+0x364b9) (0x00099840)
>> >   4 0x00014002f8b3 in ffmpeg (+0x2f8b2) (0x00099840)
>> >   5 0x000140030355 in ffmpeg (+0x30354) (0x0032e4b0)
>> >   6 0x00014000d478 in ffmpeg (+0xd477) (0x0001)
>> >
>>
>> Yeah the compilation environment doesn't matter if Wine doesn't
>> implement the function, so both mingw32 and mingw64 behave the same.
>> I don't think (old) Wine is something we should worry too much about,
>> considering you can just use native Linux builds, I doubt any real
>> usage occurs for FFmpeg through Wine.
>
> Almost all windows testing i did over the years is through mingw + wine.
> If that doesnt work anymore, then i cannot (easily) test windows anymore.
>
> Someone else should in this case do that testing in the future.
> That means in practice, testing as many patches as possible and HEAD
> bisecting found issues and reporting them to the developers whos commits
> where the first to show an issue.
>

Upgrading Wine is not an option? The wine project itself provides
Ubuntu packages for 14.04 as well, and even their "stable" version is
2.0, much newer then the 1.6 that ships with 14.04 by default.

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

Re: [FFmpeg-devel] [FFmpeg-cvslog] w32pthreads: always use Vista+ API, drop XP support

2018-01-02 Thread Michael Niedermayer
On Tue, Jan 02, 2018 at 10:36:44AM +0100, Hendrik Leppkes wrote:
> On Tue, Jan 2, 2018 at 4:28 AM, Michael Niedermayer
>  wrote:
> > On Tue, Jan 02, 2018 at 03:58:14AM +0100, Michael Niedermayer wrote:
> >> On Tue, Jan 02, 2018 at 03:55:18AM +0100, Michael Niedermayer wrote:
> >> > On Tue, Dec 26, 2017 at 01:50:08AM +, wm4 wrote:
> >> > > ffmpeg | branch: master | wm4  | Thu Dec 21 
> >> > > 20:23:14 2017 +0100| [9b121dfc32810250938021952aab4172a988cb56] | 
> >> > > committer: wm4
> >> > >
> >> > > w32pthreads: always use Vista+ API, drop XP support
> >> > >
> >> > > This removes the XP compatibility code, and switches entirely to SWR
> >> > > locks, which are available starting at Windows Vista.
> >> > >
> >> > > This removes CRITICAL_SECTION use, which allows us to add
> >> > > PTHREAD_MUTEX_INITIALIZER, which will be useful later.
> >> > >
> >> > > Windows XP is hereby not a supported build target anymore. It was
> >> > > decided in a project vote that this is OK.
> >> > >
> >> > > > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b121dfc32810250938021952aab4172a988cb56
> >> > > ---
> >> > >
> >> > >  Changelog  |   2 +
> >> > >  compat/w32pthreads.h   | 266 
> >> > > ++---
> >> > >  configure  |  13 ++-
> >> > >  libavcodec/pthread_frame.c |   4 -
> >> > >  libavcodec/pthread_slice.c |   4 -
> >> > >  libavfilter/pthread.c  |   4 -
> >> > >  libavutil/slicethread.c|   4 -
> >> > >  7 files changed, 19 insertions(+), 278 deletions(-)
> >> >
> >> > This breaks mingw32 / wine support on ubuntu 14.04
> >> > the code simply crashes at runtime
> >>
> >> Heres what wine provides as debug info:
> >>
> >> Unhandled exception: unimplemented function 
> >> KERNEL32.dll.InitializeConditionVariable called in 32-bit code 
> >> (0x7bc4e590).
> >
> > and thats mingw64:
> > Unhandled exception: unimplemented function 
> > KERNEL32.dll.InitializeConditionVariable called in 64-bit code 
> > (0x2ae6eb445e38).
> > Register dump:
> >  rip:2ae6eb445e38 rsp:0032e150 rbp:00099840 
> > eflags:0206 (   - --  I   - -P- )
> >  rax:2ae6eb445df0 rbx:0032e170 rcx:0032e170 
> > rdx:000140c31e80
> >  rsi:00014199182c rdi:000141992788  r8:000f  
> > r9: r10:2ae6eb6dfd6f
> >  r11:2ae6eb1ae510 r12: r13:000b4580 
> > r14:7b8883b0 r15:0033
> > Stack dump:
> > 0x0032e150:  0032e170 7b888429
> > 0x0032e160:  416e6f6974706972 4474654770616300
> > 0x0032e170:  00018100 
> > 0x0032e180:  2ae6eb445e38 0002
> > 0x0032e190:  000141992788 00014199182c
> > 0x0032e1a0:   
> > 0x0032e1b0:   
> > 0x0032e1c0:   
> > 0x0032e1d0:   
> > 0x0032e1e0:   
> > 0x0032e1f0:   
> > 0x0032e200:  000b44c0 000b44c0
> > Backtrace:
> > =>0 0x2ae6eb445e38 in ntdll (+0x35e38) (0x00099840)
> >   1 0x000140c31e80 in ffmpeg (+0xc31e7f) (0x00099840)
> >   2 0x00014003e6dd in ffmpeg (+0x3e6dc) (0x00099840)
> >   3 0x0001400364ba in ffmpeg (+0x364b9) (0x00099840)
> >   4 0x00014002f8b3 in ffmpeg (+0x2f8b2) (0x00099840)
> >   5 0x000140030355 in ffmpeg (+0x30354) (0x0032e4b0)
> >   6 0x00014000d478 in ffmpeg (+0xd477) (0x0001)
> >
> 
> Yeah the compilation environment doesn't matter if Wine doesn't
> implement the function, so both mingw32 and mingw64 behave the same.
> I don't think (old) Wine is something we should worry too much about,
> considering you can just use native Linux builds, I doubt any real
> usage occurs for FFmpeg through Wine.

Almost all windows testing i did over the years is through mingw + wine.
If that doesnt work anymore, then i cannot (easily) test windows anymore.

Someone else should in this case do that testing in the future.
That means in practice, testing as many patches as possible and HEAD
bisecting found issues and reporting them to the developers whos commits
where the first to show an issue.

Thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


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


Re: [FFmpeg-devel] [PATCH] lavc/qsvdec: hw device should be set

2018-01-02 Thread Mark Thompson
On 02/01/18 11:27, wm4 wrote:
> On Mon, 1 Jan 2018 23:35:42 +
> Mark Thompson  wrote:
> 
>> On 29/12/17 07:06, Zhong Li wrote:
>>> Add the flag "AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX" to indicate
>>> AVCodecContext.hw_device_ctx should be set before calling
>>> avcodec_open2() for qsv decoding.
>>> It is consistent with examples/qsvdec.c.
>>>
>>> It also can make function "hw_device_match_by_codec()" can find qsv
>>> device successfully.
>>>
>>> Signed-off-by: Zhong Li 
>>> ---
>>>  libavcodec/qsvdec.c | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
>>> index 55fe59b..ff1dcf1 100644
>>> --- a/libavcodec/qsvdec.c
>>> +++ b/libavcodec/qsvdec.c
>>> @@ -45,7 +45,8 @@ const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {
>>>  &(const AVCodecHWConfigInternal) {
>>>  .public = {
>>>  .pix_fmt = AV_PIX_FMT_QSV,
>>> -.methods = AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
>>> +.methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
>>> +   AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
>>> AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
>>>  .device_type = AV_HWDEVICE_TYPE_QSV,
>>>  },
>>>   
>>
>> Did you omit a patch implementing this?  The change here is only to the 
>> metadata, and it's not currently implemented.
> 
> Haven't looked too closely, but doesn't it do _something_ with it?

It's used to set the device used with software output (NV12/P010), which is 
orthogonal to the use with hardware output being shown here.  (It can be 
helpful when multiple instances (a decoder and an encoder, say) are going to 
use the same device but it can only be opened for exclusive access (e.g. the 
/dev/dri/cardN DRM master device on older Linux), but is usually unnecessary.)

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


Re: [FFmpeg-devel] [PATCH] lavc/qsvdec: hw device should be set

2018-01-02 Thread Mark Thompson
On 02/01/18 09:15, Li, Zhong wrote:
>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
>> Of Mark Thompson
>> Sent: Tuesday, January 2, 2018 7:36 AM
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: Re: [FFmpeg-devel] [PATCH] lavc/qsvdec: hw device should be set
>>
>> On 29/12/17 07:06, Zhong Li wrote:
>>> Add the flag "AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX" to
>> indicate
>>> AVCodecContext.hw_device_ctx should be set before calling
>>> avcodec_open2() for qsv decoding.
>>> It is consistent with examples/qsvdec.c.
>>>
>>> It also can make function "hw_device_match_by_codec()" can find qsv
>>> device successfully.
>>>
>>> Signed-off-by: Zhong Li 
>>> ---
>>>  libavcodec/qsvdec.c | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index
>>> 55fe59b..ff1dcf1 100644
>>> --- a/libavcodec/qsvdec.c
>>> +++ b/libavcodec/qsvdec.c
>>> @@ -45,7 +45,8 @@ const AVCodecHWConfigInternal
>> *ff_qsv_hw_configs[] = {
>>>  &(const AVCodecHWConfigInternal) {
>>>  .public = {
>>>  .pix_fmt = AV_PIX_FMT_QSV,
>>> -.methods =
>> AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
>>> +.methods =
>> AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
>>> +
>> AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
>>>
>> AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
>>>  .device_type = AV_HWDEVICE_TYPE_QSV,
>>>  },
>>>
>>
>> Did you omit a patch implementing this?  The change here is only to the
>> metadata, and it's not currently implemented.
> 
> Sorry maybe I omitted it, could you specify which patch? 

You sent one patch, which is just adding the HW_DEVICE_CTX method flag for 
AV_PIX_FMT_QSV output.  The feature itself is not implemented in current lavc, 
however, so applying it as-is would be wrong.  Hence I'm wondering if you 
forgot to send a patch before it which implements the feature first?

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


Re: [FFmpeg-devel] [PATCH] lavc/audiotoolboxenc: fix noise in encoded audio

2018-01-02 Thread Carl Eugen Hoyos
2018-01-02 8:52 GMT+01:00  :

> @@ -565,6 +579,10 @@ static av_cold int ffat_close_encoder(AVCodecContext 
> *avctx)
>  ff_bufqueue_discard_all(>frame_queue);
>  ff_bufqueue_discard_all(>used_frame_queue);
>  ff_af_queue_close(>afq);
> +if (at->audio_data_buf_size > 0) {
> +at->audio_data_buf_size = 0;
> +av_free(at->audio_data_buf);
> +}

The if() looks unnecessary.

Could you explain what this patch changes?
From a quick look, until now a buffer a was used with a calculated size x.
After the patch, a buffer b with the same calculated size x is allocated,
and x bytes are copied from a to b.
What do I miss?

Thank you, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavc/audiotoolboxenc: fix noise in encoded audio

2018-01-02 Thread Steven Liu
2018-01-02 16:59 GMT+08:00  :
> From: Jiejun Zhang 
>
> This fixes #6940
> ---
>  libavcodec/audiotoolboxenc.c | 34 +-
>  1 file changed, 29 insertions(+), 5 deletions(-)
>
> diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
> index 71885d1530..0c1e5feadc 100644
> --- a/libavcodec/audiotoolboxenc.c
> +++ b/libavcodec/audiotoolboxenc.c
> @@ -48,6 +48,9 @@ typedef struct ATDecodeContext {
>  AudioFrameQueue afq;
>  int eof;
>  int frame_size;
> +
> +uint8_t* audio_data_buf;
> +uint32_t audio_data_buf_size;
>  } ATDecodeContext;
>
>  static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile)
> @@ -442,6 +445,9 @@ static av_cold int ffat_init_encoder(AVCodecContext 
> *avctx)
>
>  ff_af_queue_init(avctx, >afq);
>
> +at->audio_data_buf_size = 0;
> +at->audio_data_buf = NULL;
> +
>  return 0;
>  }
>
> @@ -465,13 +471,27 @@ static OSStatus ffat_encode_callback(AudioConverterRef 
> converter, UInt32 *nb_pac
>  }
>
>  frame = ff_bufqueue_get(>frame_queue);
> -
> +int audio_data_size = frame->nb_samples *
> +  av_get_bytes_per_sample(avctx->sample_fmt) *
> +  avctx->channels;
> +if (at->audio_data_buf_size < audio_data_size) {
> +av_log(avctx, AV_LOG_INFO, "Increasing audio data buffer size to 
> %d\n",
> +   audio_data_size);
> +av_free(at->audio_data_buf);
> +at->audio_data_buf_size = audio_data_size;
> +at->audio_data_buf = av_malloc(at->audio_data_buf_size);
> +if (!at->audio_data_buf) {
> +at->audio_data_buf_size = 0;
> +data->mNumberBuffers = 0;
> +*nb_packets = 0;
> +return AVERROR(ENOMEM);
> +}
> +}
>  data->mNumberBuffers  = 1;
>  data->mBuffers[0].mNumberChannels = avctx->channels;
> -data->mBuffers[0].mDataByteSize   = frame->nb_samples *
> -
> av_get_bytes_per_sample(avctx->sample_fmt) *
> -avctx->channels;
> -data->mBuffers[0].mData   = frame->data[0];
> +data->mBuffers[0].mDataByteSize   = audio_data_size;
> +data->mBuffers[0].mData   = at->audio_data_buf;
> +memcpy(at->audio_data_buf, frame->data[0], 
> data->mBuffers[0].mDataByteSize);
>  if (*nb_packets > frame->nb_samples)
>  *nb_packets = frame->nb_samples;
>
> @@ -565,6 +585,10 @@ static av_cold int ffat_close_encoder(AVCodecContext 
> *avctx)
>  ff_bufqueue_discard_all(>frame_queue);
>  ff_bufqueue_discard_all(>used_frame_queue);
>  ff_af_queue_close(>afq);
> +if (at->audio_data_buf_size > 0) {
> +at->audio_data_buf_size = 0;
> +av_free(at->audio_data_buf);
> +}
>  return 0;
>  }


LGTM


Thanks

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


Re: [FFmpeg-devel] [PATCH] lavc/qsvdec: hw device should be set

2018-01-02 Thread wm4
On Mon, 1 Jan 2018 23:35:42 +
Mark Thompson  wrote:

> On 29/12/17 07:06, Zhong Li wrote:
> > Add the flag "AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX" to indicate
> > AVCodecContext.hw_device_ctx should be set before calling
> > avcodec_open2() for qsv decoding.
> > It is consistent with examples/qsvdec.c.
> > 
> > It also can make function "hw_device_match_by_codec()" can find qsv
> > device successfully.
> > 
> > Signed-off-by: Zhong Li 
> > ---
> >  libavcodec/qsvdec.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> > index 55fe59b..ff1dcf1 100644
> > --- a/libavcodec/qsvdec.c
> > +++ b/libavcodec/qsvdec.c
> > @@ -45,7 +45,8 @@ const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {
> >  &(const AVCodecHWConfigInternal) {
> >  .public = {
> >  .pix_fmt = AV_PIX_FMT_QSV,
> > -.methods = AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
> > +.methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
> > +   AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
> > AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
> >  .device_type = AV_HWDEVICE_TYPE_QSV,
> >  },
> >   
> 
> Did you omit a patch implementing this?  The change here is only to the 
> metadata, and it's not currently implemented.

Haven't looked too closely, but doesn't it do _something_ with it?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hls: fix seek accuracy problem

2018-01-02 Thread Steven Liu
2018-01-02 18:28 GMT+08:00  :
> From: Wu Zhiqiang 
>
> HLS demuxer seeking use dts instead of pts.
> Demuxer skip some frame when dts is before pts in special case.
> And it is impossible to re-seek back to start time after playing.
> ---
>  libavformat/hls.c | 18 ++
>  1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 950cc4c3bd..069e7b06e9 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -2086,6 +2086,7 @@ static int hls_read_packet(AVFormatContext *s, AVPacket 
> *pkt)
>   * stream */
>  if (pls->needed && !pls->pkt.data) {
>  while (1) {
> +int64_t pkt_ts;
>  int64_t ts_diff;
>  AVRational tb;
>  ret = av_read_frame(pls->ctx, >pkt);
> @@ -2101,9 +2102,17 @@ static int hls_read_packet(AVFormatContext *s, 
> AVPacket *pkt)
>  fill_timing_for_id3_timestamped_stream(pls);
>  }
>
> +if (pls->pkt.pts != AV_NOPTS_VALUE)
> +pkt_ts =  pls->pkt.pts;
> +else if (pls->pkt.dts != AV_NOPTS_VALUE)
> +pkt_ts =  pls->pkt.dts;
> +else
> +pkt_ts = AV_NOPTS_VALUE;
> +
> +
>  if (c->first_timestamp == AV_NOPTS_VALUE &&
> -pls->pkt.dts   != AV_NOPTS_VALUE)
> -c->first_timestamp = av_rescale_q(pls->pkt.dts,
> +pkt_ts   != AV_NOPTS_VALUE)
> +c->first_timestamp = av_rescale_q(pkt_ts,
>  get_timebase(pls), AV_TIME_BASE_Q);
>  }
>
> @@ -2113,15 +2122,16 @@ static int hls_read_packet(AVFormatContext *s, 
> AVPacket *pkt)
>  if (pls->seek_stream_index < 0 ||
>  pls->seek_stream_index == pls->pkt.stream_index) {
>
> -if (pls->pkt.dts == AV_NOPTS_VALUE) {
> +if (pkt_ts == AV_NOPTS_VALUE) {
>  pls->seek_timestamp = AV_NOPTS_VALUE;
>  break;
>  }
>
>  tb = get_timebase(pls);
> -ts_diff = av_rescale_rnd(pls->pkt.dts, AV_TIME_BASE,
> +ts_diff = av_rescale_rnd(pkt_ts, AV_TIME_BASE,
>  tb.den, AV_ROUND_DOWN) -
>  pls->seek_timestamp;
> +
>  if (ts_diff >= 0 && (pls->seek_flags  & AVSEEK_FLAG_ANY 
> ||
>  pls->pkt.flags & AV_PKT_FLAG_KEY)) {
>  pls->seek_timestamp = AV_NOPTS_VALUE;
> --
> 2.15.0
>


LGTM , This patch can fix ticket : https://trac.ffmpeg.org/ticket/6850


Thanks

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


[FFmpeg-devel] [PATCH] avformat/hls: fix seek accuracy problem

2018-01-02 Thread mymoeyard
From: Wu Zhiqiang 

HLS demuxer seeking use dts instead of pts.
Demuxer skip some frame when dts is before pts in special case.
And it is impossible to re-seek back to start time after playing.
---
 libavformat/hls.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 950cc4c3bd..069e7b06e9 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -2086,6 +2086,7 @@ static int hls_read_packet(AVFormatContext *s, AVPacket 
*pkt)
  * stream */
 if (pls->needed && !pls->pkt.data) {
 while (1) {
+int64_t pkt_ts;
 int64_t ts_diff;
 AVRational tb;
 ret = av_read_frame(pls->ctx, >pkt);
@@ -2101,9 +2102,17 @@ static int hls_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 fill_timing_for_id3_timestamped_stream(pls);
 }
 
+if (pls->pkt.pts != AV_NOPTS_VALUE)
+pkt_ts =  pls->pkt.pts;
+else if (pls->pkt.dts != AV_NOPTS_VALUE)
+pkt_ts =  pls->pkt.dts;
+else
+pkt_ts = AV_NOPTS_VALUE;
+
+
 if (c->first_timestamp == AV_NOPTS_VALUE &&
-pls->pkt.dts   != AV_NOPTS_VALUE)
-c->first_timestamp = av_rescale_q(pls->pkt.dts,
+pkt_ts   != AV_NOPTS_VALUE)
+c->first_timestamp = av_rescale_q(pkt_ts,
 get_timebase(pls), AV_TIME_BASE_Q);
 }
 
@@ -2113,15 +2122,16 @@ static int hls_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 if (pls->seek_stream_index < 0 ||
 pls->seek_stream_index == pls->pkt.stream_index) {
 
-if (pls->pkt.dts == AV_NOPTS_VALUE) {
+if (pkt_ts == AV_NOPTS_VALUE) {
 pls->seek_timestamp = AV_NOPTS_VALUE;
 break;
 }
 
 tb = get_timebase(pls);
-ts_diff = av_rescale_rnd(pls->pkt.dts, AV_TIME_BASE,
+ts_diff = av_rescale_rnd(pkt_ts, AV_TIME_BASE,
 tb.den, AV_ROUND_DOWN) -
 pls->seek_timestamp;
+
 if (ts_diff >= 0 && (pls->seek_flags  & AVSEEK_FLAG_ANY ||
 pls->pkt.flags & AV_PKT_FLAG_KEY)) {
 pls->seek_timestamp = AV_NOPTS_VALUE;
-- 
2.15.0

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


Re: [FFmpeg-devel] [FFmpeg-cvslog] w32pthreads: always use Vista+ API, drop XP support

2018-01-02 Thread Hendrik Leppkes
On Tue, Jan 2, 2018 at 10:47 AM, Nicolas George  wrote:
> Hendrik Leppkes (2018-01-02):
>> I don't think (old) Wine is something we should worry too much about,
>> considering you can just use native Linux builds, I doubt any real
>> usage occurs for FFmpeg through Wine.
>
> What about proprietary applications that use FFmpeg (either by calling
> the executable or with dynamic linking according to the terms of the
> LGPL (let's believe it exists))?
>

Then they can probably upgrade Wine? 14.04 comes with Wine 1.6 from
2013, its quite old.
In fact, InitializeConditionVariable was implemented in Wine 1.7.11,
so not even too far in the future from 1.6

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


Re: [FFmpeg-devel] [PATCH 3/8] decklink: Introduce support for capture of multiple audio streams

2018-01-02 Thread Matthias Hunstock
Am 29.12.2017 um 19:12 schrieb Devin Heitmueller:
> To support the existing use case where multi-channel audio can be
> captured (i.e. 7.1)

Just to be clear, the current use case is NOT to capture multi-channel
audio like 7.1. It's just to capture all of the mono SDI channels into
one FFmpeg-internal audio stream and FFmpeg calls 8 channels "7.1".

As you already noticed, the audio mapping is far from standardized and
has to be adapted anyway in most use cases... having said that, I find
the option value "discrete" misleading. I would expect every channel to
be in a separate stream when reading that, but I'm not a native english
speaker. What about e.g. "bundled"?

Last but not least, I cannot find an update to the documentation in this
patch ;)

Regards
Matthias

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


Re: [FFmpeg-devel] [FFmpeg-cvslog] w32pthreads: always use Vista+ API, drop XP support

2018-01-02 Thread Nicolas George
Hendrik Leppkes (2018-01-02):
> I don't think (old) Wine is something we should worry too much about,
> considering you can just use native Linux builds, I doubt any real
> usage occurs for FFmpeg through Wine.

What about proprietary applications that use FFmpeg (either by calling
the executable or with dynamic linking according to the terms of the
LGPL (let's believe it exists))?

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] [FFmpeg-cvslog] w32pthreads: always use Vista+ API, drop XP support

2018-01-02 Thread Hendrik Leppkes
On Tue, Jan 2, 2018 at 4:28 AM, Michael Niedermayer
 wrote:
> On Tue, Jan 02, 2018 at 03:58:14AM +0100, Michael Niedermayer wrote:
>> On Tue, Jan 02, 2018 at 03:55:18AM +0100, Michael Niedermayer wrote:
>> > On Tue, Dec 26, 2017 at 01:50:08AM +, wm4 wrote:
>> > > ffmpeg | branch: master | wm4  | Thu Dec 21 
>> > > 20:23:14 2017 +0100| [9b121dfc32810250938021952aab4172a988cb56] | 
>> > > committer: wm4
>> > >
>> > > w32pthreads: always use Vista+ API, drop XP support
>> > >
>> > > This removes the XP compatibility code, and switches entirely to SWR
>> > > locks, which are available starting at Windows Vista.
>> > >
>> > > This removes CRITICAL_SECTION use, which allows us to add
>> > > PTHREAD_MUTEX_INITIALIZER, which will be useful later.
>> > >
>> > > Windows XP is hereby not a supported build target anymore. It was
>> > > decided in a project vote that this is OK.
>> > >
>> > > > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b121dfc32810250938021952aab4172a988cb56
>> > > ---
>> > >
>> > >  Changelog  |   2 +
>> > >  compat/w32pthreads.h   | 266 
>> > > ++---
>> > >  configure  |  13 ++-
>> > >  libavcodec/pthread_frame.c |   4 -
>> > >  libavcodec/pthread_slice.c |   4 -
>> > >  libavfilter/pthread.c  |   4 -
>> > >  libavutil/slicethread.c|   4 -
>> > >  7 files changed, 19 insertions(+), 278 deletions(-)
>> >
>> > This breaks mingw32 / wine support on ubuntu 14.04
>> > the code simply crashes at runtime
>>
>> Heres what wine provides as debug info:
>>
>> Unhandled exception: unimplemented function 
>> KERNEL32.dll.InitializeConditionVariable called in 32-bit code (0x7bc4e590).
>
> and thats mingw64:
> Unhandled exception: unimplemented function 
> KERNEL32.dll.InitializeConditionVariable called in 64-bit code 
> (0x2ae6eb445e38).
> Register dump:
>  rip:2ae6eb445e38 rsp:0032e150 rbp:00099840 
> eflags:0206 (   - --  I   - -P- )
>  rax:2ae6eb445df0 rbx:0032e170 rcx:0032e170 
> rdx:000140c31e80
>  rsi:00014199182c rdi:000141992788  r8:000f  
> r9: r10:2ae6eb6dfd6f
>  r11:2ae6eb1ae510 r12: r13:000b4580 
> r14:7b8883b0 r15:0033
> Stack dump:
> 0x0032e150:  0032e170 7b888429
> 0x0032e160:  416e6f6974706972 4474654770616300
> 0x0032e170:  00018100 
> 0x0032e180:  2ae6eb445e38 0002
> 0x0032e190:  000141992788 00014199182c
> 0x0032e1a0:   
> 0x0032e1b0:   
> 0x0032e1c0:   
> 0x0032e1d0:   
> 0x0032e1e0:   
> 0x0032e1f0:   
> 0x0032e200:  000b44c0 000b44c0
> Backtrace:
> =>0 0x2ae6eb445e38 in ntdll (+0x35e38) (0x00099840)
>   1 0x000140c31e80 in ffmpeg (+0xc31e7f) (0x00099840)
>   2 0x00014003e6dd in ffmpeg (+0x3e6dc) (0x00099840)
>   3 0x0001400364ba in ffmpeg (+0x364b9) (0x00099840)
>   4 0x00014002f8b3 in ffmpeg (+0x2f8b2) (0x00099840)
>   5 0x000140030355 in ffmpeg (+0x30354) (0x0032e4b0)
>   6 0x00014000d478 in ffmpeg (+0xd477) (0x0001)
>

Yeah the compilation environment doesn't matter if Wine doesn't
implement the function, so both mingw32 and mingw64 behave the same.
I don't think (old) Wine is something we should worry too much about,
considering you can just use native Linux builds, I doubt any real
usage occurs for FFmpeg through Wine.

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


Re: [FFmpeg-devel] [PATCH] Add android_capture indev

2018-01-02 Thread Felix Matouschek


> Am 28.12.2017 um 19:20 schrieb Michael Niedermayer :
>> 
>> +av_image_copy_to_buffer(pkt.data, pkt_buffer_size,
>> +(const uint8_t * const *) image_plane_data,
>> +image_linestrides, ctx->image_format,
>> +ctx->width, ctx->height, 32);
> 
> Is the copy needed ?
> can the data not be put in a AVPacket without copy but by pointing to the 
> image?
> the AVPackets deallocation can be overridden to free the image 

I’m not sure but I guess it could lead to problems as the AImageReader has its 
own queue, which is currently limited to two images. In general the 
image_available callback is processed fast enough so this is not a problem and 
all AVPackets are buffered in the thread message queue (ctx->input_queue) while 
the original AImage is deleted. Every AImage is also permanently associated 
with the AImageReader and needs to be deleted for the AImageReader to accept 
new images. I think if doing so the input_queue and the AImageReader queue 
probably need the same size. 

How could I put the different pointers I get from the Android system for each 
plane into the AVPacket? I’m not even sure if all planes live in the same 
contiguous space of memory? How does one overwrite the AVPacket deallocation?

Currently I’m using AImageReader_acquireLatestImage(), this should be changed 
to AImageReader_acquireNextImage(), other than that it could work.

Felix

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


Re: [FFmpeg-devel] [PATCH] lavc/qsvdec: hw device should be set

2018-01-02 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Tuesday, January 2, 2018 7:36 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] lavc/qsvdec: hw device should be set
> 
> On 29/12/17 07:06, Zhong Li wrote:
> > Add the flag "AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX" to
> indicate
> > AVCodecContext.hw_device_ctx should be set before calling
> > avcodec_open2() for qsv decoding.
> > It is consistent with examples/qsvdec.c.
> >
> > It also can make function "hw_device_match_by_codec()" can find qsv
> > device successfully.
> >
> > Signed-off-by: Zhong Li 
> > ---
> >  libavcodec/qsvdec.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index
> > 55fe59b..ff1dcf1 100644
> > --- a/libavcodec/qsvdec.c
> > +++ b/libavcodec/qsvdec.c
> > @@ -45,7 +45,8 @@ const AVCodecHWConfigInternal
> *ff_qsv_hw_configs[] = {
> >  &(const AVCodecHWConfigInternal) {
> >  .public = {
> >  .pix_fmt = AV_PIX_FMT_QSV,
> > -.methods =
> AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
> > +.methods =
> AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
> > +
> AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
> >
> AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
> >  .device_type = AV_HWDEVICE_TYPE_QSV,
> >  },
> >
> 
> Did you omit a patch implementing this?  The change here is only to the
> metadata, and it's not currently implemented.

Sorry maybe I omitted it, could you specify which patch? 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavc/audiotoolboxenc: fix noise in encoded audio

2018-01-02 Thread zhangjiejun1992
From: Jiejun Zhang 

This fixes #6940
---
 libavcodec/audiotoolboxenc.c | 34 +-
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
index 71885d1530..0c1e5feadc 100644
--- a/libavcodec/audiotoolboxenc.c
+++ b/libavcodec/audiotoolboxenc.c
@@ -48,6 +48,9 @@ typedef struct ATDecodeContext {
 AudioFrameQueue afq;
 int eof;
 int frame_size;
+
+uint8_t* audio_data_buf;
+uint32_t audio_data_buf_size;
 } ATDecodeContext;
 
 static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile)
@@ -442,6 +445,9 @@ static av_cold int ffat_init_encoder(AVCodecContext *avctx)
 
 ff_af_queue_init(avctx, >afq);
 
+at->audio_data_buf_size = 0;
+at->audio_data_buf = NULL;
+
 return 0;
 }
 
@@ -465,13 +471,27 @@ static OSStatus ffat_encode_callback(AudioConverterRef 
converter, UInt32 *nb_pac
 }
 
 frame = ff_bufqueue_get(>frame_queue);
-
+int audio_data_size = frame->nb_samples *
+  av_get_bytes_per_sample(avctx->sample_fmt) *
+  avctx->channels;
+if (at->audio_data_buf_size < audio_data_size) {
+av_log(avctx, AV_LOG_INFO, "Increasing audio data buffer size to %d\n",
+   audio_data_size);
+av_free(at->audio_data_buf);
+at->audio_data_buf_size = audio_data_size;
+at->audio_data_buf = av_malloc(at->audio_data_buf_size);
+if (!at->audio_data_buf) {
+at->audio_data_buf_size = 0;
+data->mNumberBuffers = 0;
+*nb_packets = 0;
+return AVERROR(ENOMEM);
+}
+}
 data->mNumberBuffers  = 1;
 data->mBuffers[0].mNumberChannels = avctx->channels;
-data->mBuffers[0].mDataByteSize   = frame->nb_samples *
-
av_get_bytes_per_sample(avctx->sample_fmt) *
-avctx->channels;
-data->mBuffers[0].mData   = frame->data[0];
+data->mBuffers[0].mDataByteSize   = audio_data_size;
+data->mBuffers[0].mData   = at->audio_data_buf;
+memcpy(at->audio_data_buf, frame->data[0], 
data->mBuffers[0].mDataByteSize);
 if (*nb_packets > frame->nb_samples)
 *nb_packets = frame->nb_samples;
 
@@ -565,6 +585,10 @@ static av_cold int ffat_close_encoder(AVCodecContext 
*avctx)
 ff_bufqueue_discard_all(>frame_queue);
 ff_bufqueue_discard_all(>used_frame_queue);
 ff_af_queue_close(>afq);
+if (at->audio_data_buf_size > 0) {
+at->audio_data_buf_size = 0;
+av_free(at->audio_data_buf);
+}
 return 0;
 }
 
-- 
2.14.3 (Apple Git-98)

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


[FFmpeg-devel] [PATCH] avformat/aiffdec: AIFF fix in case of ANNO

2018-01-02 Thread endushka
From: Author Name 

Apple's AIFF protocol clearly states that each chucnk which is odd sized a 
padding should be added.
In the old version of aiffdec adding of padding was done in `get_meta`. And in 
case of unknown chunk name it was done in defalut case.
The new version has deleted the padding in default case and added padding 
adding after the switch.
But the new version didn't removed the padding adding in the `get_meta` 
function so in some cases padding was added twice which leaded to a bug.
---
 libavformat/aiffdec.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
index 99e05c7..20decc5 100644
--- a/libavformat/aiffdec.c
+++ b/libavformat/aiffdec.c
@@ -81,11 +81,10 @@ static void get_meta(AVFormatContext *s, const char *key, 
int size)
 av_free(str);
 return;
 }
-size += (size&1)-res;
+size -= res;
 str[res] = 0;
 av_dict_set(>metadata, key, str, AV_DICT_DONT_STRDUP_VAL);
-}else
-size+= size&1;
+}
 
 avio_skip(s->pb, size);
 }
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH 1/2] avformat/dashenc: Fix a resource leak when http persistent in enabled

2018-01-02 Thread Jeyapal, Karthick



On 1/2/18 1:41 PM, 刘歧 wrote:
>
>> On 2 Jan 2018, at 14:48, Karthick J  wrote:
>>
>> From: Karthick Jeyapal 
>>
>> ---
>> libavformat/dashenc.c | 11 +++
>> 1 file changed, 11 insertions(+)
>>
>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
>> index 3345b89..c4c112b 100644
>> --- a/libavformat/dashenc.c
>> +++ b/libavformat/dashenc.c
>> @@ -1,6 +1,7 @@
>> /*
>>  * MPEG-DASH ISO BMFF segmenter
>>  * Copyright (c) 2014 Martin Storsjo
>> + * Copyright (c) 2018 Akamai Technologies, Inc.
>>  *
>>  * This file is part of FFmpeg.
>>  *
>> @@ -1317,6 +1318,16 @@ static int dash_write_trailer(AVFormatContext *s)
>> }
>> dash_flush(s, 1, -1);
>>
>> +if (c->http_persistent) {
>> +int i;
>> +for (i = 0; i < s->nb_streams; i++) {
>> +OutputStream *os = >streams[i];
>> +ff_format_io_close(s, >out);
>> +}
>> +ff_format_io_close(s, >mpd_out);
>> +ff_format_io_close(s, >m3u8_out);
>> +}
>> +
>> if (c->remove_at_exit) {
>> char filename[1024];
>> int i;
>> -- 
>> 1.9.1
>>
>
> LGTM
Thanks. 
But I overlooked the presence dash_free function in this patch.
I have sent a new patch v2, which I think looks better than this. What do you 
think?
Sorry for any inconvenience caused. 
>
> Thanks
>
> Steven
>
>
>


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


[FFmpeg-devel] [PATCH v2 1/2] avformat/dashenc: Fix a resource leak when http persistent in enabled

2018-01-02 Thread Karthick J
From: Karthick Jeyapal 

---
 libavformat/dashenc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 3345b89..2e4ff67 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1,6 +1,7 @@
 /*
  * MPEG-DASH ISO BMFF segmenter
  * Copyright (c) 2014 Martin Storsjo
+ * Copyright (c) 2018 Akamai Technologies, Inc.
  *
  * This file is part of FFmpeg.
  *
@@ -309,6 +310,9 @@ static void dash_free(AVFormatContext *s)
 av_free(os->segments);
 }
 av_freep(>streams);
+
+ff_format_io_close(s, >mpd_out);
+ff_format_io_close(s, >m3u8_out);
 }
 
 static void output_segment_list(OutputStream *os, AVIOContext *out, 
AVFormatContext *s,
-- 
1.9.1

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


[FFmpeg-devel] [PATCH v2 2/2] avformat/dashenc: Signal http end of chunk(http_shutdown) explicitly

2018-01-02 Thread Karthick J
From: Karthick Jeyapal 

Currently http end of chunk is signalled implicitly in dashenc_io_open().
This mean playlists http writes would have to wait upto a segment duration to 
signal end of chunk causing delays.
This patch will fix that problem and improve performance.
---
 libavformat/dashenc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 2e4ff67..c9cc389 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -149,7 +149,10 @@ static void dashenc_io_close(AVFormatContext *s, 
AVIOContext **pb, char *filenam
 ff_format_io_close(s, pb);
 #if CONFIG_HTTP_PROTOCOL
 } else {
+URLContext *http_url_context = ffio_geturlcontext(*pb);
+av_assert0(http_url_context);
 avio_flush(*pb);
+ffurl_shutdown(http_url_context, AVIO_FLAG_WRITE);
 #endif
 }
 }
-- 
1.9.1

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


[FFmpeg-devel] [PATCH] avformat/aiffdec: AIFF fix in case of ANNO

2018-01-02 Thread endushka
From: Author Name 

Apple's AIFF protocol clearly states that each chucnk which is odd sized a 
padding should be added.
In the old version of aiffdec adding of padding was done in `get_meta`. And in 
case of unknown chunk name it was done in defalut case.
The new version has deleted the padding in default case and added padding 
adding after the switch.
But the new version didn't removed the padding adding in the `get_meta` 
function so in some cases padding was added twice which leaded to a bug.
---
 libavformat/aiffdec.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c
index 99e05c7..20decc5 100644
--- a/libavformat/aiffdec.c
+++ b/libavformat/aiffdec.c
@@ -81,11 +81,10 @@ static void get_meta(AVFormatContext *s, const char *key, 
int size)
 av_free(str);
 return;
 }
-size += (size&1)-res;
+size -= res;
 str[res] = 0;
 av_dict_set(>metadata, key, str, AV_DICT_DONT_STRDUP_VAL);
-}else
-size+= size&1;
+}
 
 avio_skip(s->pb, size);
 }
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH 1/2] avformat/dashenc: Fix a resource leak when http persistent in enabled

2018-01-02 Thread 刘歧

> On 2 Jan 2018, at 14:48, Karthick J  wrote:
> 
> From: Karthick Jeyapal 
> 
> ---
> libavformat/dashenc.c | 11 +++
> 1 file changed, 11 insertions(+)
> 
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 3345b89..c4c112b 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -1,6 +1,7 @@
> /*
>  * MPEG-DASH ISO BMFF segmenter
>  * Copyright (c) 2014 Martin Storsjo
> + * Copyright (c) 2018 Akamai Technologies, Inc.
>  *
>  * This file is part of FFmpeg.
>  *
> @@ -1317,6 +1318,16 @@ static int dash_write_trailer(AVFormatContext *s)
> }
> dash_flush(s, 1, -1);
> 
> +if (c->http_persistent) {
> +int i;
> +for (i = 0; i < s->nb_streams; i++) {
> +OutputStream *os = >streams[i];
> +ff_format_io_close(s, >out);
> +}
> +ff_format_io_close(s, >mpd_out);
> +ff_format_io_close(s, >m3u8_out);
> +}
> +
> if (c->remove_at_exit) {
> char filename[1024];
> int i;
> -- 
> 1.9.1
> 

LGTM

Thanks

Steven



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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/dashenc: Signal http end of chunk(http_shutdown) explicitly

2018-01-02 Thread 刘歧

> On 2 Jan 2018, at 14:48, Karthick J  wrote:
> 
> From: Karthick Jeyapal 
> 
> Currently http end of chunk is signalled implicitly in dashenc_io_open().
> This mean playlists http writes would have to wait upto a segment duration to 
> signal end of chunk causing delays.
> This patch will fix that problem and improve performance.
> ---
> libavformat/dashenc.c | 3 +++
> 1 file changed, 3 insertions(+)
> 
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index c4c112b..c328db2 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -149,7 +149,10 @@ static void dashenc_io_close(AVFormatContext *s, 
> AVIOContext **pb, char *filenam
> ff_format_io_close(s, pb);
> #if CONFIG_HTTP_PROTOCOL
> } else {
> +URLContext *http_url_context = ffio_geturlcontext(*pb);
> +av_assert0(http_url_context);
> avio_flush(*pb);
> +ffurl_shutdown(http_url_context, AVIO_FLAG_WRITE);
> #endif
> }
> }
> -- 
> 1.9.1
> 


LGTM

Thanks
Steven

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


Re: [FFmpeg-devel] [PATCH] lavc/audiotoolboxenc: fix noise in encoded audio

2018-01-02 Thread Steven Liu
2018-01-02 15:52 GMT+08:00  :
> From: Jiejun Zhang 
>
> This fixes #6940
> ---
>  libavcodec/audiotoolboxenc.c | 20 +++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c
> index 71885d1530..b70375a692 100644
> --- a/libavcodec/audiotoolboxenc.c
> +++ b/libavcodec/audiotoolboxenc.c
> @@ -48,6 +48,9 @@ typedef struct ATDecodeContext {
>  AudioFrameQueue afq;
>  int eof;
>  int frame_size;
> +
> +uint8_t* audio_data_buf;
> +uint32_t audio_data_buf_size;
>  } ATDecodeContext;
>
>  static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile)
> @@ -442,6 +445,9 @@ static av_cold int ffat_init_encoder(AVCodecContext 
> *avctx)
>
>  ff_af_queue_init(avctx, >afq);
>
> +at->audio_data_buf_size = 0;
> +at->audio_data_buf = NULL;
> +
>  return 0;
>  }
>
> @@ -471,7 +477,15 @@ static OSStatus ffat_encode_callback(AudioConverterRef 
> converter, UInt32 *nb_pac
>  data->mBuffers[0].mDataByteSize   = frame->nb_samples *
>  
> av_get_bytes_per_sample(avctx->sample_fmt) *
>  avctx->channels;
> -data->mBuffers[0].mData   = frame->data[0];
> +if (at->audio_data_buf_size < data->mBuffers[0].mDataByteSize) {
> +av_log(avctx, AV_LOG_INFO, "Increasing audio data buffer size to %u",
> +   data->mBuffers[0].mDataByteSize);
> +av_free(at->audio_data_buf);
> +at->audio_data_buf_size = data->mBuffers[0].mDataByteSize;
> +at->audio_data_buf = av_malloc(at->audio_data_buf_size);
Need check the av_malloc result here.

> +}
> +memcpy(at->audio_data_buf, frame->data[0], 
> data->mBuffers[0].mDataByteSize);
> +data->mBuffers[0].mData   = at->audio_data_buf;
>  if (*nb_packets > frame->nb_samples)
>  *nb_packets = frame->nb_samples;
>
> @@ -565,6 +579,10 @@ static av_cold int ffat_close_encoder(AVCodecContext 
> *avctx)
>  ff_bufqueue_discard_all(>frame_queue);
>  ff_bufqueue_discard_all(>used_frame_queue);
>  ff_af_queue_close(>afq);
> +if (at->audio_data_buf_size > 0) {
> +at->audio_data_buf_size = 0;
> +av_free(at->audio_data_buf);
> +}
>  return 0;
>  }
>
> --
> 2.14.3 (Apple Git-98)
>


Thanks

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