[FFmpeg-devel] [PATCH v2] avcodec/ac3: Implement float_to_fixed24 for aarch64 neon
Start porting AC-3 ARMv7 NEON algorithms over to aarch64. This one is low-hanging fruit since checkasm tests exist. Fixed the Makefile compared to v1. Tested on AWS Graviton2 (t4g.medium), GCC 12.3: $ tests/checkasm/checkasm --verbose --bench --test=ac3dsp ... NEON: - ac3dsp.float_to_fixed24 [OK] checkasm: all 1 tests passed float_to_fixed24_c: 2450.7 float_to_fixed24_neon: 574.0 Signed-off-by: Geoff Hill --- libavcodec/aarch64/Makefile | 2 ++ libavcodec/aarch64/ac3dsp_init_aarch64.c | 36 +++ libavcodec/aarch64/ac3dsp_neon.S | 37 libavcodec/ac3dsp.c | 4 ++- libavcodec/ac3dsp.h | 3 +- 5 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 libavcodec/aarch64/ac3dsp_init_aarch64.c create mode 100644 libavcodec/aarch64/ac3dsp_neon.S diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile index beb6a02f5f..95ad4dd202 100644 --- a/libavcodec/aarch64/Makefile +++ b/libavcodec/aarch64/Makefile @@ -1,4 +1,5 @@ # subsystems +OBJS-$(CONFIG_AC3DSP) += aarch64/ac3dsp_init_aarch64.o OBJS-$(CONFIG_FMTCONVERT) += aarch64/fmtconvert_init.o OBJS-$(CONFIG_H264CHROMA) += aarch64/h264chroma_init_aarch64.o OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_init_aarch64.o @@ -35,6 +36,7 @@ ARMV8-OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp.o # subsystems NEON-OBJS-$(CONFIG_AAC_DECODER) += aarch64/sbrdsp_neon.o +NEON-OBJS-$(CONFIG_AC3DSP) += aarch64/ac3dsp_neon.o NEON-OBJS-$(CONFIG_FMTCONVERT) += aarch64/fmtconvert_neon.o NEON-OBJS-$(CONFIG_H264CHROMA) += aarch64/h264cmc_neon.o NEON-OBJS-$(CONFIG_H264DSP) += aarch64/h264dsp_neon.o \ diff --git a/libavcodec/aarch64/ac3dsp_init_aarch64.c b/libavcodec/aarch64/ac3dsp_init_aarch64.c new file mode 100644 index 00..e3320de0f5 --- /dev/null +++ b/libavcodec/aarch64/ac3dsp_init_aarch64.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 Geoff Hill + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include + +#include "libavutil/arm/cpu.h" +#include "libavutil/attributes.h" +#include "libavcodec/ac3dsp.h" +#include "config.h" + +void ff_float_to_fixed24_neon(int32_t *dst, const float *src, size_t len); + +av_cold void ff_ac3dsp_init_aarch64(AC3DSPContext *c) +{ +int cpu_flags = av_get_cpu_flags(); +if (!have_neon(cpu_flags)) return; + +c->float_to_fixed24 = ff_float_to_fixed24_neon; +} diff --git a/libavcodec/aarch64/ac3dsp_neon.S b/libavcodec/aarch64/ac3dsp_neon.S new file mode 100644 index 00..77106ea586 --- /dev/null +++ b/libavcodec/aarch64/ac3dsp_neon.S @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 Geoff Hill + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU 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/aarch64/asm.S" + +// void ff_float_to_fixed24_neon(int32_t *dst, const float *src, unsigned int len) + +function ff_float_to_fixed24_neon, export=1 +0: ld1 {v0.4s, v1.4s}, [x1], #32 +fcvtzs v0.4s, v0.4s, #24 +ld1 {v2.4s, v3.4s}, [x1], #32 +fcvtzs v1.4s, v1.4s, #24 +fcvtzs v2.4s, v2.4s, #24 +st1 {v0.4s, v1.4s}, [x0], #32 +fcvtzs v3.4s, v3.4s, #24 +st1 {v2.4s, v3.4s}, [x0], #32 +subsw2, w2, #16 +b.ne0b +ret +endfunc diff --git a/libavcodec/ac3dsp.c b/libavcodec/ac3dsp.c index 8397e03d32..730fa70fff 100644 --- a/libavcodec/ac3dsp.c +++
[FFmpeg-devel] [PATCH 5/5] avcodec/huffyuvencdsp: Fix load of misaligned values
Affected many ffvhuff FATE tests. Signed-off-by: Andreas Rheinhardt --- libavcodec/huffyuvencdsp.c | 32 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/libavcodec/huffyuvencdsp.c b/libavcodec/huffyuvencdsp.c index 36e8f6130b..27428635af 100644 --- a/libavcodec/huffyuvencdsp.c +++ b/libavcodec/huffyuvencdsp.c @@ -18,16 +18,32 @@ #include "config.h" #include "libavutil/attributes.h" +#include "libavutil/intreadwrite.h" #include "huffyuvencdsp.h" #include "mathops.h" +#if HAVE_FAST_64BIT +#define BITS 64 +typedef uint64_t uint_native; +#else +#define BITS 32 +typedef uint32_t uint_native; +#endif +#define RN AV_JOIN(AV_RN, BITS) +#define RNA AV_JOIN(AV_JOIN(AV_RN, BITS), A) +#define WNA AV_JOIN(AV_JOIN(AV_WN, BITS), A) + +// 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size +#define pb_7f (~(uint_native)0 / 255 * 0x7f) +#define pb_80 (~(uint_native)0 / 255 * 0x80) + // 0x00010001 or 0x0001000100010001 or whatever, depending on the cpu's native arithmetic size -#define pw_1 (ULONG_MAX / UINT16_MAX) +#define pw_1 ((uint_native)-1 / UINT16_MAX) static void diff_int16_c(uint16_t *dst, const uint16_t *src1, const uint16_t *src2, unsigned mask, int w){ long i; #if !HAVE_FAST_UNALIGNED -if((long)src2 & (sizeof(long)-1)){ +if ((uintptr_t)src2 & (sizeof(uint_native) - 1)) { for(i=0; i+3> 1) * pw_1; -unsigned long pw_msb = pw_lsb + pw_1; +uint_native pw_lsb = (mask >> 1) * pw_1; +uint_native pw_msb = pw_lsb + pw_1; -for (i = 0; i <= w - (int)sizeof(long)/2; i += sizeof(long)/2) { -long a = *(long*)(src1+i); -long b = *(long*)(src2+i); -*(long*)(dst+i) = ((a|pw_msb) - (b_lsb)) ^ ((a^b^pw_msb)_msb); +for (i = 0; i <= w - (int)sizeof(uint_native)/2; i += sizeof(uint_native)/2) { +uint_native a = RNA(src1 + i); +uint_native b = RN (src2 + i); +WNA(dst + i, ((a | pw_msb) - (b & pw_lsb)) ^ ((a^b^pw_msb) & pw_msb)); } } for (; ihttps://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] avfilter/vf_spp: Fix left-shift of negative value
Affected the vf-spp FATE-test (on x86 only when MMX is disabled). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_spp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_spp.c b/libavfilter/vf_spp.c index 5c6495612b..c8366ae319 100644 --- a/libavfilter/vf_spp.c +++ b/libavfilter/vf_spp.c @@ -171,7 +171,7 @@ static void store_slice_c(uint8_t *dst, const int16_t *src, int y, x; #define STORE(pos) do { \ -temp = ((src[x + y*src_linesize + pos] << log2_scale) + d[pos]) >> 6; \ +temp = (src[x + y*src_linesize + pos] * (1 << log2_scale) + d[pos]) >> 6;\ if (temp & 0x100) \ temp = ~(temp >> 31); \ dst[x + y*dst_linesize + pos] = temp; \ @@ -202,7 +202,7 @@ static void store_slice16_c(uint16_t *dst, const int16_t *src, unsigned int mask = -1<>1)) >> 5; \ +temp = (src[x + y*src_linesize + pos] * (1 << log2_scale) + (d[pos]>>1)) >> 5; \ if (temp & mask ) \ temp = ~(temp >> 31); \ dst[x + y*dst_linesize + pos] = temp; \ -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/5] avcodec/pngdsp: Fix unaligned accesses, effective type violations
Affected the lscr fate-test (only visible on x86 if the SSE2 is disabled). Signed-off-by: Andreas Rheinhardt --- libavcodec/pngdsp.c | 25 +++-- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/libavcodec/pngdsp.c b/libavcodec/pngdsp.c index 65916b1386..50ee96a684 100644 --- a/libavcodec/pngdsp.c +++ b/libavcodec/pngdsp.c @@ -21,20 +21,33 @@ #include "config.h" #include "libavutil/attributes.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/macros.h" #include "png.h" #include "pngdsp.h" +#if HAVE_FAST_64BIT +#define BITS 64 +typedef uint64_t uint_native; +#else +#define BITS 32 +typedef uint32_t uint_native; +#endif +#define RN AV_JOIN(AV_RN, BITS) +#define RNA AV_JOIN(AV_JOIN(AV_RN, BITS), A) +#define WN AV_JOIN(AV_WN, BITS) + // 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size -#define pb_7f (~0UL / 255 * 0x7f) -#define pb_80 (~0UL / 255 * 0x80) +#define pb_7f (~(uint_native)0 / 255 * 0x7f) +#define pb_80 (~(uint_native)0 / 255 * 0x80) static void add_bytes_l2_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w) { long i; -for (i = 0; i <= w - (int) sizeof(long); i += sizeof(long)) { -long a = *(long *)(src1 + i); -long b = *(long *)(src2 + i); -*(long *)(dst + i) = ((a & pb_7f) + (b & pb_7f)) ^ ((a ^ b) & pb_80); +for (i = 0; i <= w - (int) sizeof(uint_native); i += sizeof(uint_native)) { +uint_native a = RNA(src1 + i); +uint_native b = RN (src2 + i); +WN(dst + i, ((a & pb_7f) + (b & pb_7f)) ^ ((a ^ b) & pb_80)); } for (; i < w; i++) dst[i] = src1[i] + src2[i]; -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/5] fate/ffmpeg: Explicitly set pix fmt for sub2video tests
Otherwise the test would use bgra on little endian and argb on big endian. Signed-off-by: Andreas Rheinhardt --- tests/fate/ffmpeg.mak | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/fate/ffmpeg.mak b/tests/fate/ffmpeg.mak index 3c549b265e..fda3a29239 100644 --- a/tests/fate/ffmpeg.mak +++ b/tests/fate/ffmpeg.mak @@ -64,7 +64,7 @@ fate-sub2video_basic: CMD = framecrc -auto_conversion_filters \ -i $(TARGET_SAMPLES)/sub/vobsub.idx \ -fps_mode passthrough -copyts \ -filter_complex "sws_flags=+accurate_rnd+bitexact\;[0:s:0]scale" \ - -c:v rawvideo -threads 1 + -c:v rawvideo -pix_fmt bgra -threads 1 # Time-limited run with a sample that doesn't require seeking and # contains samples within the initial period. @@ -74,7 +74,7 @@ fate-sub2video_time_limited: CMD = framecrc -auto_conversion_filters \ -fps_mode passthrough -copyts \ -t 15 \ -filter_complex "sws_flags=+accurate_rnd+bitexact\;[0:s:0]scale" \ - -c:v rawvideo -threads 1 + -c:v rawvideo -threads 1 -pix_fmt bgra FATE_FFMPEG-$(call ENCDEC, PCM_S16LE, PCM_S16LE) += fate-unknown_layout-pcm fate-unknown_layout-pcm: $(AREF) -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/5] avcodec/ppc/hpeldsp_altivec: Fix left-shift of negative number
It is UB and affected e.g. the vp5 and vp61 FATE tests: https://fate.ffmpeg.org/report.cgi?time=20240327083327=ppc-linux-gcc-13.2-ubsan-altivec-qemu Signed-off-by: Andreas Rheinhardt --- libavcodec/ppc/hpeldsp_altivec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/ppc/hpeldsp_altivec.c b/libavcodec/ppc/hpeldsp_altivec.c index a531b6b6ec..4bf6b28ed6 100644 --- a/libavcodec/ppc/hpeldsp_altivec.c +++ b/libavcodec/ppc/hpeldsp_altivec.c @@ -41,9 +41,9 @@ void ff_put_pixels16_altivec(uint8_t *block, const uint8_t *pixels, ptrdiff_t li register vector unsigned char pixelsv1D; int i; -register ptrdiff_t line_size_2 = line_size << 1; +register ptrdiff_t line_size_2 = line_size * (1 << 1); register ptrdiff_t line_size_3 = line_size + line_size_2; -register ptrdiff_t line_size_4 = line_size << 2; +register ptrdiff_t line_size_4 = line_size * (1 << 2); // hand-unrolling the loop by 4 gains about 15% // mininum execution time goes from 74 to 60 cycles -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v1] lavc/vaapi_encode: Add VAAPI version check for BLBRC
From: Fei Wang Fix build fail when VAAPI version less than 0.39.2. Signed-off-by: Fei Wang --- libavcodec/vaapi_encode.c | 20 +--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 940f0678a5..c4b5411e68 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1805,9 +1805,17 @@ static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx) int i, first = 1, res; supported_va_rc_modes = rc_attr.value; -if (ctx->blbrc && !(supported_va_rc_modes & VA_RC_MB)) { +if (ctx->blbrc) { +#if VA_CHECK_VERSION(0, 39, 2) +if (!(supported_va_rc_modes & VA_RC_MB)) { +ctx->blbrc = 0; +av_log(avctx, AV_LOG_WARNING, "Driver does not support BLBRC.\n"); +} +#else ctx->blbrc = 0; -av_log(avctx, AV_LOG_WARNING, "Driver does not support BLBRC.\n"); +av_log(avctx, AV_LOG_WARNING, "Please consider to update to VAAPI 0.39.2 " + "or above, which can support BLBRC.\n"); +#endif } for (i = 0; i < FF_ARRAY_ELEMS(vaapi_encode_rc_modes); i++) { @@ -2032,7 +2040,11 @@ rc_mode_found: ctx->config_attributes[ctx->nb_config_attributes++] = (VAConfigAttrib) { .type = VAConfigAttribRateControl, +#if VA_CHECK_VERSION(0, 39, 2) .value = ctx->blbrc ? ctx->va_rc_mode | VA_RC_MB : ctx->va_rc_mode, +#else +.value = ctx->va_rc_mode, +#endif }; } @@ -2061,10 +2073,12 @@ rc_mode_found: #if VA_CHECK_VERSION(1, 1, 0) .ICQ_quality_factor = av_clip(rc_quality, 1, 51), .max_qp = (avctx->qmax > 0 ? avctx->qmax : 0), -.rc_flags.bits.mb_rate_control = ctx->blbrc ? 1 : 2, #endif #if VA_CHECK_VERSION(1, 3, 0) .quality_factor = rc_quality, +#endif +#if VA_CHECK_VERSION(0, 39, 2) +.rc_flags.bits.mb_rate_control = ctx->blbrc ? 1 : 2, #endif }; vaapi_encode_add_global_param(avctx, -- 2.25.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] Revert "avformat/mov: ignore item boxes for animated heif"
This reverts commit f6b7b473d456a6aa1c063c4261b17277e2c70ac0. The image in the item boxes and the animation in the trak box are not necessarely the same, so both should be exported. Signed-off-by: James Almer --- libavformat/mov.c | 44 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 5463f36770..c93a09d385 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -83,7 +83,6 @@ typedef struct MOVParseTableEntry { static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom); static int mov_read_mfra(MOVContext *c, AVIOContext *f); -static void mov_free_stream_context(AVFormatContext *s, AVStream *st); static int64_t add_ctts_entry(MOVCtts** ctts_data, unsigned int* ctts_count, unsigned int* allocated_size, int count, int duration); @@ -4860,25 +4859,6 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) MOVStreamContext *sc; int ret; -if (c->found_iinf) { -// * For animated heif, if the iinf box showed up before the moov -// box, we need to clear all the streams read in the former. -for (int i = c->nb_heif_item - 1; i >= 0; i--) { -HEIFItem *item = >heif_item[i]; - -av_freep(>name); - -if (!item->st) -continue; - -mov_free_stream_context(c->fc, item->st); -ff_remove_stream(c->fc, item->st); -} -av_freep(>heif_item); -c->nb_heif_item = 0; -c->found_iinf = c->found_iloc = 0; -} - st = avformat_new_stream(c->fc, NULL); if (!st) return AVERROR(ENOMEM); st->id = -1; @@ -8065,9 +8045,8 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) int64_t base_offset, extent_offset, extent_length; uint8_t value; -if (c->found_moov) { -// * For animated heif, we don't care about the iloc box as all the -// necessary information can be found in the moov box. +if (c->found_iloc) { +av_log(c->fc, AV_LOG_INFO, "Duplicate iloc box found\n"); return 0; } @@ -8198,11 +8177,6 @@ static int mov_read_iinf(MOVContext *c, AVIOContext *pb, MOVAtom atom) av_log(c->fc, AV_LOG_WARNING, "Duplicate iinf box found\n"); return 0; } -if (c->found_moov) { -// * For animated heif, we don't care about the iinf box as all the -// necessary information can be found in the moov box. -return 0; -} version = avio_r8(pb); avio_rb24(pb); // flags. @@ -8356,12 +8330,6 @@ static int mov_read_ispe(MOVContext *c, AVIOContext *pb, MOVAtom atom) { uint32_t width, height; -if (c->found_moov) { -// * For animated heif, we don't care about the ispe box as all the -// necessary information can be found in the moov box. -return 0; -} - avio_r8(pb); /* version */ avio_rb24(pb); /* flags */ width = avio_rb32(pb); @@ -8396,12 +8364,6 @@ static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) int version, flags; int ret; -if (c->found_moov) { -// * For animated heif, we don't care about the iprp box as all the -// necessary information can be found in the moov box. -return 0; -} - a.size = avio_rb32(pb); a.type = avio_rl32(pb); @@ -8485,6 +8447,7 @@ static int mov_read_iprp(MOVContext *c, AVIOContext *pb, MOVAtom atom) ret = 0; fail: +c->cur_item_id = -1; for (int i = 0; i < nb_atoms; i++) av_free(atoms[i].data); av_free(atoms); @@ -9508,6 +9471,7 @@ static int mov_read_header(AVFormatContext *s) mov->trak_index = -1; mov->thmb_item_id = -1; mov->primary_item_id = -1; +mov->cur_item_id = -1; /* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */ if (pb->seekable & AVIO_SEEKABLE_NORMAL) atom.size = avio_size(pb); -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/4] avcodec/libx265: do not arbitrarily limit color values
Newer specifications such as H.273 have, and probably will further in the future add new values to these, so - instead of trying to update these limits - we should simply check if the values are not set to the value of "unspecified". This should allow newer avutil values such as IPT-C2 or YCgCo-R variants be passed to x265 itself, which apparently does its own validation further down the line. --- libavcodec/libx265.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index d3e74eaacf..43ab14bfee 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -315,12 +315,9 @@ FF_ENABLE_DEPRECATION_WARNINGS avctx->pix_fmt == AV_PIX_FMT_YUVJ422P || avctx->pix_fmt == AV_PIX_FMT_YUVJ444P; -if ((avctx->color_primaries <= AVCOL_PRI_SMPTE432 && - avctx->color_primaries != AVCOL_PRI_UNSPECIFIED) || -(avctx->color_trc <= AVCOL_TRC_ARIB_STD_B67 && - avctx->color_trc != AVCOL_TRC_UNSPECIFIED) || -(avctx->colorspace <= AVCOL_SPC_ICTCP && - avctx->colorspace != AVCOL_SPC_UNSPECIFIED)) { +if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED || +avctx->color_trc != AVCOL_TRC_UNSPECIFIED || +avctx->colorspace != AVCOL_SPC_UNSPECIFIED) { ctx->params->vui.bEnableColorDescriptionPresentFlag = 1; -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/4] avfilter/{buffersrc, vf_setparams}: map IPT-C2, YCgCo-R variants
--- libavfilter/buffersrc.c| 3 +++ libavfilter/vf_setparams.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index ddcd403785..680eedf25b 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -337,12 +337,15 @@ static const AVOption buffer_options[] = { { "smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE170M}, INT_MIN, INT_MAX, V, .unit = "colorspace"}, { "smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE240M}, INT_MIN, INT_MAX, V, .unit = "colorspace"}, { "ycgco", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_YCGCO}, INT_MIN, INT_MAX, V, .unit = "colorspace"}, +{ "ycgco-re",NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_YCGCO_RE}, INT_MIN, INT_MAX, V, .unit = "colorspace"}, +{ "ycgco-ro",NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_YCGCO_RO}, INT_MIN, INT_MAX, V, .unit = "colorspace"}, { "bt2020nc",NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT2020_NCL},INT_MIN, INT_MAX, V, .unit = "colorspace"}, { "bt2020c", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT2020_CL}, INT_MIN, INT_MAX, V, .unit = "colorspace"}, { "smpte2085", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE2085}, INT_MIN, INT_MAX, V, .unit = "colorspace"}, { "chroma-derived-nc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_CHROMA_DERIVED_NCL},INT_MIN, INT_MAX, V, .unit = "colorspace"}, { "chroma-derived-c", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_CHROMA_DERIVED_CL}, INT_MIN, INT_MAX, V, .unit = "colorspace"}, { "ictcp", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_ICTCP}, INT_MIN, INT_MAX, V, .unit = "colorspace"}, +{ "ipt-c2", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_IPT_C2}, INT_MIN, INT_MAX, V, .unit = "colorspace"}, { "range", "select color range", OFFSET(color_range), AV_OPT_TYPE_INT, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, AVCOL_RANGE_NB-1, V, .unit = "range"}, { "unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, V, .unit = "range"}, { "unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, V, .unit = "range"}, diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c index c96f4d314b..b7da8eb54b 100644 --- a/libavfilter/vf_setparams.c +++ b/libavfilter/vf_setparams.c @@ -110,12 +110,15 @@ static const AVOption setparams_options[] = { {"smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE170M}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"}, {"smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE240M}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"}, {"ycgco", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_YCGCO}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"}, +{"ycgco-re", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_YCGCO_RE}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"}, +{"ycgco-ro", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_YCGCO_RO}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"}, {"bt2020nc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT2020_NCL},INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"}, {"bt2020c",NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT2020_CL}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"}, {"smpte2085", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE2085}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"}, {"chroma-derived-nc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_CHROMA_DERIVED_NCL},INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"}, {"chroma-derived-c", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_CHROMA_DERIVED_CL}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"}, {"ictcp", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_ICTCP}, INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"}, +{"ipt-c2", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_IPT_C2},INT_MIN, INT_MAX, FLAGS, .unit = "colorspace"}, {NULL} }; -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/4] avutil/pix{desc, fmt}: add new matrix coefficients from H.273 v3
* SMPTE ST 2128 IPT-C2 defines the coefficients utilized in DoVi Profile 5. Profile 5 can thus now be represented in VUI as {AVCOL_RANGE_JPEG, AVCOL_PRI_BT2020, AVCOL_TRC_SMPTE2084, AVCOL_SPC_IPT_C2, AVCHROMA_LOC_LEFT} (although other chroma sample locations are allowed). AVCOL_TRC_SMPTE2084 should in this case be interpreted as 'PQ with reshaping'. * YCgCo-Re and YCgCo-Ro define the bitexact YCgCo-R, where the number of bits added to a source RGB bit depth is 2 (i.e., even) and 1 (i.e., odd), respectively. --- doc/APIchanges | 4 libavutil/pixdesc.c | 3 +++ libavutil/pixfmt.h | 3 +++ libavutil/version.h | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index aa102b4925..296d87d8fb 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,10 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-03-27 - xx - lavu 59.11.100 - pixfmt.h + Add AVCOL_SPC_IPT_C2, AVCOL_SPC_YCGCO_RE and AVCOL_SPC_YCGCO_RO + to map new matrix coefficients defined by H.273 v3. + 2024-03-27 - xx - lavu 59.10.100 - frame.h Add AVSideDataDescriptor, enum AVSideDataProps, and av_frame_side_data_desc(). diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 9c708520b1..1c0bcf2232 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2854,6 +2854,9 @@ static const char * const color_space_names[] = { [AVCOL_SPC_CHROMA_DERIVED_NCL] = "chroma-derived-nc", [AVCOL_SPC_CHROMA_DERIVED_CL] = "chroma-derived-c", [AVCOL_SPC_ICTCP] = "ictcp", +[AVCOL_SPC_IPT_C2] = "ipt-c2", +[AVCOL_SPC_YCGCO_RE] = "ycgco-re", +[AVCOL_SPC_YCGCO_RO] = "ycgco-ro", }; static const char * const chroma_location_names[] = { diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 4aa20e4e58..430118d3e1 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -623,6 +623,9 @@ enum AVColorSpace { AVCOL_SPC_CHROMA_DERIVED_NCL = 12, ///< Chromaticity-derived non-constant luminance system AVCOL_SPC_CHROMA_DERIVED_CL = 13, ///< Chromaticity-derived constant luminance system AVCOL_SPC_ICTCP = 14, ///< ITU-R BT.2100-0, ICtCp +AVCOL_SPC_IPT_C2 = 15, ///< SMPTE ST 2128 +AVCOL_SPC_YCGCO_RE= 16, ///< YCgCo-R, even addition of bits +AVCOL_SPC_YCGCO_RO= 17, ///< YCgCo-R, odd addition of bits AVCOL_SPC_NB///< Not part of ABI }; diff --git a/libavutil/version.h b/libavutil/version.h index 8774ed4d1a..d0cc34f43a 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 59 -#define LIBAVUTIL_VERSION_MINOR 10 +#define LIBAVUTIL_VERSION_MINOR 11 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/4] avcodec/options_table: map IPT-C2, YCgCo-R variants in colorspace
--- libavcodec/options_table.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index 7a2ef3474e..7a70fa7b6c 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -331,8 +331,11 @@ static const AVOption avcodec_options[] = { {"chroma-derived-nc", "Chroma-derived NCL", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_CHROMA_DERIVED_NCL }, INT_MIN, INT_MAX, V|E|D, .unit = "colorspace_type"}, {"chroma-derived-c", "Chroma-derived CL", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_CHROMA_DERIVED_CL }, INT_MIN, INT_MAX, V|E|D, .unit = "colorspace_type"}, {"ictcp", "ICtCp", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_ICTCP }, INT_MIN, INT_MAX, V|E|D, .unit = "colorspace_type"}, +{"ipt-c2","IPT-C2", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_IPT_C2 }, INT_MIN, INT_MAX, V|E|D, .unit = "colorspace_type"}, {"unspecified", "Unspecified",0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_UNSPECIFIED },INT_MIN, INT_MAX, V|E|D, .unit = "colorspace_type"}, {"ycocg", "YCGCO", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_YCGCO }, INT_MIN, INT_MAX, V|E|D, .unit = "colorspace_type"}, +{"ycgco-re", "YCgCo-R, even add.", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_YCGCO_RE }, INT_MIN, INT_MAX, V|E|D, .unit = "colorspace_type"}, +{"ycgco-ro", "YCgCo-R, odd add.", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_YCGCO_RO }, INT_MIN, INT_MAX, V|E|D, .unit = "colorspace_type"}, {"bt2020_ncl","BT.2020 NCL",0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT2020_NCL }, INT_MIN, INT_MAX, V|E|D, .unit = "colorspace_type"}, {"bt2020_cl", "BT.2020 CL", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT2020_CL }, INT_MIN, INT_MAX, V|E|D, .unit = "colorspace_type"}, {"color_range", "color range", OFFSET(color_range), AV_OPT_TYPE_INT, {.i64 = AVCOL_RANGE_UNSPECIFIED }, 0, INT_MAX, V|E|D, .unit = "color_range_type"}, -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 18/18] avcodec/arm/vp8: Don't discard const
Forgotten in 25e1986e6816fabf7f6065d090994f8ad050e540. Signed-off-by: Andreas Rheinhardt --- libavcodec/arm/vp8.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/arm/vp8.h b/libavcodec/arm/vp8.h index 7c59a7d63d..6f128ffebe 100644 --- a/libavcodec/arm/vp8.h +++ b/libavcodec/arm/vp8.h @@ -29,7 +29,8 @@ #define vp8_decode_block_coeffs_internal ff_decode_block_coeffs_armv6 int ff_decode_block_coeffs_armv6(VPXRangeCoder *rc, int16_t block[16], uint8_t probs[8][3][NUM_DCT_TOKENS-1], - int i, uint8_t *token_prob, int16_t qmul[2]); + int i, const uint8_t *token_prob, + const int16_t qmul[2]); #endif #endif /* AVCODEC_ARM_VP8_H */ -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 17/18] avutil/internal: Move avpriv_set_systematic_pal2 decl to imgutils_internal.h
Signed-off-by: Andreas Rheinhardt --- libavcodec/bmpenc.c | 2 +- libavcodec/gif.c | 1 + libavcodec/pcxenc.c | 2 +- libavcodec/xwdenc.c | 1 + libavfilter/framepool.c | 1 + libavfilter/vf_scale.c| 1 + libavformat/av1.c | 1 + libavutil/imgutils.c | 1 - libavutil/imgutils_internal.h | 4 libavutil/internal.h | 3 --- 10 files changed, 11 insertions(+), 6 deletions(-) diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c index 3e3ca324ea..48f25170ba 100644 --- a/libavcodec/bmpenc.c +++ b/libavcodec/bmpenc.c @@ -22,8 +22,8 @@ #include "config.h" -#include "libavutil/imgutils.h" #include "libavutil/avassert.h" +#include "libavutil/imgutils_internal.h" #include "avcodec.h" #include "bytestream.h" #include "bmp.h" diff --git a/libavcodec/gif.c b/libavcodec/gif.c index 56042d36a7..c36fa66737 100644 --- a/libavcodec/gif.c +++ b/libavcodec/gif.c @@ -30,6 +30,7 @@ * @see http://www.w3.org/Graphics/GIF/spec-gif89a.txt */ +#include "libavutil/imgutils_internal.h" #include "libavutil/mem.h" #include "libavutil/opt.h" #include "avcodec.h" diff --git a/libavcodec/pcxenc.c b/libavcodec/pcxenc.c index cf9b41b752..b763c7df47 100644 --- a/libavcodec/pcxenc.c +++ b/libavcodec/pcxenc.c @@ -26,9 +26,9 @@ * @see http://bespin.org/~qz/pc-gpe/pcx.txt */ +#include "libavutil/imgutils_internal.h" #include "avcodec.h" #include "bytestream.h" -#include "libavutil/imgutils.h" #include "codec_internal.h" #include "encode.h" diff --git a/libavcodec/xwdenc.c b/libavcodec/xwdenc.c index 08554d8632..40bee20109 100644 --- a/libavcodec/xwdenc.c +++ b/libavcodec/xwdenc.c @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/imgutils_internal.h" #include "libavutil/pixdesc.h" #include "avcodec.h" #include "bytestream.h" diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c index 841caa0460..e8621e07ac 100644 --- a/libavfilter/framepool.c +++ b/libavfilter/framepool.c @@ -24,6 +24,7 @@ #include "libavutil/buffer.h" #include "libavutil/frame.h" #include "libavutil/imgutils.h" +#include "libavutil/imgutils_internal.h" #include "libavutil/mem.h" #include "libavutil/pixfmt.h" diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 00fcb31b1c..fc0e3802db 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -33,6 +33,7 @@ #include "scale_eval.h" #include "video.h" #include "libavutil/eval.h" +#include "libavutil/imgutils_internal.h" #include "libavutil/internal.h" #include "libavutil/mem.h" #include "libavutil/opt.h" diff --git a/libavformat/av1.c b/libavformat/av1.c index cb86e66d09..35c23dd0b0 100644 --- a/libavformat/av1.c +++ b/libavformat/av1.c @@ -21,6 +21,7 @@ #include "libavutil/avassert.h" #include "libavutil/mem.h" +#include "libavutil/pixfmt.h" #include "libavcodec/av1.h" #include "libavcodec/av1_parse.h" #include "libavcodec/defs.h" diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c index 16e3133c33..d246381563 100644 --- a/libavutil/imgutils.c +++ b/libavutil/imgutils.c @@ -25,7 +25,6 @@ #include "common.h" #include "imgutils.h" #include "imgutils_internal.h" -#include "internal.h" #include "intreadwrite.h" #include "log.h" #include "mathematics.h" diff --git a/libavutil/imgutils_internal.h b/libavutil/imgutils_internal.h index d515858413..3e47731a50 100644 --- a/libavutil/imgutils_internal.h +++ b/libavutil/imgutils_internal.h @@ -22,6 +22,10 @@ #include #include +#include "pixfmt.h" + +int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt); + int ff_image_copy_plane_uc_from_x86(uint8_t *dst, ptrdiff_t dst_linesize, const uint8_t *src, ptrdiff_t src_linesize, ptrdiff_t bytewidth, int height); diff --git a/libavutil/internal.h b/libavutil/internal.h index fe0b9d7a24..ac1af367e9 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -42,7 +42,6 @@ #include "attributes.h" #include "libm.h" #include "macros.h" -#include "pixfmt.h" #ifndef attribute_align_arg #if ARCH_X86_32 && AV_GCC_VERSION_AT_LEAST(4,2) @@ -152,8 +151,6 @@ void avpriv_request_sample(void *avc, #define SUINT32 uint32_t #endif -int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt); - static av_always_inline av_const int avpriv_mirror(int x, int w) { if (!w) -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 16/18] avutil/hwcontext_vulkan: Include hwcontext.h
struct Foo * declares a new type (namely struct Foo) if there is no declaration of struct Foo already visible in the current scope; otherwise it is just a pointer to an element of the already declared type "struct Foo". There is a gotcha with the first case: struct Foo is only declared in its scope; a later declaration of struct Foo in an enclosing scope declares a different type. This happens in hwcontext_vulkan.h if it is included before hwcontext.h, because some declarations of struct AVHWDeviceContext and struct AVHWFramesContext have function prototype scope. Compilers warn about this (during checkheaders): ‘struct AVHWDeviceContext’ declared inside parameter list will not be visible outside of this definition or declaration Fix this by including hwcontext.h. Signed-off-by: Andreas Rheinhardt --- libavutil/hwcontext_vulkan.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libavutil/hwcontext_vulkan.h b/libavutil/hwcontext_vulkan.h index 895794c867..cbbd2390c1 100644 --- a/libavutil/hwcontext_vulkan.h +++ b/libavutil/hwcontext_vulkan.h @@ -26,6 +26,7 @@ #include "pixfmt.h" #include "frame.h" +#include "hwcontext.h" typedef struct AVVkFrame AVVkFrame; -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 15/18] avutil/internal: Move FF_MEMORY_POISON to its only user
Namely mem.c. Signed-off-by: Andreas Rheinhardt --- libavutil/internal.h | 2 -- libavutil/mem.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/internal.h b/libavutil/internal.h index 5772b8a612..fe0b9d7a24 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -75,8 +75,6 @@ #endif -#define FF_MEMORY_POISON 0x2a - #define FF_ALLOC_TYPED_ARRAY(p, nelem) (p = av_malloc_array(nelem, sizeof(*p))) #define FF_ALLOCZ_TYPED_ARRAY(p, nelem) (p = av_calloc(nelem, sizeof(*p))) diff --git a/libavutil/mem.c b/libavutil/mem.c index 02d4cb791f..b205d3fb25 100644 --- a/libavutil/mem.c +++ b/libavutil/mem.c @@ -64,6 +64,8 @@ void free(void *ptr); #define ALIGN (HAVE_SIMD_ALIGN_64 ? 64 : (HAVE_SIMD_ALIGN_32 ? 32 : 16)) +#define FF_MEMORY_POISON 0x2a + /* NOTE: if you want to override these functions with your own * implementations (not recommended) you have to link libav* as * dynamic libraries and remove -Wl,-Bsymbolic from the linker flags. -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 14/18] avutil/internal: Move libm inclusion to the beginning
Signed-off-by: Andreas Rheinhardt --- libavutil/internal.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavutil/internal.h b/libavutil/internal.h index e0b2c74b21..5772b8a612 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -40,6 +40,7 @@ #include #include "config.h" #include "attributes.h" +#include "libm.h" #include "macros.h" #include "pixfmt.h" @@ -86,8 +87,6 @@ */ #define FF_FIELD_AT(type, off, obj) (*(type *)((char *)&(obj) + (off))) -#include "libm.h" - /** * Return NULL if CONFIG_SMALL is true, otherwise the argument * without modification. Used to disable the definition of strings. -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 13/18] avcodec/arm/mpegvideo_arm: Use static_assert to check offsets
Also move AV_CHECK_OFFSET to its only user, namely lavc/arm/mpegvideo_arm.c and rename it to CHECK_OFFSET. Signed-off-by: Andreas Rheinhardt --- libavcodec/arm/mpegvideo_arm.c | 20 libavutil/internal.h | 8 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/libavcodec/arm/mpegvideo_arm.c b/libavcodec/arm/mpegvideo_arm.c index 008ef18eea..28a3f2cdd9 100644 --- a/libavcodec/arm/mpegvideo_arm.c +++ b/libavcodec/arm/mpegvideo_arm.c @@ -18,8 +18,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "libavutil/attributes.h" -#include "libavutil/internal.h" #include "libavutil/arm/cpu.h" #include "libavcodec/avcodec.h" #include "libavcodec/mpegvideo.h" @@ -27,13 +28,16 @@ #include "asm-offsets.h" #if HAVE_NEON -AV_CHECK_OFFSET(MpegEncContext, y_dc_scale, Y_DC_SCALE); -AV_CHECK_OFFSET(MpegEncContext, c_dc_scale, C_DC_SCALE); -AV_CHECK_OFFSET(MpegEncContext, ac_pred, AC_PRED); -AV_CHECK_OFFSET(MpegEncContext, block_last_index, BLOCK_LAST_INDEX); -AV_CHECK_OFFSET(MpegEncContext, inter_scantable.raster_end, -INTER_SCANTAB_RASTER_END); -AV_CHECK_OFFSET(MpegEncContext, h263_aic, H263_AIC); +#define CHECK_OFFSET(s, m, o) \ +static_assert(offsetof(s, m) == o, \ + "Hardcoded ASM offset of " #s " field " #o " needs to be updated."); +CHECK_OFFSET(MpegEncContext, y_dc_scale, Y_DC_SCALE); +CHECK_OFFSET(MpegEncContext, c_dc_scale, C_DC_SCALE); +CHECK_OFFSET(MpegEncContext, ac_pred, AC_PRED); +CHECK_OFFSET(MpegEncContext, block_last_index, BLOCK_LAST_INDEX); +CHECK_OFFSET(MpegEncContext, inter_scantable.raster_end, + INTER_SCANTAB_RASTER_END); +CHECK_OFFSET(MpegEncContext, h263_aic, H263_AIC); #endif void ff_dct_unquantize_h263_inter_neon(MpegEncContext *s, int16_t *block, diff --git a/libavutil/internal.h b/libavutil/internal.h index 461c0df9ad..e0b2c74b21 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -76,14 +76,6 @@ #define FF_MEMORY_POISON 0x2a -/* Check if the hard coded offset of a struct member still matches reality. - * Induce a compilation failure if not. - */ -#define AV_CHECK_OFFSET(s, m, o) struct check_##o {\ -int x_##o[offsetof(s, m) == o? 1: -1]; \ -} - - #define FF_ALLOC_TYPED_ARRAY(p, nelem) (p = av_malloc_array(nelem, sizeof(*p))) #define FF_ALLOCZ_TYPED_ARRAY(p, nelem) (p = av_calloc(nelem, sizeof(*p))) -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 11/18] lib*/version: Use static_assert for static asserts
Also update the checks that guard against inserting a new enum entry in the middle of a range. Signed-off-by: Andreas Rheinhardt --- libavcodec/version.c| 16 +++- libavdevice/version.c | 5 +++-- libavfilter/version.c | 5 +++-- libavformat/version.c | 5 +++-- libavutil/version.c | 12 +++- libpostproc/version.c | 5 +++-- libswresample/version.c | 5 +++-- libswscale/version.c| 5 +++-- 8 files changed, 36 insertions(+), 22 deletions(-) diff --git a/libavcodec/version.c b/libavcodec/version.c index d7966b2015..27f94323b8 100644 --- a/libavcodec/version.c +++ b/libavcodec/version.c @@ -18,9 +18,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "config.h" -#include "libavutil/avassert.h" #include "avcodec.h" #include "codec_id.h" #include "version.h" @@ -30,10 +31,15 @@ const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION; unsigned avcodec_version(void) { -av_assert0(AV_CODEC_ID_PCM_S8_PLANAR==65563); -av_assert0(AV_CODEC_ID_ADPCM_G722==69660); -av_assert0(AV_CODEC_ID_SRT==94216); -av_assert0(LIBAVCODEC_VERSION_MICRO >= 100); +static_assert(AV_CODEC_ID_LEAD == 269 && + AV_CODEC_ID_PCM_SGA == 65572 && + AV_CODEC_ID_ADPCM_XMD== 69683 && + AV_CODEC_ID_CBD2_DPCM== 81928 && + AV_CODEC_ID_QOA == 86121 && + AV_CODEC_ID_ARIB_CAPTION == 94233 && + AV_CODEC_ID_SMPTE_2038 == 98315, + "Don't insert new codec ids in the middle of a list"); +static_assert(LIBAVCODEC_VERSION_MICRO >= 100, "micro version starts at 100"); return LIBAVCODEC_VERSION_INT; } diff --git a/libavdevice/version.c b/libavdevice/version.c index 92d7f2d159..a058efe46e 100644 --- a/libavdevice/version.c +++ b/libavdevice/version.c @@ -18,9 +18,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "config.h" -#include "libavutil/avassert.h" #include "avdevice.h" #include "version.h" @@ -29,7 +30,7 @@ const char av_device_ffversion[] = "FFmpeg version " FFMPEG_VERSION; unsigned avdevice_version(void) { -av_assert0(LIBAVDEVICE_VERSION_MICRO >= 100); +static_assert(LIBAVDEVICE_VERSION_MICRO >= 100, "micro version starts at 100"); return LIBAVDEVICE_VERSION_INT; } diff --git a/libavfilter/version.c b/libavfilter/version.c index db1a2511e7..54c286460e 100644 --- a/libavfilter/version.c +++ b/libavfilter/version.c @@ -18,8 +18,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "config.h" -#include "libavutil/avassert.h" #include "avfilter.h" #include "version.h" @@ -28,7 +29,7 @@ const char av_filter_ffversion[] = "FFmpeg version " FFMPEG_VERSION; unsigned avfilter_version(void) { -av_assert0(LIBAVFILTER_VERSION_MICRO >= 100); +static_assert(LIBAVFILTER_VERSION_MICRO >= 100, "micro version starts at 100"); return LIBAVFILTER_VERSION_INT; } diff --git a/libavformat/version.c b/libavformat/version.c index 5f321d847e..c0781d3f47 100644 --- a/libavformat/version.c +++ b/libavformat/version.c @@ -18,9 +18,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "config.h" -#include "libavutil/avassert.h" #include "avformat.h" #include "version.h" @@ -29,7 +30,7 @@ const char av_format_ffversion[] = "FFmpeg version " FFMPEG_VERSION; unsigned avformat_version(void) { -av_assert0(LIBAVFORMAT_VERSION_MICRO >= 100); +static_assert(LIBAVFORMAT_VERSION_MICRO >= 100, "micro version starts at 100"); return LIBAVFORMAT_VERSION_INT; } diff --git a/libavutil/version.c b/libavutil/version.c index baead7c4a0..afab190336 100644 --- a/libavutil/version.c +++ b/libavutil/version.c @@ -18,8 +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 "samplefmt.h" #include "version.h" @@ -34,10 +35,11 @@ const char *av_version_info(void) unsigned avutil_version(void) { -av_assert0(AV_SAMPLE_FMT_DBLP == 9); -av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4); -av_assert0(AV_PICTURE_TYPE_BI == 7); -av_assert0(LIBAVUTIL_VERSION_MICRO >= 100); +static_assert(AV_SAMPLE_FMT_S64P == 11 && + AVMEDIA_TYPE_ATTACHMENT == 4 && + AV_PICTURE_TYPE_BI == 7, + "Don't insert new sample/media/picture types in the middle of the list"); +static_assert(LIBAVUTIL_VERSION_MICRO >= 100, "micro version starts at 100"); return LIBAVUTIL_VERSION_INT; } diff --git a/libpostproc/version.c b/libpostproc/version.c index 494575ae67..304abe08e6 100644 --- a/libpostproc/version.c +++ b/libpostproc/version.c @@ -18,8
[FFmpeg-devel] [PATCH 10/18] swscale/swscale_internal: Don't export internal function
sws_alloc_set_opts() can actually be made internal to utils.c. This commit does so. Signed-off-by: Andreas Rheinhardt --- libswscale/swscale_internal.h | 11 - libswscale/utils.c| 83 ++- 2 files changed, 43 insertions(+), 51 deletions(-) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index d7faa5e165..c2cc736dd2 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -1003,17 +1003,6 @@ void ff_hcscale_fast_mmxext(SwsContext *c, int16_t *dst1, int16_t *dst2, int dstWidth, const uint8_t *src1, const uint8_t *src2, int srcW, int xInc); -/** - * Allocate and return an SwsContext. - * This is like sws_getContext() but does not perform the init step, allowing - * the user to set additional AVOptions. - * - * @see sws_getContext() - */ -struct SwsContext *sws_alloc_set_opts(int srcW, int srcH, enum AVPixelFormat srcFormat, - int dstW, int dstH, enum AVPixelFormat dstFormat, - int flags, const double *param); - int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[]); diff --git a/libswscale/utils.c b/libswscale/utils.c index ab8a68e241..cb6e91db06 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -269,6 +269,34 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_XV36LE] = { 1, 1 }, }; +/** + * Allocate and return an SwsContext without performing initialization. + */ +static SwsContext *alloc_set_opts(int srcW, int srcH, enum AVPixelFormat srcFormat, + int dstW, int dstH, enum AVPixelFormat dstFormat, + int flags, const double *param) +{ +SwsContext *c = sws_alloc_context(); + +if (!c) +return NULL; + +c->flags = flags; +c->srcW = srcW; +c->srcH = srcH; +c->dstW = dstW; +c->dstH = dstH; +c->srcFormat = srcFormat; +c->dstFormat = dstFormat; + +if (param) { +c->param[0] = param[0]; +c->param[1] = param[1]; +} + +return c; +} + int ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos, int filterSize, int16_t *filter, int dstW) @@ -1101,9 +1129,9 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], if (ret < 0) return ret; -c->cascaded_context[0] = sws_alloc_set_opts(srcW, srcH, c->srcFormat, -tmp_width, tmp_height, tmp_format, -c->flags, c->param); +c->cascaded_context[0] = alloc_set_opts(srcW, srcH, c->srcFormat, +tmp_width, tmp_height, tmp_format, +c->flags, c->param); if (!c->cascaded_context[0]) return -1; @@ -1116,9 +1144,9 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], srcRange, table, dstRange, brightness, contrast, saturation); -c->cascaded_context[1] = sws_alloc_set_opts(tmp_width, tmp_height, tmp_format, -dstW, dstH, c->dstFormat, -c->flags, c->param); +c->cascaded_context[1] = alloc_set_opts(tmp_width, tmp_height, tmp_format, +dstW, dstH, c->dstFormat, +c->flags, c->param); if (!c->cascaded_context[1]) return -1; c->cascaded_context[1]->srcRange = srcRange; @@ -1682,9 +1710,9 @@ static av_cold int sws_init_single_context(SwsContext *c, SwsFilter *srcFilter, if (ret < 0) return ret; -c->cascaded_context[0] = sws_alloc_set_opts(srcW, srcH, srcFormat, -srcW, srcH, tmpFormat, -flags, c->param); +c->cascaded_context[0] = alloc_set_opts(srcW, srcH, srcFormat, +srcW, srcH, tmpFormat, +flags, c->param); if (!c->cascaded_context[0]) return AVERROR(EINVAL); c->cascaded_context[0]->alphablend = c->alphablend; @@ -1692,9 +1720,9 @@ static av_cold int sws_init_single_context(SwsContext *c,
[FFmpeg-devel] [PATCH 09/18] swscale/swscale_internal: Hoist branch out of loop
Signed-off-by: Andreas Rheinhardt --- I wonder whether one can use aligned writes here? libswscale/swscale_internal.h | 34 ++ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 2f6cc70946..d7faa5e165 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -1021,28 +1021,20 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[], static inline void fillPlane16(uint8_t *plane, int stride, int width, int height, int y, int alpha, int bits, const int big_endian) { -int i, j; uint8_t *ptr = plane + stride * y; int v = alpha ? 0x>>(16-bits) : (1<<(bits-1)); -for (i = 0; i < height; i++) { -#define FILL(wfunc) \ -for (j = 0; j < width; j++) {\ -wfunc(ptr+2*j, v);\ -} -if (big_endian) { -FILL(AV_WB16); -} else { -FILL(AV_WL16); -} +if (big_endian != HAVE_BIGENDIAN) +v = av_bswap16(v); +for (int i = 0; i < height; i++) { +for (int j = 0; j < width; j++) +AV_WN16(ptr + 2 * j, v); ptr += stride; } -#undef FILL } static inline void fillPlane32(uint8_t *plane, int stride, int width, int height, int y, int alpha, int bits, const int big_endian, int is_float) { -int i, j; uint8_t *ptr = plane + stride * y; uint32_t v; uint32_t onef32 = 0x3f80; @@ -1050,20 +1042,14 @@ static inline void fillPlane32(uint8_t *plane, int stride, int width, int height v = alpha ? onef32 : 0; else v = alpha ? 0x>>(32-bits) : (1<<(bits-1)); +if (big_endian != HAVE_BIGENDIAN) +v = av_bswap32(v); -for (i = 0; i < height; i++) { -#define FILL(wfunc) \ -for (j = 0; j < width; j++) {\ -wfunc(ptr+4*j, v);\ -} -if (big_endian) { -FILL(AV_WB32); -} else { -FILL(AV_WL32); -} +for (int i = 0; i < height; i++) { +for (int j = 0; j < width; j++) +AV_WN32(ptr + 4 * j, v); ptr += stride; } -#undef FILL } -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 08/18] avcodec/msmpeg4: Don't include x86-specific header unconditionally
Signed-off-by: Andreas Rheinhardt --- libavcodec/msmpeg4.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c index a2c4c57728..e327bf36a7 100644 --- a/libavcodec/msmpeg4.c +++ b/libavcodec/msmpeg4.c @@ -27,13 +27,17 @@ * MSMPEG4 backend for encoder and decoder */ +#include "config.h" + #include "libavutil/thread.h" +#if ARCH_X86 +#include "libavutil/x86/asm.h" +#endif #include "avcodec.h" #include "idctdsp.h" #include "mpegvideo.h" #include "msmpeg4.h" -#include "libavutil/x86/asm.h" #include "mpeg4videodata.h" #include "msmpeg4data.h" #include "msmpeg4_vc1_data.h" -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 07/18] swscale/swscale_internal: Only include altivec header iff HAVE_ALTIVEC
Signed-off-by: Andreas Rheinhardt --- libswscale/swscale_internal.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index abeebbb002..2f6cc70946 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -34,7 +34,9 @@ #include "libavutil/pixfmt.h" #include "libavutil/pixdesc.h" #include "libavutil/slicethread.h" +#if HAVE_ALTIVEC #include "libavutil/ppc/util_altivec.h" +#endif #include "libavutil/half2float.h" #define STR(s) AV_TOSTRING(s) // AV_STRINGIFY is too long -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 06/18] postproc/postprocess: Don't generally include arch-specific headers
Signed-off-by: Andreas Rheinhardt --- libpostproc/postprocess.c | 3 ++- libpostproc/postprocess_template.c | 5 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c index 0586e458b4..8f4de8b1e1 100644 --- a/libpostproc/postprocess.c +++ b/libpostproc/postprocess.c @@ -88,7 +88,6 @@ try to unroll inner for(x=0 ... loop to avoid these damn if(x ... checks #include "postprocess.h" #include "postprocess_internal.h" #include "libavutil/avstring.h" -#include "libavutil/ppc/util_altivec.h" #define GET_MODE_BUFFER_SIZE 500 #define OPTIONS_ARRAY_SIZE 10 @@ -499,6 +498,8 @@ static av_always_inline void do_a_deblock_C(uint8_t *src, int step, #include "postprocess_template.c" #if HAVE_ALTIVEC +#include "libavutil/ppc/util_altivec.h" + # define TEMPLATE_PP_ALTIVEC 1 # include "postprocess_altivec_template.c" # include "postprocess_template.c" diff --git a/libpostproc/postprocess_template.c b/libpostproc/postprocess_template.c index ade1d6ce2b..d56b45d3b4 100644 --- a/libpostproc/postprocess_template.c +++ b/libpostproc/postprocess_template.c @@ -22,9 +22,12 @@ * @file * mmx/mmx2/sse2 postprocess code. */ +#include "config.h" #include "libavutil/mem_internal.h" +#if ARCH_X86 #include "libavutil/x86/asm.h" +#endif /* A single TEMPLATE_PP_* should be defined (to 1) when this template is * included. The following macros will define its dependencies to 1 as well @@ -830,7 +833,7 @@ static inline void RENAME(doVertDefFilter)(uint8_t src[], int stride, PPContext #if !TEMPLATE_PP_ALTIVEC static inline void RENAME(dering)(uint8_t src[], int stride, PPContext *c) { -#if HAVE_7REGS && TEMPLATE_PP_MMXEXT +#if TEMPLATE_PP_MMXEXT && HAVE_7REGS DECLARE_ALIGNED(8, uint64_t, tmp)[3]; __asm__ volatile( "pxor %%mm6, %%mm6 \n\t" -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 05/18] avcodec, avfilter: Don't use "" for system headers
Signed-off-by: Andreas Rheinhardt --- libavcodec/qsv.c | 3 +-- libavfilter/avf_aphasemeter.c | 3 ++- libavfilter/f_drawgraph.c | 2 -- libavfilter/f_graphmonitor.c | 2 -- libavfilter/vf_lut3d.c| 4 ++-- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 7563625627..01ce186dae 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -39,8 +40,6 @@ #define QSV_HAVE_USER_PLUGIN!QSV_ONEVPL #define QSV_HAVE_AUDIO !QSV_ONEVPL -#include "mfxvp8.h" - #if QSV_HAVE_USER_PLUGIN #include #endif diff --git a/libavfilter/avf_aphasemeter.c b/libavfilter/avf_aphasemeter.c index fac8d7c048..6632bae3ec 100644 --- a/libavfilter/avf_aphasemeter.c +++ b/libavfilter/avf_aphasemeter.c @@ -23,6 +23,8 @@ * audio to video multimedia aphasemeter filter */ +#include + #include "libavutil/channel_layout.h" #include "libavutil/intreadwrite.h" #include "libavutil/opt.h" @@ -34,7 +36,6 @@ #include "audio.h" #include "video.h" #include "internal.h" -#include "float.h" typedef struct AudioPhaseMeterContext { const AVClass *class; diff --git a/libavfilter/f_drawgraph.c b/libavfilter/f_drawgraph.c index fd8641ff75..1eca7df975 100644 --- a/libavfilter/f_drawgraph.c +++ b/libavfilter/f_drawgraph.c @@ -20,8 +20,6 @@ #include "config_components.h" -#include "float.h" - #include "libavutil/avstring.h" #include "libavutil/eval.h" #include "libavutil/intreadwrite.h" diff --git a/libavfilter/f_graphmonitor.c b/libavfilter/f_graphmonitor.c index e0b20114e0..3fefa49138 100644 --- a/libavfilter/f_graphmonitor.c +++ b/libavfilter/f_graphmonitor.c @@ -20,8 +20,6 @@ #include "config_components.h" -#include "float.h" - #include "libavutil/pixdesc.h" #include "libavutil/eval.h" #include "libavutil/intreadwrite.h" diff --git a/libavfilter/vf_lut3d.c b/libavfilter/vf_lut3d.c index a312ca76c9..ba2d425198 100644 --- a/libavfilter/vf_lut3d.c +++ b/libavfilter/vf_lut3d.c @@ -24,9 +24,9 @@ * 3D Lookup table filter */ -#include "config_components.h" +#include -#include "float.h" +#include "config_components.h" #include "libavutil/opt.h" #include "libavutil/file_open.h" -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 04/18] swscale/ppc/swscale_altivec: Simplify macro
Signed-off-by: Andreas Rheinhardt --- libswscale/ppc/swscale_altivec.c | 14 -- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/libswscale/ppc/swscale_altivec.c b/libswscale/ppc/swscale_altivec.c index 8e35e0372f..9bf72738df 100644 --- a/libswscale/ppc/swscale_altivec.c +++ b/libswscale/ppc/swscale_altivec.c @@ -109,17 +109,12 @@ #define SHIFT 3 -#define output_pixel(pos, val, bias, signedness) \ -if (big_endian) { \ -AV_WB16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \ -} else { \ -AV_WL16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \ -} +#define get_pixel(val, bias, signedness) \ +(bias + av_clip_ ## signedness ## 16(val >> shift)) static void yuv2plane1_float_u(const int32_t *src, float *dest, int dstW, int start) { -static const int big_endian = HAVE_BIGENDIAN; static const int shift = 3; static const float float_mult = 1.0f / 65535.0f; int i, val; @@ -127,7 +122,7 @@ yuv2plane1_float_u(const int32_t *src, float *dest, int dstW, int start) for (i = start; i < dstW; ++i){ val = src[i] + (1 << (shift - 1)); -output_pixel(_uint, val, 0, uint); +val_uint = get_pixel(val, 0, uint); dest[i] = float_mult * (float)val_uint; } } @@ -135,7 +130,6 @@ yuv2plane1_float_u(const int32_t *src, float *dest, int dstW, int start) static void yuv2plane1_float_bswap_u(const int32_t *src, uint32_t *dest, int dstW, int start) { -static const int big_endian = HAVE_BIGENDIAN; static const int shift = 3; static const float float_mult = 1.0f / 65535.0f; int i, val; @@ -143,7 +137,7 @@ yuv2plane1_float_bswap_u(const int32_t *src, uint32_t *dest, int dstW, int start for (i = start; i < dstW; ++i){ val = src[i] + (1 << (shift - 1)); -output_pixel(_uint, val, 0, uint); +val_uint = get_pixel(val, 0, uint); dest[i] = av_bswap32(av_float2int(float_mult * (float)val_uint)); } } -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 03/18] swscale/ppc/swscale_altivec: Fix build with -O0
In this case GCC does not treat a const variable initialized to the compile-time constant "3" as a compile-time constant and errors out because the argument is not a literal value. Signed-off-by: Andreas Rheinhardt --- A similar issue exists in libswscale/ppc/swscale_vsx.c, but fixing this would be more involved (making templates out of always-inline functions...). libswscale/ppc/swscale_altivec.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libswscale/ppc/swscale_altivec.c b/libswscale/ppc/swscale_altivec.c index 1630355f51..8e35e0372f 100644 --- a/libswscale/ppc/swscale_altivec.c +++ b/libswscale/ppc/swscale_altivec.c @@ -107,6 +107,8 @@ #endif /* HAVE_BIGENDIAN */ +#define SHIFT 3 + #define output_pixel(pos, val, bias, signedness) \ if (big_endian) { \ AV_WB16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \ @@ -149,12 +151,11 @@ yuv2plane1_float_bswap_u(const int32_t *src, uint32_t *dest, int dstW, int start static void yuv2plane1_float_altivec(const int32_t *src, float *dest, int dstW) { const int dst_u = -(uintptr_t)dest & 3; -const int shift = 3; -const int add = (1 << (shift - 1)); +const int add = (1 << (SHIFT - 1)); const int clip = (1 << 16) - 1; const float fmult = 1.0f / 65535.0f; const vec_u32 vadd = (vec_u32) {add, add, add, add}; -const vec_u32 vshift = (vec_u32) vec_splat_u32(shift); +const vec_u32 vshift = (vec_u32) vec_splat_u32(SHIFT); const vec_u32 vlargest = (vec_u32) {clip, clip, clip, clip}; const vec_f vmul = (vec_f) {fmult, fmult, fmult, fmult}; const vec_f vzero = (vec_f) {0, 0, 0, 0}; @@ -182,12 +183,11 @@ static void yuv2plane1_float_altivec(const int32_t *src, float *dest, int dstW) static void yuv2plane1_float_bswap_altivec(const int32_t *src, uint32_t *dest, int dstW) { const int dst_u = -(uintptr_t)dest & 3; -const int shift = 3; -const int add = (1 << (shift - 1)); +const int add = (1 << (SHIFT - 1)); const int clip = (1 << 16) - 1; const float fmult = 1.0f / 65535.0f; const vec_u32 vadd = (vec_u32) {add, add, add, add}; -const vec_u32 vshift = (vec_u32) vec_splat_u32(shift); +const vec_u32 vshift = (vec_u32) vec_splat_u32(SHIFT); const vec_u32 vlargest = (vec_u32) {clip, clip, clip, clip}; const vec_f vmul = (vec_f) {fmult, fmult, fmult, fmult}; const vec_f vzero = (vec_f) {0, 0, 0, 0}; -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 02/18] avcodec/pcm-bluray/dvd: Use correct pointer types on BE
Signed-off-by: Andreas Rheinhardt --- libavcodec/pcm-bluray.c | 5 +++-- libavcodec/pcm-dvd.c| 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/pcm-bluray.c b/libavcodec/pcm-bluray.c index f65609514a..235020d78f 100644 --- a/libavcodec/pcm-bluray.c +++ b/libavcodec/pcm-bluray.c @@ -167,7 +167,7 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, AVFrame *frame, samples *= num_source_channels; if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) { #if HAVE_BIGENDIAN -bytestream2_get_buffer(, dst16, buf_size); +bytestream2_get_buffer(, (uint8_t*)dst16, buf_size); #else do { *dst16++ = bytestream2_get_be16u(); @@ -187,7 +187,8 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, AVFrame *frame, if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) { do { #if HAVE_BIGENDIAN -bytestream2_get_buffer(, dst16, avctx->ch_layout.nb_channels * 2); +bytestream2_get_buffer(, (uint8_t*)dst16, + avctx->ch_layout.nb_channels * 2); dst16 += avctx->ch_layout.nb_channels; #else channel = avctx->ch_layout.nb_channels; diff --git a/libavcodec/pcm-dvd.c b/libavcodec/pcm-dvd.c index 419b2a138f..319746c62e 100644 --- a/libavcodec/pcm-dvd.c +++ b/libavcodec/pcm-dvd.c @@ -157,7 +157,7 @@ static void *pcm_dvd_decode_samples(AVCodecContext *avctx, const uint8_t *src, switch (avctx->bits_per_coded_sample) { case 16: { #if HAVE_BIGENDIAN -bytestream2_get_buffer(, dst16, blocks * s->block_size); +bytestream2_get_buffer(, (uint8_t*)dst16, blocks * s->block_size); dst16 += blocks * s->block_size / 2; #else int samples = blocks * avctx->ch_layout.nb_channels; -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/3] lavf/subtitles: Unfix ticket #5032
Obviously the most controversial patch in this set. I'd like to know what program exactly that produced the broken file in ticket #5032 so that we can send the guilty party to parsing jail More seriously, eating any run of CR CR CR... is incredibly broken and is part of the reason for the convoluted parsing logic in srtdec before this patchset. A compromise solution could be to peek two bytes forward and see if the line ending is CR CR LF. My guess is the file was produced by running unix2dos on a file with CR LF, thus converting the LF to CR LF. webvttdec is better with this, probably because these kinds of line ending is explicitly banned by the WebVTT spec. That is, CR CR LF is to be treated as two line endings, no ifs or buts about it. /Tomas From 784672af12da1d5fefeefad83cffa4b31f8b50fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Thu, 28 Mar 2024 23:30:06 +0100 Subject: [PATCH 3/3] lavf/subtitles: Unfix ticket #5032 This ticket should have been marked as wontfix so as to not encourage completely broken muxers. --- libavformat/subtitles.c | 10 ++ tests/fate/subtitles.mak | 3 --- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/libavformat/subtitles.c b/libavformat/subtitles.c index bda549abd0..11fa89f5eb 100644 --- a/libavformat/subtitles.c +++ b/libavformat/subtitles.c @@ -459,13 +459,7 @@ ptrdiff_t ff_subtitles_read_line(FFTextReader *tr, char *buf, size_t size) buf[cur++] = c; buf[cur] = '\0'; } -// don't eat \n\n -if (c == '\r') { -// sub/ticket5032-rrn.srt has \r\r\n -while (ff_text_peek_r8(tr) == '\r') -ff_text_r8(tr); -if (ff_text_peek_r8(tr) == '\n') -ff_text_r8(tr); -} +if (c == '\r' && ff_text_peek_r8(tr) == '\n') +ff_text_r8(tr); return cur; } diff --git a/tests/fate/subtitles.mak b/tests/fate/subtitles.mak index 90412e9ac1..940cd9a9ec 100644 --- a/tests/fate/subtitles.mak +++ b/tests/fate/subtitles.mak @@ -73,9 +73,6 @@ fate-sub-srt: CMD = fmtstdout ass -i $(TARGET_SAMPLES)/sub/SubRip_capability_tes FATE_SUBTITLES_ASS-$(call DEMDEC, SRT, SUBRIP) += fate-sub-srt-badsyntax fate-sub-srt-badsyntax: CMD = fmtstdout ass -i $(TARGET_SAMPLES)/sub/badsyntax.srt -FATE_SUBTITLES-$(call ALLYES, SRT_DEMUXER SUBRIP_DECODER SRT_MUXER) += fate-sub-srt-rrn-remux -fate-sub-srt-rrn-remux: CMD = fmtstdout srt -i $(TARGET_SAMPLES)/sub/ticket5032-rrn.srt -c:s copy - FATE_SUBTITLES-$(call ALLYES, SRT_DEMUXER SUBRIP_DECODER SRT_MUXER) += fate-sub-srt-madness-timeshift fate-sub-srt-madness-timeshift: CMD = fmtstdout srt -itsoffset 3.14 -i $(TARGET_SAMPLES)/sub/madness.srt -c:s copy -- 2.39.2 ___ 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 2/3] lavf/srtdec: Permit streaming input
Here as well From 6d0684ca6fe02d80fc07a622fb85445a6917c29f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Thu, 28 Mar 2024 22:15:18 +0100 Subject: [PATCH 2/3] lavf/srtdec: Permit streaming input This is largely a rewrite. Read packets in srt_read_packet() rather than reading the entire file in srt_read_header(). Rely on AVFMT_GENERIC_INDEX for seeking. Allow zero-length packets (same as WebVTT). The implementation before this is broken in at least the following ways: Decimals like .99 are silently accepted and converted to 999.999 seconds. This is because no verification is done on the milliseconds part. This patch enforces that the minutes and seconds parts are 00-59, and the milliseconds 000-999. It's not perfect since FFmpeg doesn't have regex functionality or indeed any kind of parsing framework, but it's better than before. Segmenting cues by lines that consist of just a single integer is incredibly wrong, since the subtitle text itself may well contain lines that are just a lone integer. This means files written with CR line endings that have text with lone integers are parsed in a completely broken manner. Neither can we segment by lines containing --> since this is permissible in SubRip (as far as I can tell). WebVTT explicitly forbids it however. --- libavformat/srtdec.c | 211 --- tests/ref/fate/sub-srt-rrn-remux | 4 + 2 files changed, 116 insertions(+), 99 deletions(-) diff --git a/libavformat/srtdec.c b/libavformat/srtdec.c index 6bf73599a7..c74d40b726 100644 --- a/libavformat/srtdec.c +++ b/libavformat/srtdec.c @@ -28,7 +28,8 @@ #include "libavutil/intreadwrite.h" typedef struct { -FFDemuxSubtitlesQueue q; +AVBPrint buf; +FFTextReader tr; } SRTContext; static int srt_probe(const AVProbeData *p) @@ -72,54 +73,66 @@ struct event_info { static int get_event_info(const char *line, struct event_info *ei) { -int hh1, mm1, ss1, ms1; -int hh2, mm2, ss2, ms2; - -ei->x1 = ei->x2 = ei->y1 = ei->y2 = ei->duration = -1; -ei->pts = AV_NOPTS_VALUE; -ei->pos = -1; -if (sscanf(line, "%d:%d:%d%*1[,.]%d --> %d:%d:%d%*1[,.]%d" +unsigned int hh1, mm1, ss1, ms1; +unsigned int hh2, mm2, ss2, ms2; +int n, m = 0; + +// require exactly two digits for mm and ss, three digits for ms +n = sscanf(line, "%*u:%*1u%*1u:%*1u%*1u%*1[,.]%*1u%*1u%*1u --> %*u:%*1u%*1u:%*1u%*1u%*1[,.]%*1u%*1u%*1u%n", ); +if (n < 0 || m <= 0) +return -1; +n = sscanf(line, "%u:%u:%u%*1[,.]%u --> %u:%u:%u%*1[,.]%u" "%*[ ]X1:%"PRId32" X2:%"PRId32" Y1:%"PRId32" Y2:%"PRId32, , , , , , , , , - >x1, >x2, >y1, >y2) >= 8) { + >x1, >x2, >y1, >y2); +// do not accept partial positions (9 <= n <= 11) +if ((n == 8 || n == 12) && +// require timestamps to be well-formed +mm1 < 60 && ss1 < 60 && ms1 < 1000 && +mm2 < 60 && ss2 < 60 && ms2 < 1000) { +// hh is converted to long long before the multiplication +// hence this cannot overflow even if hh == UINT_MAX const int64_t start = (hh1*3600LL + mm1*60LL + ss1) * 1000LL + ms1; const int64_t end = (hh2*3600LL + mm2*60LL + ss2) * 1000LL + ms2; -ei->duration = end - start; -ei->pts = start; -return 0; +// accept start == end (hidden subtitles) since a FATE test requires it +// WebVTT by contrast does not allow this +if (start <= end) { +ei->duration = end - start; +ei->pts = start; +return 0; +} } return -1; } -static int add_event(FFDemuxSubtitlesQueue *q, AVBPrint *buf, char *line_cache, - const struct event_info *ei, int append_cache) +static int output_packet(AVBPrint *buf, + const struct event_info *ei, AVPacket *pkt) { -if (append_cache && line_cache[0]) -av_bprintf(buf, "%s\n", line_cache); -line_cache[0] = 0; +int ret; if (!av_bprint_is_complete(buf)) return AVERROR(ENOMEM); +// len < size throughout this loop, so we don't need to +// call av_bprint_is_complete() twice like the old code did while (buf->len > 0 && buf->str[buf->len - 1] == '\n') buf->str[--buf->len] = 0; -if (buf->len) { -AVPacket *sub = ff_subtitles_queue_insert_bprint(q, buf, 0); -if (!sub) -return AVERROR(ENOMEM); -av_bprint_clear(buf); -sub->pos = ei->pos; -sub->pts = ei->pts; -sub->duration = ei->duration; -if (ei->x1 != -1) { -uint8_t *p = av_packet_new_side_data(sub, AV_PKT_DATA_SUBTITLE_POSITION, 16); -if (p) { -AV_WL32(p, ei->x1); -AV_WL32(p + 4, ei->y1); -AV_WL32(p + 8, ei->x2); -AV_WL32(p + 12, ei->y2); -} +ret = av_new_packet(pkt, buf->len);
Re: [FFmpeg-devel] [PATCH 1/3] lavf/subtitles: Do not eat \n\n
Oops, forgot to actually attach the patch From fccc13f728c50a676d20f3ca5b822fa1da60b259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Thu, 28 Mar 2024 20:30:37 +0100 Subject: [PATCH 1/3] lavf/subtitles: Do not eat \n\n --- libavformat/subtitles.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libavformat/subtitles.c b/libavformat/subtitles.c index 3413763c7b..bda549abd0 100644 --- a/libavformat/subtitles.c +++ b/libavformat/subtitles.c @@ -446,11 +446,12 @@ int ff_subtitles_read_chunk(AVIOContext *pb, AVBPrint *buf) ptrdiff_t ff_subtitles_read_line(FFTextReader *tr, char *buf, size_t size) { size_t cur = 0; +unsigned char c; if (!size) return 0; buf[0] = '\0'; while (cur + 1 < size) { -unsigned char c = ff_text_r8(tr); +c = ff_text_r8(tr); if (!c) return ff_text_eof(tr) ? cur : AVERROR_INVALIDDATA; if (c == '\r' || c == '\n') @@ -458,9 +459,13 @@ ptrdiff_t ff_subtitles_read_line(FFTextReader *tr, char *buf, size_t size) buf[cur++] = c; buf[cur] = '\0'; } -while (ff_text_peek_r8(tr) == '\r') -ff_text_r8(tr); -if (ff_text_peek_r8(tr) == '\n') -ff_text_r8(tr); +// don't eat \n\n +if (c == '\r') { +// sub/ticket5032-rrn.srt has \r\r\n +while (ff_text_peek_r8(tr) == '\r') +ff_text_r8(tr); +if (ff_text_peek_r8(tr) == '\n') +ff_text_r8(tr); +} return cur; } -- 2.39.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/3] lavf/srtdec: Permit streaming input
I am once again asking more people on this list to peruse https://langsec.org/ /Tomas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/3] lavf/subtitles: Do not eat \n\n
___ 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] libavformat/hls.c: support in-stream ID3 metadata update.
On Mon, Mar 25, 2024, 19:58 Romain Beauxis wrote: > This patch adds support for updating HLS metadata passed as ID3 frames. > > This seems like a pretty straight-forward improvement. Updating the > metadaata of the first stream seems to be the mechanism is other places > in the code and works as expected. > Hello! Any interest in reviewing this? --- > libavformat/hls.c | 54 --- > 1 file changed, 32 insertions(+), 22 deletions(-) > > diff --git a/libavformat/hls.c b/libavformat/hls.c > index f6b44c2e35..ba6634d57a 100644 > --- a/libavformat/hls.c > +++ b/libavformat/hls.c > @@ -93,6 +93,12 @@ enum PlaylistType { > PLS_TYPE_VOD > }; > > +#define ID3_PRIV_OWNER_TS "com.apple.streaming.transportStreamTimestamp" > +#define ID3_PRIV_OWNER_AUDIO_SETUP "com.apple.streaming.audioDescription" > + > +#define ID3v2_PRIV_OWNER_TS ID3v2_PRIV_METADATA_PREFIX ID3_PRIV_OWNER_TS > +#define ID3v2_PRIV_OWNER_AUDIO_SETUP ID3v2_PRIV_METADATA_PREFIX > ID3_PRIV_OWNER_AUDIO_SETUP > + > /* > * Each playlist has its own demuxer. If it currently is active, > * it has an open AVIOContext too, and potentially an AVPacket > @@ -150,9 +156,7 @@ struct playlist { > int64_t id3_offset; /* in stream original tb */ > uint8_t* id3_buf; /* temp buffer for id3 parsing */ > unsigned int id3_buf_size; > -AVDictionary *id3_initial; /* data from first id3 tag */ > -int id3_found; /* ID3 tag found at some point */ > -int id3_changed; /* ID3 tag data has changed at some point */ > +AVDictionary *last_id3; /* data from the last id3 tag */ > ID3v2ExtraMeta *id3_deferred_extra; /* stored here until subdemuxer > is opened */ > > HLSAudioSetupInfo audio_setup_info; > @@ -270,7 +274,7 @@ static void free_playlist_list(HLSContext *c) > av_freep(>main_streams); > av_freep(>renditions); > av_freep(>id3_buf); > -av_dict_free(>id3_initial); > +av_dict_free(>last_id3); > ff_id3v2_free_extra_meta(>id3_deferred_extra); > av_freep(>init_sec_buf); > av_packet_free(>pkt); > @@ -1083,15 +1087,13 @@ static void parse_id3(AVFormatContext *s, > AVIOContext *pb, >AVDictionary **metadata, int64_t *dts, > HLSAudioSetupInfo *audio_setup_info, >ID3v2ExtraMetaAPIC **apic, ID3v2ExtraMeta > **extra_meta) > { > -static const char id3_priv_owner_ts[] = > "com.apple.streaming.transportStreamTimestamp"; > -static const char id3_priv_owner_audio_setup[] = > "com.apple.streaming.audioDescription"; > ID3v2ExtraMeta *meta; > > ff_id3v2_read_dict(pb, metadata, ID3v2_DEFAULT_MAGIC, extra_meta); > for (meta = *extra_meta; meta; meta = meta->next) { > if (!strcmp(meta->tag, "PRIV")) { > ID3v2ExtraMetaPRIV *priv = >data.priv; > -if (priv->datasize == 8 && !av_strncasecmp(priv->owner, > id3_priv_owner_ts, 44)) { > +if (priv->datasize == 8 && !av_strncasecmp(priv->owner, > ID3_PRIV_OWNER_TS, strlen(ID3_PRIV_OWNER_TS))) { > /* 33-bit MPEG timestamp */ > int64_t ts = AV_RB64(priv->data); > av_log(s, AV_LOG_DEBUG, "HLS ID3 audio timestamp > %"PRId64"\n", ts); > @@ -1099,7 +1101,9 @@ static void parse_id3(AVFormatContext *s, > AVIOContext *pb, > *dts = ts; > else > av_log(s, AV_LOG_ERROR, "Invalid HLS ID3 audio > timestamp %"PRId64"\n", ts); > -} else if (priv->datasize >= 8 && > !av_strncasecmp(priv->owner, id3_priv_owner_audio_setup, 36)) { > +} else if (priv->datasize >= 8 && > + !av_strncasecmp(priv->owner, > ID3_PRIV_OWNER_AUDIO_SETUP, 36) && > + audio_setup_info) { > ff_hls_senc_read_audio_setup_info(audio_setup_info, > priv->data, priv->datasize); > } > } else if (!strcmp(meta->tag, "APIC") && apic) > @@ -1113,9 +1117,10 @@ static int id3_has_changed_values(struct playlist > *pls, AVDictionary *metadata, > { > const AVDictionaryEntry *entry = NULL; > const AVDictionaryEntry *oldentry; > + > /* check that no keys have changed values */ > while ((entry = av_dict_iterate(metadata, entry))) { > -oldentry = av_dict_get(pls->id3_initial, entry->key, NULL, > AV_DICT_MATCH_CASE); > +oldentry = av_dict_get(pls->last_id3, entry->key, NULL, > AV_DICT_MATCH_CASE); > if (!oldentry || strcmp(oldentry->value, entry->value) != 0) > return 1; > } > @@ -1143,35 +1148,40 @@ static void handle_id3(AVIOContext *pb, struct > playlist *pls) > ID3v2ExtraMetaAPIC *apic = NULL; > ID3v2ExtraMeta *extra_meta = NULL; > int64_t timestamp = AV_NOPTS_VALUE; > +// Only set audio_setup_info on first id3 chunk. > +HLSAudioSetupInfo *audio_setup_info = pls->last_id3 ? NULL : > >audio_setup_info; > > -parse_id3(pls->ctx, pb, , , >
[FFmpeg-devel] [PATCH 01/18] avcodec/mips/ac3dsp_mips: Add missing includes
Likely broken in d7a75d21635eab4f4a1efea22945933059c2e36f. Signed-off-by: Andreas Rheinhardt --- libavcodec/mips/ac3dsp_mips.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/mips/ac3dsp_mips.c b/libavcodec/mips/ac3dsp_mips.c index e97a412922..cc49ba3888 100644 --- a/libavcodec/mips/ac3dsp_mips.c +++ b/libavcodec/mips/ac3dsp_mips.c @@ -54,11 +54,13 @@ */ #include +#include #include "config.h" #include "libavcodec/ac3dsp.h" #include "libavcodec/ac3.h" #include "libavcodec/ac3tab.h" +#include "libavutil/macros.h" #include "libavutil/mips/asmdefs.h" #if HAVE_INLINE_ASM -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/4] avformat/lc3: Add file format for LC3/LC3plus transport
On Thu, Mar 28, 2024 at 5:40 PM Antoine Soulier wrote: > I don't think it's "easy" seekable. > We cannot move to an arbitrary position: > - There is no start-code > Not relevant. > - The frame size can be variable (not generated by the proposed encoder > implementation, but allowed). > Not relevant. > > The only possibility I see is checking that the frame size looks valid for > multiple frames. > Not relevant, the only needed feature is known stored number of samples in each packet for proper pts/timestamp generation. The range of valid frame sizes is large (20 to 625 Bytes), so I can only > validate 6 bits for each 16 bits packet size read. > > This format is not really designed to be seekable. > Do you think we will need it? > I cant force you do to correct implementation. Seeking is possible, just you are not aware of actual solution. Hint: see other demuxers. > > > On Thu, Mar 28, 2024 at 2:33 AM Paul B Mahol wrote: > >> This format actually supports seeking. >> >> The proposed solution here is sub-optimal. >> >> On Wed, Mar 27, 2024 at 11:22 PM Antoine Soulier via ffmpeg-devel < >> ffmpeg-devel@ffmpeg.org> wrote: >> >>> A file format is described in Bluetooth SIG LC3 and ETSI TS 103 634, for >>> test purpose. This is the format implemented here. >>> >>> Signed-off-by: Antoine Soulier >>> --- >>> doc/muxers.texi | 6 ++ >>> libavformat/Makefile | 2 + >>> libavformat/allformats.c | 2 + >>> libavformat/lc3dec.c | 135 +++ >>> libavformat/lc3enc.c | 102 + >>> 5 files changed, 247 insertions(+) >>> create mode 100644 libavformat/lc3dec.c >>> create mode 100644 libavformat/lc3enc.c >>> >>> diff --git a/doc/muxers.texi b/doc/muxers.texi >>> index a10a8e216f..9687746c30 100644 >>> --- a/doc/muxers.texi >>> +++ b/doc/muxers.texi >>> @@ -2612,6 +2612,12 @@ WebDAV server every second: >>> ffmpeg -f x11grab -framerate 1 -i :0.0 -q:v 6 -update 1 -protocol_opts >>> method=PUT http://example.com/desktop.jpg >>> @end example >>> >>> +@section lc3 >>> +Bluetooth SIG Low Complexity Communication Codec audio (LC3), or >>> +ETSI TS 103 634 Low Complexity Communication Codec plus (LC3plus). >>> + >>> +This muxer accepts a single @code{lc3} audio stream. >>> + >>> @section matroska >>> >>> Matroska container muxer. >>> diff --git a/libavformat/Makefile b/libavformat/Makefile >>> index 44aa485029..4961c42852 100644 >>> --- a/libavformat/Makefile >>> +++ b/libavformat/Makefile >>> @@ -332,6 +332,8 @@ OBJS-$(CONFIG_KVAG_DEMUXER) += kvag.o >>> OBJS-$(CONFIG_KVAG_MUXER)+= kvag.o rawenc.o >>> OBJS-$(CONFIG_LAF_DEMUXER) += lafdec.o >>> OBJS-$(CONFIG_LATM_MUXER)+= latmenc.o rawenc.o >>> +OBJS-$(CONFIG_LC3_DEMUXER) += lc3dec.o >>> +OBJS-$(CONFIG_LC3_MUXER) += lc3enc.o >>> OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o >>> OBJS-$(CONFIG_LOAS_DEMUXER) += loasdec.o rawdec.o >>> OBJS-$(CONFIG_LUODAT_DEMUXER)+= luodatdec.o >>> diff --git a/libavformat/allformats.c b/libavformat/allformats.c >>> index e15d0fa6d7..e225354faf 100644 >>> --- a/libavformat/allformats.c >>> +++ b/libavformat/allformats.c >>> @@ -252,6 +252,8 @@ extern const FFInputFormat ff_kvag_demuxer; >>> extern const FFOutputFormat ff_kvag_muxer; >>> extern const FFInputFormat ff_laf_demuxer; >>> extern const FFOutputFormat ff_latm_muxer; >>> +extern const FFInputFormat ff_lc3_demuxer; >>> +extern const FFOutputFormat ff_lc3_muxer; >>> extern const FFInputFormat ff_lmlm4_demuxer; >>> extern const FFInputFormat ff_loas_demuxer; >>> extern const FFInputFormat ff_luodat_demuxer; >>> diff --git a/libavformat/lc3dec.c b/libavformat/lc3dec.c >>> new file mode 100644 >>> index 00..9ca9825f1b >>> --- /dev/null >>> +++ b/libavformat/lc3dec.c >>> @@ -0,0 +1,135 @@ >>> +/* >>> + * LC3 demuxer >>> + * Copyright (C) 2024 Antoine Soulier >>> + * >>> + * This file is part of FFmpeg. >>> + * >>> + * FFmpeg is free software; you can redistribute it and/or >>> + * modify it under the terms of the GNU Lesser General Public >>> + * License as published by the Free Software Foundation; either >>> + * version 2.1 of the License, or (at your option) any later version. >>> + * >>> + * FFmpeg is distributed in the hope that it will be useful, >>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >>> + * Lesser General Public License for more details. >>> + * >>> + * You should have received a copy of the GNU Lesser General Public >>> + * License along with FFmpeg; if not, write to the Free Software >>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA >>> 02110-1301 USA >>> + */ >>> + >>> +/** >>> + * @file >>> + * Based on the file format specified by : >>> + * >>> + * - Bluetooth SIG - Low Complexity Communication Codec Test
[FFmpeg-devel] [PATCH 2/2] avformat/lc3: Add file format for LC3/LC3plus transport
A file format is described in Bluetooth SIG LC3 and ETSI TS 103 634, for test purpose. This is the format implemented here. Signed-off-by: Antoine Soulier --- Changelog| 1 + doc/muxers.texi | 6 ++ libavformat/Makefile | 2 + libavformat/allformats.c | 2 + libavformat/lc3dec.c | 135 +++ libavformat/lc3enc.c | 100 + 6 files changed, 246 insertions(+) create mode 100644 libavformat/lc3dec.c create mode 100644 libavformat/lc3enc.c diff --git a/Changelog b/Changelog index 83a4cf7888..08c200a41d 100644 --- a/Changelog +++ b/Changelog @@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. version : +- LC3/LC3plus demuxer and muxer - LC3/LC3plus decoding/encoding using external library liblc3 diff --git a/doc/muxers.texi b/doc/muxers.texi index a10a8e216f..9687746c30 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -2612,6 +2612,12 @@ WebDAV server every second: ffmpeg -f x11grab -framerate 1 -i :0.0 -q:v 6 -update 1 -protocol_opts method=PUT http://example.com/desktop.jpg @end example +@section lc3 +Bluetooth SIG Low Complexity Communication Codec audio (LC3), or +ETSI TS 103 634 Low Complexity Communication Codec plus (LC3plus). + +This muxer accepts a single @code{lc3} audio stream. + @section matroska Matroska container muxer. diff --git a/libavformat/Makefile b/libavformat/Makefile index 44aa485029..4961c42852 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -332,6 +332,8 @@ OBJS-$(CONFIG_KVAG_DEMUXER) += kvag.o OBJS-$(CONFIG_KVAG_MUXER)+= kvag.o rawenc.o OBJS-$(CONFIG_LAF_DEMUXER) += lafdec.o OBJS-$(CONFIG_LATM_MUXER)+= latmenc.o rawenc.o +OBJS-$(CONFIG_LC3_DEMUXER) += lc3dec.o +OBJS-$(CONFIG_LC3_MUXER) += lc3enc.o OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o OBJS-$(CONFIG_LOAS_DEMUXER) += loasdec.o rawdec.o OBJS-$(CONFIG_LUODAT_DEMUXER)+= luodatdec.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 9df42bb87a..0b36a7c3eb 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -252,6 +252,8 @@ extern const FFInputFormat ff_kvag_demuxer; extern const FFOutputFormat ff_kvag_muxer; extern const FFInputFormat ff_laf_demuxer; extern const FFOutputFormat ff_latm_muxer; +extern const FFInputFormat ff_lc3_demuxer; +extern const FFOutputFormat ff_lc3_muxer; extern const FFInputFormat ff_lmlm4_demuxer; extern const FFInputFormat ff_loas_demuxer; extern const FFInputFormat ff_luodat_demuxer; diff --git a/libavformat/lc3dec.c b/libavformat/lc3dec.c new file mode 100644 index 00..c377df4c63 --- /dev/null +++ b/libavformat/lc3dec.c @@ -0,0 +1,135 @@ +/* + * LC3 demuxer + * Copyright (C) 2024 Antoine Soulier + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Based on the file format specified by : + * + * - Bluetooth SIG - Low Complexity Communication Codec Test Suite + * https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=502301 + * 3.2.8.2 Reference LC3 Codec Bitstream Format + * + * - ETSI TI 103 634 V1.4.1 - Low Complexity Communication Codec plus + * https://www.etsi.org/deliver/etsi_ts/103600_103699/103634/01.04.01_60/ts_103634v010401p.pdf + * LC3plus conformance script package + */ + +#include "libavcodec/packet.h" +#include "libavutil/intreadwrite.h" + +#include "avformat.h" +#include "avio.h" +#include "demux.h" +#include "internal.h" + +typedef struct LC3DemuxContext { +int frame_samples; +int64_t position; +int64_t length; +} LC3DemuxContext; + +static int lc3_read_header(AVFormatContext *s) +{ +LC3DemuxContext *lc3 = s->priv_data; +AVStream *st = NULL; +uint16_t tag, hdr_size; +uint16_t frame_10us; +uint32_t length; +int ep_mode, hr_mode; +int srate_hz, channels, bit_rate; +int num_extra_params, ret; + +tag = avio_rb16(s->pb); +hdr_size = avio_rl16(s->pb); + +if (tag != 0x1ccc || hdr_size < 9 * sizeof(uint16_t)) +return AVERROR_INVALIDDATA; + +num_extra_params =
[FFmpeg-devel] [PATCH 1/2] avcodec/liblc3: Add encoding/decoding support of LC3 audio codec
The LC3 audio codec is the default codec of Bluetooth LE audio. This is a wrapper over the liblc3 library (https://github.com/google/liblc3). Signed-off-by: Antoine Soulier --- Changelog | 4 + configure | 6 ++ doc/encoders.texi | 57 doc/general_contents.texi | 11 ++- libavcodec/Makefile | 2 + libavcodec/allcodecs.c| 2 + libavcodec/codec_desc.c | 7 ++ libavcodec/codec_id.h | 1 + libavcodec/liblc3dec.c| 141 libavcodec/liblc3enc.c| 190 ++ 10 files changed, 420 insertions(+), 1 deletion(-) create mode 100644 libavcodec/liblc3dec.c create mode 100644 libavcodec/liblc3enc.c diff --git a/Changelog b/Changelog index e83a00e35c..83a4cf7888 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,10 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. +version : +- LC3/LC3plus decoding/encoding using external library liblc3 + + version 7.0: - DXV DXT1 encoder - LEAD MCMP decoder diff --git a/configure b/configure index 2d46ef0b9c..e5d9ba9f53 100755 --- a/configure +++ b/configure @@ -244,6 +244,7 @@ External library support: --enable-libjxl enable JPEG XL de/encoding via libjxl [no] --enable-libklvanc enable Kernel Labs VANC processing [no] --enable-libkvazaar enable HEVC encoding via libkvazaar [no] + --enable-liblc3 enable LC3 de/encoding via liblc3 [no] --enable-liblensfun enable lensfun lens correction [no] --enable-libmodplug enable ModPlug via libmodplug [no] --enable-libmp3lame enable MP3 encoding via libmp3lame [no] @@ -1926,6 +1927,7 @@ EXTERNAL_LIBRARY_LIST=" libjxl libklvanc libkvazaar +liblc3 libmodplug libmp3lame libmysofa @@ -3499,6 +3501,9 @@ libilbc_encoder_deps="libilbc" libjxl_decoder_deps="libjxl libjxl_threads" libjxl_encoder_deps="libjxl libjxl_threads" libkvazaar_encoder_deps="libkvazaar" +liblc3_decoder_deps="liblc3" +liblc3_encoder_deps="liblc3" +liblc3_encoder_select="audio_frame_queue" libmodplug_demuxer_deps="libmodplug" libmp3lame_encoder_deps="libmp3lame" libmp3lame_encoder_select="audio_frame_queue mpegaudioheader" @@ -6869,6 +6874,7 @@ enabled libjxl&& require_pkg_config libjxl "libjxl >= 0.7.0" jxl/dec require_pkg_config libjxl_threads "libjxl_threads >= 0.7.0" jxl/thread_parallel_runner.h JxlThreadParallelRunner enabled libklvanc && require libklvanc libklvanc/vanc.h klvanc_context_create -lklvanc enabled libkvazaar&& require_pkg_config libkvazaar "kvazaar >= 2.0.0" kvazaar.h kvz_api_get +enabled liblc3&& require_pkg_config liblc3 "lc3 >= 1.1.0" lc3.h lc3_hr_setup_encoder enabled liblensfun&& require_pkg_config liblensfun lensfun lensfun.h lf_db_create if enabled libmfx && enabled libvpl; then diff --git a/doc/encoders.texi b/doc/encoders.texi index 7c223ed74c..66847191e1 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -814,6 +814,63 @@ ffmpeg -i input.wav -c:a libfdk_aac -profile:a aac_he -b:a 64k output.m4a @end example @end itemize +@anchor{liblc3-enc} +@section liblc3 + +liblc3 LC3 (Low Complexity Communication Codec) encoder wrapper. + +Requires the presence of the liblc3 headers and library during configuration. +You need to explicitly configure the build with @code{--enable-liblc3}. + +This encoder has support for the Bluetooth SIG LC3 codec for the LE Audio +protocol, and the following features of LC3plus: +@itemize +@item +Frame duration of 2.5 and 5ms. +@item +High-Resolution mode, 48 KHz, and 96 kHz sampling rates. +@end itemize + +For more information see the liblc3 project at +@url{https://github.com/google/liblc3}. + +@subsection Options + +The following options are mapped on the shared FFmpeg codec options. + +@table @option +@item b @var{bitrate} +Set the bit rate in bits/s. This will determine the fixed size of the encoded +frames, for a selected frame duration. + +@item ar @var{frequency} +Set the audio sampling rate (in Hz). + +@item channels +Set the number of audio channels. + +@item frame_duration +Set the audio frame duration in milliseconds. Default value is 10ms. +Allowed frame durations are 2.5ms, 5ms, 7.5ms and 10ms. +LC3 (Bluetooth LE Audio), allows 7.5ms and 10ms; and LC3plus 2.5ms, 5ms +and 10ms. + +The 10ms frame duration is available in LC3 and LC3 plus standard. +In this mode, the produced bitstream can be referenced either as LC3 or LC3plus. + +@item high_resolution @var{boolean} +Enable the high-resolution mode if set to 1. The high-resolution mode is +available with all LC3plus frame durations and for a sampling rate of 48 KHz, +and 96 KHz. + +The encoder automatically turns off this mode at lower sampling rates and +activates it at 96 KHz. + +This mode should be preferred at high bitrates. In this
[FFmpeg-devel] [PATCH 2/2] configure: simplify bigendian check
Signed-off-by: J. Dekker --- configure | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/configure b/configure index d332f18e3d..0ff1ff0335 100755 --- a/configure +++ b/configure @@ -6108,11 +6108,7 @@ extern_prefix=${sym%%ff_extern*} check_cc pragma_deprecated "" '_Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")' -# The global variable ensures the bits appear unchanged in the object file. -test_cc
[FFmpeg-devel] [PATCH 1/2] configure,etc: unify shebang usage
Signed-off-by: J. Dekker --- configure | 3 ++- doc/texidep.pl| 2 +- ffbuild/libversion.sh | 1 + tests/fate-run.sh | 2 +- tests/fate.sh | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 2d46ef0b9c..d332f18e3d 100755 --- a/configure +++ b/configure @@ -4725,7 +4725,7 @@ chmod +x $TMPE # make sure we can execute files in $TMPDIR cat > $TMPSH 2>> $logfile <> $logfile 2>&1 if ! $TMPSH >> $logfile 2>&1; then @@ -8270,6 +8270,7 @@ print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols $ # Settings for pkg-config files cat > $TMPH < diff --git a/ffbuild/libversion.sh b/ffbuild/libversion.sh index a94ab58057..ecaa90cde6 100755 --- a/ffbuild/libversion.sh +++ b/ffbuild/libversion.sh @@ -1,3 +1,4 @@ +#!/bin/sh toupper(){ echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ } diff --git a/tests/fate-run.sh b/tests/fate-run.sh index 9863e4f2d9..6ae0320c60 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh export LC_ALL=C diff --git a/tests/fate.sh b/tests/fate.sh index 07908be3a5..c5ee18de80 100755 --- a/tests/fate.sh +++ b/tests/fate.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh config=$1 -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] avformat/lc3: Add file format for LC3/LC3plus transport
Antoine Soulier via ffmpeg-devel: > A file format is described in Bluetooth SIG LC3 and ETSI TS 103 634, for > test purpose. This is the format implemented here. > > Signed-off-by: Antoine Soulier > --- > Changelog| 1 + > doc/muxers.texi | 6 ++ > libavformat/Makefile | 2 + > libavformat/allformats.c | 2 + > libavformat/lc3dec.c | 135 +++ > libavformat/lc3enc.c | 102 + > 6 files changed, 248 insertions(+) > create mode 100644 libavformat/lc3dec.c > create mode 100644 libavformat/lc3enc.c > > diff --git a/Changelog b/Changelog > index 83a4cf7888..08c200a41d 100644 > --- a/Changelog > +++ b/Changelog > @@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest > within each release, > releases are sorted from youngest to oldest. > > version : > +- LC3/LC3plus demuxer and muxer > - LC3/LC3plus decoding/encoding using external library liblc3 > > > diff --git a/doc/muxers.texi b/doc/muxers.texi > index a10a8e216f..9687746c30 100644 > --- a/doc/muxers.texi > +++ b/doc/muxers.texi > @@ -2612,6 +2612,12 @@ WebDAV server every second: > ffmpeg -f x11grab -framerate 1 -i :0.0 -q:v 6 -update 1 -protocol_opts > method=PUT http://example.com/desktop.jpg > @end example > > +@section lc3 > +Bluetooth SIG Low Complexity Communication Codec audio (LC3), or > +ETSI TS 103 634 Low Complexity Communication Codec plus (LC3plus). > + > +This muxer accepts a single @code{lc3} audio stream. > + > @section matroska > > Matroska container muxer. > diff --git a/libavformat/Makefile b/libavformat/Makefile > index 44aa485029..4961c42852 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -332,6 +332,8 @@ OBJS-$(CONFIG_KVAG_DEMUXER) += kvag.o > OBJS-$(CONFIG_KVAG_MUXER)+= kvag.o rawenc.o > OBJS-$(CONFIG_LAF_DEMUXER) += lafdec.o > OBJS-$(CONFIG_LATM_MUXER)+= latmenc.o rawenc.o > +OBJS-$(CONFIG_LC3_DEMUXER) += lc3dec.o > +OBJS-$(CONFIG_LC3_MUXER) += lc3enc.o > OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o > OBJS-$(CONFIG_LOAS_DEMUXER) += loasdec.o rawdec.o > OBJS-$(CONFIG_LUODAT_DEMUXER)+= luodatdec.o > diff --git a/libavformat/allformats.c b/libavformat/allformats.c > index 9df42bb87a..0b36a7c3eb 100644 > --- a/libavformat/allformats.c > +++ b/libavformat/allformats.c > @@ -252,6 +252,8 @@ extern const FFInputFormat ff_kvag_demuxer; > extern const FFOutputFormat ff_kvag_muxer; > extern const FFInputFormat ff_laf_demuxer; > extern const FFOutputFormat ff_latm_muxer; > +extern const FFInputFormat ff_lc3_demuxer; > +extern const FFOutputFormat ff_lc3_muxer; > extern const FFInputFormat ff_lmlm4_demuxer; > extern const FFInputFormat ff_loas_demuxer; > extern const FFInputFormat ff_luodat_demuxer; > diff --git a/libavformat/lc3dec.c b/libavformat/lc3dec.c > new file mode 100644 > index 00..9ca9825f1b > --- /dev/null > +++ b/libavformat/lc3dec.c > @@ -0,0 +1,135 @@ > +/* > + * LC3 demuxer > + * Copyright (C) 2024 Antoine Soulier > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > + */ > + > +/** > + * @file > + * Based on the file format specified by : > + * > + * - Bluetooth SIG - Low Complexity Communication Codec Test Suite > + * https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=502301 > + * 3.2.8.2 Reference LC3 Codec Bitstream Format > + * > + * - ETSI TI 103 634 V1.4.1 - Low Complexity Communication Codec plus > + * > https://www.etsi.org/deliver/etsi_ts/103600_103699/103634/01.04.01_60/ts_103634v010401p.pdf > + * LC3plus conformance script package > + */ > + > +#include "libavcodec/packet.h" > +#include "libavutil/intreadwrite.h" > + > +#include "avformat.h" > +#include "avio.h" > +#include "demux.h" > +#include "internal.h" > + > +typedef struct LC3DemuxContext { > +int frame_samples; > +int64_t position; > +int64_t length; > +} LC3DemuxContext; > + > +static int lc3_read_header(AVFormatContext *s) > +{ > +LC3DemuxContext *lc3 = s->priv_data; > +AVStream *st = NULL; > +uint16_t tag, hdr_size; > +uint16_t frame_us; > +
Re: [FFmpeg-devel] [PATCH v5 1/1] avformat/demux: Add duration_probesize AVOption
On date Thursday 2024-03-28 18:57:36 +0100, Nicolas Gaullier wrote: > Yet another probesize used to get the durations when > estimate_timings_from_pts is required. It is aimed at users interested > in better durations probing for itself, or because using > avformat_find_stream_info indirectly and requiring exact values: for > concatdec for example, especially if streamcopying above it. > The current code is a performance trade-off that can fail to get video > stream durations in a scenario with high bitrates and buffering for > files ending cleanly (as opposed to live captures): the physical gap > between the last video packet and the last audio packet is very high in > such a case. > > Default behaviour is unchanged: 250k up to 250k << 6 (step by step). > Setting this new option has two effects: > - override the maximum probesize (currently 250k << 6) > - reduce the number of steps to 1 instead of 6, this is to avoid > detecting the audio "too early" and failing to reach a video packet. > Even if a single audio stream duration is found but not the other > audio/video stream durations, there will be a retry, so at the end the > full user-overriden probesize will be used as expected by the user. > > Signed-off-by: Nicolas Gaullier > --- > doc/APIchanges | 3 +++ > doc/formats.texi| 19 ++- > libavformat/avformat.h | 16 ++-- > libavformat/demux.c | 13 - > libavformat/options_table.h | 1 + > libavformat/version.h | 2 +- > 6 files changed, 45 insertions(+), 9 deletions(-) > > diff --git a/doc/APIchanges b/doc/APIchanges > index aa102b4925..f709db536d 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 > > API changes, most recent first: > > +2024-03-28 - xx - lavf 61.3.100 - avformat.h > + Add AVFormatContext.duration_probesize. > + > 2024-03-27 - xx - lavu 59.10.100 - frame.h >Add AVSideDataDescriptor, enum AVSideDataProps, and >av_frame_side_data_desc(). > diff --git a/doc/formats.texi b/doc/formats.texi > index 69fc1457a4..3fe7fa9d8d 100644 > --- a/doc/formats.texi > +++ b/doc/formats.texi > @@ -225,9 +225,26 @@ Specifies the maximum number of streams. This can be > used to reject files that > would require too many resources due to a large number of streams. > > @item skip_estimate_duration_from_pts @var{bool} (@emph{input}) > -Skip estimation of input duration when calculated using PTS. > +Skip estimation of input duration if it requires an additional probing for > PTS at end of file. > At present, applicable for MPEG-PS and MPEG-TS. > > +@item duration_probesize @var{integer} (@emph{input}) > +Set probing size, in bytes, for input duration estimation when it actually > requires > +an additional probing for PTS at end of file (at present: MPEG-PS and > MPEG-TS). > +It is aimed at users interested in better durations probing for itself, or > indirectly > +because using the concat demuxer, for example. > +The typical use case is an MPEG-TS CBR with a high bitrate, high video > buffering and > +ending cleaning with similar PTS for video and audio: in such a scenario, > the large > +physical gap between the last video packet and the last audio packet makes > it necessary > +to read many bytes in order to get the video stream duration. > +Another use case is where the default probing behaviour only reaches a > single video frame which is > +not the last one of the stream due to frame reordering, so the duration is > not accurate. > +Setting the duration_probesize has a performance impact even for small files > because the probing > +size is fixed. nit++: setting the @option{duration_probesize} or ... setting this option > +Default behaviour is a general purpose trade-off, largely adaptive: the > probing size may range from > +25 up to 16M, but it is not extended to get streams durations at all > costs. I'm a bit concerned if we should really mention these values, since they are currently hardcoded and this might result in inconsistent documentation in case of update (probably we can only mention that it is adaptive therefore avoiding to expose the internal thresholds). > +Must be an integer not lesser than 1, or 0 for default behaviour. > + [...] Looks good to me otherwise, thanks. ___ 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] avformat/lc3: Add file format for LC3/LC3plus transport
A file format is described in Bluetooth SIG LC3 and ETSI TS 103 634, for test purpose. This is the format implemented here. Signed-off-by: Antoine Soulier --- Changelog| 1 + doc/muxers.texi | 6 ++ libavformat/Makefile | 2 + libavformat/allformats.c | 2 + libavformat/lc3dec.c | 135 +++ libavformat/lc3enc.c | 102 + 6 files changed, 248 insertions(+) create mode 100644 libavformat/lc3dec.c create mode 100644 libavformat/lc3enc.c diff --git a/Changelog b/Changelog index 83a4cf7888..08c200a41d 100644 --- a/Changelog +++ b/Changelog @@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. version : +- LC3/LC3plus demuxer and muxer - LC3/LC3plus decoding/encoding using external library liblc3 diff --git a/doc/muxers.texi b/doc/muxers.texi index a10a8e216f..9687746c30 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -2612,6 +2612,12 @@ WebDAV server every second: ffmpeg -f x11grab -framerate 1 -i :0.0 -q:v 6 -update 1 -protocol_opts method=PUT http://example.com/desktop.jpg @end example +@section lc3 +Bluetooth SIG Low Complexity Communication Codec audio (LC3), or +ETSI TS 103 634 Low Complexity Communication Codec plus (LC3plus). + +This muxer accepts a single @code{lc3} audio stream. + @section matroska Matroska container muxer. diff --git a/libavformat/Makefile b/libavformat/Makefile index 44aa485029..4961c42852 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -332,6 +332,8 @@ OBJS-$(CONFIG_KVAG_DEMUXER) += kvag.o OBJS-$(CONFIG_KVAG_MUXER)+= kvag.o rawenc.o OBJS-$(CONFIG_LAF_DEMUXER) += lafdec.o OBJS-$(CONFIG_LATM_MUXER)+= latmenc.o rawenc.o +OBJS-$(CONFIG_LC3_DEMUXER) += lc3dec.o +OBJS-$(CONFIG_LC3_MUXER) += lc3enc.o OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o OBJS-$(CONFIG_LOAS_DEMUXER) += loasdec.o rawdec.o OBJS-$(CONFIG_LUODAT_DEMUXER)+= luodatdec.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 9df42bb87a..0b36a7c3eb 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -252,6 +252,8 @@ extern const FFInputFormat ff_kvag_demuxer; extern const FFOutputFormat ff_kvag_muxer; extern const FFInputFormat ff_laf_demuxer; extern const FFOutputFormat ff_latm_muxer; +extern const FFInputFormat ff_lc3_demuxer; +extern const FFOutputFormat ff_lc3_muxer; extern const FFInputFormat ff_lmlm4_demuxer; extern const FFInputFormat ff_loas_demuxer; extern const FFInputFormat ff_luodat_demuxer; diff --git a/libavformat/lc3dec.c b/libavformat/lc3dec.c new file mode 100644 index 00..9ca9825f1b --- /dev/null +++ b/libavformat/lc3dec.c @@ -0,0 +1,135 @@ +/* + * LC3 demuxer + * Copyright (C) 2024 Antoine Soulier + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Based on the file format specified by : + * + * - Bluetooth SIG - Low Complexity Communication Codec Test Suite + * https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=502301 + * 3.2.8.2 Reference LC3 Codec Bitstream Format + * + * - ETSI TI 103 634 V1.4.1 - Low Complexity Communication Codec plus + * https://www.etsi.org/deliver/etsi_ts/103600_103699/103634/01.04.01_60/ts_103634v010401p.pdf + * LC3plus conformance script package + */ + +#include "libavcodec/packet.h" +#include "libavutil/intreadwrite.h" + +#include "avformat.h" +#include "avio.h" +#include "demux.h" +#include "internal.h" + +typedef struct LC3DemuxContext { +int frame_samples; +int64_t position; +int64_t length; +} LC3DemuxContext; + +static int lc3_read_header(AVFormatContext *s) +{ +LC3DemuxContext *lc3 = s->priv_data; +AVStream *st = NULL; +uint16_t tag, hdr_size; +uint16_t frame_us; +uint32_t length; +int ep_mode, hr_mode; +int srate_hz, channels, bit_rate; +int num_extra_params, ret; + +tag = avio_rb16(s->pb); +hdr_size = avio_rl16(s->pb); + +if (tag != 0x1ccc || hdr_size < 9 * sizeof(uint16_t)) +return AVERROR_INVALIDDATA; + +num_extra_params =
[FFmpeg-devel] [PATCH 1/2] avcodec/liblc3: Add encoding/decoding support of LC3 audio codec
The LC3 audio codec is the default codec of Bluetooth LE audio. This is a wrapper over the liblc3 library (https://github.com/google/liblc3). Signed-off-by: Antoine Soulier --- Changelog | 4 + configure | 6 ++ doc/encoders.texi | 57 doc/general_contents.texi | 11 ++- libavcodec/Makefile | 2 + libavcodec/allcodecs.c| 2 + libavcodec/codec_desc.c | 7 ++ libavcodec/codec_id.h | 1 + libavcodec/liblc3dec.c| 135 +++ libavcodec/liblc3enc.c| 190 ++ 10 files changed, 414 insertions(+), 1 deletion(-) create mode 100644 libavcodec/liblc3dec.c create mode 100644 libavcodec/liblc3enc.c diff --git a/Changelog b/Changelog index e83a00e35c..83a4cf7888 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,10 @@ Entries are sorted chronologically from oldest to youngest within each release, releases are sorted from youngest to oldest. +version : +- LC3/LC3plus decoding/encoding using external library liblc3 + + version 7.0: - DXV DXT1 encoder - LEAD MCMP decoder diff --git a/configure b/configure index 2d46ef0b9c..e5d9ba9f53 100755 --- a/configure +++ b/configure @@ -244,6 +244,7 @@ External library support: --enable-libjxl enable JPEG XL de/encoding via libjxl [no] --enable-libklvanc enable Kernel Labs VANC processing [no] --enable-libkvazaar enable HEVC encoding via libkvazaar [no] + --enable-liblc3 enable LC3 de/encoding via liblc3 [no] --enable-liblensfun enable lensfun lens correction [no] --enable-libmodplug enable ModPlug via libmodplug [no] --enable-libmp3lame enable MP3 encoding via libmp3lame [no] @@ -1926,6 +1927,7 @@ EXTERNAL_LIBRARY_LIST=" libjxl libklvanc libkvazaar +liblc3 libmodplug libmp3lame libmysofa @@ -3499,6 +3501,9 @@ libilbc_encoder_deps="libilbc" libjxl_decoder_deps="libjxl libjxl_threads" libjxl_encoder_deps="libjxl libjxl_threads" libkvazaar_encoder_deps="libkvazaar" +liblc3_decoder_deps="liblc3" +liblc3_encoder_deps="liblc3" +liblc3_encoder_select="audio_frame_queue" libmodplug_demuxer_deps="libmodplug" libmp3lame_encoder_deps="libmp3lame" libmp3lame_encoder_select="audio_frame_queue mpegaudioheader" @@ -6869,6 +6874,7 @@ enabled libjxl&& require_pkg_config libjxl "libjxl >= 0.7.0" jxl/dec require_pkg_config libjxl_threads "libjxl_threads >= 0.7.0" jxl/thread_parallel_runner.h JxlThreadParallelRunner enabled libklvanc && require libklvanc libklvanc/vanc.h klvanc_context_create -lklvanc enabled libkvazaar&& require_pkg_config libkvazaar "kvazaar >= 2.0.0" kvazaar.h kvz_api_get +enabled liblc3&& require_pkg_config liblc3 "lc3 >= 1.1.0" lc3.h lc3_hr_setup_encoder enabled liblensfun&& require_pkg_config liblensfun lensfun lensfun.h lf_db_create if enabled libmfx && enabled libvpl; then diff --git a/doc/encoders.texi b/doc/encoders.texi index 7c223ed74c..66847191e1 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -814,6 +814,63 @@ ffmpeg -i input.wav -c:a libfdk_aac -profile:a aac_he -b:a 64k output.m4a @end example @end itemize +@anchor{liblc3-enc} +@section liblc3 + +liblc3 LC3 (Low Complexity Communication Codec) encoder wrapper. + +Requires the presence of the liblc3 headers and library during configuration. +You need to explicitly configure the build with @code{--enable-liblc3}. + +This encoder has support for the Bluetooth SIG LC3 codec for the LE Audio +protocol, and the following features of LC3plus: +@itemize +@item +Frame duration of 2.5 and 5ms. +@item +High-Resolution mode, 48 KHz, and 96 kHz sampling rates. +@end itemize + +For more information see the liblc3 project at +@url{https://github.com/google/liblc3}. + +@subsection Options + +The following options are mapped on the shared FFmpeg codec options. + +@table @option +@item b @var{bitrate} +Set the bit rate in bits/s. This will determine the fixed size of the encoded +frames, for a selected frame duration. + +@item ar @var{frequency} +Set the audio sampling rate (in Hz). + +@item channels +Set the number of audio channels. + +@item frame_duration +Set the audio frame duration in milliseconds. Default value is 10ms. +Allowed frame durations are 2.5ms, 5ms, 7.5ms and 10ms. +LC3 (Bluetooth LE Audio), allows 7.5ms and 10ms; and LC3plus 2.5ms, 5ms +and 10ms. + +The 10ms frame duration is available in LC3 and LC3 plus standard. +In this mode, the produced bitstream can be referenced either as LC3 or LC3plus. + +@item high_resolution @var{boolean} +Enable the high-resolution mode if set to 1. The high-resolution mode is +available with all LC3plus frame durations and for a sampling rate of 48 KHz, +and 96 KHz. + +The encoder automatically turns off this mode at lower sampling rates and +activates it at 96 KHz. + +This mode should be preferred at high bitrates. In this
Re: [FFmpeg-devel] [PATCH] avformat/flac_picture: print a warning when mimetype is unknown
On Thu, Mar 28, 2024 at 05:08:42PM -0300, James Almer wrote: > It's not an error since bba6df9ac7bd8386d92e1a7f5c737ca4e575fcc. > > Signed-off-by: James Almer > --- > libavformat/flac_picture.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) LGTM thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No snowflake in an avalanche ever feels responsible. -- 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".
Re: [FFmpeg-devel] [PATCH] V2 tests/fate/filter-audio.mak: add test for ATEMPO audio filter
On Thu, 28 Mar 2024 at 1:52 PM, Anton Khirnov wrote: > > atempo uses floats for processing, are you sure this > will produce > > exactly the same results everywhere? Tried replicating in some available environments I had and it worked fine, though could not relate with the test not working because of floats. > ___ 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 v10 5/5] doc/indevs: update CC extraction example to use RCWT muxer
Signed-off-by: Marth64 --- doc/indevs.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/indevs.texi b/doc/indevs.texi index d1b2bacf8b..fc14737181 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -1069,9 +1069,9 @@ ffplay -f lavfi "movie=test.avi[out0];amovie=test.wav[out1]" @end example @item -Dump decoded frames to images and closed captions to a file (experimental): +Dump decoded frames to images and Closed Captions to an RCWT backup: @example -ffmpeg -f lavfi -i "movie=test.ts[out0+subcc]" -map v frame%08d.png -map s -c copy -f rawvideo subcc.bin +ffmpeg -f lavfi -i "movie=test.ts[out0+subcc]" -map v frame%08d.png -map s -c copy subcc.bin @end example @end itemize -- 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 v10 4/5] doc/muxers: refresh the RCWT muxer's doc to be consistent with the demuxer
Signed-off-by: Marth64 --- doc/muxers.texi | 29 +++-- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index a10a8e216f..4161401059 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -3038,19 +3038,18 @@ ogg files can be safely chained. @end table -@anchor{rcwt} +@anchor{rcwtenc} @section rcwt -Raw Captions With Time (RCWT) is a format native to ccextractor, a commonly -used open source tool for processing 608/708 closed caption (CC) sources. -It can be used to archive the original, raw CC bitstream and to produce -a source file for later CC processing or conversion. As a result, -it also allows for interopability with ccextractor for processing CC data -extracted via ffmpeg. The format is simple to parse and can be used -to retain all lines and variants of CC. +RCWT (Raw Captions With Time) is a format native to ccextractor, a commonly +used open source tool for processing 608/708 Closed Captions (CC) sources. +It can be used to archive the original extracted CC bitstream and to produce +a source file for later processing or conversion. The format allows +for interoperability between ccextractor and FFmpeg, is simple to parse, +and can be used to create a backup of the CC presentation. -This muxer implements the specification as of 2024-01-05, which has -been stable and unchanged for 10 years as of this writing. +This muxer implements the specification as of March 2024, which has +been stable and unchanged since April 2014. This muxer will have some nuances from the way that ccextractor muxes RCWT. No compatibility issues when processing the output with ccextractor @@ -3060,6 +3059,16 @@ and outputs will not be a bit-exact match. A free specification of RCWT can be found here: @url{https://github.com/CCExtractor/ccextractor/blob/master/docs/BINARY_FILE_FORMAT.TXT} +@subsection Examples + +@itemize +@item +Extract Closed Captions to RCWT using lavfi: +@example +ffmpeg -f lavfi -i "movie=INPUT.mkv[out+subcc]" -map 0:s:0 -c:s copy CC.rcwt.bin +@end example +@end itemize + @anchor{segment} @section segment, stream_segment, ssegment -- 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 v10 3/5] avformat/rcwtenc: remove repeated documentation
The high level summary of RCWT can be delegated doc/muxers, which makes it easier to maintain and more consistent with the documentation of the demuxer. Signed-off-by: Marth64 --- libavformat/rcwtenc.c | 5 - 1 file changed, 5 deletions(-) diff --git a/libavformat/rcwtenc.c b/libavformat/rcwtenc.c index f2459ef1d3..e06bc4b734 100644 --- a/libavformat/rcwtenc.c +++ b/libavformat/rcwtenc.c @@ -21,11 +21,6 @@ /* * RCWT (Raw Captions With Time) is a format native to ccextractor, a commonly * used open source tool for processing 608/708 Closed Captions (CC) sources. - * It can be used to archive the original, raw CC bitstream and to produce - * a source file for later CC processing or conversion. As a result, - * it also allows for interopability with ccextractor for processing CC data - * extracted via ffmpeg. The format is simple to parse and can be used - * to retain all lines and variants of CC. * * This muxer implements the specification as of March 2024, which has * been stable and unchanged since April 2014. -- 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 v10 2/5] avformat/rcwtdec: add RCWT Closed Captions demuxer
RCWT (Raw Captions With Time) is a format native to ccextractor, a commonly used OSS tool for processing 608/708 Closed Captions (CC). RCWT can be used to archive the original extracted CC bitstream. The muxer was added in January 2024. In this commit, add the demuxer. One can now demux RCWT files for rendering in ccaption_dec or interop with ccextractor (which produces RCWT). Using the muxer/demuxer combo, the CC bits can be kept for processing or rendering with either tool. This can be an effective way to backup an original CC stream, including format extensions like EIA-708 and overall original presentation. Signed-off-by: Marth64 --- doc/demuxers.texi| 30 ++ libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/rcwtdec.c| 123 +++ 4 files changed, 155 insertions(+) create mode 100644 libavformat/rcwtdec.c diff --git a/doc/demuxers.texi b/doc/demuxers.texi index b70f3a38d7..04293c4813 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -1038,6 +1038,36 @@ the command: ffplay -f rawvideo -pixel_format rgb24 -video_size 320x240 -framerate 10 input.raw @end example +@anchor{rcwtdec} +@section rcwt + +RCWT (Raw Captions With Time) is a format native to ccextractor, a commonly +used open source tool for processing 608/708 Closed Captions (CC) sources. +For more information on the format, see @ref{rcwtenc,,,ffmpeg-formats}. + +This demuxer implements the specification as of March 2024, which has +been stable and unchanged since April 2014. + +@subsection Examples + +@itemize +@item +Render CC to ASS using the built-in decoder: +@example +ffmpeg -i CC.rcwt.bin CC.ass +@end example +Note that if your output appears to be empty, you may have to manually +set the decoder's @option{data_field} option to pick the desired CC substream. + +@item +Convert an RCWT backup to Scenarist (SCC) format: +@example +ffmpeg -i CC.rcwt.bin -c:s copy CC.scc +@end example +Note that the SCC format does not support all of the possible CC extensions +that can be stored in RCWT (such as EIA-708). +@end itemize + @section sbg SBaGen script demuxer. diff --git a/libavformat/Makefile b/libavformat/Makefile index 44aa485029..5d77cba7f1 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -493,6 +493,7 @@ OBJS-$(CONFIG_QOA_DEMUXER) += qoadec.o OBJS-$(CONFIG_R3D_DEMUXER) += r3d.o OBJS-$(CONFIG_RAWVIDEO_DEMUXER) += rawvideodec.o OBJS-$(CONFIG_RAWVIDEO_MUXER)+= rawenc.o +OBJS-$(CONFIG_RCWT_DEMUXER) += rcwtdec.o subtitles.o OBJS-$(CONFIG_RCWT_MUXER)+= rcwtenc.o subtitles.o OBJS-$(CONFIG_REALTEXT_DEMUXER) += realtextdec.o subtitles.o OBJS-$(CONFIG_REDSPARK_DEMUXER) += redspark.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 9df42bb87a..ae925dcf60 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -391,6 +391,7 @@ extern const FFInputFormat ff_qoa_demuxer; extern const FFInputFormat ff_r3d_demuxer; extern const FFInputFormat ff_rawvideo_demuxer; extern const FFOutputFormat ff_rawvideo_muxer; +extern const FFInputFormat ff_rcwt_demuxer; extern const FFOutputFormat ff_rcwt_muxer; extern const FFInputFormat ff_realtext_demuxer; extern const FFInputFormat ff_redspark_demuxer; diff --git a/libavformat/rcwtdec.c b/libavformat/rcwtdec.c new file mode 100644 index 00..91f994c3ab --- /dev/null +++ b/libavformat/rcwtdec.c @@ -0,0 +1,123 @@ +/* + * RCWT (Raw Captions With Time) demuxer + * + * 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 + */ + +/* + * RCWT (Raw Captions With Time) is a format native to ccextractor, a commonly + * used open source tool for processing 608/708 Closed Captions (CC) sources. + * + * This demuxer implements the specification as of March 2024, which has + * been stable and unchanged since April 2014. + * + * A free specification of RCWT can be found here: + * @url{https://github.com/CCExtractor/ccextractor/blob/master/docs/BINARY_FILE_FORMAT.TXT} + */ + +#include "avformat.h" +#include "demux.h" +#include "internal.h" +#include "subtitles.h" +#include "libavutil/intreadwrite.h" + +#define RCWT_HEADER_SIZE11 + +typedef
[FFmpeg-devel] [PATCH v10 1/5] avformat/subtitles: extend ff_subtitles_queue_insert() to support not yet available events
If ff_subtitles_queue_insert() were given a NULL buffer with 0 length, it would still attempt to grow the packet or memcpy depending on if merge option is enabled. In this commit, allow passing a NULL buffer with 0 length without attempting to do such operations. This way, if a subtitle demuxer happens to pass an empty cue or wants to use av_get_packet() to read bytes, there are no unnecessary operations on the packet after it is allocated. Signed-off-by: Marth64 --- libavformat/subtitles.c | 23 +++ libavformat/subtitles.h | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/libavformat/subtitles.c b/libavformat/subtitles.c index 3413763c7b..1c9b229f5b 100644 --- a/libavformat/subtitles.c +++ b/libavformat/subtitles.c @@ -21,6 +21,7 @@ #include "avformat.h" #include "subtitles.h" #include "avio_internal.h" +#include "libavutil/avassert.h" #include "libavutil/avstring.h" void ff_text_init_avio(void *s, FFTextReader *r, AVIOContext *pb) @@ -111,15 +112,19 @@ AVPacket *ff_subtitles_queue_insert(FFDemuxSubtitlesQueue *q, { AVPacket **subs, *sub; +av_assert1(event || len == 0); + if (merge && q->nb_subs > 0) { /* merge with previous event */ int old_len; sub = q->subs[q->nb_subs - 1]; old_len = sub->size; -if (av_grow_packet(sub, len) < 0) -return NULL; -memcpy(sub->data + old_len, event, len); +if (event) { +if (av_grow_packet(sub, len) < 0) +return NULL; +memcpy(sub->data + old_len, event, len); +} } else { /* new event */ @@ -133,14 +138,16 @@ AVPacket *ff_subtitles_queue_insert(FFDemuxSubtitlesQueue *q, sub = av_packet_alloc(); if (!sub) return NULL; -if (av_new_packet(sub, len) < 0) { -av_packet_free(); -return NULL; +if (event) { +if (av_new_packet(sub, len) < 0) { +av_packet_free(); +return NULL; +} +memcpy(sub->data, event, len); } -subs[q->nb_subs++] = sub; sub->flags |= AV_PKT_FLAG_KEY; sub->pts = sub->dts = 0; -memcpy(sub->data, event, len); +subs[q->nb_subs++] = sub; } return sub; } diff --git a/libavformat/subtitles.h b/libavformat/subtitles.h index 88665663c5..ad6b96ca6a 100644 --- a/libavformat/subtitles.h +++ b/libavformat/subtitles.h @@ -112,7 +112,7 @@ typedef struct { /** * Insert a new subtitle event. * - * @param event the subtitle line, may not be zero terminated + * @param event the subtitle line (not zero terminated) or NULL on not yet available event * @param len the length of the event (in strlen() sense, so without '\0') * @param merge set to 1 if the current event should be concatenated with the * previous one instead of adding a new entry, 0 otherwise -- 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 v10 0/5] RCWT Closed Captions demuxer (v10)
Since v7/8: * Addresses last known feedback (about av_assert call) * Changelog entry removed, since v7.0 is cut and there is no "next" space yet (will make patch once available) Signed-off-by: Marth64 -- 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] avformat/flac_picture: print a warning when mimetype is unknown
It's not an error since bba6df9ac7bd8386d92e1a7f5c737ca4e575fcc. Signed-off-by: James Almer --- libavformat/flac_picture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/flac_picture.c b/libavformat/flac_picture.c index 20df0192d4..c9f3f11edd 100644 --- a/libavformat/flac_picture.c +++ b/libavformat/flac_picture.c @@ -89,7 +89,7 @@ int ff_flac_parse_picture(AVFormatContext *s, uint8_t **bufp, int buf_size, mime++; } if (id == AV_CODEC_ID_NONE) { -av_log(s, AV_LOG_ERROR, "Unknown attached picture mimetype: %s.\n", +av_log(s, AV_LOG_WARNING, "Unknown attached picture mimetype: %s.\n", mimetype); return 0; } -- 2.44.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] Fixes #10509
> On Tue, Mar 26, 2024 at 2:36 AM Poorva <2003gaikarpoo...@gmail.com> wrote: >> >> > > On Mon, Mar 25, 2024 at 2:04 AM Marton Balint wrote: >> >> >> >> On Sun, 24 Mar 2024, Poorva wrote: >> >> > From 0874a55ad33bb4df2789cbafc5247c0ae3d97e6a Mon Sep 17 00:00:00 2001 >> > From: PoorvaGaikar >> > Date: Sat, 9 Mar 2024 00:27:25 +0530 >> > Subject: [PATCH v2] avfilter/f_select.c: add support for iw and ih >> > constants >> >> You should mention the fixed ticket number in the commit message. >> >> > >> > --- >> > doc/filters.texi | 6 ++ >> > libavfilter/f_select.c | 14 ++ >> > 2 files changed, 20 insertions(+) >> > >> > diff --git a/doc/filters.texi b/doc/filters.texi >> > index 913365671d..e73dc9c1bf 100644 >> > --- a/doc/filters.texi >> > +++ b/doc/filters.texi >> > @@ -30737,6 +30737,12 @@ missing. >> > That basically means that an input frame is selected if its pts is within >> > the >> > interval set by the concat demuxer. >> > >> > +@item iw @emph{(video only)} >> > +Represents the width of the input video frame >> > + >> > +@item ih @emph{(video only)} >> > +Represents the height of the input video frame >> > + >> > @end table >> > >> > The default value of the select expression is "1". >> > diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c >> > index 9b330a0673..ccfe915ee1 100644 >> > --- a/libavfilter/f_select.c >> > +++ b/libavfilter/f_select.c >> > @@ -90,6 +90,9 @@ static const char *const var_names[] = { >> > >> > "concatdec_select", ///< frame is within the interval set by the >> > concat demuxer >> > >> > +"ih",///< ih: Represents the height of the input >> > video frame. >> > +"iw",///< iw: Represents the width of the input video >> > frame. >> > + >> > NULL >> > }; >> > >> > @@ -144,6 +147,9 @@ enum var_name { >> > >> > VAR_CONCATDEC_SELECT, >> > >> > +VAR_IH, >> > +VAR_IW, >> > + >> > VAR_VARS_NB >> > }; >> > >> > @@ -264,6 +270,9 @@ static int config_input(AVFilterLink *inlink) >> > select->var_values[VAR_CONSUMED_SAMPLES_N] = NAN; >> > select->var_values[VAR_SAMPLES_N] = NAN; >> > >> > +select->var_values[VAR_IH] = NAN; >> > +select->var_values[VAR_IW] = NAN; >> > + >> > select->var_values[VAR_SAMPLE_RATE] = >> > inlink->type == AVMEDIA_TYPE_AUDIO ? inlink->sample_rate : NAN; >> > >> > @@ -370,6 +379,10 @@ FF_ENABLE_DEPRECATION_WARNINGS >> > } >> > break; >> > } >> > +if (inlink->type == AVMEDIA_TYPE_VIDEO){ >> > +select->var_values[VAR_IH] = frame->height; >> > +select->var_values[VAR_IW] = frame->width; >> > +} >> >> There is a switch(inlink->type) just above this, so you should put these >> there to the corresponding case AVMEDIA_TYPE_VIDEO, and not create a new >> block. >> >> > >> > select->select = res = av_expr_eval(select->expr, select->var_values, >> > NULL); >> > av_log(inlink->dst, AV_LOG_DEBUG, >> > @@ -546,3 +559,4 @@ const AVFilter ff_vf_select = { >> > .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS | >> > AVFILTER_FLAG_METADATA_ONLY, >> > }; >> > #endif /* CONFIG_SELECT_FILTER */ >> > + >> >> This is still an uneeded newline. > > > Thank you for your feedback on the Git patch I submitted for review. > I have rectified the problem by adding the necessary changes . > The updated patch file is attached for your review. >> >> I wanted to follow up on the patch titled "v3-0001-avfilter-f_select.c - Add Support for IW and IH" that I submitted earlier and provide an update based on the feedback received. In response to your suggestion about the switch block, I have integrated the changes into the existing switch block for AVMEDIA_TYPE_VIDEO. Additionally, I have removed an unnecessary new line that was added at the end of the file. Despite these modifications, I have not received any further feedback or comments on the patch. Therefore, I kindly request the community to review the updated patch attached to this email. >> >> 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 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 v9 0/5] RCWT Closed Captions demuxer (v9)
Stefano, v10 coming shortly. Thank you! ___ 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 v9 0/5] RCWT Closed Captions demuxer (v9)
Thanks for checking Stefano, I have been behind a bit. I will follow up with the fix once possible. ___ 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 v9 0/5] RCWT Closed Captions demuxer (v9)
On date Tuesday 2024-03-26 17:07:01 +0100, Stefano Sabatini wrote: > On date Tuesday 2024-03-26 10:29:18 -0500, Marth64 wrote: > > Ping if possible. The patches still apply. 3 of the 5 patches are > > documentation only and the demuxer itself is much smaller now. The muxer > > already made it in, so was hoping the demuxer could go too :fingers_crossed: > > I sent a few comments but in general looks good to me, will wait a few > days to see if there are more comments and will push otherwise. Marth64: I see an unaddressed comment by Andreas, I'll wait for the next update before merging. ___ 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 v11 3/8] avcodec/bsf: Add awebp2webp bitstream filter
On date Thursday 2024-03-28 15:08:53 +0100, ffmpeg-devel Mailing List wrote: > Splits a packet containing a webp animations into > one non-compliant packet per frame of the animation. > Skips RIFF and WEBP chunks for those packets except > for the first. Copyies ICC, EXIF and XMP chunks first > into each of the packets except for the first. > --- > configure | 1 + > libavcodec/bitstream_filters.c | 1 + > libavcodec/bsf/Makefile| 1 + > libavcodec/bsf/awebp2webp.c| 350 + > 4 files changed, 353 insertions(+) > create mode 100644 libavcodec/bsf/awebp2webp.c missing doc/bitstreams.texi update? also you might mention in the Changelog, assuming this might be directly used by users [...] ___ 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 3/4] avformat/lc3: Add file format for LC3/LC3plus transport
On date Wednesday 2024-03-27 22:21:44 +, ffmpeg-devel Mailing List wrote: > A file format is described in Bluetooth SIG LC3 and ETSI TS 103 634, for > test purpose. This is the format implemented here. > > Signed-off-by: Antoine Soulier > --- > doc/muxers.texi | 6 ++ > libavformat/Makefile | 2 + > libavformat/allformats.c | 2 + > libavformat/lc3dec.c | 135 +++ > libavformat/lc3enc.c | 102 + > 5 files changed, 247 insertions(+) > create mode 100644 libavformat/lc3dec.c > create mode 100644 libavformat/lc3enc.c Note: you might add an entry for muxing/demuxing support to the Changelog. Looks good to me otherwise. ___ 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 v5 1/1] avformat/demux: Add duration_probesize AVOption
Yet another probesize used to get the durations when estimate_timings_from_pts is required. It is aimed at users interested in better durations probing for itself, or because using avformat_find_stream_info indirectly and requiring exact values: for concatdec for example, especially if streamcopying above it. The current code is a performance trade-off that can fail to get video stream durations in a scenario with high bitrates and buffering for files ending cleanly (as opposed to live captures): the physical gap between the last video packet and the last audio packet is very high in such a case. Default behaviour is unchanged: 250k up to 250k << 6 (step by step). Setting this new option has two effects: - override the maximum probesize (currently 250k << 6) - reduce the number of steps to 1 instead of 6, this is to avoid detecting the audio "too early" and failing to reach a video packet. Even if a single audio stream duration is found but not the other audio/video stream durations, there will be a retry, so at the end the full user-overriden probesize will be used as expected by the user. Signed-off-by: Nicolas Gaullier --- doc/APIchanges | 3 +++ doc/formats.texi| 19 ++- libavformat/avformat.h | 16 ++-- libavformat/demux.c | 13 - libavformat/options_table.h | 1 + libavformat/version.h | 2 +- 6 files changed, 45 insertions(+), 9 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index aa102b4925..f709db536d 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-03-28 - xx - lavf 61.3.100 - avformat.h + Add AVFormatContext.duration_probesize. + 2024-03-27 - xx - lavu 59.10.100 - frame.h Add AVSideDataDescriptor, enum AVSideDataProps, and av_frame_side_data_desc(). diff --git a/doc/formats.texi b/doc/formats.texi index 69fc1457a4..3fe7fa9d8d 100644 --- a/doc/formats.texi +++ b/doc/formats.texi @@ -225,9 +225,26 @@ Specifies the maximum number of streams. This can be used to reject files that would require too many resources due to a large number of streams. @item skip_estimate_duration_from_pts @var{bool} (@emph{input}) -Skip estimation of input duration when calculated using PTS. +Skip estimation of input duration if it requires an additional probing for PTS at end of file. At present, applicable for MPEG-PS and MPEG-TS. +@item duration_probesize @var{integer} (@emph{input}) +Set probing size, in bytes, for input duration estimation when it actually requires +an additional probing for PTS at end of file (at present: MPEG-PS and MPEG-TS). +It is aimed at users interested in better durations probing for itself, or indirectly +because using the concat demuxer, for example. +The typical use case is an MPEG-TS CBR with a high bitrate, high video buffering and +ending cleaning with similar PTS for video and audio: in such a scenario, the large +physical gap between the last video packet and the last audio packet makes it necessary +to read many bytes in order to get the video stream duration. +Another use case is where the default probing behaviour only reaches a single video frame which is +not the last one of the stream due to frame reordering, so the duration is not accurate. +Setting the duration_probesize has a performance impact even for small files because the probing +size is fixed. +Default behaviour is a general purpose trade-off, largely adaptive: the probing size may range from +25 up to 16M, but it is not extended to get streams durations at all costs. +Must be an integer not lesser than 1, or 0 for default behaviour. + @item strict, f_strict @var{integer} (@emph{input/output}) Specify how strictly to follow the standards. @code{f_strict} is deprecated and should be used only via the @command{ffmpeg} tool. diff --git a/libavformat/avformat.h b/libavformat/avformat.h index de40397676..8afdcd9fd0 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1439,7 +1439,7 @@ typedef struct AVFormatContext { * * @note this is \e not used for determining the \ref AVInputFormat * "input format" - * @sa format_probesize + * @see format_probesize */ int64_t probesize; @@ -1667,6 +1667,8 @@ typedef struct AVFormatContext { * Skip duration calcuation in estimate_timings_from_pts. * - encoding: unused * - decoding: set by user + * + * @see duration_probesize */ int skip_estimate_duration_from_pts; @@ -1729,7 +1731,7 @@ typedef struct AVFormatContext { * * Demuxing only, set by the caller before avformat_open_input(). * - * @sa probesize + * @see probesize */ int format_probesize; @@ -1870,6 +1872,16 @@ typedef struct AVFormatContext { * @return 0 on success, a negative AVERROR code on failure */
[FFmpeg-devel] [PATCH v5 0/1] avformat/demux: Add duration_probesize AVOption
V5 including all Stefano's feedback. Notes: - I have largely reworked the texi, I hope the use case is more clear. - I have rewrote "250K up to 16M" to "25 up to 16M" to be clear about the K/M units. - @seealso seems not supported in my doxy environment, so I simply moved all the @sa to @see >> +int64_t duration_max_read_size = ic->duration_probesize ? >> + ic->duration_probesize >> DURATION_MAX_RETRY_USER : >> + DURATION_MAX_READ_SIZE_DEFAULT; > >nit: I find the right shift followed by the leftshift a bit confusing, but >probably there is no simple way to prevent it Apart code simplification, there is a least one reason for that: an odd number would not be satisfactory for the algorithm. Each seek/retry has to join with no overlap. Here, if the user set duration_probesize=17, the first seek will be at filesize-8 / 8 bytes and the next-unique retry at filesize-16 / 8 bytes. Thank you for your time, Nicolas Nicolas Gaullier (1): avformat/demux: Add duration_probesize AVOption doc/APIchanges | 3 +++ doc/formats.texi| 19 ++- libavformat/avformat.h | 16 ++-- libavformat/demux.c | 13 - libavformat/options_table.h | 1 + libavformat/version.h | 2 +- 6 files changed, 45 insertions(+), 9 deletions(-) -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/4] Changelog: Add LC3/LC3plus decoding/encoding support
On date Wednesday 2024-03-27 22:21:45 +, ffmpeg-devel Mailing List wrote: > Signed-off-by: Antoine Soulier > --- > Changelog | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/Changelog b/Changelog > index 934241a965..2282f8ca76 100644 > --- a/Changelog > +++ b/Changelog > @@ -37,6 +37,7 @@ version : > - Support PacketTypeMetadata of PacketType in enhanced flv format > - ffplay with hwaccel decoding support (depends on vulkan renderer via > libplacebo) > - dnn filter libtorch backend > +- LC3/LC3plus decoding/encoding using external library liblc3 You might merge this with the codec patch (also since 7.0 was cut this will be in the next release) ___ 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 2/4] avcodec/liblc3: Add encoding/decoding support of LC3 audio codec
On date Wednesday 2024-03-27 22:21:43 +, ffmpeg-devel Mailing List wrote: > The LC3 audio codec is the default codec of Bluetooth LE audio. > This is a wrapper over the liblc3 library (https://github.com/google/liblc3). > > Signed-off-by: Antoine Soulier > --- > doc/encoders.texi | 57 > doc/general_contents.texi | 11 ++- > libavcodec/Makefile | 2 + > libavcodec/allcodecs.c| 2 + > libavcodec/codec_desc.c | 7 ++ > libavcodec/codec_id.h | 1 + > libavcodec/liblc3dec.c| 135 +++ > libavcodec/liblc3enc.c| 190 ++ > 8 files changed, 404 insertions(+), 1 deletion(-) > create mode 100644 libavcodec/liblc3dec.c > create mode 100644 libavcodec/liblc3enc.c > > diff --git a/doc/encoders.texi b/doc/encoders.texi > index 7c223ed74c..66847191e1 100644 > --- a/doc/encoders.texi > +++ b/doc/encoders.texi > @@ -814,6 +814,63 @@ ffmpeg -i input.wav -c:a libfdk_aac -profile:a aac_he > -b:a 64k output.m4a > @end example > @end itemize > > +@anchor{liblc3-enc} > +@section liblc3 > + > +liblc3 LC3 (Low Complexity Communication Codec) encoder wrapper. > + > +Requires the presence of the liblc3 headers and library during configuration. > +You need to explicitly configure the build with @code{--enable-liblc3}. > + > +This encoder has support for the Bluetooth SIG LC3 codec for the LE Audio > +protocol, and the following features of LC3plus: > +@itemize > +@item > +Frame duration of 2.5 and 5ms. > +@item > +High-Resolution mode, 48 KHz, and 96 kHz sampling rates. > +@end itemize > + > +For more information see the liblc3 project at > +@url{https://github.com/google/liblc3}. > + > +@subsection Options > + > +The following options are mapped on the shared FFmpeg codec options. > + > +@table @option > +@item b @var{bitrate} > +Set the bit rate in bits/s. This will determine the fixed size of the encoded > +frames, for a selected frame duration. > + > +@item ar @var{frequency} > +Set the audio sampling rate (in Hz). > + > +@item channels > +Set the number of audio channels. > + > +@item frame_duration > +Set the audio frame duration in milliseconds. Default value is 10ms. > +Allowed frame durations are 2.5ms, 5ms, 7.5ms and 10ms. > +LC3 (Bluetooth LE Audio), allows 7.5ms and 10ms; and LC3plus 2.5ms, 5ms > +and 10ms. > + > +The 10ms frame duration is available in LC3 and LC3 plus standard. > +In this mode, the produced bitstream can be referenced either as LC3 or > LC3plus. > + > +@item high_resolution @var{boolean} > +Enable the high-resolution mode if set to 1. The high-resolution mode is > +available with all LC3plus frame durations and for a sampling rate of 48 KHz, > +and 96 KHz. > + > +The encoder automatically turns off this mode at lower sampling rates and > +activates it at 96 KHz. > + > +This mode should be preferred at high bitrates. In this mode, the audio > +bandwidth is always up to the Nyquist frequency, compared to LC3 at 48 KHz, > +which limits the bandwidth to 20 KHz. > +@end table > + > @anchor{libmp3lame} > @section libmp3lame > > diff --git a/doc/general_contents.texi b/doc/general_contents.texi > index f269cbd1a9..e7cf4f8239 100644 > --- a/doc/general_contents.texi > +++ b/doc/general_contents.texi > @@ -237,6 +237,14 @@ Go to > @url{http://sourceforge.net/projects/opencore-amr/} and follow the > instructions for installing the library. > Then pass @code{--enable-libfdk-aac} to configure to enable it. > > +@subsection LC3 library > + > +FFmpeg can make use of the Google LC3 library for LC3 decoding & encoding. > + > +Go to @url{https://github.com/google/liblc3/} and follow the instructions for > +installing the library. > +Then pass @code{--enable-liblc3} to configure to enable it. > + > @section OpenH264 > > FFmpeg can make use of the OpenH264 library for H.264 decoding and encoding. > @@ -1300,7 +1308,8 @@ following image formats are supported: > @tab encoding and decoding supported through external library libilbc > @item IMC (Intel Music Coder) @tab @tab X > @item Interplay ACM@tab @tab X > -@item MACE (Macintosh Audio Compression/Expansion) 3:1 @tab @tab X > +@item LC3@tab E @tab E > +@tab supported through external library liblc3 > @item MACE (Macintosh Audio Compression/Expansion) 6:1 @tab @tab X > @item Marian's A-pac audio @tab @tab X > @item MI-SC4 (Micronas SC-4 Audio) @tab @tab X > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index 9ce6d445c1..e70811dbd6 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -1123,6 +1123,8 @@ OBJS-$(CONFIG_LIBILBC_ENCODER)+= libilbc.o > OBJS-$(CONFIG_LIBJXL_DECODER) += libjxldec.o libjxl.o > OBJS-$(CONFIG_LIBJXL_ENCODER) += libjxlenc.o libjxl.o > OBJS-$(CONFIG_LIBKVAZAAR_ENCODER) += libkvazaar.o > +OBJS-$(CONFIG_LIBLC3_ENCODER) += liblc3enc.o >
Re: [FFmpeg-devel] [PATCH 1/4] configure: Add option for enabling LC3/LC3plus wrapper
On date Wednesday 2024-03-27 22:21:42 +, ffmpeg-devel Mailing List wrote: > Signed-off-by: Antoine Soulier > --- > configure | 6 ++ > 1 file changed, 6 insertions(+) > > diff --git a/configure b/configure > index 2a1d22310b..4262b96117 100755 > --- a/configure > +++ b/configure > @@ -244,6 +244,7 @@ External library support: >--enable-libjxl enable JPEG XL de/encoding via libjxl [no] >--enable-libklvanc enable Kernel Labs VANC processing [no] >--enable-libkvazaar enable HEVC encoding via libkvazaar [no] > + --enable-liblc3 enable LC3 de/encoding via liblc3 [no] >--enable-liblensfun enable lensfun lens correction [no] >--enable-libmodplug enable ModPlug via libmodplug [no] >--enable-libmp3lame enable MP3 encoding via libmp3lame [no] > @@ -1926,6 +1927,7 @@ EXTERNAL_LIBRARY_LIST=" > libjxl > libklvanc > libkvazaar > +liblc3 > libmodplug > libmp3lame > libmysofa > @@ -3499,6 +3501,9 @@ libilbc_encoder_deps="libilbc" > libjxl_decoder_deps="libjxl libjxl_threads" > libjxl_encoder_deps="libjxl libjxl_threads" > libkvazaar_encoder_deps="libkvazaar" > +liblc3_decoder_deps="liblc3" > +liblc3_encoder_deps="liblc3" > +liblc3_encoder_select="audio_frame_queue" > libmodplug_demuxer_deps="libmodplug" > libmp3lame_encoder_deps="libmp3lame" > libmp3lame_encoder_select="audio_frame_queue mpegaudioheader" > @@ -6869,6 +6874,7 @@ enabled libjxl&& require_pkg_config libjxl > "libjxl >= 0.7.0" jxl/dec > require_pkg_config libjxl_threads > "libjxl_threads >= 0.7.0" jxl/thread_parallel_runner.h JxlThreadParallelRunner > enabled libklvanc && require libklvanc libklvanc/vanc.h > klvanc_context_create -lklvanc > enabled libkvazaar&& require_pkg_config libkvazaar "kvazaar >= > 2.0.0" kvazaar.h kvz_api_get > +enabled liblc3&& require_pkg_config liblc3 "lc3 >= 1.1.0" lc3.h > lc3_hr_setup_encoder > enabled liblensfun&& require_pkg_config liblensfun lensfun lensfun.h > lf_db_create > > if enabled libmfx && enabled libvpl; then It would be better to merge this with the codec patch, looks good to me otherwise. ___ 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] libavformat/flac_picture: Don't return AVERROR_INVALIDDATA for errors with flac picture mimetype
On Wed, Mar 27, 2024 at 01:05:52PM -0700, Dale Curtis wrote: > Bump on this patch -- it still applies cleanly. We're still seeing files in > the wild like this. will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In a rich man's house there is no place to spit but his face. -- Diogenes of Sinope signature.asc Description: 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 7/7 v5] avcodec/hevcdec: export global side data in AVCodecContext
Signed-off-by: James Almer --- libavcodec/avcodec.h | 2 +- libavcodec/h2645_sei.c | 215 + libavcodec/h2645_sei.h | 2 + libavcodec/hevcdec.c | 4 + libavcodec/pthread_frame.c | 11 ++ 5 files changed, 141 insertions(+), 93 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 83dc487251..968009a192 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2071,7 +2071,7 @@ typedef struct AVCodecContext { * - encoding: may be set by user before calling avcodec_open2() for * encoder configuration. Afterwards owned and freed by the * encoder. - * - decoding: unused + * - decoding: may be set by libavcodec in avcodec_open2(). */ AVFrameSideData **decoded_side_data; int nb_decoded_side_data; diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c index afc103b69c..14a01c64d2 100644 --- a/libavcodec/h2645_sei.c +++ b/libavcodec/h2645_sei.c @@ -529,6 +529,120 @@ static int is_frame_packing_type_valid(SEIFpaType type, enum AVCodecID codec_id) type >= SEI_FPA_TYPE_SIDE_BY_SIDE; } +static int h2645_sei_to_side_data(AVCodecContext *avctx, H2645SEI *sei, + AVFrameSideData ***sd, int *nb_sd) +{ +int ret; + +for (unsigned i = 0; i < sei->unregistered.nb_buf_ref; i++) { +H2645SEIUnregistered *unreg = >unregistered; + +if (unreg->buf_ref[i]) { +AVFrameSideData *entry = av_frame_side_data_add(sd, nb_sd, +AV_FRAME_DATA_SEI_UNREGISTERED, +>buf_ref[i], 0); +if (!entry) +av_buffer_unref(>buf_ref[i]); +} +} +sei->unregistered.nb_buf_ref = 0; + +if (sei->ambient_viewing_environment.present) { +H2645SEIAmbientViewingEnvironment *env = +>ambient_viewing_environment; +AVBufferRef *buf; +size_t size; + +AVAmbientViewingEnvironment *dst_env = +av_ambient_viewing_environment_alloc(); +if (!dst_env) +return AVERROR(ENOMEM); + +buf = av_buffer_create((uint8_t *)dst_env, size, NULL, NULL, 0); +if (!buf) { +av_free(dst_env); +return AVERROR(ENOMEM); +} + +ret = ff_frame_new_side_data_from_buf_ext(avctx, sd, nb_sd, + AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT, ); + +if (ret < 0) +return ret; + +dst_env->ambient_illuminance = av_make_q(env->ambient_illuminance, 1); +dst_env->ambient_light_x = av_make_q(env->ambient_light_x, 5); +dst_env->ambient_light_y = av_make_q(env->ambient_light_y, 5); +} + +if (sei->mastering_display.present) { +// HEVC uses a g,b,r ordering, which we convert to a more natural r,g,b +const int mapping[3] = {2, 0, 1}; +const int chroma_den = 5; +const int luma_den = 1; +int i; +AVMasteringDisplayMetadata *metadata; + +ret = ff_decode_mastering_display_new_ext(avctx, sd, nb_sd, ); +if (ret < 0) +return ret; + +if (metadata) { +for (i = 0; i < 3; i++) { +const int j = mapping[i]; +metadata->display_primaries[i][0].num = sei->mastering_display.display_primaries[j][0]; +metadata->display_primaries[i][0].den = chroma_den; +metadata->display_primaries[i][1].num = sei->mastering_display.display_primaries[j][1]; +metadata->display_primaries[i][1].den = chroma_den; +} +metadata->white_point[0].num = sei->mastering_display.white_point[0]; +metadata->white_point[0].den = chroma_den; +metadata->white_point[1].num = sei->mastering_display.white_point[1]; +metadata->white_point[1].den = chroma_den; + +metadata->max_luminance.num = sei->mastering_display.max_luminance; +metadata->max_luminance.den = luma_den; +metadata->min_luminance.num = sei->mastering_display.min_luminance; +metadata->min_luminance.den = luma_den; +metadata->has_luminance = 1; +metadata->has_primaries = 1; + +av_log(avctx, AV_LOG_DEBUG, "Mastering Display Metadata:\n"); +av_log(avctx, AV_LOG_DEBUG, + "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f)\n", + av_q2d(metadata->display_primaries[0][0]), + av_q2d(metadata->display_primaries[0][1]), + av_q2d(metadata->display_primaries[1][0]), + av_q2d(metadata->display_primaries[1][1]), + av_q2d(metadata->display_primaries[2][0]), + av_q2d(metadata->display_primaries[2][1]), + av_q2d(metadata->white_point[0]),
[FFmpeg-devel] [PATCH 6/7 v5] avcodec/decode: add AVFrameSideData helper wrappers that don't depend on frames
They will be useful to fill arrays stored in other structs. Signed-off-by: James Almer --- libavcodec/decode.c | 106 libavcodec/decode.h | 24 ++ 2 files changed, 112 insertions(+), 18 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 34bcb7cc64..1f6c2a8dde 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1799,16 +1799,16 @@ int ff_decode_preinit(AVCodecContext *avctx) * @retval 0 side data of this type can be added to frame * @retval 1 side data of this type should not be added to frame */ -static int side_data_pref(const AVCodecContext *avctx, AVFrame *frame, - enum AVFrameSideDataType type) +static int side_data_pref(const AVCodecContext *avctx, AVFrameSideData ***sd, + int *nb_sd, enum AVFrameSideDataType type) { DecodeContext *dc = decode_ctx(avctx->internal); // Note: could be skipped for `type` without corresponding packet sd -if (av_frame_get_side_data(frame, type)) { +if (av_frame_side_data_get(*sd, *nb_sd, type)) { if (dc->side_data_pref_mask & (1ULL << type)) return 1; -av_frame_remove_side_data(frame, type); +av_frame_side_data_remove(sd, nb_sd, type); } return 0; @@ -1821,7 +1821,7 @@ int ff_frame_new_side_data(const AVCodecContext *avctx, AVFrame *frame, { AVFrameSideData *sd; -if (side_data_pref(avctx, frame, type)) { +if (side_data_pref(avctx, >side_data, >nb_side_data, type)) { if (psd) *psd = NULL; return 0; @@ -1834,34 +1834,71 @@ int ff_frame_new_side_data(const AVCodecContext *avctx, AVFrame *frame, return sd ? 0 : AVERROR(ENOMEM); } -int ff_frame_new_side_data_from_buf(const AVCodecContext *avctx, -AVFrame *frame, enum AVFrameSideDataType type, -AVBufferRef **buf, AVFrameSideData **psd) +int ff_frame_new_side_data_from_buf_ext(const AVCodecContext *avctx, +AVFrameSideData ***sd, int *nb_sd, +enum AVFrameSideDataType type, +AVBufferRef **buf) { -AVFrameSideData *sd = NULL; int ret = 0; -if (side_data_pref(avctx, frame, type)) +if (side_data_pref(avctx, sd, nb_sd, type)) goto finish; -sd = av_frame_new_side_data_from_buf(frame, type, *buf); -if (sd) -*buf = NULL; -else +if (!av_frame_side_data_add(sd, nb_sd, type, buf, 0)) ret = AVERROR(ENOMEM); finish: av_buffer_unref(buf); -if (psd) -*psd = sd; return ret; } +int ff_frame_new_side_data_from_buf(const AVCodecContext *avctx, +AVFrame *frame, enum AVFrameSideDataType type, +AVBufferRef **buf, AVFrameSideData **psd) +{ +return ff_frame_new_side_data_from_buf_ext(avctx, + >side_data, >nb_side_data, + type, buf); +} + +int ff_decode_mastering_display_new_ext(const AVCodecContext *avctx, +AVFrameSideData ***sd, int *nb_sd, +struct AVMasteringDisplayMetadata **mdm) +{ +AVBufferRef *buf; +size_t size; + +if (side_data_pref(avctx, sd, nb_sd, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA)) { +*mdm = NULL; +return 0; +} + +*mdm = av_mastering_display_metadata_alloc_size(); +if (!*mdm) +return AVERROR(ENOMEM); + +buf = av_buffer_create((uint8_t *)*mdm, size, NULL, NULL, 0); +if (!buf) { +av_freep(mdm); +return AVERROR(ENOMEM); +} + +if (!av_frame_side_data_add(sd, nb_sd, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA, +, 0)) { +*mdm = NULL; +av_buffer_unref(); +return AVERROR(ENOMEM); +} + +return 0; +} + int ff_decode_mastering_display_new(const AVCodecContext *avctx, AVFrame *frame, AVMasteringDisplayMetadata **mdm) { -if (side_data_pref(avctx, frame, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA)) { +if (side_data_pref(avctx, >side_data, >nb_side_data, + AV_FRAME_DATA_MASTERING_DISPLAY_METADATA)) { *mdm = NULL; return 0; } @@ -1870,10 +1907,43 @@ int ff_decode_mastering_display_new(const AVCodecContext *avctx, AVFrame *frame, return *mdm ? 0 : AVERROR(ENOMEM); } +int ff_decode_content_light_new_ext(const AVCodecContext *avctx, +AVFrameSideData ***sd, int *nb_sd, +AVContentLightMetadata **clm) +{ +AVBufferRef *buf; +size_t size; + +if (side_data_pref(avctx, sd, nb_sd, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL)) { +*clm = NULL; +
[FFmpeg-devel] [PATCH 5/7 v5] avutil/mastering_display_metadata: add a new allocator function that returns a size
av_mastering_display_metadata_alloc() is not useful in scenarios where you need to know the runtime size of AVMasteringDisplayMetadata. Signed-off-by: James Almer --- libavutil/mastering_display_metadata.c | 13 + libavutil/mastering_display_metadata.h | 9 + 2 files changed, 22 insertions(+) diff --git a/libavutil/mastering_display_metadata.c b/libavutil/mastering_display_metadata.c index 6069347617..ea41f13f9d 100644 --- a/libavutil/mastering_display_metadata.c +++ b/libavutil/mastering_display_metadata.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #include @@ -29,6 +30,18 @@ AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void) return av_mallocz(sizeof(AVMasteringDisplayMetadata)); } +AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc_size(size_t *size) +{ +AVMasteringDisplayMetadata *mastering = av_mallocz(sizeof(AVMasteringDisplayMetadata)); +if (!mastering) +return NULL; + +if (size) +*size = sizeof(*mastering); + +return mastering; +} + AVMasteringDisplayMetadata *av_mastering_display_metadata_create_side_data(AVFrame *frame) { AVFrameSideData *side_data = av_frame_new_side_data(frame, diff --git a/libavutil/mastering_display_metadata.h b/libavutil/mastering_display_metadata.h index c23b07c3cd..52fcef9e37 100644 --- a/libavutil/mastering_display_metadata.h +++ b/libavutil/mastering_display_metadata.h @@ -77,6 +77,15 @@ typedef struct AVMasteringDisplayMetadata { */ AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void); +/** + * Allocate an AVMasteringDisplayMetadata structure and set its fields to + * default values. The resulting struct can be freed using av_freep(). + * + * @return An AVMasteringDisplayMetadata filled with default values or NULL + * on failure. + */ +AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc_size(size_t *size); + /** * Allocate a complete AVMasteringDisplayMetadata and add it to the frame. * -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/7 v5] avutil/frame: add helper to remove side data of a given type from an array
Signed-off-by: James Almer --- libavutil/frame.c | 6 ++ libavutil/frame.h | 5 + 2 files changed, 11 insertions(+) diff --git a/libavutil/frame.c b/libavutil/frame.c index d37f1511e8..10b9f7fa94 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -937,6 +937,12 @@ const AVFrameSideData *av_frame_side_data_get_c(const AVFrameSideData * const *s return NULL; } +void av_frame_side_data_remove(AVFrameSideData ***sd, int *nb_sd, + enum AVFrameSideDataType type) +{ +remove_side_data(sd, nb_sd, type); +} + AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type) { diff --git a/libavutil/frame.h b/libavutil/frame.h index 4885600dce..68a2ad1555 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1149,6 +1149,11 @@ const AVFrameSideData *av_frame_side_data_get(AVFrameSideData * const *sd, nb_sd, type); } +/** + * Remove and free all side data instances of the given type from an array. + */ +void av_frame_side_data_remove(AVFrameSideData ***sd, int *nb_sd, + enum AVFrameSideDataType type); /** * @} */ -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/7 v5] avutil/frame: use the same data information as the source entry when cloning side data
src->{data,size} does not need to match src->buf->{data,size}. Signed-off-by: James Almer --- libavutil/frame.c | 30 -- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 9c3569db0e..d37f1511e8 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -741,16 +741,14 @@ AVBufferRef *av_frame_get_plane_buffer(const AVFrame *frame, int plane) return NULL; } -static AVFrameSideData *add_side_data_from_buf(AVFrameSideData ***sd, - int *nb_sd, - enum AVFrameSideDataType type, - AVBufferRef *buf) +static AVFrameSideData *add_side_data_from_buf_ext(AVFrameSideData ***sd, + int *nb_sd, + enum AVFrameSideDataType type, + AVBufferRef *buf, uint8_t *data, + size_t size) { AVFrameSideData *ret, **tmp; -if (!buf) -return NULL; - // *nb_sd + 1 needs to fit into an int and a size_t. if ((unsigned)*nb_sd >= FFMIN(INT_MAX, SIZE_MAX)) return NULL; @@ -765,8 +763,8 @@ static AVFrameSideData *add_side_data_from_buf(AVFrameSideData ***sd, return NULL; ret->buf = buf; -ret->data = ret->buf->data; -ret->size = buf->size; +ret->data = data; +ret->size = size; ret->type = type; (*sd)[(*nb_sd)++] = ret; @@ -774,6 +772,17 @@ static AVFrameSideData *add_side_data_from_buf(AVFrameSideData ***sd, return ret; } +static AVFrameSideData *add_side_data_from_buf(AVFrameSideData ***sd, + int *nb_sd, + enum AVFrameSideDataType type, + AVBufferRef *buf) +{ +if (!buf) +return NULL; + +return add_side_data_from_buf_ext(sd, nb_sd, type, buf, buf->data, buf->size); +} + AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef *buf) @@ -901,7 +910,8 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, if (!buf) return AVERROR(ENOMEM); -sd_dst = add_side_data_from_buf(sd, nb_sd, src->type, buf); +sd_dst = add_side_data_from_buf_ext(sd, nb_sd, src->type, buf, +src->data, src->size); if (!sd_dst) { av_buffer_unref(); return AVERROR(ENOMEM); -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/7 v5] avutil/frame: add a flag to allow overwritting existing entries
Enable it only for side data types that don't allow more than one entry. Signed-off-by: James Almer --- libavutil/frame.c | 59 +-- libavutil/frame.h | 30 +++- libavutil/tests/side_data_array.c | 52 +++ tests/ref/fate/side_data_array| 22 ++-- 4 files changed, 119 insertions(+), 44 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 87cc8450c8..9c3569db0e 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -795,15 +795,36 @@ AVFrameSideData *av_frame_new_side_data(AVFrame *frame, return ret; } +static AVFrameSideData *replace_side_data_from_buf(AVFrameSideData *dst, + AVBufferRef *buf, int flags) +{ +if (!(flags & AV_FRAME_SIDE_DATA_FLAG_REPLACE)) +return NULL; + +av_dict_free(>metadata); +dst->buf = buf; +dst->data = buf->data; +dst->size = buf->size; +return dst; +} + AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, size_t size, unsigned int flags) { +const AVSideDataDescriptor *desc = av_frame_side_data_desc(type); AVBufferRef *buf = av_buffer_alloc(size); AVFrameSideData *ret = NULL; if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) remove_side_data(sd, nb_sd, type); +if ((!desc || !(desc->props & AV_SIDE_DATA_PROP_MULTI)) && +(ret = (AVFrameSideData *)av_frame_side_data_get(*sd, *nb_sd, type))) { +ret = replace_side_data_from_buf(ret, buf, flags); +if (!ret) +av_buffer_unref(); +return ret; +} ret = add_side_data_from_buf(sd, nb_sd, type, buf); if (!ret) @@ -822,6 +843,13 @@ AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) remove_side_data(sd, nb_sd, type); +if ((!desc || !(desc->props & AV_SIDE_DATA_PROP_MULTI)) && +(sd_dst = (AVFrameSideData *)av_frame_side_data_get(*sd, *nb_sd, type))) { +sd_dst = replace_side_data_from_buf(sd_dst, buf, flags); +if (sd_dst) +*pbuf = NULL; +return sd_dst; +} sd_dst = add_side_data_from_buf(sd, nb_sd, type, buf); if (!sd_dst) @@ -834,6 +862,7 @@ AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, const AVFrameSideData *src, unsigned int flags) { +const AVSideDataDescriptor *desc; AVBufferRef *buf= NULL; AVFrameSideData *sd_dst = NULL; int ret= AVERROR_BUG; @@ -841,13 +870,37 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, if (!sd || !src || !nb_sd || (*nb_sd && !*sd)) return AVERROR(EINVAL); +desc = av_frame_side_data_desc(src->type); +if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) +remove_side_data(sd, nb_sd, src->type); +if ((!desc || !(desc->props & AV_SIDE_DATA_PROP_MULTI)) && +(sd_dst = (AVFrameSideData *)av_frame_side_data_get(*sd, *nb_sd, src->type))) { +AVDictionary *dict = NULL; + +if (!(flags & AV_FRAME_SIDE_DATA_FLAG_REPLACE)) +return AVERROR(EEXIST); + +ret = av_dict_copy(, src->metadata, 0); +if (ret < 0) +return ret; + +ret = av_buffer_replace(_dst->buf, src->buf); +if (ret < 0) { +av_dict_free(); +return ret; +} + +av_dict_free(_dst->metadata); +sd_dst->metadata = dict; +sd_dst->data = src->data; +sd_dst->size = src->size; +return 0; +} + buf = av_buffer_ref(src->buf); if (!buf) return AVERROR(ENOMEM); -if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) -remove_side_data(sd, nb_sd, src->type); - sd_dst = add_side_data_from_buf(sd, nb_sd, src->type, buf); if (!sd_dst) { av_buffer_unref(); diff --git a/libavutil/frame.h b/libavutil/frame.h index 8d16924432..4885600dce 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1040,7 +1040,15 @@ const AVSideDataDescriptor *av_frame_side_data_desc(enum AVFrameSideDataType typ */ void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd); +/** + * Remove existing entries before adding new ones. + */ #define AV_FRAME_SIDE_DATA_FLAG_UNIQUE (1 << 0) +/** + * Don't add a new entry if another of the same type exists. + * Applies only for side data types without the AV_SIDE_DATA_PROP_MULTI prop. + */ +#define AV_FRAME_SIDE_DATA_FLAG_REPLACE (1 << 1) /** * Add new side data entry to an array. @@ -1053,10 +1061,12 @@ void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd); * @param size size of the side data * @param flags Some combination of
[FFmpeg-devel] [PATCH 1/7 v5] avutil/frame: add helper for adding side data w/ AVBufferRef to array
Signed-off-by: James Almer --- libavutil/frame.c | 19 +++ libavutil/frame.h | 24 2 files changed, 43 insertions(+) diff --git a/libavutil/frame.c b/libavutil/frame.c index ef1613c344..87cc8450c8 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -812,6 +812,25 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, return ret; } +AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, +enum AVFrameSideDataType type, +AVBufferRef **pbuf, unsigned int flags) +{ +const AVSideDataDescriptor *desc = av_frame_side_data_desc(type); +AVFrameSideData *sd_dst = NULL; +AVBufferRef *buf = *pbuf; + +if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) +remove_side_data(sd, nb_sd, type); + +sd_dst = add_side_data_from_buf(sd, nb_sd, type, buf); +if (!sd_dst) +return NULL; + +*pbuf = NULL; +return sd_dst; +} + int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, const AVFrameSideData *src, unsigned int flags) { diff --git a/libavutil/frame.h b/libavutil/frame.h index 3b6d746a16..8d16924432 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1062,6 +1062,30 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, size_t size, unsigned int flags); +/** + * Add a new side data entry to an array from an existing AVBufferRef. + * + * @param sdpointer to array of side data to which to add another entry, + * or to NULL in order to start a new array. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. + * @param type type of the added side data + * @param buf Pointer to AVBufferRef to add to the array. On success, + * the function takes ownership of the AVBufferRef and *buf is + * set to NULL, unless AV_FRAME_SIDE_DATA_FLAG_NEW_REF is set + * in which case the ownership will remain with the caller. + * @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0. + * + * @return newly added side data on success, NULL on error. + * @note In case of AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of + * matching AVFrameSideDataType will be removed before the addition + * is attempted. + * + */ +AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, +enum AVFrameSideDataType type, +AVBufferRef **buf, unsigned int flags); + /** * Add a new side data entry to an array based on existing side data, taking * a reference towards the contained AVBufferRef. -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] fftools/ffplay: split filters & show modes cycling into separate keys
On 28 Mar 2024, at 17:46, Ondřej Fiala wrote: > Just want to make sure, since I am aware of some cases of large commercial > email > providers blocking my email provider... did anyone with a gmail address > receive > this patch? > Yes > Thanks, > Ondřej > > On Tue Mar 26, 2024 at 3:18 AM CET, Ondřej Fiala wrote: >> I am forwarding a patch from December that seems to have been overlooked. >> >> See the original threads in the archive: >> https://ffmpeg.org/pipermail/ffmpeg-devel/2023-December/318613.html >> https://ffmpeg.org/pipermail/ffmpeg-devel/2023-December/318654.html >> >> Forwarded message from Ondřej Fiala on Tue Dec 19, 2023 at 3:02 AM: >> --- >> It's annoying to have to go through the audio visualization modes when you >> just want to switch back-and-forth between two video filters. It also makes >> the code simpler. >> >> doc/ffplay.texi | 5 - >> fftools/ffplay.c | 10 -- >> 2 files changed, 8 insertions(+), 7 deletions(-) >> >> diff --git a/doc/ffplay.texi b/doc/ffplay.texi >> index 93f77eeece..91d138a974 100644 >> --- a/doc/ffplay.texi >> +++ b/doc/ffplay.texi >> @@ -241,8 +241,11 @@ Cycle subtitle channel in the current program. >> @item c >> Cycle program. >> >> +@item d >> +Cycle show modes. >> + >> @item w >> -Cycle video filters or show modes. >> +Cycle video filters. >> >> @item s >> Step to the next frame. >> diff --git a/fftools/ffplay.c b/fftools/ffplay.c >> index 873ee8cc74..2eb616a88a 100644 >> --- a/fftools/ffplay.c >> +++ b/fftools/ffplay.c >> @@ -3370,14 +3370,12 @@ static void event_loop(VideoState *cur_stream) >> case SDLK_t: >> stream_cycle_channel(cur_stream, AVMEDIA_TYPE_SUBTITLE); >> break; >> +case SDLK_d: >> +toggle_audio_display(cur_stream); >> +break; >> case SDLK_w: >> -if (cur_stream->show_mode == SHOW_MODE_VIDEO && >> cur_stream->vfilter_idx < nb_vfilters - 1) { >> -if (++cur_stream->vfilter_idx >= nb_vfilters) >> -cur_stream->vfilter_idx = 0; >> -} else { >> +if (++cur_stream->vfilter_idx >= nb_vfilters) >> cur_stream->vfilter_idx = 0; >> -toggle_audio_display(cur_stream); >> -} >> break; >> case SDLK_PAGEUP: >> if (cur_stream->ic->nb_chapters <= 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 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] Fwd: [PATCH] fftools/ffplay: split filters & show modes cycling into separate keys
Just want to make sure, since I am aware of some cases of large commercial email providers blocking my email provider... did anyone with a gmail address receive this patch? Thanks, Ondřej On Tue Mar 26, 2024 at 3:18 AM CET, Ondřej Fiala wrote: > I am forwarding a patch from December that seems to have been overlooked. > > See the original threads in the archive: > https://ffmpeg.org/pipermail/ffmpeg-devel/2023-December/318613.html > https://ffmpeg.org/pipermail/ffmpeg-devel/2023-December/318654.html > > Forwarded message from Ondřej Fiala on Tue Dec 19, 2023 at 3:02 AM: > --- > It's annoying to have to go through the audio visualization modes when you > just want to switch back-and-forth between two video filters. It also makes > the code simpler. > > doc/ffplay.texi | 5 - > fftools/ffplay.c | 10 -- > 2 files changed, 8 insertions(+), 7 deletions(-) > > diff --git a/doc/ffplay.texi b/doc/ffplay.texi > index 93f77eeece..91d138a974 100644 > --- a/doc/ffplay.texi > +++ b/doc/ffplay.texi > @@ -241,8 +241,11 @@ Cycle subtitle channel in the current program. > @item c > Cycle program. > > +@item d > +Cycle show modes. > + > @item w > -Cycle video filters or show modes. > +Cycle video filters. > > @item s > Step to the next frame. > diff --git a/fftools/ffplay.c b/fftools/ffplay.c > index 873ee8cc74..2eb616a88a 100644 > --- a/fftools/ffplay.c > +++ b/fftools/ffplay.c > @@ -3370,14 +3370,12 @@ static void event_loop(VideoState *cur_stream) > case SDLK_t: > stream_cycle_channel(cur_stream, AVMEDIA_TYPE_SUBTITLE); > break; > +case SDLK_d: > +toggle_audio_display(cur_stream); > +break; > case SDLK_w: > -if (cur_stream->show_mode == SHOW_MODE_VIDEO && > cur_stream->vfilter_idx < nb_vfilters - 1) { > -if (++cur_stream->vfilter_idx >= nb_vfilters) > -cur_stream->vfilter_idx = 0; > -} else { > +if (++cur_stream->vfilter_idx >= nb_vfilters) > cur_stream->vfilter_idx = 0; > -toggle_audio_display(cur_stream); > -} > break; > case SDLK_PAGEUP: > if (cur_stream->ic->nb_chapters <= 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 3/4] avformat/lc3: Add file format for LC3/LC3plus transport
I don't think it's "easy" seekable. We cannot move to an arbitrary position: - There is no start-code - The frame size can be variable (not generated by the proposed encoder implementation, but allowed). The only possibility I see is checking that the frame size looks valid for multiple frames. The range of valid frame sizes is large (20 to 625 Bytes), so I can only validate 6 bits for each 16 bits packet size read. This format is not really designed to be seekable. Do you think we will need it? On Thu, Mar 28, 2024 at 2:33 AM Paul B Mahol wrote: > This format actually supports seeking. > > The proposed solution here is sub-optimal. > > On Wed, Mar 27, 2024 at 11:22 PM Antoine Soulier via ffmpeg-devel < > ffmpeg-devel@ffmpeg.org> wrote: > >> A file format is described in Bluetooth SIG LC3 and ETSI TS 103 634, for >> test purpose. This is the format implemented here. >> >> Signed-off-by: Antoine Soulier >> --- >> doc/muxers.texi | 6 ++ >> libavformat/Makefile | 2 + >> libavformat/allformats.c | 2 + >> libavformat/lc3dec.c | 135 +++ >> libavformat/lc3enc.c | 102 + >> 5 files changed, 247 insertions(+) >> create mode 100644 libavformat/lc3dec.c >> create mode 100644 libavformat/lc3enc.c >> >> diff --git a/doc/muxers.texi b/doc/muxers.texi >> index a10a8e216f..9687746c30 100644 >> --- a/doc/muxers.texi >> +++ b/doc/muxers.texi >> @@ -2612,6 +2612,12 @@ WebDAV server every second: >> ffmpeg -f x11grab -framerate 1 -i :0.0 -q:v 6 -update 1 -protocol_opts >> method=PUT http://example.com/desktop.jpg >> @end example >> >> +@section lc3 >> +Bluetooth SIG Low Complexity Communication Codec audio (LC3), or >> +ETSI TS 103 634 Low Complexity Communication Codec plus (LC3plus). >> + >> +This muxer accepts a single @code{lc3} audio stream. >> + >> @section matroska >> >> Matroska container muxer. >> diff --git a/libavformat/Makefile b/libavformat/Makefile >> index 44aa485029..4961c42852 100644 >> --- a/libavformat/Makefile >> +++ b/libavformat/Makefile >> @@ -332,6 +332,8 @@ OBJS-$(CONFIG_KVAG_DEMUXER) += kvag.o >> OBJS-$(CONFIG_KVAG_MUXER)+= kvag.o rawenc.o >> OBJS-$(CONFIG_LAF_DEMUXER) += lafdec.o >> OBJS-$(CONFIG_LATM_MUXER)+= latmenc.o rawenc.o >> +OBJS-$(CONFIG_LC3_DEMUXER) += lc3dec.o >> +OBJS-$(CONFIG_LC3_MUXER) += lc3enc.o >> OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o >> OBJS-$(CONFIG_LOAS_DEMUXER) += loasdec.o rawdec.o >> OBJS-$(CONFIG_LUODAT_DEMUXER)+= luodatdec.o >> diff --git a/libavformat/allformats.c b/libavformat/allformats.c >> index e15d0fa6d7..e225354faf 100644 >> --- a/libavformat/allformats.c >> +++ b/libavformat/allformats.c >> @@ -252,6 +252,8 @@ extern const FFInputFormat ff_kvag_demuxer; >> extern const FFOutputFormat ff_kvag_muxer; >> extern const FFInputFormat ff_laf_demuxer; >> extern const FFOutputFormat ff_latm_muxer; >> +extern const FFInputFormat ff_lc3_demuxer; >> +extern const FFOutputFormat ff_lc3_muxer; >> extern const FFInputFormat ff_lmlm4_demuxer; >> extern const FFInputFormat ff_loas_demuxer; >> extern const FFInputFormat ff_luodat_demuxer; >> diff --git a/libavformat/lc3dec.c b/libavformat/lc3dec.c >> new file mode 100644 >> index 00..9ca9825f1b >> --- /dev/null >> +++ b/libavformat/lc3dec.c >> @@ -0,0 +1,135 @@ >> +/* >> + * LC3 demuxer >> + * Copyright (C) 2024 Antoine Soulier >> + * >> + * This file is part of FFmpeg. >> + * >> + * FFmpeg is free software; you can redistribute it and/or >> + * modify it under the terms of the GNU Lesser General Public >> + * License as published by the Free Software Foundation; either >> + * version 2.1 of the License, or (at your option) any later version. >> + * >> + * FFmpeg is distributed in the hope that it will be useful, >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >> + * Lesser General Public License for more details. >> + * >> + * You should have received a copy of the GNU Lesser General Public >> + * License along with FFmpeg; if not, write to the Free Software >> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA >> 02110-1301 USA >> + */ >> + >> +/** >> + * @file >> + * Based on the file format specified by : >> + * >> + * - Bluetooth SIG - Low Complexity Communication Codec Test Suite >> + * >> https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=502301 >> + * 3.2.8.2 Reference LC3 Codec Bitstream Format >> + * >> + * - ETSI TI 103 634 V1.4.1 - Low Complexity Communication Codec plus >> + * >> https://www.etsi.org/deliver/etsi_ts/103600_103699/103634/01.04.01_60/ts_103634v010401p.pdf >> + * LC3plus conformance script package >> + */ >> + >> +#include "libavcodec/packet.h" >> +#include "libavutil/intreadwrite.h" >> + >> +#include "avformat.h" >>
Re: [FFmpeg-devel] [PATCH] avformat/dvdvideodec: remove `if ((ret = ...) < 0)` pattern
Thanks all for the feedback. I think I took the idea too literally here, and agree in retrospect it’s not necessary at this point. The good news is while I made this change, I didn’t find any pre-existing bugs in this demuxer due to using the pattern. (Because while I was writing it, I had made the mistake a few times and was able to correct them :D) I think we can skip this and if it becomes an issue down the line I’ll make the changes surgically. Going forward for my own contributions, I’ll avoid the pattern unless it truly offers readability gain. Apologies for the inconvenience. Best, Marth64 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 1/6] avcodec/mpeg12dec: extract only one type of CC substream
>Is it not possible to extract all of them simultaneously? Each of the extractable CC bitstreams would need to be exposed as an independent eia608 AVStream, because each represents a distinct stream. They can’t be commingled (which is what this patch addressed). I’m not sure of a way to sanely present multiple eia608 streams to the end user. AVStreamGroup gives me hope for the future, but I can’t think of a technique in present day. This is because: as it stands now the only way I know of to open a context on an mpeg2/h26x source with an eia608 AVStream exposed is via the lavfi movie=in[out+subcc] technique - but that only exposes one stream. I guess the subcc keyword in the filter can be expanded to expose multiple bitstreams, even via AVStreamGroup, but user would have to be aware and opt-in. Otherwise it could get confusing. How would the user easily know which bitstreams are in the source file? We can probe this to some extent, but what if the eia608 bytes don’t show until halfway through the source? Open to ideas, thoughts, as I’m gathering my own on this in a notebook over the past few weeks. Respectfully, Marth64 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 8/8] avcodec/dovi_rpu: attach ext blocks to frames
On Sat, 23 Mar 2024 20:19:57 +0100 Niklas Haas wrote: > From: Niklas Haas > > --- > libavcodec/dovi_rpu.c | 5 - > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/dovi_rpu.c b/libavcodec/dovi_rpu.c > index b3defd87bda..2b4d2b470c2 100644 > --- a/libavcodec/dovi_rpu.c > +++ b/libavcodec/dovi_rpu.c > @@ -94,7 +94,7 @@ int ff_dovi_attach_side_data(DOVIContext *s, AVFrame *frame) > AVFrameSideData *sd; > AVBufferRef *buf; > AVDOVIMetadata *dovi; > -size_t dovi_size; > +size_t dovi_size, ext_sz; > > if (!s->mapping || !s->color) > return 0; /* incomplete dovi metadata */ > @@ -120,6 +120,9 @@ int ff_dovi_attach_side_data(DOVIContext *s, AVFrame > *frame) > COPY(AVDOVIRpuDataHeader, av_dovi_get_header(dovi), >header, > disable_residual_flag); > COPY(AVDOVIDataMapping, av_dovi_get_mapping(dovi), s->mapping, > nlq_pivots); > COPY(AVDOVIColorMetadata, av_dovi_get_color(dovi), s->color, > source_diagonal); > +ext_sz = FFMIN(sizeof(AVDOVIDmData), dovi->ext_block_size); > +for (int i = 0; i < s->num_ext_blocks; i++) > +memcpy(av_dovi_get_ext(dovi, i), >ext_blocks[i], ext_sz); Forgot to set dovi->num_ext_blocks = s->num_ext_blocks, fixed. > return 0; > } > > -- > 2.44.0 > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lavc/videotoolboxenc: add MJPEG support
gnattu via ffmpeg-devel: > For example: > ./ffmpeg -hwaccel videotoolbox\ >-i INPUT -c:v mjpeg_videotoolbox\ > out.mp4 > > This encoder does not have many options and can only use ``-q:v` to control > quality. > > Signed-off-by: Gnattu OC > --- > Changelog| 1 + > configure| 2 ++ > libavcodec/Makefile | 1 + > libavcodec/allcodecs.c | 1 + > libavcodec/videotoolboxenc.c | 39 +--- > 5 files changed, 41 insertions(+), 3 deletions(-) > > diff --git a/Changelog b/Changelog > index e83a00e35c..b73a44f9ad 100644 > --- a/Changelog > +++ b/Changelog > @@ -38,6 +38,7 @@ version 7.0: > - ffplay with hwaccel decoding support (depends on vulkan renderer via > libplacebo) > - dnn filter libtorch backend > - Android content URIs protocol > +- VideoToolbox MJPEG encoder > > > version 6.1: > diff --git a/configure b/configure > index 2a1d22310b..52a0ee762f 100755 > --- a/configure > +++ b/configure > @@ -3474,6 +3474,8 @@ hevc_videotoolbox_encoder_deps="pthreads" > hevc_videotoolbox_encoder_select="atsc_a53 videotoolbox_encoder" > prores_videotoolbox_encoder_deps="pthreads" > prores_videotoolbox_encoder_select="videotoolbox_encoder" > +mjpeg_videotoolbox_encoder_deps="pthreads" > +mjpeg_videotoolbox_encoder_select="videotoolbox_encoder" > libaom_av1_decoder_deps="libaom" > libaom_av1_encoder_deps="libaom" > libaom_av1_encoder_select="extract_extradata_bsf" > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index 9ce6d445c1..f59b2ae691 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -503,6 +503,7 @@ OBJS-$(CONFIG_MJPEGB_DECODER) += mjpegbdec.o > OBJS-$(CONFIG_MJPEG_CUVID_DECODER) += cuviddec.o > OBJS-$(CONFIG_MJPEG_QSV_ENCODER) += qsvenc_jpeg.o > OBJS-$(CONFIG_MJPEG_VAAPI_ENCODER) += vaapi_encode_mjpeg.o > +OBJS-$(CONFIG_MJPEG_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o > OBJS-$(CONFIG_MLP_DECODER) += mlpdec.o mlpdsp.o > OBJS-$(CONFIG_MLP_ENCODER) += mlpenc.o mlp.o > OBJS-$(CONFIG_MMVIDEO_DECODER) += mmvideo.o > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c > index 2386b450a6..f8a90fdca2 100644 > --- a/libavcodec/allcodecs.c > +++ b/libavcodec/allcodecs.c > @@ -879,6 +879,7 @@ extern const FFCodec ff_mpeg4_mediacodec_encoder; > extern const FFCodec ff_mpeg4_omx_encoder; > extern const FFCodec ff_mpeg4_v4l2m2m_encoder; > extern const FFCodec ff_prores_videotoolbox_encoder; > +extern const FFCodec ff_mjpeg_videotoolbox_encoder; > extern const FFCodec ff_vc1_cuvid_decoder; > extern const FFCodec ff_vp8_cuvid_decoder; > extern const FFCodec ff_vp8_mediacodec_decoder; > diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c > index 15c34d59c3..0574edab56 100644 > --- a/libavcodec/videotoolboxenc.c > +++ b/libavcodec/videotoolboxenc.c > @@ -547,6 +547,7 @@ static CMVideoCodecType get_cm_codec_type(AVCodecContext > *avctx, > else > return MKBETAG('a','p','c','n'); // > kCMVideoCodecType_AppleProRes422 > } > +case AV_CODEC_ID_MJPEG: return kCMVideoCodecType_JPEG; > default: return 0; > } > } > @@ -1233,7 +1234,7 @@ static int vtenc_create_encoder(AVCodecContext *avctx, >kVTCompressionPropertyKey_Quality, >quality_num); > CFRelease(quality_num); > -} else if (avctx->codec_id != AV_CODEC_ID_PRORES) { > +} else if (avctx->codec_id != AV_CODEC_ID_PRORES && avctx->codec_id != > AV_CODEC_ID_MJPEG) { > bit_rate_num = CFNumberCreate(kCFAllocatorDefault, >kCFNumberSInt32Type, >_rate); > @@ -1347,7 +1348,7 @@ static int vtenc_create_encoder(AVCodecContext *avctx, > } > } > > -if (avctx->gop_size > 0 && avctx->codec_id != AV_CODEC_ID_PRORES) { > +if (avctx->gop_size > 0 && avctx->codec_id != AV_CODEC_ID_PRORES && > avctx->codec_id != AV_CODEC_ID_MJPEG) { > CFNumberRef interval = CFNumberCreate(kCFAllocatorDefault, >kCFNumberIntType, >>gop_size); > @@ -1496,7 +1497,7 @@ static int vtenc_create_encoder(AVCodecContext *avctx, > } > } > > -if (!vtctx->has_b_frames && avctx->codec_id != AV_CODEC_ID_PRORES) { > +if (!vtctx->has_b_frames && avctx->codec_id != AV_CODEC_ID_PRORES && > avctx->codec_id != AV_CODEC_ID_MJPEG) { > status = VTSessionSetProperty(vtctx->session, > > kVTCompressionPropertyKey_AllowFrameReordering, >kCFBooleanFalse); > @@ -2844,6 +2845,13 @@ static const enum AVPixelFormat prores_pix_fmts[] = { > AV_PIX_FMT_NONE > }; > > +static const enum AVPixelFormat mjpeg_pix_fmts[] = { >
[FFmpeg-devel] [PATCH v11 6/8] libavformat/webp: add WebP demuxer
From: Josef Zlomek Adds the demuxer of animated WebP files. It supports non-animated, animated, truncated, and concatenated files. Reading from a pipe (and other non-seekable inputs) is also supported. The WebP demuxer splits the input stream into packets containing one frame. It also marks the key frames properly. The loop count is ignored by default (same behaviour as animated PNG and GIF), it may be enabled by the option '-ignore_loop 0'. The frame rate is set according to the frame delay in the ANMF chunk. If the delay is too low, or the image is not animated, the default frame rate is set to 10 fps, similarly to other WebP libraries and browsers. The fate suite was updated accordingly. Signed-off-by: Josef Zlomek --- Changelog | 1 + doc/demuxers.texi | 28 ++ libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/version.h | 2 +- libavformat/webpdec.c | 383 ++ tests/ref/fate/exif-image-webp| 4 +- tests/ref/fate/webp-rgb-lena-lossless | 2 +- tests/ref/fate/webp-rgb-lena-lossless-rgb24 | 2 +- tests/ref/fate/webp-rgb-lossless | 2 +- .../fate/webp-rgb-lossless-palette-predictor | 2 +- tests/ref/fate/webp-rgb-lossy-q80 | 2 +- tests/ref/fate/webp-rgba-lossless | 2 +- tests/ref/fate/webp-rgba-lossy-q80| 2 +- 14 files changed, 424 insertions(+), 10 deletions(-) create mode 100644 libavformat/webpdec.c diff --git a/Changelog b/Changelog index bafa56dc2a..d91e9df577 100644 --- a/Changelog +++ b/Changelog @@ -78,6 +78,7 @@ version 6.1: variable-fields elements within the same parent element - ffprobe -output_format option added as an alias of -of - animated WebP decoder +- animated WebP demuxer version 6.0: diff --git a/doc/demuxers.texi b/doc/demuxers.texi index b70f3a38d7..64c9c8c215 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -1128,4 +1128,32 @@ this is set to 0, which means that a sensible value is chosen based on the input format. @end table +@section webp + +Animated WebP demuxer. + +It accepts the following options: + +@table @option +@item -min_delay @var{int} +Set the minimum valid delay between frames in milliseconds. +Range is 0 to 6. Default value is 10. + +@item -max_webp_delay @var{int} +Set the maximum valid delay between frames in milliseconds. +Range is 0 to 16777215. Default value is 16777215 (over four hours), +the maximum value allowed by the specification. + +@item -default_delay @var{int} +Set the default delay between frames in milliseconds. +Range is 0 to 6. Default value is 100. + +@item -ignore_loop @var{bool} +WebP files can contain information to loop a certain number of times +(or infinitely). If @option{ignore_loop} is set to true, then the loop +setting from the input will be ignored and looping will not occur. +If set to false, then looping will occur and will cycle the number +of times according to the WebP. Default value is true. +@end table + @c man end DEMUXERS diff --git a/libavformat/Makefile b/libavformat/Makefile index 44aa485029..cede2920e5 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -625,6 +625,7 @@ OBJS-$(CONFIG_WEBM_MUXER)+= matroskaenc.o matroska.o \ av1.o avlanguage.o OBJS-$(CONFIG_WEBM_DASH_MANIFEST_MUXER) += webmdashenc.o OBJS-$(CONFIG_WEBM_CHUNK_MUXER) += webm_chunk.o +OBJS-$(CONFIG_WEBP_DEMUXER) += webpdec.o OBJS-$(CONFIG_WEBP_MUXER)+= webpenc.o OBJS-$(CONFIG_WEBVTT_DEMUXER)+= webvttdec.o subtitles.o OBJS-$(CONFIG_WEBVTT_MUXER) += webvttenc.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 9df42bb87a..c1febf0b04 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -508,6 +508,7 @@ extern const FFInputFormat ff_webm_dash_manifest_demuxer; extern const FFOutputFormat ff_webm_dash_manifest_muxer; extern const FFOutputFormat ff_webm_chunk_muxer; extern const FFOutputFormat ff_webp_muxer; +extern const FFInputFormat ff_webp_demuxer; extern const FFInputFormat ff_webvtt_demuxer; extern const FFOutputFormat ff_webvtt_muxer; extern const FFInputFormat ff_wsaud_demuxer; diff --git a/libavformat/version.h b/libavformat/version.h index 904e7f06aa..21042d998f 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ #include "version_major.h" #define LIBAVFORMAT_VERSION_MINOR 2 -#define LIBAVFORMAT_VERSION_MICRO 100 +#define LIBAVFORMAT_VERSION_MICRO 101 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ diff --git a/libavformat/webpdec.c b/libavformat/webpdec.c new file mode 100644 index
[FFmpeg-devel] [PATCH v11 8/8] avcodec/webp: export XMP metadata
--- libavcodec/webp.c | 42 -- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/libavcodec/webp.c b/libavcodec/webp.c index 832ede52fc..b9feaa5bf0 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -38,8 +38,8 @@ * @author Josef Zlomek, Pexeso Inc. * Animation * - * Unimplemented: - * - XMP metadata + * @author Thilo Borgmann + * XMP metadata */ #include "libavutil/imgutils.h" @@ -216,6 +216,7 @@ typedef struct WebPContext { int alpha_data_size;/* alpha chunk data size */ int has_exif; /* set after an EXIF chunk has been processed */ int has_iccp; /* set after an ICCP chunk has been processed */ +int has_xmp;/* set after an XMP chunk has been processed */ int width; /* image width */ int height; /* image height */ int vp8x_flags; /* global flags from VP8X chunk */ @@ -1463,6 +1464,7 @@ static int webp_decode_frame_common(AVCodecContext *avctx, uint8_t *data, int si // reset metadata bit for each packet s->has_exif = 0; s->has_iccp = 0; +s->has_xmp = 0; while (bytestream2_get_bytes_left() > 8) { char chunk_str[5] = { 0 }; @@ -1494,6 +1496,7 @@ static int webp_decode_frame_common(AVCodecContext *avctx, uint8_t *data, int si s->canvas_height = 0; s->has_exif = 0; s->has_iccp = 0; +s->has_xmp = 0; ff_thread_release_ext_buffer(>canvas_frame); break; case MKTAG('V', 'P', '8', ' '): @@ -1679,12 +1682,39 @@ exif_end: } s->vp8x_flags |= VP8X_FLAG_ANIMATION; break; -case MKTAG('X', 'M', 'P', ' '): -AV_WL32(chunk_str, chunk_type); -av_log(avctx, AV_LOG_WARNING, "skipping unsupported chunk: %s\n", - chunk_str); +case MKTAG('X', 'M', 'P', ' '): { +GetByteContext xmp_gb; +AVDictionary **xmp_metadata = NULL; +uint8_t *buffer; +int xmp_offset = bytestream2_tell(); + +if (s->has_xmp) { +av_log(avctx, AV_LOG_VERBOSE, "Ignoring extra XMP chunk\n"); +goto xmp_end; +} +if (!(s->vp8x_flags & VP8X_FLAG_XMP_METADATA)) +av_log(avctx, AV_LOG_WARNING, + "XMP chunk present, but XMP bit not set in the " + "VP8X header\n"); + +// there are at least chunk_size bytes left to read +buffer = av_malloc(chunk_size + 1); +if (!buffer) { +return AVERROR(ENOMEM); +} + +s->has_xmp = 1; +bytestream2_init(_gb, data + xmp_offset, size - xmp_offset); +bytestream2_get_buffer(_gb, buffer, chunk_size); +buffer[chunk_size] = '\0'; + +xmp_metadata = (s->vp8x_flags & VP8X_FLAG_ANIMATION) ? >metadata : >frame->metadata; +av_dict_set(xmp_metadata, "xmp", buffer, AV_DICT_DONT_STRDUP_VAL); + +xmp_end: bytestream2_skip(, chunk_size); break; +} default: AV_WL32(chunk_str, chunk_type); av_log(avctx, AV_LOG_VERBOSE, "skipping unknown chunk: %s\n", -- 2.39.3 (Apple Git-146) ___ 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 v11 4/8] libavcodec/webp: add support for animated WebP
From: Josef Zlomek Fixes: 4907 Adds support for decoding of animated WebP. The WebP decoder adds the animation related features according to the specs: https://developers.google.com/speed/webp/docs/riff_container#animation The frames of the animation may be smaller than the image canvas. Therefore, the frame is decoded to a temporary frame, then it is blended into the canvas, the canvas is copied to the output frame, and finally the frame is disposed from the canvas. The output to AV_PIX_FMT_YUVA420P/AV_PIX_FMT_YUV420P is still supported. The background color is specified only as BGRA in the WebP file so it is converted to YUVA if YUV formats are output. Signed-off-by: Josef Zlomek --- Changelog | 1 + libavcodec/codec_desc.c | 3 +- libavcodec/version.h| 2 +- libavcodec/webp.c | 710 4 files changed, 653 insertions(+), 63 deletions(-) diff --git a/Changelog b/Changelog index e83a00e35c..bafa56dc2a 100644 --- a/Changelog +++ b/Changelog @@ -77,6 +77,7 @@ version 6.1: - ffprobe XML output schema changed to account for multiple variable-fields elements within the same parent element - ffprobe -output_format option added as an alias of -of +- animated WebP decoder version 6.0: diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 3bab86db62..b017acbc74 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1259,8 +1259,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .type = AVMEDIA_TYPE_VIDEO, .name = "webp", .long_name = NULL_IF_CONFIG_SMALL("WebP"), -.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY | - AV_CODEC_PROP_LOSSLESS, +.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS, .mime_types= MT("image/webp"), }, { diff --git a/libavcodec/version.h b/libavcodec/version.h index 06631ffa8c..789d9047c2 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -30,7 +30,7 @@ #include "version_major.h" #define LIBAVCODEC_VERSION_MINOR 4 -#define LIBAVCODEC_VERSION_MICRO 100 +#define LIBAVCODEC_VERSION_MICRO 101 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/libavcodec/webp.c b/libavcodec/webp.c index d6af48585e..293bb485de 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -35,12 +35,15 @@ * Exif metadata * ICC profile * + * @author Josef Zlomek, Pexeso Inc. + * Animation + * * Unimplemented: - * - Animation * - XMP metadata */ #include "libavutil/imgutils.h" +#include "libavutil/colorspace.h" #define BITSTREAM_READER_LE #include "avcodec.h" @@ -67,6 +70,14 @@ #define NUM_SHORT_DISTANCES 120 #define MAX_HUFFMAN_CODE_LENGTH 15 +#define ANMF_DISPOSAL_METHOD0x01 +#define ANMF_DISPOSAL_METHOD_UNCHANGED 0x00 +#define ANMF_DISPOSAL_METHOD_BACKGROUND 0x01 + +#define ANMF_BLENDING_METHOD0x02 +#define ANMF_BLENDING_METHOD_ALPHA 0x00 +#define ANMF_BLENDING_METHOD_OVERWRITE 0x02 + static const uint16_t alphabet_sizes[HUFFMAN_CODES_PER_META_CODE] = { NUM_LITERAL_CODES + NUM_LENGTH_CODES, NUM_LITERAL_CODES, NUM_LITERAL_CODES, NUM_LITERAL_CODES, @@ -191,6 +202,8 @@ typedef struct ImageContext { typedef struct WebPContext { VP8Context v; /* VP8 Context used for lossy decoding */ GetBitContext gb; /* bitstream reader for main image chunk */ +ThreadFrame canvas_frame; /* ThreadFrame for canvas */ +AVFrame *frame; /* AVFrame for decoded frame */ AVFrame *alpha_frame; /* AVFrame for alpha data decompressed from VP8L */ AVPacket *pkt; /* AVPacket to be passed to the underlying VP8 decoder */ AVCodecContext *avctx; /* parent AVCodecContext */ @@ -205,7 +218,22 @@ typedef struct WebPContext { int has_iccp; /* set after an ICCP chunk has been processed */ int width; /* image width */ int height; /* image height */ -int lossless; /* indicates lossless or lossy */ +int vp8x_flags; /* global flags from VP8X chunk */ +int canvas_width; /* canvas width */ +int canvas_height; /* canvas height */ +int anmf_flags; /* frame flags from ANMF chunk */ +int pos_x; /* frame position X */ +int pos_y; /* frame position Y */ +int prev_anmf_flags;/* previous frame flags from ANMF chunk */ +int prev_width; /* previous frame width */ +int prev_height;/* previous frame height */ +int prev_pos_x;
[FFmpeg-devel] [PATCH v11 5/8] avcodec/webp: make init_canvas_frame static
--- libavcodec/webp.c | 142 +++--- 1 file changed, 70 insertions(+), 72 deletions(-) diff --git a/libavcodec/webp.c b/libavcodec/webp.c index 293bb485de..832ede52fc 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -1379,7 +1379,76 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p, return ret; } -int init_canvas_frame(WebPContext *s, int format, int key_frame); +static int init_canvas_frame(WebPContext *s, int format, int key_frame) +{ +AVFrame *canvas = s->canvas_frame.f; +int height; +int ret; + +// canvas is needed only for animation +if (!(s->vp8x_flags & VP8X_FLAG_ANIMATION)) +return 0; + +// avoid init for non-key frames whose format and size did not change +if (!key_frame && +canvas->data[0] && +canvas->format == format && +canvas->width == s->canvas_width && +canvas->height == s->canvas_height) +return 0; + +// canvas changes within IPPP sequences will lose thread sync +// because of the ThreadFrame reallocation and will wait forever +// so if frame-threading is used, forbid canvas changes and unlock +// previous frames +if (!key_frame && canvas->data[0]) { +if (s->avctx->thread_count > 1) { +av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The output will be damaged. Use -threads 1 to try decoding with best effort.\n"); +// unlock previous frames that have sent an _await() call +ff_thread_report_progress(>canvas_frame, INT_MAX, 0); +return AVERROR_PATCHWELCOME; +} else { +// warn for damaged frames +av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The output will be damaged.\n"); +} +} + +s->avctx->pix_fmt = format; +canvas->format= format; +canvas->width = s->canvas_width; +canvas->height= s->canvas_height; + +// VP8 decoder changed the width and height in AVCodecContext. +// Change it back to the canvas size. +ret = ff_set_dimensions(s->avctx, s->canvas_width, s->canvas_height); +if (ret < 0) +return ret; + +ff_thread_release_ext_buffer(>canvas_frame); +ret = ff_thread_get_ext_buffer(s->avctx, >canvas_frame, AV_GET_BUFFER_FLAG_REF); +if (ret < 0) +return ret; + +if (canvas->format == AV_PIX_FMT_ARGB) { +height = canvas->height; +memset(canvas->data[0], 0, height * canvas->linesize[0]); +} else /* if (canvas->format == AV_PIX_FMT_YUVA420P) */ { +const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(canvas->format); +for (int comp = 0; comp < desc->nb_components; comp++) { +int plane = desc->comp[comp].plane; + +if (comp == 1 || comp == 2) +height = AV_CEIL_RSHIFT(canvas->height, desc->log2_chroma_h); +else +height = FFALIGN(canvas->height, 1 << desc->log2_chroma_h); + +memset(canvas->data[plane], s->transparent_yuva[plane], + height * canvas->linesize[plane]); +} +} + +return 0; +} static int webp_decode_frame_common(AVCodecContext *avctx, uint8_t *data, int size, int *got_frame, int key_frame, AVFrame *p) @@ -1628,77 +1697,6 @@ exif_end: return size; } -int init_canvas_frame(WebPContext *s, int format, int key_frame) -{ -AVFrame *canvas = s->canvas_frame.f; -int height; -int ret; - -// canvas is needed only for animation -if (!(s->vp8x_flags & VP8X_FLAG_ANIMATION)) -return 0; - -// avoid init for non-key frames whose format and size did not change -if (!key_frame && -canvas->data[0] && -canvas->format == format && -canvas->width == s->canvas_width && -canvas->height == s->canvas_height) -return 0; - -// canvas changes within IPPP sequences will loose thread sync -// because of the ThreadFrame reallocation and will wait forever -// so if frame-threading is used, forbid canvas changes and unlock -// previous frames -if (!key_frame && canvas->data[0]) { -if (s->avctx->thread_count > 1) { -av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The output will be damaged. Use -threads 1 to try decoding with best effort.\n"); -// unlock previous frames that have sent an _await() call -ff_thread_report_progress(>canvas_frame, INT_MAX, 0); -return AVERROR_PATCHWELCOME; -} else { -// warn for damaged frames -av_log(s->avctx, AV_LOG_WARNING, "Canvas change detected. The output will be damaged.\n"); -} -} - -s->avctx->pix_fmt = format; -canvas->format= format; -canvas->width = s->canvas_width; -canvas->height= s->canvas_height; - -// VP8 decoder changed the width and height in AVCodecContext. -// Change it
[FFmpeg-devel] [PATCH v11 3/8] avcodec/bsf: Add awebp2webp bitstream filter
Splits a packet containing a webp animations into one non-compliant packet per frame of the animation. Skips RIFF and WEBP chunks for those packets except for the first. Copyies ICC, EXIF and XMP chunks first into each of the packets except for the first. --- configure | 1 + libavcodec/bitstream_filters.c | 1 + libavcodec/bsf/Makefile| 1 + libavcodec/bsf/awebp2webp.c| 350 + 4 files changed, 353 insertions(+) create mode 100644 libavcodec/bsf/awebp2webp.c diff --git a/configure b/configure index 2d46ef0b9c..91813a41cd 100755 --- a/configure +++ b/configure @@ -3418,6 +3418,7 @@ aac_adtstoasc_bsf_select="adts_header mpeg4audio" av1_frame_merge_bsf_select="cbs_av1" av1_frame_split_bsf_select="cbs_av1" av1_metadata_bsf_select="cbs_av1" +awebp2webp_bsf_select="" dts2pts_bsf_select="cbs_h264 h264parse" eac3_core_bsf_select="ac3_parser" evc_frame_merge_bsf_select="evcparse" diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c index 12860c332b..af88283a8c 100644 --- a/libavcodec/bitstream_filters.c +++ b/libavcodec/bitstream_filters.c @@ -28,6 +28,7 @@ extern const FFBitStreamFilter ff_aac_adtstoasc_bsf; extern const FFBitStreamFilter ff_av1_frame_merge_bsf; extern const FFBitStreamFilter ff_av1_frame_split_bsf; extern const FFBitStreamFilter ff_av1_metadata_bsf; +extern const FFBitStreamFilter ff_awebp2webp_bsf; extern const FFBitStreamFilter ff_chomp_bsf; extern const FFBitStreamFilter ff_dump_extradata_bsf; extern const FFBitStreamFilter ff_dca_core_bsf; diff --git a/libavcodec/bsf/Makefile b/libavcodec/bsf/Makefile index fb70ad0c21..48c67dd210 100644 --- a/libavcodec/bsf/Makefile +++ b/libavcodec/bsf/Makefile @@ -5,6 +5,7 @@ OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += bsf/aac_adtstoasc.o OBJS-$(CONFIG_AV1_FRAME_MERGE_BSF)+= bsf/av1_frame_merge.o OBJS-$(CONFIG_AV1_FRAME_SPLIT_BSF)+= bsf/av1_frame_split.o OBJS-$(CONFIG_AV1_METADATA_BSF) += bsf/av1_metadata.o +OBJS-$(CONFIG_AWEBP2WEBP_BSF) += bsf/awebp2webp.o OBJS-$(CONFIG_CHOMP_BSF) += bsf/chomp.o OBJS-$(CONFIG_DCA_CORE_BSF) += bsf/dca_core.o OBJS-$(CONFIG_DTS2PTS_BSF)+= bsf/dts2pts.o diff --git a/libavcodec/bsf/awebp2webp.c b/libavcodec/bsf/awebp2webp.c new file mode 100644 index 00..ebd123c667 --- /dev/null +++ b/libavcodec/bsf/awebp2webp.c @@ -0,0 +1,350 @@ +/* + * Animated WebP into non-compliant WebP bitstream filter + * Copyright (c) 2024 Thilo Borgmann + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Animated WebP into non-compliant WebP bitstream filter + * Splits a packet containing a webp animations into + * one non-compliant packet per frame of the animation. + * Skips RIFF and WEBP chunks for those packets except + * for the first. Copyies ICC, EXIF and XMP chunks first + * into each of the packets except for the first. + * @author Thilo Borgmann + */ + +#include +#include + +#include "codec_id.h" +#include "bytestream.h" +#include "libavutil/error.h" + +#include "bsf.h" +#include "bsf_internal.h" +#include "packet.h" + +#define VP8X_FLAG_ANIMATION 0x02 +#define VP8X_FLAG_XMP_METADATA 0x04 +#define VP8X_FLAG_EXIF_METADATA 0x08 +#define VP8X_FLAG_ALPHA 0x10 +#define VP8X_FLAG_ICC 0x20 + +typedef struct WEBPBSFContext { +const AVClass *class; +GetByteContext gb; + +AVPacket *last_pkt; +uint8_t *last_iccp; +uint8_t *last_exif; +uint8_t *last_xmp; + +int iccp_size; +int exif_size; +int xmp_size; + +int add_iccp; +int add_exif; +int add_xmp; + +uint64_t last_pts; +} WEBPBSFContext; + +static int save_chunk(WEBPBSFContext *ctx, uint8_t **buf, int *buf_size, uint32_t chunk_size) +{ +if (*buf || !buf_size || !chunk_size) +return 0; + +*buf = av_malloc(chunk_size + 8); +if (!*buf) +return AVERROR(ENOMEM); + +*buf_size = chunk_size + 8; + +bytestream2_seek(>gb, -8, SEEK_CUR); +bytestream2_get_buffer(>gb, *buf, chunk_size + 8); + +return 0; +} + +static int awebp2webp_filter(AVBSFContext *ctx, AVPacket *out) +{ +WEBPBSFContext *s = ctx->priv_data;
[FFmpeg-devel] [PATCH v11 2/8] avcodec/webp: separate VP8 decoding
--- libavcodec/webp.c | 50 +-- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/libavcodec/webp.c b/libavcodec/webp.c index 2301699e5a..d6af48585e 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -194,6 +194,7 @@ typedef struct WebPContext { AVFrame *alpha_frame; /* AVFrame for alpha data decompressed from VP8L */ AVPacket *pkt; /* AVPacket to be passed to the underlying VP8 decoder */ AVCodecContext *avctx; /* parent AVCodecContext */ +AVCodecContext *avctx_vp8; /* wrapper context for VP8 decoder */ int initialized;/* set once the VP8 context is initialized */ int has_alpha; /* has a separate alpha chunk */ enum AlphaCompression alpha_compression; /* compression type for alpha chunk */ @@ -1298,12 +1299,13 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p, int ret; if (!s->initialized) { -ff_vp8_decode_init(avctx); +VP8Context *s_vp8 = s->avctx_vp8->priv_data; +s_vp8->actually_webp = 1; s->initialized = 1; -s->v.actually_webp = 1; } avctx->pix_fmt = s->has_alpha ? AV_PIX_FMT_YUVA420P : AV_PIX_FMT_YUV420P; s->lossless = 0; +s->avctx_vp8->pix_fmt = avctx->pix_fmt; if (data_size > INT_MAX) { av_log(avctx, AV_LOG_ERROR, "unsupported chunk size\n"); @@ -1314,14 +1316,32 @@ static int vp8_lossy_decode_frame(AVCodecContext *avctx, AVFrame *p, s->pkt->data = data_start; s->pkt->size = data_size; -ret = ff_vp8_decode_frame(avctx, p, got_frame, s->pkt); -if (ret < 0) +ret = avcodec_send_packet(s->avctx_vp8, s->pkt); +if (ret < 0) { +av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for decoding\n"); return ret; +} -if (!*got_frame) +ret = avcodec_receive_frame(s->avctx_vp8, p); +if (ret < 0) { +av_log(avctx, AV_LOG_ERROR, "VP8 decoding error: %s.\n", av_err2str(ret)); return AVERROR_INVALIDDATA; +} + +ret = ff_decode_frame_props(avctx, p); +if (ret < 0) { +return ret; +} + +if (!p->private_ref) { +ret = ff_attach_decode_data(p); +if (ret < 0) { +return ret; +} +} -update_canvas_size(avctx, avctx->width, avctx->height); +*got_frame = 1; +update_canvas_size(avctx, s->avctx_vp8->width, s->avctx_vp8->height); if (s->has_alpha) { ret = vp8_lossy_decode_alpha(avctx, p, s->alpha_data, @@ -1538,11 +1558,28 @@ exif_end: static av_cold int webp_decode_init(AVCodecContext *avctx) { WebPContext *s = avctx->priv_data; +int ret; +const AVCodec *codec; s->pkt = av_packet_alloc(); if (!s->pkt) return AVERROR(ENOMEM); + +/* Prepare everything needed for VP8 decoding */ +codec = avcodec_find_decoder(AV_CODEC_ID_VP8); +if (!codec) +return AVERROR_BUG; +s->avctx_vp8 = avcodec_alloc_context3(codec); +if (!s->avctx_vp8) +return AVERROR(ENOMEM); +s->avctx_vp8->flags = avctx->flags; +s->avctx_vp8->flags2 = avctx->flags2; +s->avctx_vp8->pix_fmt = avctx->pix_fmt; +ret = avcodec_open2(s->avctx_vp8, codec, NULL); +if (ret < 0) { +return ret; +} return 0; } @@ -1551,6 +1588,7 @@ static av_cold int webp_decode_close(AVCodecContext *avctx) WebPContext *s = avctx->priv_data; av_packet_free(>pkt); +avcodec_free_context(>avctx_vp8); if (s->initialized) return ff_vp8_decode_free(avctx); -- 2.39.3 (Apple Git-146) ___ 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 v11 7/8] fate: add test for animated WebP
--- tests/fate/image.mak | 3 +++ tests/ref/fate/webp-anim | 22 ++ 2 files changed, 25 insertions(+) create mode 100644 tests/ref/fate/webp-anim diff --git a/tests/fate/image.mak b/tests/fate/image.mak index 7c0e0fec08..4620d65b3f 100644 --- a/tests/fate/image.mak +++ b/tests/fate/image.mak @@ -566,6 +566,9 @@ fate-webp-rgb-lossy-q80: CMD = framecrc -i $(TARGET_SAMPLES)/webp/rgb_q80.webp FATE_WEBP += fate-webp-rgba-lossy-q80 fate-webp-rgba-lossy-q80: CMD = framecrc -i $(TARGET_SAMPLES)/webp/rgba_q80.webp +FATE_WEBP += fate-webp-anim +fate-webp-anim: CMD = framecrc -i $(TARGET_SAMPLES)/webp/130227-100431-6817p.webp + FATE_WEBP-$(call DEMDEC, IMAGE2, WEBP) += $(FATE_WEBP) FATE_IMAGE_FRAMECRC += $(FATE_WEBP-yes) fate-webp: $(FATE_WEBP-yes) diff --git a/tests/ref/fate/webp-anim b/tests/ref/fate/webp-anim new file mode 100644 index 00..f0d3f1a88f --- /dev/null +++ b/tests/ref/fate/webp-anim @@ -0,0 +1,22 @@ +#tb 0: 1/1000 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 100x70 +#sar 0: 0/1 +0, 0, 0, 80,28000, 0x2023ba6e +0, 80, 80, 80,28000, 0x4292b778 +0,160,160, 80,28000, 0x1c972ef1 +0,240,240, 80,28000, 0xa98d8d04 +0,320,320, 80,28000, 0xd323b6af +0,400,400, 80,28000, 0x508aba99 +0,480,480, 80,28000, 0x5c672dda +0,560,560, 80,28000, 0xc8961ebb +0,640,640, 1000,28000, 0x82460e1b +0, 1640, 1640, 80,28000, 0x3debbfc9 +0, 1720, 1720, 80,28000, 0x427ab31f +0, 1800, 1800, 80,28000, 0x6bbdec2e +0, 1880, 1880, 80,28000, 0x5690b56b +0, 1960, 1960, 80,28000, 0xb62963f3 +0, 2040, 2040, 80,28000, 0x68dd37b2 +0, 2120, 2120, 80,28000, 0x465c47d2 +0, 2200, 2200,1,28000, 0xa92033df -- 2.39.3 (Apple Git-146) ___ 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 v11 0/8] webp: add support for animated WebP decoding
VP8 decoder decoupled again The whole animated sequence goes into one packet The (currently public) bitstream filter splits animations up into non-conformant packets Now with XMP metadata support (as string, like MOV) Patch 5/8 is still there for making changes in lavc/webp reviewable but shall be stashed when pushing. -Thilo Josef Zlomek (2): libavcodec/webp: add support for animated WebP libavformat/webp: add WebP demuxer Thilo Borgmann (6): avcodec/webp: remove unused definitions avcodec/webp: separate VP8 decoding avcodec/bsf: Add awebp2webp bitstream filter avcodec/webp: make init_canvas_frame static fate: add test for animated WebP avcodec/webp: export XMP metadata Changelog | 2 + configure | 1 + doc/demuxers.texi | 28 + libavcodec/bitstream_filters.c| 1 + libavcodec/bsf/Makefile | 1 + libavcodec/bsf/awebp2webp.c | 350 libavcodec/codec_desc.c | 3 +- libavcodec/version.h | 2 +- libavcodec/webp.c | 796 -- libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/version.h | 2 +- libavformat/webpdec.c | 383 + tests/fate/image.mak | 3 + tests/ref/fate/exif-image-webp| 4 +- tests/ref/fate/webp-anim | 22 + tests/ref/fate/webp-rgb-lena-lossless | 2 +- tests/ref/fate/webp-rgb-lena-lossless-rgb24 | 2 +- tests/ref/fate/webp-rgb-lossless | 2 +- .../fate/webp-rgb-lossless-palette-predictor | 2 +- tests/ref/fate/webp-rgb-lossy-q80 | 2 +- tests/ref/fate/webp-rgba-lossless | 2 +- tests/ref/fate/webp-rgba-lossy-q80| 2 +- 23 files changed, 1530 insertions(+), 84 deletions(-) create mode 100644 libavcodec/bsf/awebp2webp.c create mode 100644 libavformat/webpdec.c create mode 100644 tests/ref/fate/webp-anim -- 2.39.3 (Apple Git-146) ___ 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 v11 1/8] avcodec/webp: remove unused definitions
--- libavcodec/webp.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/webp.c b/libavcodec/webp.c index 9308ea2b69..2301699e5a 100644 --- a/libavcodec/webp.c +++ b/libavcodec/webp.c @@ -59,8 +59,6 @@ #define VP8X_FLAG_ALPHA 0x10 #define VP8X_FLAG_ICC 0x20 -#define MAX_PALETTE_SIZE256 -#define MAX_CACHE_BITS 11 #define NUM_CODE_LENGTH_CODES 19 #define HUFFMAN_CODES_PER_META_CODE 5 #define NUM_LITERAL_CODES 256 -- 2.39.3 (Apple Git-146) ___ 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 2/7 v4] avutil/frame: add helper for adding side data w/ AVBufferRef to array
On 3/28/2024 9:19 AM, Anton Khirnov wrote: Quoting James Almer (2024-03-28 12:49:08) On 3/28/2024 8:27 AM, Anton Khirnov wrote: Quoting James Almer (2024-03-28 04:12:05) Signed-off-by: James Almer --- libavutil/frame.c | 53 +++ libavutil/frame.h | 34 ++ 2 files changed, 87 insertions(+) diff --git a/libavutil/frame.c b/libavutil/frame.c index d9bd19b2aa..a165e56a64 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -834,6 +834,59 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, return ret; } +AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, +enum AVFrameSideDataType type, +AVBufferRef **pbuf, unsigned int flags) +{ +const AVSideDataDescriptor *desc = av_frame_side_data_desc(type); +AVFrameSideData *sd_dst = NULL; +AVBufferRef *buf; + +if (!sd || !pbuf || !*pbuf || !nb_sd || (*nb_sd && !*sd)) Overzealous checks like these tend to hide bugs. Any of these conditions being false means the caller is insane and we should crash. I'll remove some, but others simplify the code below (like knowing beforehand that *pbuf is not NULL). You can just assume them all to be true. Or use av_assert0(). diff --git a/libavutil/frame.h b/libavutil/frame.h index 2ea129888e..3e5d170a5b 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1048,6 +1048,10 @@ void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd); * Don't add a new entry if another of the same type exists. */ #define AV_FRAME_SIDE_DATA_FLAG_REPLACE (1 << 1) +/** + * Create a new reference instead of taking ownership of the passed in one. + */ +#define AV_FRAME_SIDE_DATA_FLAG_NEW_REF (1 << 2) Who needs this? Someone who wants to keep the reference around, like when attaching a buffer to several outputs (global to individual output frames). Is that a common enough use case to warrant this flag? It complicates the code quite substantially. And if you're making some side data instance global, what is the point of also attaching it to frames? To pass it to API that does not handle global entries, like currently happens with filtergraphs. I can remove the flag for now in any case. It can be added later trivially. ___ 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] avcodec/hevc_ps: fix the problem of memcmp losing effectiveness
>From: ffmpeg-devel On Behalf Of >Hendrik Leppkes >Sent: Thursday, March 28, 2024 5:43 PM >To: FFmpeg development discussions and patches de...@ffmpeg.org> >Subject: Re: [FFmpeg-devel] [PATCH] avcodec/hevc_ps: fix the problem of >memcmp losing effectiveness > >On Thu, Mar 28, 2024 at 10:12 AM >wrote: >> >> From: Tong Wu >> >> HEVCHdrParams* receives a pointer which points to a dynamically >> allocated memory block. It causes the memcmp always returning 1. >> Add a function to do the comparision. A condition is also added to >> avoid malloc(0). >> >> Signed-off-by: Tong Wu > >I've been looking into some playback glitches after >456c8ebe7c7dcd766d36cd0296815d89fd1166b5 and I can confirm that this >patch fixes those as well. > >Using the fixed position of the *hdr member and its offset seems a bit >icky though, and _at least_ could use a comment so future changes keep >it last. Comment is added to the header. Thanks, Tong ___ 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/hevc_ps: fix the problem of memcmp losing effectiveness
From: Tong Wu HEVCHdrParams* receives a pointer which points to a dynamically allocated memory block. It causes the memcmp always returning 1. Add a function to do the comparision. A condition is also added to avoid malloc(0). Signed-off-by: Tong Wu --- libavcodec/hevc_ps.c | 20 libavcodec/hevc_ps.h | 4 +++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index cbef3ef4cd..8b3a27a17c 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -449,6 +449,16 @@ static void uninit_vps(FFRefStructOpaque opaque, void *obj) av_freep(>hdr); } +static int compare_vps(const HEVCVPS *vps1, const HEVCVPS *vps2) +{ +if ((!vps1->hdr && !vps2->hdr) || +(vps1->hdr && vps2->hdr && !memcmp(vps1->hdr, vps2->hdr, sizeof(*vps1->hdr { +return !memcmp(vps1, vps2, offsetof(HEVCVPS, hdr)); +} + +return 0; +} + int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps) { @@ -545,9 +555,11 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx, goto err; } -vps->hdr = av_calloc(vps->vps_num_hrd_parameters, sizeof(*vps->hdr)); -if (!vps->hdr) -goto err; +if (vps->vps_num_hrd_parameters) { +vps->hdr = av_calloc(vps->vps_num_hrd_parameters, sizeof(*vps->hdr)); +if (!vps->hdr) +goto err; +} for (i = 0; i < vps->vps_num_hrd_parameters; i++) { int common_inf_present = 1; @@ -569,7 +581,7 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx, } if (ps->vps_list[vps_id] && -!memcmp(ps->vps_list[vps_id], vps, sizeof(*vps))) { +compare_vps(ps->vps_list[vps_id], vps)) { ff_refstruct_unref(); } else { remove_vps(ps, vps_id); diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h index cc75aeb8d3..0d8eaf2b3e 100644 --- a/libavcodec/hevc_ps.h +++ b/libavcodec/hevc_ps.h @@ -153,7 +153,6 @@ typedef struct PTL { typedef struct HEVCVPS { unsigned int vps_id; -HEVCHdrParams *hdr; uint8_t vps_temporal_id_nesting_flag; int vps_max_layers; @@ -175,6 +174,9 @@ typedef struct HEVCVPS { uint8_t data[4096]; int data_size; +/* Put this at the end of the structure to make it easier to calculate the + * size before this pointer, which is used for memcmp */ +HEVCHdrParams *hdr; } HEVCVPS; typedef struct ScalingList { -- 2.41.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 0/8] Dolby Vision extension block parsing
On Sat, 23 Mar 2024 20:19:49 +0100 Niklas Haas wrote: > Changes since v1: > - Rebased onto master > - Dropped av_dovi_metadata_alloc_ext(), instead statically allocate > space for 32 extension blocks (AV_DOVI_MAX_EXT_BLOCKS) > - Removed misleading comment on nlq_pivots > - Fix memory leak on ff_dovi_ctx_flush() > - Switch to using ff_refstruct to properly manage ext_block lifetime > - Properly attach parsed extension blocks to the frame side data > - Avoid UB on get_cie_xy > - Validate num_ext_blocks > - Added commit fixing incorrect return code on invalid data > - Removed redundant extra init_get_bits8 > - Reorderd fields to avoid unnecessary padding Ping, any further comments / objections? > > ___ > 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 1/7 v4] avutil/frame: add a flag to allow overwritting existing entries
On 3/28/2024 9:21 AM, Anton Khirnov wrote: Quoting James Almer (2024-03-28 12:41:40) On 3/28/2024 8:23 AM, Anton Khirnov wrote: Quoting James Almer (2024-03-28 04:12:04) Enable it only for side data types that don't allow more than one entry. Signed-off-by: James Almer --- libavutil/frame.c | 59 --- libavutil/frame.h | 27 +- libavutil/tests/side_data_array.c | 52 +++ tests/ref/fate/side_data_array| 22 ++-- 4 files changed, 115 insertions(+), 45 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index ef1613c344..d9bd19b2aa 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -799,12 +799,34 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, size_t size, unsigned int flags) { -AVBufferRef *buf = av_buffer_alloc(size); +const AVSideDataDescriptor *desc = av_frame_side_data_desc(type); +AVBufferRef *buf; AVFrameSideData *ret = NULL; if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) remove_side_data(sd, nb_sd, type); +if (!desc || !(desc->props & AV_SIDE_DATA_PROP_MULTI)) { desc == NULL means type is invalid This being a generic alloc function, it should IMO not be limited to currently defined types. And I chose to treat them as non multi, as that's the most common scenario. Andreas argued in the thread adding descriptors that side data type without a descriptor is invalid and should explode. I tend to agree. I agree with that when you're handling side data that comes from something like a filter or similar modules within our libraries, as that'd be a bug. But this is the public core API for side data, and i don't see a reason why we should fail if the caller does av_frame_side_data_new(, _sd, 1000, 1, 0);. We never did before, and doing it now feels wrong. ___ 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] avfilter: fix YUV colorspace negotiation for YUVJ
On Mon, 25 Mar 2024 16:10:55 +0100 Niklas Haas wrote: > On Mon, 25 Mar 2024 14:40:44 +0100 Niklas Haas wrote: > > From: Niklas Haas > > > > Ironically, despite being introduced to make YUVJ unnecessary, the new > > YUV negotiation logic failed to actually negotiate YUVJ formats > > themselves correctly, leading to errors when passing YUVJ frames into > > a filter graph. (They were effectively treated like RGB or Grayscale > > formats, rather than as forced-full-range YUV, and hence did not have > > their colorspace matrix correctly negotiated) > > > > Fix this by splitting off the YUVJ check from ff_fmt_is_regular_yuv(). > > Obviously, we can trivially undo this change again once YUVJ is actually > > deleted from the codebase. > > Breaks FATE, I will investigate. This breakage was already fixed by another series of commits I had on a different branch, which were themselves dependent on the new AVCodec API. (Specifically, those commits that enable ffmpeg_enc.c to propagate the desired output color range back up the filter graph, as well as the FATE fix to properly tag rawvideo tiles) It may make more sense to just focus on merging that one first, then. ___ 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/mfenc: expose more properties of the media foundation encoder
Thank you for the notes, here is a new patch that incorporates your suggestions. You are right, the default value of 12 for gop_size is suprising, I didn't know about it before now. --- libavcodec/mf_utils.h | 5 + libavcodec/mfenc.c| 33 +++-- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/libavcodec/mf_utils.h b/libavcodec/mf_utils.h index aebfb9ad21..387c005f38 100644 --- a/libavcodec/mf_utils.h +++ b/libavcodec/mf_utils.h @@ -97,6 +97,11 @@ DEFINE_GUID(ff_CODECAPI_AVEncH264CABACEnable,0xee6cad62, 0xd305, 0x4248, 0xa DEFINE_GUID(ff_CODECAPI_AVEncVideoForceKeyFrame, 0x398c1b98, 0x8353, 0x475a, 0x9e, 0xf2, 0x8f, 0x26, 0x5d, 0x26, 0x3, 0x45); DEFINE_GUID(ff_CODECAPI_AVEncMPVDefaultBPictureCount, 0x8d390aac, 0xdc5c, 0x4200, 0xb5, 0x7f, 0x81, 0x4d, 0x04, 0xba, 0xba, 0xb2); DEFINE_GUID(ff_CODECAPI_AVScenarioInfo, 0xb28a6e64,0x3ff9,0x446a,0x8a,0x4b,0x0d,0x7a,0x53,0x41,0x32,0x36); +DEFINE_GUID(ff_CODECAPI_AVEncCommonBufferSize, 0x0db96574, 0xb6a4, 0x4c8b, 0x81, 0x06, 0x37, 0x73, 0xde, 0x03, 0x10, 0xcd); +DEFINE_GUID(ff_CODECAPI_AVEncCommonMaxBitRate, 0x9651eae4, 0x39b9, 0x4ebf, 0x85, 0xef, 0xd7, 0xf4, 0x44, 0xec, 0x74, 0x65); +DEFINE_GUID(ff_CODECAPI_AVEncCommonQualityVsSpeed, 0x98332df8, 0x03cd, 0x476b, 0x89, 0xfa, 0x3f, 0x9e, 0x44, 0x2d, 0xec, 0x9f); +DEFINE_GUID(ff_CODECAPI_AVEncMPVGOPSize, 0x95f31b26, 0x95a4, 0x41aa, 0x93, 0x03, 0x24, 0x6a, 0x7f, 0xc6, 0xee, 0xf1); +DEFINE_GUID(ff_CODECAPI_AVEncVideoEncodeQP, 0x2cb5696b, 0x23fb, 0x4ce1, 0xa0, 0xf9, 0xef, 0x5b, 0x90, 0xfd, 0x55, 0xca); DEFINE_GUID(ff_MF_SA_D3D11_BINDFLAGS, 0xeacf97ad, 0x065c, 0x4408, 0xbe, 0xe3, 0xfd, 0xcb, 0xfd, 0x12, 0x8b, 0xe2); DEFINE_GUID(ff_MF_SA_D3D11_USAGE, 0xe85fe442, 0x2ca3, 0x486e, 0xa9, 0xc7, 0x10, 0x9d, 0xda, 0x60, 0x98, 0x80); diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c index 9225692c51..cad531bd7d 100644 --- a/libavcodec/mfenc.c +++ b/libavcodec/mfenc.c @@ -695,6 +695,21 @@ FF_ENABLE_DEPRECATION_WARNINGS if (c->opt_enc_quality >= 0) ICodecAPI_SetValue(c->codec_api, _CODECAPI_AVEncCommonQuality, FF_VAL_VT_UI4(c->opt_enc_quality)); +if (avctx->rc_max_rate > 0) +ICodecAPI_SetValue(c->codec_api, _CODECAPI_AVEncCommonMaxBitRate, FF_VAL_VT_UI4(avctx->rc_max_rate)); + +if (avctx->gop_size > 0) +ICodecAPI_SetValue(c->codec_api, _CODECAPI_AVEncMPVGOPSize, FF_VAL_VT_UI4(avctx->gop_size)); + +if(avctx->rc_buffer_size > 0) +ICodecAPI_SetValue(c->codec_api, _CODECAPI_AVEncCommonBufferSize, FF_VAL_VT_UI4(avctx->rc_buffer_size)); + +if(avctx->compression_level >= 0) +ICodecAPI_SetValue(c->codec_api, _CODECAPI_AVEncCommonQualityVsSpeed, FF_VAL_VT_UI4(avctx->compression_level)); + +if(avctx->global_quality > 0) +ICodecAPI_SetValue(c->codec_api, _CODECAPI_AVEncVideoEncodeQP, FF_VAL_VT_UI4(avctx->global_quality )); + // Always set the number of b-frames. Qualcomm's HEVC encoder on SD835 // defaults this to 1, and that setting is buggy with many of the // rate control modes. (0 or 2 b-frames works fine with most rate @@ -1223,7 +1238,7 @@ static int mf_init(AVCodecContext *avctx) #define OFFSET(x) offsetof(MFContext, x) -#define MF_ENCODER(MEDIATYPE, NAME, ID, OPTS, FMTS, CAPS) \ +#define MF_ENCODER(MEDIATYPE, NAME, ID, OPTS, FMTS, CAPS, DEFAULTS) \ static const AVClass ff_ ## NAME ## _mf_encoder_class = { \ .class_name = #NAME "_mf", \ .item_name = av_default_item_name, \ @@ -1243,6 +1258,7 @@ static int mf_init(AVCodecContext *avctx) FMTS \ CAPS \ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, \ + .defaults = DEFAULTS, \ }; #define AFMTS \ @@ -1252,9 +1268,9 @@ static int mf_init(AVCodecContext *avctx) .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID | \ AV_CODEC_CAP_DR1 | AV_CODEC_CAP_VARIABLE_FRAME_SIZE, -MF_ENCODER(AUDIO, aac, AAC, NULL, AFMTS, ACAPS); -MF_ENCODER(AUDIO, ac3, AC3, NULL, AFMTS, ACAPS); -MF_ENCODER(AUDIO, mp3, MP3, NULL, AFMTS, ACAPS); +MF_ENCODER(AUDIO, aac, AAC, NULL, AFMTS, ACAPS, NULL); +MF_ENCODER(AUDIO, ac3, AC3, NULL, AFMTS, ACAPS, NULL); +MF_ENCODER(AUDIO, mp3, MP3, NULL, AFMTS, ACAPS, NULL); #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption venc_opts[] = { @@ -1283,6 +1299,11 @@ static const AVOption venc_opts[] = { {NULL} }; +static const FFCodecDefault defaults[] = { +{ "g", "0" }, +{ NULL }, +}; + #define VFMTS \
Re: [FFmpeg-devel] [PATCH 1/7 v4] avutil/frame: add a flag to allow overwritting existing entries
Quoting James Almer (2024-03-28 12:41:40) > On 3/28/2024 8:23 AM, Anton Khirnov wrote: > > Quoting James Almer (2024-03-28 04:12:04) > >> Enable it only for side data types that don't allow more than one entry. > >> > >> Signed-off-by: James Almer > >> --- > >> libavutil/frame.c | 59 --- > >> libavutil/frame.h | 27 +- > >> libavutil/tests/side_data_array.c | 52 +++ > >> tests/ref/fate/side_data_array| 22 ++-- > >> 4 files changed, 115 insertions(+), 45 deletions(-) > >> > >> diff --git a/libavutil/frame.c b/libavutil/frame.c > >> index ef1613c344..d9bd19b2aa 100644 > >> --- a/libavutil/frame.c > >> +++ b/libavutil/frame.c > >> @@ -799,12 +799,34 @@ AVFrameSideData > >> *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, > >> enum AVFrameSideDataType type, > >> size_t size, unsigned int flags) > >> { > >> -AVBufferRef *buf = av_buffer_alloc(size); > >> +const AVSideDataDescriptor *desc = av_frame_side_data_desc(type); > >> +AVBufferRef *buf; > >> AVFrameSideData *ret = NULL; > >> > >> if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) > >> remove_side_data(sd, nb_sd, type); > >> +if (!desc || !(desc->props & AV_SIDE_DATA_PROP_MULTI)) { > > > > desc == NULL means type is invalid > > This being a generic alloc function, it should IMO not be limited to > currently defined types. And I chose to treat them as non multi, as > that's the most common scenario. Andreas argued in the thread adding descriptors that side data type without a descriptor is invalid and should explode. I tend to agree. -- 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] [PATCH 2/7 v4] avutil/frame: add helper for adding side data w/ AVBufferRef to array
Quoting James Almer (2024-03-28 12:49:08) > On 3/28/2024 8:27 AM, Anton Khirnov wrote: > > Quoting James Almer (2024-03-28 04:12:05) > >> Signed-off-by: James Almer > >> --- > >> libavutil/frame.c | 53 +++ > >> libavutil/frame.h | 34 ++ > >> 2 files changed, 87 insertions(+) > >> > >> diff --git a/libavutil/frame.c b/libavutil/frame.c > >> index d9bd19b2aa..a165e56a64 100644 > >> --- a/libavutil/frame.c > >> +++ b/libavutil/frame.c > >> @@ -834,6 +834,59 @@ AVFrameSideData > >> *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, > >> return ret; > >> } > >> > >> +AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, > >> +enum AVFrameSideDataType type, > >> +AVBufferRef **pbuf, unsigned int > >> flags) > >> +{ > >> +const AVSideDataDescriptor *desc = av_frame_side_data_desc(type); > >> +AVFrameSideData *sd_dst = NULL; > >> +AVBufferRef *buf; > >> + > >> +if (!sd || !pbuf || !*pbuf || !nb_sd || (*nb_sd && !*sd)) > > > > Overzealous checks like these tend to hide bugs. Any of these conditions > > being false means the caller is insane and we should crash. > > I'll remove some, but others simplify the code below (like knowing > beforehand that *pbuf is not NULL). You can just assume them all to be true. Or use av_assert0(). > >> diff --git a/libavutil/frame.h b/libavutil/frame.h > >> index 2ea129888e..3e5d170a5b 100644 > >> --- a/libavutil/frame.h > >> +++ b/libavutil/frame.h > >> @@ -1048,6 +1048,10 @@ void av_frame_side_data_free(AVFrameSideData ***sd, > >> int *nb_sd); > >>* Don't add a new entry if another of the same type exists. > >>*/ > >> #define AV_FRAME_SIDE_DATA_FLAG_REPLACE (1 << 1) > >> +/** > >> + * Create a new reference instead of taking ownership of the passed in > >> one. > >> + */ > >> +#define AV_FRAME_SIDE_DATA_FLAG_NEW_REF (1 << 2) > > > > Who needs this? > > Someone who wants to keep the reference around, like when attaching a > buffer to several outputs (global to individual output frames). Is that a common enough use case to warrant this flag? It complicates the code quite substantially. And if you're making some side data instance global, what is the point of also attaching it to frames? -- 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] [PATCH 2/7 v4] avutil/frame: add helper for adding side data w/ AVBufferRef to array
On 3/28/2024 8:27 AM, Anton Khirnov wrote: Quoting James Almer (2024-03-28 04:12:05) Signed-off-by: James Almer --- libavutil/frame.c | 53 +++ libavutil/frame.h | 34 ++ 2 files changed, 87 insertions(+) diff --git a/libavutil/frame.c b/libavutil/frame.c index d9bd19b2aa..a165e56a64 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -834,6 +834,59 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, return ret; } +AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, +enum AVFrameSideDataType type, +AVBufferRef **pbuf, unsigned int flags) +{ +const AVSideDataDescriptor *desc = av_frame_side_data_desc(type); +AVFrameSideData *sd_dst = NULL; +AVBufferRef *buf; + +if (!sd || !pbuf || !*pbuf || !nb_sd || (*nb_sd && !*sd)) Overzealous checks like these tend to hide bugs. Any of these conditions being false means the caller is insane and we should crash. I'll remove some, but others simplify the code below (like knowing beforehand that *pbuf is not NULL). +return NULL; + +if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) +remove_side_data(sd, nb_sd, type); +if (!desc || !(desc->props & AV_SIDE_DATA_PROP_MULTI)) { +for (int i = 0; i < *nb_sd; i++) { +AVFrameSideData *entry = ((*sd)[i]); + +if (entry->type != type) +continue; +if (!(flags & AV_FRAME_SIDE_DATA_FLAG_REPLACE)) +return NULL; + +buf = *pbuf; +if (flags & AV_FRAME_SIDE_DATA_FLAG_NEW_REF) { +int ret = av_buffer_replace(>buf, buf); +if (ret < 0) +return NULL; +} else +*pbuf = NULL; + +av_dict_free(>metadata); +entry->data = buf->data; +entry->size = buf->size; +return entry; This again looks like a minor variation of the block you've added twice already. +} +} + +buf = (flags & AV_FRAME_SIDE_DATA_FLAG_NEW_REF) ? + av_buffer_ref(*pbuf) : *pbuf; + +sd_dst = add_side_data_from_buf(sd, nb_sd, type, buf); +if (!sd_dst) { +if (flags & AV_FRAME_SIDE_DATA_FLAG_NEW_REF) +av_buffer_unref(); +return NULL; +} + +if (!(flags & AV_FRAME_SIDE_DATA_FLAG_NEW_REF)) +*pbuf = NULL; + +return sd_dst; +} + int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, const AVFrameSideData *src, unsigned int flags) { diff --git a/libavutil/frame.h b/libavutil/frame.h index 2ea129888e..3e5d170a5b 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1048,6 +1048,10 @@ void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd); * Don't add a new entry if another of the same type exists. */ #define AV_FRAME_SIDE_DATA_FLAG_REPLACE (1 << 1) +/** + * Create a new reference instead of taking ownership of the passed in one. + */ +#define AV_FRAME_SIDE_DATA_FLAG_NEW_REF (1 << 2) Who needs this? Someone who wants to keep the reference around, like when attaching a buffer to several outputs (global to individual output frames). ___ 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/7 v4] avutil/frame: add a flag to allow overwritting existing entries
On 3/28/2024 8:23 AM, Anton Khirnov wrote: Quoting James Almer (2024-03-28 04:12:04) Enable it only for side data types that don't allow more than one entry. Signed-off-by: James Almer --- libavutil/frame.c | 59 --- libavutil/frame.h | 27 +- libavutil/tests/side_data_array.c | 52 +++ tests/ref/fate/side_data_array| 22 ++-- 4 files changed, 115 insertions(+), 45 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index ef1613c344..d9bd19b2aa 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -799,12 +799,34 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, size_t size, unsigned int flags) { -AVBufferRef *buf = av_buffer_alloc(size); +const AVSideDataDescriptor *desc = av_frame_side_data_desc(type); +AVBufferRef *buf; AVFrameSideData *ret = NULL; if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) remove_side_data(sd, nb_sd, type); +if (!desc || !(desc->props & AV_SIDE_DATA_PROP_MULTI)) { desc == NULL means type is invalid This being a generic alloc function, it should IMO not be limited to currently defined types. And I chose to treat them as non multi, as that's the most common scenario. +for (int i = 0; i < *nb_sd; i++) { +AVFrameSideData *entry = ((*sd)[i]); +if (entry->type != type) +continue; Why are you not calling av_frame_side_data_get()? An oversight i guess :p @@ -822,13 +845,41 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, if (!sd || !src || !nb_sd || (*nb_sd && !*sd)) return AVERROR(EINVAL); +desc = av_frame_side_data_desc(src->type); +if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) +remove_side_data(sd, nb_sd, src->type); +if (!desc || !(desc->props & AV_SIDE_DATA_PROP_MULTI)) { +for (int i = 0; i < *nb_sd; i++) { +AVFrameSideData *entry = ((*sd)[i]); +AVDictionary *dict = NULL; + +if (entry->type != src->type) +continue; +if (!(flags & AV_FRAME_SIDE_DATA_FLAG_REPLACE)) +return AVERROR(EEXIST); + +ret = av_dict_copy(, src->metadata, 0); +if (ret < 0) +return ret; + +ret = av_buffer_replace(>buf, src->buf); +if (ret < 0) { +av_dict_free(); +return ret; +} + +av_dict_free(>metadata); +entry->metadata = dict; +entry->data = src->data; +entry->size = src->size; +return 0; +} This whole block looks very similar to the one you're adding to av_frame_side_data_new(). I can try to factorize it. +} + buf = av_buffer_ref(src->buf); if (!buf) return AVERROR(ENOMEM); -if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) -remove_side_data(sd, nb_sd, src->type); - sd_dst = add_side_data_from_buf(sd, nb_sd, src->type, buf); if (!sd_dst) { av_buffer_unref(); diff --git a/libavutil/frame.h b/libavutil/frame.h index 3b6d746a16..2ea129888e 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1040,7 +1040,14 @@ const AVSideDataDescriptor *av_frame_side_data_desc(enum AVFrameSideDataType typ */ void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd); +/** + * Remove existing entries before adding new ones. + */ #define AV_FRAME_SIDE_DATA_FLAG_UNIQUE (1 << 0) +/** + * Don't add a new entry if another of the same type exists. This should mention that it only applies to MULTI side data types. Ok. ___ 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 6/7 v4] avcodec/decode: make the AVFrameSideData helper wrappers not depend on frames
Quoting James Almer (2024-03-28 12:36:37) > On 3/28/2024 8:32 AM, Anton Khirnov wrote: > > Quoting James Almer (2024-03-28 04:12:09) > >> They will be useful to fill arrays stored in other structs. > >> > >> Signed-off-by: James Almer > >> --- > >> libavcodec/av1dec.c | 7 +-- > >> libavcodec/cri.c| 3 +- > >> libavcodec/decode.c | 99 +++-- > >> libavcodec/decode.h | 28 ++-- > >> libavcodec/dpx.c| 3 +- > >> libavcodec/h2645_sei.c | 4 +- > >> libavcodec/h264_slice.c | 3 +- > >> libavcodec/hevcdec.c| 6 ++- > >> libavcodec/libdav1d.c | 7 +-- > >> libavcodec/libjxldec.c | 3 +- > >> libavcodec/mjpegdec.c | 3 +- > >> libavcodec/mpeg12dec.c | 11 +++-- > >> libavcodec/pngdec.c | 8 ++-- > >> libavcodec/qsvdec.c | 4 +- > >> libavcodec/tiff.c | 3 +- > >> libavcodec/webp.c | 3 +- > >> 16 files changed, 120 insertions(+), 75 deletions(-) > > > > Extra churn in all the decoders, longer and harder to read lines. > > Why not make ff_frame_new_side_data_from_buf() a wrapper for a new > > function instead? > > Can you elaborate? I'm making all the decode.h side data wrappers take > pointers to AVFrameSideData instead of AVFrames so they're not limited > to the latter. I mean: * add new function(s) that work with AVFrameSideData; * keep signatures for existing function the same, but change their implementation into a wrapper for the above this way the decoders do not need to be changed. -- 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".