Re: [FFmpeg-devel] [PATCH] lavfi/vf_vpp_qsv: fix duration in pass-through mode
On Ma, 2023-07-24 at 10:36 +0800, Xiang, Haihao wrote: > From: Haihao Xiang > > Signed-off-by: Haihao Xiang > --- > libavfilter/vf_vpp_qsv.c | 5 + > 1 file changed, 5 insertions(+) > > diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c > index 334a86551b..be9bf54743 100644 > --- a/libavfilter/vf_vpp_qsv.c > +++ b/libavfilter/vf_vpp_qsv.c > @@ -582,6 +582,11 @@ static int activate(AVFilterContext *ctx) > if (in->pts != AV_NOPTS_VALUE) > in->pts = av_rescale_q(in->pts, inlink->time_base, outlink- > >time_base); > > + if (outlink->frame_rate.num && outlink->frame_rate.den) > + in->duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), > outlink->time_base); > + else > + in->duration = 0; > + > ret = ff_filter_frame(outlink, in); > if (ret < 0) > return ret; Will apply - 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] lavu/hwcontext_qsv: silence the warning
On Ma, 2023-07-24 at 10:41 +0800, Xiang, Haihao wrote: > From: Haihao Xiang > > libavutil/hwcontext_qsv.c: In function ‘qsv_map_to’: > libavutil/hwcontext_qsv.c:1905:47: warning: cast from pointer to integer > of different size [-Wpointer-to-int-cast] > > Signed-off-by: Haihao Xiang > --- > libavutil/hwcontext_qsv.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c > index d4b564ba2d..1bfda9e69b 100644 > --- a/libavutil/hwcontext_qsv.c > +++ b/libavutil/hwcontext_qsv.c > @@ -1902,7 +1902,7 @@ static int qsv_map_to(AVHWFramesContext *dst_ctx, > case AV_PIX_FMT_VAAPI: > { > mfxHDLPair *pair = (mfxHDLPair*)hwctx->surfaces[i].Data.MemId; > - if (*(VASurfaceID*)pair->first == (VASurfaceID)src->data[3]) { > + if (*(VASurfaceID*)pair->first == (VASurfaceID)(uintptr_t)src- > >data[3]) { > index = i; > break; > } Will apply, - 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".
[FFmpeg-devel] [PATCH 1/4] lavfi/qsvvpp: add set_frame_ext_params callback
From: Haihao Xiang This allows we add mfxExtBuffer per frame later. Signed-off-by: Haihao Xiang --- libavfilter/qsvvpp.c | 67 +--- libavfilter/qsvvpp.h | 10 +++ 2 files changed, 61 insertions(+), 16 deletions(-) diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index a03de05d9c..3c8dfea16a 100644 --- a/libavfilter/qsvvpp.c +++ b/libavfilter/qsvvpp.c @@ -731,6 +731,11 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) return 0; } +static int set_frame_ext_params_null(AVFilterContext *ctx, const AVFrame *in, AVFrame *out, QSVVPPFrameParam *fp) +{ +return 0; +} + int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param) { int i; @@ -742,6 +747,10 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param) s->filter_frame = ff_filter_frame; s->out_sw_format = param->out_sw_format; +s->set_frame_ext_params = param->set_frame_ext_params; +if (!s->set_frame_ext_params) +s->set_frame_ext_params = set_frame_ext_params_null; + /* create the vpp session */ ret = init_vpp_session(avctx, s); if (ret < 0) @@ -868,27 +877,53 @@ failed: static int qsvvpp_init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s, const QSVFrame *in, QSVFrame *out) { int ret; +mfxExtBuffer *ext_param[QSVVPP_MAX_FRAME_EXTBUFS]; +QSVVPPFrameParam fp = { 0, ext_param }; -if (s->vpp_initted) -return 0; +ret = s->set_frame_ext_params(avctx, in->frame, out->frame, &fp); +if (ret) +return ret; -s->vpp_param.vpp.In.PicStruct = in->surface.Info.PicStruct; -s->vpp_param.vpp.Out.PicStruct = out->surface.Info.PicStruct; +if (fp.num_ext_buf) { +av_freep(&s->ext_buffers); +s->nb_ext_buffers = s->nb_seq_buffers + fp.num_ext_buf; -/* Query VPP params again, including params for frame */ -ret = MFXVideoVPP_Query(s->session, &s->vpp_param, &s->vpp_param); -if (ret < 0) -return ff_qsvvpp_print_error(avctx, ret, "Error querying VPP params"); -else if (ret > 0) -ff_qsvvpp_print_warning(avctx, ret, "Warning When querying VPP params"); +s->ext_buffers = av_calloc(s->nb_ext_buffers, sizeof(*s->ext_buffers)); +if (!s->ext_buffers) +return AVERROR(ENOMEM); -ret = MFXVideoVPP_Init(s->session, &s->vpp_param); -if (ret < 0) -return ff_qsvvpp_print_error(avctx, ret, "Failed to create a qsvvpp"); -else if (ret > 0) -ff_qsvvpp_print_warning(avctx, ret, "Warning When creating qsvvpp"); +memcpy(&s->ext_buffers[0], s->seq_buffers, s->nb_seq_buffers * sizeof(*s->seq_buffers)); +memcpy(&s->ext_buffers[s->nb_seq_buffers], fp.ext_buf, fp.num_ext_buf * sizeof(*fp.ext_buf)); +s->vpp_param.ExtParam= s->ext_buffers; +s->vpp_param.NumExtParam = s->nb_ext_buffers; +} + +if (!s->vpp_initted) { +s->vpp_param.vpp.In.PicStruct = in->surface.Info.PicStruct; +s->vpp_param.vpp.Out.PicStruct = out->surface.Info.PicStruct; + +/* Query VPP params again, including params for frame */ +ret = MFXVideoVPP_Query(s->session, &s->vpp_param, &s->vpp_param); +if (ret < 0) +return ff_qsvvpp_print_error(avctx, ret, "Error querying VPP params"); +else if (ret > 0) +ff_qsvvpp_print_warning(avctx, ret, "Warning When querying VPP params"); + +ret = MFXVideoVPP_Init(s->session, &s->vpp_param); +if (ret < 0) +return ff_qsvvpp_print_error(avctx, ret, "Failed to create a qsvvpp"); +else if (ret > 0) +ff_qsvvpp_print_warning(avctx, ret, "Warning When creating qsvvpp"); -s->vpp_initted = 1; +s->vpp_initted = 1; +} else if (fp.num_ext_buf) { +ret = MFXVideoVPP_Reset(s->session, &s->vpp_param); +if (ret < 0) { +ret = ff_qsvvpp_print_error(avctx, ret, "Failed to reset session for qsvvpp"); +return ret; +} else if (ret > 0) +ff_qsvvpp_print_warning(avctx, ret, "Warning When resetting session for qsvvpp"); +} return 0; } diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h index fba5f037d4..4eea7a46c7 100644 --- a/libavfilter/qsvvpp.h +++ b/libavfilter/qsvvpp.h @@ -52,11 +52,20 @@ typedef struct QSVFrame { int queued; } QSVFrame; +#define QSVVPP_MAX_FRAME_EXTBUFS8 + +typedef struct QSVVPPFrameParam { +/* To fill with MFX enhanced filter configurations */ +int num_ext_buf; +mfxExtBuffer **ext_buf; +} QSVVPPFrameParam; + typedef struct QSVVPPContext { const AVClass *class; mfxSession session; int (*filter_frame) (AVFilterLink *outlink, AVFrame *frame); /**< callback */ +int (*set_frame_ext_params)(AVFilterContext *ctx, const AVFrame *in, AVFrame *out, QSVVPPFrameParam *fp); /**< callbak */ enum AVPixelFormat out_sw_format; /**< Real output format */ mfxVideoPa
[FFmpeg-devel] [PATCH 2/4] lavfi/vf_vpp_qsv: take input color properties into account
From: Haihao Xiang Signed-off-by: Haihao Xiang --- libavfilter/vf_vpp_qsv.c | 36 1 file changed, 36 insertions(+) diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c index 334a86551b..bf4264efc5 100644 --- a/libavfilter/vf_vpp_qsv.c +++ b/libavfilter/vf_vpp_qsv.c @@ -58,6 +58,10 @@ typedef struct VPPContext{ mfxExtVPPRotation rotation_conf; mfxExtVPPMirroring mirroring_conf; mfxExtVPPScaling scale_conf; +#if QSV_ONEVPL +/** Video signal info attached on the input frame */ +mfxExtVideoSignalInfo invsi_conf; +#endif /** * New dimensions. Special values are: @@ -344,6 +348,37 @@ static mfxStatus get_mfx_version(const AVFilterContext *ctx, mfxVersion *mfx_ver return MFXQueryVersion(device_hwctx->session, mfx_version); } +static int vpp_set_frame_ext_params(AVFilterContext *ctx, const AVFrame *in, AVFrame *out, QSVVPPFrameParam *fp) +{ +#if QSV_ONEVPL +VPPContext *vpp = ctx->priv; +QSVVPPContext *qsvvpp = &vpp->qsv; +mfxExtVideoSignalInfo invsi_conf; + +fp->num_ext_buf = 0; + +if (!in || +!QSV_RUNTIME_VERSION_ATLEAST(qsvvpp->ver, 2, 0)) +return 0; + +memset(&invsi_conf, 0, sizeof(mfxExtVideoSignalInfo)); +invsi_conf.Header.BufferId = MFX_EXTBUFF_VIDEO_SIGNAL_INFO_IN; +invsi_conf.Header.BufferSz = sizeof(mfxExtVideoSignalInfo); +invsi_conf.VideoFullRange = (in->color_range == AVCOL_RANGE_JPEG); +invsi_conf.ColourPrimaries = (in->color_primaries == AVCOL_PRI_UNSPECIFIED) ? AVCOL_PRI_BT709 : in->color_primaries; +invsi_conf.TransferCharacteristics = (in->color_trc == AVCOL_TRC_UNSPECIFIED) ? AVCOL_TRC_BT709 : in->color_trc; +invsi_conf.MatrixCoefficients = (in->colorspace == AVCOL_SPC_UNSPECIFIED) ? AVCOL_SPC_BT709 : in->colorspace; +invsi_conf.ColourDescriptionPresent = 1; + +if (memcmp(&vpp->invsi_conf, &invsi_conf, sizeof(mfxExtVideoSignalInfo))) { +vpp->invsi_conf = invsi_conf; +fp->ext_buf[fp->num_ext_buf++] = (mfxExtBuffer*)&vpp->invsi_conf; +} +#endif + +return 0; +} + static int config_output(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; @@ -361,6 +396,7 @@ static int config_output(AVFilterLink *outlink) outlink->time_base = av_inv_q(vpp->framerate); param.filter_frame = NULL; +param.set_frame_ext_params = vpp_set_frame_ext_params; param.num_ext_buf = 0; param.ext_buf = ext_buf; -- 2.34.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 3/4] lavfi/vf_vpp_qsv: set color properties for output
From: Haihao Xiang User may set color range / matrix coefficient set / primaries / transfer characteristics for output. Signed-off-by: Haihao Xiang --- libavfilter/vf_vpp_qsv.c | 90 ++-- 1 file changed, 87 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c index bf4264efc5..795b859de1 100644 --- a/libavfilter/vf_vpp_qsv.c +++ b/libavfilter/vf_vpp_qsv.c @@ -61,6 +61,8 @@ typedef struct VPPContext{ #if QSV_ONEVPL /** Video signal info attached on the input frame */ mfxExtVideoSignalInfo invsi_conf; +/** Video signal info attached on the output frame */ +mfxExtVideoSignalInfo outvsi_conf; #endif /** @@ -104,6 +106,16 @@ typedef struct VPPContext{ char *ow, *oh; char *output_format_str; +/** The color properties for output */ +char *color_primaries_str; +char *color_transfer_str; +char *color_matrix_str; + +int color_range; +enum AVColorPrimaries color_primaries; +enum AVColorTransferCharacteristic color_transfer; +enum AVColorSpace color_matrix; + int has_passthrough;/* apply pass through mode if possible */ int field_rate; /* Generate output at frame rate or field rate for deinterlace mode, 0: frame, 1: field */ } VPPContext; @@ -231,6 +243,11 @@ static av_cold int vpp_preinit(AVFilterContext *ctx) vpp->contrast = 1.0; vpp->transpose = -1; +vpp->color_range = AVCOL_RANGE_UNSPECIFIED; +vpp->color_primaries = AVCOL_PRI_UNSPECIFIED; +vpp->color_transfer = AVCOL_TRC_UNSPECIFIED; +vpp->color_matrix = AVCOL_SPC_UNSPECIFIED; + vpp->has_passthrough = 1; return 0; @@ -250,6 +267,24 @@ static av_cold int vpp_init(AVFilterContext *ctx) } } +#define STRING_OPTION(var_name, func_name, default_value) do { \ +if (vpp->var_name ## _str) {\ +int var = av_ ## func_name ## _from_name(vpp->var_name ## _str); \ +if (var < 0) { \ +av_log(ctx, AV_LOG_ERROR, "Invalid %s.\n", #var_name); \ +return AVERROR(EINVAL); \ +} \ +vpp->var_name = var;\ +} else {\ +vpp->var_name = default_value; \ +} \ +} while (0) + +STRING_OPTION(color_primaries, color_primaries, AVCOL_PRI_UNSPECIFIED); +STRING_OPTION(color_transfer, color_transfer, AVCOL_TRC_UNSPECIFIED); +STRING_OPTION(color_matrix,color_space, AVCOL_SPC_UNSPECIFIED); + +#undef STRING_OPTION return 0; } @@ -353,11 +388,11 @@ static int vpp_set_frame_ext_params(AVFilterContext *ctx, const AVFrame *in, AVF #if QSV_ONEVPL VPPContext *vpp = ctx->priv; QSVVPPContext *qsvvpp = &vpp->qsv; -mfxExtVideoSignalInfo invsi_conf; +mfxExtVideoSignalInfo invsi_conf, outvsi_conf; fp->num_ext_buf = 0; -if (!in || +if (!in || !out || !QSV_RUNTIME_VERSION_ATLEAST(qsvvpp->ver, 2, 0)) return 0; @@ -370,9 +405,32 @@ static int vpp_set_frame_ext_params(AVFilterContext *ctx, const AVFrame *in, AVF invsi_conf.MatrixCoefficients = (in->colorspace == AVCOL_SPC_UNSPECIFIED) ? AVCOL_SPC_BT709 : in->colorspace; invsi_conf.ColourDescriptionPresent = 1; -if (memcmp(&vpp->invsi_conf, &invsi_conf, sizeof(mfxExtVideoSignalInfo))) { +if (vpp->color_range != AVCOL_RANGE_UNSPECIFIED) +out->color_range = vpp->color_range; +if (vpp->color_primaries != AVCOL_PRI_UNSPECIFIED) +out->color_primaries = vpp->color_primaries; +if (vpp->color_transfer != AVCOL_TRC_UNSPECIFIED) +out->color_trc = vpp->color_transfer; +if (vpp->color_matrix != AVCOL_SPC_UNSPECIFIED) +out->colorspace = vpp->color_matrix; + +memset(&outvsi_conf, 0, sizeof(mfxExtVideoSignalInfo)); +outvsi_conf.Header.BufferId = MFX_EXTBUFF_VIDEO_SIGNAL_INFO_OUT; +outvsi_conf.Header.BufferSz = sizeof(mfxExtVideoSignalInfo); +outvsi_conf.VideoFullRange = (out->color_range == AVCOL_RANGE_JPEG); +outvsi_conf.ColourPrimaries = (out->color_primaries == AVCOL_PRI_UNSPECIFIED) ? AVCOL_PRI_BT709 : out->color_primaries; +outvsi_conf.TransferCharacteristics = (out->color_trc == AVCOL_TRC_UNSPECIFIED) ? AVCOL_TRC_BT709 : out->color_trc; +outvsi_conf.MatrixCoefficients = (out->colorspace == AVCOL_SPC_UNSPECIFIED) ? AVCOL_SPC_BT709 : out->colorspace; +outvsi_conf.ColourDescriptionPresent = 1; + +if (memcmp(&vpp->invsi_conf, &invsi_conf, sizeof(mfxExtVideoSignalInfo)) || +memcmp(&vpp->outvsi_conf, &outvsi_conf, sizeof(mfxEx
[FFmpeg-devel] [PATCH 4/4] lavfi/vf_vpp_qsv: perform conversion from HDR to SDR
From: Haihao Xiang option tonemap is added to disable / enable tonemapping. By default tonemapping is not performed. Signed-off-by: Haihao Xiang --- libavfilter/vf_vpp_qsv.c | 88 1 file changed, 88 insertions(+) diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c index 795b859de1..615ff5b0d4 100644 --- a/libavfilter/vf_vpp_qsv.c +++ b/libavfilter/vf_vpp_qsv.c @@ -31,6 +31,7 @@ #include "libavutil/hwcontext_qsv.h" #include "libavutil/pixdesc.h" #include "libavutil/mathematics.h" +#include "libavutil/mastering_display_metadata.h" #include "formats.h" #include "internal.h" @@ -63,6 +64,9 @@ typedef struct VPPContext{ mfxExtVideoSignalInfo invsi_conf; /** Video signal info attached on the output frame */ mfxExtVideoSignalInfo outvsi_conf; +/** HDR parameters attached on the input frame */ +mfxExtMasteringDisplayColourVolume mdcv_conf; +mfxExtContentLightLevelInfo clli_conf; #endif /** @@ -118,6 +122,7 @@ typedef struct VPPContext{ int has_passthrough;/* apply pass through mode if possible */ int field_rate; /* Generate output at frame rate or field rate for deinterlace mode, 0: frame, 1: field */ +int tonemap;/* 1: perform tonemapping if the input has HDR metadata, 0: always disable tonemapping */ } VPPContext; static const char *const var_names[] = { @@ -389,6 +394,10 @@ static int vpp_set_frame_ext_params(AVFilterContext *ctx, const AVFrame *in, AVF VPPContext *vpp = ctx->priv; QSVVPPContext *qsvvpp = &vpp->qsv; mfxExtVideoSignalInfo invsi_conf, outvsi_conf; +mfxExtMasteringDisplayColourVolume mdcv_conf; +mfxExtContentLightLevelInfo clli_conf; +AVFrameSideData *sd; +int tm = 0; fp->num_ext_buf = 0; @@ -405,6 +414,73 @@ static int vpp_set_frame_ext_params(AVFilterContext *ctx, const AVFrame *in, AVF invsi_conf.MatrixCoefficients = (in->colorspace == AVCOL_SPC_UNSPECIFIED) ? AVCOL_SPC_BT709 : in->colorspace; invsi_conf.ColourDescriptionPresent = 1; +memset(&mdcv_conf, 0, sizeof(mfxExtMasteringDisplayColourVolume)); +sd = av_frame_get_side_data(in, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); +if (vpp->tonemap && sd) { +AVMasteringDisplayMetadata *mdm = (AVMasteringDisplayMetadata *)sd->data; + +if (mdm->has_primaries && mdm->has_luminance) { +const int mapping[3] = {1, 2, 0}; +const int chroma_den = 5; +const int luma_den = 1; +int i; + +mdcv_conf.Header.BufferId = MFX_EXTBUFF_MASTERING_DISPLAY_COLOUR_VOLUME_IN; +mdcv_conf.Header.BufferSz = sizeof(mfxExtMasteringDisplayColourVolume); + +for (i = 0; i < 3; i++) { +const int j = mapping[i]; + +mdcv_conf.DisplayPrimariesX[i] = +FFMIN(lrint(chroma_den * +av_q2d(mdm->display_primaries[j][0])), + chroma_den); +mdcv_conf.DisplayPrimariesY[i] = +FFMIN(lrint(chroma_den * +av_q2d(mdm->display_primaries[j][1])), + chroma_den); +} + +mdcv_conf.WhitePointX = +FFMIN(lrint(chroma_den * av_q2d(mdm->white_point[0])), + chroma_den); +mdcv_conf.WhitePointY = +FFMIN(lrint(chroma_den * av_q2d(mdm->white_point[1])), + chroma_den); + +/* MaxDisplayMasteringLuminance is in the unit of 1 nits however + * MinDisplayMasteringLuminance is in the unit of 0.0001 nits + */ +mdcv_conf.MaxDisplayMasteringLuminance = +lrint(av_q2d(mdm->max_luminance)); +mdcv_conf.MinDisplayMasteringLuminance = +lrint(luma_den * av_q2d(mdm->min_luminance)); +tm = 1; +} +} + +memset(&clli_conf, 0, sizeof(mfxExtContentLightLevelInfo)); +sd = av_frame_get_side_data(in, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); +if (vpp->tonemap && sd) { +AVContentLightMetadata *clm = (AVContentLightMetadata *)sd->data; + +clli_conf.Header.BufferId = MFX_EXTBUFF_CONTENT_LIGHT_LEVEL_INFO; +clli_conf.Header.BufferSz = sizeof(mfxExtContentLightLevelInfo); +clli_conf.MaxContentLightLevel= FFMIN(clm->MaxCLL, 65535); +clli_conf.MaxPicAverageLightLevel = FFMIN(clm->MaxFALL, 65535); +tm = 1; +} + +if (tm) { +av_frame_remove_side_data(out, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); +av_frame_remove_side_data(out, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); + +out->color_primaries = AVCOL_PRI_BT709; +out->color_trc = AVCOL_TRC_BT709; +out->colorspace = AVCOL_SPC_BT709; +out->color_range = AVCOL_RANGE_MPEG; +} + if (vpp->color_range !=
Re: [FFmpeg-devel] [PATCH 2/2] lavc/avfft: deprecate the API
Jul 26, 2023, 01:17 by mich...@niedermayer.cc: > On Tue, Jul 25, 2023 at 12:47:12AM +0200, Lynne wrote: > >> This deprecates the currently unused API. >> --- >> doc/APIchanges | 5 + >> libavcodec/avfft.h | 31 +++ >> libavcodec/tests/fft.c | 4 >> libavcodec/version.h | 2 +- >> libavcodec/version_major.h | 2 ++ >> 5 files changed, 43 insertions(+), 1 deletion(-) >> > > not sure i missed a patch but this breaks > "make testprogs" here > > CClibavcodec/tests/avfft.o > In file included from /usr/include/math.h:37:0, > from libavcodec/tests/fft.c:34, > from libavcodec/tests/avfft.c:25: > /usr/include/x86_64-linux-gnu/bits/types.h:30:1: error: expected ‘=’, ‘,’, > ‘;’, ‘asm’ or ‘__attribute__’ before ‘typedef’ > typedef unsigned char __u_char; > ^~~ > > thx > Thanks, fixed in attached v3. >From 4573f20278b817e4a2d59f010b02f467171fbf42 Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 24 Jul 2023 23:55:55 +0200 Subject: [PATCH v3 2/2] lavc/avfft: deprecate the API This deprecates the currently unused API. --- doc/APIchanges | 5 + libavcodec/avfft.h | 31 +++ libavcodec/tests/fft.c | 6 ++ libavcodec/version.h | 2 +- libavcodec/version_major.h | 2 ++ 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 5afe8bcb75..6f6c3b4aa6 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,11 @@ The last version increases of all libraries were on 2023-02-09 API changes, most recent first: +2023-07-xx - xx - lavc 60.23.100 - avfft.h + The entire header will be deprecated and removed in two major bumps. + For a replacement to av_dct, av_rdft, av_fft and av_mdct, use + the new API from libavutil/tx.h. + 2023-07-xx - xx - lavc 60 - avcodec.h Deprecate AV_CODEC_FLAG_DROPCHANGED without replacement. diff --git a/libavcodec/avfft.h b/libavcodec/avfft.h index 0c0f9b8d8d..e3a0da1eb9 100644 --- a/libavcodec/avfft.h +++ b/libavcodec/avfft.h @@ -19,6 +19,10 @@ #ifndef AVCODEC_AVFFT_H #define AVCODEC_AVFFT_H +#include "libavutil/attributes.h" +#include "version_major.h" +#if FF_API_AVFFT + /** * @file * @ingroup lavc_fft @@ -44,26 +48,42 @@ typedef struct FFTContext FFTContext; * Set up a complex FFT. * @param nbits log2 of the length of the input array * @param inverse if 0 perform the forward transform, if 1 perform the inverse + * @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_FFT */ +attribute_deprecated FFTContext *av_fft_init(int nbits, int inverse); /** * Do the permutation needed BEFORE calling ff_fft_calc(). + * @deprecated without replacement */ +attribute_deprecated void av_fft_permute(FFTContext *s, FFTComplex *z); /** * Do a complex FFT with the parameters defined in av_fft_init(). The * input data must be permuted before. No 1.0/sqrt(n) normalization is done. + * @deprecated use the av_tx_fn value returned by av_tx_init, which also does permutation */ +attribute_deprecated void av_fft_calc(FFTContext *s, FFTComplex *z); +attribute_deprecated void av_fft_end(FFTContext *s); +/** + * @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_MDCT, + * with a flag of AV_TX_FULL_IMDCT for a replacement to av_imdct_calc. + */ +attribute_deprecated FFTContext *av_mdct_init(int nbits, int inverse, double scale); +attribute_deprecated void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); +attribute_deprecated void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input); +attribute_deprecated void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); +attribute_deprecated void av_mdct_end(FFTContext *s); /* Real Discrete Fourier Transform */ @@ -81,9 +101,14 @@ typedef struct RDFTContext RDFTContext; * Set up a real FFT. * @param nbits log2 of the length of the input array * @param trans the type of transform + * + * @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_RDFT */ +attribute_deprecated RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans); +attribute_deprecated void av_rdft_calc(RDFTContext *s, FFTSample *data); +attribute_deprecated void av_rdft_end(RDFTContext *s); /* Discrete Cosine Transform */ @@ -106,13 +131,19 @@ enum DCTTransformType { * @param typethe type of transform * * @note the first element of the input of DST-I is ignored + * + * @deprecated use av_tx_init from libavutil/tx.h with an appropriate type of AV_TX_FLOAT_DCT */ +attribute_deprecated DCTContext *av_dct_init(int nbits, enum DCTTransformType type); +attribute_deprecated void av_dct_calc(DCTContext *s, FFTSample *data); +attribute_deprecated void av_dct_end (DCTContext *s); /** * @} */ +#endif /* FF_API_AVFFT */ #endif /* AVCODEC_AVFFT_H */
[FFmpeg-devel] [PATCH 1/3] avfft: wrap lavu/tx instead of ff_fft
Patch attached. >From 3a595d6f177617ce89cc2709eca61b7cf486ce22 Mon Sep 17 00:00:00 2001 From: Lynne Date: Thu, 10 Nov 2022 11:23:38 +0100 Subject: [PATCH 1/3] avfft: wrap lavu/tx instead of ff_fft --- libavcodec/avfft.c | 40 +++- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/libavcodec/avfft.c b/libavcodec/avfft.c index 2200f37708..e4b19af272 100644 --- a/libavcodec/avfft.c +++ b/libavcodec/avfft.c @@ -18,38 +18,60 @@ #include "libavutil/attributes.h" #include "libavutil/mem.h" +#include "libavutil/tx.h" #include "avfft.h" #include "fft.h" #include "rdft.h" #include "dct.h" +typedef struct AVTXWrapper { +AVTXContext *ctx; +av_tx_fn fn; + +AVTXContext *ctx2; +av_tx_fn fn2; + +ptrdiff_t stride; +} AVTXWrapper; + /* FFT */ FFTContext *av_fft_init(int nbits, int inverse) { -FFTContext *s = av_mallocz(sizeof(*s)); - -if (s && ff_fft_init(s, nbits, inverse)) -av_freep(&s); +int ret; +float scale = 1.0f; +AVTXWrapper *s = av_malloc(sizeof(*s)); +if (!s) +return NULL; + +ret = av_tx_init(&s->ctx, &s->fn, AV_TX_FLOAT_FFT, inverse, 1 << nbits, + &scale, AV_TX_INPLACE); +if (ret < 0) { +av_free(s); +return NULL; +} -return s; +return (FFTContext *)s; } void av_fft_permute(FFTContext *s, FFTComplex *z) { -s->fft_permute(s, z); +/* Empty */ } void av_fft_calc(FFTContext *s, FFTComplex *z) { -s->fft_calc(s, z); +AVTXWrapper *w = (AVTXWrapper *)s; +w->fn(w->ctx, z, (void *)z, sizeof(AVComplexFloat)); } av_cold void av_fft_end(FFTContext *s) { if (s) { -ff_fft_end(s); -av_free(s); +AVTXWrapper *w = (AVTXWrapper *)s; +av_tx_uninit(&w->ctx); +av_tx_uninit(&w->ctx2); +av_free(w); } } -- 2.40.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/3] avfft: wrap lavu/tx instead of ff_mdct
Patch attached. >From 593d95ce1d2510394c09ea64d8669973889d20e8 Mon Sep 17 00:00:00 2001 From: Lynne Date: Thu, 10 Nov 2022 11:26:33 +0100 Subject: [PATCH 2/3] avfft: wrap lavu/tx instead of ff_mdct --- libavcodec/avfft.c | 43 --- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/libavcodec/avfft.c b/libavcodec/avfft.c index e4b19af272..ff5c739897 100644 --- a/libavcodec/avfft.c +++ b/libavcodec/avfft.c @@ -75,43 +75,56 @@ av_cold void av_fft_end(FFTContext *s) } } -#if CONFIG_MDCT - FFTContext *av_mdct_init(int nbits, int inverse, double scale) { -FFTContext *s = av_malloc(sizeof(*s)); +int ret; +float scale_f = scale; +AVTXWrapper *s = av_malloc(sizeof(*s)); +if (!s) +return NULL; -if (s && ff_mdct_init(s, nbits, inverse, scale)) -av_freep(&s); +ret = av_tx_init(&s->ctx, &s->fn, AV_TX_FLOAT_MDCT, inverse, 1 << (nbits - 1), &scale_f, 0); +if (ret < 0) { +av_free(s); +return NULL; +} -return s; +if (inverse) { +ret = av_tx_init(&s->ctx2, &s->fn2, AV_TX_FLOAT_MDCT, inverse, 1 << (nbits - 1), + &scale_f, AV_TX_FULL_IMDCT); +if (ret < 0) { +av_tx_uninit(&s->ctx); +av_free(s); +return NULL; +} +} + +return (FFTContext *)s; } void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input) { -s->imdct_calc(s, output, input); +AVTXWrapper *w = (AVTXWrapper *)s; +w->fn2(w->ctx2, output, (void *)input, sizeof(float)); } void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input) { -s->imdct_half(s, output, input); +AVTXWrapper *w = (AVTXWrapper *)s; +w->fn(w->ctx, output, (void *)input, sizeof(float)); } void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input) { -s->mdct_calc(s, output, input); +AVTXWrapper *w = (AVTXWrapper *)s; +w->fn(w->ctx, output, (void *)input, sizeof(float)); } av_cold void av_mdct_end(FFTContext *s) { -if (s) { -ff_mdct_end(s); -av_free(s); -} +av_fft_end(s); } -#endif /* CONFIG_MDCT */ - #if CONFIG_RDFT RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans) -- 2.40.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 3/3] avfft: wrap lavu/tx instead of ff_rdft
Patch attached. >From 68781f3bc021fe96c4b4b4a355e03d7c5bd3539b Mon Sep 17 00:00:00 2001 From: Lynne Date: Thu, 10 Nov 2022 11:26:59 +0100 Subject: [PATCH 3/3] avfft: wrap lavu/tx instead of ff_rdft --- libavcodec/avfft.c | 37 - 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/libavcodec/avfft.c b/libavcodec/avfft.c index ff5c739897..f5880f9932 100644 --- a/libavcodec/avfft.c +++ b/libavcodec/avfft.c @@ -125,33 +125,44 @@ av_cold void av_mdct_end(FFTContext *s) av_fft_end(s); } -#if CONFIG_RDFT - RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans) { -RDFTContext *s = av_malloc(sizeof(*s)); +int ret; +float scale = 1.0f; +AVTXWrapper *s; -if (s && ff_rdft_init(s, nbits, trans)) -av_freep(&s); +/* The other 2 modes are unconventional, do not form an orthogonal + * transform, have never been useful, and so they're not implemented. */ +if (trans != IDFT_C2R && trans != DFT_R2C) +return NULL; -return s; +s = av_malloc(sizeof(*s)); +if (!s) +return NULL; + +ret = av_tx_init(&s->ctx, &s->fn, AV_TX_FLOAT_RDFT, trans == IDFT_C2R, + 1 << nbits, &scale, AV_TX_INPLACE); +if (ret < 0) { +av_free(s); +return NULL; +} + +s->stride = (trans == DFT_C2R) ? sizeof(float) : sizeof(AVComplexFloat); + +return (RDFTContext *)s; } void av_rdft_calc(RDFTContext *s, FFTSample *data) { -s->rdft_calc(s, data); +AVTXWrapper *w = (AVTXWrapper *)s; +w->fn(w->ctx, data, (void *)data, w->stride); } av_cold void av_rdft_end(RDFTContext *s) { -if (s) { -ff_rdft_end(s); -av_free(s); -} +av_fft_end((FFTContext *)s); } -#endif /* CONFIG_RDFT */ - #if CONFIG_DCT DCTContext *av_dct_init(int nbits, enum DCTTransformType inverse) -- 2.40.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] avformat/flv: correct the video frametype mask to 0x70
avformat/flv: correct the video frametype mask to 0x70 because the flv specification said the video frametype should use value range from 0x00 to 0x70, so use 0xF0 have no problem before support enhanced flv, but the 0xF0 will get incorrect result after support enhanced flv, so should set the video frametype mask 0x70 to make it correct now. Reported-By: flvAnalyser Signed-off-by: Steven Liu --- libavformat/flv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/flv.h b/libavformat/flv.h index 91e0a4140c..f710963b92 100644 --- a/libavformat/flv.h +++ b/libavformat/flv.h @@ -48,7 +48,7 @@ #define FLV_AUDIO_CODECID_MASK0xf0 #define FLV_VIDEO_CODECID_MASK0x0f -#define FLV_VIDEO_FRAMETYPE_MASK 0xf0 +#define FLV_VIDEO_FRAMETYPE_MASK 0x70 #define AMF_END_OF_OBJECT 0x09 -- 2.40.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 v3 1/2] lavc: add prores bitstream parser
Signed-off-by: clarkh --- libavcodec/Makefile| 1 + libavcodec/parsers.c | 1 + libavcodec/prores_parser.c | 107 + 3 files changed, 109 insertions(+) create mode 100644 libavcodec/prores_parser.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 1b0226c089..21cd28c9ac 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1198,6 +1198,7 @@ OBJS-$(CONFIG_OPUS_PARSER) += opus_parser.o opus_parse.o \ vorbis_data.o OBJS-$(CONFIG_PNG_PARSER) += png_parser.o OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o +OBJS-$(CONFIG_PRORES_PARSER) += prores_parser.o OBJS-$(CONFIG_QOI_PARSER) += qoi_parser.o OBJS-$(CONFIG_RV30_PARSER) += rv34_parser.o OBJS-$(CONFIG_RV40_PARSER) += rv34_parser.o diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c index 285f81a901..131867686a 100644 --- a/libavcodec/parsers.c +++ b/libavcodec/parsers.c @@ -64,6 +64,7 @@ extern const AVCodecParser ff_mpegvideo_parser; extern const AVCodecParser ff_opus_parser; extern const AVCodecParser ff_png_parser; extern const AVCodecParser ff_pnm_parser; +extern const AVCodecParser ff_prores_parser; extern const AVCodecParser ff_qoi_parser; extern const AVCodecParser ff_rv30_parser; extern const AVCodecParser ff_rv40_parser; diff --git a/libavcodec/prores_parser.c b/libavcodec/prores_parser.c new file mode 100644 index 00..1299c7b642 --- /dev/null +++ b/libavcodec/prores_parser.c @@ -0,0 +1,107 @@ +/* + * ProRes bitstream parser + * Copyright (c) 2023 clarkh + * + * 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 "parser.h" +#include "libavutil/intreadwrite.h" +#include "libavcodec/proresdata.h" + +typedef struct { +ParseContext pc; +int remaining; +int overwrite; +} ProResParserContext; + +static int prores_find_frame_end(ProResParserContext *pctx, const uint8_t *buf, int buf_size) +{ +ParseContext *pc = &pctx->pc; +uint64_t state64 = pc->state64; +int pic_found = pc->frame_start_found; +int i = 0; + +if (!pic_found) { +for (i = 0; i < buf_size; i++) { +state64 = (state64 << 8) | buf[i]; +if ((state64 & 0x) == FRAME_ID) { +i++; +pic_found = 1; +pctx->remaining = state64 >> 32; +pctx->remaining -= pctx->overwrite; +break; +} +} +} + +if (pic_found) { +if (!buf_size) +return END_NOT_FOUND; + +if (pctx->remaining > buf_size) { +pctx->remaining -= buf_size; +} else { +int remaining = pctx->remaining; + +pc->frame_start_found = 0; +pc->state64 = -1; +pctx->remaining = 0; +pctx->overwrite = 0; +return remaining; +} +} else { +pctx->overwrite += buf_size; +} + +pc->frame_start_found = pic_found; +pc->state64 = state64; + +return END_NOT_FOUND; +} + +static int prores_parse(AVCodecParserContext *s, AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size) +{ +ProResParserContext *pctx = s->priv_data; +ParseContext *pc = &pctx->pc; +int next; + +if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { +next = buf_size; +} else { +next = prores_find_frame_end(pctx, buf, buf_size); +if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { +*poutbuf = NULL; +*poutbuf_size = 0; +return buf_size; +} +} + +*poutbuf = buf; +*poutbuf_size = buf_size; + +return next; +} + +const AVCodecParser ff_prores_parser = { +.codec_ids = { AV_CODEC_ID_PRORES }, +.priv_data_size = sizeof(ProResParserContext), +.parser_parse = prores_parse, +.parser_close = ff_parse_close +}; -- 2.34.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
[FFmpeg-devel] [PATCH v3 2/2] lavf: add prores bitstream demuxer and muxer
Signed-off-by: clarkh --- libavformat/Makefile | 2 ++ libavformat/allformats.c | 2 ++ libavformat/proresdec.c | 66 libavformat/rawenc.c | 13 4 files changed, 83 insertions(+) create mode 100644 libavformat/proresdec.c diff --git a/libavformat/Makefile b/libavformat/Makefile index bd78c206b9..16def0765b 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -480,6 +480,8 @@ OBJS-$(CONFIG_PDV_DEMUXER) += pdvdec.o OBJS-$(CONFIG_PJS_DEMUXER) += pjsdec.o subtitles.o OBJS-$(CONFIG_PMP_DEMUXER) += pmpdec.o OBJS-$(CONFIG_PP_BNK_DEMUXER)+= pp_bnk.o +OBJS-$(CONFIG_PRORES_DEMUXER)+= proresdec.o rawdec.o +OBJS-$(CONFIG_PRORES_MUXER) += rawenc.o OBJS-$(CONFIG_PVA_DEMUXER) += pva.o OBJS-$(CONFIG_PVF_DEMUXER) += pvfdec.o pcm.o OBJS-$(CONFIG_QCP_DEMUXER) += qcp.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 6324952bd2..0b762034ca 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -378,6 +378,8 @@ extern const AVInputFormat ff_pdv_demuxer; extern const AVInputFormat ff_pjs_demuxer; extern const AVInputFormat ff_pmp_demuxer; extern const AVInputFormat ff_pp_bnk_demuxer; +extern const AVInputFormat ff_prores_demuxer; +extern const FFOutputFormat ff_prores_muxer; extern const FFOutputFormat ff_psp_muxer; extern const AVInputFormat ff_pva_demuxer; extern const AVInputFormat ff_pvf_demuxer; diff --git a/libavformat/proresdec.c b/libavformat/proresdec.c new file mode 100644 index 00..67f25b79ec --- /dev/null +++ b/libavformat/proresdec.c @@ -0,0 +1,66 @@ +/* + * ProRes bitstream probe + * Copyright (c) 2023 clarkh + * + * 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 "libavcodec/proresdata.h" +#include "avformat.h" +#include "rawdec.h" + +#define FRAME_FIXED_HEADER_SIZE 20 + +static int prores_check_frame_header(const uint8_t *buf, const int data_size) +{ +int hdr_size, width, height; +int version, alpha_info; + +hdr_size = AV_RB16(buf); +if (hdr_size < FRAME_FIXED_HEADER_SIZE) +return AVERROR_INVALIDDATA; + +version = buf[3]; +if (version > 1) +return AVERROR_INVALIDDATA; + +width = AV_RB16(buf + 8); +height = AV_RB16(buf + 10); +if (!width || !height) +return AVERROR_INVALIDDATA; + +alpha_info = buf[17] & 0x0f; +if (alpha_info > 2) +return AVERROR_INVALIDDATA; + +return 0; +} + +static int prores_probe(const AVProbeData *p) +{ +// 8: frame_size(4B) + frame_identifier(4B) +if (p->buf_size < (8 + FRAME_FIXED_HEADER_SIZE) || AV_RB32(p->buf + 4) != FRAME_ID) +return 0; + +if (prores_check_frame_header(p->buf + 8, p->buf_size - 8) < 0) +return 0; + +return AVPROBE_SCORE_MAX; +} + +FF_DEF_RAWVIDEO_DEMUXER(prores, "raw ProRes", prores_probe, "prores", AV_CODEC_ID_PRORES) diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c index f916db13a2..28ca47ae70 100644 --- a/libavformat/rawenc.c +++ b/libavformat/rawenc.c @@ -538,6 +538,19 @@ const FFOutputFormat ff_obu_muxer = { }; #endif +#if CONFIG_PRORES_MUXER +const FFOutputFormat ff_prores_muxer = { +.p.name= "prores", +.p.long_name = NULL_IF_CONFIG_SMALL("raw prores video"), +.p.extensions = "prores", +.p.audio_codec = AV_CODEC_ID_NONE, +.p.video_codec = AV_CODEC_ID_PRORES, +.init = force_one_stream, +.write_packet = ff_raw_write_packet, +.p.flags = AVFMT_NOTIMESTAMPS, +}; +#endif + #if CONFIG_RAWVIDEO_MUXER const FFOutputFormat ff_rawvideo_muxer = { .p.name= "rawvideo", -- 2.34.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".
Re: [FFmpeg-devel] [PATCH 5/6] fftools: avradio support
On Mon, Jul 24, 2023 at 10:19:13PM +0200, Tomas Härdin wrote: > sön 2023-07-23 klockan 16:01 -0300 skrev James Almer: > > What bothers me is that even though it's added outside of lavd, it's > > being added as a brand new lavd, with all the drawbacks this implies, > > including it being tied to lavf in an awful way. And all for a single > > "device" AVInputFormat. It's completely overkill. > > > > Why is this libavradio not designed as a standalone library, with its > > own, carefully designed API for general radio usage, that can be then > > glued to lavd as an AVInputFormat relying on said external library? > > Such libraries already exist. Libraries that need talented developers > working on them. Something that I have already suggested, but it > appears to be falling on deaf ears. Which is a shame. You suggested this for many things, including MXF For MXF your suggestion has no support AFAIK. And it would cause problems with MXF support in FFmpeg (but thats off topic here) For avradio, maybe i need to communicate more with the other developers but I am not ignoring your suggestion. I also dont do what you suggest litterally (which is maybe why you think iam ignoring it) But since a while my plan for DAB support is to using an external library. For FM and AM, using an external libraray is just a mistake, same as it is for something like *av_asprintf(). The external libraray would just be more pain than doing it internally About the need for talented developers in SDR projects. I understand every project needs more talented developers. But what my goal after having some fun with SDR is, is to serve the end user. And here iam trying to make it possible that "FFmpeg based" players and tools can use SDR. If i join gnu radio and use pipes very few end users of FFmpeg based tools would be served by that I dont understand why you keep telling me to join a absolutely huge python project (which has no need for any further development in SDR code) (and has no easy path to be used by a FFmpeg based tool end user) For FFmpeg using a C or C++ libraray for some parts of SDR like DAB is something that makes sense and i plan to go that route. But beyond that I simply do not understand how your suggestions would server end users Its not my goal to create a "player" for myself. I have a radio from my grand aunt that works still fine. Again my goal was to have fun with the math&dsp code and serve the end users of this project. gnu radio needs no further math & dsp from me and it wont serve end users of libav* / FFmpeg tools. The repeated suggestion for gnu radio baffles me. Maybe iam missing something, of course, but i dont see how this could work. Maybe if iam all wrong here, why dont you send a patch, that gives ffmpeg & libav* based tool end users AM/FM/DAB/DVB support through gnu radio ? With same features and convenience avradio does today. thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org 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] lavu: add AVVideoHint API
On Mon, 2023-07-24 at 01:27 +0200, Stefano Sabatini wrote: > CAUTION: This email originated from outside of the organization. Do > not click links or open attachments unless you can confirm the sender > and know the content is safe. > > > > > > sorry to nitpick, but if we have this information in the single > > rect > > should not we use that instead? > > > > Basically I see two options: > > 1. generic VideoHint, storing single hint type and rects > > > > for example we might have type=changed, and the rects storing only > > the > > changed rects > > > > If we want to extend this then we need to add a new type. The > > problem > > might be if we want to store more than one VideoHint in the side > > data > > (it it possible to store more than one AVVideoHint, each one with a > > different type, as side data?). Suppose for example we want to add > > a > > new hint type, e.g. ROI, then we can add a new AVHideoHint with > > type=roi - but I don't know if we can have several frame hint side > > data (each one with different individual types). > > > > 2. generic VideoHint, storing rects each one containing the hint > > type > > > > for example we might have a list of rects, each one with > > type=changed|constant|roi. This would allow one to store different > > kind of hints in the same AVVideoHint structure, but at the same > > time > > would enable inconsistent data (for example we might have changed > > and > > unchanged rects in the same list of rects) > > I don't think it allowed such inconsistency the way it was made. Basically, the semantics was that the Hint type could be either CONSTANT or CHANGED and that was the basis to interpret the rects with type DAMAGE. > > In each case, storing the type in the generic AVVideHint and in > > each > > rect might lead to inconsistent states (e.g. you might have generic > > type=damage, and have type=roi and type=changed in the rects), in > > this > > case having the type in both the general structure and in each > > rects > > seems redundant and leads to possible data inconsistencies. > > > > ... > > > > > I would rather go to solution 1, but I'm not sure if having more > > than > > one hint in the side data (with different subtypes) is possible and > > wanted. If this is the case, probably the best solution would be to > > store more than one AVVideoHint (each one with an individual type > > and > > list of rects) in the single side data object. > > Elaborating on this. > > 1. Ideally we might want to extend the av_frame_get_side_data API to > be able to store more than one entry per side data, by adding a > unique > label to the side data, but this requires probably more effort and > extends the scope even further. > > 2. Alternatively, we might extend the hint API like this: > > AVVideoHint *av_video_hint_create_side_data(AVFrame *frame, > size_t nb_rects); > > AVVideoHint *av_video_hint_extend_side_data(AVFrame *frame, > size_t nb_rects); > > by marking the continuation on the previous hint (but this would > complicate deserialization as you need then to iterate to get all the > side data). > > Or we could make a variadic function like this: > AVVideoHint *av_video_hint_create_side_data(AVFrame *frame, size_t > nb_rects, ...); > > Alternatively, we might store in AVVideoHint more than one hint, but > this somehow conflict with the general design. > > ... > > As a low effort approach, I would keep the initial design of a single > hint type per side-data (dropping the possibility of having more than > one hint type in the same side data), which should be fixed > generically by implementing 1. Agreed. For clarity I am attaching again the patch with Anton's changes just rebased on the current master branch. Anton, is this still ok to be merged? Best, Elias NICE SRL, viale Monte Grappa 3/5, 20124 Milano, Italia, Registro delle Imprese di Milano Monza Brianza Lodi REA n. 2096882, Capitale Sociale: 10.329,14 EUR i.v., Cod. Fisc. e P.IVA 01133050052, Societa con Socio Unico From fcd9051a9167f48083f0edc4bf44b3d09e568091 Mon Sep 17 00:00:00 2001 From: Elias Carotti Date: Mon, 10 Jul 2023 14:34:53 +0200 Subject: [PATCH] Add side data type to provide hint to the video encoders about unchanged portions of each frame. Signed-off-by: Anton Khirnov --- doc/APIchanges | 3 ++ libavutil/Makefile | 2 + libavutil/frame.h | 10 libavutil/version.h| 2 +- libavutil/video_hint.c | 82 libavutil/video_hint.h | 105 + 6 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 libavutil/video_hint.c create mode 100644 libavutil/video_hint.h diff --git a/doc/APIchanges b/doc/APIchanges index 5afe8bcb75..2adc7b5225 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-
[FFmpeg-devel] [PATCH avcodec/amfenc:, 10, bit, support, v3, 1/3] avcodec/amfenc: Fixes the color information in the output.
From: Michael Fabian 'Xaymar' Dirks added 10 bit support for amf hevc. before: command - ffmpeg.exe -hide_banner -y -hwaccel d3d11va -hwaccel_output_format d3d11 -i test_10bit_file.mkv -an -c:v h264_amf res.dx11_hw_h264.mkv output - Format of input frames context (p010le) is not supported by AMF. command - ffmpeg.exe -hide_banner -y -hwaccel d3d11va -hwaccel_output_format d3d11 -i test_10bit_file -an -c:v hevc_amf res.dx11_hw_hevc.mkv output - Format of input frames context (p010le) is not supported by AMF. after: command - ffmpeg.exe -hide_banner -y -hwaccel d3d11va -hwaccel_output_format d3d11 -i test_10bit_file -an -c:v h264_amf res.dx11_hw_h264.mkv output - 8bit file command - ffmpeg.exe -hide_banner -y -hwaccel d3d11va -hwaccel_output_format d3d11 -i test_10bit_file -an -c:v hevc_amf res.dx11_hw_hevc.mkv output - 10bit file v2 - lost line returned in ff_amf_pix_fmts v3 - fixes after review --- libavcodec/amfenc.c | 2 ++ libavcodec/amfenc.h | 1 + libavcodec/amfenc_h264.c | 49 - libavcodec/amfenc_hevc.c | 58 +++- 4 files changed, 108 insertions(+), 2 deletions(-) diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c index cb48f8c273..1d863afdc4 100644 --- a/libavcodec/amfenc.c +++ b/libavcodec/amfenc.c @@ -60,6 +60,7 @@ const enum AVPixelFormat ff_amf_pix_fmts[] = { #if CONFIG_DXVA2 AV_PIX_FMT_DXVA2_VLD, #endif +AV_PIX_FMT_P010, AV_PIX_FMT_NONE }; @@ -72,6 +73,7 @@ static const FormatMap format_map[] = { { AV_PIX_FMT_NONE, AMF_SURFACE_UNKNOWN }, { AV_PIX_FMT_NV12, AMF_SURFACE_NV12 }, +{ AV_PIX_FMT_P010, AMF_SURFACE_P010 }, { AV_PIX_FMT_BGR0, AMF_SURFACE_BGRA }, { AV_PIX_FMT_RGB0, AMF_SURFACE_RGBA }, { AV_PIX_FMT_GRAY8, AMF_SURFACE_GRAY8 }, diff --git a/libavcodec/amfenc.h b/libavcodec/amfenc.h index 2dbd378ef8..267eb593a2 100644 --- a/libavcodec/amfenc.h +++ b/libavcodec/amfenc.h @@ -21,6 +21,7 @@ #include +#include #include #include #include diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c index 2380aa4e90..4b6708ca8f 100644 --- a/libavcodec/amfenc_h264.c +++ b/libavcodec/amfenc_h264.c @@ -199,6 +199,9 @@ static av_cold int amf_encode_init_h264(AVCodecContext *avctx) AMFRate framerate; AMFSize framesize = AMFConstructSize(avctx->width, avctx->height); int deblocking_filter = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0; +amf_int64color_depth; +amf_int64color_profile; +enum AVPixelFormat pix_fmt; if (avctx->framerate.num > 0 && avctx->framerate.den > 0) { framerate = AMFConstructRate(avctx->framerate.num, avctx->framerate.den); @@ -262,10 +265,54 @@ FF_ENABLE_DEPRECATION_WARNINGS AMF_ASSIGN_PROPERTY_RATIO(res, ctx->encoder, AMF_VIDEO_ENCODER_ASPECT_RATIO, ratio); } -/// Color Range (Partial/TV/MPEG or Full/PC/JPEG) +color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_UNKNOWN; +// Color Metadata +/// Color Range (Support for older Drivers) if (avctx->color_range == AVCOL_RANGE_JPEG) { AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_FULL_RANGE_COLOR, 1); +/// Color Space for Full (JPEG) Range +switch (avctx->colorspace) { +case AVCOL_SPC_SMPTE170M: +color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_601; +break; +case AVCOL_SPC_BT709: +color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_709; +break; +case AVCOL_SPC_BT2020_NCL: +case AVCOL_SPC_BT2020_CL: +color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_2020; +break; +} +} else { +AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_FULL_RANGE_COLOR, 0); +/// Color Space for Limited (MPEG) range +switch (avctx->colorspace) { +case AVCOL_SPC_SMPTE170M: +color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_601; +break; +case AVCOL_SPC_BT709: +color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_709; +break; +case AVCOL_SPC_BT2020_NCL: +case AVCOL_SPC_BT2020_CL: +color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_2020; +break; +} } +/// Color Depth +pix_fmt = avctx->hw_frames_ctx ? ((AVHWFramesContext*)avctx->hw_frames_ctx->data)->sw_format +: avctx->pix_fmt; +color_depth = AMF_COLOR_BIT_DEPTH_8; +if (pix_fmt == AV_PIX_FMT_P010) { +color_depth = AMF_COLOR_BIT_DEPTH_10; +} + +AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_COLOR_BIT_DEPTH, color_depth); +AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_OU
[FFmpeg-devel] [PATCH avcodec/amfenc:, 10, bit, support, v3, 2/3] avcodec/amfenc: HDR metadata.
From: nyanmisaka --- libavcodec/amfenc.c | 83 + 1 file changed, 83 insertions(+) diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c index 1d863afdc4..ec71f899fe 100644 --- a/libavcodec/amfenc.c +++ b/libavcodec/amfenc.c @@ -36,6 +36,57 @@ #include "amfenc.h" #include "encode.h" #include "internal.h" +#include "libavutil/mastering_display_metadata.h" + +static int amf_save_hdr_metadata(AVCodecContext *avctx, const AVFrame *frame, AMFHDRMetadata *hdrmeta) +{ +AVFrameSideData*sd_display; +AVFrameSideData*sd_light; +AVMasteringDisplayMetadata *display_meta; +AVContentLightMetadata *light_meta; + +sd_display = av_frame_get_side_data(frame, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); +if (sd_display) { +display_meta = (AVMasteringDisplayMetadata *)sd_display->data; +if (display_meta->has_luminance) { +const unsigned int luma_den = 1; +hdrmeta->maxMasteringLuminance = +(amf_uint32)(luma_den * av_q2d(display_meta->max_luminance)); +hdrmeta->minMasteringLuminance = +FFMIN((amf_uint32)(luma_den * av_q2d(display_meta->min_luminance)), hdrmeta->maxMasteringLuminance); +} +if (display_meta->has_primaries) { +const unsigned int chroma_den = 5; +hdrmeta->redPrimary[0] = +FFMIN((amf_uint16)(chroma_den * av_q2d(display_meta->display_primaries[0][0])), chroma_den); +hdrmeta->redPrimary[1] = +FFMIN((amf_uint16)(chroma_den * av_q2d(display_meta->display_primaries[0][1])), chroma_den); +hdrmeta->greenPrimary[0] = +FFMIN((amf_uint16)(chroma_den * av_q2d(display_meta->display_primaries[1][0])), chroma_den); +hdrmeta->greenPrimary[1] = +FFMIN((amf_uint16)(chroma_den * av_q2d(display_meta->display_primaries[1][1])), chroma_den); +hdrmeta->bluePrimary[0] = +FFMIN((amf_uint16)(chroma_den * av_q2d(display_meta->display_primaries[2][0])), chroma_den); +hdrmeta->bluePrimary[1] = +FFMIN((amf_uint16)(chroma_den * av_q2d(display_meta->display_primaries[2][1])), chroma_den); +hdrmeta->whitePoint[0] = +FFMIN((amf_uint16)(chroma_den * av_q2d(display_meta->white_point[0])), chroma_den); +hdrmeta->whitePoint[1] = +FFMIN((amf_uint16)(chroma_den * av_q2d(display_meta->white_point[1])), chroma_den); +} + +sd_light = av_frame_get_side_data(frame, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); +if (sd_light) { +light_meta = (AVContentLightMetadata *)sd_light->data; +if (light_meta) { +hdrmeta->maxContentLightLevel = (amf_uint16)light_meta->MaxCLL; +hdrmeta->maxFrameAverageLightLevel = (amf_uint16)light_meta->MaxFALL; +} +} +return 0; +} +return 1; +} #if CONFIG_D3D11VA #include @@ -683,6 +734,26 @@ int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt) frame_ref_storage_buffer->pVtbl->Release(frame_ref_storage_buffer); } +// HDR10 metadata +if (frame->color_trc == AVCOL_TRC_SMPTE2084) { +AMFBuffer * hdrmeta_buffer = NULL; +res = ctx->context->pVtbl->AllocBuffer(ctx->context, AMF_MEMORY_HOST, sizeof(AMFHDRMetadata), &hdrmeta_buffer); +if (res == AMF_OK) { +AMFHDRMetadata * hdrmeta = (AMFHDRMetadata*)hdrmeta_buffer->pVtbl->GetNative(hdrmeta_buffer); +if (amf_save_hdr_metadata(avctx, frame, hdrmeta) == 0) { +switch (avctx->codec->id) { +case AV_CODEC_ID_H264: +AMF_ASSIGN_PROPERTY_INTERFACE(res, ctx->encoder, AMF_VIDEO_ENCODER_INPUT_HDR_METADATA, hdrmeta_buffer); break; +case AV_CODEC_ID_HEVC: +AMF_ASSIGN_PROPERTY_INTERFACE(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_INPUT_HDR_METADATA, hdrmeta_buffer); break; +} +res = amf_set_property_buffer(surface, L"av_frame_hdrmeta", hdrmeta_buffer); +AMF_RETURN_IF_FALSE(avctx, res == AMF_OK, AVERROR_UNKNOWN, "SetProperty failed for \"av_frame_hdrmeta\" with error %d\n", res); +} +hdrmeta_buffer->pVtbl->Release(hdrmeta_buffer); +} +} + surface->pVtbl->SetPts(surface, frame->pts); AMF_ASSIGN_PROPERTY_INT64(res, surface, PTS_PROP, frame->pts); @@ -746,6 +817,18 @@ int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt) } res_resubmit = AMF_OK; if (ctx->delayed_surface != NULL) { // try to resubmit frame +if (ctx->delayed_surface->pVtbl->HasProperty(ctx->delayed_surface, L"av_frame_hdrmeta")) { +AMFBuffer * hdrmeta_buffer
[FFmpeg-devel] [PATCH avcodec/amfenc:, 10, bit, support, v3, 3/3] avcodec/amfenc: add 10 bit encoding in av1_amf
Signed-off-by: Evgeny Pavlov Co-authored-by: Dmitrii Ovchinnikov --- libavcodec/amfenc_av1.c | 47 + 1 file changed, 47 insertions(+) diff --git a/libavcodec/amfenc_av1.c b/libavcodec/amfenc_av1.c index 30c0a9fad2..5c5313001d 100644 --- a/libavcodec/amfenc_av1.c +++ b/libavcodec/amfenc_av1.c @@ -165,6 +165,9 @@ static av_cold int amf_encode_init_av1(AVCodecContext* avctx) AMFGuid guid; AMFRate framerate; AMFSize framesize = AMFConstructSize(avctx->width, avctx->height); +amf_int64 color_depth; +amf_int64 color_profile; +enumAVPixelFormat pix_fmt; @@ -203,6 +206,50 @@ FF_ENABLE_DEPRECATION_WARNINGS } AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_PROFILE, profile); +// Color Metadata +/// Color Space & Depth +pix_fmt = avctx->hw_frames_ctx ? ((AVHWFramesContext*)avctx->hw_frames_ctx->data)->sw_format +: avctx->pix_fmt; +color_depth = AMF_COLOR_BIT_DEPTH_8; +if (pix_fmt == AV_PIX_FMT_P010) { +color_depth = AMF_COLOR_BIT_DEPTH_10; +} +color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_UNKNOWN; + +if (avctx->color_range == AVCOL_RANGE_JPEG) { +switch (avctx->colorspace) { +case AVCOL_SPC_SMPTE170M: +color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_601; +break; +case AVCOL_SPC_BT709: +color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_709; +break; +case AVCOL_SPC_BT2020_NCL: +case AVCOL_SPC_BT2020_CL: +color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_2020; +break; +} +} else { +switch (avctx->colorspace) { +case AVCOL_SPC_SMPTE170M: +color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_601; +break; +case AVCOL_SPC_BT709: +color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_709; +break; +case AVCOL_SPC_BT2020_NCL: +case AVCOL_SPC_BT2020_CL: +color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_2020; +break; +} +} +AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_COLOR_BIT_DEPTH, color_depth); +AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_OUTPUT_COLOR_PROFILE, color_profile); +/// Color Transfer Characteristics (AMF matches ISO/IEC) +AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_OUTPUT_TRANSFER_CHARACTERISTIC, (amf_int64)avctx->color_trc); +/// Color Primaries (AMF matches ISO/IEC) +AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_OUTPUT_COLOR_PRIMARIES, (amf_int64)avctx->color_primaries); + profile_level = avctx->level; if (profile_level == FF_LEVEL_UNKNOWN) { profile_level = ctx->level; -- 2.41.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".
Re: [FFmpeg-devel] [PATCH v3 1/2] lavc: add prores bitstream parser
On Wed, Jul 26, 2023 at 11:27 AM hung kuishing wrote: > Signed-off-by: clarkh > --- > libavcodec/Makefile| 1 + > libavcodec/parsers.c | 1 + > libavcodec/prores_parser.c | 107 + > 3 files changed, 109 insertions(+) > create mode 100644 libavcodec/prores_parser.c > What is usage for this? Which streams/files need this? Have parser be tested rigorously with random noise data? > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index 1b0226c089..21cd28c9ac 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -1198,6 +1198,7 @@ OBJS-$(CONFIG_OPUS_PARSER) += > opus_parser.o opus_parse.o \ >vorbis_data.o > OBJS-$(CONFIG_PNG_PARSER) += png_parser.o > OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o > +OBJS-$(CONFIG_PRORES_PARSER) += prores_parser.o > OBJS-$(CONFIG_QOI_PARSER) += qoi_parser.o > OBJS-$(CONFIG_RV30_PARSER) += rv34_parser.o > OBJS-$(CONFIG_RV40_PARSER) += rv34_parser.o > diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c > index 285f81a901..131867686a 100644 > --- a/libavcodec/parsers.c > +++ b/libavcodec/parsers.c > @@ -64,6 +64,7 @@ extern const AVCodecParser ff_mpegvideo_parser; > extern const AVCodecParser ff_opus_parser; > extern const AVCodecParser ff_png_parser; > extern const AVCodecParser ff_pnm_parser; > +extern const AVCodecParser ff_prores_parser; > extern const AVCodecParser ff_qoi_parser; > extern const AVCodecParser ff_rv30_parser; > extern const AVCodecParser ff_rv40_parser; > diff --git a/libavcodec/prores_parser.c b/libavcodec/prores_parser.c > new file mode 100644 > index 00..1299c7b642 > --- /dev/null > +++ b/libavcodec/prores_parser.c > @@ -0,0 +1,107 @@ > +/* > + * ProRes bitstream parser > + * Copyright (c) 2023 clarkh > + * > + * 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 "parser.h" > +#include "libavutil/intreadwrite.h" > +#include "libavcodec/proresdata.h" > + > +typedef struct { > +ParseContext pc; > +int remaining; > +int overwrite; > +} ProResParserContext; > + > +static int prores_find_frame_end(ProResParserContext *pctx, const uint8_t > *buf, int buf_size) > +{ > +ParseContext *pc = &pctx->pc; > +uint64_t state64 = pc->state64; > +int pic_found = pc->frame_start_found; > +int i = 0; > + > +if (!pic_found) { > +for (i = 0; i < buf_size; i++) { > +state64 = (state64 << 8) | buf[i]; > +if ((state64 & 0x) == FRAME_ID) { > +i++; > +pic_found = 1; > +pctx->remaining = state64 >> 32; > +pctx->remaining -= pctx->overwrite; > +break; > +} > +} > +} > + > +if (pic_found) { > +if (!buf_size) > +return END_NOT_FOUND; > + > +if (pctx->remaining > buf_size) { > +pctx->remaining -= buf_size; > +} else { > +int remaining = pctx->remaining; > + > +pc->frame_start_found = 0; > +pc->state64 = -1; > +pctx->remaining = 0; > +pctx->overwrite = 0; > +return remaining; > +} > +} else { > +pctx->overwrite += buf_size; > +} > + > +pc->frame_start_found = pic_found; > +pc->state64 = state64; > + > +return END_NOT_FOUND; > +} > + > +static int prores_parse(AVCodecParserContext *s, AVCodecContext *avctx, > + const uint8_t **poutbuf, int *poutbuf_size, > + const uint8_t *buf, int buf_size) > +{ > +ProResParserContext *pctx = s->priv_data; > +ParseContext *pc = &pctx->pc; > +int next; > + > +if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { > +next = buf_size; > +} else { > +next = prores_find_frame_end(pctx, buf, buf_size); > +if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { > +*poutbuf = NULL; > +*poutbuf_size = 0; > +return buf_size; > +} > +} > + > +*poutbuf = buf; > +*poutbuf_size = buf_size; > + > +return next; > +} > +
Re: [FFmpeg-devel] [PATCH v3 2/2] lavf: add prores bitstream demuxer and muxer
On 7/26/2023 10:28 AM, hung kuishing wrote: > Signed-off-by: clarkh > --- > libavformat/Makefile | 2 ++ > libavformat/allformats.c | 2 ++ > libavformat/proresdec.c | 66 > libavformat/rawenc.c | 13 > 4 files changed, 83 insertions(+) > create mode 100644 libavformat/proresdec.c At this point I am giving this a strong NAK. Both my initial comment[1] and subsequent comment[2] about the first one being ignore, have been ignored. It is a simple question. - Derek [1] http://ffmpeg.org/pipermail/ffmpeg-devel/2023-July/312552.html [2] http://ffmpeg.org/pipermail/ffmpeg-devel/2023-July/312635.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".
Re: [FFmpeg-devel] [PATCH] avformat/movenc: Fix writing a sample size of 0 for PCM in MP4
Hello, On 7/26/23 00:09, "zhilizhao(赵志立)" wrote: On Jul 26, 2023, at 00:28, Raphaël Zumer wrote: Encoding PCM in MP4 currently causes subsequent decoding to fail due to a sample size of 0. This doesn’t give a context on which case the sample size is 0. Using FFmpeg (round-trip). Just mux some Wave file to MP4 and try decoding it back. Unless it is sample-dependent for some reason, it will always fail. Use bits per coded sample instead, which are set correctly based on my tests and allow muxed files to be decoded as expected. Since neither bits_per_raw_sample or bits_per_coded_sample has strong guarantee, I decided to fall back to av_get_exact_bits_per_sample(). http://ffmpeg.org/pipermail/ffmpeg-devel/2023-July/312653.html Can you show or describe a case where bits_per_raw_sample is set and not bits_per_coded_sample? For PCM av_get_exact_bits_per_sample() looks fine, but if the behavior of bits_per_raw_sample/bits_per_coded_sample is inconsistent on decode that seems undesirable or undocumented behavior that should be rectified. Looking at the documentation (https://ffmpeg.org/doxygen/6.0/structAVCodecParameters.html) it is mentioned to be equivalent to bits_per_raw_sample for PCM formats. So this looks like a bug. Note: PCM in MP4 muxed with versions of FFmpeg 6.0 and prior (before implementation of the pcmC box) will continue to fail decoding due to the sample size not being available. I see that it was assumed to be 16-bit before commit d4ee17. The assumption is incorrect. We didn’t recognize those samples are ISO/IEC 23003-5 before. I mean that it is possible to mux s16 PCM into MP4 (in a nonstandard way I guess) prior to that patch set and this breaks decoding files created this way. I can mux a s16le Wave file using FFmpeg 6.0 to MP4, it will be decoded correctly and retain the sample format. Try to decode it using FFmpeg post the 23003-5 patch and it simply fails decoding because there's no pcmC box. There doesn't need to be a fallback, just a consideration. Thanks Raphaël Zumer ___ 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] avformat/movenc: fix sample size being zero in pcmC
On 7/25/23 23:45, Zhao Zhili wrote: From: Zhao Zhili -avio_w8(pb, track->par->bits_per_raw_sample); +sample_size = track->par->bits_per_raw_sample; +if (!sample_size) +sample_size = av_get_exact_bits_per_sample(track->par->codec_id); +av_assert0(sample_size); +avio_w8(pb, sample_size); Why not just replace bits_per_raw_sample completely with av_get_exact_bits_per_sample()? Are there edge cases, like incorrect codec ID, or sample sizes smaller than specified by the codec ID (and if there is ever a mismatch, which is expected in pcmC?) If not, there should be no need to prioritize bits_per_raw_sample in the first place and add a fallback - going straight to av_get_exact_bits_per_sample() should suffice and keep the code simpler. As noted in another thread, bits_per_raw_sample seems to always be 0 when muxing PCM to MP4 with FFmpeg, whereas bits_per_coded_sample has the correct value from the samples that I tested. Raphaël Zumer ___ 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 v3 1/2] lavc: add prores bitstream parser
> From: ffmpeg-devel On Behalf Of > Paul B Mahol > Sent: Wednesday, July 26, 2023 9:02 PM > To: FFmpeg development discussions and patches de...@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH v3 1/2] lavc: add prores bitstream > parser > > On Wed, Jul 26, 2023 at 11:27 AM hung kuishing > > wrote: > > > Signed-off-by: clarkh > > --- > > libavcodec/Makefile| 1 + > > libavcodec/parsers.c | 1 + > > libavcodec/prores_parser.c | 107 > > + > > 3 files changed, 109 insertions(+) > > create mode 100644 libavcodec/prores_parser.c > > > > What is usage for this? > Which streams/files need this? This patch originated from a need in my work to wrap the ProRes bitstream generated by ffmpeg into another mov wrapper. If it doesn't add value to the community, just ignore it with ease. > Have parser be tested rigorously with random noise data? I tested with some random data, ffmpeg can handle them correctly. ___ 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 v3 2/2] lavf: add prores bitstream demuxer and muxer
> From: ffmpeg-devel On Behalf Of > Derek Buitenhuis > Sent: Wednesday, July 26, 2023 8:55 PM > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH v3 2/2] lavf: add prores bitstream > demuxer and muxer > > On 7/26/2023 10:28 AM, hung kuishing wrote: > > Signed-off-by: clarkh > > --- > > libavformat/Makefile | 2 ++ > > libavformat/allformats.c | 2 ++ > > libavformat/proresdec.c | 66 > > > libavformat/rawenc.c | 13 > > 4 files changed, 83 insertions(+) > > create mode 100644 libavformat/proresdec.c > > At this point I am giving this a strong NAK. > > Both my initial comment[1] and subsequent comment[2] about the > first one being ignore, have been ignored. It is a simple question. Sorry for not replying to your question in time! This patch originated from a need in my work to wrap the ProRes bitstream generated by ffmpeg into another mov wrapper. ___ 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] avformat/movenc: fix sample size being zero in pcmC
> From: ffmpeg-devel On Behalf Of Raphaël > Zumer > Sent: 2023年7月26日 21:38 > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH 1/2] avformat/movenc: fix sample size > being zero in pcmC > > On 7/25/23 23:45, Zhao Zhili wrote: > > From: Zhao Zhili > > > > -avio_w8(pb, track->par->bits_per_raw_sample); > > +sample_size = track->par->bits_per_raw_sample; > > +if (!sample_size) > > +sample_size = av_get_exact_bits_per_sample(track->par->codec_id); > > +av_assert0(sample_size); > > +avio_w8(pb, sample_size); > > Why not just replace bits_per_raw_sample completely with > av_get_exact_bits_per_sample()? > > Are there edge cases, like incorrect codec ID, or sample sizes smaller than > specified by the codec ID (and if there is ever a mismatch, > which is expected in pcmC?) > > If not, there should be no need to prioritize bits_per_raw_sample in the > first place and add a fallback - going straight to > av_get_exact_bits_per_sample() should suffice and keep the code simpler. Check bits_per_raw_sample first for a little bit of performance. Don't use bits_per_coded_sample because it make less sense in this case and to keep the code simpler. > > As noted in another thread, bits_per_raw_sample seems to always be 0 when > muxing PCM to MP4 with FFmpeg, whereas > bits_per_coded_sample has the correct value from the samples that I tested. That's only one usecase. bits_per_coded_sample has been set while bit_per_raw_sample wasn't only because the implementation of wav demux and there's no encoding process. (You can try -c:a pcm_s16le) There are more usecases to support, e.g., only use mp4 muxer without any demuxer or encoder. User can create and set a AVCodecParameters manually, and let bits_per_coded_sample be zero. > > Raphaël Zumer > > ___ > 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 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] fftools/ffprobe: fix handling parse_options() return value
--- fftools/ffprobe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index a39185f6fe..81610c097b 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -4113,7 +4113,7 @@ int main(int argc, char **argv) show_banner(argc, argv, options); ret = parse_options(NULL, argc, argv, options, opt_input_file); if (ret < 0) { -ret = AVERROR_EXIT ? 0 : ret; +ret = (ret == AVERROR_EXIT) ? 0 : ret; goto end; } -- 2.40.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".
Re: [FFmpeg-devel] [PATCH] avformat/movenc: Fix writing a sample size of 0 for PCM in MP4
> -Original Message- > From: ffmpeg-devel On Behalf Of Raphaël > Zumer > Sent: 2023年7月26日 21:20 > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH] avformat/movenc: Fix writing a sample > size of 0 for PCM in MP4 > > Hello, > > On 7/26/23 00:09, "zhilizhao(赵志立)" wrote: > >> On Jul 26, 2023, at 00:28, Raphaël Zumer wrote: > >> > >> Encoding PCM in MP4 currently causes subsequent decoding to fail due to a > >> sample size of 0. > > This doesn’t give a context on which case the sample size is 0. > > Using FFmpeg (round-trip). Just mux some Wave file to MP4 and try decoding it > back. Unless it is sample-dependent for some reason, it > will always fail. > > >> Use bits per coded sample instead, which are set correctly based on my > >> tests and allow muxed files to be decoded as expected. > > Since neither bits_per_raw_sample or bits_per_coded_sample has strong > > guarantee, > > I decided to fall back to av_get_exact_bits_per_sample(). > > > > http://ffmpeg.org/pipermail/ffmpeg-devel/2023-July/312653.html > > Can you show or describe a case where bits_per_raw_sample is set and not > bits_per_coded_sample? > > For PCM av_get_exact_bits_per_sample() looks fine, but if the behavior of > bits_per_raw_sample/bits_per_coded_sample is inconsistent > on decode that seems undesirable or undocumented behavior that should be > rectified. > > Looking at the documentation > (https://ffmpeg.org/doxygen/6.0/structAVCodecParameters.html) it is mentioned > to be equivalent to > bits_per_raw_sample for PCM formats. So this looks like a bug. > > >> Note: PCM in MP4 muxed with versions of FFmpeg 6.0 and prior (before > >> implementation of the pcmC box) will continue to fail > decoding due to the sample size not being available. I see that it was > assumed to be 16-bit before commit d4ee17. > > The assumption is incorrect. We didn’t recognize those samples are > > ISO/IEC 23003-5 before. > > I mean that it is possible to mux s16 PCM into MP4 (in a nonstandard way I > guess) prior to that patch set and this breaks decoding files > created this way. > > I can mux a s16le Wave file using FFmpeg 6.0 to MP4, it will be decoded > correctly and retain the sample format. Try to decode it using > FFmpeg post the 23003-5 patch and it simply fails decoding because there's no > pcmC box. I think you mixed up PCM in mp4 (-f mp4) and PCM in quicktime format (-f mov). There is no support of mux PCM in mp4 before the patch. And demux PCM in mp4 only works by chance. Let's focus on improve current situation, there isn't much to look back. > > There doesn't need to be a fallback, just a consideration. > > Thanks > > Raphaël Zumer > > ___ > 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 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 v26 5/9] avcodec/evc_decoder: Provided support for EVC decoder
On 6/15/2023 8:48 AM, Dawid Kozinski wrote: - Added EVC decoder wrapper - Changes in project configuration file and libavcodec Makefile - Added documentation for xevd wrapper Signed-off-by: Dawid Kozinski I'm getting [evc @ 01ee1ba7e960] An invalid frame was output by a decoder. This is a bug, please report it. [vist#0:0/evc @ 01ee1d47f220] Decoding error: Internal bug, should not have happened With akiyo_cif.evc, so there's something wrong. --- configure | 4 + doc/decoders.texi | 24 ++ doc/general_contents.texi | 10 +- libavcodec/Makefile | 1 + libavcodec/allcodecs.c| 1 + libavcodec/libxevd.c | 479 ++ 6 files changed, 518 insertions(+), 1 deletion(-) create mode 100644 libavcodec/libxevd.c diff --git a/configure b/configure index e2370a23bb..cae3b666a5 100755 --- a/configure +++ b/configure @@ -293,6 +293,7 @@ External library support: --enable-libx264 enable H.264 encoding via x264 [no] --enable-libx265 enable HEVC encoding via x265 [no] --enable-libxeve enable EVC encoding via libxeve [no] + --enable-libxevd enable EVC decoding via libxevd [no] --enable-libxavs enable AVS encoding via xavs [no] --enable-libxavs2enable AVS2 encoding via xavs2 [no] --enable-libxcb enable X11 grabbing using XCB [autodetect] @@ -1904,6 +1905,7 @@ EXTERNAL_LIBRARY_LIST=" libvorbis libvpx libwebp +libxevd libxeve libxml2 libzimg @@ -3460,6 +3462,7 @@ libx265_encoder_deps="libx265" libx265_encoder_select="atsc_a53" libxavs_encoder_deps="libxavs" libxavs2_encoder_deps="libxavs2" +libxevd_decoder_deps="libxevd" libxeve_encoder_deps="libxeve" libxvid_encoder_deps="libxvid" libzvbi_teletext_decoder_deps="libzvbi" @@ -6835,6 +6838,7 @@ enabled libx265 && require_pkg_config libx265 x265 x265.h x265_api_get require_cpp_condition libx265 x265.h "X265_BUILD >= 89" enabled libxavs && require libxavs "stdint.h xavs.h" xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs" enabled libxavs2 && require_pkg_config libxavs2 "xavs2 >= 1.3.0" "stdint.h xavs2.h" xavs2_api_get +enabled libxevd && require_pkg_config libxevd "xevd >= 0.4.1" "xevd.h" xevd_decode enabled libxeve && require_pkg_config libxeve "xeve >= 0.4.3" "xeve.h" xeve_encode enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore enabled libzimg && require_pkg_config libzimg "zimg >= 2.7.0" zimg.h zimg_get_api_version diff --git a/doc/decoders.texi b/doc/decoders.texi index 09b8314dd2..6311af229f 100644 --- a/doc/decoders.texi +++ b/doc/decoders.texi @@ -130,6 +130,30 @@ Set amount of frame threads to use during decoding. The default value is 0 (auto @end table +@section libxevd + +eXtra-fast Essential Video Decoder (XEVD) MPEG-5 EVC decoder wrapper. + +This decoder requires the presence of the libxevd headers and library +during configuration. You need to explicitly configure the build with +@option{--enable-libxevd}. + +The xevd project website is at @url{https://github.com/mpeg5/xevd}. + +@subsection Options + +The following options are supported by the libxevd wrapper. +The xevd-equivalent options or values are listed in parentheses for easy migration. + +To get a more accurate and extensive documentation of the libxevd options, +invoke the command @code{xevd_app --help} or consult the libxevd documentation. + +@table @option +@item threads (@emph{threads}) +Force to use a specific number of threads + +@end table + @section QSV Decoders The family of Intel QuickSync Video decoders (VC1, MPEG-2, H.264, HEVC, diff --git a/doc/general_contents.texi b/doc/general_contents.texi index c6a997bfd6..8e08f5ebc3 100644 --- a/doc/general_contents.texi +++ b/doc/general_contents.texi @@ -351,6 +351,14 @@ Go to @url{https://github.com/mpeg5/xeve} and follow the instructions for installing the XEVE library. Then pass @code{--enable-libxeve} to configure to enable it. +@section eXtra-fast Essential Video Decoder (XEVD) + +FFmpeg can make use of the XEVD library for EVC video decoding. + +Go to @url{https://github.com/mpeg5/xevd} and follow the instructions for +installing the XEVD library. Then pass @code{--enable-libxevd} to configure to +enable it. + @section ZVBI ZVBI is a VBI decoding library which can be used by FFmpeg to decode DVB @@ -953,7 +961,7 @@ following image formats are supported: @item Escape 124 @tab @tab X @item Escape 130 @tab @tab X @item EVC / MPEG-5 Part 1@tab X @tab X -@tab encoding and decoding supported through external library libxeve +@tab encoding and decoding supported through external libraries libxeve and libxevd @item FFmpeg video codec #1 @tab X @tab X @tab lossless codec
Re: [FFmpeg-devel] [PATCH] fftools/ffprobe: fix handling parse_options() return value
On 7/26/2023 12:31 PM, Anton Khirnov wrote: --- fftools/ffprobe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index a39185f6fe..81610c097b 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -4113,7 +4113,7 @@ int main(int argc, char **argv) show_banner(argc, argv, options); ret = parse_options(NULL, argc, argv, options, opt_input_file); if (ret < 0) { -ret = AVERROR_EXIT ? 0 : ret; +ret = (ret == AVERROR_EXIT) ? 0 : ret; goto end; } LGTM. ___ 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] avformat/movenc: Fix writing a sample size of 0 for PCM in MP4
On 7/26/23 11:37, Zhao Zhili wrote: I think you mixed up PCM in mp4 (-f mp4) and PCM in quicktime format (-f mov). There is no support of mux PCM in mp4 before the patch. And demux PCM in mp4 only works by chance. Let's focus on improve current situation, there isn't much to look back. I double-checked my test sample that I thought was muxed with FFmpeg 6.0, and actually the lavf version matches the most recent one. FFmpeg 6.0 does reject it for muxing in MP4. Sorry for the mixup. RZ ___ 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] avformat/movenc: fix sample size being zero in pcmC
On 7/26/23 11:22, Zhao Zhili wrote: From: ffmpeg-devel On Behalf Of Raphaël Zumer Sent: 2023年7月26日 21:38 To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH 1/2] avformat/movenc: fix sample size being zero in pcmC On 7/25/23 23:45, Zhao Zhili wrote: From: Zhao Zhili -avio_w8(pb, track->par->bits_per_raw_sample); +sample_size = track->par->bits_per_raw_sample; +if (!sample_size) +sample_size = av_get_exact_bits_per_sample(track->par->codec_id); +av_assert0(sample_size); +avio_w8(pb, sample_size); Why not just replace bits_per_raw_sample completely with av_get_exact_bits_per_sample()? Are there edge cases, like incorrect codec ID, or sample sizes smaller than specified by the codec ID (and if there is ever a mismatch, which is expected in pcmC?) If not, there should be no need to prioritize bits_per_raw_sample in the first place and add a fallback - going straight to av_get_exact_bits_per_sample() should suffice and keep the code simpler. Check bits_per_raw_sample first for a little bit of performance. Don't use bits_per_coded_sample because it make less sense in this case and to keep the code simpler. I doubt it is worth the trouble, but my opinion is not important if no one else cares. As noted in another thread, bits_per_raw_sample seems to always be 0 when muxing PCM to MP4 with FFmpeg, whereas bits_per_coded_sample has the correct value from the samples that I tested. That's only one usecase. bits_per_coded_sample has been set while bit_per_raw_sample wasn't only because the implementation of wav demux and there's no encoding process. (You can try -c:a pcm_s16le) There are more usecases to support, e.g., only use mp4 muxer without any demuxer or encoder. User can create and set a AVCodecParameters manually, and let bits_per_coded_sample be zero. That is fair, I just wanted to point out the mismatch as a potential (separate) issue. RZ ___ 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 v3 2/2] lavf: add prores bitstream demuxer and muxer
On Wed, 26 Jul 2023 at 13:55, Derek Buitenhuis wrote: > On 7/26/2023 10:28 AM, hung kuishing wrote: > > Signed-off-by: clarkh > > --- > > libavformat/Makefile | 2 ++ > > libavformat/allformats.c | 2 ++ > > libavformat/proresdec.c | 66 > > libavformat/rawenc.c | 13 > > 4 files changed, 83 insertions(+) > > create mode 100644 libavformat/proresdec.c > > At this point I am giving this a strong NAK. > > Both my initial comment[1] and subsequent comment[2] about the first one > being ignore, > have been ignored. It is a simple question. > I agree we should not be perpetuating custom formats such as raw ProRes. Kieran ___ 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 v3 2/2] lavf: add prores bitstream demuxer and muxer
hung kuishing: >> From: ffmpeg-devel On Behalf Of >> Derek Buitenhuis >> Sent: Wednesday, July 26, 2023 8:55 PM >> To: ffmpeg-devel@ffmpeg.org >> Subject: Re: [FFmpeg-devel] [PATCH v3 2/2] lavf: add prores bitstream >> demuxer and muxer >> >> On 7/26/2023 10:28 AM, hung kuishing wrote: >>> Signed-off-by: clarkh >>> --- >>> libavformat/Makefile | 2 ++ >>> libavformat/allformats.c | 2 ++ >>> libavformat/proresdec.c | 66 >> >>> libavformat/rawenc.c | 13 >>> 4 files changed, 83 insertions(+) >>> create mode 100644 libavformat/proresdec.c >> >> At this point I am giving this a strong NAK. >> >> Both my initial comment[1] and subsequent comment[2] about the >> first one being ignore, have been ignored. It is a simple question. > > Sorry for not replying to your question in time! > This patch originated from a need in my work to wrap the ProRes bitstream > generated by ffmpeg into another mov wrapper. So there are no files in the wild for this? Then there is no point in this. Or is this something that other mov wrappers (you meant muxers!?) accept? (Couldn't you just have used e.g. nut (or even mov itself) to temporarily store the ProRes data and then pipe this to to the foreign muxer?) - Andreas ___ 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] hevcdsp_idct_neon.S: Avoid unnecessary mov.
From: Reimar Döffinger ret can be given an argument instead. This is also consistent with how other assembler code in FFmpeg does it. --- libavcodec/aarch64/hevcdsp_idct_neon.S | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavcodec/aarch64/hevcdsp_idct_neon.S b/libavcodec/aarch64/hevcdsp_idct_neon.S index b7f23386a4..f7142c939c 100644 --- a/libavcodec/aarch64/hevcdsp_idct_neon.S +++ b/libavcodec/aarch64/hevcdsp_idct_neon.S @@ -617,8 +617,7 @@ function ff_hevc_idct_16x16_\bitdepth\()_neon, export=1 add sp, sp, #640 -mov x30, x15 -ret +ret x15 endfunc .endm @@ -814,8 +813,7 @@ function ff_hevc_idct_32x32_\bitdepth\()_neon, export=1 .endr add sp, sp, #2432 -mov x30, x15 -ret +ret x15 endfunc .endm -- 2.37.1 (Apple Git-137.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".
Re: [FFmpeg-devel] [PATCH] hevcdsp_idct_neon.S: Avoid unnecessary mov.
On Wed, 26 Jul 2023, reimar.doeffin...@gmx.de wrote: From: Reimar Döffinger ret can be given an argument instead. This is also consistent with how other assembler code in FFmpeg does it. --- libavcodec/aarch64/hevcdsp_idct_neon.S | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavcodec/aarch64/hevcdsp_idct_neon.S b/libavcodec/aarch64/hevcdsp_idct_neon.S index b7f23386a4..f7142c939c 100644 --- a/libavcodec/aarch64/hevcdsp_idct_neon.S +++ b/libavcodec/aarch64/hevcdsp_idct_neon.S @@ -617,8 +617,7 @@ function ff_hevc_idct_16x16_\bitdepth\()_neon, export=1 add sp, sp, #640 -mov x30, x15 -ret +ret x15 endfunc .endm @@ -814,8 +813,7 @@ function ff_hevc_idct_32x32_\bitdepth\()_neon, export=1 .endr add sp, sp, #2432 -mov x30, x15 -ret +ret x15 endfunc .endm LGTM, assuming checkasm still passes. // Martin ___ 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 v4 3/7] avcodec/webp_parser: parse each frame into one packet
tis 2023-07-25 klockan 16:18 +0200 skrev Thilo Borgmann: > Am 25.07.23 um 14:24 schrieb Tomas Härdin: > > > + // Extremely simplified key frame detection: > > > + // - the first frame (containing headers) is marked as a key > > > frame > > > + // - other frames are marked as non-key frames > > > > Is there a more proper way of doing this? > > All frames (except the ANMF chunks) are INTRA, and all of them have a > WEBP tag. > Whereas all ANMF chunks are in the same WEBP chunk as their reference > frame. > So it should really be as simple as it is to mark all WEBP frames as > key frames as the code does. > What more dedicated do you have in mind? Nah mostly just curious. It just feels so weird when VP8 intra already exists. Maybe I'm missing something. Browsers already support VP8 after all. > The logic as-is works with all samples I have, animated and not. > Seems to also align well with their example file layouts. > You have a more weird one? Nope /Tomas ___ 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 v2 0/3] avcodec: move HDR10 (MDCV/CLL) SEI handling to h2645_sei
On Tue, Jul 25, 2023 at 10:29 PM Jan Ekström wrote: > > This allows parsing code to be re-utilized from H.264, as well as probably > from VVC in the future. > > This additionally eases verification of the AVCodecContext side data patch > set, which includes libx264 integration for HDR10 side data. > > Changes from v1: > * Reordered the new h2645_sei include to correct location as per alphabetical > order. Thanks for Leo Izen for noticing this. > * Cleaned up the mastering_display_metadata.h include in hevcdec, as that file > no longer directly handles AVContentLightMetadata or > AVMasteringDisplayMetadata. > > Notes: > * In addition to testing with FATE, looking at the show_frames ffprobe output > for a UHD BD sample with each IRAP containing these SEI entries, the > behavior is the same as before with regards to each frame having the side > data persist. > > There is also no change with tests I've done with a UHD BD mp4 remux as well > as an iphone 12 sample I had around, So I think I have not modified the HEVC > behavior in any great manner. > * As for H.264, it now automatically gains support for these SEI messages. It > seems like its definition of CVS (coded video sequence) is from one IDR to > another (essentially a GOP). That said, currently the decoder resets the SEI > setup in decode_nal_units, which means that the side data only persist for > a single frame. > Unless there are objections, I will apply this tomorrow evening as this is a strict improvement over the current situation where the parsing is limited to HEVC and at least checking with ffprobe does not show regressions for HEVC. Jan ___ 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 v2 5/5] fftools/ffmpeg: support applying container level cropping
tis 2023-07-25 klockan 14:09 -0300 skrev James Almer: > Signed-off-by: James Almer > --- > Now inserting a filter into the graph. This looks useful for MXF > + { "apply_cropping", HAS_ARG | OPT_BOOL | OPT_SPEC | > + OPT_EXPERT | > OPT_INPUT, { .off = > OFFSET(apply_cropping) }, > + "Apply frame cropping instead of exporting it" }, Hm. Can this be applied automatically for ffplay? When transcoding I expect the typical use case is to not crop and to carry the metadata over. MXF -> MOV for example. But when playing I expect one just wants to see the display rectangle. /Tomas ___ 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 v2 5/5] fftools/ffmpeg: support applying container level cropping
On 7/26/2023 6:42 PM, Tomas Härdin wrote: tis 2023-07-25 klockan 14:09 -0300 skrev James Almer: Signed-off-by: James Almer --- Now inserting a filter into the graph. This looks useful for MXF + { "apply_cropping", HAS_ARG | OPT_BOOL | OPT_SPEC | + OPT_EXPERT | OPT_INPUT, { .off = OFFSET(apply_cropping) }, + "Apply frame cropping instead of exporting it" }, Hm. Can this be applied automatically for ffplay? When transcoding I expect the typical use case is to not crop and to carry the metadata over. MXF -> MOV for example. But when playing I expect one just wants to see the display rectangle. You want it to be disabled by default on ffmpeg but enabled in ffplay? For the latter, something like: diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 5212ad053e..217fc3e45a 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -36,6 +36,7 @@ #include "libavutil/eval.h" #include "libavutil/mathematics.h" #include "libavutil/pixdesc.h" +#include "libavutil/intreadwrite.h" #include "libavutil/imgutils.h" #include "libavutil/dict.h" #include "libavutil/fifo.h" @@ -346,6 +347,7 @@ static const char **vfilters_list = NULL; static int nb_vfilters = 0; static char *afilters = NULL; static int autorotate = 1; +static int apply_cropping = 1; static int find_stream_info = 1; static int filter_nbthreads = 0; @@ -1922,6 +1924,27 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c } } +if (apply_cropping) { +size_t cropping_size; +uint8_t *cropping = av_stream_get_side_data(is->video_st, AV_PKT_DATA_FRAME_CROPPING, &cropping_size); + +if (cropping && cropping_size == sizeof(uint32_t) * 4) { +char crop_buf[64]; +int top= AV_RL32(cropping + 0); +int bottom = AV_RL32(cropping + 4); +int left = AV_RL32(cropping + 8); +int right = AV_RL32(cropping + 12); + +if (top < 0 || bottom < 0 || left < 0 || right < 0) { +ret = AVERROR(EINVAL); +goto fail; +} + +snprintf(crop_buf, sizeof(crop_buf), "w=iw-%d-%d:h=ih-%d-%d", left, right, top, bottom); +INSERT_FILT("crop", crop_buf); +} +} + if ((ret = configure_filtergraph(graph, vfilters, filt_src, last_filter)) < 0) goto fail; @@ -3593,6 +3616,7 @@ static const OptionDef options[] = { { "scodec", HAS_ARG | OPT_STRING | OPT_EXPERT, { &subtitle_codec_name }, "force subtitle decoder", "decoder_name" }, { "vcodec", HAS_ARG | OPT_STRING | OPT_EXPERT, {&video_codec_name }, "force video decoder","decoder_name" }, { "autorotate", OPT_BOOL, { &autorotate }, "automatically rotate video", "" }, +{ "apply_cropping", OPT_BOOL, { &apply_cropping }, "apply frame cropping", "" }, { "find_stream_info", OPT_BOOL | OPT_INPUT | OPT_EXPERT, { &find_stream_info }, "read and decode the streams to fill missing information with heuristics" }, { "filter_threads", HAS_ARG | OPT_INT | OPT_EXPERT, { &filter_nbthreads }, "number of filter threads per graph" }, Would do it, but i don't know if this affects the AVCodecContext option of the same name too or not (to apply or not bitstream level cropping, like the h264 one, which is obviously enabled by default). To have it disabled on ffmpeg by default, i think the following would work (on top of this patch): diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 1209cf2046..a37c136cf9 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -1086,10 +1086,11 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) ist->autorotate = 1; MATCH_PER_STREAM_OPT(autorotate, i, ist->autorotate, ic, st); -ist->apply_cropping = 1; +ist->apply_cropping = -1; MATCH_PER_STREAM_OPT(apply_cropping, i, ist->apply_cropping, ic, st); -av_dict_set_int(&o->g->codec_opts, "apply_cropping", ist->apply_cropping, 0); +if (ist->apply_cropping >= 0) +av_dict_set_int(&o->g->codec_opts, "apply_cropping", ist->apply_cropping, 0); MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st); if (codec_tag) { diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 8cadb4732c..5df52ef718 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1419,7 +1419,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, return ret; } -if (ist->apply_cropping && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) { +if (ist->apply_cropping > 0 && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) { size_t cropping_size; uint8_t *cropping = av_stream_get_side_data(ist->st, AV_PKT_DATA_FRAME_CROPPING, &cropping_size); And actually work fine with the AVCodecContext option. ___ ffmpeg-devel mai
Re: [FFmpeg-devel] [PATCH v8 2/6] avformat/flvdec: support demux hevc in enhanced flv
On Thu, Apr 13, 2023 at 05:44:37PM +0800, Steven Liu wrote: > Signed-off-by: Steven Liu > --- > libavformat/flvdec.c | 58 ++-- > 1 file changed, 50 insertions(+), 8 deletions(-) > > diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c > index d83edff727..6a1e6e7ff0 100644 > --- a/libavformat/flvdec.c > +++ b/libavformat/flvdec.c > @@ -79,6 +79,8 @@ typedef struct FLVContext { > int64_t last_ts; > int64_t time_offset; > int64_t time_pos; > + > +uint8_t exheader; > } FLVContext; > > /* AMF date type */ > @@ -302,13 +304,25 @@ static void flv_set_audio_codec(AVFormatContext *s, > AVStream *astream, > } > } > > -static int flv_same_video_codec(AVCodecParameters *vpar, int flags) > +static int flv_same_video_codec(AVFormatContext *s, AVCodecParameters *vpar, > int flags) > { > int flv_codecid = flags & FLV_VIDEO_CODECID_MASK; > +FLVContext *flv = s->priv_data; > > if (!vpar->codec_id && !vpar->codec_tag) > return 1; > > +if (flv->exheader) { > +uint8_t *codec_id_str = (uint8_t *)s->pb->buf_ptr; > +uint32_t codec_id = codec_id_str[3] | codec_id_str[2] << 8 | > codec_id_str[1] << 16 | codec_id_str[0] << 24; pb->buf_ptr is in general not supposed to be directly accessed In this case here it segfaults READ of size 1 at 0x610003b7 thread T0 #0 0x7f928d in flv_same_video_codec ffmpeg/libavformat/flvdec.c:317:29 #1 0x7f928d in flv_read_packet ffmpeg/libavformat/flvdec.c:1177 #2 0x6ff32f in ff_read_packet ffmpeg/libavformat/demux.c:575:15 #3 0x70a2fd in read_frame_internal ffmpeg/libavformat/demux.c:1263:15 #4 0x71d158 in avformat_find_stream_info ffmpeg/libavformat/demux.c:2634:15 #5 0x4c821b in LLVMFuzzerTestOneInput ffmpeg/tools/target_dem_fuzzer.c:206:11 can you remove pb->buf_ptr use ? I can fix it too but i have no testcase and fate doesnt cover this so my fix would be untested ... thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator signature.asc Description: PGP signature ___ 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/4] avcodec/rtv1: Check if the minimal size is available in decode_rtv1()
Signed-off-by: Michael Niedermayer --- libavcodec/rtv1.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/rtv1.c b/libavcodec/rtv1.c index 4b202e6a21..95fa9210d8 100644 --- a/libavcodec/rtv1.c +++ b/libavcodec/rtv1.c @@ -44,6 +44,8 @@ static int decode_rtv1(GetByteContext *gb, uint8_t *dst, ptrdiff_t linesize, uint8_t block[8] = { 0 }; int run = 0; +if (bytestream2_get_bytes_left(gb) < (width / 4) * (height / 4) / 0x * 4) +return AVERROR_INVALIDDATA; for (int y = 0; y < height; y += 4) { for (int x = 0; x < width * 4; x += 16) { int mode = 0; @@ -126,7 +128,9 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p, dst = p->data[0] + p->linesize[0] * (avctx->coded_height - 1); linesize = -p->linesize[0]; -decode_rtv1(&gb, dst, linesize, width, height, flags, dsp->dxt1_block); +ret = decode_rtv1(&gb, dst, linesize, width, height, flags, dsp->dxt1_block); +if (ret < 0) +return ret; p->pict_type = AV_PICTURE_TYPE_I; p->flags |= AV_FRAME_FLAG_KEY; -- 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/4] tools/target_dec_fuzzer: Adjust threshold for rtv1
Fixes: 60499/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RTV1_fuzzer-5020295866744832 Fixes: Timeout Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- tools/target_dec_fuzzer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index 165951dc9d..570291fa79 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -274,6 +274,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case AV_CODEC_ID_RKA: maxsamples /= 256; break; case AV_CODEC_ID_RSCC:maxpixels /= 256; break; case AV_CODEC_ID_RASC:maxpixels /= 16;break; +case AV_CODEC_ID_RTV1:maxpixels /= 16;break; case AV_CODEC_ID_SANM:maxpixels /= 16;break; case AV_CODEC_ID_SCPR:maxpixels /= 32;break; case AV_CODEC_ID_SCREENPRESSO:maxpixels /= 64;break; -- 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 3/4] avcodec/vvc_parser: Avoid undefined overflow in POC computation
The comments to the function say that it does not implement the spec and instead follows VTM. This patch is quite likely not the right solution and more intended to show the issue to people knowing the specific part of VTM ... Fixes: signed integer overflow: 2147483392 + 256 cannot be represented in type 'int' Fixes: 60505/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6216675924770816 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/vvc_parser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/vvc_parser.c b/libavcodec/vvc_parser.c index 3951ebe50a..c661595e1e 100644 --- a/libavcodec/vvc_parser.c +++ b/libavcodec/vvc_parser.c @@ -225,10 +225,10 @@ static void get_slice_poc(VVCParserContext *s, int *poc, } else { if ((poc_lsb < prev_poc_lsb) && ((prev_poc_lsb - poc_lsb) >= (max_poc_lsb / 2))) -poc_msb = prev_poc_msb + max_poc_lsb; +poc_msb = prev_poc_msb + (unsigned)max_poc_lsb; else if ((poc_lsb > prev_poc_lsb) && ((poc_lsb - prev_poc_lsb) > (max_poc_lsb / 2))) -poc_msb = prev_poc_msb - max_poc_lsb; +poc_msb = prev_poc_msb - (unsigned)max_poc_lsb; else poc_msb = prev_poc_msb; } -- 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 4/4] avcodec/evc_ps: Check num_ref_pic_list_in_sps
Fixes: out of array write Fixes: 60798/clusterfuzz-testcase-minimized-ffmpeg_BSF_EVC_FRAME_MERGE_fuzzer-4633529766772736 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/evc_ps.c | 9 + 1 file changed, 9 insertions(+) diff --git a/libavcodec/evc_ps.c b/libavcodec/evc_ps.c index 04ee6a45e6..64384a392c 100644 --- a/libavcodec/evc_ps.c +++ b/libavcodec/evc_ps.c @@ -243,11 +243,20 @@ int ff_evc_parse_sps(GetBitContext *gb, EVCParamSets *ps) sps->rpl1_same_as_rpl0_flag = get_bits1(gb); sps->num_ref_pic_list_in_sps[0] = get_ue_golomb(gb); +if ((unsigned)sps->num_ref_pic_list_in_sps[0] >= EVC_MAX_NUM_RPLS) { +ret = AVERROR_INVALIDDATA; +goto fail; +} + for (int i = 0; i < sps->num_ref_pic_list_in_sps[0]; ++i) ref_pic_list_struct(gb, &sps->rpls[0][i]); if (!sps->rpl1_same_as_rpl0_flag) { sps->num_ref_pic_list_in_sps[1] = get_ue_golomb(gb); +if ((unsigned)sps->num_ref_pic_list_in_sps[1] >= EVC_MAX_NUM_RPLS) { +ret = AVERROR_INVALIDDATA; +goto fail; +} for (int i = 0; i < sps->num_ref_pic_list_in_sps[1]; ++i) ref_pic_list_struct(gb, &sps->rpls[1][i]); } -- 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".
Re: [FFmpeg-devel] [PATCH 4/4] avcodec/evc_ps: Check num_ref_pic_list_in_sps
On 7/26/2023 8:59 PM, Michael Niedermayer wrote: Fixes: out of array write Fixes: 60798/clusterfuzz-testcase-minimized-ffmpeg_BSF_EVC_FRAME_MERGE_fuzzer-4633529766772736 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/evc_ps.c | 9 + 1 file changed, 9 insertions(+) diff --git a/libavcodec/evc_ps.c b/libavcodec/evc_ps.c index 04ee6a45e6..64384a392c 100644 --- a/libavcodec/evc_ps.c +++ b/libavcodec/evc_ps.c @@ -243,11 +243,20 @@ int ff_evc_parse_sps(GetBitContext *gb, EVCParamSets *ps) sps->rpl1_same_as_rpl0_flag = get_bits1(gb); sps->num_ref_pic_list_in_sps[0] = get_ue_golomb(gb); +if ((unsigned)sps->num_ref_pic_list_in_sps[0] >= EVC_MAX_NUM_RPLS) { EVC_MAX_NUM_RPLS should be 64, not 32 as it's currently defined. So change that too and it LGTM. +ret = AVERROR_INVALIDDATA; +goto fail; +} + for (int i = 0; i < sps->num_ref_pic_list_in_sps[0]; ++i) ref_pic_list_struct(gb, &sps->rpls[0][i]); if (!sps->rpl1_same_as_rpl0_flag) { sps->num_ref_pic_list_in_sps[1] = get_ue_golomb(gb); +if ((unsigned)sps->num_ref_pic_list_in_sps[1] >= EVC_MAX_NUM_RPLS) { +ret = AVERROR_INVALIDDATA; +goto fail; +} for (int i = 0; i < sps->num_ref_pic_list_in_sps[1]; ++i) ref_pic_list_struct(gb, &sps->rpls[1][i]); } ___ 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] avformat/flvdec: use avio operation instead of pb->buf_ptr use
fix segfaults: READ of size 1 at 0x610003b7 thread T0 #0 0x7f928d in flv_same_video_codec ffmpeg/libavformat/flvdec.c:317:29 #1 0x7f928d in flv_read_packet ffmpeg/libavformat/flvdec.c:1177 #2 0x6ff32f in ff_read_packet ffmpeg/libavformat/demux.c:575:15 #3 0x70a2fd in read_frame_internal ffmpeg/libavformat/demux.c:1263:15 #4 0x71d158 in avformat_find_stream_info ffmpeg/libavformat/demux.c:2634:15 #5 0x4c821b in LLVMFuzzerTestOneInput ffmpeg/tools/target_dem_fuzzer.c:206:11 Signed-off-by: Steven Liu --- libavformat/flvdec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 3fe21622f7..003e4d7691 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -313,8 +313,9 @@ static int flv_same_video_codec(AVFormatContext *s, AVCodecParameters *vpar, int return 1; if (flv->exheader) { -uint8_t *codec_id_str = (uint8_t *)s->pb->buf_ptr; -uint32_t codec_id = codec_id_str[3] | codec_id_str[2] << 8 | codec_id_str[1] << 16 | codec_id_str[0] << 24; +int64_t pos = avio_tell(s->pb); +uint32_t codec_id = avio_rb32(s->pb); +avio_seek(s->pb, pos, SEEK_SET); switch(codec_id) { case MKBETAG('h', 'v', 'c', '1'): return vpar->codec_id == AV_CODEC_ID_HEVC; -- 2.40.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] Add NVENC "Maximum encoded slice size in bytes" for H.264/HEVC codecs.
From: Aleksoid Date: Thu, 27 Jul 2023 12:26:23 +1000 Subject: [PATCH] Add NVENC "Maximum encoded slice size in bytes" for H.264/HEVC codecs. Signed-off-by: Aleksoid --- libavcodec/nvenc.c | 18 ++ libavcodec/nvenc.h | 1 + libavcodec/nvenc_h264.c | 2 ++ libavcodec/nvenc_hevc.c | 2 ++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 0b6417674e..c82fcbfe1e 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -1166,8 +1166,13 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx) || vui->videoFormat != 5 || vui->videoFullRangeFlag != 0); -h264->sliceMode = 3; -h264->sliceModeData = avctx->slices > 0 ? avctx->slices : 1; +if (ctx->max_slice_size > 0) { +h264->sliceMode = 1; +h264->sliceModeData = ctx->max_slice_size; +} else { +h264->sliceMode = 3; +h264->sliceModeData = avctx->slices > 0 ? avctx->slices : 1; +} if (ctx->intra_refresh) { h264->enableIntraRefresh = 1; @@ -1287,8 +1292,13 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx) || vui->videoFormat != 5 || vui->videoFullRangeFlag != 0); -hevc->sliceMode = 3; -hevc->sliceModeData = avctx->slices > 0 ? avctx->slices : 1; +if (ctx->max_slice_size > 0) { +hevc->sliceMode = 1; +hevc->sliceModeData = ctx->max_slice_size; +} else { +hevc->sliceMode = 3; +hevc->sliceModeData = avctx->slices > 0 ? avctx->slices : 1; +} if (ctx->intra_refresh) { hevc->enableIntraRefresh = 1; diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h index 3a4b456a41..cf0e8e5946 100644 --- a/libavcodec/nvenc.h +++ b/libavcodec/nvenc.h @@ -262,6 +262,7 @@ typedef struct NvencContext int udu_sei; int timing_info; int highbitdepth; +int max_slice_size; } NvencContext; int ff_nvenc_encode_init(AVCodecContext *avctx); diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c index a99860998e..4440e49b25 100644 --- a/libavcodec/nvenc_h264.c +++ b/libavcodec/nvenc_h264.c @@ -206,6 +206,8 @@ static const AVOption options[] = { OFFSET(intra_refresh),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { "single-slice-intra-refresh", "Use single slice intra refresh", OFFSET(single_slice_intra_refresh), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, +{ "max_slice_size", "Maximum encoded slice size in bytes", + OFFSET(max_slice_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, { "constrained-encoding", "Enable constrainedFrame encoding where each slice in the constrained picture is independent of other slices", OFFSET(constrained_encoding), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { NULL } diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c index a02f277888..e606655e7e 100644 --- a/libavcodec/nvenc_hevc.c +++ b/libavcodec/nvenc_hevc.c @@ -187,6 +187,8 @@ static const AVOption options[] = { OFFSET(intra_refresh),AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { "single-slice-intra-refresh", "Use single slice intra refresh", OFFSET(single_slice_intra_refresh), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, +{ "max_slice_size", "Maximum encoded slice size in bytes", + OFFSET(max_slice_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, { "constrained-encoding", "Enable constrainedFrame encoding where each slice in the constrained picture is independent of other slices", OFFSET(constrained_encoding), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { NULL } -- 2.41.0.windows.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".
Re: [FFmpeg-devel] [PATCH v8 2/6] avformat/flvdec: support demux hevc in enhanced flv
Michael Niedermayer 于2023年7月27日周四 07:27写道: Hi Michael, > > On Thu, Apr 13, 2023 at 05:44:37PM +0800, Steven Liu wrote: > > Signed-off-by: Steven Liu > > --- > > libavformat/flvdec.c | 58 ++-- > > 1 file changed, 50 insertions(+), 8 deletions(-) > > > > diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c > > index d83edff727..6a1e6e7ff0 100644 > > --- a/libavformat/flvdec.c > > +++ b/libavformat/flvdec.c > > @@ -79,6 +79,8 @@ typedef struct FLVContext { > > int64_t last_ts; > > int64_t time_offset; > > int64_t time_pos; > > + > > +uint8_t exheader; > > } FLVContext; > > > > /* AMF date type */ > > @@ -302,13 +304,25 @@ static void flv_set_audio_codec(AVFormatContext *s, > > AVStream *astream, > > } > > } > > > > -static int flv_same_video_codec(AVCodecParameters *vpar, int flags) > > +static int flv_same_video_codec(AVFormatContext *s, AVCodecParameters > > *vpar, int flags) > > { > > int flv_codecid = flags & FLV_VIDEO_CODECID_MASK; > > +FLVContext *flv = s->priv_data; > > > > if (!vpar->codec_id && !vpar->codec_tag) > > return 1; > > > > +if (flv->exheader) { > > +uint8_t *codec_id_str = (uint8_t *)s->pb->buf_ptr; > > +uint32_t codec_id = codec_id_str[3] | codec_id_str[2] << 8 | > > codec_id_str[1] << 16 | codec_id_str[0] << 24; > > pb->buf_ptr is in general not supposed to be directly accessed > > In this case here it segfaults > > READ of size 1 at 0x610003b7 thread T0 > #0 0x7f928d in flv_same_video_codec ffmpeg/libavformat/flvdec.c:317:29 > #1 0x7f928d in flv_read_packet ffmpeg/libavformat/flvdec.c:1177 > #2 0x6ff32f in ff_read_packet ffmpeg/libavformat/demux.c:575:15 > #3 0x70a2fd in read_frame_internal ffmpeg/libavformat/demux.c:1263:15 > #4 0x71d158 in avformat_find_stream_info > ffmpeg/libavformat/demux.c:2634:15 > #5 0x4c821b in LLVMFuzzerTestOneInput > ffmpeg/tools/target_dem_fuzzer.c:206:11 > > can you remove pb->buf_ptr use ? > I can fix it too but i have no testcase and fate doesnt cover this so my fix > would > be untested ... https://patchwork.ffmpeg.org/project/ffmpeg/patch/20230727023744.20984-1...@chinaffmpeg.org/ Can this patch fix it? > > thx > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Democracy is the form of government in which you can choose your dictator > ___ > 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". Thanks Steven ___ 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] avformat/flvdec: use avio operation instead of pb->buf_ptr use
On Thu, Jul 27, 2023 at 4:38 AM Steven Liu wrote: > > fix segfaults: > READ of size 1 at 0x610003b7 thread T0 > #0 0x7f928d in flv_same_video_codec ffmpeg/libavformat/flvdec.c:317:29 > #1 0x7f928d in flv_read_packet ffmpeg/libavformat/flvdec.c:1177 > #2 0x6ff32f in ff_read_packet ffmpeg/libavformat/demux.c:575:15 > #3 0x70a2fd in read_frame_internal ffmpeg/libavformat/demux.c:1263:15 > #4 0x71d158 in avformat_find_stream_info > ffmpeg/libavformat/demux.c:2634:15 > #5 0x4c821b in LLVMFuzzerTestOneInput > ffmpeg/tools/target_dem_fuzzer.c:206:11 > > Signed-off-by: Steven Liu > --- > libavformat/flvdec.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c > index 3fe21622f7..003e4d7691 100644 > --- a/libavformat/flvdec.c > +++ b/libavformat/flvdec.c > @@ -313,8 +313,9 @@ static int flv_same_video_codec(AVFormatContext *s, > AVCodecParameters *vpar, int > return 1; > > if (flv->exheader) { > -uint8_t *codec_id_str = (uint8_t *)s->pb->buf_ptr; > -uint32_t codec_id = codec_id_str[3] | codec_id_str[2] << 8 | > codec_id_str[1] << 16 | codec_id_str[0] << 24; > +int64_t pos = avio_tell(s->pb); > +uint32_t codec_id = avio_rb32(s->pb); > +avio_seek(s->pb, pos, SEEK_SET); > switch(codec_id) { > case MKBETAG('h', 'v', 'c', '1'): > return vpar->codec_id == AV_CODEC_ID_HEVC; You don't need to store the position, just do a relative seek backwards by 4 bytes. I would also recommend to include a call to ffio_ensure_seekback so it works with streams. eg. something like this: ffio_ensure_seekback(s->pb, 4); avio_rb32(s->pb); avio_seek(s->pb, -4, SEEK_CUR); Add appropriate error checking, in particular for ffio_ensure_seekback, etc. - Hendrik ___ 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".