Re: [FFmpeg-devel] [PATCH] avutil/tx: Use proper default scale for double MDCT/RDFT
On Sat, Feb 17, 2024 at 08:44:47PM +0100, Andreas Rheinhardt wrote: > Fixes a bug and a Clang warning: > "use of logical '||' with constant operand [-Wconstant-logical-operand]" > > Signed-off-by: Andreas Rheinhardt > --- > libavutil/tx.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/libavutil/tx.c b/libavutil/tx.c > index cc360cff31..f7aa409d72 100644 > --- a/libavutil/tx.c > +++ b/libavutil/tx.c > @@ -914,7 +914,8 @@ av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, > enum AVTXType type, > if (!(flags & AV_TX_INPLACE)) > flags |= FF_TX_OUT_OF_PLACE; > > -if (!scale && ((type == AV_TX_FLOAT_MDCT) || (type == AV_TX_INT32_MDCT) > || (type == AV_TX_FLOAT_RDFT) || (AV_TX_INT32_RDFT))) > +if (!scale && ((type == AV_TX_FLOAT_MDCT) || (type == AV_TX_INT32_MDCT) > || > + (type == AV_TX_FLOAT_RDFT) || (type == AV_TX_INT32_RDFT))) > scale = _scale_f; > else if (!scale && ((type == AV_TX_DOUBLE_MDCT) || (type == > AV_TX_DOUBLE_RDFT))) > scale = _scale_d; pls apply -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B) ___ 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] avcodec/s302m: enable non-PCM decoding
On 2024-02-18 01:25 am, Anton Khirnov wrote: Quoting Gyan Doshi (2024-02-17 13:37:38) On 2024-02-17 05:52 pm, Anton Khirnov wrote: Quoting Gyan Doshi (2024-02-17 12:46:27) As a TC member who is part of the disagreement, I believe your participation is recused. No, I do not think "TC members who commented on a patch lose their right to vote" is a reasonable interpretation of that rule. I refer to "If the disagreement involves a member of the TC, that member should recuse themselves from the decision" at https://ffmpeg.org/community.html#Announcement You clearly are one of the parties to the disagreement, and "recuse themselves from the decision" is self-explanatory. Such a maximalist interpretation makes no sense - why should my opinion become invalid because I commented on a patch, but not if I kept it to myself and let someone else object to your patch? a) I didn't make that rule, just pointed it out b) what "maximalist" interpretation? - I think the current patch is fine, you don't. That's a disagreement and you're involved in it, so the rule tells you to not be a judge. This is not a complex body of law or obscure legalese , just a trivial application of the rule composed in school-level English. c) your opinion hasn't been made invalid - it just can't be a weighted vote in the TC decision. And it's not merely because you 'commented' - see (b). Regards, Gyan ___ 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/5] avcodec/bsf/(hevc|vvc)_mp4toannexb: Ensure extradata_size < INT_MAX
On 2/17/2024 11:41 PM, Andreas Rheinhardt wrote: AVCodecParameters.extradata_size is an int. Signed-off-by: Andreas Rheinhardt --- libavcodec/bsf/hevc_mp4toannexb.c | 2 +- libavcodec/bsf/vvc_mp4toannexb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/bsf/hevc_mp4toannexb.c b/libavcodec/bsf/hevc_mp4toannexb.c index 8eec18f31e..c0df2b79a6 100644 --- a/libavcodec/bsf/hevc_mp4toannexb.c +++ b/libavcodec/bsf/hevc_mp4toannexb.c @@ -69,7 +69,7 @@ static int hevc_extradata_to_annexb(AVBSFContext *ctx) if (!nalu_len || nalu_len > bytestream2_get_bytes_left() || -4 + AV_INPUT_BUFFER_PADDING_SIZE + nalu_len > SIZE_MAX - new_extradata_size) { +4 + nalu_len > FFMIN(INT_MAX, SIZE_MAX) - AV_INPUT_BUFFER_PADDING_SIZE - new_extradata_size) { ret = AVERROR_INVALIDDATA; goto fail; } diff --git a/libavcodec/bsf/vvc_mp4toannexb.c b/libavcodec/bsf/vvc_mp4toannexb.c index 36bdae8f49..1b851f3223 100644 --- a/libavcodec/bsf/vvc_mp4toannexb.c +++ b/libavcodec/bsf/vvc_mp4toannexb.c @@ -159,7 +159,7 @@ static int vvc_extradata_to_annexb(AVBSFContext *ctx) if (!nalu_len || nalu_len > bytestream2_get_bytes_left() || -4 + AV_INPUT_BUFFER_PADDING_SIZE + nalu_len > SIZE_MAX - new_extradata_size) { +4 + nalu_len > FFMIN(INT_MAX, SIZE_MAX) - AV_INPUT_BUFFER_PADDING_SIZE - new_extradata_size) { Just use INT_MAX, there's no point in this check. Do you expect a system where an int is smaller than the type meant to store size of buffers in memory? ret = AVERROR_INVALIDDATA; goto fail; } ___ 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/5] avfilter/vf_signature: Allocate arrays together
Andreas Rheinhardt: > Signed-off-by: Andreas Rheinhardt > --- > libavfilter/vf_signature.c | 9 ++--- > 1 file changed, 2 insertions(+), 7 deletions(-) > > diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c > index 4896e8f2c1..eb48bf773d 100644 > --- a/libavfilter/vf_signature.c > +++ b/libavfilter/vf_signature.c > @@ -250,14 +250,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *picref) > int64_t* elemsignature; > uint64_t* sortsignature; > > -elemsignature = av_malloc_array(elemcat->elem_count, > sizeof(int64_t)); > +elemsignature = av_malloc_array(elemcat->elem_count, 2 * > sizeof(int64_t)); > if (!elemsignature) > return AVERROR(ENOMEM); > -sortsignature = av_malloc_array(elemcat->elem_count, > sizeof(int64_t)); > -if (!sortsignature) { > -av_freep(); > -return AVERROR(ENOMEM); > -} > +sortsignature = elemsignature + elemcat->elem_count; > > for (j = 0; j < elemcat->elem_count; j++) { > blocksum = 0; > @@ -307,7 +303,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame > *picref) > f++; > } > av_freep(); > -av_freep(); > } > > /* confidence */ Will apply this patchset tomorrow unless there are objections. - 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 5/5] avcodec/bsf/vvc_mp4toannexb: Don't realloc when creating new extradata
AVCodecParameters.extradata is supposed to be allocated with av_malloc(); av_realloc() and its wrappers do not guarantee the proper alignment. Therefore parse the extradata twice: Once to check its validity and to determine the eventual size and a second time to actually write the new extradata. (Of course, not reallocating the buffer is beneficial in itself.) Signed-off-by: Andreas Rheinhardt --- libavcodec/bsf/vvc_mp4toannexb.c | 51 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/libavcodec/bsf/vvc_mp4toannexb.c b/libavcodec/bsf/vvc_mp4toannexb.c index bfb0338116..1879c1fab9 100644 --- a/libavcodec/bsf/vvc_mp4toannexb.c +++ b/libavcodec/bsf/vvc_mp4toannexb.c @@ -38,13 +38,11 @@ typedef struct VVCBSFContext { } VVCBSFContext; static int vvc_extradata_to_annexb_internal(void *logctx, GetByteContext *gb, -uint8_t **new_extradatap, +uint8_t *new_extradata, size_t *new_extradata_sizep) { int num_arrays = bytestream2_get_byte(gb); -uint8_t *new_extradata = NULL; size_t new_extradata_size = 0; -int ret; for (int i = 0; i < num_arrays; i++) { int cnt; @@ -55,15 +53,15 @@ static int vvc_extradata_to_annexb_internal(void *logctx, GetByteContext *gb, else cnt = bytestream2_get_be16(gb); -av_log(logctx, AV_LOG_DEBUG, "nalu_type %d cnt %d\n", type, cnt); +if (!new_extradata) +av_log(logctx, AV_LOG_DEBUG, "nalu_type %d cnt %d\n", type, cnt); if (!(type == VVC_OPI_NUT || type == VVC_DCI_NUT || type == VVC_VPS_NUT || type == VVC_SPS_NUT || type == VVC_PPS_NUT || type == VVC_PREFIX_SEI_NUT || type == VVC_SUFFIX_SEI_NUT)) { av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit type in extradata: %d\n", type); -ret = AVERROR_INVALIDDATA; -goto fail; +return AVERROR_INVALIDDATA; } for (int j = 0; j < cnt; j++) { @@ -72,30 +70,21 @@ static int vvc_extradata_to_annexb_internal(void *logctx, GetByteContext *gb, if (!nalu_len || nalu_len > bytestream2_get_bytes_left(gb) || 4 + nalu_len > FFMIN(INT_MAX, SIZE_MAX) - AV_INPUT_BUFFER_PADDING_SIZE - new_extradata_size) { -ret = AVERROR_INVALIDDATA; -goto fail; +return AVERROR_INVALIDDATA; } -ret = av_reallocp(_extradata, new_extradata_size + nalu_len + 4 - + AV_INPUT_BUFFER_PADDING_SIZE); -if (ret < 0) -goto fail; - -AV_WB32(new_extradata + new_extradata_size, 1); // add the startcode -bytestream2_get_buffer(gb, new_extradata + new_extradata_size + 4, - nalu_len); +if (new_extradata) { +AV_WB32(new_extradata + new_extradata_size, 1); // add the startcode +bytestream2_get_bufferu(gb, new_extradata + new_extradata_size + 4, +nalu_len); +} else +bytestream2_skipu(gb, nalu_len); new_extradata_size += 4 + nalu_len; -memset(new_extradata + new_extradata_size, 0, - AV_INPUT_BUFFER_PADDING_SIZE); } } -*new_extradatap = new_extradata; *new_extradata_sizep = new_extradata_size; return 0; -fail: -av_freep(_extradata); -return ret; } static int vvc_extradata_to_annexb(AVBSFContext *ctx) @@ -193,10 +182,20 @@ static int vvc_extradata_to_annexb(AVBSFContext *ctx) max_picture_width, max_picture_height, avg_frame_rate); } -ret = vvc_extradata_to_annexb_internal(ctx, , _extradata, - _extradata_size); -if (ret < 0) -return ret; +while (1) { +GetByteContext gb_bak = gb; +ret = vvc_extradata_to_annexb_internal(ctx, , new_extradata, + _extradata_size); +if (ret < 0) +return ret; +if (new_extradata || !new_extradata_size) +break; +new_extradata = av_malloc(new_extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); +if (!new_extradata) +return AVERROR(ENOMEM); +memset(new_extradata + new_extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); +gb = gb_bak; +} av_freep(>par_out->extradata); ctx->par_out->extradata = new_extradata; -- 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 4/5] avcodec/bsf/vvc_mp4toannexb: Factor creating new extradata out
This is in preparation for the next commit. Signed-off-by: Andreas Rheinhardt --- libavcodec/bsf/vvc_mp4toannexb.c | 116 ++- 1 file changed, 67 insertions(+), 49 deletions(-) diff --git a/libavcodec/bsf/vvc_mp4toannexb.c b/libavcodec/bsf/vvc_mp4toannexb.c index 1b851f3223..bfb0338116 100644 --- a/libavcodec/bsf/vvc_mp4toannexb.c +++ b/libavcodec/bsf/vvc_mp4toannexb.c @@ -37,16 +37,77 @@ typedef struct VVCBSFContext { int extradata_parsed; } VVCBSFContext; +static int vvc_extradata_to_annexb_internal(void *logctx, GetByteContext *gb, +uint8_t **new_extradatap, +size_t *new_extradata_sizep) +{ +int num_arrays = bytestream2_get_byte(gb); +uint8_t *new_extradata = NULL; +size_t new_extradata_size = 0; +int ret; + +for (int i = 0; i < num_arrays; i++) { +int cnt; +int type = bytestream2_get_byte(gb) & 0x1f; + +if (type == VVC_OPI_NUT || type == VVC_DCI_NUT) +cnt = 1; +else +cnt = bytestream2_get_be16(gb); + +av_log(logctx, AV_LOG_DEBUG, "nalu_type %d cnt %d\n", type, cnt); + +if (!(type == VVC_OPI_NUT || type == VVC_DCI_NUT || + type == VVC_VPS_NUT || type == VVC_SPS_NUT || type == VVC_PPS_NUT + || type == VVC_PREFIX_SEI_NUT || type == VVC_SUFFIX_SEI_NUT)) { +av_log(logctx, AV_LOG_ERROR, + "Invalid NAL unit type in extradata: %d\n", type); +ret = AVERROR_INVALIDDATA; +goto fail; +} + +for (int j = 0; j < cnt; j++) { +const int nalu_len = bytestream2_get_be16(gb); + +if (!nalu_len || +nalu_len > bytestream2_get_bytes_left(gb) || +4 + nalu_len > FFMIN(INT_MAX, SIZE_MAX) - AV_INPUT_BUFFER_PADDING_SIZE - new_extradata_size) { +ret = AVERROR_INVALIDDATA; +goto fail; +} +ret = av_reallocp(_extradata, new_extradata_size + nalu_len + 4 + + AV_INPUT_BUFFER_PADDING_SIZE); +if (ret < 0) +goto fail; + +AV_WB32(new_extradata + new_extradata_size, 1); // add the startcode +bytestream2_get_buffer(gb, new_extradata + new_extradata_size + 4, + nalu_len); +new_extradata_size += 4 + nalu_len; +memset(new_extradata + new_extradata_size, 0, + AV_INPUT_BUFFER_PADDING_SIZE); +} +} + +*new_extradatap = new_extradata; +*new_extradata_sizep = new_extradata_size; + +return 0; +fail: +av_freep(_extradata); +return ret; +} + static int vvc_extradata_to_annexb(AVBSFContext *ctx) { GetByteContext gb; -int length_size, num_arrays, i, j; +int length_size, i, j; int ret = 0; int temp = 0; int ptl_present; uint8_t *new_extradata = NULL; -size_t new_extradata_size = 0; +size_t new_extradata_size; int max_picture_width = 0; int max_picture_height = 0; @@ -132,50 +193,10 @@ static int vvc_extradata_to_annexb(AVBSFContext *ctx) max_picture_width, max_picture_height, avg_frame_rate); } -num_arrays = bytestream2_get_byte(); - -for (i = 0; i < num_arrays; i++) { -int cnt; -int type = bytestream2_get_byte() & 0x1f; - -if (type == VVC_OPI_NUT || type == VVC_DCI_NUT) -cnt = 1; -else -cnt = bytestream2_get_be16(); - -av_log(ctx, AV_LOG_DEBUG, "nalu_type %d cnt %d\n", type, cnt); - -if (!(type == VVC_OPI_NUT || type == VVC_DCI_NUT || - type == VVC_VPS_NUT || type == VVC_SPS_NUT || type == VVC_PPS_NUT - || type == VVC_PREFIX_SEI_NUT || type == VVC_SUFFIX_SEI_NUT)) { -av_log(ctx, AV_LOG_ERROR, - "Invalid NAL unit type in extradata: %d\n", type); -ret = AVERROR_INVALIDDATA; -goto fail; -} - -for (j = 0; j < cnt; j++) { -const int nalu_len = bytestream2_get_be16(); - -if (!nalu_len || -nalu_len > bytestream2_get_bytes_left() || -4 + nalu_len > FFMIN(INT_MAX, SIZE_MAX) - AV_INPUT_BUFFER_PADDING_SIZE - new_extradata_size) { -ret = AVERROR_INVALIDDATA; -goto fail; -} -ret = av_reallocp(_extradata, new_extradata_size + nalu_len + 4 - + AV_INPUT_BUFFER_PADDING_SIZE); -if (ret < 0) -goto fail; - -AV_WB32(new_extradata + new_extradata_size, 1); // add the startcode -bytestream2_get_buffer(, new_extradata + new_extradata_size + 4, - nalu_len); -new_extradata_size += 4 + nalu_len; -memset(new_extradata + new_extradata_size, 0, -
[FFmpeg-devel] [PATCH 3/5] avcodec/bsf/hevc_mp4toannexb: Don't realloc when creating new extradata
AVCodecParameters.extradata is supposed to be allocated with av_malloc(); av_realloc() and its wrappers do not guarantee the proper alignment. Therefore parse the extradata twice: Once to check its validity and to determine the eventual size and a second time to actually write the new extradata. (Of course, not reallocating the buffer is beneficial in itself.) Signed-off-by: Andreas Rheinhardt --- libavcodec/bsf/hevc_mp4toannexb.c | 44 +++ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/libavcodec/bsf/hevc_mp4toannexb.c b/libavcodec/bsf/hevc_mp4toannexb.c index a695cba370..f5424e95b8 100644 --- a/libavcodec/bsf/hevc_mp4toannexb.c +++ b/libavcodec/bsf/hevc_mp4toannexb.c @@ -38,13 +38,11 @@ typedef struct HEVCBSFContext { } HEVCBSFContext; static int hevc_extradata_to_annexb_internal(void *logctx, GetByteContext *gb, - uint8_t **new_extradatap, + uint8_t *new_extradata, size_t *new_extradata_sizep) { int num_arrays = bytestream2_get_byte(gb); -uint8_t *new_extradata = NULL; size_t new_extradata_size = 0; -int ret; for (int i = 0; i < num_arrays; i++) { int type = bytestream2_get_byte(gb) & 0x3f; @@ -54,8 +52,7 @@ static int hevc_extradata_to_annexb_internal(void *logctx, GetByteContext *gb, type == HEVC_NAL_SEI_PREFIX || type == HEVC_NAL_SEI_SUFFIX)) { av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit type in extradata: %d\n", type); -ret = AVERROR_INVALIDDATA; -goto fail; +return AVERROR_INVALIDDATA; } for (int j = 0; j < cnt; j++) { @@ -64,26 +61,19 @@ static int hevc_extradata_to_annexb_internal(void *logctx, GetByteContext *gb, if (!nalu_len || nalu_len > bytestream2_get_bytes_left(gb) || 4 + nalu_len > FFMIN(INT_MAX, SIZE_MAX) - AV_INPUT_BUFFER_PADDING_SIZE - new_extradata_size) { -ret = AVERROR_INVALIDDATA; -goto fail; +return AVERROR_INVALIDDATA; } -ret = av_reallocp(_extradata, new_extradata_size + nalu_len + 4 + AV_INPUT_BUFFER_PADDING_SIZE); -if (ret < 0) -goto fail; - -AV_WB32(new_extradata + new_extradata_size, 1); // add the startcode -bytestream2_get_buffer(gb, new_extradata + new_extradata_size + 4, nalu_len); +if (new_extradata) { +AV_WB32(new_extradata + new_extradata_size, 1); // add the startcode +bytestream2_get_bufferu(gb, new_extradata + new_extradata_size + 4, nalu_len); +} else +bytestream2_skipu(gb, nalu_len); new_extradata_size += 4 + nalu_len; -memset(new_extradata + new_extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); } } -*new_extradatap = new_extradata; *new_extradata_sizep = new_extradata_size; return 0; -fail: -av_freep(_extradata); -return ret; } static int hevc_extradata_to_annexb(AVBSFContext *ctx) @@ -100,10 +90,20 @@ static int hevc_extradata_to_annexb(AVBSFContext *ctx) bytestream2_skip(, 21); length_size = (bytestream2_get_byte() & 3) + 1; -ret = hevc_extradata_to_annexb_internal(ctx, , _extradata, -_extradata_size); -if (ret < 0) -return ret; +while (1) { +GetByteContext gb_bak = gb; +ret = hevc_extradata_to_annexb_internal(ctx, , new_extradata, +_extradata_size); +if (ret < 0) +return ret; +if (new_extradata || !new_extradata_size) +break; +new_extradata = av_malloc(new_extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); +if (!new_extradata) +return AVERROR(ENOMEM); +memset(new_extradata + new_extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); +gb = gb_bak; +} av_freep(>par_out->extradata); ctx->par_out->extradata = new_extradata; -- 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 2/5] avcodec/bsf/hevc_mp4toannexb: Factor creating new extradata out
This is in preparation for the next commit. Signed-off-by: Andreas Rheinhardt --- libavcodec/bsf/hevc_mp4toannexb.c | 64 --- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/libavcodec/bsf/hevc_mp4toannexb.c b/libavcodec/bsf/hevc_mp4toannexb.c index c0df2b79a6..a695cba370 100644 --- a/libavcodec/bsf/hevc_mp4toannexb.c +++ b/libavcodec/bsf/hevc_mp4toannexb.c @@ -37,38 +37,32 @@ typedef struct HEVCBSFContext { int extradata_parsed; } HEVCBSFContext; -static int hevc_extradata_to_annexb(AVBSFContext *ctx) +static int hevc_extradata_to_annexb_internal(void *logctx, GetByteContext *gb, + uint8_t **new_extradatap, + size_t *new_extradata_sizep) { -GetByteContext gb; -int length_size, num_arrays, i, j; -int ret = 0; - +int num_arrays = bytestream2_get_byte(gb); uint8_t *new_extradata = NULL; -size_t new_extradata_size = 0; - -bytestream2_init(, ctx->par_in->extradata, ctx->par_in->extradata_size); - -bytestream2_skip(, 21); -length_size = (bytestream2_get_byte() & 3) + 1; -num_arrays = bytestream2_get_byte(); +size_t new_extradata_size = 0; +int ret; -for (i = 0; i < num_arrays; i++) { -int type = bytestream2_get_byte() & 0x3f; -int cnt = bytestream2_get_be16(); +for (int i = 0; i < num_arrays; i++) { +int type = bytestream2_get_byte(gb) & 0x3f; +int cnt = bytestream2_get_be16(gb); if (!(type == HEVC_NAL_VPS || type == HEVC_NAL_SPS || type == HEVC_NAL_PPS || type == HEVC_NAL_SEI_PREFIX || type == HEVC_NAL_SEI_SUFFIX)) { -av_log(ctx, AV_LOG_ERROR, "Invalid NAL unit type in extradata: %d\n", +av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit type in extradata: %d\n", type); ret = AVERROR_INVALIDDATA; goto fail; } -for (j = 0; j < cnt; j++) { -const int nalu_len = bytestream2_get_be16(); +for (int j = 0; j < cnt; j++) { +const int nalu_len = bytestream2_get_be16(gb); if (!nalu_len || -nalu_len > bytestream2_get_bytes_left() || +nalu_len > bytestream2_get_bytes_left(gb) || 4 + nalu_len > FFMIN(INT_MAX, SIZE_MAX) - AV_INPUT_BUFFER_PADDING_SIZE - new_extradata_size) { ret = AVERROR_INVALIDDATA; goto fail; @@ -78,11 +72,38 @@ static int hevc_extradata_to_annexb(AVBSFContext *ctx) goto fail; AV_WB32(new_extradata + new_extradata_size, 1); // add the startcode -bytestream2_get_buffer(, new_extradata + new_extradata_size + 4, nalu_len); +bytestream2_get_buffer(gb, new_extradata + new_extradata_size + 4, nalu_len); new_extradata_size += 4 + nalu_len; memset(new_extradata + new_extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); } } +*new_extradatap = new_extradata; +*new_extradata_sizep = new_extradata_size; + +return 0; +fail: +av_freep(_extradata); +return ret; +} + +static int hevc_extradata_to_annexb(AVBSFContext *ctx) +{ +GetByteContext gb; +int length_size; +int ret = 0; + +uint8_t *new_extradata = NULL; +size_t new_extradata_size; + +bytestream2_init(, ctx->par_in->extradata, ctx->par_in->extradata_size); + +bytestream2_skip(, 21); +length_size = (bytestream2_get_byte() & 3) + 1; + +ret = hevc_extradata_to_annexb_internal(ctx, , _extradata, +_extradata_size); +if (ret < 0) +return ret; av_freep(>par_out->extradata); ctx->par_out->extradata = new_extradata; @@ -92,9 +113,6 @@ static int hevc_extradata_to_annexb(AVBSFContext *ctx) av_log(ctx, AV_LOG_WARNING, "No parameter sets in the extradata\n"); return length_size; -fail: -av_freep(_extradata); -return ret; } static int hevc_mp4toannexb_init(AVBSFContext *ctx) -- 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 1/5] avcodec/bsf/(hevc|vvc)_mp4toannexb: Ensure extradata_size < INT_MAX
AVCodecParameters.extradata_size is an int. Signed-off-by: Andreas Rheinhardt --- libavcodec/bsf/hevc_mp4toannexb.c | 2 +- libavcodec/bsf/vvc_mp4toannexb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/bsf/hevc_mp4toannexb.c b/libavcodec/bsf/hevc_mp4toannexb.c index 8eec18f31e..c0df2b79a6 100644 --- a/libavcodec/bsf/hevc_mp4toannexb.c +++ b/libavcodec/bsf/hevc_mp4toannexb.c @@ -69,7 +69,7 @@ static int hevc_extradata_to_annexb(AVBSFContext *ctx) if (!nalu_len || nalu_len > bytestream2_get_bytes_left() || -4 + AV_INPUT_BUFFER_PADDING_SIZE + nalu_len > SIZE_MAX - new_extradata_size) { +4 + nalu_len > FFMIN(INT_MAX, SIZE_MAX) - AV_INPUT_BUFFER_PADDING_SIZE - new_extradata_size) { ret = AVERROR_INVALIDDATA; goto fail; } diff --git a/libavcodec/bsf/vvc_mp4toannexb.c b/libavcodec/bsf/vvc_mp4toannexb.c index 36bdae8f49..1b851f3223 100644 --- a/libavcodec/bsf/vvc_mp4toannexb.c +++ b/libavcodec/bsf/vvc_mp4toannexb.c @@ -159,7 +159,7 @@ static int vvc_extradata_to_annexb(AVBSFContext *ctx) if (!nalu_len || nalu_len > bytestream2_get_bytes_left() || -4 + AV_INPUT_BUFFER_PADDING_SIZE + nalu_len > SIZE_MAX - new_extradata_size) { +4 + nalu_len > FFMIN(INT_MAX, SIZE_MAX) - AV_INPUT_BUFFER_PADDING_SIZE - new_extradata_size) { ret = AVERROR_INVALIDDATA; goto fail; } -- 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] lavc/vvc: Fail inter prediction if using IBC
Hi Frank, Thank you for the patch. The IBC is working on my side. I will send out the patch in the following weeks. Could you send me the fuzz file? I want to ensure that it will not cause my patch to crash. On Sat, Feb 17, 2024 at 10:48 PM Frank Plowman wrote: > IBC is not yet implemented. Fail the inter prediction process with > AVERROR_PATCHWELCOME if the bitstream uses IBC. Fixes crashes due to > out-of-bounds reads when attempting to decode IBC bitstreams. > > Signed-off-by: Frank Plowman > --- > libavcodec/vvc/vvc_inter.c | 30 +++--- > 1 file changed, 23 insertions(+), 7 deletions(-) > > diff --git a/libavcodec/vvc/vvc_inter.c b/libavcodec/vvc/vvc_inter.c > index e05f3db93e..cb5e8d4ef6 100644 > --- a/libavcodec/vvc/vvc_inter.c > +++ b/libavcodec/vvc/vvc_inter.c > @@ -779,7 +779,7 @@ static void derive_sb_mv(VVCLocalContext *lc, MvField > *mv, MvField *orig_mv, int > } > } > > -static void pred_regular_blk(VVCLocalContext *lc, const int skip_ciip) > +static int pred_regular_blk(VVCLocalContext *lc, const int skip_ciip) > { > const VVCFrameContext *fc = lc->fc; > const CodingUnit *cu= lc->cu; > @@ -789,7 +789,7 @@ static void pred_regular_blk(VVCLocalContext *lc, > const int skip_ciip) > int sbw, sbh, sb_bdof_flag = 0; > > if (cu->ciip_flag && skip_ciip) > -return; > +return 0; > > sbw = cu->cb_width / mi->num_sb_x; > sbh = cu->cb_height / mi->num_sb_y; > @@ -803,11 +803,17 @@ static void pred_regular_blk(VVCLocalContext *lc, > const int skip_ciip) > ff_vvc_set_neighbour_available(lc, x0, y0, sbw, sbh); > > derive_sb_mv(lc, , _mv, _bdof_flag, x0, y0, sbw, > sbh); > +if (mv.pred_flag == PF_INTRA) { > +avpriv_report_missing_feature(fc->log_ctx, "Intra Block > Copy"); > +return AVERROR_PATCHWELCOME; > +} > pred_regular_luma(lc, mi->hpel_if_idx, mi->hpel_if_idx, , > x0, y0, sbw, sbh, _mv, sb_bdof_flag); > if (fc->ps.sps->r->sps_chroma_format_idc) > pred_regular_chroma(lc, , x0, y0, sbw, sbh, _mv, > pu->dmvr_flag); > } > } > + > +return 0; > } > > static void derive_affine_mvc(MvField *mvc, const VVCFrameContext *fc, > const MvField *mv, > @@ -872,23 +878,29 @@ static void pred_affine_blk(VVCLocalContext *lc) > } > } > > -static void predict_inter(VVCLocalContext *lc) > +static int predict_inter(VVCLocalContext *lc) > { > const VVCFrameContext *fc = lc->fc; > const CodingUnit *cu= lc->cu; > const PredictionUnit *pu= >pu; > +int ret; > > if (pu->merge_gpm_flag) > pred_gpm_blk(lc); > else if (pu->inter_affine_flag) > pred_affine_blk(lc); > -else > -pred_regular_blk(lc, 1);//intra block is not ready yet, skip > ciip > +else { > +ret = pred_regular_blk(lc, 1);//intra block is not ready yet, > skip ciip > +if (ret < 0) > +return ret; > +} > > if (lc->sc->sh.r->sh_lmcs_used_flag && !cu->ciip_flag) { > uint8_t* dst0 = POS(0, cu->x0, cu->y0); > fc->vvcdsp.lmcs.filter(dst0, fc->frame->linesize[LUMA], > cu->cb_width, cu->cb_height, fc->ps.lmcs.fwd_lut); > } > + > +return 0; > } > > static int has_inter_luma(const CodingUnit *cu) > @@ -901,11 +913,15 @@ int ff_vvc_predict_inter(VVCLocalContext *lc, const > int rs) > const VVCFrameContext *fc = lc->fc; > const CTU *ctu = fc->tab.ctus + rs; > CodingUnit *cu = ctu->cus; > +int ret; > > while (cu) { > lc->cu = cu; > -if (has_inter_luma(cu)) > -predict_inter(lc); > +if (has_inter_luma(cu)) { > +ret = predict_inter(lc); > +if (ret < 0) > +return ret; > +} > cu = cu->next; > } > > -- > 2.43.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 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] tools: Add target_sws_fuzzer.c
On 2/17/2024 10:03 PM, Michael Niedermayer wrote: On Sat, Feb 17, 2024 at 09:13:21PM -0300, James Almer wrote: On 2/17/2024 8:48 PM, Michael Niedermayer wrote: Signed-off-by: Michael Niedermayer --- Makefile | 3 + tools/Makefile| 3 + tools/target_sws_fuzzer.c | 168 ++ 3 files changed, 174 insertions(+) create mode 100644 tools/target_sws_fuzzer.c diff --git a/Makefile b/Makefile index dbc930270b3..b309dbc4db9 100644 --- a/Makefile +++ b/Makefile @@ -64,6 +64,9 @@ tools/target_dem_fuzzer$(EXESUF): tools/target_dem_fuzzer.o $(FF_DEP_LIBS) tools/target_io_dem_fuzzer$(EXESUF): tools/target_io_dem_fuzzer.o $(FF_DEP_LIBS) $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH) +tools/target_sws_fuzzer$(EXESUF): tools/target_sws_fuzzer.o $(FF_DEP_LIBS) + $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH) + tools/enum_options$(EXESUF): ELIBS = $(FF_EXTRALIBS) tools/enum_options$(EXESUF): $(FF_DEP_LIBS) diff --git a/tools/Makefile b/tools/Makefile index dee6a416688..72e8e709a8d 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -17,6 +17,9 @@ tools/target_dem_fuzzer.o: tools/target_dem_fuzzer.c tools/target_io_dem_fuzzer.o: tools/target_dem_fuzzer.c $(COMPILE_C) -DIO_FLAT=0 +tools/target_sws_fuzzer.o: tools/target_sws_fuzzer.c + $(COMPILE_C) + tools/enc_recon_frame_test$(EXESUF): tools/decode_simple.o tools/venc_data_dump$(EXESUF): tools/decode_simple.o tools/scale_slice_test$(EXESUF): tools/decode_simple.o diff --git a/tools/target_sws_fuzzer.c b/tools/target_sws_fuzzer.c new file mode 100644 index 000..babb6e81629 --- /dev/null +++ b/tools/target_sws_fuzzer.c @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2024 Michael Niedermayer + * + * 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 "config.h" +#include "libavutil/avassert.h" +#include "libavutil/avstring.h" +#include "libavutil/cpu.h" +#include "libavutil/imgutils.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/opt.h" + +#include "libavcodec/bytestream.h" + +#include "libswscale/swscale.h" + + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); + +static void error(const char *err) +{ +fprintf(stderr, "%s", err); +exit(1); +} + +static int alloc_plane(uint8_t *data[AV_VIDEO_MAX_PLANES], int stride[AV_VIDEO_MAX_PLANES], int w, int h, int format, int *hshift, int *vshift) +{ +int ret = av_image_fill_linesizes(stride, format, w); +if (ret < 0) +return -1; + +av_pix_fmt_get_chroma_sub_sample(format, hshift, vshift); + +for(int p=0; p av_image_alloc()? Would be better to actually test sws with buffers created by our own public helpers. av_image_alloc() allocates the planes in one continous piece so teh fuzzer would not be able to detect accesses over the end of the first or accesses prior the 2nd. So this is not possible Then use av_image_fill_plane_sizes() after av_image_fill_linesizes() and then allocate the buffers with its output. See fuzz_video_get_buffer() in test_dec_fuzzer.c It's best if we don't rewrite basic buffer allocation and size calculation functions every time we add new code. +} + +static void free_plane(uint8_t *data[AV_VIDEO_MAX_PLANES]) +{ +for(int p=0; p AV_VIDEO_MAX_PLANES. will change +struct SwsContext *sws = NULL; +const AVPixFmtDescriptor *desc_src, *desc_dst; + +if (size > 128) { +GetByteContext gbc; +int64_t flags64; + +size -= 128; +bytestream2_init(, data + size, 128); +srcW = bytestream2_get_le32() % 256; +srcH = bytestream2_get_le32() % 256; +dstW = bytestream2_get_le32() % 256; +dstH = bytestream2_get_le32() % 256; +flags = bytestream2_get_le32(); + +srcFormat = bytestream2_get_le32() % AV_PIX_FMT_NB; +dstFormat = bytestream2_get_le32() % AV_PIX_FMT_NB; nit: Maybe sanitize the choices with sws_isSupportedInput() and sws_isSupportedOutput()? Unless having sws_init_context() fail with invalid arguments is also intended. Honestly i do not know which way is best Leave it as is, it's not important. + +
[FFmpeg-devel] [PATCH] avutil/version: Remove outdated checks
Signed-off-by: Andreas Rheinhardt --- libavutil/version.c | 16 1 file changed, 16 deletions(-) diff --git a/libavutil/version.c b/libavutil/version.c index 75c5c0d1a8..baead7c4a0 100644 --- a/libavutil/version.c +++ b/libavutil/version.c @@ -18,14 +18,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include - #include "config.h" #include "avassert.h" #include "avutil.h" -#include "common.h" -#include "libm.h" -#include "log.h" #include "samplefmt.h" #include "version.h" @@ -44,17 +39,6 @@ unsigned avutil_version(void) av_assert0(AV_PICTURE_TYPE_BI == 7); av_assert0(LIBAVUTIL_VERSION_MICRO >= 100); -av_assert0(((size_t)-1) > 0); // C guarantees this but if false on a platform we care about revert at least b284e1ffe343d6697fb950d1ee517bafda8a9844 - -if (av_sat_dadd32(1, 2) != 5) { -av_log(NULL, AV_LOG_FATAL, "Libavutil has been built with a broken binutils, please upgrade binutils and rebuild\n"); -abort(); -} - -if (llrint(1LL<<60) != 1LL<<60) { -av_log(NULL, AV_LOG_ERROR, "Libavutil has been linked to a broken llrint()\n"); -} - return LIBAVUTIL_VERSION_INT; } -- 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 7/7] avcodec/movtextenc: Don't copy data around unnecessarily
Using av_bprint_init_for_buffer() avoids copying data into the internal AVBPrint buffer (or worse: to allocate a temporary buffer in case the internal buffer does not suffice). Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextenc.c | 33 ++--- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index 7aa74d7c9d..fd8c7dc9f7 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -22,7 +22,6 @@ #include #include "avcodec.h" #include "libavutil/opt.h" -#include "libavutil/avstring.h" #include "libavutil/intreadwrite.h" #include "libavutil/mem.h" #include "libavutil/common.h" @@ -170,7 +169,6 @@ static int mov_text_encode_close(AVCodecContext *avctx) ff_ass_split_free(s->ass_ctx); av_freep(>style_attributes); av_freep(>fonts); -av_bprint_finalize(>buffer, NULL); return 0; } @@ -183,6 +181,9 @@ static int encode_sample_description(AVCodecContext *avctx) int font_names_total_len = 0; MovTextContext *s = avctx->priv_data; uint8_t buf[30], *p = buf; +int ret; + +av_bprint_init(>buffer, 0, INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE + 1); // 0x00, 0x00, 0x00, 0x00, // uint32_t displayFlags // 0x01, // int8_t horizontal-justification @@ -306,19 +307,23 @@ static int encode_sample_description(AVCodecContext *avctx) // }; if (!av_bprint_is_complete(>buffer)) { -return AVERROR(ENOMEM); +ret = AVERROR(ENOMEM); +goto fail; } avctx->extradata_size = s->buffer.len; avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { -return AVERROR(ENOMEM); +ret = AVERROR(ENOMEM); +goto fail; } memcpy(avctx->extradata, s->buffer.str, avctx->extradata_size); -av_bprint_clear(>buffer); +ret = 0; +fail: +av_bprint_finalize(>buffer, NULL); -return 0; +return ret; } static av_cold int mov_text_encode_init(AVCodecContext *avctx) @@ -327,8 +332,6 @@ static av_cold int mov_text_encode_init(AVCodecContext *avctx) MovTextContext *s = avctx->priv_data; s->avctx = avctx; -av_bprint_init(>buffer, 0, AV_BPRINT_SIZE_UNLIMITED); - s->ass_ctx = ff_ass_split(avctx->subtitle_header); if (!s->ass_ctx) return AVERROR_INVALIDDATA; @@ -640,10 +643,14 @@ static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf, ASSDialog *dialog; int i, length; +if (bufsize < 3) +goto too_small; + s->text_pos = 0; s->count = 0; s->box_flags = 0; -av_bprint_clear(>buffer); + +av_bprint_init_for_buffer(>buffer, buf + 2, bufsize - 2); for (i = 0; i < sub->num_rects; i++) { const char *ass = sub->rects[i]->ass; @@ -663,23 +670,19 @@ static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf, if (s->buffer.len > UINT16_MAX) return AVERROR(ERANGE); AV_WB16(buf, s->buffer.len); -buf += 2; for (size_t j = 0; j < box_count; j++) box_types[j].encode(s); -if (!av_bprint_is_complete(>buffer)) -return AVERROR(ENOMEM); - if (!s->buffer.len) return 0; -if (s->buffer.len > bufsize - 3) { +if (!av_bprint_is_complete(>buffer)) { +too_small: av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n"); return AVERROR_BUFFER_TOO_SMALL; } -memcpy(buf, s->buffer.str, s->buffer.len); length = s->buffer.len + 2; return length; -- 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 6/7] avcodec/srtenc, webvttenc: Use av_printf_format
Signed-off-by: Andreas Rheinhardt --- libavcodec/srtenc.c| 5 + libavcodec/webvttenc.c | 5 + 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/libavcodec/srtenc.c b/libavcodec/srtenc.c index 9b6f61ebd1..a607beb990 100644 --- a/libavcodec/srtenc.c +++ b/libavcodec/srtenc.c @@ -41,10 +41,7 @@ typedef struct { } SRTContext; -#ifdef __GNUC__ -__attribute__ ((__format__ (__printf__, 2, 3))) -#endif -static void srt_print(SRTContext *s, const char *str, ...) +static av_printf_format(2, 3) void srt_print(SRTContext *s, const char *str, ...) { va_list vargs; va_start(vargs, str); diff --git a/libavcodec/webvttenc.c b/libavcodec/webvttenc.c index 9922f33485..3b66b4f2dd 100644 --- a/libavcodec/webvttenc.c +++ b/libavcodec/webvttenc.c @@ -38,10 +38,7 @@ typedef struct { int stack_ptr; } WebVTTContext; -#ifdef __GNUC__ -__attribute__ ((__format__ (__printf__, 2, 3))) -#endif -static void webvtt_print(WebVTTContext *s, const char *str, ...) +static av_printf_format(2, 3) void webvtt_print(WebVTTContext *s, const char *str, ...) { va_list vargs; va_start(vargs, str); -- 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 5/7] avcodec/ttmlenc: Remove always-true check
Signed-off-by: Andreas Rheinhardt --- libavcodec/ttmlenc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavcodec/ttmlenc.c b/libavcodec/ttmlenc.c index f48274d2ea..779cb75199 100644 --- a/libavcodec/ttmlenc.c +++ b/libavcodec/ttmlenc.c @@ -351,9 +351,8 @@ static int ttml_write_header_content(AVCodecContext *avctx) memcpy(avctx->extradata, TTMLENC_EXTRADATA_SIGNATURE, TTMLENC_EXTRADATA_SIGNATURE_SIZE); -if (additional_extradata_size) -memcpy(avctx->extradata + TTMLENC_EXTRADATA_SIGNATURE_SIZE, - s->buffer.str, additional_extradata_size); +memcpy(avctx->extradata + TTMLENC_EXTRADATA_SIGNATURE_SIZE, + s->buffer.str, additional_extradata_size); ret = 0; fail: -- 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 4/7] avcodec/ttmlenc: Don't copy data around unnecessarily
Using av_bprint_init_for_buffer() avoids copying data into the internal AVBPrint buffer (or worse: to allocate a temporary buffer in case the internal buffer does not suffice). Signed-off-by: Andreas Rheinhardt --- libavcodec/ttmlenc.c | 36 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/libavcodec/ttmlenc.c b/libavcodec/ttmlenc.c index 6a2ab23cab..f48274d2ea 100644 --- a/libavcodec/ttmlenc.c +++ b/libavcodec/ttmlenc.c @@ -29,11 +29,9 @@ #include "avcodec.h" #include "codec_internal.h" -#include "libavutil/avstring.h" #include "libavutil/bprint.h" #include "libavutil/internal.h" #include "ass_split.h" -#include "ass.h" #include "ttmlenc.h" typedef struct { @@ -84,7 +82,7 @@ static int ttml_encode_frame(AVCodecContext *avctx, uint8_t *buf, ASSDialog *dialog; int i; -av_bprint_clear(>buffer); +av_bprint_init_for_buffer(>buffer, buf, bufsize); for (i=0; inum_rects; i++) { const char *ass = sub->rects[i]->ass; @@ -129,14 +127,9 @@ static int ttml_encode_frame(AVCodecContext *avctx, uint8_t *buf, ff_ass_free_dialog(); } -if (!av_bprint_is_complete(>buffer)) -return AVERROR(ENOMEM); if (!s->buffer.len) return 0; - -// force null-termination, so in case our destination buffer is -// too small, the return value is larger than bufsize minus null. -if (av_strlcpy(buf, s->buffer.str, bufsize) > bufsize - 1) { +if (!av_bprint_is_complete(>buffer)) { av_log(avctx, AV_LOG_ERROR, "Buffer too small for TTML event.\n"); return AVERROR_BUFFER_TOO_SMALL; } @@ -150,8 +143,6 @@ static av_cold int ttml_encode_close(AVCodecContext *avctx) ff_ass_split_free(s->ass_ctx); -av_bprint_finalize(>buffer, NULL); - return 0; } @@ -306,6 +297,7 @@ static int ttml_write_header_content(AVCodecContext *avctx) const size_t base_extradata_size = TTMLENC_EXTRADATA_SIGNATURE_SIZE + 1 + AV_INPUT_BUFFER_PADDING_SIZE; size_t additional_extradata_size = 0; +int ret; if (script_info.play_res_x <= 0 || script_info.play_res_y <= 0) { av_log(avctx, AV_LOG_ERROR, @@ -314,6 +306,8 @@ static int ttml_write_header_content(AVCodecContext *avctx) return AVERROR_INVALIDDATA; } +av_bprint_init(>buffer, 0, INT_MAX - base_extradata_size); + // write the first string in extradata, attributes in the base "tt" element. av_bprintf(>buffer, TTML_DEFAULT_NAMESPACING); // the cell resolution is in character cells, so not exactly 1:1 against @@ -329,10 +323,10 @@ static int ttml_write_header_content(AVCodecContext *avctx) av_bprintf(>buffer, "\n"); for (int i = 0; i < ass->styles_count; i++) { -int ret = ttml_write_region(avctx, >buffer, script_info, -ass->styles[i]); +ret = ttml_write_region(avctx, >buffer, script_info, +ass->styles[i]); if (ret < 0) -return ret; +goto fail; } av_bprintf(>buffer, "\n"); @@ -340,14 +334,16 @@ static int ttml_write_header_content(AVCodecContext *avctx) av_bprint_chars(>buffer, '\0', 1); if (!av_bprint_is_complete(>buffer)) { -return AVERROR(ENOMEM); +ret = AVERROR(ENOMEM); +goto fail; } additional_extradata_size = s->buffer.len; if (!(avctx->extradata = av_mallocz(base_extradata_size + additional_extradata_size))) { -return AVERROR(ENOMEM); +ret = AVERROR(ENOMEM); +goto fail; } avctx->extradata_size = @@ -359,9 +355,11 @@ static int ttml_write_header_content(AVCodecContext *avctx) memcpy(avctx->extradata + TTMLENC_EXTRADATA_SIGNATURE_SIZE, s->buffer.str, additional_extradata_size); -av_bprint_clear(>buffer); +ret = 0; +fail: +av_bprint_finalize(>buffer, NULL); -return 0; +return ret; } static av_cold int ttml_encode_init(AVCodecContext *avctx) @@ -370,8 +368,6 @@ static av_cold int ttml_encode_init(AVCodecContext *avctx) int ret = AVERROR_BUG; s->avctx = avctx; -av_bprint_init(>buffer, 0, AV_BPRINT_SIZE_UNLIMITED); - if (!(s->ass_ctx = ff_ass_split(avctx->subtitle_header))) { return AVERROR_INVALIDDATA; } -- 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/7] avcodec/webvttenc: Don't copy data around unnecessarily
Using av_bprint_init_for_buffer() avoids copying data into the internal AVBPrint buffer (or worse: to allocate a temporary buffer in case the internal buffer does not suffice). It also ensures that the data is always 0-terminated. Signed-off-by: Andreas Rheinhardt --- libavcodec/webvttenc.c | 10 ++ 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libavcodec/webvttenc.c b/libavcodec/webvttenc.c index 4369aacb74..9922f33485 100644 --- a/libavcodec/webvttenc.c +++ b/libavcodec/webvttenc.c @@ -22,7 +22,6 @@ #include #include "avcodec.h" -#include "libavutil/avstring.h" #include "libavutil/bprint.h" #include "ass_split.h" #include "ass.h" @@ -162,7 +161,7 @@ static int webvtt_encode_frame(AVCodecContext *avctx, ASSDialog *dialog; int i; -av_bprint_clear(>buffer); +av_bprint_init_for_buffer(>buffer, buf, bufsize); for (i=0; inum_rects; i++) { const char *ass = sub->rects[i]->ass; @@ -180,16 +179,13 @@ static int webvtt_encode_frame(AVCodecContext *avctx, ff_ass_free_dialog(); } -if (!av_bprint_is_complete(>buffer)) -return AVERROR(ENOMEM); if (!s->buffer.len) return 0; -if (s->buffer.len > bufsize) { +if (!av_bprint_is_complete(>buffer)) { av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n"); return AVERROR_BUFFER_TOO_SMALL; } -memcpy(buf, s->buffer.str, s->buffer.len); return s->buffer.len; } @@ -198,7 +194,6 @@ static int webvtt_encode_close(AVCodecContext *avctx) { WebVTTContext *s = avctx->priv_data; ff_ass_split_free(s->ass_ctx); -av_bprint_finalize(>buffer, NULL); return 0; } @@ -207,7 +202,6 @@ static av_cold int webvtt_encode_init(AVCodecContext *avctx) WebVTTContext *s = avctx->priv_data; s->avctx = avctx; s->ass_ctx = ff_ass_split(avctx->subtitle_header); -av_bprint_init(>buffer, 0, AV_BPRINT_SIZE_UNLIMITED); return s->ass_ctx ? 0 : AVERROR_INVALIDDATA; } -- 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 2/7] avcodec/srtenc: Don't copy data around unnecessarily
Using av_bprint_init_for_buffer() avoids copying data into the internal AVBPrint buffer (or worse: to allocate a temporary buffer in case the internal buffer does not suffice). It also ensures that the data is always 0-terminated, whereas the current code never does this and returns success in case the length of the string to write and the size of the buffer coincide. Signed-off-by: Andreas Rheinhardt --- libavcodec/srtenc.c | 10 ++ 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libavcodec/srtenc.c b/libavcodec/srtenc.c index 7e36a2200c..9b6f61ebd1 100644 --- a/libavcodec/srtenc.c +++ b/libavcodec/srtenc.c @@ -23,7 +23,6 @@ #include #include "avcodec.h" -#include "libavutil/avstring.h" #include "libavutil/bprint.h" #include "ass_split.h" #include "ass.h" @@ -138,7 +137,6 @@ static av_cold int srt_encode_init(AVCodecContext *avctx) SRTContext *s = avctx->priv_data; s->avctx = avctx; s->ass_ctx = ff_ass_split(avctx->subtitle_header); -av_bprint_init(>buffer, 0, AV_BPRINT_SIZE_UNLIMITED); return s->ass_ctx ? 0 : AVERROR_INVALIDDATA; } @@ -237,7 +235,7 @@ static int encode_frame(AVCodecContext *avctx, ASSDialog *dialog; int i; -av_bprint_clear(>buffer); +av_bprint_init_for_buffer(>buffer, buf, bufsize); for (i=0; inum_rects; i++) { const char *ass = sub->rects[i]->ass; @@ -257,16 +255,13 @@ static int encode_frame(AVCodecContext *avctx, ff_ass_free_dialog(); } -if (!av_bprint_is_complete(>buffer)) -return AVERROR(ENOMEM); if (!s->buffer.len) return 0; -if (s->buffer.len > bufsize) { +if (!av_bprint_is_complete(>buffer)) { av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n"); return AVERROR_BUFFER_TOO_SMALL; } -memcpy(buf, s->buffer.str, s->buffer.len); return s->buffer.len; } @@ -287,7 +282,6 @@ static int srt_encode_close(AVCodecContext *avctx) { SRTContext *s = avctx->priv_data; ff_ass_split_free(s->ass_ctx); -av_bprint_finalize(>buffer, NULL); return 0; } -- 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 1/7] avcodec/assenc: Use size_t for length of string
Signed-off-by: Andreas Rheinhardt --- libavcodec/assenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/assenc.c b/libavcodec/assenc.c index e548b9fd3b..e734522729 100644 --- a/libavcodec/assenc.c +++ b/libavcodec/assenc.c @@ -45,7 +45,7 @@ static int ass_encode_frame(AVCodecContext *avctx, unsigned char *buf, int bufsize, const AVSubtitle *sub) { -int len; +size_t len; if (sub->num_rects != 1) { av_log(avctx, AV_LOG_ERROR, "Only one rect per AVSubtitle is supported in ASS.\n"); @@ -59,7 +59,7 @@ static int ass_encode_frame(AVCodecContext *avctx, len = av_strlcpy(buf, sub->rects[0]->ass, bufsize); -if (len > bufsize - 1) { +if (len >= bufsize) { av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n"); return AVERROR_BUFFER_TOO_SMALL; } -- 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] avcodec/avcodec: Deprecate AV_INPUT_BUFFER_MIN_SIZE
It used to be used with preallocated packet buffers with the old encode API, but said API is no more and therefore there is no reason for this to be public any more. So deprecate it and use an internal replacement for the encoders using it as an upper bound for the size of their headers. Signed-off-by: Andreas Rheinhardt --- doc/APIchanges | 3 +++ libavcodec/asvenc.c | 2 +- libavcodec/avcodec.h| 4 libavcodec/encode.h | 6 ++ libavcodec/ffv1enc.c| 4 ++-- libavcodec/flashsv2enc.c| 2 +- libavcodec/gif.c| 2 +- libavcodec/huffyuvenc.c | 2 +- libavcodec/j2kenc.c | 2 +- libavcodec/jpeglsenc.c | 2 +- libavcodec/libxvid.c| 2 +- libavcodec/ljpegenc.c | 2 +- libavcodec/msrleenc.c | 2 +- libavcodec/msvideo1enc.c| 2 +- libavcodec/pngenc.c | 6 +++--- libavcodec/proresenc_anatoliy.c | 4 ++-- libavcodec/proresenc_kostya.c | 2 +- libavcodec/snowenc.c| 2 +- libavcodec/svq1enc.c| 2 +- libavcodec/tiffenc.c| 2 +- libavcodec/version_major.h | 1 + 21 files changed, 35 insertions(+), 21 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 77b9740891..27030ee03e 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09 API changes, most recent first: +2024-02-17 - xx - lavc 60.yy.100 - avcodec.h + Deprecate AV_INPUT_BUFFER_MIN_SIZE without replacement. + 2024-02-13 - xx - lavf 60.21.100 - avformat.h Add AVStreamGroup.disposition. diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c index 50da46738c..6179b50583 100644 --- a/libavcodec/asvenc.c +++ b/libavcodec/asvenc.c @@ -272,7 +272,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } if ((ret = ff_alloc_packet(avctx, pkt, c->mb_height * c->mb_width * MAX_MB_SIZE + - AV_INPUT_BUFFER_MIN_SIZE)) < 0) + FF_INPUT_BUFFER_MIN_SIZE)) < 0) return ret; init_put_bits(>pb, pkt->data, pkt->size); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 0018ccbb0c..43859251cc 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -187,12 +187,16 @@ struct AVCodecParameters; * @{ */ +#if FF_API_BUFFER_MIN_SIZE /** * @ingroup lavc_encoding * minimum encoding buffer size * Used to avoid some checks during header writing. + * @deprecated Unused: avcodec_receive_packet() does not work + * with preallocated packet buffers. */ #define AV_INPUT_BUFFER_MIN_SIZE 16384 +#endif /** * @ingroup lavc_encoding diff --git a/libavcodec/encode.h b/libavcodec/encode.h index e019cd7702..85331e04b7 100644 --- a/libavcodec/encode.h +++ b/libavcodec/encode.h @@ -26,6 +26,12 @@ #include "avcodec.h" #include "packet.h" +/** + * Used by some encoders as upper bound for the length of headers. + * TODO: Use proper codec-specific upper bounds. + */ +#define FF_INPUT_BUFFER_MIN_SIZE 16384 + /** * Called by encoders to get the next frame for encoding. * diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index 4f581fbf6b..e510abf6ff 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -1104,7 +1104,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, uint8_t keystate= 128; uint8_t *buf_p; int i, ret; -int64_t maxsize = AV_INPUT_BUFFER_MIN_SIZE +int64_t maxsize = FF_INPUT_BUFFER_MIN_SIZE + avctx->width*avctx->height*37LL*4; if(!pict) { @@ -1154,7 +1154,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } if (f->version > 3) -maxsize = AV_INPUT_BUFFER_MIN_SIZE + avctx->width*avctx->height*3LL*4; +maxsize = FF_INPUT_BUFFER_MIN_SIZE + avctx->width*avctx->height*3LL*4; if (maxsize > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - 32) { av_log(avctx, AV_LOG_WARNING, "Cannot allocate worst case packet size, the encoding could fail\n"); diff --git a/libavcodec/flashsv2enc.c b/libavcodec/flashsv2enc.c index 75b48eb1fd..6dcb9102a8 100644 --- a/libavcodec/flashsv2enc.c +++ b/libavcodec/flashsv2enc.c @@ -857,7 +857,7 @@ static int flashsv2_encode_frame(AVCodecContext *avctx, AVPacket *pkt, int res; int keyframe = 0; -if ((res = ff_alloc_packet(avctx, pkt, s->frame_size + AV_INPUT_BUFFER_MIN_SIZE)) < 0) +if ((res = ff_alloc_packet(avctx, pkt, s->frame_size + FF_INPUT_BUFFER_MIN_SIZE)) < 0) return res; /* First frame needs to be a keyframe */ diff --git a/libavcodec/gif.c b/libavcodec/gif.c index 7a32f8fc8b..49356236e7 100644 --- a/libavcodec/gif.c +++ b/libavcodec/gif.c @@ -477,7 +477,7 @@ static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const uint32_t *palette = NULL; int ret; -if ((ret =
Re: [FFmpeg-devel] [PATCH] tools: Add target_sws_fuzzer.c
On Sat, Feb 17, 2024 at 07:04:08PM -0500, Sean McGovern wrote: > On Sat, Feb 17, 2024, 18:49 Michael Niedermayer > wrote: > > > Signed-off-by: Michael Niedermayer > > --- > > Makefile | 3 + > > tools/Makefile| 3 + > > tools/target_sws_fuzzer.c | 168 ++ > > 3 files changed, 174 insertions(+) > > create mode 100644 tools/target_sws_fuzzer.c > > > > diff --git a/Makefile b/Makefile > > index dbc930270b3..b309dbc4db9 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -64,6 +64,9 @@ tools/target_dem_fuzzer$(EXESUF): > > tools/target_dem_fuzzer.o $(FF_DEP_LIBS) > > tools/target_io_dem_fuzzer$(EXESUF): tools/target_io_dem_fuzzer.o > > $(FF_DEP_LIBS) > > $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) > > $(LIBFUZZER_PATH) > > > > +tools/target_sws_fuzzer$(EXESUF): tools/target_sws_fuzzer.o $(FF_DEP_LIBS) > > + $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) > > $(LIBFUZZER_PATH) > > + > > > > tools/enum_options$(EXESUF): ELIBS = $(FF_EXTRALIBS) > > tools/enum_options$(EXESUF): $(FF_DEP_LIBS) > > diff --git a/tools/Makefile b/tools/Makefile > > index dee6a416688..72e8e709a8d 100644 > > --- a/tools/Makefile > > +++ b/tools/Makefile > > @@ -17,6 +17,9 @@ tools/target_dem_fuzzer.o: tools/target_dem_fuzzer.c > > tools/target_io_dem_fuzzer.o: tools/target_dem_fuzzer.c > > $(COMPILE_C) -DIO_FLAT=0 > > > > +tools/target_sws_fuzzer.o: tools/target_sws_fuzzer.c > > + $(COMPILE_C) > > + > > tools/enc_recon_frame_test$(EXESUF): tools/decode_simple.o > > tools/venc_data_dump$(EXESUF): tools/decode_simple.o > > tools/scale_slice_test$(EXESUF): tools/decode_simple.o > > diff --git a/tools/target_sws_fuzzer.c b/tools/target_sws_fuzzer.c > > new file mode 100644 > > index 000..babb6e81629 > > --- /dev/null > > +++ b/tools/target_sws_fuzzer.c > > @@ -0,0 +1,168 @@ > > +/* > > + * Copyright (c) 2024 Michael Niedermayer > > + * > > + * 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 "config.h" > > +#include "libavutil/avassert.h" > > +#include "libavutil/avstring.h" > > +#include "libavutil/cpu.h" > > +#include "libavutil/imgutils.h" > > +#include "libavutil/intreadwrite.h" > > +#include "libavutil/opt.h" > > + > > +#include "libavcodec/bytestream.h" > > + > > +#include "libswscale/swscale.h" > > + > > + > > +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); > > + > > +static void error(const char *err) > > +{ > > +fprintf(stderr, "%s", err); > > +exit(1); > > +} > > + > > +static int alloc_plane(uint8_t *data[AV_VIDEO_MAX_PLANES], int > > stride[AV_VIDEO_MAX_PLANES], int w, int h, int format, int *hshift, int > > *vshift) > > +{ > > +int ret = av_image_fill_linesizes(stride, format, w); > > +if (ret < 0) > > +return -1; > > + > > +av_pix_fmt_get_chroma_sub_sample(format, hshift, vshift); > > + > > +for(int p=0; p > +if (stride[p]) { > > +stride[p] = FFALIGN(stride[p], 32); > > +int ph = AV_CEIL_RSHIFT(h, (p == 1 || p == 2) ? *vshift : 0); > > +av_log(0,0, "P:%d St %d ph %d\n", p, stride[p], ph); > > +data[p] = av_mallocz(stride[p] * ph + 32); > > +if (!data[p]) > > +return -1; > > +} > > +} > > +if (format == AV_PIX_FMT_PAL8) { > > +data[1] = av_mallocz(256*4); > > +if (!data[1]) > > +return -1; > > +} > > +return 0; > > +} > > + > > +static void free_plane(uint8_t *data[AV_VIDEO_MAX_PLANES]) > > +{ > > +for(int p=0; p > +av_freep([p]); > > +} > > + > > +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { > > +int srcW= 48, srcH = 48; > > +int dstW= 48, dstH = 48; > > +int srcHShift, srcVShift; > > +int dstHShift, dstVShift; > > +unsigned flags = 1; > > +int srcStride[AV_VIDEO_MAX_PLANES] = {0}; > > +int dstStride[AV_VIDEO_MAX_PLANES] = {0}; > > +int ret; > > +const uint8_t *end = data + size; > > +enum AVPixelFormat srcFormat = AV_PIX_FMT_YUV420P; > > +enum AVPixelFormat dstFormat = AV_PIX_FMT_YUV420P; > > +uint8_t *src[4] = { 0 }; >
[FFmpeg-devel] [PATCH] avutil/common: Move includes to the beginning of the file
Signed-off-by: Andreas Rheinhardt --- libavutil/common.h | 20 +++- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/libavutil/common.h b/libavutil/common.h index de2140a678..57c87f1919 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -42,6 +42,13 @@ #include "attributes.h" #include "error.h" #include "macros.h" +#include "mem.h" + +#ifdef HAVE_AV_CONFIG_H +# include "config.h" +# include "intmath.h" +# include "internal.h" +#endif /* HAVE_AV_CONFIG_H */ //rounded division & shift #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) @@ -84,11 +91,6 @@ /* misc math functions */ -#ifdef HAVE_AV_CONFIG_H -# include "config.h" -# include "intmath.h" -#endif - #ifndef av_ceil_log2 # define av_ceil_log2 av_ceil_log2_c #endif @@ -568,12 +570,4 @@ static av_always_inline av_const int av_parity_c(uint32_t v) }\ }\ - - -#include "mem.h" - -#ifdef HAVE_AV_CONFIG_H -#include "internal.h" -#endif /* HAVE_AV_CONFIG_H */ - #endif /* AVUTIL_COMMON_H */ -- 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] tools: Add target_sws_fuzzer.c
On Sat, Feb 17, 2024 at 09:13:21PM -0300, James Almer wrote: > > > On 2/17/2024 8:48 PM, Michael Niedermayer wrote: > > Signed-off-by: Michael Niedermayer > > --- > > Makefile | 3 + > > tools/Makefile| 3 + > > tools/target_sws_fuzzer.c | 168 ++ > > 3 files changed, 174 insertions(+) > > create mode 100644 tools/target_sws_fuzzer.c > > > > diff --git a/Makefile b/Makefile > > index dbc930270b3..b309dbc4db9 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -64,6 +64,9 @@ tools/target_dem_fuzzer$(EXESUF): > > tools/target_dem_fuzzer.o $(FF_DEP_LIBS) > > tools/target_io_dem_fuzzer$(EXESUF): tools/target_io_dem_fuzzer.o > > $(FF_DEP_LIBS) > > $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) > > $(LIBFUZZER_PATH) > > +tools/target_sws_fuzzer$(EXESUF): tools/target_sws_fuzzer.o $(FF_DEP_LIBS) > > + $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) > > $(LIBFUZZER_PATH) > > + > > tools/enum_options$(EXESUF): ELIBS = $(FF_EXTRALIBS) > > tools/enum_options$(EXESUF): $(FF_DEP_LIBS) > > diff --git a/tools/Makefile b/tools/Makefile > > index dee6a416688..72e8e709a8d 100644 > > --- a/tools/Makefile > > +++ b/tools/Makefile > > @@ -17,6 +17,9 @@ tools/target_dem_fuzzer.o: tools/target_dem_fuzzer.c > > tools/target_io_dem_fuzzer.o: tools/target_dem_fuzzer.c > > $(COMPILE_C) -DIO_FLAT=0 > > +tools/target_sws_fuzzer.o: tools/target_sws_fuzzer.c > > + $(COMPILE_C) > > + > > tools/enc_recon_frame_test$(EXESUF): tools/decode_simple.o > > tools/venc_data_dump$(EXESUF): tools/decode_simple.o > > tools/scale_slice_test$(EXESUF): tools/decode_simple.o > > diff --git a/tools/target_sws_fuzzer.c b/tools/target_sws_fuzzer.c > > new file mode 100644 > > index 000..babb6e81629 > > --- /dev/null > > +++ b/tools/target_sws_fuzzer.c > > @@ -0,0 +1,168 @@ > > +/* > > + * Copyright (c) 2024 Michael Niedermayer > > + * > > + * 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 "config.h" > > +#include "libavutil/avassert.h" > > +#include "libavutil/avstring.h" > > +#include "libavutil/cpu.h" > > +#include "libavutil/imgutils.h" > > +#include "libavutil/intreadwrite.h" > > +#include "libavutil/opt.h" > > + > > +#include "libavcodec/bytestream.h" > > + > > +#include "libswscale/swscale.h" > > + > > + > > +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); > > + > > +static void error(const char *err) > > +{ > > +fprintf(stderr, "%s", err); > > +exit(1); > > +} > > + > > +static int alloc_plane(uint8_t *data[AV_VIDEO_MAX_PLANES], int > > stride[AV_VIDEO_MAX_PLANES], int w, int h, int format, int *hshift, int > > *vshift) > > +{ > > +int ret = av_image_fill_linesizes(stride, format, w); > > +if (ret < 0) > > +return -1; > > + > > +av_pix_fmt_get_chroma_sub_sample(format, hshift, vshift); > > + > > +for(int p=0; p > +if (stride[p]) { > > +stride[p] = FFALIGN(stride[p], 32); > > +int ph = AV_CEIL_RSHIFT(h, (p == 1 || p == 2) ? *vshift : 0); > > +av_log(0,0, "P:%d St %d ph %d\n", p, stride[p], ph); > > +data[p] = av_mallocz(stride[p] * ph + 32); > > +if (!data[p]) > > +return -1; > > +} > > +} > > +if (format == AV_PIX_FMT_PAL8) { > > +data[1] = av_mallocz(256*4); > > +if (!data[1]) > > +return -1; > > +} > > +return 0; > > av_image_alloc()? Would be better to actually test sws with buffers created > by our own public helpers. av_image_alloc() allocates the planes in one continous piece so teh fuzzer would not be able to detect accesses over the end of the first or accesses prior the 2nd. So this is not possible > > > +} > > + > > +static void free_plane(uint8_t *data[AV_VIDEO_MAX_PLANES]) > > +{ > > +for(int p=0; p > +av_freep([p]); > > +} > > + > > +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { > > +int srcW= 48, srcH = 48; > > +int dstW= 48, dstH = 48; > > +int srcHShift, srcVShift; > > +int dstHShift, dstVShift; > > +unsigned flags = 1; > > +int
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/s302m: enable non-PCM decoding
On Sat, Feb 17, 2024 at 08:55:43PM +0100, Anton Khirnov wrote: > Quoting Gyan Doshi (2024-02-17 13:37:38) > > On 2024-02-17 05:52 pm, Anton Khirnov wrote: > > > Quoting Gyan Doshi (2024-02-17 12:46:27) > > >> As a TC member who is part of the disagreement, I believe your > > >> participation is recused. > > > No, I do not think "TC members who commented on a patch lose their right > > > to vote" is a reasonable interpretation of that rule. > > > > I refer to > > > > "If the disagreement involves a member of the TC, that member should > > recuse themselves from the decision" > > > > at > > > > https://ffmpeg.org/community.html#Announcement > > > > You clearly are one of the parties to the disagreement, and "recuse > > themselves from the decision" is self-explanatory. > > Such a maximalist interpretation makes no sense - why should my opinion > become invalid because I commented on a patch, "If the disagreement involves a member of the TC" does IMHO not preclude commenting on a patch. For a disagreement we need 2 parties. For example one party who wants a patch in and one who blocks the patch. or 2 parties where both block the other. Being a party of a disagreement would not make anyones opinon invalid. But I think it is reasonable that parties of a disagreement cannot be the judge of the disagreement. > but not if I kept it to > myself and let someone else object to your patch? I think the deatils of this would matter. If a TC member simply does nothing and has no involvement and someone else objects, sure thet TC member could vote. OTOH if a TC member asks someone else to object to hide a conflict of interrest and then votes. IMO Thats a severe breach of trust and that person should not be in any committee thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Breaking DRM is a little like attempting to break through a door even though the window is wide open and the only thing in the house is a bunch of things you dont want and which you would get tomorrow for free anyway 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] tools: Add target_sws_fuzzer.c
On 2/17/2024 8:48 PM, Michael Niedermayer wrote: Signed-off-by: Michael Niedermayer --- Makefile | 3 + tools/Makefile| 3 + tools/target_sws_fuzzer.c | 168 ++ 3 files changed, 174 insertions(+) create mode 100644 tools/target_sws_fuzzer.c diff --git a/Makefile b/Makefile index dbc930270b3..b309dbc4db9 100644 --- a/Makefile +++ b/Makefile @@ -64,6 +64,9 @@ tools/target_dem_fuzzer$(EXESUF): tools/target_dem_fuzzer.o $(FF_DEP_LIBS) tools/target_io_dem_fuzzer$(EXESUF): tools/target_io_dem_fuzzer.o $(FF_DEP_LIBS) $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH) +tools/target_sws_fuzzer$(EXESUF): tools/target_sws_fuzzer.o $(FF_DEP_LIBS) + $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH) + tools/enum_options$(EXESUF): ELIBS = $(FF_EXTRALIBS) tools/enum_options$(EXESUF): $(FF_DEP_LIBS) diff --git a/tools/Makefile b/tools/Makefile index dee6a416688..72e8e709a8d 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -17,6 +17,9 @@ tools/target_dem_fuzzer.o: tools/target_dem_fuzzer.c tools/target_io_dem_fuzzer.o: tools/target_dem_fuzzer.c $(COMPILE_C) -DIO_FLAT=0 +tools/target_sws_fuzzer.o: tools/target_sws_fuzzer.c + $(COMPILE_C) + tools/enc_recon_frame_test$(EXESUF): tools/decode_simple.o tools/venc_data_dump$(EXESUF): tools/decode_simple.o tools/scale_slice_test$(EXESUF): tools/decode_simple.o diff --git a/tools/target_sws_fuzzer.c b/tools/target_sws_fuzzer.c new file mode 100644 index 000..babb6e81629 --- /dev/null +++ b/tools/target_sws_fuzzer.c @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2024 Michael Niedermayer + * + * 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 "config.h" +#include "libavutil/avassert.h" +#include "libavutil/avstring.h" +#include "libavutil/cpu.h" +#include "libavutil/imgutils.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/opt.h" + +#include "libavcodec/bytestream.h" + +#include "libswscale/swscale.h" + + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); + +static void error(const char *err) +{ +fprintf(stderr, "%s", err); +exit(1); +} + +static int alloc_plane(uint8_t *data[AV_VIDEO_MAX_PLANES], int stride[AV_VIDEO_MAX_PLANES], int w, int h, int format, int *hshift, int *vshift) +{ +int ret = av_image_fill_linesizes(stride, format, w); +if (ret < 0) +return -1; + +av_pix_fmt_get_chroma_sub_sample(format, hshift, vshift); + +for(int p=0; p av_image_alloc()? Would be better to actually test sws with buffers created by our own public helpers. +} + +static void free_plane(uint8_t *data[AV_VIDEO_MAX_PLANES]) +{ +for(int p=0; p AV_VIDEO_MAX_PLANES. +struct SwsContext *sws = NULL; +const AVPixFmtDescriptor *desc_src, *desc_dst; + +if (size > 128) { +GetByteContext gbc; +int64_t flags64; + +size -= 128; +bytestream2_init(, data + size, 128); +srcW = bytestream2_get_le32() % 256; +srcH = bytestream2_get_le32() % 256; +dstW = bytestream2_get_le32() % 256; +dstH = bytestream2_get_le32() % 256; +flags = bytestream2_get_le32(); + +srcFormat = bytestream2_get_le32() % AV_PIX_FMT_NB; +dstFormat = bytestream2_get_le32() % AV_PIX_FMT_NB; nit: Maybe sanitize the choices with sws_isSupportedInput() and sws_isSupportedOutput()? Unless having sws_init_context() fail with invalid arguments is also intended. + +flags64 = bytestream2_get_le64(); +if (flags64 & 0x10) +av_force_cpu_flags(0); + +if (av_image_check_size(srcW, srcH, srcFormat, NULL)) +srcW = srcH = 123; +if (av_image_check_size(dstW, dstH, dstFormat, NULL)) +dstW = dstH = 123; Is there a format where this could fail, knowing the dimensions are at most 255x255? +//TODO alphablend +} + +desc_src = av_pix_fmt_desc_get(srcFormat); +desc_dst = av_pix_fmt_desc_get(dstFormat); + +ret = alloc_plane(src, srcStride, srcW, srcH, srcFormat, , ); +if (ret < 0) +goto end; + +ret = alloc_plane(dst, dstStride, dstW, dstH, dstFormat, , ); +
Re: [FFmpeg-devel] [PATCH] tools: Add target_sws_fuzzer.c
On Sat, Feb 17, 2024, 18:49 Michael Niedermayer wrote: > Signed-off-by: Michael Niedermayer > --- > Makefile | 3 + > tools/Makefile| 3 + > tools/target_sws_fuzzer.c | 168 ++ > 3 files changed, 174 insertions(+) > create mode 100644 tools/target_sws_fuzzer.c > > diff --git a/Makefile b/Makefile > index dbc930270b3..b309dbc4db9 100644 > --- a/Makefile > +++ b/Makefile > @@ -64,6 +64,9 @@ tools/target_dem_fuzzer$(EXESUF): > tools/target_dem_fuzzer.o $(FF_DEP_LIBS) > tools/target_io_dem_fuzzer$(EXESUF): tools/target_io_dem_fuzzer.o > $(FF_DEP_LIBS) > $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) > $(LIBFUZZER_PATH) > > +tools/target_sws_fuzzer$(EXESUF): tools/target_sws_fuzzer.o $(FF_DEP_LIBS) > + $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) > $(LIBFUZZER_PATH) > + > > tools/enum_options$(EXESUF): ELIBS = $(FF_EXTRALIBS) > tools/enum_options$(EXESUF): $(FF_DEP_LIBS) > diff --git a/tools/Makefile b/tools/Makefile > index dee6a416688..72e8e709a8d 100644 > --- a/tools/Makefile > +++ b/tools/Makefile > @@ -17,6 +17,9 @@ tools/target_dem_fuzzer.o: tools/target_dem_fuzzer.c > tools/target_io_dem_fuzzer.o: tools/target_dem_fuzzer.c > $(COMPILE_C) -DIO_FLAT=0 > > +tools/target_sws_fuzzer.o: tools/target_sws_fuzzer.c > + $(COMPILE_C) > + > tools/enc_recon_frame_test$(EXESUF): tools/decode_simple.o > tools/venc_data_dump$(EXESUF): tools/decode_simple.o > tools/scale_slice_test$(EXESUF): tools/decode_simple.o > diff --git a/tools/target_sws_fuzzer.c b/tools/target_sws_fuzzer.c > new file mode 100644 > index 000..babb6e81629 > --- /dev/null > +++ b/tools/target_sws_fuzzer.c > @@ -0,0 +1,168 @@ > +/* > + * Copyright (c) 2024 Michael Niedermayer > + * > + * 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 "config.h" > +#include "libavutil/avassert.h" > +#include "libavutil/avstring.h" > +#include "libavutil/cpu.h" > +#include "libavutil/imgutils.h" > +#include "libavutil/intreadwrite.h" > +#include "libavutil/opt.h" > + > +#include "libavcodec/bytestream.h" > + > +#include "libswscale/swscale.h" > + > + > +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); > + > +static void error(const char *err) > +{ > +fprintf(stderr, "%s", err); > +exit(1); > +} > + > +static int alloc_plane(uint8_t *data[AV_VIDEO_MAX_PLANES], int > stride[AV_VIDEO_MAX_PLANES], int w, int h, int format, int *hshift, int > *vshift) > +{ > +int ret = av_image_fill_linesizes(stride, format, w); > +if (ret < 0) > +return -1; > + > +av_pix_fmt_get_chroma_sub_sample(format, hshift, vshift); > + > +for(int p=0; p +if (stride[p]) { > +stride[p] = FFALIGN(stride[p], 32); > +int ph = AV_CEIL_RSHIFT(h, (p == 1 || p == 2) ? *vshift : 0); > +av_log(0,0, "P:%d St %d ph %d\n", p, stride[p], ph); > +data[p] = av_mallocz(stride[p] * ph + 32); > +if (!data[p]) > +return -1; > +} > +} > +if (format == AV_PIX_FMT_PAL8) { > +data[1] = av_mallocz(256*4); > +if (!data[1]) > +return -1; > +} > +return 0; > +} > + > +static void free_plane(uint8_t *data[AV_VIDEO_MAX_PLANES]) > +{ > +for(int p=0; p +av_freep([p]); > +} > + > +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { > +int srcW= 48, srcH = 48; > +int dstW= 48, dstH = 48; > +int srcHShift, srcVShift; > +int dstHShift, dstVShift; > +unsigned flags = 1; > +int srcStride[AV_VIDEO_MAX_PLANES] = {0}; > +int dstStride[AV_VIDEO_MAX_PLANES] = {0}; > +int ret; > +const uint8_t *end = data + size; > +enum AVPixelFormat srcFormat = AV_PIX_FMT_YUV420P; > +enum AVPixelFormat dstFormat = AV_PIX_FMT_YUV420P; > +uint8_t *src[4] = { 0 }; > +uint8_t *dst[4] = { 0 }; > +struct SwsContext *sws = NULL; > +const AVPixFmtDescriptor *desc_src, *desc_dst; > + > +if (size > 128) { > +GetByteContext gbc; > +int64_t flags64; > + > +size -= 128; > +bytestream2_init(, data + size, 128); > +srcW = bytestream2_get_le32() % 256; > +
[FFmpeg-devel] [PATCH] tools: Add target_sws_fuzzer.c
Signed-off-by: Michael Niedermayer --- Makefile | 3 + tools/Makefile| 3 + tools/target_sws_fuzzer.c | 168 ++ 3 files changed, 174 insertions(+) create mode 100644 tools/target_sws_fuzzer.c diff --git a/Makefile b/Makefile index dbc930270b3..b309dbc4db9 100644 --- a/Makefile +++ b/Makefile @@ -64,6 +64,9 @@ tools/target_dem_fuzzer$(EXESUF): tools/target_dem_fuzzer.o $(FF_DEP_LIBS) tools/target_io_dem_fuzzer$(EXESUF): tools/target_io_dem_fuzzer.o $(FF_DEP_LIBS) $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH) +tools/target_sws_fuzzer$(EXESUF): tools/target_sws_fuzzer.o $(FF_DEP_LIBS) + $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH) + tools/enum_options$(EXESUF): ELIBS = $(FF_EXTRALIBS) tools/enum_options$(EXESUF): $(FF_DEP_LIBS) diff --git a/tools/Makefile b/tools/Makefile index dee6a416688..72e8e709a8d 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -17,6 +17,9 @@ tools/target_dem_fuzzer.o: tools/target_dem_fuzzer.c tools/target_io_dem_fuzzer.o: tools/target_dem_fuzzer.c $(COMPILE_C) -DIO_FLAT=0 +tools/target_sws_fuzzer.o: tools/target_sws_fuzzer.c + $(COMPILE_C) + tools/enc_recon_frame_test$(EXESUF): tools/decode_simple.o tools/venc_data_dump$(EXESUF): tools/decode_simple.o tools/scale_slice_test$(EXESUF): tools/decode_simple.o diff --git a/tools/target_sws_fuzzer.c b/tools/target_sws_fuzzer.c new file mode 100644 index 000..babb6e81629 --- /dev/null +++ b/tools/target_sws_fuzzer.c @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2024 Michael Niedermayer + * + * 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 "config.h" +#include "libavutil/avassert.h" +#include "libavutil/avstring.h" +#include "libavutil/cpu.h" +#include "libavutil/imgutils.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/opt.h" + +#include "libavcodec/bytestream.h" + +#include "libswscale/swscale.h" + + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); + +static void error(const char *err) +{ +fprintf(stderr, "%s", err); +exit(1); +} + +static int alloc_plane(uint8_t *data[AV_VIDEO_MAX_PLANES], int stride[AV_VIDEO_MAX_PLANES], int w, int h, int format, int *hshift, int *vshift) +{ +int ret = av_image_fill_linesizes(stride, format, w); +if (ret < 0) +return -1; + +av_pix_fmt_get_chroma_sub_sample(format, hshift, vshift); + +for(int p=0; p 128) { +GetByteContext gbc; +int64_t flags64; + +size -= 128; +bytestream2_init(, data + size, 128); +srcW = bytestream2_get_le32() % 256; +srcH = bytestream2_get_le32() % 256; +dstW = bytestream2_get_le32() % 256; +dstH = bytestream2_get_le32() % 256; +flags = bytestream2_get_le32(); + +srcFormat = bytestream2_get_le32() % AV_PIX_FMT_NB; +dstFormat = bytestream2_get_le32() % AV_PIX_FMT_NB; + +flags64 = bytestream2_get_le64(); +if (flags64 & 0x10) +av_force_cpu_flags(0); + +if (av_image_check_size(srcW, srcH, srcFormat, NULL)) +srcW = srcH = 123; +if (av_image_check_size(dstW, dstH, dstFormat, NULL)) +dstW = dstH = 123; +//TODO alphablend +} + +desc_src = av_pix_fmt_desc_get(srcFormat); +desc_dst = av_pix_fmt_desc_get(dstFormat); + +ret = alloc_plane(src, srcStride, srcW, srcH, srcFormat, , ); +if (ret < 0) +goto end; + +ret = alloc_plane(dst, dstStride, dstW, dstH, dstFormat, , ); +if (ret < 0) +goto end; + + +for(int p=0; p size) +psize = size; +if (psize) { +memcpy(src[p], data, psize); +data += psize; +size -= psize; +} +} + +sws = sws_alloc_context(); +if (!sws) +error("Failed sws allocation"); + +av_opt_set_int(sws, "sws_flags", flags, 0); +av_opt_set_int(sws, "srcw", srcW, 0); +av_opt_set_int(sws, "srch", srcH, 0); +av_opt_set_int(sws, "dstw", dstW, 0); +av_opt_set_int(sws, "dsth", dstH, 0); +av_opt_set_int(sws, "src_format", srcFormat, 0); +av_opt_set_int(sws, "dst_format",
Re: [FFmpeg-devel] [PATCH 2/5] avutil/channel_layout: add AV_CHANNEL_ORDER_NB
On Fri, 16 Feb 2024, James Almer wrote: On 2/16/2024 7:42 PM, Marton Balint wrote: On Thu, 15 Feb 2024, Anton Khirnov wrote: Quoting Marton Balint (2024-02-13 21:27:34) On Tue, 13 Feb 2024, James Almer wrote: On 2/12/2024 6:15 PM, Marton Balint wrote: Signed-off-by: Marton Balint --- libavutil/channel_layout.h | 4 1 file changed, 4 insertions(+) diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h index b8bff6f365..db0c005e87 100644 --- a/libavutil/channel_layout.h +++ b/libavutil/channel_layout.h @@ -146,6 +146,10 @@ enum AVChannelOrder { * as defined in AmbiX format $ 2.1. */ AV_CHANNEL_ORDER_AMBISONIC, + /** + * Number of channel orders, not part of ABI/API + */ + AV_CHANNEL_ORDER_NB }; Is it worth adding this to a public header just to limit a loop in a test? A loop that fwiw still depends on an array that needs to be updated with more names if you add new orders. Several other enums also have this. So API consistency can be considered a more important factor. I'd be concerned that many callers don't undertand the implications of "not part of the ABI". Maybe we should rename all of them to FF_ prefix to make it more clear callers should not use these? I think this is a good idea. So is it OK to apply this if I change the prefix to FF? I wont oppose to it. Ok, changed locally. Will apply the series soon. Regards, Marton ___ 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 8/8] fate: add IAMF in mp4 tests
Signed-off-by: James Almer --- tests/fate/mov.mak | 35 tests/ref/fate/mov-mp4-iamf-5_1_4 | 98 tests/ref/fate/mov-mp4-iamf-7_1_4 | 114 tests/ref/fate/mov-mp4-iamf-ambisonic_1 | 66 ++ tests/ref/fate/mov-mp4-iamf-stereo | 18 5 files changed, 331 insertions(+) create mode 100644 tests/ref/fate/mov-mp4-iamf-5_1_4 create mode 100644 tests/ref/fate/mov-mp4-iamf-7_1_4 create mode 100644 tests/ref/fate/mov-mp4-iamf-ambisonic_1 create mode 100644 tests/ref/fate/mov-mp4-iamf-stereo diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index 4850c8aa94..17fd99d8d2 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -194,6 +194,41 @@ fate-mov-pcm-remux: CMD = md5 -i $(TARGET_PATH)/tests/data/asynth-44100-1.wav -m fate-mov-pcm-remux: CMP = oneline fate-mov-pcm-remux: REF = e76115bc392d702da38f523216bba165 +FATE_MOV_FFMPEG-$(call TRANSCODE, FLAC, MOV, WAV_DEMUXER PCM_S16LE_DECODER) += fate-mov-mp4-iamf-stereo +fate-mov-mp4-iamf-stereo: tests/data/asynth-44100-2.wav tests/data/streamgroups/audio_element-stereo tests/data/streamgroups/mix_presentation-stereo +fate-mov-mp4-iamf-stereo: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav +fate-mov-mp4-iamf-stereo: CMD = transcode wav $(SRC) mp4 " \ + -/stream_group $(TARGET_PATH)/tests/data/streamgroups/audio_element-stereo \ + -/stream_group $(TARGET_PATH)/tests/data/streamgroups/mix_presentation-stereo \ + -streamid 0:0 -c:a flac -t 1" "-c:a copy -map 0" + +FATE_MOV_FFMPEG-$(call TRANSCODE, FLAC, MOV, WAV_DEMUXER PCM_S16LE_DECODER) += fate-mov-mp4-iamf-5_1_4 +fate-mov-mp4-iamf-5_1_4: tests/data/asynth-44100-10.wav tests/data/filtergraphs/iamf_5_1_4 tests/data/streamgroups/audio_element-5_1_4 tests/data/streamgroups/mix_presentation-5_1_4 +fate-mov-mp4-iamf-5_1_4: SRC = $(TARGET_PATH)/tests/data/asynth-44100-10.wav +fate-mov-mp4-iamf-5_1_4: CMD = transcode wav $(SRC) mp4 "-auto_conversion_filters \ + -/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/iamf_5_1_4 \ + -/stream_group $(TARGET_PATH)/tests/data/streamgroups/audio_element-5_1_4 \ + -/stream_group $(TARGET_PATH)/tests/data/streamgroups/mix_presentation-5_1_4 \ + -streamid 0:0 -streamid 1:1 -streamid 2:2 -streamid 3:3 -streamid 4:4 -streamid 5:5 -map [FRONT] -map [BACK] -map [CENTER] -map [LFE] -map [TOP_FRONT] -map [TOP_BACK] -c:a flac -t 1" "-c:a copy -map 0" + +FATE_MOV_FFMPEG-$(call TRANSCODE, FLAC, MOV, WAV_DEMUXER PCM_S16LE_DECODER) += fate-mov-mp4-iamf-7_1_4 +fate-mov-mp4-iamf-7_1_4: tests/data/asynth-44100-12.wav tests/data/filtergraphs/iamf_7_1_4 tests/data/streamgroups/audio_element-7_1_4 tests/data/streamgroups/mix_presentation-7_1_4 +fate-mov-mp4-iamf-7_1_4: SRC = $(TARGET_PATH)/tests/data/asynth-44100-12.wav +fate-mov-mp4-iamf-7_1_4: CMD = transcode wav $(SRC) mp4 "-auto_conversion_filters \ + -/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/iamf_7_1_4 \ + -/stream_group $(TARGET_PATH)/tests/data/streamgroups/audio_element-7_1_4 \ + -/stream_group $(TARGET_PATH)/tests/data/streamgroups/mix_presentation-7_1_4 \ + -streamid 0:0 -streamid 1:1 -streamid 2:2 -streamid 3:3 -streamid 4:4 -streamid 5:5 -streamid 6:6 -map [FRONT] -map [BACK] -map [CENTER] -map [LFE] -map [SIDE] -map [TOP_FRONT] -map [TOP_BACK] -c:a flac -t 1" "-c:a copy -map 0" + +FATE_MOV_FFMPEG-$(call TRANSCODE, FLAC, MOV, WAV_DEMUXER PCM_S16LE_DECODER) += fate-mov-mp4-iamf-ambisonic_1 +fate-mov-mp4-iamf-ambisonic_1: tests/data/asynth-44100-4.wav tests/data/filtergraphs/iamf_ambisonic_1 tests/data/streamgroups/audio_element-ambisonic_1 tests/data/streamgroups/mix_presentation-ambisonic_1 +fate-mov-mp4-iamf-ambisonic_1: SRC = $(TARGET_PATH)/tests/data/asynth-44100-4.wav +fate-mov-mp4-iamf-ambisonic_1: CMD = transcode wav $(SRC) mp4 "-auto_conversion_filters \ + -/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/iamf_ambisonic_1 \ + -/stream_group $(TARGET_PATH)/tests/data/streamgroups/audio_element-ambisonic_1 \ + -/stream_group $(TARGET_PATH)/tests/data/streamgroups/mix_presentation-ambisonic_1 \ + -streamid 0:0 -streamid 1:1 -streamid 2:2 -streamid 3:3 -map [MONO0] -map [MONO1] -map [MONO2] -map [MONO3] -c:a flac -t 1" "-c:a copy -map 0" + FATE_FFMPEG += $(FATE_MOV_FFMPEG-yes) fate-mov: $(FATE_MOV) $(FATE_MOV_FFMPEG-yes) $(FATE_MOV_FFPROBE) $(FATE_MOV_FASTSTART) $(FATE_MOV_FFMPEG_FFPROBE-yes) diff --git a/tests/ref/fate/mov-mp4-iamf-5_1_4 b/tests/ref/fate/mov-mp4-iamf-5_1_4 new file mode 100644 index 00..2f29a83cf4 --- /dev/null +++ b/tests/ref/fate/mov-mp4-iamf-5_1_4 @@ -0,0 +1,98 @@ +65421714a3fd372d2babc9c6400ff00b *tests/data/fate/mov-mp4-iamf-5_1_4.mp4 +86340 tests/data/fate/mov-mp4-iamf-5_1_4.mp4 +#extradata 0: 34, 0x40a802c6 +#extradata 1: 34, 0x40a802c6 +#extradata 2: 34, 0x407c02c4 +#extradata 3: 34, 0x407c02c4 +#extradata 4: 34, 0x40a802c6 +#extradata 5: 34, 0x40a802c6 +#tb 0: 1/44100
[FFmpeg-devel] [PATCH 7/8] avformat/movenc: add support for Immersive Audio Model and Formats in ISOBMFF
Signed-off-by: James Almer --- libavformat/movenc.c | 349 +++ libavformat/movenc.h | 6 + 2 files changed, 293 insertions(+), 62 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index c71a9983ed..cd63b353b8 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -32,6 +32,7 @@ #include "dovi_isom.h" #include "riff.h" #include "avio.h" +#include "iamf_writer.h" #include "isom.h" #include "av1.h" #include "avc.h" @@ -41,12 +42,14 @@ #include "libavcodec/flac.h" #include "libavcodec/get_bits.h" +#include "libavcodec/bsf.h" #include "libavcodec/internal.h" #include "libavcodec/put_bits.h" #include "libavcodec/vc1_common.h" #include "libavcodec/raw.h" #include "internal.h" #include "libavutil/avstring.h" +#include "libavutil/bprint.h" #include "libavutil/channel_layout.h" #include "libavutil/csp.h" #include "libavutil/intfloat.h" @@ -316,6 +319,32 @@ static int mov_write_sdtp_tag(AVIOContext *pb, MOVTrack *track) return update_size(pb, pos); } +static int mov_write_iacb_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *track) +{ +AVIOContext *dyn_bc; +int64_t pos = avio_tell(pb); +uint8_t *dyn_buf = NULL; +int dyn_size; +int ret = avio_open_dyn_buf(_bc); +if (ret < 0) +return ret; + +avio_wb32(pb, 0); +ffio_wfourcc(pb, "iacb"); +avio_w8(pb, 1); // configurationVersion + +ret = ff_iamf_write_descriptors(track->iamf, dyn_bc, s); +if (ret < 0) +return ret; + +dyn_size = avio_close_dyn_buf(dyn_bc, _buf); +ffio_write_leb(pb, dyn_size); +avio_write(pb, dyn_buf, dyn_size); +av_free(dyn_buf); + +return update_size(pb, pos); +} + static int mov_write_amr_tag(AVIOContext *pb, MOVTrack *track) { avio_wb32(pb, 0x11); /* size */ @@ -1358,6 +1387,8 @@ static int mov_write_audio_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex ret = mov_write_wave_tag(s, pb, track); else if (track->tag == MKTAG('m','p','4','a')) ret = mov_write_esds_tag(pb, track); +else if (track->tag == MKTAG('i','a','m','f')) +ret = mov_write_iacb_tag(mov->fc, pb, track); else if (track->par->codec_id == AV_CODEC_ID_AMR_NB) ret = mov_write_amr_tag(pb, track); else if (track->par->codec_id == AV_CODEC_ID_AC3) @@ -2529,7 +2560,7 @@ static int mov_write_video_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContex if (track->mode == MODE_AVIF) { mov_write_ccst_tag(pb); -if (s->nb_streams > 0 && track == >tracks[1]) +if (mov->nb_streams > 0 && track == >tracks[1]) mov_write_aux_tag(pb, "auxi"); } @@ -3124,9 +3155,9 @@ static int mov_write_iloc_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatConte avio_wb32(pb, 0); /* Version & flags */ avio_w8(pb, (4 << 4) + 4); /* offset_size(4) and length_size(4) */ avio_w8(pb, 0); /* base_offset_size(4) and reserved(4) */ -avio_wb16(pb, s->nb_streams); /* item_count */ +avio_wb16(pb, mov->nb_streams); /* item_count */ -for (int i = 0; i < s->nb_streams; i++) { +for (int i = 0; i < mov->nb_streams; i++) { avio_wb16(pb, i + 1); /* item_id */ avio_wb16(pb, 0); /* data_reference_index */ avio_wb16(pb, 1); /* extent_count */ @@ -3145,9 +3176,9 @@ static int mov_write_iinf_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatConte avio_wb32(pb, 0); /* size */ ffio_wfourcc(pb, "iinf"); avio_wb32(pb, 0); /* Version & flags */ -avio_wb16(pb, s->nb_streams); /* entry_count */ +avio_wb16(pb, mov->nb_streams); /* entry_count */ -for (int i = 0; i < s->nb_streams; i++) { +for (int i = 0; i < mov->nb_streams; i++) { int64_t infe_pos = avio_tell(pb); avio_wb32(pb, 0); /* size */ ffio_wfourcc(pb, "infe"); @@ -3216,7 +3247,7 @@ static int mov_write_ipco_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatConte int64_t pos = avio_tell(pb); avio_wb32(pb, 0); /* size */ ffio_wfourcc(pb, "ipco"); -for (int i = 0; i < s->nb_streams; i++) { +for (int i = 0; i < mov->nb_streams; i++) { mov_write_ispe_tag(pb, mov, s, i); mov_write_pixi_tag(pb, mov, s, i); mov_write_av1c_tag(pb, >tracks[i]); @@ -3234,9 +3265,9 @@ static int mov_write_ipma_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatConte avio_wb32(pb, 0); /* size */ ffio_wfourcc(pb, "ipma"); avio_wb32(pb, 0); /* Version & flags */ -avio_wb32(pb, s->nb_streams); /* entry_count */ +avio_wb32(pb, mov->nb_streams); /* entry_count */ -for (int i = 0, index = 1; i < s->nb_streams; i++) { +for (int i = 0, index = 1; i < mov->nb_streams; i++) { avio_wb16(pb, i + 1); /* item_ID */ avio_w8(pb, 4); /* association_count */ @@ -4213,7 +4244,7 @@ static int mov_write_covr(AVIOContext *pb, AVFormatContext *s) int64_t pos = 0; int i; -for (i = 0; i < s->nb_streams; i++) { +
[FFmpeg-devel] [PATCH 6/8] avformat/iamfenc: further split into shareable modules
Signed-off-by: James Almer --- configure | 4 +- libavformat/Makefile | 3 +- libavformat/iamf_writer.c | 239 ++ libavformat/iamf_writer.h | 7 ++ libavformat/iamfenc.c | 228 ++-- 5 files changed, 258 insertions(+), 223 deletions(-) diff --git a/configure b/configure index 968f1ad198..adaeae2604 100755 --- a/configure +++ b/configure @@ -2517,6 +2517,7 @@ CONFIG_EXTRA=" huffyuvdsp huffyuvencdsp iamfdec +iamfenc idctdsp iirfilter inflate_wrapper @@ -3536,6 +3537,7 @@ hds_muxer_select="flv_muxer" hls_demuxer_select="adts_header ac3_parser mov_demuxer mpegts_demuxer" hls_muxer_select="mov_muxer mpegts_muxer" iamf_demuxer_select="iamfdec" +iamf_muxer_select="iamfenc" image2_alias_pix_demuxer_select="image2_demuxer" image2_brender_pix_demuxer_select="image2_demuxer" imf_demuxer_deps="libxml2" @@ -3552,7 +3554,7 @@ mlp_demuxer_select="mlp_parser" mmf_muxer_select="riffenc" mov_demuxer_select="iso_media riffdec iamfdec" mov_demuxer_suggest="zlib" -mov_muxer_select="iso_media riffenc rtpenc_chain vp9_superframe_bsf aac_adtstoasc_bsf ac3_parser" +mov_muxer_select="iamfenc iso_media riffenc rtpenc_chain vp9_superframe_bsf aac_adtstoasc_bsf ac3_parser" mp3_demuxer_select="mpegaudio_parser" mp3_muxer_select="mpegaudioheader" mp4_muxer_select="mov_muxer" diff --git a/libavformat/Makefile b/libavformat/Makefile index 3b83f5a685..4a380668bd 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -36,6 +36,7 @@ OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o # subsystems OBJS-$(CONFIG_ISO_MEDIA) += isom.o OBJS-$(CONFIG_IAMFDEC) += iamf_reader.o iamf_parse.o iamf.o +OBJS-$(CONFIG_IAMFENC) += iamf_writer.o iamf.o OBJS-$(CONFIG_NETWORK) += network.o OBJS-$(CONFIG_RIFFDEC) += riffdec.o OBJS-$(CONFIG_RIFFENC) += riffenc.o @@ -260,7 +261,7 @@ OBJS-$(CONFIG_HLS_DEMUXER) += hls.o hls_sample_encryption.o OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o OBJS-$(CONFIG_HNM_DEMUXER) += hnm.o OBJS-$(CONFIG_IAMF_DEMUXER) += iamfdec.o -OBJS-$(CONFIG_IAMF_MUXER)+= iamfenc.o iamf_writer.o iamf.o +OBJS-$(CONFIG_IAMF_MUXER)+= iamfenc.o OBJS-$(CONFIG_ICO_DEMUXER) += icodec.o OBJS-$(CONFIG_ICO_MUXER) += icoenc.o OBJS-$(CONFIG_IDCIN_DEMUXER) += idcin.o diff --git a/libavformat/iamf_writer.c b/libavformat/iamf_writer.c index 1a360dee2f..25e2fd9e8a 100644 --- a/libavformat/iamf_writer.c +++ b/libavformat/iamf_writer.c @@ -835,3 +835,242 @@ int ff_iamf_write_descriptors(const IAMFContext *iamf, AVIOContext *pb, void *lo return 0; } + +static int write_parameter_block(const IAMFContext *iamf, AVIOContext *pb, + const AVIAMFParamDefinition *param, void *log_ctx) +{ +uint8_t header[MAX_IAMF_OBU_HEADER_SIZE]; +IAMFParamDefinition *param_definition = ff_iamf_get_param_definition(iamf, param->parameter_id); +PutBitContext pbc; +AVIOContext *dyn_bc; +uint8_t *dyn_buf = NULL; +int dyn_size, ret; + +if (param->type > AV_IAMF_PARAMETER_DEFINITION_RECON_GAIN) { +av_log(log_ctx, AV_LOG_DEBUG, "Ignoring side data with unknown type %u\n", + param->type); +return 0; +} + +if (!param_definition) { +av_log(log_ctx, AV_LOG_ERROR, "Non-existent Parameter Definition with ID %u referenced by a packet\n", + param->parameter_id); +return AVERROR(EINVAL); +} + +if (param->type != param_definition->param->type) { +av_log(log_ctx, AV_LOG_ERROR, "Inconsistent values for Parameter Definition " +"with ID %u in a packet\n", + param->parameter_id); +return AVERROR(EINVAL); +} + +ret = avio_open_dyn_buf(_bc); +if (ret < 0) +return ret; + +// Sequence Header +init_put_bits(, header, sizeof(header)); +put_bits(, 5, IAMF_OBU_IA_PARAMETER_BLOCK); +put_bits(, 3, 0); +flush_put_bits(); +avio_write(pb, header, put_bytes_count(, 1)); + +ffio_write_leb(dyn_bc, param->parameter_id); +if (!param_definition->mode) { +ffio_write_leb(dyn_bc, param->duration); +ffio_write_leb(dyn_bc, param->constant_subblock_duration); +if (param->constant_subblock_duration == 0) +ffio_write_leb(dyn_bc, param->nb_subblocks); +} + +for (int i = 0; i < param->nb_subblocks; i++) { +const void *subblock = av_iamf_param_definition_get_subblock(param, i); + +switch (param->type) { +case AV_IAMF_PARAMETER_DEFINITION_MIX_GAIN: { +const AVIAMFMixGain *mix = subblock; +if (!param_definition->mode && param->constant_subblock_duration == 0) +
[FFmpeg-devel] [PATCH 5/8] avformat/mov: add support for Immersive Audio Model and Formats in ISOBMFF
Signed-off-by: James Almer --- configure | 2 +- libavformat/isom.h | 3 + libavformat/mov.c | 291 ++--- 3 files changed, 279 insertions(+), 17 deletions(-) diff --git a/configure b/configure index 472de63276..968f1ad198 100755 --- a/configure +++ b/configure @@ -3550,7 +3550,7 @@ matroska_demuxer_suggest="bzlib zlib" matroska_muxer_select="mpeg4audio riffenc aac_adtstoasc_bsf pgs_frame_merge_bsf vp9_superframe_bsf" mlp_demuxer_select="mlp_parser" mmf_muxer_select="riffenc" -mov_demuxer_select="iso_media riffdec" +mov_demuxer_select="iso_media riffdec iamfdec" mov_demuxer_suggest="zlib" mov_muxer_select="iso_media riffenc rtpenc_chain vp9_superframe_bsf aac_adtstoasc_bsf ac3_parser" mp3_demuxer_select="mpegaudio_parser" diff --git a/libavformat/isom.h b/libavformat/isom.h index eee94d0449..25025e4cee 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -168,6 +168,7 @@ typedef struct MOVStreamContext { AVIOContext *pb; int refcount; int pb_is_copied; +int id; ///< AVStream id int ffindex; ///< AVStream index int next_chunk; unsigned int chunk_count; @@ -264,6 +265,8 @@ typedef struct MOVStreamContext { AVEncryptionInfo *default_encrypted_sample; MOVEncryptionIndex *encryption_index; } cenc; + +struct IAMFDemuxContext *iamf; } MOVStreamContext; typedef struct HEIFItem { diff --git a/libavformat/mov.c b/libavformat/mov.c index 66b36eaa4a..1a1db2746c 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -58,6 +58,8 @@ #include "internal.h" #include "avio_internal.h" #include "demux.h" +#include "iamf_parse.h" +#include "iamf_reader.h" #include "dovi_isom.h" #include "riff.h" #include "isom.h" @@ -212,6 +214,7 @@ static int mov_read_covr(MOVContext *c, AVIOContext *pb, int type, int len) } st = c->fc->streams[c->fc->nb_streams - 1]; st->priv_data = sc; +sc->id = st->id; sc->refcount = 1; if (st->attached_pic.size >= 8 && id != AV_CODEC_ID_BMP) { @@ -836,6 +839,171 @@ static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static int mov_read_iacb(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ +AVStream *st; +MOVStreamContext *sc; +FFIOContext b; +AVIOContext *descriptor_pb; +AVDictionary *metadata; +IAMFContext *iamf; +int64_t start_time, duration; +unsigned descriptors_size; +int nb_frames, disposition; +int version, ret; + +if (atom.size < 5) +return AVERROR_INVALIDDATA; + +if (c->fc->nb_streams < 1) +return 0; + +version = avio_r8(pb); +if (version != 1) { +av_log(c->fc, AV_LOG_ERROR, "%s configurationVersion %d", + version < 1 ? "invalid" : "unsupported", version); +return AVERROR_INVALIDDATA; +} + +descriptors_size = ffio_read_leb(pb); +if (!descriptors_size || descriptors_size > INT_MAX) +return AVERROR_INVALIDDATA; + +st = c->fc->streams[c->fc->nb_streams - 1]; +sc = st->priv_data; + +sc->iamf = av_mallocz(sizeof(*sc->iamf)); +if (!sc->iamf) +return AVERROR(ENOMEM); +iamf = >iamf->iamf; + +st->codecpar->extradata = av_malloc(descriptors_size); +if (!st->codecpar->extradata) +return AVERROR(ENOMEM); +st->codecpar->extradata_size = descriptors_size; + +ret = avio_read(pb, st->codecpar->extradata, descriptors_size); +if (ret != descriptors_size) +return ret < 0 ? ret : AVERROR_INVALIDDATA; + +ffio_init_read_context(, st->codecpar->extradata, descriptors_size); +descriptor_pb = + +ret = ff_iamfdec_read_descriptors(iamf, descriptor_pb, descriptors_size, c->fc); +if (ret < 0) +return ret; + +metadata = st->metadata; +st->metadata = NULL; +start_time = st->start_time; +nb_frames = st->nb_frames; +duration = st->duration; +disposition = st->disposition; + +for (int i = 0; i < iamf->nb_audio_elements; i++) { +IAMFAudioElement *audio_element = iamf->audio_elements[i]; +AVStreamGroup *stg = +avformat_stream_group_create(c->fc, AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT, NULL); + +if (!stg) { +ret = AVERROR(ENOMEM); +goto fail; +} + +av_iamf_audio_element_free(>params.iamf_audio_element); +stg->id = audio_element->audio_element_id; +stg->params.iamf_audio_element = audio_element->element; + +for (int j = 0; j < audio_element->nb_substreams; j++) { +IAMFSubStream *substream = _element->substreams[j]; +AVStream *stream; + +if (!i && !j) +stream = st; +else +stream = avformat_new_stream(c->fc, NULL); +if (!stream) { +ret = AVERROR(ENOMEM); +goto fail; +} + +stream->start_time = start_time; +
[FFmpeg-devel] [PATCH 4/8] avformat/mov: make MOVStreamContext refcounted
This will be useful in the next commit. Signed-off-by: James Almer --- libavformat/isom.h | 1 + libavformat/mov.c | 7 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index a4cca4c798..eee94d0449 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -166,6 +166,7 @@ typedef struct MOVIndexRange { typedef struct MOVStreamContext { AVIOContext *pb; +int refcount; int pb_is_copied; int ffindex; ///< AVStream index int next_chunk; diff --git a/libavformat/mov.c b/libavformat/mov.c index e548f93f17..66b36eaa4a 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -212,6 +212,7 @@ static int mov_read_covr(MOVContext *c, AVIOContext *pb, int type, int len) } st = c->fc->streams[c->fc->nb_streams - 1]; st->priv_data = sc; +sc->refcount = 1; if (st->attached_pic.size >= 8 && id != AV_CODEC_ID_BMP) { if (AV_RB64(st->attached_pic.data) == 0x89504e470d0a1a0a) { @@ -4672,6 +4673,7 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) st->codecpar->codec_type = AVMEDIA_TYPE_DATA; sc->ffindex = st->index; c->trak_index = st->index; +sc->refcount = 1; if ((ret = mov_read_default(c, pb, atom)) < 0) return ret; @@ -4959,6 +4961,7 @@ static int heif_add_stream(MOVContext *c, HEIFItem *item) sc = st->priv_data; sc->pb = c->fc->pb; sc->pb_is_copied = 1; +sc->refcount = 1; // Populate the necessary fields used by mov_build_index. sc->stsc_count = 1; @@ -8660,8 +8663,10 @@ static void mov_free_stream_context(AVFormatContext *s, AVStream *st) { MOVStreamContext *sc = st->priv_data; -if (!sc) +if (!sc || --sc->refcount) { +st->priv_data = NULL; return; +} av_freep(>ctts_data); for (int i = 0; i < sc->drefs_count; i++) { -- 2.43.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/8] avformat/mov: factorize out setting the output packet properties
Signed-off-by: James Almer --- libavformat/mov.c | 113 ++ 1 file changed, 64 insertions(+), 49 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 92304565df..e548f93f17 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -9192,8 +9192,9 @@ static int mov_switch_root(AVFormatContext *s, int64_t target, int index) return 1; } -static int mov_change_extradata(MOVStreamContext *sc, AVPacket *pkt) +static int mov_change_extradata(AVStream *st, AVPacket *pkt) { +MOVStreamContext *sc = st->priv_data; uint8_t *side, *extradata; int extradata_size; @@ -9203,7 +9204,7 @@ static int mov_change_extradata(MOVStreamContext *sc, AVPacket *pkt) /* Notify the decoder that extradata changed. */ extradata_size = sc->extradata_size[sc->last_stsd_index]; extradata = sc->extradata[sc->last_stsd_index]; -if (extradata_size > 0 && extradata) { +if (st->discard != AVDISCARD_ALL && extradata_size > 0 && extradata) { side = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, extradata_size); @@ -9236,6 +9237,64 @@ static int get_eia608_packet(AVIOContext *pb, AVPacket *pkt, int size) return 0; } +static int mov_finalize_packet(AVFormatContext *s, AVStream *st, AVIndexEntry *sample, +int64_t current_index, AVPacket *pkt) +{ +MOVStreamContext *sc = st->priv_data; + +pkt->stream_index = sc->ffindex; +pkt->dts = sample->timestamp; +if (sample->flags & AVINDEX_DISCARD_FRAME) { +pkt->flags |= AV_PKT_FLAG_DISCARD; +} +if (sc->ctts_data && sc->ctts_index < sc->ctts_count) { +pkt->pts = av_sat_add64(pkt->dts, av_sat_add64(sc->dts_shift, sc->ctts_data[sc->ctts_index].duration)); +/* update ctts context */ +sc->ctts_sample++; +if (sc->ctts_index < sc->ctts_count && +sc->ctts_data[sc->ctts_index].count == sc->ctts_sample) { +sc->ctts_index++; +sc->ctts_sample = 0; +} +} else { +int64_t next_dts = (sc->current_sample < ffstream(st)->nb_index_entries) ? +ffstream(st)->index_entries[sc->current_sample].timestamp : st->duration; + +if (next_dts >= pkt->dts) +pkt->duration = next_dts - pkt->dts; +pkt->pts = pkt->dts; +} + +if (sc->sdtp_data && sc->current_sample <= sc->sdtp_count) { +uint8_t sample_flags = sc->sdtp_data[sc->current_sample - 1]; +uint8_t sample_is_depended_on = (sample_flags >> 2) & 0x3; +pkt->flags |= sample_is_depended_on == MOV_SAMPLE_DEPENDENCY_NO ? AV_PKT_FLAG_DISPOSABLE : 0; +} +pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0; +pkt->pos = sample->pos; + +/* Multiple stsd handling. */ +if (sc->stsc_data) { +if (sc->stsc_data[sc->stsc_index].id > 0 && +sc->stsc_data[sc->stsc_index].id - 1 < sc->stsd_count && +sc->stsc_data[sc->stsc_index].id - 1 != sc->last_stsd_index) { +int ret = mov_change_extradata(st, pkt); +if (ret < 0) +return ret; +} + +/* Update the stsc index for the next sample */ +sc->stsc_sample++; +if (mov_stsc_index_valid(sc->stsc_index, sc->stsc_count) && +mov_get_stsc_samples(sc, sc->stsc_index) == sc->stsc_sample) { +sc->stsc_index++; +sc->stsc_sample = 0; +} +} + +return 0; +} + static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) { MOVContext *mov = s->priv_data; @@ -9320,56 +9379,12 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) } } -pkt->stream_index = sc->ffindex; -pkt->dts = sample->timestamp; -if (sample->flags & AVINDEX_DISCARD_FRAME) { -pkt->flags |= AV_PKT_FLAG_DISCARD; -} -if (sc->ctts_data && sc->ctts_index < sc->ctts_count) { -pkt->pts = av_sat_add64(pkt->dts, av_sat_add64(sc->dts_shift, sc->ctts_data[sc->ctts_index].duration)); -/* update ctts context */ -sc->ctts_sample++; -if (sc->ctts_index < sc->ctts_count && -sc->ctts_data[sc->ctts_index].count == sc->ctts_sample) { -sc->ctts_index++; -sc->ctts_sample = 0; -} -} else { -int64_t next_dts = (sc->current_sample < ffstream(st)->nb_index_entries) ? -ffstream(st)->index_entries[sc->current_sample].timestamp : st->duration; +ret = mov_finalize_packet(s, st, sample, current_index, pkt); +if (ret < 0) +return ret; -if (next_dts >= pkt->dts) -pkt->duration = next_dts - pkt->dts; -pkt->pts = pkt->dts; -} if (st->discard == AVDISCARD_ALL) goto retry; -if (sc->sdtp_data && sc->current_sample <= sc->sdtp_count) { -uint8_t sample_flags =
[FFmpeg-devel] [PATCH 2/8] avformat/iamfdec: further split into shareable modules
Signed-off-by: James Almer --- configure | 2 + libavformat/Makefile | 3 +- libavformat/iamf_reader.c | 366 ++ libavformat/iamf_reader.h | 49 + libavformat/iamfdec.c | 347 ++-- 5 files changed, 432 insertions(+), 335 deletions(-) create mode 100644 libavformat/iamf_reader.c create mode 100644 libavformat/iamf_reader.h diff --git a/configure b/configure index f72533b7d2..472de63276 100755 --- a/configure +++ b/configure @@ -2516,6 +2516,7 @@ CONFIG_EXTRA=" huffman huffyuvdsp huffyuvencdsp +iamfdec idctdsp iirfilter inflate_wrapper @@ -3534,6 +3535,7 @@ gxf_muxer_select="pcm_rechunk_bsf" hds_muxer_select="flv_muxer" hls_demuxer_select="adts_header ac3_parser mov_demuxer mpegts_demuxer" hls_muxer_select="mov_muxer mpegts_muxer" +iamf_demuxer_select="iamfdec" image2_alias_pix_demuxer_select="image2_demuxer" image2_brender_pix_demuxer_select="image2_demuxer" imf_demuxer_deps="libxml2" diff --git a/libavformat/Makefile b/libavformat/Makefile index 9e8e7c9cb8..3b83f5a685 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -35,6 +35,7 @@ OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o # subsystems OBJS-$(CONFIG_ISO_MEDIA) += isom.o +OBJS-$(CONFIG_IAMFDEC) += iamf_reader.o iamf_parse.o iamf.o OBJS-$(CONFIG_NETWORK) += network.o OBJS-$(CONFIG_RIFFDEC) += riffdec.o OBJS-$(CONFIG_RIFFENC) += riffenc.o @@ -258,7 +259,7 @@ OBJS-$(CONFIG_EVC_MUXER) += rawenc.o OBJS-$(CONFIG_HLS_DEMUXER) += hls.o hls_sample_encryption.o OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o OBJS-$(CONFIG_HNM_DEMUXER) += hnm.o -OBJS-$(CONFIG_IAMF_DEMUXER) += iamfdec.o iamf_parse.o iamf.o +OBJS-$(CONFIG_IAMF_DEMUXER) += iamfdec.o OBJS-$(CONFIG_IAMF_MUXER)+= iamfenc.o iamf_writer.o iamf.o OBJS-$(CONFIG_ICO_DEMUXER) += icodec.o OBJS-$(CONFIG_ICO_MUXER) += icoenc.o diff --git a/libavformat/iamf_reader.c b/libavformat/iamf_reader.c new file mode 100644 index 00..12affe2497 --- /dev/null +++ b/libavformat/iamf_reader.c @@ -0,0 +1,366 @@ +/* + * Immersive Audio Model and Formats demuxing utils + * Copyright (c) 2024 James Almer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/avassert.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/log.h" +#include "libavcodec/mathops.h" +#include "libavcodec/packet.h" +#include "avformat.h" +#include "avio_internal.h" +#include "iamf.h" +#include "iamf_parse.h" +#include "iamf_reader.h" + +static AVStream *find_stream_by_id(AVFormatContext *s, int id) +{ +for (int i = 0; i < s->nb_streams; i++) +if (s->streams[i]->id == id) +return s->streams[i]; + +av_log(s, AV_LOG_ERROR, "Invalid stream id %d\n", id); +return NULL; +} + +static int audio_frame_obu(AVFormatContext *s, const IAMFDemuxContext *c, + AVIOContext *pb, AVPacket *pkt, + int len, enum IAMF_OBU_Type type, + unsigned skip_samples, unsigned discard_padding, + int id_in_bitstream) +{ +AVStream *st; +int ret, audio_substream_id; + +if (id_in_bitstream) { +unsigned explicit_audio_substream_id; +int64_t pos = avio_tell(pb); +explicit_audio_substream_id = ffio_read_leb(pb); +len -= avio_tell(pb) - pos; +audio_substream_id = explicit_audio_substream_id; +} else +audio_substream_id = type - IAMF_OBU_IA_AUDIO_FRAME_ID0; + +st = find_stream_by_id(s, audio_substream_id); +if (!st) +return AVERROR_INVALIDDATA; + +ret = av_get_packet(pb, pkt, len); +if (ret < 0) +return ret; +if (ret != len) +return AVERROR_INVALIDDATA; + +if (skip_samples || discard_padding) { +uint8_t *side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10); +if (!side_data) +return AVERROR(ENOMEM); +AV_WL32(side_data, skip_samples); +
[FFmpeg-devel] [PATCH 1/8] avformat/demux: allow demuxers to output more than one packet per read_packet() call
Signed-off-by: James Almer --- libavformat/demux.c | 72 + libavformat/demux.h | 2 ++ 2 files changed, 56 insertions(+), 18 deletions(-) diff --git a/libavformat/demux.c b/libavformat/demux.c index b70979c520..e0205f9dec 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -540,6 +540,59 @@ static int update_wrap_reference(AVFormatContext *s, AVStream *st, int stream_in return 1; } +static void update_timestamps(AVFormatContext *s, AVStream *st, AVPacket *pkt) +{ +FFStream *const sti = ffstream(st); + +if (update_wrap_reference(s, st, pkt->stream_index, pkt) && sti->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET) { +// correct first time stamps to negative values +if (!is_relative(sti->first_dts)) +sti->first_dts = wrap_timestamp(st, sti->first_dts); +if (!is_relative(st->start_time)) +st->start_time = wrap_timestamp(st, st->start_time); +if (!is_relative(sti->cur_dts)) +sti->cur_dts = wrap_timestamp(st, sti->cur_dts); +} + +pkt->dts = wrap_timestamp(st, pkt->dts); +pkt->pts = wrap_timestamp(st, pkt->pts); + +force_codec_ids(s, st); + +/* TODO: audio: time filter; video: frame reordering (pts != dts) */ +if (s->use_wallclock_as_timestamps) +pkt->dts = pkt->pts = av_rescale_q(av_gettime(), AV_TIME_BASE_Q, st->time_base); +} + +int ff_buffer_packet(AVFormatContext *s, AVPacket *pkt) +{ +FFFormatContext *const si = ffformatcontext(s); +AVStream *st = s->streams[pkt->stream_index]; +FFStream *sti = ffstream(st); +const AVPacket *pkt1; +int err; + +update_timestamps(s, st, pkt); + +err = avpriv_packet_list_put(>raw_packet_buffer, pkt, NULL, 0); +if (err < 0) { +av_packet_unref(pkt); +return err; +} + +pkt1 = >raw_packet_buffer.tail->pkt; +si->raw_packet_buffer_size += pkt1->size; + +if (sti->request_probe <= 0) +return 0; + +err = probe_codec(s, st, pkt1); +if (err < 0) +return err; + +return 0; +} + int ff_read_packet(AVFormatContext *s, AVPacket *pkt) { FFFormatContext *const si = ffformatcontext(s); @@ -619,24 +672,7 @@ FF_ENABLE_DEPRECATION_WARNINGS st = s->streams[pkt->stream_index]; sti = ffstream(st); -if (update_wrap_reference(s, st, pkt->stream_index, pkt) && sti->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET) { -// correct first time stamps to negative values -if (!is_relative(sti->first_dts)) -sti->first_dts = wrap_timestamp(st, sti->first_dts); -if (!is_relative(st->start_time)) -st->start_time = wrap_timestamp(st, st->start_time); -if (!is_relative(sti->cur_dts)) -sti->cur_dts = wrap_timestamp(st, sti->cur_dts); -} - -pkt->dts = wrap_timestamp(st, pkt->dts); -pkt->pts = wrap_timestamp(st, pkt->pts); - -force_codec_ids(s, st); - -/* TODO: audio: time filter; video: frame reordering (pts != dts) */ -if (s->use_wallclock_as_timestamps) -pkt->dts = pkt->pts = av_rescale_q(av_gettime(), AV_TIME_BASE_Q, st->time_base); +update_timestamps(s, st, pkt); if (!pktl && sti->request_probe <= 0) return 0; diff --git a/libavformat/demux.h b/libavformat/demux.h index d65eb16ff8..04a426c420 100644 --- a/libavformat/demux.h +++ b/libavformat/demux.h @@ -238,4 +238,6 @@ int ff_get_extradata(void *logctx, AVCodecParameters *par, AVIOContext *pb, int */ int ff_find_stream_index(const AVFormatContext *s, int id); +int ff_buffer_packet(AVFormatContext *s, AVPacket *pkt); + #endif /* AVFORMAT_DEMUX_H */ -- 2.43.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 1/8] avfilter/avfilter: Avoid allocation for AVFilterInternal
Andreas Rheinhardt: > To do this, allocate AVFilterInternal jointly with AVFilterContext > and rename it to FFFilterContext in the process (similarly to > AVStream/FFStream). > The AVFilterInternal* will be removed from AVFilterContext > on the next major bump. > > Signed-off-by: Andreas Rheinhardt > --- > Several of these patches are from the bump patchset; I have just > removed the removal of the internal-pointers, so that this could > be applied at any time. > > libavfilter/avfilter.c| 22 ++ > libavfilter/graphparser.c | 2 +- > libavfilter/internal.h| 16 +--- > 3 files changed, 24 insertions(+), 16 deletions(-) > > diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c > index 9fe249f3f9..2d935cf576 100644 > --- a/libavfilter/avfilter.c > +++ b/libavfilter/avfilter.c > @@ -159,7 +159,7 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, > src->outputs[srcpad] || dst->inputs[dstpad]) > return AVERROR(EINVAL); > > -if (!src->internal->initialized || !dst->internal->initialized) { > +if (!fffilterctx(src)->initialized || !fffilterctx(dst)->initialized) { > av_log(src, AV_LOG_ERROR, "Filters must be initialized before > linking.\n"); > return AVERROR(EINVAL); > } > @@ -668,15 +668,17 @@ static int default_execute(AVFilterContext *ctx, > avfilter_action_func *func, voi > > AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char > *inst_name) > { > +FFFilterContext *ctx; > AVFilterContext *ret; > int preinited = 0; > > if (!filter) > return NULL; > > -ret = av_mallocz(sizeof(AVFilterContext)); > -if (!ret) > +ctx = av_mallocz(sizeof(*ctx)); > +if (!ctx) > return NULL; > +ret = >p; > > ret->av_class = _class; > ret->filter = filter; > @@ -698,10 +700,7 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, > const char *inst_name) > av_opt_set_defaults(ret->priv); > } > > -ret->internal = av_mallocz(sizeof(*ret->internal)); > -if (!ret->internal) > -goto err; > -ret->internal->execute = default_execute; > +ctx->execute = default_execute; > > ret->nb_inputs = filter->nb_inputs; > if (ret->nb_inputs ) { > @@ -735,7 +734,6 @@ err: > av_freep(>output_pads); > ret->nb_outputs = 0; > av_freep(>priv); > -av_freep(>internal); > av_free(ret); > return NULL; > } > @@ -807,7 +805,6 @@ void avfilter_free(AVFilterContext *filter) > av_expr_free(filter->enable); > filter->enable = NULL; > av_freep(>var_values); > -av_freep(>internal); > av_free(filter); > } > > @@ -891,9 +888,10 @@ int ff_filter_process_command(AVFilterContext *ctx, > const char *cmd, > > int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options) > { > +FFFilterContext *ctxi = fffilterctx(ctx); > int ret = 0; > > -if (ctx->internal->initialized) { > +if (ctxi->initialized) { > av_log(ctx, AV_LOG_ERROR, "Filter already initialized\n"); > return AVERROR(EINVAL); > } > @@ -908,7 +906,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary > **options) > ctx->thread_type & ctx->graph->thread_type & AVFILTER_THREAD_SLICE && > ctx->graph->internal->thread_execute) { > ctx->thread_type = AVFILTER_THREAD_SLICE; > -ctx->internal->execute = ctx->graph->internal->thread_execute; > +ctxi->execute= ctx->graph->internal->thread_execute; > } else { > ctx->thread_type = 0; > } > @@ -924,7 +922,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary > **options) > return ret; > } > > -ctx->internal->initialized = 1; > +ctxi->initialized = 1; > > return 0; > } > diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c > index 96ef6b15bf..229e647c0a 100644 > --- a/libavfilter/graphparser.c > +++ b/libavfilter/graphparser.c > @@ -626,7 +626,7 @@ int avfilter_graph_segment_init(AVFilterGraphSegment > *seg, int flags) > > if (p->filter_name) > return fail_creation_pending(seg, p->filter_name, __func__); > -if (!p->filter || p->filter->internal->initialized) > +if (!p->filter || fffilterctx(p->filter)->initialized) > continue; > > ret = avfilter_init_dict(p->filter, NULL); > diff --git a/libavfilter/internal.h b/libavfilter/internal.h > index a6cdf9994c..3d46923cad 100644 > --- a/libavfilter/internal.h > +++ b/libavfilter/internal.h > @@ -133,18 +133,28 @@ struct AVFilterGraphInternal { > FFFrameQueueGlobal frame_queues; > }; > > -struct AVFilterInternal { > +typedef struct FFFilterContext { > +/** > + * The public AVFilterContext. See avfilter.h for it. > + */ > +AVFilterContext p; > + > avfilter_execute_func *execute; > > // 1 when
[FFmpeg-devel] [PATCH] configure, libavutil/version: Remove unused HAVE_MMX2
Signed-off-by: Andreas Rheinhardt --- configure | 1 - libavutil/version.c | 1 - 2 files changed, 2 deletions(-) diff --git a/configure b/configure index f72533b7d2..c7defd9bf3 100755 --- a/configure +++ b/configure @@ -8091,7 +8091,6 @@ cat > $TMPH <= 100); -av_assert0(HAVE_MMX2 == HAVE_MMXEXT); av_assert0(((size_t)-1) > 0); // C guarantees this but if false on a platform we care about revert at least b284e1ffe343d6697fb950d1ee517bafda8a9844 -- 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 4/4] avcodec/internal: Move ff_exp2fi() to aacsbr.c
Only used there. Signed-off-by: Andreas Rheinhardt --- libavcodec/aacsbr.c | 39 +-- libavcodec/internal.h | 22 -- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c index 683c079b91..da9e160a57 100644 --- a/libavcodec/aacsbr.c +++ b/libavcodec/aacsbr.c @@ -31,10 +31,10 @@ #include "sbr.h" #include "aacsbr.h" #include "aacsbrdata.h" -#include "internal.h" #include "aacps.h" #include "sbrdsp.h" #include "libavutil/internal.h" +#include "libavutil/intfloat.h" #include "libavutil/libm.h" #include "libavutil/avassert.h" #include "libavutil/mem_internal.h" @@ -47,6 +47,25 @@ #include "mips/aacsbr_mips.h" #endif /* ARCH_MIPS */ +/** + * 2^(x) for integer x + * @return correctly rounded float + */ +static av_always_inline float exp2fi(int x) { +/* Normal range */ +if (-126 <= x && x <= 128) +return av_int2float((x+127) << 23); +/* Too large */ +else if (x > 128) +return INFINITY; +/* Subnormal numbers */ +else if (x > -150) +return av_int2float(1 << (x+149)); +/* Negligibly small */ +else +return 0; +} + static void aacsbr_func_ptr_init(AACSBRContext *c); static void make_bands(int16_t* bands, int start, int stop, int num_bands) @@ -79,13 +98,13 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) for (k = 0; k < sbr->n[sbr->data[0].bs_freq_res[e]]; k++) { float temp1, temp2, fac; if (sbr->data[0].bs_amp_res) { -temp1 = ff_exp2fi(sbr->data[0].env_facs_q[e][k] + 7); -temp2 = ff_exp2fi(pan_offset - sbr->data[1].env_facs_q[e][k]); +temp1 = exp2fi(sbr->data[0].env_facs_q[e][k] + 7); +temp2 = exp2fi(pan_offset - sbr->data[1].env_facs_q[e][k]); } else { -temp1 = ff_exp2fi((sbr->data[0].env_facs_q[e][k]>>1) + 7) * +temp1 = exp2fi((sbr->data[0].env_facs_q[e][k]>>1) + 7) * exp2_tab[sbr->data[0].env_facs_q[e][k] & 1]; -temp2 = ff_exp2fi((pan_offset - sbr->data[1].env_facs_q[e][k])>>1) * +temp2 = exp2fi((pan_offset - sbr->data[1].env_facs_q[e][k])>>1) * exp2_tab[(pan_offset - sbr->data[1].env_facs_q[e][k]) & 1]; } if (temp1 > 1E20) { @@ -99,8 +118,8 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) } for (e = 1; e <= sbr->data[0].bs_num_noise; e++) { for (k = 0; k < sbr->n_q; k++) { -float temp1 = ff_exp2fi(NOISE_FLOOR_OFFSET - sbr->data[0].noise_facs_q[e][k] + 1); -float temp2 = ff_exp2fi(12 - sbr->data[1].noise_facs_q[e][k]); +float temp1 = exp2fi(NOISE_FLOOR_OFFSET - sbr->data[0].noise_facs_q[e][k] + 1); +float temp2 = exp2fi(12 - sbr->data[1].noise_facs_q[e][k]); float fac; av_assert0(temp1 <= 1E20); fac = temp1 / (1.0f + temp2); @@ -113,9 +132,9 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) for (e = 1; e <= sbr->data[ch].bs_num_env; e++) for (k = 0; k < sbr->n[sbr->data[ch].bs_freq_res[e]]; k++){ if (sbr->data[ch].bs_amp_res) -sbr->data[ch].env_facs[e][k] = ff_exp2fi(sbr->data[ch].env_facs_q[e][k] + 6); +sbr->data[ch].env_facs[e][k] = exp2fi(sbr->data[ch].env_facs_q[e][k] + 6); else -sbr->data[ch].env_facs[e][k] = ff_exp2fi((sbr->data[ch].env_facs_q[e][k]>>1) + 6) +sbr->data[ch].env_facs[e][k] = exp2fi((sbr->data[ch].env_facs_q[e][k]>>1) + 6) * exp2_tab[sbr->data[ch].env_facs_q[e][k] & 1]; if (sbr->data[ch].env_facs[e][k] > 1E20) { av_log(NULL, AV_LOG_ERROR, "envelope scalefactor overflow in dequant\n"); @@ -126,7 +145,7 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac) for (e = 1; e <= sbr->data[ch].bs_num_noise; e++) for (k = 0; k < sbr->n_q; k++) sbr->data[ch].noise_facs[e][k] = -ff_exp2fi(NOISE_FLOOR_OFFSET - sbr->data[ch].noise_facs_q[e][k]); +exp2fi(NOISE_FLOOR_OFFSET - sbr->data[ch].noise_facs_q[e][k]); } } } diff --git a/libavcodec/internal.h b/libavcodec/internal.h index eb9e0d707c..04f7cebdcb 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -26,10 +26,7 @@ #include -#include "libavutil/buffer.h" #include "libavutil/channel_layout.h" -#include "libavutil/mathematics.h" -#include "libavutil/pixfmt.h" #include "avcodec.h" #include "config.h" @@
[FFmpeg-devel] [PATCH 3/4] avcodec/jpeg2000: Simplify exp2fi for numbers used here
The call to ff_exp2fi() here always uses arguments in the normal range, so that the branches in ff_exp2fi() are unnecessary. This is so because JPEG2000 itself only supports up to 128 bits per component per pixel (we only support far less); furthermore, expn is always 0..31 for the decoder and also sane for the encoder, so that the difference between these two values is always in the normal range of -126..128. Signed-off-by: Andreas Rheinhardt --- libavcodec/jpeg2000.c | 18 ++ 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c index 0aa984bc53..d6ffb02319 100644 --- a/libavcodec/jpeg2000.c +++ b/libavcodec/jpeg2000.c @@ -32,7 +32,6 @@ #include "libavutil/mem.h" #include "libavutil/thread.h" #include "avcodec.h" -#include "internal.h" #include "jpeg2000.h" #define SHL(a, n) ((n) >= 0 ? (a) << (n) : (a) >> -(n)) @@ -201,6 +200,17 @@ void ff_jpeg2000_set_significance(Jpeg2000T1Context *t1, int x, int y, // static const uint8_t lut_gain[2][4] = { { 0, 0, 0, 0 }, { 0, 1, 1, 2 } }; (unused) +/** + * 2^(x) for integer x in the range -126..128. + * @return correctly rounded float + */ +static av_always_inline float exp2fi(int x) +{ +av_assert2(-126 <= x && x <= 128); +/* Normal range */ +return av_int2float((x+127) << 23); +} + static void init_band_stepsize(AVCodecContext *avctx, Jpeg2000Band *band, Jpeg2000CodingStyle *codsty, @@ -230,7 +240,7 @@ static void init_band_stepsize(AVCodecContext *avctx, * R_b = R_I + log2 (gain_b ) * see ISO/IEC 15444-1:2002 E.1.1 eqn. E-3 and E-4 */ gain= cbps; -band->f_stepsize = ff_exp2fi(gain - qntsty->expn[gbandno]); +band->f_stepsize = exp2fi(gain - qntsty->expn[gbandno]); band->f_stepsize *= qntsty->mant[gbandno] / 2048.0 + 1.0; break; default: @@ -391,7 +401,7 @@ static int init_band(AVCodecContext *avctx, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int bandno, int gbandno, int reslevelno, - int cbps, int dx, int dy) + const int cbps, int dx, int dy) { Jpeg2000Band *band = reslevel->band + bandno; uint8_t log2_band_prec_width, log2_band_prec_height; @@ -466,7 +476,7 @@ static int init_band(AVCodecContext *avctx, int ff_jpeg2000_init_component(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, - int cbps, int dx, int dy, + const int cbps, int dx, int dy, AVCodecContext *avctx) { int reslevelno, bandno, gbandno = 0, ret, i, j; -- 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 2/4] avcodec/jpeg2000dec: Avoid using GetByteContext.buffer directly
Signed-off-by: Andreas Rheinhardt --- libavcodec/jpeg2000dec.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 3d18d48e7c..1afc6b1e2d 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -886,8 +886,8 @@ static int get_ppm(Jpeg2000DecoderContext *s, int n) return AVERROR(ENOMEM); s->has_ppm = 1; memset(>packed_headers_stream, 0, sizeof(s->packed_headers_stream)); -bytestream_get_buffer(>g.buffer, s->packed_headers + s->packed_headers_size, - n - 3); +bytestream2_get_bufferu(>g, s->packed_headers + s->packed_headers_size, +n - 3); s->packed_headers_size += n - 3; return 0; @@ -921,10 +921,8 @@ static int get_ppt(Jpeg2000DecoderContext *s, int n) } else return AVERROR(ENOMEM); memset(>packed_headers_stream, 0, sizeof(tile->packed_headers_stream)); -memcpy(tile->packed_headers + tile->packed_headers_size, - s->g.buffer, n - 3); +bytestream2_get_bufferu(>g, tile->packed_headers + tile->packed_headers_size, n - 3); tile->packed_headers_size += n - 3; -bytestream2_skip(>g, n - 3); return 0; } -- 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 1/2] avcodec/s302m: enable non-PCM decoding
Quoting Gyan Doshi (2024-02-17 13:37:38) > On 2024-02-17 05:52 pm, Anton Khirnov wrote: > > Quoting Gyan Doshi (2024-02-17 12:46:27) > >> As a TC member who is part of the disagreement, I believe your > >> participation is recused. > > No, I do not think "TC members who commented on a patch lose their right > > to vote" is a reasonable interpretation of that rule. > > I refer to > > "If the disagreement involves a member of the TC, that member should > recuse themselves from the decision" > > at > > https://ffmpeg.org/community.html#Announcement > > You clearly are one of the parties to the disagreement, and "recuse > themselves from the decision" is self-explanatory. Such a maximalist interpretation makes no sense - why should my opinion become invalid because I commented on a patch, but not if I kept it to myself and let someone else object to your patch? And as Rémi said, it would lead to perverse counterproductive incentives, such as TC members refraining from reviewing code. -- Anton Khirnov ___ 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] lavu/tx: correctly use a default scale parameter for all transform types
This fixes the previous commit and adds more cases (DCT-I and DST-I). I am holding off on defining a scale parameter for FFTs as I'd like to use a complex value for them. Patch attached. >From 5b58ac6995cd52c3d61d46f5d4eca42a686752b7 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sat, 17 Feb 2024 20:50:48 +0100 Subject: [PATCH] lavu/tx: correctly use a default scale parameter for all transform types This fixes the previous commit and adds more cases (DCT-I and DST-I). I am holding off on defining a scale parameter for FFTs as I'd like to use a complex value for them. --- libavutil/tx.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavutil/tx.c b/libavutil/tx.c index cc360cff31..f991618b4b 100644 --- a/libavutil/tx.c +++ b/libavutil/tx.c @@ -914,10 +914,12 @@ av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, if (!(flags & AV_TX_INPLACE)) flags |= FF_TX_OUT_OF_PLACE; -if (!scale && ((type == AV_TX_FLOAT_MDCT) || (type == AV_TX_INT32_MDCT) || (type == AV_TX_FLOAT_RDFT) || (AV_TX_INT32_RDFT))) -scale = _scale_f; -else if (!scale && ((type == AV_TX_DOUBLE_MDCT) || (type == AV_TX_DOUBLE_RDFT))) +if (!scale && ((type == AV_TX_DOUBLE_MDCT) || (type == AV_TX_DOUBLE_DCT) || + (type == AV_TX_DOUBLE_DCT_I) || (type == AV_TX_DOUBLE_DST_I) || + (type == AV_TX_DOUBLE_RDFT))) scale = _scale_d; +else if (!scale && !TYPE_IS(FFT, type)) +scale = _scale_f; ret = ff_tx_init_subtx(, type, flags, NULL, len, inv, scale); if (ret < 0) -- 2.43.0.381.gb435a96ce8 ___ 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/jpeg2000dec, j2kenc: Constify where appropriate
Signed-off-by: Andreas Rheinhardt --- libavcodec/j2kenc.c | 2 +- libavcodec/jpeg2000dec.c | 14 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c index 789791f529..ebf21f6e7a 100644 --- a/libavcodec/j2kenc.c +++ b/libavcodec/j2kenc.c @@ -781,7 +781,7 @@ static void putnumpasses(Jpeg2000EncoderContext *s, int n) static int encode_packet(Jpeg2000EncoderContext *s, Jpeg2000ResLevel *rlevel, int layno, - int precno, uint8_t *expn, int numgbits, int packetno, + int precno, const uint8_t *expn, int numgbits, int packetno, int nlayers) { int bandno, empty = 1; diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 691cfbd891..3d18d48e7c 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -489,7 +489,7 @@ static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c) /* get coding parameters for a particular tile or whole image*/ static int get_cod(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c, - uint8_t *properties) + const uint8_t *properties) { Jpeg2000CodingStyle tmp; int compno, ret; @@ -639,7 +639,7 @@ static int get_qcx(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q) /* Get quantization parameters for a particular tile or a whole image. */ static int get_qcd(Jpeg2000DecoderContext *s, int n, Jpeg2000QuantStyle *q, - uint8_t *properties) + const uint8_t *properties) { Jpeg2000QuantStyle tmp; int compno, ret; @@ -1004,7 +1004,7 @@ static int getlblockinc(Jpeg2000DecoderContext *s) return res; } -static inline void select_header(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, +static inline void select_header(Jpeg2000DecoderContext *s, const Jpeg2000Tile *tile, int *tp_index) { s->g = tile->tile_part[*tp_index].header_tpg; @@ -1015,8 +1015,8 @@ static inline void select_header(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, } } -static inline void select_stream(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, - int *tp_index, Jpeg2000CodingStyle *codsty) +static inline void select_stream(Jpeg2000DecoderContext *s, const Jpeg2000Tile *tile, + int *tp_index, const Jpeg2000CodingStyle *codsty) { s->g = tile->tile_part[*tp_index].tpg; if (bytestream2_get_bytes_left(>g) == 0 && s->bit_index == 8) { @@ -1033,9 +1033,9 @@ static inline void select_stream(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, } static int jpeg2000_decode_packet(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile, int *tp_index, - Jpeg2000CodingStyle *codsty, + const Jpeg2000CodingStyle *codsty, Jpeg2000ResLevel *rlevel, int precno, - int layno, uint8_t *expn, int numgbits) + int layno, const uint8_t *expn, int numgbits) { int bandno, cblkno, ret, nb_code_blocks; int cwsno; -- 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] avutil/tx: Use proper default scale for double MDCT/RDFT
Fixes a bug and a Clang warning: "use of logical '||' with constant operand [-Wconstant-logical-operand]" Signed-off-by: Andreas Rheinhardt --- libavutil/tx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavutil/tx.c b/libavutil/tx.c index cc360cff31..f7aa409d72 100644 --- a/libavutil/tx.c +++ b/libavutil/tx.c @@ -914,7 +914,8 @@ av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, if (!(flags & AV_TX_INPLACE)) flags |= FF_TX_OUT_OF_PLACE; -if (!scale && ((type == AV_TX_FLOAT_MDCT) || (type == AV_TX_INT32_MDCT) || (type == AV_TX_FLOAT_RDFT) || (AV_TX_INT32_RDFT))) +if (!scale && ((type == AV_TX_FLOAT_MDCT) || (type == AV_TX_INT32_MDCT) || + (type == AV_TX_FLOAT_RDFT) || (type == AV_TX_INT32_RDFT))) scale = _scale_f; else if (!scale && ((type == AV_TX_DOUBLE_MDCT) || (type == AV_TX_DOUBLE_RDFT))) scale = _scale_d; -- 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] avutil/intreadwrite: Remove obsolete warning
Obsolete since 7ec2354c38978b918dc079b611393becb6c80bf7. Signed-off-by: Andreas Rheinhardt --- libavutil/intreadwrite.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavutil/intreadwrite.h b/libavutil/intreadwrite.h index 21df7887f3..d0a5773b54 100644 --- a/libavutil/intreadwrite.h +++ b/libavutil/intreadwrite.h @@ -583,9 +583,7 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias; #endif /* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be - * naturally aligned. They may be implemented using MMX, - * so emms_c() must be called before using any float code - * afterwards. + * naturally aligned. */ #define AV_COPY(n, d, s) \ -- 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] FFmpeg TC input needed
On Sat, Feb 17, 2024 at 05:15:43PM +0530, Gyan Doshi wrote: > Issue: > > Patch: avcodec/s302m: enable non-PCM decoding > URL: > https://patchwork.ffmpeg.org/project/ffmpeg/patch/20240127103854.9971-1-ffm...@gyani.pro/ > > The issue needing resolution is whether the patch should be added to the > existing s302m decoder or should that decoder > be removed and all old and new patched features inlined into the mpeg-ts > demuxer. [Nested decoder, bsf, demuxer, something else ...] I think the discussion is too much looking at the fine details What we need is TS -> raw samples TS -> TS(lossless) TS -> nonTS (lossless) nonTS -> TS (lossless) raw samples -> TS I think some of the discussed options have problems with lossless non PCM in some intermediate encapsulation in mpeg-TS thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I do not agree with what you have to say, but I'll defend to the death your right to say it. -- Voltaire 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 2/2] swscale/swscale: Check srcSliceH for bayer
Fixes: Assertion srcSliceH > 1 failed at libswscale/swscale_unscaled.c:1359 Signed-off-by: Michael Niedermayer --- libswscale/swscale.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 46ba68fe6a6..7bea5147db1 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -904,7 +904,8 @@ static int scale_internal(SwsContext *c, if ((srcSliceY & (macro_height_src - 1)) || ((srcSliceH & (macro_height_src - 1)) && srcSliceY + srcSliceH != c->srcH) || -srcSliceY + srcSliceH > c->srcH) { +srcSliceY + srcSliceH > c->srcH || +(isBayer(c->srcFormat) && srcSliceH <= 1)) { av_log(c, AV_LOG_ERROR, "Slice parameters %d, %d are invalid\n", srcSliceY, srcSliceH); return AVERROR(EINVAL); } -- 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 1/2] swscale/utils: Allocate more dithererror
Fixes: out of array read Signed-off-by: Michael Niedermayer --- libswscale/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index ec822ff5d92..4dc0fbfefbf 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1885,7 +1885,7 @@ static av_cold int sws_init_single_context(SwsContext *c, SwsFilter *srcFilter, } for (i = 0; i < 4; i++) -if (!FF_ALLOCZ_TYPED_ARRAY(c->dither_error[i], c->dstW + 2)) +if (!FF_ALLOCZ_TYPED_ARRAY(c->dither_error[i], c->dstW + 3)) goto nomem; c->needAlpha = (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat) && isALPHA(c->dstFormat)) ? 1 : 0; -- 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] FFmpeg TC input needed
On Sat, 17 Feb 2024 at 13:16, Gyan Doshi wrote: > > Whilst s302m multiple substreams I haven't seen, Dolby E streams > internally > > contain multiple programs, often 5.1 and a 2.0 downmix. > > That is downstream of the Dolby-E decoder and user will have to use a > filter like channelsplit to bifurcate > those channels irrespective of where the s302m code resides. > The point is there are several layers of streams that also can change dynamically. > > There is a 3x3 matrix of flavours between coded Dolby E and the carriage > > PCM (16-bit, 20-bit, 24-bit). > > Have you seen a larger non-PCM word size inside a smaller AES3 word? > Actually I think that case won't work in the real world, true as the LSBs will be truncated, not passed along. 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] FFmpeg TC input needed
On 2024-02-17 07:12 pm, Niklas Haas wrote: On Sat, 17 Feb 2024 18:45:57 +0530 Gyan Doshi wrote: Whilst s302m multiple substreams I haven't seen, Dolby E streams internally contain multiple programs, often 5.1 and a 2.0 downmix. That is downstream of the Dolby-E decoder and user will have to use a filter like channelsplit to bifurcate those channels irrespective of where the s302m code resides. Is there metadata in Dolby E that tells you which channels belong together (and what attributes they might have)? Is it always 5.1+2.0, or could you have e.g. four different 2.0 programs encoded into a single S302M/AES3 stream? Yes, the metadata is program configuration, with 8 max channels and 8 max programs, so 8 mono programs at most. But my samples are all 5.1+2 or 7.1 or 4.0. These will all result in a single decoded stream from the dolby_e decoder. Regards, Gyan ___ 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] lavc/vvc: Fail inter prediction if using IBC
IBC is not yet implemented. Fail the inter prediction process with AVERROR_PATCHWELCOME if the bitstream uses IBC. Fixes crashes due to out-of-bounds reads when attempting to decode IBC bitstreams. Signed-off-by: Frank Plowman --- libavcodec/vvc/vvc_inter.c | 30 +++--- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/libavcodec/vvc/vvc_inter.c b/libavcodec/vvc/vvc_inter.c index e05f3db93e..cb5e8d4ef6 100644 --- a/libavcodec/vvc/vvc_inter.c +++ b/libavcodec/vvc/vvc_inter.c @@ -779,7 +779,7 @@ static void derive_sb_mv(VVCLocalContext *lc, MvField *mv, MvField *orig_mv, int } } -static void pred_regular_blk(VVCLocalContext *lc, const int skip_ciip) +static int pred_regular_blk(VVCLocalContext *lc, const int skip_ciip) { const VVCFrameContext *fc = lc->fc; const CodingUnit *cu= lc->cu; @@ -789,7 +789,7 @@ static void pred_regular_blk(VVCLocalContext *lc, const int skip_ciip) int sbw, sbh, sb_bdof_flag = 0; if (cu->ciip_flag && skip_ciip) -return; +return 0; sbw = cu->cb_width / mi->num_sb_x; sbh = cu->cb_height / mi->num_sb_y; @@ -803,11 +803,17 @@ static void pred_regular_blk(VVCLocalContext *lc, const int skip_ciip) ff_vvc_set_neighbour_available(lc, x0, y0, sbw, sbh); derive_sb_mv(lc, , _mv, _bdof_flag, x0, y0, sbw, sbh); +if (mv.pred_flag == PF_INTRA) { +avpriv_report_missing_feature(fc->log_ctx, "Intra Block Copy"); +return AVERROR_PATCHWELCOME; +} pred_regular_luma(lc, mi->hpel_if_idx, mi->hpel_if_idx, , x0, y0, sbw, sbh, _mv, sb_bdof_flag); if (fc->ps.sps->r->sps_chroma_format_idc) pred_regular_chroma(lc, , x0, y0, sbw, sbh, _mv, pu->dmvr_flag); } } + +return 0; } static void derive_affine_mvc(MvField *mvc, const VVCFrameContext *fc, const MvField *mv, @@ -872,23 +878,29 @@ static void pred_affine_blk(VVCLocalContext *lc) } } -static void predict_inter(VVCLocalContext *lc) +static int predict_inter(VVCLocalContext *lc) { const VVCFrameContext *fc = lc->fc; const CodingUnit *cu= lc->cu; const PredictionUnit *pu= >pu; +int ret; if (pu->merge_gpm_flag) pred_gpm_blk(lc); else if (pu->inter_affine_flag) pred_affine_blk(lc); -else -pred_regular_blk(lc, 1);//intra block is not ready yet, skip ciip +else { +ret = pred_regular_blk(lc, 1);//intra block is not ready yet, skip ciip +if (ret < 0) +return ret; +} if (lc->sc->sh.r->sh_lmcs_used_flag && !cu->ciip_flag) { uint8_t* dst0 = POS(0, cu->x0, cu->y0); fc->vvcdsp.lmcs.filter(dst0, fc->frame->linesize[LUMA], cu->cb_width, cu->cb_height, fc->ps.lmcs.fwd_lut); } + +return 0; } static int has_inter_luma(const CodingUnit *cu) @@ -901,11 +913,15 @@ int ff_vvc_predict_inter(VVCLocalContext *lc, const int rs) const VVCFrameContext *fc = lc->fc; const CTU *ctu = fc->tab.ctus + rs; CodingUnit *cu = ctu->cus; +int ret; while (cu) { lc->cu = cu; -if (has_inter_luma(cu)) -predict_inter(lc); +if (has_inter_luma(cu)) { +ret = predict_inter(lc); +if (ret < 0) +return ret; +} cu = cu->next; } -- 2.43.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] FFmpeg TC input needed
On Sat, 17 Feb 2024 18:45:57 +0530 Gyan Doshi wrote: > > Whilst s302m multiple substreams I haven't seen, Dolby E streams internally > > contain multiple programs, often 5.1 and a 2.0 downmix. > > That is downstream of the Dolby-E decoder and user will have to use a > filter like channelsplit to bifurcate > those channels irrespective of where the s302m code resides. Is there metadata in Dolby E that tells you which channels belong together (and what attributes they might have)? Is it always 5.1+2.0, or could you have e.g. four different 2.0 programs encoded into a single S302M/AES3 stream? ___ 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] FFmpeg TC input needed
On 2024-02-17 05:31 pm, Kieran Kunhya wrote: On Sat, 17 Feb 2024, 11:46 Gyan Doshi, wrote: Issue: Patch: avcodec/s302m: enable non-PCM decoding URL: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20240127103854.9971-1-ffm...@gyani.pro/ The issue needing resolution is whether the patch should be added to the existing s302m decoder or should that decoder be removed and all old and new patched features inlined into the mpeg-ts demuxer. Additional comments: Dolby E can exist in any PCM container (wav, MP4). S302M just happens to be a tricky one. Whilst s302m multiple substreams I haven't seen, Dolby E streams internally contain multiple programs, often 5.1 and a 2.0 downmix. That is downstream of the Dolby-E decoder and user will have to use a filter like channelsplit to bifurcate those channels irrespective of where the s302m code resides. There is a 3x3 matrix of flavours between coded Dolby E and the carriage PCM (16-bit, 20-bit, 24-bit). Have you seen a larger non-PCM word size inside a smaller AES3 word? Regards, Gyan ___ 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] avcodec/s302m: enable non-PCM decoding
On 2024-02-17 05:52 pm, Anton Khirnov wrote: Quoting Gyan Doshi (2024-02-17 12:46:27) As a TC member who is part of the disagreement, I believe your participation is recused. No, I do not think "TC members who commented on a patch lose their right to vote" is a reasonable interpretation of that rule. I refer to "If the disagreement involves a member of the TC, that member should recuse themselves from the decision" at https://ffmpeg.org/community.html#Announcement You clearly are one of the parties to the disagreement, and "recuse themselves from the decision" is self-explanatory. Regards, Gyan ___ 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] avcodec/s302m: enable non-PCM decoding
Le lauantaina 17. helmikuuta 2024, 13.46.27 EET Gyan Doshi a écrit : > As a TC member who is part of the disagreement, I believe your > participation is recused. Obviously not. We don't want to get into a situation whence TC members have an incentive not to participate in regular code reviews just so that they can participate in the hypothetical making of later related TC decisions. That would be both dumb and counter-productive. Somebody disagreeing with you does not necessarily mean that they have a conflict of interest in the subject matter. -- 雷米‧德尼-库尔蒙 http://www.remlab.net/ ___ 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] avcodec/s302m: enable non-PCM decoding
Quoting Gyan Doshi (2024-02-17 12:46:27) > As a TC member who is part of the disagreement, I believe your > participation is recused. No, I do not think "TC members who commented on a patch lose their right to vote" is a reasonable interpretation of that rule. -- Anton Khirnov ___ 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] FFmpeg TC input needed
On Sat, 17 Feb 2024, 11:46 Gyan Doshi, wrote: > Issue: > > Patch: avcodec/s302m: enable non-PCM decoding > URL: > > https://patchwork.ffmpeg.org/project/ffmpeg/patch/20240127103854.9971-1-ffm...@gyani.pro/ > > The issue needing resolution is whether the patch should be added to the > existing s302m decoder or should that decoder > be removed and all old and new patched features inlined into the mpeg-ts > demuxer. > Additional comments: Dolby E can exist in any PCM container (wav, MP4). S302M just happens to be a tricky one. Whilst s302m multiple substreams I haven't seen, Dolby E streams internally contain multiple programs, often 5.1 and a 2.0 downmix. Strictly speaking you have to handle the case where the Dolby E frame is misaligned and spans two S302M packets which does exist (and there is ambiguity about the PTS). There is a 3x3 matrix of flavours between coded Dolby E and the carriage PCM (16-bit, 20-bit, 24-bit). 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 1/2] avcodec/s302m: enable non-PCM decoding
On 2024-02-16 02:33 pm, Anton Khirnov wrote: Quoting Gyan Doshi (2024-02-15 17:47:49) This patch facilitates a certain productive use of ffmpeg with respect to processing of live inputs that wasn't possible earlier, and which currently is being used successfully by multiple people over the past few weeks. It applies a processing model already implemented in multiple other decoders for a number of years. I haven't seen many reports of issues with them. And surely something being 'a constant source of issues' would be a lot more than 'subtly broken' as you describe them. This reads very much like "I can't be bothered to do it properly and would rather someone else fix it in the future". Given past experience, that someone is highly likely to be me, and fixing past architectural decisions requires a lot more effort than doing things properly in the first place.. You're the only one who has objected on architectural grounds and Not true, Andreas has objected as well. If you are blocking this patch, do acknowledge here within 24 hours and we can send this to the TC else I'll push it after that period. I must say I rather dislike this "my way or the highway" attitude. So yes, I am objecting to the patch in its current form. Thanks for the clear signal. I've presented my case to the TC on the ML. As a TC member who is part of the disagreement, I believe your participation is recused. Regards, Gyan ___ 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] FFmpeg TC input needed
Issue: Patch: avcodec/s302m: enable non-PCM decoding URL: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20240127103854.9971-1-ffm...@gyani.pro/ The issue needing resolution is whether the patch should be added to the existing s302m decoder or should that decoder be removed and all old and new patched features inlined into the mpeg-ts demuxer. Summary: SMPTE ST 302 specifies for carriage of LPCM media in MPEG-TS. SMPTE ST 337 enables this for non-PCM codecs. The payload has a custom layout so it can't be directly processed hence lavc/s302m decodes the packet data to yield LPCM media. But it can only deal at present with LPCM payloads, meaning that non-PCM payloads need to be exported to a raw bytestream format and then decoded in a 2nd step, which prohibits direct transcoding of live/streaming inputs. This patch corrects the identification process for non-PCM payloads, reformats the payload and then carries out in-place decoding by calling a nested decoder similar to the ftr or imm5 decoders in lavc. In the v1 patch review, Andreas, in response to the proposed doc entry describing the feature capability of multiple or differing payloads in a s302m stream, suggested[1] that s302m should be a bitstream filter instead, but I did not see that as an actionable suggestion as he immediately listed the bsf limitations preventing the possibility. I also had not seen an actual sample of s302m with multiple embedded streams. Kieran also observed[2] that he had not seen such a stream in the wild. So the added features of this patch, wherever they are ultimately located, shall not yield more than one media stream. Anton suggested[3] that the decoder should instead be a demuxer. I saw no other objections to the architecture of the patch. I posted the v2 patch, incorporating some changes suggested by Andreas, 4 days later. This had gone uncommented for over two weeks when I posted a notice stating an intention to push. Anton posted[4] a new objection that "If it dynamically generates nested decoders, then it's not a proper codec in our model". This new objection is not connected to multiple streams but only to a codec 'model' that I don't see described anywhere and which contradicts the implementations of multiple decoders with a nested decoder, including the ftr and imm5 decoders, which are most similar in design to the patched s302m decoder. Anton later on mentioned[5] that nested decoders are "a constant source of issues". However, I didn't find anything on trac reporting an issue with the nested decoders of ftr and imm5 nor anything on ffmpeg-devel-ml or ffmpeg-user-ml. Nothing in their commit history either points to architectural bugs. These decoders have been around for 6 years among themselves. The testing of the patched s302m decoder over the past month by myself, an OTT provider and others shows no issues either. Finally, Anton speculates[6] that the burden of fixes will likely fall upon him. In none of his objections, till the time of writing, did I see specific concerns with the patch. There are some limitations in shifting this decoder wholesale to inside the MPEG-TS demuxer. A s302m stream may contain some non-media payload accompanying non-PCM media i.e. S-ADM metadata. At present, I have neither the samples nor the specification needed in order to locate and extract or parse this metadata. Formatting the payload data inside the demuxer will lead to irrevocable loss of such metadata if present. However, a decoder patch allows simultaneuous output of both a decoded stream alongside a copied stream. The end-user can then do with the raw data whatever they wish. Ultimately, s302m is specified an an elementary stream inside a MPEG-TS container. Its internal handling is better left to a dedicated module like a decoder. A bitstream filter might be a better fit if s302m streams with multiple media payloads ever start appearing - none have, so far - but for single media payloads, a decoder remains the best place. Regards, Gyan [1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2024-January/320119.html [2]: https://ffmpeg.org/pipermail/ffmpeg-devel/2024-January/320321.html [3]: https://ffmpeg.org/pipermail/ffmpeg-devel/2024-January/320258.html [4]: https://ffmpeg.org/pipermail/ffmpeg-devel/2024-February/321514.html [5]: https://ffmpeg.org/pipermail/ffmpeg-devel/2024-February/321523.html [6]: https://ffmpeg.org/pipermail/ffmpeg-devel/2024-February/321539.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 1/2] avcodec/s302m: enable non-PCM decoding
On 2024-02-16 07:25 pm, Andreas Rheinhardt wrote: Gyan Doshi: On 2024-02-15 04:17 pm, Anton Khirnov wrote: Hi, sorry for the delay, I've been busy fixing things for the release Quoting Gyan Doshi via ffmpeg-devel (2024-01-29 05:00:33) On 2024-01-28 04:24 pm, Anton Khirnov wrote: a) it would mean essentially inlining this decoder in the demuxer. Why is that a problem? This decoder seems like it shouldn't be a decoder. I agree with Andreas that this seems like it's a demuxer pretending to be a decoder. This module transforms the entire raw payload data to generate its output, even if the syntax is simple which essentially makes it a de-coder. The de-multiplexer aspect of multiple streams is an academic possibility allowed by the standard but not seen in any sample which makes me suspect it's used for carriage between broadcast facilities rather than something ever sent to an OTT provider, let alone an end user. If it dynamically generates nested decoders, then it's not a proper codec in our model. It should be either a part of the demuxer, or a bitstream filter (possibly inserted automatically by the demuxer). s302m is a hybrid creature and does not slot cleanly into any role. So there is no theoretically proper place for this component - any choice is a least-out-of-place accommodation. But it is much more out of place inside a demuxer. Analyzing packet payload and then manipulating that entire payload is much closer to a decoding role than data chunk extraction for packetization. And the stream extracted from the container is meant to be SMPTE ST 302 not PCM* or Dolby-E/AC-3..etc, which will both misrepresent what the container carries and possibly discard S-ADM metadata, if present, in the packet. With passthrough demuxing, a stream can be mapped for both decoding and streamcopying. This is not true: It can not be streamcopied into formats expecting ordinary PCM or Dolby-e/AC-3. Which is why exporting the data without the unnecessary packetization is preferable. With this decoder patch, the packet exported from the demuxer remains s302m. That may contain either PCM or non-PCM payload[+ ADM metadata]. A streamcopied output into TS or raw data allows the user to parse out the ADM on their own. I don't have the standard or samples for ADM so I can't extract it with either a decoder or demuxer patch. If they want the non-PCM coded stream then they select the pre-existing method of non_pcm_mode copy in the decoder and a suitable pcm_* encoder to extract the coded stream, else set the non pcm mode to decode to obtain playable LPCM AVFrames. With a demuxer patch, the packet extracted from the demuxer is either PCM* or some non-PCM codec. The ADM portion if present is lost since there is no parser for it. And if we add an option for passthrough demuxing and leave the s302m decoder as it is, then we're back with the status quo of a 2-step transcoding pipeline. Regards, Gyan ___ 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".