Re: [FFmpeg-devel] [PATCH] lavformat/utils: Fix a memleak that st->codec->hw_frames_ctx
On Fri, 20 Jan 2017 10:06:50 +0800 "Huang, Zhengxu" wrote: > From 9ceb2ac6a89246f2e686eb3ad3448fbaff5328f7 Mon Sep 17 00:00:00 2001 > From: Zhengxu > Date: Fri, 13 Jan 2017 10:33:05 +0800 > Subject: [PATCH] lavformat/utils: Fix a memleak that st->codec->hw_frames_ctx > is not released. > > Signed-off-by: ChaoX A Liu > Signed-off-by: Huang, Zhengxu > Signed-off-by: Andrew, Zhang > --- > libavformat/utils.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/libavformat/utils.c b/libavformat/utils.c > index d5dfca7..cadec15 100644 > --- a/libavformat/utils.c > +++ b/libavformat/utils.c > @@ -4127,6 +4127,7 @@ static void free_stream(AVStream **pst) > FF_DISABLE_DEPRECATION_WARNINGS > av_freep(&st->codec->extradata); > av_freep(&st->codec->subtitle_header); > +av_buffer_unref(&st->codec->hw_frames_ctx); > av_freep(&st->codec); > FF_ENABLE_DEPRECATION_WARNINGS > #endif What triggers this? In a sane world this should never ever happen. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] dcaenc: use Huffman codes for Bit Allocation Index
Hi. My previous patch introduced Huffman for quantized data, this patch allows to use Huffman for bit allocation indexes (abits). This is a less significant improvement but still noticeable in case of limited bitrate. In case of DIN_45403 input sample I got: before: Best PSNR is 44.47 for shift 0 after: Best PSNR is 46.64 for shift 0 Thank you. -- Daniil Cherednik 0001-dcaenc-Use-Huffman-codes-for-Bit-Allocation-Index.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavformat/utils: Fix a memleak that st->codec->hw_frames_ctx
Have you ever used valgrind? Please just run the command below: valgrind --leak-check=full --log-file=out.log ffmpeg -hwaccel qsv -qsv_device /dev/dri/renderD128 -c:v h264_qsv -i a.h264 -c:v h264_qsv -b:v 2M -y out.h264 See line 3323 of ffmpeg.c, ret = avcodec_copy_context(ost->st->codec, ost->enc_ctx); and see what have been done in avcodec_copy_context: if (src->hw_frames_ctx) { dest->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx); if (!dest->hw_frames_ctx) goto fail; } However, that is not freed when calling avformat_free_context. On Fri, Jan 20, 2017 at 4:47 PM, wm4 wrote: > On Fri, 20 Jan 2017 10:06:50 +0800 > "Huang, Zhengxu" wrote: > > > From 9ceb2ac6a89246f2e686eb3ad3448fbaff5328f7 Mon Sep 17 00:00:00 2001 > > From: Zhengxu > > Date: Fri, 13 Jan 2017 10:33:05 +0800 > > Subject: [PATCH] lavformat/utils: Fix a memleak that > st->codec->hw_frames_ctx > > is not released. > > > > Signed-off-by: ChaoX A Liu > > Signed-off-by: Huang, Zhengxu > > Signed-off-by: Andrew, Zhang > > --- > > libavformat/utils.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/libavformat/utils.c b/libavformat/utils.c > > index d5dfca7..cadec15 100644 > > --- a/libavformat/utils.c > > +++ b/libavformat/utils.c > > @@ -4127,6 +4127,7 @@ static void free_stream(AVStream **pst) > > FF_DISABLE_DEPRECATION_WARNINGS > > av_freep(&st->codec->extradata); > > av_freep(&st->codec->subtitle_header); > > +av_buffer_unref(&st->codec->hw_frames_ctx); > > av_freep(&st->codec); > > FF_ENABLE_DEPRECATION_WARNINGS > > #endif > > What triggers this? In a sane world this should never ever happen. > ___ > 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] [PATCH] ffmpeg_qsv.c: Init an hwframes_context for decoder instead of encoder
From 2149f87637ab941be14828f7ae2c224908784c7d Mon Sep 17 00:00:00 2001 From: Zhengxu Date: Wed, 4 Jan 2017 16:43:43 +0800 Subject: [PATCH] ffmpeg_qsv.c: Init an hwframes_context for decoder instead of encoder. We consider that encoder is the last stage in the pipeline. Thinking about filters, they get hwframes_context from their inputs. Likewise, encoder should get hwframes_context from its input instead creating a new faker one. Encoder can get acuurate parameters by doing so. Signed-off-by: ChaoX A Liu Signed-off-by: Huang, Zhengxu Signed-off-by: Andrew, Zhang --- ffmpeg_qsv.c | 95 +++- 1 file changed, 43 insertions(+), 52 deletions(-) diff --git a/ffmpeg_qsv.c b/ffmpeg_qsv.c index 86824b6..8cedb7e 100644 --- a/ffmpeg_qsv.c +++ b/ffmpeg_qsv.c @@ -81,25 +81,26 @@ int qsv_init(AVCodecContext *s) return ret; } -av_buffer_unref(&ist->hw_frames_ctx); -ist->hw_frames_ctx = av_hwframe_ctx_alloc(hw_device_ctx); -if (!ist->hw_frames_ctx) -return AVERROR(ENOMEM); - -frames_ctx = (AVHWFramesContext*)ist->hw_frames_ctx->data; -frames_hwctx = frames_ctx->hwctx; - -frames_ctx->width = FFALIGN(s->coded_width, 32); -frames_ctx->height= FFALIGN(s->coded_height, 32); -frames_ctx->format= AV_PIX_FMT_QSV; -frames_ctx->sw_format = s->sw_pix_fmt; -frames_ctx->initial_pool_size = 64; -frames_hwctx->frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET; - -ret = av_hwframe_ctx_init(ist->hw_frames_ctx); -if (ret < 0) { -av_log(NULL, AV_LOG_ERROR, "Error initializing a QSV frame pool\n"); -return ret; +if(!ist->hw_frames_ctx) { +ist->hw_frames_ctx = av_hwframe_ctx_alloc(hw_device_ctx); +if (!ist->hw_frames_ctx) +return AVERROR(ENOMEM); + +frames_ctx = (AVHWFramesContext*)ist->hw_frames_ctx->data; +frames_hwctx = frames_ctx->hwctx; + +frames_ctx->width = FFALIGN(s->coded_width, 32); +frames_ctx->height= FFALIGN(s->coded_height, 32); +frames_ctx->format= AV_PIX_FMT_QSV; +frames_ctx->sw_format = s->sw_pix_fmt; +frames_ctx->initial_pool_size = 64; +frames_hwctx->frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET; + +ret = av_hwframe_ctx_init(ist->hw_frames_ctx); +if (ret < 0) { +av_log(NULL, AV_LOG_ERROR, "Error initializing a QSV frame pool\n"); +return ret; +} } ist->hwaccel_get_buffer = qsv_get_buffer; @@ -114,9 +115,8 @@ int qsv_transcode_init(OutputStream *ost) const enum AVPixelFormat *pix_fmt; int err, i; -AVBufferRef *encode_frames_ref = NULL; -AVHWFramesContext *encode_frames; -AVQSVFramesContext *qsv_frames; +AVHWFramesContext *frames_ctx; +AVQSVFramesContext *frames_hwctx; /* check if the encoder supports QSV */ if (!ost->enc->pix_fmts) @@ -150,42 +150,33 @@ int qsv_transcode_init(OutputStream *ost) if (!hw_device_ctx) { err = qsv_device_init(ist); if (err < 0) -goto fail; -} - -// This creates a dummy hw_frames_ctx for the encoder to be -// suitably initialised. It only contains one real frame, so -// hopefully doesn't waste too much memory. - -encode_frames_ref = av_hwframe_ctx_alloc(hw_device_ctx); -if (!encode_frames_ref) { -err = AVERROR(ENOMEM); -goto fail; +return err; } -encode_frames = (AVHWFramesContext*)encode_frames_ref->data; -qsv_frames = encode_frames->hwctx; -encode_frames->width = FFALIGN(ist->resample_width, 32); -encode_frames->height= FFALIGN(ist->resample_height, 32); -encode_frames->format= AV_PIX_FMT_QSV; -encode_frames->sw_format = AV_PIX_FMT_NV12; -encode_frames->initial_pool_size = 1; +ist->dec_ctx->pix_fmt = AV_PIX_FMT_QSV; +ist->resample_pix_fmt = AV_PIX_FMT_QSV; +ist->hw_frames_ctx= av_hwframe_ctx_alloc(hw_device_ctx); +if (!ist->hw_frames_ctx) +return AVERROR(ENOMEM); -qsv_frames->frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET; +frames_ctx = (AVHWFramesContext*)ist->hw_frames_ctx->data; +frames_hwctx = frames_ctx->hwctx; -err = av_hwframe_ctx_init(encode_frames_ref); -if (err < 0) -goto fail; +frames_ctx->width = FFALIGN(ist->resample_width, 32); +frames_ctx->height= FFALIGN(ist->resample_height, 32); +frames_ctx->format= AV_PIX_FMT_QSV; +frames_ctx->sw_format = AV_PIX_FMT_NV12; +frames_ctx->initial_pool_size = 64; +frames_hwctx->frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET; -ist->dec_ctx->pix_fmt = AV_PIX_FMT_QSV; -ist->resample_pix_fmt = AV_PIX_FMT_QSV; +err = av_hwframe_ctx_init(ist->hw_frames_ctx); +if (err < 0) { +
Re: [FFmpeg-devel] [PATCH] libavcodec/nvenc.c Reduce initialization time for gpu id > 0
> Yes, this is a simpler logic. Works for me locally. Can you please apply this > patch to ffmpeg master. Thanks. Applied We also discovered a case where this patch is necessary to successfully use multiple GPUs at all. A user asked in #ffmpeg about nvenc getting stuck when one GPU is at full load, even when ffmpeg was instructed to use a different GPU. Turned out that when GPU #0 is under full video engine load, initializing CUDA/NVENC on it just hangs indefinitely until the load drops. With the old logic this meant then when trying to use GPU #1, ffmpeg would still initialize GPU #0 to test its capabilities and get stuck while doing so. Not sure if this is intended behavior, I'd expect CUDA/NVENC to just fail when no resources are left instead of blocking indefinitely on init. The primary problem of being unable to use GPU #1 has been fixed with this patch though. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavformat/utils: Fix a memleak that st->codec->hw_frames_ctx
On Fri, Jan 20, 2017 at 8:35 PM, Chao Liu wrote: > Have you ever used valgrind? Please just run the command below: > valgrind --leak-check=full --log-file=out.log ffmpeg -hwaccel qsv > -qsv_device /dev/dri/renderD128 -c:v h264_qsv -i a.h264 -c:v h264_qsv -b:v > 2M -y out.h264 > > See line 3323 of ffmpeg.c, > ret = avcodec_copy_context(ost->st->codec, ost->enc_ctx); > and see what have been done in avcodec_copy_context: > if (src->hw_frames_ctx) { > dest->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx); > if (!dest->hw_frames_ctx) > goto fail; > } > However, that is not freed when calling avformat_free_context. > avcodec_copy_context is deprecated and should generally not be used anymore. It would be more appropriate to resolve whatever issue remains in ffmpeg that it needs to call it. Otherwise, hw_frames_ctx is supplied by the caller to libavcodec, so it also should manage its lifetime, I would think, and not be blindly free'ed by avcodec. PS: Please don't top post. - Hendrik ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavformat/utils: Fix a memleak that st->codec->hw_frames_ctx
On Fri, 20 Jan 2017 17:35:33 +0800 Chao Liu wrote: > Have you ever used valgrind? Please just run the command below: > valgrind --leak-check=full --log-file=out.log ffmpeg -hwaccel qsv > -qsv_device /dev/dri/renderD128 -c:v h264_qsv -i a.h264 -c:v h264_qsv -b:v > 2M -y out.h264 > > See line 3323 of ffmpeg.c, > ret = avcodec_copy_context(ost->st->codec, ost->enc_ctx); > and see what have been done in avcodec_copy_context: > if (src->hw_frames_ctx) { > dest->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx); > if (!dest->hw_frames_ctx) > goto fail; > } > However, that is not freed when calling avformat_free_context. > The hardware decoder should never be created in the demuxer. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] ffmpeg_qsv.c: Init an hwframes_context for decoder instead of encoder
On Fri, 20 Jan 2017 17:41:01 +0800 "Huang, Zhengxu" wrote: > From 2149f87637ab941be14828f7ae2c224908784c7d Mon Sep 17 00:00:00 2001 > From: Zhengxu > Date: Wed, 4 Jan 2017 16:43:43 +0800 > Subject: [PATCH] ffmpeg_qsv.c: Init an hwframes_context for decoder instead of > encoder. > > We consider that encoder is the last stage in the pipeline. Thinking > about filters, they get hwframes_context from their inputs. Likewise, > encoder should get hwframes_context from its input instead creating a > new faker one. Encoder can get acuurate parameters by doing so. the idea is right. What ffmpeg.c does is a gross hack that avconv doesn't have or need. Ideally, ffmpeg_qsv.c would look like avconv's equivalent file: https://git.libav.org/?p=libav.git;a=blob;f=avconv_qsv.c;hb=HEAD (It's quite possible that this still lacks avconv changes needed for this, and which were either skipped during merge, or not merged yet.) > Signed-off-by: ChaoX A Liu > Signed-off-by: Huang, Zhengxu > Signed-off-by: Andrew, Zhang > --- > ffmpeg_qsv.c | 95 > +++- > 1 file changed, 43 insertions(+), 52 deletions(-) > > diff --git a/ffmpeg_qsv.c b/ffmpeg_qsv.c > index 86824b6..8cedb7e 100644 > --- a/ffmpeg_qsv.c > +++ b/ffmpeg_qsv.c > @@ -81,25 +81,26 @@ int qsv_init(AVCodecContext *s) > return ret; > } > > -av_buffer_unref(&ist->hw_frames_ctx); > -ist->hw_frames_ctx = av_hwframe_ctx_alloc(hw_device_ctx); > -if (!ist->hw_frames_ctx) > -return AVERROR(ENOMEM); > - > -frames_ctx = (AVHWFramesContext*)ist->hw_frames_ctx->data; > -frames_hwctx = frames_ctx->hwctx; > - > -frames_ctx->width = FFALIGN(s->coded_width, 32); > -frames_ctx->height= FFALIGN(s->coded_height, 32); > -frames_ctx->format= AV_PIX_FMT_QSV; > -frames_ctx->sw_format = s->sw_pix_fmt; > -frames_ctx->initial_pool_size = 64; > -frames_hwctx->frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET; > - > -ret = av_hwframe_ctx_init(ist->hw_frames_ctx); > -if (ret < 0) { > -av_log(NULL, AV_LOG_ERROR, "Error initializing a QSV frame pool\n"); > -return ret; > +if(!ist->hw_frames_ctx) { Why this check? It's pointless - hw_frames_ctx is unset when get_format is called. It also changes indentation, which makes reviewing harder. > +ist->hw_frames_ctx = av_hwframe_ctx_alloc(hw_device_ctx); > +if (!ist->hw_frames_ctx) > +return AVERROR(ENOMEM); > + > +frames_ctx = (AVHWFramesContext*)ist->hw_frames_ctx->data; > +frames_hwctx = frames_ctx->hwctx; > + > +frames_ctx->width = FFALIGN(s->coded_width, 32); > +frames_ctx->height= FFALIGN(s->coded_height, 32); > +frames_ctx->format= AV_PIX_FMT_QSV; > +frames_ctx->sw_format = s->sw_pix_fmt; > +frames_ctx->initial_pool_size = 64; > +frames_hwctx->frame_type = > MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET; > + > +ret = av_hwframe_ctx_init(ist->hw_frames_ctx); > +if (ret < 0) { > +av_log(NULL, AV_LOG_ERROR, "Error initializing a QSV frame > pool\n"); > +return ret; > +} > } > > ist->hwaccel_get_buffer = qsv_get_buffer; > @@ -114,9 +115,8 @@ int qsv_transcode_init(OutputStream *ost) > const enum AVPixelFormat *pix_fmt; > > int err, i; > -AVBufferRef *encode_frames_ref = NULL; > -AVHWFramesContext *encode_frames; > -AVQSVFramesContext *qsv_frames; > +AVHWFramesContext *frames_ctx; > +AVQSVFramesContext *frames_hwctx; > > /* check if the encoder supports QSV */ > if (!ost->enc->pix_fmts) > @@ -150,42 +150,33 @@ int qsv_transcode_init(OutputStream *ost) > if (!hw_device_ctx) { > err = qsv_device_init(ist); > if (err < 0) > -goto fail; > -} > - > -// This creates a dummy hw_frames_ctx for the encoder to be > -// suitably initialised. It only contains one real frame, so > -// hopefully doesn't waste too much memory. > - > -encode_frames_ref = av_hwframe_ctx_alloc(hw_device_ctx); > -if (!encode_frames_ref) { > -err = AVERROR(ENOMEM); > -goto fail; > +return err; > } > -encode_frames = (AVHWFramesContext*)encode_frames_ref->data; > -qsv_frames = encode_frames->hwctx; > > -encode_frames->width = FFALIGN(ist->resample_width, 32); > -encode_frames->height= FFALIGN(ist->resample_height, 32); > -encode_frames->format= AV_PIX_FMT_QSV; > -encode_frames->sw_format = AV_PIX_FMT_NV12; > -encode_frames->initial_pool_size = 1; > +ist->dec_ctx->pix_fmt = AV_PIX_FMT_QSV; > +ist->resample_pix_fmt = AV_PIX_FMT_QSV; These lines should be removed. AFAIK they're hacks to make ffmpeg.c "behave". Please fix the root of the issue instead. > +ist->hw_frames_ctx= av_hwframe_c
Re: [FFmpeg-devel] dcaenc: use Huffman codes for Bit Allocation Index
On 20 January 2017 at 08:57, Даниил Чередник wrote: > Hi. > > My previous patch introduced Huffman for quantized data, this patch allows > to use Huffman for bit allocation indexes (abits). This is a less > significant improvement but still noticeable in case of limited bitrate. In > case of DIN_45403 input sample I got: > before: > Best PSNR is 44.47 for shift 0 > after: > Best PSNR is 46.64 for shift 0 > > Thank you. > -- > Daniil Cherednik > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > Hi, I've reviewed and tested the patch, saw nothing wrong. There was indeed a small improvement from signalling bit allocation using Huffman tables. Performance didn't even decrease on my machine. Thanks, pushed. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec/atrac3: allow 6 channels (non-joint stereo)
On 1/19/17, bananaman...@gmail.com wrote: > From: bnnm > > Raises max channels to 6 (for non joint-stereo only), > there is no difference decoding 1 or N discrete channels. > Fixes trac issue #5840 > > Signed-off-by: bnnm > --- > libavcodec/atrac3.c | 17 - > 1 file changed, 8 insertions(+), 9 deletions(-) > applied ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/3] avformat/avienc: add reserve_index_space option
On 19.01.2017 18:32, Michael Niedermayer wrote: On Wed, Jan 18, 2017 at 10:27:02AM +0100, Tobias Rapp wrote: Allows the user to reserve space for the ODML master index. A sufficient sized master index in the AVI header avoids storing follow-up master indexes within the 'movi' data later. If the option is omitted or zero the index size is estimated from output duration and bitrate. A worst-case bitrate for video streams is assumed in case it is not available. Note: fate reference files changed because the video stream had zero bitrate before and is guessed now. Signed-off-by: Tobias Rapp --- libavformat/avi.h | 1 - libavformat/avienc.c| 77 ++--- libavformat/version.h | 2 +- tests/ref/fate/mpeg4-bsf-unpack-bframes | 2 +- tests/ref/lavf-fate/avi_cram| 2 +- 5 files changed, 74 insertions(+), 10 deletions(-) this breaks segment: ./ffmpeg -i lena.pnm -f segment test%d.avi possibly related to avi_init() Yes, I can reproduce the problem when going back to Git master and just adding a dummy init (see attached diff). Not sure how to fix this, other muxers also have an init but seem to work fine (mkv) ... Of course I could simply work-around it by moving the code from avi_init into avi_write_header. Regards, Tobias diff --git a/libavformat/avienc.c b/libavformat/avienc.c index fd16fff..fb78300 100644 --- a/libavformat/avienc.c +++ b/libavformat/avienc.c @@ -134,6 +134,12 @@ static int avi_add_ientry(AVFormatContext *s, int stream_index, char *tag, return 0; } + +static int avi_init(struct AVFormatContext *s) +{ +return 0; +} + static int64_t avi_start_new_riff(AVFormatContext *s, AVIOContext *pb, const char *riff_tag, const char *list_tag) { @@ -927,6 +933,7 @@ AVOutputFormat ff_avi_muxer = { .priv_data_size = sizeof(AVIContext), .audio_codec= CONFIG_LIBMP3LAME ? AV_CODEC_ID_MP3 : AV_CODEC_ID_AC3, .video_codec= AV_CODEC_ID_MPEG4, +.init = avi_init, .write_header = avi_write_header, .write_packet = avi_write_packet, .write_trailer = avi_write_trailer, ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/3] avformat/avienc: add reserve_index_space option
On 20.01.2017 15:56, Tobias Rapp wrote: On 19.01.2017 18:32, Michael Niedermayer wrote: On Wed, Jan 18, 2017 at 10:27:02AM +0100, Tobias Rapp wrote: Allows the user to reserve space for the ODML master index. A sufficient sized master index in the AVI header avoids storing follow-up master indexes within the 'movi' data later. If the option is omitted or zero the index size is estimated from output duration and bitrate. A worst-case bitrate for video streams is assumed in case it is not available. Note: fate reference files changed because the video stream had zero bitrate before and is guessed now. Signed-off-by: Tobias Rapp --- libavformat/avi.h | 1 - libavformat/avienc.c| 77 ++--- libavformat/version.h | 2 +- tests/ref/fate/mpeg4-bsf-unpack-bframes | 2 +- tests/ref/lavf-fate/avi_cram| 2 +- 5 files changed, 74 insertions(+), 10 deletions(-) this breaks segment: ./ffmpeg -i lena.pnm -f segment test%d.avi possibly related to avi_init() Yes, I can reproduce the problem when going back to Git master and just adding a dummy init (see attached diff). Not sure how to fix this, other muxers also have an init but seem to work fine (mkv) ... Apparently the codec_tag is cleared in seg_write_header() around line 811: [...] if (!oc->oformat->codec_tag || av_codec_get_id (oc->oformat->codec_tag, ipar->codec_tag) == opar->codec_id || av_codec_get_tag(oc->oformat->codec_tag, ipar->codec_id) <= 0) { opar->codec_tag = ipar->codec_tag; } else { opar->codec_tag = 0; } [...] See http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/segment.c;hb=HEAD#l811 If .init is unset, the header is written before the codec_tag is cleared. If .init is set, it is written after these lines. Regards, Tobias ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/3] avformat/avienc: add reserve_index_space option
On Fri, Jan 20, 2017 at 05:06:59PM +0100, Tobias Rapp wrote: > On 20.01.2017 15:56, Tobias Rapp wrote: > >On 19.01.2017 18:32, Michael Niedermayer wrote: > >>On Wed, Jan 18, 2017 at 10:27:02AM +0100, Tobias Rapp wrote: > >>>Allows the user to reserve space for the ODML master index. A sufficient > >>>sized master index in the AVI header avoids storing follow-up master > >>>indexes within the 'movi' data later. > >>> > >>>If the option is omitted or zero the index size is estimated from output > >>>duration and bitrate. A worst-case bitrate for video streams is assumed > >>>in case it is not available. > >>> > >>>Note: fate reference files changed because the video stream had zero > >>>bitrate before and is guessed now. > >>> > >>>Signed-off-by: Tobias Rapp > >>>--- > >>> libavformat/avi.h | 1 - > >>> libavformat/avienc.c| 77 > >>>++--- > >>> libavformat/version.h | 2 +- > >>> tests/ref/fate/mpeg4-bsf-unpack-bframes | 2 +- > >>> tests/ref/lavf-fate/avi_cram| 2 +- > >>> 5 files changed, 74 insertions(+), 10 deletions(-) > >> > >>this breaks segment: > >>./ffmpeg -i lena.pnm -f segment test%d.avi > >> > >>possibly related to avi_init() > > > >Yes, I can reproduce the problem when going back to Git master and just > >adding a dummy init (see attached diff). Not sure how to fix this, other > >muxers also have an init but seem to work fine (mkv) ... > > Apparently the codec_tag is cleared in seg_write_header() around line 811: > > [...] > if (!oc->oformat->codec_tag || > av_codec_get_id (oc->oformat->codec_tag, ipar->codec_tag) == > opar->codec_id || > av_codec_get_tag(oc->oformat->codec_tag, ipar->codec_id) <= 0) { > opar->codec_tag = ipar->codec_tag; > } else { > opar->codec_tag = 0; > } > [...] > > See > http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavformat/segment.c;hb=HEAD#l811 > > If .init is unset, the header is written before the codec_tag is > cleared. If .init is set, it is written after these lines. the return code of your init function is wrong i think also this patch causes a 1 byte difference in the output of: ./ffmpeg -i ~/tickets/1116/AVI-RLE_MP3.avi -vcodec copy -an out2.avi is that intended ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avformat: add MIDI Sample Dump Standard demuxer
Signed-off-by: Paul B Mahol --- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/sdsdec.c | 165 +++ 3 files changed, 167 insertions(+) create mode 100644 libavformat/sdsdec.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 872b30e..fbb28e3 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -435,6 +435,7 @@ OBJS-$(CONFIG_SAP_DEMUXER) += sapdec.o OBJS-$(CONFIG_SAP_MUXER) += sapenc.o OBJS-$(CONFIG_SBG_DEMUXER) += sbgdec.o OBJS-$(CONFIG_SDP_DEMUXER) += rtsp.o +OBJS-$(CONFIG_SDS_DEMUXER) += sdsdec.o OBJS-$(CONFIG_SDR2_DEMUXER) += sdr2.o OBJS-$(CONFIG_SEGAFILM_DEMUXER) += segafilm.o OBJS-$(CONFIG_SEGMENT_MUXER) += segment.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 6a79b75..8787c79 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -274,6 +274,7 @@ void av_register_all(void) REGISTER_MUXDEMUX(SAP, sap); REGISTER_DEMUXER (SBG, sbg); REGISTER_DEMUXER (SDP, sdp); +REGISTER_DEMUXER (SDS, sds); REGISTER_DEMUXER (SDR2, sdr2); #if CONFIG_RTPDEC ff_register_rtp_dynamic_payload_handlers(); diff --git a/libavformat/sdsdec.c b/libavformat/sdsdec.c new file mode 100644 index 000..727586a --- /dev/null +++ b/libavformat/sdsdec.c @@ -0,0 +1,165 @@ +/* + * MIDI Sample Dump Standard format demuxer + * Copyright (c) 2017 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/intreadwrite.h" +#include "avformat.h" +#include "internal.h" + +typedef struct SDSContext { +uint8_t data[120]; +int bit_depth; +int size; +void (*read_block)(const uint8_t *src, int32_t *dst); +} SDSContext; + +static int sds_probe(AVProbeData *p) +{ +if (AV_RB32(p->buf) == 0xF07E0001 && p->buf[20] == 0xF7 && +p->buf[6] >= 8 && p->buf[6] <= 28) +return AVPROBE_SCORE_EXTENSION; +return 0; +} + +static void byte2_read(const uint8_t *src, int32_t *dst) +{ +int i; + +for (i = 0; i < 120; i += 2) { +unsigned sample = (src[i + 0] << 25) + (src[i + 1] << 18); + +dst[i / 2] = sample; +} +} + +static void byte3_read(const uint8_t *src, int32_t *dst) +{ +int i; + +for (i = 0; i < 120; i += 3) { +unsigned sample; + + sample = (src[i + 0] << 25) | (src[i + 1] << 18) | (src[i + 2] << 11); +dst[i / 3] = sample; +} +} + +static void byte4_read(const uint8_t *src, int32_t *dst) +{ +int i; + +for (i = 0; i < 120; i += 4) { +unsigned sample; + + sample = (src[i + 0] << 25) | (src[i + 1] << 18) | (src[i + 2] << 11) | (src[i + 3] << 4); +dst[i / 4] = sample; +} +} + +#define SDS_3BYTE_TO_INT_DECODE(x) (((x) & 0x7F) | (((x) & 0x7F00) >> 1) | (((x) & 0x7F) >> 2)) + +static int sds_read_header(AVFormatContext *ctx) +{ +SDSContext *s = ctx->priv_data; +unsigned sample_period; +AVIOContext *pb = ctx->pb; +AVStream *st; + +st = avformat_new_stream(ctx, NULL); +if (!st) +return AVERROR(ENOMEM); + +avio_skip(pb, 4); +avio_skip(pb, 2); + +s->bit_depth = avio_r8(pb); +if (s->bit_depth < 8 || s->bit_depth > 28) +return AVERROR_INVALIDDATA; + +if (s->bit_depth < 14) { +s->read_block = byte2_read; +s->size = 60 * 4; +} else if (s->bit_depth < 21) { +s->read_block = byte3_read; +s->size = 40 * 4; +} else { +s->read_block = byte4_read; +s->size = 30 * 4; +} +st->codecpar->codec_id = AV_CODEC_ID_PCM_U32LE; + +sample_period = avio_rl24(pb); +sample_period = SDS_3BYTE_TO_INT_DECODE(sample_period); +avio_skip(pb, 11); + +st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; +st->codecpar->channels = 1; +st->codecpar->sample_rate = sample_period ? 10 / sample_period : 16000; +st->duration = (avio_size(pb) - 21) / (127) * s->size / 4; + +avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); + +return 0; +} + +static int sds_read_packet(AVFormatContext *ctx, AVPacket *pkt) +{ +SD
Re: [FFmpeg-devel] [PATCH] ffmpeg.c: Add output file index and stream index to vstats file.
On Thu, Jan 19, 2017 at 02:34:14PM -0800, Sasi Inguva wrote: > Signed-off-by: Sasi Inguva > --- > ffmpeg.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/ffmpeg.c b/ffmpeg.c > index 977708c069..a566c3fe2a 100644 > --- a/ffmpeg.c > +++ b/ffmpeg.c > @@ -1347,7 +1347,7 @@ static void do_video_stats(OutputStream *ost, int > frame_size) > enc = ost->enc_ctx; > if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { > frame_number = ost->st->nb_frames; > -fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, > +fprintf(vstats_file, "out= %2d st= %2d frame= %5d q= %2.1f ", > ost->file_index, ost->index, frame_number, > ost->quality / (float)FF_QP2LAMBDA); Should this be under a check for vstats version ? So as not to break any code using the vstats file or is there some declaration in our docs that the format may change at any time ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In a rich man's house there is no place to spit but his face. -- Diogenes of Sinope signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: Add FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM to most h263 based codecs
On Thu, Dec 22, 2016 at 05:50:13PM +0100, Michael Niedermayer wrote: > Signed-off-by: Michael Niedermayer > --- > libavcodec/flvdec.c| 1 + > libavcodec/h263dec.c | 2 ++ > libavcodec/intelh263dec.c | 1 + > libavcodec/mpeg4videodec.c | 1 + > libavcodec/msmpeg4dec.c| 4 > 5 files changed, 9 insertions(+) applied [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In fact, the RIAA has been known to suggest that students drop out of college or go to community college in order to be able to afford settlements. -- The RIAA signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] lavf/segment: fix crash when failing to open segment list
This happens because segment_end() returns an error, so seg_write_packet never proceeds to segment_start(), and seg->avf->pb is never re-set, so we crash with a null pb when av_write_trailer flushes the packet queue. This doesn't seem to be clearly recoverable, so I'm just failing more gracefully. Repro: ffmpeg -i input.ts -f segment -c copy -segment_list /noaxx.m3u8 test-%05d.ts (assuming you don't have write access to /) --- libavformat/segment.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavformat/segment.c b/libavformat/segment.c index 9b3dc178eb..9d471483b3 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -354,6 +354,9 @@ static int segment_end(AVFormatContext *s, int write_trailer, int is_last) int i; int err; +if (!oc || !oc->pb) +return AVERROR(EINVAL); + av_write_frame(oc, NULL); /* Flush any buffered data (fragmented mp4) */ if (write_trailer) ret = av_write_trailer(oc); @@ -850,7 +853,7 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt) int64_t usecs; int64_t wrapped_val; -if (!seg->avf) +if (!seg->avf || !seg->avf->pb) return AVERROR(EINVAL); calc_times: -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] ffmpeg.c: Add output file index and stream index to vstats file.
Couldn't find any version that relates to vstats. There is nothing that says format may change any time , but there is no defined format either. Let me know the version enum I have to update if I need to. On Fri, Jan 20, 2017 at 4:18 PM, Michael Niedermayer wrote: > On Thu, Jan 19, 2017 at 02:34:14PM -0800, Sasi Inguva wrote: > > Signed-off-by: Sasi Inguva > > --- > > ffmpeg.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/ffmpeg.c b/ffmpeg.c > > index 977708c069..a566c3fe2a 100644 > > --- a/ffmpeg.c > > +++ b/ffmpeg.c > > @@ -1347,7 +1347,7 @@ static void do_video_stats(OutputStream *ost, int > frame_size) > > enc = ost->enc_ctx; > > if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { > > frame_number = ost->st->nb_frames; > > -fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, > > +fprintf(vstats_file, "out= %2d st= %2d frame= %5d q= %2.1f ", > ost->file_index, ost->index, frame_number, > > ost->quality / (float)FF_QP2LAMBDA); > > Should this be under a check for vstats version ? > So as not to break any code using the vstats file or is there some > declaration in our docs that the format may change at any time ? > > [...] > > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > In a rich man's house there is no place to spit but his face. > -- Diogenes of Sinope > > ___ > 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] [PATCH] avcodec/alsdec.c: testing MPEG-4 ALS decoder with floating point audio data
If als_07_2ch192k32bF.mp4 isn't already located in fate-suite/lossless-audio/, you can download at: http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_IEC_14496-26_2010_Bitstreams/DVD1/mpeg4audio-conformance/compressedMp4/als_07_2ch192k32bF.mp4 Reference file can be found at: https://dl.dropboxusercontent.com/u/1519724/als_07_2ch192k32bF.f32 Signed-off-by: Thomas Turner --- tests/fate/als.mak | 4 1 file changed, 4 insertions(+) diff --git a/tests/fate/als.mak b/tests/fate/als.mak index ff2badf..1f4c88f 100644 --- a/tests/fate/als.mak +++ b/tests/fate/als.mak @@ -7,5 +7,9 @@ endef $(foreach N,$(ALS_SUITE),$(eval $(call FATE_ALS_SUITE,$(N +FATE_ALS += fate-mpeg4-als-conformance-07 +fate-mpeg4-als-conformance-07: CMD = ffmpeg -i $(TARGET_SAMPLES)/lossless-audio/als_07_2ch192k32bF.mp4 -af atrim=end_sample=958446 -f f32le - +fate-mpeg4-als-conformance-07: REF = $(TARGET_SAMPLES)/audio-reference/als_07_2ch192k32bF.f32 + FATE_SAMPLES_AVCONV-$(call DEMDEC, MOV, ALS) += $(FATE_ALS) fate-als: $(FATE_ALS) -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel