Re: [FFmpeg-devel] [PATCH v2 3/3] libavcodec/qsvdec: using suggested num to set init_pool_size
On Mon, 2022-03-28 at 02:26 +, Xiang, Haihao wrote: > On Fri, 2022-03-18 at 07:40 +, Soft Works wrote: > > > -Original Message- > > > From: ffmpeg-devel On Behalf Of > > > Wenbin Chen > > > Sent: Friday, March 18, 2022 7:25 AM > > > To: ffmpeg-devel@ffmpeg.org > > > Subject: [FFmpeg-devel] [PATCH v2 3/3] libavcodec/qsvdec: using > > > suggested num to set init_pool_size > > > > > > The init_pool_size is set to be 64 and it is too many. > > > Use IOSurfQuery to get NumFrameSuggest which is the suggested > > > number of frame that needed to be allocated when initializing the > > > decoder. > > > Considering that the hevc_qsv encoder uses the most frame buffer, > > > async is 4 (default) and max_b_frames is 8 (default) and decoder > > > may followed by VPP, use NumFrameSuggest + 16 to set init_pool_size. > > > > > > Signed-off-by: Wenbin Chen > > > Signed-off-by: Guangxin Xu > > > --- > > > libavcodec/qsvdec.c | 14 -- > > > 1 file changed, 12 insertions(+), 2 deletions(-) > > > > > > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c > > > index 210bd0c1d5..9875d3d632 100644 > > > --- a/libavcodec/qsvdec.c > > > +++ b/libavcodec/qsvdec.c > > > @@ -88,7 +88,7 @@ typedef struct QSVContext { > > > uint32_t fourcc; > > > mfxFrameInfo frame_info; > > > AVBufferPool *pool; > > > - > > > +int suggest_pool_size; > > > int initialized; > > > > > > // options set by the caller > > > @@ -275,7 +275,7 @@ static int qsv_decode_preinit(AVCodecContext > > > *avctx, QSVContext *q, enum AVPixel > > > hwframes_ctx->height= FFALIGN(avctx- > > > > coded_height, 32); > > > > > > hwframes_ctx->format= AV_PIX_FMT_QSV; > > > hwframes_ctx->sw_format = avctx->sw_pix_fmt; > > > -hwframes_ctx->initial_pool_size = 64 + avctx- > > > > extra_hw_frames; > > > > > > +hwframes_ctx->initial_pool_size = q->suggest_pool_size + 16 + > > > avctx->extra_hw_frames; > > > frames_hwctx->frame_type= > > > MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET; > > > > > > ret = av_hwframe_ctx_init(avctx->hw_frames_ctx); > > > @@ -793,6 +793,9 @@ static int qsv_process_data(AVCodecContext *avctx, > > > QSVContext *q, > > > } > > > > > > if (q->reinit_flag || !q->session || !q->initialized) { > > > +mfxFrameAllocRequest request; > > > +memset(&request, 0, sizeof(request)); > > > + > > > q->reinit_flag = 0; > > > ret = qsv_decode_header(avctx, q, pkt, pix_fmt, ¶m); > > > if (ret < 0) { > > > @@ -802,12 +805,19 @@ static int qsv_process_data(AVCodecContext > > > *avctx, QSVContext *q, > > > av_log(avctx, AV_LOG_ERROR, "Error decoding > > > header\n"); > > > goto reinit_fail; > > > } > > > +param.IOPattern = q->iopattern; > > > > > > q->orig_pix_fmt = avctx->pix_fmt = pix_fmt = > > > ff_qsv_map_fourcc(param.mfx.FrameInfo.FourCC); > > > > > > avctx->coded_width = param.mfx.FrameInfo.Width; > > > avctx->coded_height = param.mfx.FrameInfo.Height; > > > > > > +ret = MFXVideoDECODE_QueryIOSurf(q->session, ¶m, > > > &request); > > > +if (ret < 0) > > > +return ff_qsv_print_error(avctx, ret, "Error querying IO > > > surface"); > > > + > > > +q->suggest_pool_size = request.NumFrameSuggested; > > > + > > > ret = qsv_decode_preinit(avctx, q, pix_fmt, ¶m); > > > if (ret < 0) > > > goto reinit_fail; > > > -- > > > > Thanks for the patch! I have that on my list for quite a while. > > Will look at it shortly. > > Hi Softworz, > > This patchset LGTM and works well, do you have any comment ? Ping, I'll apply this patchset in a few days if no more comment. Regards Haihao ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] libavcodec/qsvdec: Add more pixel format support to qsvdec
On Wed, 2022-03-30 at 14:43 +0800, Wenbin Chen wrote: > Qsv decoder only supports directly output nv12 and p010 to system > memory. For other format, we need to download frame from qsv format > to system memory. Now add other supported format to qsvdec. > > Signed-off-by: Wenbin Chen > --- > libavcodec/qsv.c | 36 > libavcodec/qsv_internal.h | 3 +++ > libavcodec/qsvdec.c | 23 +-- > 3 files changed, 56 insertions(+), 6 deletions(-) > > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c > index 67d0e3934a..8010eef172 100644 > --- a/libavcodec/qsv.c > +++ b/libavcodec/qsv.c > @@ -244,6 +244,42 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t > *fourcc) > } > } > > +int ff_qsv_map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 > *surface) > +{ > +switch (frame->format) { > +case AV_PIX_FMT_NV12: > +case AV_PIX_FMT_P010: > +surface->Data.Y = frame->data[0]; > +surface->Data.UV = frame->data[1]; > +/* The SDK checks Data.V when using system memory for VP9 encoding */ > +surface->Data.V = surface->Data.UV + 1; > +break; > +case AV_PIX_FMT_X2RGB10LE: > +case AV_PIX_FMT_BGRA: > +surface->Data.B = frame->data[0]; > +surface->Data.G = frame->data[0] + 1; > +surface->Data.R = frame->data[0] + 2; > +surface->Data.A = frame->data[0] + 3; > +break; > +case AV_PIX_FMT_YUYV422: > +surface->Data.Y = frame->data[0]; > +surface->Data.U = frame->data[0] + 1; > +surface->Data.V = frame->data[0] + 3; > +break; > + > +case AV_PIX_FMT_Y210: > +surface->Data.Y16 = (mfxU16 *)frame->data[0]; > +surface->Data.U16 = (mfxU16 *)frame->data[0] + 1; > +surface->Data.V16 = (mfxU16 *)frame->data[0] + 3; > +break; > +default: > +return MFX_ERR_UNSUPPORTED; Please change the return type to mfxStatus if you want to return a mfx error code, otherwise return a ffmpeg error here. Thanks Haihao > +} > +surface->Data.PitchLow = frame->linesize[0]; > + > +return 0; > +} > + > int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame *frame) > { > int i; > diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h > index 58186ea7ca..e2aecdcbd6 100644 > --- a/libavcodec/qsv_internal.h > +++ b/libavcodec/qsv_internal.h > @@ -147,4 +147,7 @@ int ff_qsv_find_surface_idx(QSVFramesContext *ctx, > QSVFrame *frame); > void ff_qsv_frame_add_ext_param(AVCodecContext *avctx, QSVFrame *frame, > mfxExtBuffer *param); > > +int ff_qsv_map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 > *surface); > + > + > #endif /* AVCODEC_QSV_INTERNAL_H */ > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c > index 661f15bc75..f159e2690f 100644 > --- a/libavcodec/qsvdec.c > +++ b/libavcodec/qsvdec.c > @@ -132,21 +132,28 @@ static int qsv_get_continuous_buffer(AVCodecContext > *avctx, AVFrame *frame, > frame->linesize[0] = FFALIGN(avctx->width, 128); > break; > case AV_PIX_FMT_P010: > +case AV_PIX_FMT_YUYV422: > frame->linesize[0] = 2 * FFALIGN(avctx->width, 128); > break; > +case AV_PIX_FMT_Y210: > +frame->linesize[0] = 4 * FFALIGN(avctx->width, 128); > +break; > default: > av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format.\n"); > return AVERROR(EINVAL); > } > > -frame->linesize[1] = frame->linesize[0]; > frame->buf[0] = av_buffer_pool_get(pool); > if (!frame->buf[0]) > return AVERROR(ENOMEM); > > frame->data[0] = frame->buf[0]->data; > -frame->data[1] = frame->data[0] + > -frame->linesize[0] * FFALIGN(avctx->height, 64); > +if (avctx->pix_fmt == AV_PIX_FMT_NV12 || > +avctx->pix_fmt == AV_PIX_FMT_P010) { > +frame->linesize[1] = frame->linesize[0]; > +frame->data[1] = frame->data[0] + > +frame->linesize[0] * FFALIGN(avctx->height, 64); > +} > > ret = ff_attach_decode_data(frame); > if (ret < 0) > @@ -426,9 +433,11 @@ static int alloc_frame(AVCodecContext *avctx, QSVContext > *q, QSVFrame *frame) > if (frame->frame->format == AV_PIX_FMT_QSV) { > frame->surface = *(mfxFrameSurface1*)frame->frame->data[3]; > } else { > -frame->surface.Data.PitchLow = frame->frame->linesize[0]; > -frame->surface.Data.Y= frame->frame->data[0]; > -frame->surface.Data.UV = frame->frame->data[1]; > +ret = ff_qsv_map_frame_to_surface(frame->frame, &frame->surface); > +if (ret < 0) { > +av_log(avctx, AV_LOG_ERROR, "map frame to surface failed.\n"); > +return AVERROR(EINVAL); > +} > } > > frame->surface.Info = q->frame_info; > @@ -993,6 +1002,8 @@ const FFCodec ff_##x##_qsv_decoder = { \ > .p.priv_c
Re: [FFmpeg-devel] [PATCH 1/2] libavcodec/qsvdec: Add more pixel format support to qsvdec
> On Wed, 2022-03-30 at 14:43 +0800, Wenbin Chen wrote: > > Qsv decoder only supports directly output nv12 and p010 to system > > memory. For other format, we need to download frame from qsv format > > to system memory. Now add other supported format to qsvdec. > > > > Signed-off-by: Wenbin Chen > > --- > > libavcodec/qsv.c | 36 > > libavcodec/qsv_internal.h | 3 +++ > > libavcodec/qsvdec.c | 23 +-- > > 3 files changed, 56 insertions(+), 6 deletions(-) > > > > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c > > index 67d0e3934a..8010eef172 100644 > > --- a/libavcodec/qsv.c > > +++ b/libavcodec/qsv.c > > @@ -244,6 +244,42 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat > format, uint32_t > > *fourcc) > > } > > } > > > > +int ff_qsv_map_frame_to_surface(const AVFrame *frame, > mfxFrameSurface1 > > *surface) > > +{ > > +switch (frame->format) { > > +case AV_PIX_FMT_NV12: > > +case AV_PIX_FMT_P010: > > +surface->Data.Y = frame->data[0]; > > +surface->Data.UV = frame->data[1]; > > +/* The SDK checks Data.V when using system memory for VP9 > encoding */ > > +surface->Data.V = surface->Data.UV + 1; > > +break; > > +case AV_PIX_FMT_X2RGB10LE: > > +case AV_PIX_FMT_BGRA: > > +surface->Data.B = frame->data[0]; > > +surface->Data.G = frame->data[0] + 1; > > +surface->Data.R = frame->data[0] + 2; > > +surface->Data.A = frame->data[0] + 3; > > +break; > > +case AV_PIX_FMT_YUYV422: > > +surface->Data.Y = frame->data[0]; > > +surface->Data.U = frame->data[0] + 1; > > +surface->Data.V = frame->data[0] + 3; > > +break; > > + > > +case AV_PIX_FMT_Y210: > > +surface->Data.Y16 = (mfxU16 *)frame->data[0]; > > +surface->Data.U16 = (mfxU16 *)frame->data[0] + 1; > > +surface->Data.V16 = (mfxU16 *)frame->data[0] + 3; > > +break; > > +default: > > +return MFX_ERR_UNSUPPORTED; > > Please change the return type to mfxStatus if you want to return a mfx error > code, otherwise return a ffmpeg error here. > > Thanks > Haihao > Thanks for review. I will update it. > > > +} > > +surface->Data.PitchLow = frame->linesize[0]; > > + > > +return 0; > > +} > > + > > int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame *frame) > > { > > int i; > > diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h > > index 58186ea7ca..e2aecdcbd6 100644 > > --- a/libavcodec/qsv_internal.h > > +++ b/libavcodec/qsv_internal.h > > @@ -147,4 +147,7 @@ int ff_qsv_find_surface_idx(QSVFramesContext > *ctx, > > QSVFrame *frame); > > void ff_qsv_frame_add_ext_param(AVCodecContext *avctx, QSVFrame > *frame, > > mfxExtBuffer *param); > > > > +int ff_qsv_map_frame_to_surface(const AVFrame *frame, > mfxFrameSurface1 > > *surface); > > + > > + > > #endif /* AVCODEC_QSV_INTERNAL_H */ > > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c > > index 661f15bc75..f159e2690f 100644 > > --- a/libavcodec/qsvdec.c > > +++ b/libavcodec/qsvdec.c > > @@ -132,21 +132,28 @@ static int > qsv_get_continuous_buffer(AVCodecContext > > *avctx, AVFrame *frame, > > frame->linesize[0] = FFALIGN(avctx->width, 128); > > break; > > case AV_PIX_FMT_P010: > > +case AV_PIX_FMT_YUYV422: > > frame->linesize[0] = 2 * FFALIGN(avctx->width, 128); > > break; > > +case AV_PIX_FMT_Y210: > > +frame->linesize[0] = 4 * FFALIGN(avctx->width, 128); > > +break; > > default: > > av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format.\n"); > > return AVERROR(EINVAL); > > } > > > > -frame->linesize[1] = frame->linesize[0]; > > frame->buf[0] = av_buffer_pool_get(pool); > > if (!frame->buf[0]) > > return AVERROR(ENOMEM); > > > > frame->data[0] = frame->buf[0]->data; > > -frame->data[1] = frame->data[0] + > > -frame->linesize[0] * FFALIGN(avctx->height, > > 64); > > +if (avctx->pix_fmt == AV_PIX_FMT_NV12 || > > +avctx->pix_fmt == AV_PIX_FMT_P010) { > > +frame->linesize[1] = frame->linesize[0]; > > +frame->data[1] = frame->data[0] + > > +frame->linesize[0] * FFALIGN(avctx->height, 64); > > +} > > > > ret = ff_attach_decode_data(frame); > > if (ret < 0) > > @@ -426,9 +433,11 @@ static int alloc_frame(AVCodecContext *avctx, > QSVContext > > *q, QSVFrame *frame) > > if (frame->frame->format == AV_PIX_FMT_QSV) { > > frame->surface = *(mfxFrameSurface1*)frame->frame->data[3]; > > } else { > > -frame->surface.Data.PitchLow = frame->frame->linesize[0]; > > -frame->surface.Data.Y= frame->frame->data[0]; > > -frame->surface.Data.UV = frame->frame->data[1]; > > +ret = ff_qsv_map_frame_to_surface(frame->frame, &frame
Re: [FFmpeg-devel] Request For Comment no Matroska specs
Op vr 1 apr. 2022 14:53 schreef Steve Lhomme : > On 2022-04-01 14:33, Steve Lhomme wrote: > > Hi ffmmpeg developers, > > > > As you may know, we are working hard on the Matroska specifications at > > the IETF. We already got EBML as an RFC [1]. We are in the process of > > finalizing the main Matroska document. Before we submit the document for > > formal review before "final" publishing, we would like people who know a > > bit about Matroska to review the current draft in case there are parts > > missing, hard to decipher or, even worse, bugs. > > > > This is a 200 pages document, so it may take a while. You can find draft > > 09 at [2]. It should explain what is found in Matroska 1 to 4. Some > > unused elements have been deprecated since the original informal > > specifications. These elements can be found in Annex A. > > I forgot to mention you can reply here or on the GitHub repository of > the specs [3] by creating an issue or even a Pull Request. > > [3] https://github.com/ietf-wg-cellar/matroska-specification > > > Thanks > > > > [1] https://datatracker.ietf.org/doc/rfc8794/ > > [2] https://datatracker.ietf.org/doc/draft-ietf-cellar-matroska/ There is also a HTML version of the draft available, which is perhaps easier to read: https://www.ietf.org/archive/id/draft-ietf-cellar-matroska-09.html ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 1/2] libavcodec/qsvdec: Add more pixel format support to qsvdec
Qsv decoder only supports directly output nv12 and p010 to system memory. For other format, we need to download frame from qsv format to system memory. Now add other supported format to qsvdec. Signed-off-by: Wenbin Chen --- libavcodec/qsv.c | 36 libavcodec/qsv_internal.h | 3 +++ libavcodec/qsvdec.c | 23 +-- 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index b75877e698..cc1352aa2a 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -244,6 +244,42 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc) } } +int ff_qsv_map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 *surface) +{ +switch (frame->format) { +case AV_PIX_FMT_NV12: +case AV_PIX_FMT_P010: +surface->Data.Y = frame->data[0]; +surface->Data.UV = frame->data[1]; +/* The SDK checks Data.V when using system memory for VP9 encoding */ +surface->Data.V = surface->Data.UV + 1; +break; +case AV_PIX_FMT_X2RGB10LE: +case AV_PIX_FMT_BGRA: +surface->Data.B = frame->data[0]; +surface->Data.G = frame->data[0] + 1; +surface->Data.R = frame->data[0] + 2; +surface->Data.A = frame->data[0] + 3; +break; +case AV_PIX_FMT_YUYV422: +surface->Data.Y = frame->data[0]; +surface->Data.U = frame->data[0] + 1; +surface->Data.V = frame->data[0] + 3; +break; + +case AV_PIX_FMT_Y210: +surface->Data.Y16 = (mfxU16 *)frame->data[0]; +surface->Data.U16 = (mfxU16 *)frame->data[0] + 1; +surface->Data.V16 = (mfxU16 *)frame->data[0] + 3; +break; +default: +return AVERROR(ENOSYS); +} +surface->Data.PitchLow = frame->linesize[0]; + +return 0; +} + int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame *frame) { int i; diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index 58186ea7ca..e2aecdcbd6 100644 --- a/libavcodec/qsv_internal.h +++ b/libavcodec/qsv_internal.h @@ -147,4 +147,7 @@ int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame *frame); void ff_qsv_frame_add_ext_param(AVCodecContext *avctx, QSVFrame *frame, mfxExtBuffer *param); +int ff_qsv_map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 *surface); + + #endif /* AVCODEC_QSV_INTERNAL_H */ diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 6236391357..f1d56b2af3 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -129,21 +129,28 @@ static int qsv_get_continuous_buffer(AVCodecContext *avctx, AVFrame *frame, frame->linesize[0] = FFALIGN(avctx->width, 128); break; case AV_PIX_FMT_P010: +case AV_PIX_FMT_YUYV422: frame->linesize[0] = 2 * FFALIGN(avctx->width, 128); break; +case AV_PIX_FMT_Y210: +frame->linesize[0] = 4 * FFALIGN(avctx->width, 128); +break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format.\n"); return AVERROR(EINVAL); } -frame->linesize[1] = frame->linesize[0]; frame->buf[0] = av_buffer_pool_get(pool); if (!frame->buf[0]) return AVERROR(ENOMEM); frame->data[0] = frame->buf[0]->data; -frame->data[1] = frame->data[0] + -frame->linesize[0] * FFALIGN(avctx->height, 64); +if (avctx->pix_fmt == AV_PIX_FMT_NV12 || +avctx->pix_fmt == AV_PIX_FMT_P010) { +frame->linesize[1] = frame->linesize[0]; +frame->data[1] = frame->data[0] + +frame->linesize[0] * FFALIGN(avctx->height, 64); +} ret = ff_attach_decode_data(frame); if (ret < 0) @@ -423,9 +430,11 @@ static int alloc_frame(AVCodecContext *avctx, QSVContext *q, QSVFrame *frame) if (frame->frame->format == AV_PIX_FMT_QSV) { frame->surface = *(mfxFrameSurface1*)frame->frame->data[3]; } else { -frame->surface.Data.PitchLow = frame->frame->linesize[0]; -frame->surface.Data.Y= frame->frame->data[0]; -frame->surface.Data.UV = frame->frame->data[1]; +ret = ff_qsv_map_frame_to_surface(frame->frame, &frame->surface); +if (ret < 0) { +av_log(avctx, AV_LOG_ERROR, "map frame to surface failed.\n"); +return ret; +} } frame->surface.Info = q->frame_info; @@ -990,6 +999,8 @@ const AVCodec ff_##x##_qsv_decoder = { \ .priv_class = &x##_qsv_class, \ .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, \ AV_PIX_FMT_P010, \ +AV_PIX_FMT_YUYV422, \ +AV_PIX_FMT_Y210, \ AV_PIX_FMT_QSV, \ AV_PIX_FMT_NONE }, \
[FFmpeg-devel] [PATCH v2 2/2] libavcodec/qsvenc: Add more pixel format support to qsvenc
Qsv encoder only support input P010 and nv12 format directly from system memory. For other format, we need to upload frame to device memory and input qsv format to encoder. Now add other system memory format support to qsv encoder. Signed-off-by: Wenbin Chen --- libavcodec/qsvenc.c | 30 -- libavcodec/qsvenc_hevc.c | 2 ++ 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 40d60cde3c..55cce96022 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1602,32 +1602,10 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame, else if (frame->repeat_pict == 4) qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_TRIPLING; -qf->surface.Data.PitchLow = qf->frame->linesize[0]; -qf->surface.Data.Y = qf->frame->data[0]; -qf->surface.Data.UV= qf->frame->data[1]; - -/* The SDK checks Data.V when using system memory for VP9 encoding */ -switch (frame->format) { -case AV_PIX_FMT_NV12: -qf->surface.Data.V = qf->surface.Data.UV + 1; -break; - -case AV_PIX_FMT_P010: -qf->surface.Data.V = qf->surface.Data.UV + 2; -break; - -case AV_PIX_FMT_X2RGB10: -case AV_PIX_FMT_BGRA: -qf->surface.Data.B = qf->frame->data[0]; -qf->surface.Data.G = qf->frame->data[0] + 1; -qf->surface.Data.R = qf->frame->data[0] + 2; -qf->surface.Data.A = qf->frame->data[0] + 3; -break; - -default: -/* should not reach here */ -av_assert0(0); -break; +ret = ff_qsv_map_frame_to_surface(qf->frame, &qf->surface); +if (ret < 0) { +av_log(q->avctx, AV_LOG_ERROR, "map frame to surface failed.\n"); +return ret; } } qf->surface.Data.TimeStamp = av_rescale_q(frame->pts, q->avctx->time_base, (AVRational){1, 9}); diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index ade546d4ca..c8d58f9247 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -303,6 +303,8 @@ const AVCodec ff_hevc_qsv_encoder = { .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, AV_PIX_FMT_P010, +AV_PIX_FMT_YUYV422, +AV_PIX_FMT_Y210, AV_PIX_FMT_QSV, #if QSV_VERSION_ATLEAST(1, 17) AV_PIX_FMT_BGRA, -- 2.32.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] avfilter/src_movie: switch to activate()
Signed-off-by: Paul B Mahol --- libavfilter/src_movie.c | 84 - 1 file changed, 50 insertions(+), 34 deletions(-) diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index 711854c23c..8c7ea5686a 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -46,6 +46,7 @@ #include "audio.h" #include "avfilter.h" +#include "filters.h" #include "formats.h" #include "internal.h" #include "video.h" @@ -55,6 +56,7 @@ typedef struct MovieStream { AVCodecContext *codec_ctx; int64_t discontinuity_threshold; int64_t last_pts; +int got_eof; } MovieStream; typedef struct MovieContext { @@ -70,6 +72,8 @@ typedef struct MovieContext { int64_t discontinuity_threshold; int64_t ts_offset; int dec_threads; +int got_eagain; +int got_wanted; AVFormatContext *format_ctx; @@ -100,7 +104,6 @@ static const AVOption movie_options[]= { }; static int movie_config_output_props(AVFilterLink *outlink); -static int movie_request_frame(AVFilterLink *outlink); static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec) { @@ -314,7 +317,6 @@ static av_cold int movie_common_init(AVFilterContext *ctx) if (!pad.name) return AVERROR(ENOMEM); pad.config_props = movie_config_output_props; -pad.request_frame = movie_request_frame; if ((ret = ff_append_outpad_free_name(ctx, &pad)) < 0) return ret; if ( movie->st[i].st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && @@ -554,47 +556,61 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id) return 0; } -static int movie_request_frame(AVFilterLink *outlink) +static int activate(AVFilterContext *ctx) { -AVFilterContext *ctx = outlink->src; MovieContext *movie = ctx->priv; -unsigned out_id = FF_OUTLINK_IDX(outlink); +int ret = 0; + +/* check all decoders for available output */ +for (int i = 0; i < ctx->nb_outputs; i++) { +if (ff_outlink_frame_wanted(ctx->outputs[i])) +movie->got_wanted++; + +ret = movie_push_frame(ctx, i); +if (ret == AVERROR(EAGAIN)) +movie->got_eagain++; +else if (ret == AVERROR_EOF) +movie->st[i].got_eof++; +else if (ret < 0) +return ret; +} -while (1) { -int got_eagain = 0, got_eof = 0; -int ret = 0; +if (movie->got_eagain || movie->got_wanted) { +/* all decoders require more input -> read a new packet */ +movie->got_eagain = 0; +movie->got_wanted = 0; +ret = movie_decode_packet(ctx); +if (ret < 0 && ret != AVERROR(EAGAIN)) +return ret; +ff_filter_set_ready(ctx, 100); +return 0; +} else { +int nb_eofs = 0; -/* check all decoders for available output */ for (int i = 0; i < ctx->nb_outputs; i++) { -ret = movie_push_frame(ctx, i); -if (ret == AVERROR(EAGAIN)) -got_eagain++; -else if (ret == AVERROR_EOF) -got_eof++; -else if (ret < 0) -return ret; -else if (i == out_id) -return 0; +if (movie->st[i].got_eof && movie->loop_count == 1) +ff_outlink_set_status(ctx->outputs[i], AVERROR_EOF, movie->st[i].last_pts); +nb_eofs++; } -if (got_eagain) { -/* all decoders require more input -> read a new packet */ -ret = movie_decode_packet(ctx); +if (nb_eofs != ctx->nb_outputs) { +ff_filter_set_ready(ctx, 100); +return 0; +} + +if (movie->loop_count != 1) { +ret = rewind_file(ctx); if (ret < 0) return ret; -} else if (got_eof) { -/* all decoders flushed */ -if (movie->loop_count != 1) { -ret = rewind_file(ctx); -if (ret < 0) -return ret; -movie->loop_count -= movie->loop_count > 1; -av_log(ctx, AV_LOG_VERBOSE, "Stream finished, looping.\n"); -continue; -} -return AVERROR_EOF; +movie->loop_count -= movie->loop_count > 1; +av_log(ctx, AV_LOG_VERBOSE, "Stream finished, looping.\n"); +for (int i = 0; i < ctx->nb_outputs; i++) +movie->st[i].got_eof = 0; } +return 0; } + +return FFERROR_NOT_READY; } static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, @@ -651,7 +667,7 @@ const AVFilter ff_avsrc_movie = { .init = movie_common_init, .uninit= movie_uninit, FILTER_QUERY_FUNC(movie_query_formats), - +.activate = activate, .inputs= NULL, .outputs = NULL, .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS, @@ -670,7 +686,
[FFmpeg-devel] [PATCH 2/2] avfilter/src_movie: add option to set decoding thread type
Signed-off-by: Paul B Mahol --- doc/filters.texi| 3 +++ libavfilter/src_movie.c | 11 +-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 1d56d24819..af332041e8 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -28790,6 +28790,9 @@ timestamps. @item dec_threads Specifies the number of threads for decoding +@item dec_thread_type +Specifies the thread type for decoding. + @item format_opts Specify format options for the opened file. Format options can be specified as a list of @var{key}=@var{value} pairs separated by ':'. The following example diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index 8c7ea5686a..b4592d0390 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -72,6 +72,7 @@ typedef struct MovieContext { int64_t discontinuity_threshold; int64_t ts_offset; int dec_threads; +int thread_type; int got_eagain; int got_wanted; @@ -99,6 +100,10 @@ static const AVOption movie_options[]= { { "loop", "set loop count", OFFSET(loop_count), AV_OPT_TYPE_INT,{.i64 = 1}, 0,INT_MAX, FLAGS }, { "discontinuity", "set discontinuity threshold", OFFSET(discontinuity_threshold), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX, FLAGS }, { "dec_threads", "set the number of threads for decoding", OFFSET(dec_threads), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS }, +{ "dec_thread_type","set the type of threads for decoding", OFFSET(thread_type), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 2, FLAGS, .unit = "thread_type" }, +{ "auto", "auto",0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, FLAGS, .unit = "thread_type" }, +{ "frame","more than one frame at once", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, FLAGS, .unit = "thread_type" }, +{ "slice","more than one part of single frame at once", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, FLAGS, .unit = "thread_type" }, { "format_opts", "set format options for the opened file", OFFSET(format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS}, { NULL }, }; @@ -159,7 +164,7 @@ static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec) return found; } -static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads) +static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads, int thread_type) { const AVCodec *codec; int ret; @@ -181,6 +186,8 @@ static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads) if (!dec_threads) dec_threads = ff_filter_get_nb_threads(ctx); st->codec_ctx->thread_count = dec_threads; +if (thread_type) +st->codec_ctx->thread_type = thread_type; if ((ret = avcodec_open2(st->codec_ctx, codec, NULL)) < 0) { av_log(ctx, AV_LOG_ERROR, "Failed to open codec\n"); @@ -325,7 +332,7 @@ static av_cold int movie_common_init(AVFilterContext *ctx) if (ret < 0) return ret; } -ret = open_stream(ctx, &movie->st[i], movie->dec_threads); +ret = open_stream(ctx, &movie->st[i], movie->dec_threads, movie->thread_type); if (ret < 0) return ret; } -- 2.35.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] libavutil/hwcontext_qsv: Align width and heigh when download qsv frame
The width and height for qsv frame to download need to be aligned with 16. Add the alignment operation. Now the following command works: ffmpeg -hwaccel qsv -f rawvideo -s 1920x1080 -pix_fmt yuv420p -i \ input.yuv -vf "hwupload=extra_hw_frames=16,format=qsv,hwdownload, \ format=nv12" -f null - Signed-off-by: Wenbin Chen --- libavutil/hwcontext_qsv.c | 32 1 file changed, 32 insertions(+) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 95f8071abe..fe11e215a8 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -1063,6 +1063,38 @@ static int qsv_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, if (ret < 0) return ret; +/* According to MSDK spec for mfxframeinfo, "Width must be a multiple of 16. + * Height must be a multiple of 16 for progressive frame sequence and a + * multiple of 32 otherwise.", so allign all frames to 16 before downloading. */ +if (dst->height & 15 || dst->linesize[0] & 15) { +AVFrame *tmp_frame; +tmp_frame = av_frame_alloc(); +if (!tmp_frame) +return AVERROR(ENOMEM); +ret = av_frame_ref(tmp_frame, dst); +if (ret < 0) { +av_frame_free(&tmp_frame); +return ret; +} +av_frame_unref(dst); + +dst->width = FFALIGN(tmp_frame->linesize[0], 16); +dst->height = FFALIGN(tmp_frame->height, 16); +dst->format = tmp_frame->format; +ret = av_frame_get_buffer(dst, 0); +if (ret < 0) { +av_frame_free(&tmp_frame); +return ret; +} + +dst->width = tmp_frame->width; +dst->height = tmp_frame->height; +ret = av_frame_copy_props(dst, tmp_frame); +av_frame_free(&tmp_frame); +if (ret < 0) +return ret; +} + if (!s->session_download) { if (s->child_frames_ref) return qsv_transfer_data_child(ctx, dst, src); -- 2.32.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] avfilter/src_movie: switch to activate()
Signed-off-by: Paul B Mahol --- libavfilter/src_movie.c | 90 + 1 file changed, 56 insertions(+), 34 deletions(-) diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index 711854c23c..bc7b0d37af 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -46,6 +46,7 @@ #include "audio.h" #include "avfilter.h" +#include "filters.h" #include "formats.h" #include "internal.h" #include "video.h" @@ -55,6 +56,7 @@ typedef struct MovieStream { AVCodecContext *codec_ctx; int64_t discontinuity_threshold; int64_t last_pts; +int got_eof; } MovieStream; typedef struct MovieContext { @@ -70,6 +72,8 @@ typedef struct MovieContext { int64_t discontinuity_threshold; int64_t ts_offset; int dec_threads; +int got_eagain; +int got_wanted; AVFormatContext *format_ctx; @@ -100,7 +104,6 @@ static const AVOption movie_options[]= { }; static int movie_config_output_props(AVFilterLink *outlink); -static int movie_request_frame(AVFilterLink *outlink); static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec) { @@ -314,7 +317,6 @@ static av_cold int movie_common_init(AVFilterContext *ctx) if (!pad.name) return AVERROR(ENOMEM); pad.config_props = movie_config_output_props; -pad.request_frame = movie_request_frame; if ((ret = ff_append_outpad_free_name(ctx, &pad)) < 0) return ret; if ( movie->st[i].st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && @@ -554,47 +556,67 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id) return 0; } -static int movie_request_frame(AVFilterLink *outlink) +static int activate(AVFilterContext *ctx) { -AVFilterContext *ctx = outlink->src; MovieContext *movie = ctx->priv; -unsigned out_id = FF_OUTLINK_IDX(outlink); +int ret = 0; + +/* check all decoders for available output */ +for (int i = 0; i < ctx->nb_outputs; i++) { +if (movie->st[i].got_eof) +continue; + +if (ff_outlink_frame_wanted(ctx->outputs[i])) +movie->got_wanted++; -while (1) { -int got_eagain = 0, got_eof = 0; -int ret = 0; +ret = movie_push_frame(ctx, i); +if (ret == AVERROR(EAGAIN)) +movie->got_eagain++; +else if (ret == AVERROR_EOF) +movie->st[i].got_eof = 1; +else if (ret < 0) +return ret; +} + +if (movie->got_eagain || movie->got_wanted) { +/* all decoders require more input -> read a new packet */ +movie->got_eagain = 0; +movie->got_wanted = 0; +ret = movie_decode_packet(ctx); +if (ret < 0 && ret != AVERROR(EAGAIN)) +return ret; +ff_filter_set_ready(ctx, 100); +return 0; +} else { +int nb_eofs = 0; -/* check all decoders for available output */ for (int i = 0; i < ctx->nb_outputs; i++) { -ret = movie_push_frame(ctx, i); -if (ret == AVERROR(EAGAIN)) -got_eagain++; -else if (ret == AVERROR_EOF) -got_eof++; -else if (ret < 0) -return ret; -else if (i == out_id) -return 0; +if (movie->st[i].got_eof) { +if (movie->loop_count == 1) +ff_outlink_set_status(ctx->outputs[i], AVERROR_EOF, movie->st[i].last_pts); +nb_eofs++; +} +} + +if (nb_eofs != ctx->nb_outputs) { +ff_filter_set_ready(ctx, 100); +return 0; } -if (got_eagain) { -/* all decoders require more input -> read a new packet */ -ret = movie_decode_packet(ctx); +if (movie->loop_count != 1) { +ret = rewind_file(ctx); if (ret < 0) return ret; -} else if (got_eof) { -/* all decoders flushed */ -if (movie->loop_count != 1) { -ret = rewind_file(ctx); -if (ret < 0) -return ret; -movie->loop_count -= movie->loop_count > 1; -av_log(ctx, AV_LOG_VERBOSE, "Stream finished, looping.\n"); -continue; -} -return AVERROR_EOF; +movie->loop_count -= movie->loop_count > 1; +av_log(ctx, AV_LOG_VERBOSE, "Stream finished, looping.\n"); +for (int i = 0; i < ctx->nb_outputs; i++) +movie->st[i].got_eof = 0; +ff_filter_set_ready(ctx, 100); } +return 0; } + +return FFERROR_NOT_READY; } static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, @@ -651,7 +673,7 @@ const AVFilter ff_avsrc_movie = { .init = movie_common_init, .uninit= movie_uninit, FILTER_QUERY_FUNC(movie_query_format
[FFmpeg-devel] [PATCH 2/2] avfilter/src_movie: add option to set decoding thread type
Signed-off-by: Paul B Mahol --- doc/filters.texi| 3 +++ libavfilter/src_movie.c | 11 +-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 636c80dbff..a13977edd8 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -29317,6 +29317,9 @@ timestamps. @item dec_threads Specifies the number of threads for decoding +@item dec_thread_type +Specifies the thread type for decoding. + @item format_opts Specify format options for the opened file. Format options can be specified as a list of @var{key}=@var{value} pairs separated by ':'. The following example diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index bc7b0d37af..08cba437bf 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -72,6 +72,7 @@ typedef struct MovieContext { int64_t discontinuity_threshold; int64_t ts_offset; int dec_threads; +int thread_type; int got_eagain; int got_wanted; @@ -99,6 +100,10 @@ static const AVOption movie_options[]= { { "loop", "set loop count", OFFSET(loop_count), AV_OPT_TYPE_INT,{.i64 = 1}, 0,INT_MAX, FLAGS }, { "discontinuity", "set discontinuity threshold", OFFSET(discontinuity_threshold), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX, FLAGS }, { "dec_threads", "set the number of threads for decoding", OFFSET(dec_threads), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS }, +{ "dec_thread_type","set the type of threads for decoding", OFFSET(thread_type), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 2, FLAGS, .unit = "thread_type" }, +{ "auto", "auto",0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, FLAGS, .unit = "thread_type" }, +{ "frame","more than one frame at once", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, FLAGS, .unit = "thread_type" }, +{ "slice","more than one part of single frame at once", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, FLAGS, .unit = "thread_type" }, { "format_opts", "set format options for the opened file", OFFSET(format_opts), AV_OPT_TYPE_DICT, {.str = NULL}, 0, 0, FLAGS}, { NULL }, }; @@ -159,7 +164,7 @@ static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec) return found; } -static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads) +static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads, int thread_type) { const AVCodec *codec; int ret; @@ -181,6 +186,8 @@ static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads) if (!dec_threads) dec_threads = ff_filter_get_nb_threads(ctx); st->codec_ctx->thread_count = dec_threads; +if (thread_type) +st->codec_ctx->thread_type = thread_type; if ((ret = avcodec_open2(st->codec_ctx, codec, NULL)) < 0) { av_log(ctx, AV_LOG_ERROR, "Failed to open codec\n"); @@ -325,7 +332,7 @@ static av_cold int movie_common_init(AVFilterContext *ctx) if (ret < 0) return ret; } -ret = open_stream(ctx, &movie->st[i], movie->dec_threads); +ret = open_stream(ctx, &movie->st[i], movie->dec_threads, movie->thread_type); if (ret < 0) return ret; } -- 2.35.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v12 0/4] Jpeg XL Patch Set
This patchset adds the Jpeg XL Image format as well as a decoder and encoder for it based on the external reference implementation library, libjxl. Lynne said she plans to add a proper parser in the near future, to provide features this (removed) one did not, e.g. finding frame boundaries and box concatenation. Changes: v12: - Remove the parser in order to avoid avpriv in the ABI - Add a lightweight version of it to avformat to help the prober - Remove the FATE test for the parser which no longer exists v11: - Fix regression I introduced in v10 with skipping boxes v10: - Make changes requested by Andreas Reinhardt from v9 v9: - v8 with a typo fix v8: - v7, but with stylistic changes as requested by Lynne and others on IRC v7: - Fully implement the parser and test it against the conformance samples Leo Izen (4): avcodec/jpegxl: add Jpeg XL image codec avcodec/libjxl: add Jpeg XL decoding via libjxl avcodec/libjxl: add Jpeg XL encoding via libjxl avformat/image2: add Jpeg XL as image2 format MAINTAINERS| 3 + configure | 6 + doc/general_contents.texi | 7 + libavcodec/Makefile| 2 + libavcodec/allcodecs.c | 2 + libavcodec/codec_desc.c| 9 + libavcodec/codec_id.h | 1 + libavcodec/libjxl.c| 70 +++ libavcodec/libjxl.h| 48 + libavcodec/libjxldec.c | 301 libavcodec/libjxlenc.c | 379 +++ libavcodec/version.h | 2 +- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/img2.c | 1 + libavformat/img2dec.c | 18 ++ libavformat/img2enc.c | 6 +- libavformat/jpegxl_probe.c | 393 + libavformat/jpegxl_probe.h | 32 +++ libavformat/mov.c | 1 + libavformat/version.h | 4 +- 21 files changed, 1281 insertions(+), 6 deletions(-) create mode 100644 libavcodec/libjxl.c create mode 100644 libavcodec/libjxl.h create mode 100644 libavcodec/libjxldec.c create mode 100644 libavcodec/libjxlenc.c create mode 100644 libavformat/jpegxl_probe.c create mode 100644 libavformat/jpegxl_probe.h -- 2.35.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v12 1/4] avcodec/jpegxl: add Jpeg XL image codec
This commit adds support to libavcodec to read encoded Jpeg XL images. Jpeg XL is intended to be an extended-life replacement to legacy mjpeg. --- MAINTAINERS | 1 + libavcodec/codec_desc.c | 9 + libavcodec/codec_id.h | 1 + libavcodec/version.h| 2 +- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 76e1332ad8..490d6643d1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -617,6 +617,7 @@ Haihao Xiang (haihao) 1F0C 31E8 B4FE F7A4 4DC1 DC99 E0F5 76D4 76FC 437F Jaikrishnan Menon 61A1 F09F 01C9 2D45 78E1 C862 25DC 8831 AF70 D368 James Almer 7751 2E8C FD94 A169 57E6 9A7A 1463 01AD 7376 59E0 Jean Delvare 7CA6 9F44 60F1 BDC4 1FD2 C858 A552 6B9B B3CD 4E6A +Leo Izen (thebombzen) B6FD 3CFC 7ACF 83FC 9137 6945 5A71 C331 FD2F A19A Loren Merritt ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE Lynne FE50 139C 6805 72CA FD52 1F8D A2FE A5F0 3F03 4464 Michael Niedermayer 9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 81f3b3c640..1b82870aaa 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1863,6 +1863,15 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("GEM Raster image"), .props = AV_CODEC_PROP_LOSSY, }, +{ +.id= AV_CODEC_ID_JPEGXL, +.type = AVMEDIA_TYPE_VIDEO, +.name = "jpegxl", +.long_name = NULL_IF_CONFIG_SMALL("JPEG XL"), +.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY | + AV_CODEC_PROP_LOSSLESS, +.mime_types= MT("image/jxl"), +}, /* various PCM "codecs" */ { diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 3ffb9bd22e..dbc4f3a208 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -308,6 +308,7 @@ enum AVCodecID { AV_CODEC_ID_SIMBIOSIS_IMX, AV_CODEC_ID_SGA_VIDEO, AV_CODEC_ID_GEM, +AV_CODEC_ID_JPEGXL, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the start of audio codecs diff --git a/libavcodec/version.h b/libavcodec/version.h index a744e7469f..26ee41eb1f 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 25 +#define LIBAVCODEC_VERSION_MINOR 26 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ -- 2.35.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v12 2/4] avcodec/libjxl: add Jpeg XL decoding via libjxl
This commit adds decoding support to libavcodec for Jpeg XL images via the external library libjxl. --- MAINTAINERS | 1 + configure | 5 + doc/general_contents.texi | 7 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c| 1 + libavcodec/libjxl.c | 70 + libavcodec/libjxl.h | 48 ++ libavcodec/libjxldec.c| 301 ++ 8 files changed, 434 insertions(+) create mode 100644 libavcodec/libjxl.c create mode 100644 libavcodec/libjxl.h create mode 100644 libavcodec/libjxldec.c diff --git a/MAINTAINERS b/MAINTAINERS index 490d6643d1..3de21d8aff 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -194,6 +194,7 @@ Codecs: libcodec2.c Tomas Härdin libdirac* David Conrad libdavs2.cHuiwen Ren + libjxl*.c, libjxl.h Leo Izen libgsm.c Michel Bardiaux libkvazaar.c Arttu Ylä-Outinen libopenh264enc.c Martin Storsjo, Linjie Fu diff --git a/configure b/configure index e4d36aa639..969b13eba3 100755 --- a/configure +++ b/configure @@ -240,6 +240,7 @@ External library support: --enable-libiec61883 enable iec61883 via libiec61883 [no] --enable-libilbc enable iLBC de/encoding via libilbc [no] --enable-libjack enable JACK audio sound server [no] + --enable-libjxl enable JPEG XL decoding via libjxl [no] --enable-libklvanc enable Kernel Labs VANC processing [no] --enable-libkvazaar enable HEVC encoding via libkvazaar [no] --enable-liblensfun enable lensfun lens correction [no] @@ -1833,6 +1834,7 @@ EXTERNAL_LIBRARY_LIST=" libiec61883 libilbc libjack +libjxl libklvanc libkvazaar libmodplug @@ -3329,6 +3331,7 @@ libgsm_ms_decoder_deps="libgsm" libgsm_ms_encoder_deps="libgsm" libilbc_decoder_deps="libilbc" libilbc_encoder_deps="libilbc" +libjxl_decoder_deps="libjxl libjxl_threads" libkvazaar_encoder_deps="libkvazaar" libmodplug_demuxer_deps="libmodplug" libmp3lame_encoder_deps="libmp3lame" @@ -6541,6 +6544,8 @@ enabled libgsm&& { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do check_lib libgsm "${gsm_hdr}" gsm_create -lgsm && break; done || die "ERROR: libgsm not found"; } enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc $pthreads_extralibs +enabled libjxl&& require_pkg_config libjxl "libjxl >= 0.7.0" jxl/decode.h JxlDecoderVersion && + require_pkg_config libjxl_threads "libjxl_threads >= 0.7.0" jxl/thread_parallel_runner.h JxlThreadParallelRunner enabled libklvanc && require libklvanc libklvanc/vanc.h klvanc_context_create -lklvanc enabled libkvazaar&& require_pkg_config libkvazaar "kvazaar >= 0.8.1" kvazaar.h kvz_api_get enabled liblensfun&& require_pkg_config liblensfun lensfun lensfun.h lf_db_new diff --git a/doc/general_contents.texi b/doc/general_contents.texi index fcd9da1b34..a893347fbe 100644 --- a/doc/general_contents.texi +++ b/doc/general_contents.texi @@ -171,6 +171,13 @@ Go to @url{https://github.com/TimothyGu/libilbc} and follow the instructions for installing the library. Then pass @code{--enable-libilbc} to configure to enable it. +@section libjxl + +JPEG XL is an image format intended to fully replace legacy JPEG for an extended +period of life. See @url{https://jpegxl.info/} for more information, and see +@url{https://github.com/libjxl/libjxl} for the library source. You can pass +@code{--enable-libjxl} to configure in order enable the libjxl wrapper. + @section libvpx FFmpeg can make use of the libvpx library for VP8/VP9 decoding and encoding. diff --git a/libavcodec/Makefile b/libavcodec/Makefile index fb8b0e824b..c6d0ae4107 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1059,6 +1059,7 @@ OBJS-$(CONFIG_LIBGSM_MS_DECODER) += libgsmdec.o OBJS-$(CONFIG_LIBGSM_MS_ENCODER) += libgsmenc.o OBJS-$(CONFIG_LIBILBC_DECODER)+= libilbc.o OBJS-$(CONFIG_LIBILBC_ENCODER)+= libilbc.o +OBJS-$(CONFIG_LIBJXL_DECODER) += libjxldec.o libjxl.o OBJS-$(CONFIG_LIBKVAZAAR_ENCODER) += libkvazaar.o OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER) += libopencore-amr.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 22d56760ec..a9cd69dfce 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -749,6 +749,7 @@ extern const FFCodec ff_libgsm_ms_encoder; extern const FFCodec ff_libgsm_ms_decoder; extern const FFCodec ff_libilbc_encoder; extern const FFCodec ff_libilbc_decoder; +extern const FFCodec ff_libjxl_decoder; extern const FFCodec ff_libmp3lame_encoder; extern const FFCodec ff_libope
[FFmpeg-devel] [PATCH v12 3/4] avcodec/libjxl: add Jpeg XL encoding via libjxl
This commit adds encoding support to libavcodec for Jpeg XL images via the external library libjxl. --- configure | 3 +- libavcodec/Makefile| 1 + libavcodec/allcodecs.c | 1 + libavcodec/libjxlenc.c | 379 + 4 files changed, 383 insertions(+), 1 deletion(-) create mode 100644 libavcodec/libjxlenc.c diff --git a/configure b/configure index 969b13eba3..85a1a8b53c 100755 --- a/configure +++ b/configure @@ -240,7 +240,7 @@ External library support: --enable-libiec61883 enable iec61883 via libiec61883 [no] --enable-libilbc enable iLBC de/encoding via libilbc [no] --enable-libjack enable JACK audio sound server [no] - --enable-libjxl enable JPEG XL decoding via libjxl [no] + --enable-libjxl enable JPEG XL de/encoding via libjxl [no] --enable-libklvanc enable Kernel Labs VANC processing [no] --enable-libkvazaar enable HEVC encoding via libkvazaar [no] --enable-liblensfun enable lensfun lens correction [no] @@ -3332,6 +3332,7 @@ libgsm_ms_encoder_deps="libgsm" libilbc_decoder_deps="libilbc" libilbc_encoder_deps="libilbc" libjxl_decoder_deps="libjxl libjxl_threads" +libjxl_encoder_deps="libjxl libjxl_threads" libkvazaar_encoder_deps="libkvazaar" libmodplug_demuxer_deps="libmodplug" libmp3lame_encoder_deps="libmp3lame" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index c6d0ae4107..e18ad872b4 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1060,6 +1060,7 @@ OBJS-$(CONFIG_LIBGSM_MS_ENCODER) += libgsmenc.o OBJS-$(CONFIG_LIBILBC_DECODER)+= libilbc.o OBJS-$(CONFIG_LIBILBC_ENCODER)+= libilbc.o OBJS-$(CONFIG_LIBJXL_DECODER) += libjxldec.o libjxl.o +OBJS-$(CONFIG_LIBJXL_ENCODER) += libjxlenc.o libjxl.o OBJS-$(CONFIG_LIBKVAZAAR_ENCODER) += libkvazaar.o OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER) += libopencore-amr.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index a9cd69dfce..db92fb7af5 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -750,6 +750,7 @@ extern const FFCodec ff_libgsm_ms_decoder; extern const FFCodec ff_libilbc_encoder; extern const FFCodec ff_libilbc_decoder; extern const FFCodec ff_libjxl_decoder; +extern const FFCodec ff_libjxl_encoder; extern const FFCodec ff_libmp3lame_encoder; extern const FFCodec ff_libopencore_amrnb_encoder; extern const FFCodec ff_libopencore_amrnb_decoder; diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c new file mode 100644 index 00..deacc0f1f8 --- /dev/null +++ b/libavcodec/libjxlenc.c @@ -0,0 +1,379 @@ +/* + * JPEG XL encoding support via libjxl + * Copyright (c) 2021 Leo Izen + * + * 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 + */ + +/** + * @file + * JPEG XL encoder using libjxl + */ + +#include "libavutil/avutil.h" +#include "libavutil/error.h" +#include "libavutil/frame.h" +#include "libavutil/libm.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" +#include "libavutil/pixfmt.h" +#include "libavutil/version.h" + +#include "avcodec.h" +#include "codec_internal.h" + +#include +#include +#include "libjxl.h" + +typedef struct LibJxlEncodeContext { +AVClass *class; +void *runner; +JxlEncoder *encoder; +JxlEncoderFrameSettings *options; +int effort; +float distance; +int modular; +uint8_t *buffer; +size_t buffer_size; +} LibJxlEncodeContext; + +/** + * Map a quality setting for -qscale roughly from libjpeg + * quality numbers to libjxl's butteraugli distance for + * photographic content. + * + * Setting distance explicitly is preferred, but this will + * allow qscale to be used as a fallback. + * + * This function is continuous and injective on [0, 100] which + * makes it monotonic. + * + * @param quality 0.0 to 100.0 quality setting, libjpeg quality + * @return Butteraugli distance between 0.0 and 15.0 + */ +static float quality_to_distance(float quality) +{ +if (quality >= 100.0) +return 0.0; +else if (quality >= 90.0) +return (100.0 - quality) * 0.10; +else if (quality >= 30.0) +return 0.1 + (100.0 - quality) * 0.09; +
[FFmpeg-devel] [PATCH v12 4/4] avformat/image2: add Jpeg XL as image2 format
This commit adds support to libavformat for muxing and demuxing Jpeg XL images as image2 streams. --- MAINTAINERS| 1 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/img2.c | 1 + libavformat/img2dec.c | 18 ++ libavformat/img2enc.c | 6 +- libavformat/jpegxl_probe.c | 393 + libavformat/jpegxl_probe.h | 32 +++ libavformat/mov.c | 1 + libavformat/version.h | 4 +- 10 files changed, 453 insertions(+), 5 deletions(-) create mode 100644 libavformat/jpegxl_probe.c create mode 100644 libavformat/jpegxl_probe.h diff --git a/MAINTAINERS b/MAINTAINERS index 3de21d8aff..0adbcde97f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -439,6 +439,7 @@ Muxers/Demuxers: ipmovie.c Mike Melanson ircam*Paul B Mahol iss.c Stefan Gehrer + jpegxl_probe.*Leo Izen jvdec.c Peter Ross kvag.cZane van Iperen libmodplug.c Clément Bœsch diff --git a/libavformat/Makefile b/libavformat/Makefile index d7182d6bd8..beecdf5a66 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -272,6 +272,7 @@ OBJS-$(CONFIG_IMAGE_GIF_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_J2K_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_JPEG_PIPE_DEMUXER)+= img2dec.o img2.o OBJS-$(CONFIG_IMAGE_JPEGLS_PIPE_DEMUXER) += img2dec.o img2.o +OBJS-$(CONFIG_IMAGE_JPEGXL_PIPE_DEMUXER) += img2dec.o img2.o jpegxl_probe.o OBJS-$(CONFIG_IMAGE_PAM_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_PBM_PIPE_DEMUXER) += img2dec.o img2.o OBJS-$(CONFIG_IMAGE_PCX_PIPE_DEMUXER) += img2dec.o img2.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 587ad59b3c..941f3643f8 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -510,6 +510,7 @@ extern const AVInputFormat ff_image_gif_pipe_demuxer; extern const AVInputFormat ff_image_j2k_pipe_demuxer; extern const AVInputFormat ff_image_jpeg_pipe_demuxer; extern const AVInputFormat ff_image_jpegls_pipe_demuxer; +extern const AVInputFormat ff_image_jpegxl_pipe_demuxer; extern const AVInputFormat ff_image_pam_pipe_demuxer; extern const AVInputFormat ff_image_pbm_pipe_demuxer; extern const AVInputFormat ff_image_pcx_pipe_demuxer; diff --git a/libavformat/img2.c b/libavformat/img2.c index 4153102c92..13b1b997b8 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -87,6 +87,7 @@ const IdStrMap ff_img_tags[] = { { AV_CODEC_ID_GEM,"img" }, { AV_CODEC_ID_GEM,"ximg" }, { AV_CODEC_ID_GEM,"timg" }, +{ AV_CODEC_ID_JPEGXL, "jxl" }, { AV_CODEC_ID_NONE, NULL } }; diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c index b9c06c5b54..560d464dff 100644 --- a/libavformat/img2dec.c +++ b/libavformat/img2dec.c @@ -36,6 +36,7 @@ #include "avio_internal.h" #include "internal.h" #include "img2.h" +#include "jpegxl_probe.h" #include "libavcodec/mjpeg.h" #include "libavcodec/xwd.h" #include "subtitles.h" @@ -836,6 +837,22 @@ static int jpegls_probe(const AVProbeData *p) return 0; } +static int jpegxl_probe(const AVProbeData *p) +{ +const uint8_t *b = p->buf; + +/* ISOBMFF-based container */ +/* 0x4a584c20 == "JXL " */ +if (AV_RL64(b) == FF_JPEGXL_CONTAINER_SIGNATURE_LE) +return AVPROBE_SCORE_EXTENSION + 1; +/* Raw codestreams all start with 0xff0a */ +if (AV_RL16(b) != FF_JPEGXL_CODESTREAM_SIGNATURE_LE) +return 0; +if (ff_jpegxl_verify_codestream_header(p->buf, p->buf_size) >= 0) +return AVPROBE_SCORE_MAX - 2; +return 0; +} + static int pcx_probe(const AVProbeData *p) { const uint8_t *b = p->buf; @@ -1165,6 +1182,7 @@ IMAGEAUTO_DEMUXER(gif, GIF) IMAGEAUTO_DEMUXER_EXT(j2k, JPEG2000, J2K) IMAGEAUTO_DEMUXER_EXT(jpeg, MJPEG, JPEG) IMAGEAUTO_DEMUXER(jpegls,JPEGLS) +IMAGEAUTO_DEMUXER(jpegxl,JPEGXL) IMAGEAUTO_DEMUXER(pam, PAM) IMAGEAUTO_DEMUXER(pbm, PBM) IMAGEAUTO_DEMUXER(pcx, PCX) diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c index 9b3b8741c8..e6ec6a50aa 100644 --- a/libavformat/img2enc.c +++ b/libavformat/img2enc.c @@ -263,9 +263,9 @@ static const AVClass img2mux_class = { const AVOutputFormat ff_image2_muxer = { .name = "image2", .long_name = NULL_IF_CONFIG_SMALL("image2 sequence"), -.extensions = "bmp,dpx,exr,jls,jpeg,jpg,ljpg,pam,pbm,pcx,pfm,pgm,pgmyuv,png," - "ppm,sgi,tga,tif,tiff,jp2,j2c,j2k,xwd,sun,ras,rs,im1,im8,im24," - "sunras,xbm,xface,pix,y", +.extensions = "bmp,dpx,exr,jls,jpeg,jpg,jxl,ljpg,pam,pbm,pcx,pfm,pgm,pgmyuv," + "png,ppm,sgi,tga,tif,tiff,jp2,j2c,j2k,xwd,s
[FFmpeg-devel] [PATCH 1/2] avformat/ape: more bits in size for less overflows
Fixes: signed integer overflow: 2147483647 + 3 cannot be represented in type 'int' Fixes: 46184/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-4678059519770624 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/ape.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavformat/ape.c b/libavformat/ape.c index f5e50046e8..bf1254e7bd 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -42,8 +42,8 @@ typedef struct APEFrame { int64_t pos; +int64_t size; int nblocks; -int size; int skip; int64_t pts; } APEFrame; @@ -128,7 +128,7 @@ static void ape_dumpinfo(AVFormatContext * s, APEContext * ape_ctx) av_log(s, AV_LOG_DEBUG, "\nFrames\n\n"); for (i = 0; i < ape_ctx->totalframes; i++) -av_log(s, AV_LOG_DEBUG, "%8d %8"PRId64" %8d (%d samples)\n", i, +av_log(s, AV_LOG_DEBUG, "%8d %8"PRId64" %8"PRId64" (%d samples)\n", i, ape_ctx->frames[i].pos, ape_ctx->frames[i].size, ape_ctx->frames[i].nblocks); @@ -146,7 +146,8 @@ static int ape_read_header(AVFormatContext * s) AVStream *st; uint32_t tag; int i, ret; -int total_blocks, final_size = 0; +int total_blocks; +int64_t final_size = 0; int64_t pts, file_size; /* Skip any leading junk such as id3v2 tags */ @@ -387,7 +388,7 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt) if (ape->frames[ape->currentframe].size <= 0 || ape->frames[ape->currentframe].size > INT_MAX - extra_size) { -av_log(s, AV_LOG_ERROR, "invalid packet size: %d\n", +av_log(s, AV_LOG_ERROR, "invalid packet size: %8"PRId64"\n", ape->frames[ape->currentframe].size); ape->currentframe++; return AVERROR(EIO); -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] avcodec/binkaudio: Clear state on EAGAIN
Its not supported to maintain a frame as receive_frame() argument over multiple calls Fixes: store to null pointer of type 'FFTSample' (aka 'float') Fixes: 46231/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BINKAUDIO_DCT_fuzzer-6276566037954560 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/binkaudio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c index c4f3e743e2..f8cdc9f0cf 100644 --- a/libavcodec/binkaudio.c +++ b/libavcodec/binkaudio.c @@ -301,8 +301,10 @@ static int binkaudio_receive_frame(AVCodecContext *avctx, AVFrame *frame) again: if (!s->pkt->data) { ret = ff_decode_get_packet(avctx, s->pkt); -if (ret < 0) +if (ret < 0) { +s->ch_offset = 0; return ret; +} if (s->pkt->size < 4) { av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".