Re: [FFmpeg-devel] [PATCH 1/7] avcodec/h263dec: Remove redundant code to set cur_pic_ptr
Michael Niedermayer: > On Mon, Aug 15, 2022 at 01:49:24PM +0200, Andreas Rheinhardt wrote: >> It is done later in ff_mpv_frame_start() (and nobody uses >> current_picture_ptr between setting it in ff_mpv_frame_start()). >> >> (The reason the vsynth*-h263-obmc code changes is because >> the call to ff_find_unused_picture() now happens after the older >> pictures have been unreferenced in ff_mpv_frame_start(), >> so that their slots in the picture array can be immediately >> reused; the obmc code is somehow buggy and changes its output >> depending on the earlier contents of the motion_val buffer.) >> >> Signed-off-by: Andreas Rheinhardt >> --- > >> I'd like to take this opportunity to once again ask anyone familiar >> with H.263 to take a look at this OBMC issue. > > Iam too busy ATM :( i might look at some point but its not very high > on my todo as it works :) security & release is more important > Good that you became aware of this issue. (You were the "anyone familiar with H.263" person I thought of.) > but i can say this breaks fate as it is: > I am aware of this; this is due to a slight conflict with b645138a34321fb1d1b7988cd0d78b897e4d65ca. The ref file changes were appropriate for git master at the time I sent this. I already updated mine locally. > --- ./tests/ref/vsynth/vsynth1-h263-obmc 2022-08-16 00:19:00.345967181 > +0200 > +++ tests/data/fate/vsynth1-h263-obmc 2022-08-16 00:19:05.262017999 +0200 > @@ -1,4 +1,4 @@ > 7dec64380f375e5118b66f3b1e24 *tests/data/fate/vsynth1-h263-obmc.avi > 657320 tests/data/fate/vsynth1-h263-obmc.avi > -f5048b5f0c98833a1d11f8034fb1827f > *tests/data/fate/vsynth1-h263-obmc.out.rawvideo > -stddev:8.12 PSNR: 29.93 MAXDIFF: 113 bytes: 7603200/ 7603200 > +2a69f6b37378aa34418dfd04ec98c1c8 > *tests/data/fate/vsynth1-h263-obmc.out.rawvideo > +stddev:8.38 PSNR: 29.66 MAXDIFF: 116 bytes: 7603200/ 7603200 > Test vsynth1-h263-obmc failed. Look at tests/data/fate/vsynth1-h263-obmc.err > for details. > tests/Makefile:304: recipe for target 'fate-vsynth1-h263-obmc' failed > make: *** [fate-vsynth1-h263-obmc] Error 1 > > [...] ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/mov: don't read duration from mvhd atom
> On Aug 16, 2022, at 7:14 AM, James Almer wrote: > > This duration is equal to the longest duration in all track's tkhd atoms, > which > may be comprised of the sum of all edit lists in each track. Empty edit lists > in tracks represent start_time, and the actual media duration is stored in the > mdhd atom. > This change lets the generic demux code derive the longest track duration > taken > from mdhd atoms, so the correct duration and start_time combination will be > reported. > > Should fix ticket #9775. The patch LGTM. However, does the ticket indicts some issue related to the mov muxer, which may be hidden by the patch? > > Signed-off-by: James Almer > --- > libavformat/mov.c| 4 > tests/ref/fate/gaplessenc-itunes-to-ipod-aac | 2 +- > 2 files changed, 1 insertion(+), 5 deletions(-) > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 6ee6ed0950..fee9c39f39 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -1516,10 +1516,6 @@ static int mov_read_mvhd(MOVContext *c, AVIOContext > *pb, MOVAtom atom) > av_log(c->fc, AV_LOG_TRACE, "time scale = %i\n", c->time_scale); > > c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration > */ > -// set the AVFormatContext duration because the duration of individual > tracks > -// may be inaccurate > -if (!c->trex_data) > -c->fc->duration = av_rescale(c->duration, AV_TIME_BASE, > c->time_scale); > avio_rb32(pb); /* preferred scale */ > > avio_rb16(pb); /* preferred volume */ > diff --git a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac > b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac > index f967ac05bc..1f89e9af85 100644 > --- a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac > +++ b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac > @@ -5,7 +5,7 @@ duration_ts=103326 > [/STREAM] > [FORMAT] > start_time=0.00 > -duration=2.344000 > +duration=2.342993 > [/FORMAT] > packet|pts=-1024|dts=-1024|duration=1024|flags=KD|side_data| > > -- > 2.37.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] [PATCH v2] libswscale/aarch64: add another hscale specialization
On Sat, 13 Aug 2022, Swinney, Jonathan wrote: This specialization handles the case where filtersize is 4 mod 8, e.g. 12, 20, etc. Aarch64 was previously using the c function for this case. This implementation speeds up that case significantly. hscale_8_to_15__fs_12_dstW_512_c: 6234.1 hscale_8_to_15__fs_12_dstW_512_neon: 1505.6 Signed-off-by: Jonathan Swinney --- libswscale/aarch64/hscale.S | 107 +++ libswscale/aarch64/swscale.c | 18 +++--- 2 files changed, 117 insertions(+), 8 deletions(-) Thanks, this update looks fine to me, so I pushed it! // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] tools: Make sure to create the tools directory before building decode_simple.o
Quoting Martin Storsjö (2022-08-08 10:59:51) > This directory dependency is normally added implicitly by rules > in ffbuild/common.mak; for tools it's created by a rule for TOOLOBJS. > TOOLOBJS is populated implicitly from TOOLS, and decode_simple.o > doesn't end up there because it's an odd occurrance of a lone > object file in the tools subdirectory, not belonging to any other > tool. > > --- > This fixes stray fate errors where make tried to build this object > file when no other rule had ended up creating the tools directory > already, like this one: > http://fate.ffmpeg.org/log.cgi?time=20220808051007&slot=i686-mingw32-clang-trunk&log=test > --- > tools/Makefile | 2 ++ > 1 file changed, 2 insertions(+) Should be ok -- 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] qsvenc_{hevc,h264}: add scenario option
Quoting Xiang, Haihao (2022-08-12 06:52:53) > +#define QSV_OPTION_SCENARIO \ > +{ "scenario", "A hint to encoder about the scenario for the encoding > session", OFFSET(qsv.scenario), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 8, VE, > "scenario" }, \ The default should probably be one of the MFX_SCENARIO flags (unknown makes most sense I suppose) rather than 0. -- 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 v3 0/3] checkasm: updated tests for sw_scale
On Sat, 13 Aug 2022, Swinney, Jonathan wrote: We don't generally use stdbool in ffmpeg, even if it's C99 - just use a plain int and 0/1. Updated this. Other than that, the checkasm changes look fine (I coauthored part of them - and your cleanup of my WIP patch looks good!). Yes, thank you for the help on that! Hmm, can you elaborate on this bit? With only the first patch applied, the checkasm test still succeeds. That was leftover from when my test was broken. Is that that with the fixed test, it works fine. Could we split this improvement for the existing codepath into a separate preceding patch, to keep things a bit clearer? I split it out. Let me know if I didn't split like you intended. Thanks, this looked good to me, so I pushed them! // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lavu/tx: implement aarch64 NEON SIMD
Quoting Lynne (2022-08-14 06:31:50) > New - Total for len 131072 reps 4096 = 1.942836 s > Old - Segfaults ??? -- 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/2] RFC: checkasm: motion: Test different h parameters
On Thu, 4 Aug 2022, Martin Storsjö wrote: On Wed, 13 Jul 2022, Martin Storsjö wrote: Previously, the checkasm test always passed h=8, so no other cases were tested. Out of the me_cmp functions, in practice, some functions are hardcoded to always assume a 8x8 block (ignoring the h parameter), while others do use the parameter. For those with hardcoded height, both the reference C function and the assembly implementations ignore the parameter similarly. The documentation for the functions indicate that heights between w/2 and 2*w, within the range of 4 to 16, should be supported. This patch just tests random heights in that range, without knowing what width the current function actually uses. --- I'm not sure if it's good to have checkasm exercise cases that don't occur in practice or not. In particular, the aarch64 functions have a separate implementation for non-multiple-of-4 height, which probably doesn't ever get called in practice, while other SIMD implementations lack that. Alternatively, we'd improve the documentation for the expectations for these functions and make the test match that, and remove the unused non-multiple-of-4 case in the aarch64 assembly. --- tests/checkasm/motion.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/checkasm/motion.c b/tests/checkasm/motion.c index 0112822174..79e4358941 100644 --- a/tests/checkasm/motion.c +++ b/tests/checkasm/motion.c @@ -45,7 +45,7 @@ static void test_motion(const char *name, me_cmp_func test_func) /* motion estimation can look up to 17 bytes ahead */ static const int look_ahead = 17; -int i, x, y, d1, d2; +int i, x, y, h, d1, d2; uint8_t *ptr; LOCAL_ALIGNED_16(uint8_t, img1, [WIDTH * HEIGHT]); @@ -68,14 +68,16 @@ static void test_motion(const char *name, me_cmp_func test_func) for (i = 0; i < ITERATIONS; i++) { x = rnd() % (WIDTH - look_ahead); y = rnd() % (HEIGHT - look_ahead); +// Pick a random h between 4 and 16; pick an even value. +h = 4 + ((rnd() % (16 + 1 - 4)) & ~1); ptr = img2 + y * WIDTH + x; -d2 = call_ref(NULL, img1, ptr, WIDTH, 8); -d1 = call_new(NULL, img1, ptr, WIDTH, 8); +d2 = call_ref(NULL, img1, ptr, WIDTH, h); +d1 = call_new(NULL, img1, ptr, WIDTH, h); if (d1 != d2) { fail(); -printf("func: %s, x=%d y=%d, error: asm=%d c=%d\n", name, x, y, d1, d2); +printf("func: %s, x=%d y=%d h=%d, error: asm=%d c=%d\n", name, x, y, h, d1, d2); break; } } -- 2.25.1 Ping As there doesn't seem to be much opinion on this, I'll go ahead and land this (patch 1/2 was approved already), as this improves the test coverage for the aarch64 neon me_cmp assembly patches that are in progress. // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v1 1/3] lavc/decode: Add get_hw_config function
The commit message is misleading - you are not adding code, you are moving code. Quoting Fei Wang (2022-08-12 14:55:43) > From: Linjie Fu > > Wrap the procedure of getting the hardware config from a pixel format > into a function. > > Signed-off-by: Linjie Fu > Signed-off-by: Fei Wang > --- > libavcodec/decode.c | 33 + > 1 file changed, 21 insertions(+), 12 deletions(-) > > diff --git a/libavcodec/decode.c b/libavcodec/decode.c > index 75373989c6..d66d5a4160 100644 > --- a/libavcodec/decode.c > +++ b/libavcodec/decode.c > @@ -1156,6 +1156,26 @@ static void hwaccel_uninit(AVCodecContext *avctx) > av_buffer_unref(&avctx->hw_frames_ctx); > } > > +static const AVCodecHWConfigInternal *get_hw_config(AVCodecContext *avctx, > enum AVPixelFormat fmt) > +{ > +const AVCodecHWConfigInternal *hw_config; > +int i; Should be declared in the loop > +if (ffcodec(avctx->codec)->hw_configs) { > +for (i = 0;; i++) { > +hw_config = ffcodec(avctx->codec)->hw_configs[i]; > +if (!hw_config) > +break; return NULL; > +if (hw_config->public.pix_fmt == fmt) > +break; return hw_config; > +} > +} else { > +hw_config = NULL; > +} You can save one level of indentation by starting with if (!ffcodec(avctx->codec)->hw_configs) return NULL; -- 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 v1 2/3] lavc/decode: Add internal surface re-allocate method for hwaccel
Quoting Fei Wang (2022-08-12 14:55:44) > From: Linjie Fu > > Add HWACCEL_CAP_INTERNAL_ALLOC flag to indicate hwaccels are able to > re-allocate surface internally through ff_decode_get_hw_frames_ctx. > > Signed-off-by: Linjie Fu > Signed-off-by: Fei Wang > --- The commit message should explain what problem is this trying to solve. It is very much not obvious to me. -- 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 v2] lavc/aarch64: hevc_add_res add 12bit variants
On Tue, 16 Aug 2022, J. Dekker wrote: hevc_add_res_4x4_12_c: 46.0 hevc_add_res_4x4_12_neon: 18.7 hevc_add_res_8x8_12_c: 194.7 hevc_add_res_8x8_12_neon: 25.2 hevc_add_res_16x16_12_c: 716.0 hevc_add_res_16x16_12_neon: 69.7 hevc_add_res_32x32_12_c: 3820.7 hevc_add_res_32x32_12_neon: 261.0 Signed-off-by: J. Dekker --- libavcodec/aarch64/hevcdsp_idct_neon.S| 156 -- libavcodec/aarch64/hevcdsp_init_aarch64.c | 34 ++--- 2 files changed, 105 insertions(+), 85 deletions(-) -function ff_hevc_add_residual_32x32_10_neon, export=1 +.macro add_res bitdepth +function ff_hevc_add_residual_4x4_\bitdepth\()_neon, export=1 +mvniv21.8h, #((0xFF << (\bitdepth - 8)) & 0xFF), lsl #8 +b X(ff_hevc_add_residual_4x4_16_neon) When the function isn't exported, you shouldn't use X() to access the symbol of it. On Darwin, X() adds the underscore prefix, but that symbol name is only defined for exported functions. Also, you probably should remove the ff_ prefix for symbols that aren't exported, for clarity. This issue causes the patch in its current form to break compilation on macOS. -void ff_hevc_add_residual_4x4_8_neon(uint8_t *_dst, int16_t *coeffs, - ptrdiff_t stride); -void ff_hevc_add_residual_4x4_10_neon(uint8_t *_dst, int16_t *coeffs, - ptrdiff_t stride); -void ff_hevc_add_residual_8x8_8_neon(uint8_t *_dst, int16_t *coeffs, - ptrdiff_t stride); -void ff_hevc_add_residual_8x8_10_neon(uint8_t *_dst, int16_t *coeffs, - ptrdiff_t stride); -void ff_hevc_add_residual_16x16_8_neon(uint8_t *_dst, int16_t *coeffs, - ptrdiff_t stride); -void ff_hevc_add_residual_16x16_10_neon(uint8_t *_dst, int16_t *coeffs, -ptrdiff_t stride); -void ff_hevc_add_residual_32x32_8_neon(uint8_t *_dst, int16_t *coeffs, - ptrdiff_t stride); -void ff_hevc_add_residual_32x32_10_neon(uint8_t *_dst, int16_t *coeffs, -ptrdiff_t stride); +void ff_hevc_add_residual_4x4_8_neon(uint8_t *_dst, int16_t *coeffs, ptrdiff_t stride); +void ff_hevc_add_residual_4x4_10_neon(uint8_t *_dst, int16_t *coeffs, ptrdiff_t stride); +void ff_hevc_add_residual_4x4_12_neon(uint8_t *_dst, int16_t *coeffs, ptrdiff_t stride); +void ff_hevc_add_residual_8x8_8_neon(uint8_t *_dst, int16_t *coeffs, ptrdiff_t stride); +void ff_hevc_add_residual_8x8_10_neon(uint8_t *_dst, int16_t *coeffs, ptrdiff_t stride); +void ff_hevc_add_residual_8x8_12_neon(uint8_t *_dst, int16_t *coeffs, ptrdiff_t stride); +void ff_hevc_add_residual_16x16_8_neon(uint8_t *_dst, int16_t *coeffs, ptrdiff_t stride); +void ff_hevc_add_residual_16x16_10_neon(uint8_t *_dst, int16_t *coeffs, ptrdiff_t stride); +void ff_hevc_add_residual_16x16_12_neon(uint8_t *_dst, int16_t *coeffs, ptrdiff_t stride); +void ff_hevc_add_residual_32x32_8_neon(uint8_t *_dst, int16_t *coeffs, ptrdiff_t stride); +void ff_hevc_add_residual_32x32_10_neon(uint8_t *_dst, int16_t *coeffs, ptrdiff_t stride); +void ff_hevc_add_residual_32x32_12_neon(uint8_t *_dst, int16_t *coeffs, ptrdiff_t stride); Note that these have been amended to include "const" on the coeffs parameter recently. // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3] lavc/aarch64: hevc_add_res add 12bit variants
hevc_add_res_4x4_12_c: 46.0 hevc_add_res_4x4_12_neon: 18.7 hevc_add_res_8x8_12_c: 194.7 hevc_add_res_8x8_12_neon: 25.2 hevc_add_res_16x16_12_c: 716.0 hevc_add_res_16x16_12_neon: 69.7 hevc_add_res_32x32_12_c: 3820.7 hevc_add_res_32x32_12_neon: 261.0 Signed-off-by: J. Dekker --- libavcodec/aarch64/hevcdsp_idct_neon.S| 156 -- libavcodec/aarch64/hevcdsp_init_aarch64.c | 34 ++--- 2 files changed, 105 insertions(+), 85 deletions(-) diff --git a/libavcodec/aarch64/hevcdsp_idct_neon.S b/libavcodec/aarch64/hevcdsp_idct_neon.S index 484eea8437..97c51e06e3 100644 --- a/libavcodec/aarch64/hevcdsp_idct_neon.S +++ b/libavcodec/aarch64/hevcdsp_idct_neon.S @@ -37,11 +37,11 @@ const trans, align=4 .short 31, 22, 13, 4 endconst -.macro clip10 in1, in2, c1, c2 -smax\in1, \in1, \c1 -smax\in2, \in2, \c1 -smin\in1, \in1, \c2 -smin\in2, \in2, \c2 +.macro clip2 in1, in2, min, max +smax\in1, \in1, \min +smax\in2, \in2, \min +smin\in1, \in1, \max +smin\in2, \in2, \max .endm function ff_hevc_add_residual_4x4_8_neon, export=1 @@ -64,25 +64,6 @@ function ff_hevc_add_residual_4x4_8_neon, export=1 ret endfunc -function ff_hevc_add_residual_4x4_10_neon, export=1 -mov x12, x0 -ld1 {v0.8h-v1.8h}, [x1] -ld1 {v2.d}[0], [x12], x2 -ld1 {v2.d}[1], [x12], x2 -ld1 {v3.d}[0], [x12], x2 -sqadd v0.8h, v0.8h, v2.8h -ld1 {v3.d}[1], [x12], x2 -moviv4.8h, #0 -sqadd v1.8h, v1.8h, v3.8h -mvniv5.8h, #0xFC, lsl #8 // movi #0x3FF -clip10 v0.8h, v1.8h, v4.8h, v5.8h -st1 {v0.d}[0], [x0], x2 -st1 {v0.d}[1], [x0], x2 -st1 {v1.d}[0], [x0], x2 -st1 {v1.d}[1], [x0], x2 -ret -endfunc - function ff_hevc_add_residual_8x8_8_neon, export=1 add x12, x0, x2 add x2, x2, x2 @@ -103,25 +84,6 @@ function ff_hevc_add_residual_8x8_8_neon, export=1 ret endfunc -function ff_hevc_add_residual_8x8_10_neon, export=1 -add x12, x0, x2 -add x2, x2, x2 -mov x3, #8 -moviv4.8h, #0 -mvniv5.8h, #0xFC, lsl #8 // movi #0x3FF -1: subsx3, x3, #2 -ld1 {v0.8h-v1.8h}, [x1], #32 -ld1 {v2.8h}, [x0] -sqadd v0.8h, v0.8h, v2.8h -ld1 {v3.8h}, [x12] -sqadd v1.8h, v1.8h, v3.8h -clip10 v0.8h, v1.8h, v4.8h, v5.8h -st1 {v0.8h}, [x0], x2 -st1 {v1.8h}, [x12], x2 -bne 1b -ret -endfunc - function ff_hevc_add_residual_16x16_8_neon, export=1 mov x3, #16 add x12, x0, x2 @@ -148,28 +110,6 @@ function ff_hevc_add_residual_16x16_8_neon, export=1 ret endfunc -function ff_hevc_add_residual_16x16_10_neon, export=1 -mov x3, #16 -moviv20.8h, #0 -mvniv21.8h, #0xFC, lsl #8 // movi #0x3FF -add x12, x0, x2 -add x2, x2, x2 -1: subsx3, x3, #2 -ld1 {v16.8h-v17.8h}, [x0] -ld1 {v0.8h-v3.8h}, [x1], #64 -sqadd v0.8h, v0.8h, v16.8h -ld1 {v18.8h-v19.8h}, [x12] -sqadd v1.8h, v1.8h, v17.8h -sqadd v2.8h, v2.8h, v18.8h -sqadd v3.8h, v3.8h, v19.8h -clip10 v0.8h, v1.8h, v20.8h, v21.8h -clip10 v2.8h, v3.8h, v20.8h, v21.8h -st1 {v0.8h-v1.8h}, [x0], x2 -st1 {v2.8h-v3.8h}, [x12], x2 -bne 1b -ret -endfunc - function ff_hevc_add_residual_32x32_8_neon, export=1 add x12, x0, x2 add x2, x2, x2 @@ -209,10 +149,88 @@ function ff_hevc_add_residual_32x32_8_neon, export=1 ret endfunc -function ff_hevc_add_residual_32x32_10_neon, export=1 +.macro add_res bitdepth +function ff_hevc_add_residual_4x4_\bitdepth\()_neon, export=1 +mvniv21.8h, #((0xFF << (\bitdepth - 8)) & 0xFF), lsl #8 +b hevc_add_residual_4x4_16_neon +endfunc +function ff_hevc_add_residual_8x8_\bitdepth\()_neon, export=1 +mvniv21.8h, #((0xFF << (\bitdepth - 8)) & 0xFF), lsl #8 +b hevc_add_residual_8x8_16_neon +endfunc +function ff_hevc_add_residual_16x16_\bitdepth\()_neon, export=1 +mvniv21.8h, #((0xFF << (\bitdepth - 8)) & 0xFF), lsl #8 +b
Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg: store a separate copy of input codec parameters
On 8/13/2022 12:36 PM, Anton Khirnov wrote: Use it instead of AVStream.codecpar in the main thread. While AVStream.codecpar is documented to only be updated when the stream is added or avformat_find_stream_info(), it is actually updated during demuxing. Accessing it from a different thread then constitutes a race. Should we consider a bug that some demuxers update stream's codepars post init? Or is the documentation not reflecting the actual behavior what's wrong? Ideally, some mechanism should eventually be provided for signalling parameter updates to the user. Then the demuxing thread could pick up the changes and propagate them to the decoder. --- fftools/ffmpeg.c | 39 --- fftools/ffmpeg.h | 6 ++ fftools/ffmpeg_opt.c | 6 +- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 8eb7759392..ef7177fc33 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -608,6 +608,7 @@ static void ffmpeg_cleanup(int ret) av_freep(&ist->dts_buffer); avcodec_free_context(&ist->dec_ctx); +avcodec_parameters_free(&ist->par); av_freep(&input_streams[i]); } @@ -1492,7 +1493,7 @@ static void print_final_stats(int64_t total_size) for (j = 0; j < f->nb_streams; j++) { InputStream *ist = input_streams[f->ist_index + j]; -enum AVMediaType type = ist->st->codecpar->codec_type; +enum AVMediaType type = ist->par->codec_type; total_size+= ist->data_size; total_packets += ist->nb_packets; @@ -1809,7 +1810,7 @@ static void flush_encoders(void) for (x = 0; x < fg->nb_inputs; x++) { InputFilter *ifilter = fg->inputs[x]; if (ifilter->format < 0 && -ifilter_parameters_from_codecpar(ifilter, ifilter->ist->st->codecpar) < 0) { +ifilter_parameters_from_codecpar(ifilter, ifilter->ist->par) < 0) { av_log(NULL, AV_LOG_ERROR, "Error copying paramerets from input stream\n"); exit_program(1); } @@ -1912,11 +1913,11 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p if (pkt->dts == AV_NOPTS_VALUE) { opkt->dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ost->mux_timebase); } else if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { -int duration = av_get_audio_frame_duration2(ist->st->codecpar, pkt->size); +int duration = av_get_audio_frame_duration2(ist->par, pkt->size); if(!duration) -duration = ist->st->codecpar->frame_size; +duration = ist->par->frame_size; opkt->dts = av_rescale_delta(ist->st->time_base, pkt->dts, -(AVRational){1, ist->st->codecpar->sample_rate}, duration, +(AVRational){1, ist->par->sample_rate}, duration, &ist->filter_in_rescale_delta_last, ost->mux_timebase); /* dts will be set immediately afterwards to what pts is now */ opkt->pts = opkt->dts - ost_tb_start_time; @@ -1976,7 +1977,7 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame, int keep_ref /* determine if the parameters for this input changed */ need_reinit = ifilter->format != frame->format; -switch (ifilter->ist->st->codecpar->codec_type) { +switch (ifilter->ist->par->codec_type) { case AVMEDIA_TYPE_AUDIO: need_reinit |= ifilter->sample_rate!= frame->sample_rate || av_channel_layout_compare(&ifilter->ch_layout, &frame->ch_layout); @@ -2056,7 +2057,7 @@ static int ifilter_send_eof(InputFilter *ifilter, int64_t pts) } else { // the filtergraph was never configured if (ifilter->format < 0) { -ret = ifilter_parameters_from_codecpar(ifilter, ifilter->ist->st->codecpar); +ret = ifilter_parameters_from_codecpar(ifilter, ifilter->ist->par); if (ret < 0) return ret; } @@ -2212,9 +2213,9 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_ // The following line may be required in some cases where there is no parser // or the parser does not has_b_frames correctly -if (ist->st->codecpar->video_delay < ist->dec_ctx->has_b_frames) { +if (ist->par->video_delay < ist->dec_ctx->has_b_frames) { if (ist->dec_ctx->codec_id == AV_CODEC_ID_H264) { -ist->st->codecpar->video_delay = ist->dec_ctx->has_b_frames; +ist->par->video_delay = ist->dec_ctx->has_b_frames; } else av_log(ist->dec_ctx, AV_LOG_WARNING, "video_delay is larger in decoder than demuxer %d > %d.\n" @@ -,7 +2223,7 @@
Re: [FFmpeg-devel] [PATCH v3] lavc/aarch64: hevc_add_res add 12bit variants
On Tue, 16 Aug 2022, J. Dekker wrote: hevc_add_res_4x4_12_c: 46.0 hevc_add_res_4x4_12_neon: 18.7 hevc_add_res_8x8_12_c: 194.7 hevc_add_res_8x8_12_neon: 25.2 hevc_add_res_16x16_12_c: 716.0 hevc_add_res_16x16_12_neon: 69.7 hevc_add_res_32x32_12_c: 3820.7 hevc_add_res_32x32_12_neon: 261.0 Signed-off-by: J. Dekker --- libavcodec/aarch64/hevcdsp_idct_neon.S| 156 -- libavcodec/aarch64/hevcdsp_init_aarch64.c | 34 ++--- 2 files changed, 105 insertions(+), 85 deletions(-) Thanks, this version seems fine to me. diff --git a/libavcodec/aarch64/hevcdsp_init_aarch64.c b/libavcodec/aarch64/hevcdsp_init_aarch64.c index 9cbe983870..b6d5efb77f 100644 --- a/libavcodec/aarch64/hevcdsp_init_aarch64.c +++ b/libavcodec/aarch64/hevcdsp_init_aarch64.c @@ -25,22 +25,18 @@ #include "libavutil/aarch64/cpu.h" #include "libavcodec/hevcdsp.h" -void ff_hevc_add_residual_4x4_8_neon(uint8_t *_dst, const int16_t *coeffs, - ptrdiff_t stride); +void ff_hevc_add_residual_4x4_8_neon(uint8_t *_dst, const int16_t *coeffs, ptrdiff_t stride); The joined forms of these lines end up a bit long, while they previously did fit below the 80 column soft-limit, so IMO I'd prefer to keep them wrapped - but it's not a big deal. (I guess it made more sense to join the lines before the 'const' was added.) // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg: store a separate copy of input codec parameters
James Almer: > On 8/13/2022 12:36 PM, Anton Khirnov wrote: >> Use it instead of AVStream.codecpar in the main thread. While >> AVStream.codecpar is documented to only be updated when the stream is >> added or avformat_find_stream_info(), it is actually updated during >> demuxing. Accessing it from a different thread then constitutes a race. > > Should we consider a bug that some demuxers update stream's codepars > post init? Or is the documentation not reflecting the actual behavior > what's wrong? > Some demuxers? It is the generic demuxing code (read_frame_internal(), demux.c lines 1335-1347) that does this. And some demuxers probably do it, too. At least the concat demuxer IIRC. >> >> Ideally, some mechanism should eventually be provided for signalling >> parameter updates to the user. Then the demuxing thread could pick up >> the changes and propagate them to the decoder. >> --- >> fftools/ffmpeg.c | 39 --- >> fftools/ffmpeg.h | 6 ++ >> fftools/ffmpeg_opt.c | 6 +- >> 3 files changed, 31 insertions(+), 20 deletions(-) >> >> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c >> index 8eb7759392..ef7177fc33 100644 >> --- a/fftools/ffmpeg.c >> +++ b/fftools/ffmpeg.c >> @@ -608,6 +608,7 @@ static void ffmpeg_cleanup(int ret) >> av_freep(&ist->dts_buffer); >> avcodec_free_context(&ist->dec_ctx); >> + avcodec_parameters_free(&ist->par); >> av_freep(&input_streams[i]); >> } >> @@ -1492,7 +1493,7 @@ static void print_final_stats(int64_t total_size) >> for (j = 0; j < f->nb_streams; j++) { >> InputStream *ist = input_streams[f->ist_index + j]; >> - enum AVMediaType type = ist->st->codecpar->codec_type; >> + enum AVMediaType type = ist->par->codec_type; >> total_size += ist->data_size; >> total_packets += ist->nb_packets; >> @@ -1809,7 +1810,7 @@ static void flush_encoders(void) >> for (x = 0; x < fg->nb_inputs; x++) { >> InputFilter *ifilter = fg->inputs[x]; >> if (ifilter->format < 0 && >> - ifilter_parameters_from_codecpar(ifilter, >> ifilter->ist->st->codecpar) < 0) { >> + ifilter_parameters_from_codecpar(ifilter, >> ifilter->ist->par) < 0) { >> av_log(NULL, AV_LOG_ERROR, "Error copying >> paramerets from input stream\n"); >> exit_program(1); >> } >> @@ -1912,11 +1913,11 @@ static void do_streamcopy(InputStream *ist, >> OutputStream *ost, const AVPacket *p >> if (pkt->dts == AV_NOPTS_VALUE) { >> opkt->dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, >> ost->mux_timebase); >> } else if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { >> - int duration = >> av_get_audio_frame_duration2(ist->st->codecpar, pkt->size); >> + int duration = av_get_audio_frame_duration2(ist->par, >> pkt->size); >> if(!duration) >> - duration = ist->st->codecpar->frame_size; >> + duration = ist->par->frame_size; >> opkt->dts = av_rescale_delta(ist->st->time_base, pkt->dts, >> - (AVRational){1, >> ist->st->codecpar->sample_rate}, duration, >> + (AVRational){1, >> ist->par->sample_rate}, duration, >> >> &ist->filter_in_rescale_delta_last, ost->mux_timebase); >> /* dts will be set immediately afterwards to what pts is now */ >> opkt->pts = opkt->dts - ost_tb_start_time; >> @@ -1976,7 +1977,7 @@ static int ifilter_send_frame(InputFilter >> *ifilter, AVFrame *frame, int keep_ref >> /* determine if the parameters for this input changed */ >> need_reinit = ifilter->format != frame->format; >> - switch (ifilter->ist->st->codecpar->codec_type) { >> + switch (ifilter->ist->par->codec_type) { >> case AVMEDIA_TYPE_AUDIO: >> need_reinit |= ifilter->sample_rate != frame->sample_rate || >> >> av_channel_layout_compare(&ifilter->ch_layout, &frame->ch_layout); >> @@ -2056,7 +2057,7 @@ static int ifilter_send_eof(InputFilter >> *ifilter, int64_t pts) >> } else { >> // the filtergraph was never configured >> if (ifilter->format < 0) { >> - ret = ifilter_parameters_from_codecpar(ifilter, >> ifilter->ist->st->codecpar); >> + ret = ifilter_parameters_from_codecpar(ifilter, >> ifilter->ist->par); >> if (ret < 0) >> return ret; >> } >> @@ -2212,9 +2213,9 @@ static int decode_video(InputStream *ist, >> AVPacket *pkt, int *got_output, int64_ >> // The following line may be required in some cases where >> there is no parser >> // or the parser does not has_b_frames correctly >> - if (ist->st->codecpar->video_delay < ist->
[FFmpeg-devel] [PATCH 1/5] fftools: Add support for dictionary options
From: Jan Ekström --- fftools/cmdutils.c | 18 ++ fftools/cmdutils.h | 2 ++ fftools/ffmpeg_opt.c | 11 +-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 18e768b386..22ba654bb0 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -131,6 +131,22 @@ int64_t parse_time_or_die(const char *context, const char *timestr, return us; } +static AVDictionary *parse_dict_or_die(const char *context, + const char *dict_str) +{ +AVDictionary *dict = NULL; +int ret = av_dict_parse_string(&dict, dict_str, "=", ",", 0); +if (ret < 0) { +av_log(NULL, AV_LOG_FATAL, + "Failed to create a dictionary from '%s': %s!\n", + dict_str, av_err2str(ret)); +exit_program(1); +} + + +return dict; +} + void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags, int alt_flags) { @@ -288,6 +304,8 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt, *(float *)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY); } else if (po->flags & OPT_DOUBLE) { *(double *)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY); +} else if (po->flags & OPT_DICT) { +*(AVDictionary **)dst = parse_dict_or_die(opt, arg); } else if (po->u.func_arg) { int ret = po->u.func_arg(optctx, opt, arg); if (ret < 0) { diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index d87e162ccd..6a519c6546 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -129,6 +129,7 @@ typedef struct SpecifierOpt { uint64_t ui64; float f; double dbl; +AVDictionary *dict; } u; } SpecifierOpt; @@ -157,6 +158,7 @@ typedef struct OptionDef { #define OPT_DOUBLE 0x2 #define OPT_INPUT 0x4 #define OPT_OUTPUT 0x8 +#define OPT_DICT 0x10 union { void *dst_ptr; int (*func_arg)(void *, const char *, const char *); diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 97f14b2a5b..cc038aae6b 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -62,6 +62,7 @@ #define SPECIFIER_OPT_FMT_ui64 "%"PRIu64 #define SPECIFIER_OPT_FMT_f"%f" #define SPECIFIER_OPT_FMT_dbl "%lf" +#define SPECIFIER_OPT_FMT_dict "%p" static const char *const opt_name_codec_names[] = {"c", "codec", "acodec", "vcodec", "scodec", "dcodec", NULL}; static const char *const opt_name_audio_channels[]= {"ac", NULL}; @@ -208,11 +209,17 @@ static void uninit_options(OptionsContext *o) av_freep(&(*so)[i].specifier); if (po->flags & OPT_STRING) av_freep(&(*so)[i].u.str); +else if (po->flags & OPT_DICT) +av_dict_free(&(*so)[i].u.dict); } av_freep(so); *count = 0; -} else if (po->flags & OPT_OFFSET && po->flags & OPT_STRING) -av_freep(dst); +} else if (po->flags & OPT_OFFSET) { +if (po->flags & OPT_STRING) +av_freep(dst); +else if (po->flags & OPT_DICT) +av_dict_free((AVDictionary **)&dst); +} po++; } -- 2.20.1 (Apple Git-117) ___ 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] ffmpeg: Add display_matrix option
From: Jan Ekström This enables overriding the rotation as well as horizontal/vertical flip state of a specific video stream on the input side. Additionally, switch the singular test that was utilizing the rotation metadata to instead override the input display rotation, thus leading to the same result. --- doc/ffmpeg.texi | 13 + fftools/cmdutils.h | 1 + fftools/ffmpeg.h| 2 + fftools/ffmpeg_opt.c| 107 tests/fate/filter-video.mak | 2 +- 5 files changed, 124 insertions(+), 1 deletion(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 42440d93b4..5d3e3b3052 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -912,6 +912,19 @@ If used together with @option{-vcodec copy}, it will affect the aspect ratio stored at container level, but not the aspect ratio stored in encoded frames, if it exists. +@item -display_matrix[:@var{stream_specifier}] @var{opt1=val1[,opt2=val2]...} (@emph{input,per-stream}) +Set the video display matrix according to given options. + +@table @option +@item rotation=@var{number} +Set the rotation using a floating point number that describes a pure +counter-clockwise rotation in degrees. +The @code{-autorotate} logic will be affected. +@item hflip=@var{[0,1]} +@item vflip=@var{[0,1]} +Set a horizontal or vertical flip. +@end table + @item -vn (@emph{input/output}) As an input option, blocks all video streams of a file from being filtered or being automatically selected or mapped for any output. See @code{-discard} diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 6a519c6546..df90cc6958 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -166,6 +166,7 @@ typedef struct OptionDef { } u; const char *help; const char *argname; +const AVClass *args; } OptionDef; /** diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 6991ba7632..0ea730fd42 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -193,6 +193,8 @@ typedef struct OptionsContext { intnb_force_fps; SpecifierOpt *frame_aspect_ratios; intnb_frame_aspect_ratios; +SpecifierOpt *display_matrixes; +intnb_display_matrixes; SpecifierOpt *rc_overrides; intnb_rc_overrides; SpecifierOpt *intra_matrices; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index cc038aae6b..e184b4239c 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -20,6 +20,7 @@ #include "config.h" +#include #include #if HAVE_SYS_RESOURCE_H @@ -45,6 +46,7 @@ #include "libavutil/avutil.h" #include "libavutil/bprint.h" #include "libavutil/channel_layout.h" +#include "libavutil/display.h" #include "libavutil/getenv_utf8.h" #include "libavutil/intreadwrite.h" #include "libavutil/fifo.h" @@ -87,6 +89,7 @@ static const char *const opt_name_forced_key_frames[] = {"forced_key_fra static const char *const opt_name_fps_mode[] = {"fps_mode", NULL}; static const char *const opt_name_force_fps[] = {"force_fps", NULL}; static const char *const opt_name_frame_aspect_ratios[] = {"aspect", NULL}; +static const char *const opt_name_display_matrixes[] = {"display_matrix", NULL}; static const char *const opt_name_rc_overrides[] = {"rc_override", NULL}; static const char *const opt_name_intra_matrices[]= {"intra_matrix", NULL}; static const char *const opt_name_inter_matrices[]= {"inter_matrix", NULL}; @@ -112,6 +115,32 @@ static const char *const opt_name_time_bases[] = {"time_base", NU static const char *const opt_name_enc_time_bases[]= {"enc_time_base", NULL}; static const char *const opt_name_bits_per_raw_sample[] = {"bits_per_raw_sample", NULL}; +// XXX this should probably go into a seperate file _args.c and #included here +struct display_matrix_s { +const AVClass *class; +double rotation; +int hflip; +int vflip; +}; +#define OFFSET(x) offsetof(struct display_matrix_s, x) +static const AVOption display_matrix_args[] = { +{ "rotation", "set rotation", OFFSET(rotation), AV_OPT_TYPE_DOUBLE, +{ .dbl = DBL_MAX }, -(DBL_MAX), DBL_MAX - 1.0f, AV_OPT_FLAG_ARGUMENT}, +{ "hflip","set hflip", OFFSET(hflip),AV_OPT_TYPE_BOOL, +{ .i64 = -1 }, 0, 1, AV_OPT_FLAG_ARGUMENT}, +{ "vflip","set vflip", OFFSET(vflip),AV_OPT_TYPE_BOOL, +{ .i64 = -1 }, 0, 1, AV_OPT_FLAG_ARGUMENT}, +{ NULL }, +}; +static const AVClass class_display_matrix_args = { +.class_name = "display_matrix_args", +.item_name = av_default_item_name, +.option = display_matrix_args, +.version= LIBAVUTIL_VERSION_INT, +}; +#undef OFFSET +// XXX + #define WARN_MULTIPLE_OPT_USAGE(name, type, so, st)\ {\ char namestr[128] = "";\ @@ -808,6 +837,75 @@ static i
[FFmpeg-devel] [PATCH 3/5] ffmpeg: Deprecate display rotation override with a metadata key
From: Jan Ekström Now that we have proper options for defining display matrix overrides, this should no longer be required. fftools does not have its own versioning, so for now the define is just set to 1 and disables the functionality if set to zero. --- fftools/ffmpeg.c | 2 ++ fftools/ffmpeg.h | 5 + fftools/ffmpeg_opt.c | 10 ++ 3 files changed, 17 insertions(+) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 8eb7759392..b0a8839129 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2824,12 +2824,14 @@ static int init_output_stream_streamcopy(OutputStream *ost) } } +#if FFMPEG_ROTATION_METADATA if (ost->rotate_overridden) { uint8_t *sd = av_stream_new_side_data(ost->st, AV_PKT_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9); if (sd) av_display_rotation_set((int32_t *)sd, -ost->rotate_override_value); } +#endif switch (par->codec_type) { case AVMEDIA_TYPE_AUDIO: diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 0ea730fd42..12125ac006 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -53,6 +53,7 @@ #define FFMPEG_OPT_PSNR 1 #define FFMPEG_OPT_MAP_CHANNEL 1 #define FFMPEG_OPT_MAP_SYNC 1 +#define FFMPEG_ROTATION_METADATA 1 enum VideoSyncMethod { VSYNC_AUTO = -1, @@ -520,11 +521,15 @@ typedef struct OutputStream { const char *fps_mode; int force_fps; int top_field_first; +#if FFMPEG_ROTATION_METADATA int rotate_overridden; +#endif int autoscale; int bitexact; int bits_per_raw_sample; +#if FFMPEG_ROTATION_METADATA double rotate_override_value; +#endif AVRational frame_aspect_ratio; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index e184b4239c..f6551621c3 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2930,16 +2930,26 @@ static void of_add_metadata(AVFormatContext *oc, const OptionsContext *o) for (int j = 0; j < oc->nb_streams; j++) { OutputStream *ost = output_streams[nb_output_streams - oc->nb_streams + j]; if ((ret = check_stream_specifier(oc, oc->streams[j], stream_spec)) > 0) { +#if FFMPEG_ROTATION_METADATA if (!strcmp(o->metadata[i].u.str, "rotate")) { char *tail; double theta = av_strtod(val, &tail); if (!*tail) { ost->rotate_overridden = 1; ost->rotate_override_value = theta; + +av_log(NULL, AV_LOG_WARNING, + "Conversion of a 'rotate' metadata key to a " + "proper display matrix rotation is deprecated. " + "See -display_matrix for setting rotation " + "instead."); } } else { +#endif av_dict_set(&oc->streams[j]->metadata, o->metadata[i].u.str, *val ? val : NULL, 0); +#if FFMPEG_ROTATION_METADATA } +#endif } else if (ret < 0) exit_program(1); } -- 2.20.1 (Apple Git-117) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/5] ffmpeg: Allow printing of option arguments in help output
--- fftools/cmdutils.c | 5 + libavutil/opt.c| 14 +- libavutil/opt.h| 8 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 22ba654bb0..dae018f83a 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -172,6 +172,11 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags, av_strlcat(buf, po->argname, sizeof(buf)); } printf("-%-17s %s\n", buf, po->help); + +if (po->args) { +const AVClass *p = po->args; +av_arg_show(&p, NULL); +} } printf("\n"); } diff --git a/libavutil/opt.c b/libavutil/opt.c index a3940f47fb..89ef111690 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -1256,7 +1256,7 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, av_log(av_log_obj, AV_LOG_INFO, " %-15s ", opt->name); else av_log(av_log_obj, AV_LOG_INFO, " %s%-17s ", - (opt->flags & AV_OPT_FLAG_FILTERING_PARAM) ? " " : "-", + (opt->flags & (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_ARGUMENT)) ? " " : "-", opt->name); switch (opt->type) { @@ -1329,6 +1329,7 @@ FF_ENABLE_DEPRECATION_WARNINGS av_log(av_log_obj, AV_LOG_INFO, "%-12s ", ""); break; } +if (!(opt->flags & AV_OPT_FLAG_ARGUMENT)) { av_log(av_log_obj, AV_LOG_INFO, "%c%c%c%c%c%c%c%c%c%c%c", (opt->flags & AV_OPT_FLAG_ENCODING_PARAM) ? 'E' : '.', (opt->flags & AV_OPT_FLAG_DECODING_PARAM) ? 'D' : '.', @@ -1341,6 +1342,7 @@ FF_ENABLE_DEPRECATION_WARNINGS (opt->flags & AV_OPT_FLAG_BSF_PARAM) ? 'B' : '.', (opt->flags & AV_OPT_FLAG_RUNTIME_PARAM) ? 'T' : '.', (opt->flags & AV_OPT_FLAG_DEPRECATED) ? 'P' : '.'); +} if (opt->help) av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help); @@ -1456,6 +1458,16 @@ int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags) return 0; } +int av_arg_show(void *obj, void *av_log_obj) +{ +if (!obj) +return -1; + +opt_list(obj, av_log_obj, NULL, AV_OPT_FLAG_ARGUMENT, 0, -1); + +return 0; +} + void av_opt_set_defaults(void *s) { av_opt_set_defaults2(s, 0, 0); diff --git a/libavutil/opt.h b/libavutil/opt.h index 461b5d3b6b..dce3483237 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -297,6 +297,7 @@ typedef struct AVOption { #define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic parameter which can be set by the user for filtering #define AV_OPT_FLAG_DEPRECATED (1<<17) ///< set if option is deprecated, users should refer to AVOption.help text for more information #define AV_OPT_FLAG_CHILD_CONSTS(1<<18) ///< set if option constants can also reside in child objects +#define AV_OPT_FLAG_ARGUMENT(1<<19) ///< set if option is an argument to another option //FIXME think about enc-audio, ... style flags /** @@ -386,6 +387,13 @@ typedef struct AVOptionRanges { */ int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags); +/** + * Show the obj arguments. + * + * @param av_log_obj log context to use for showing the options + */ +int av_arg_show(void *obj, void *av_log_obj); + /** * Set the values of all AVOption fields to their default values. * -- 2.20.1 (Apple Git-117) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 5/5] ffmpeg: Add {h, v}scale argument to display_matrix option to allow for scaling via the display matrix
--- doc/ffmpeg.texi | 4 fftools/ffmpeg_filter.c | 15 +++ fftools/ffmpeg_opt.c| 10 ++ libavutil/display.c | 21 + libavutil/display.h | 28 5 files changed, 78 insertions(+) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 5d3e3b3052..52cca7a407 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -923,6 +923,10 @@ The @code{-autorotate} logic will be affected. @item hflip=@var{[0,1]} @item vflip=@var{[0,1]} Set a horizontal or vertical flip. +@item hscale=@var{[0,2]} +Set a horizontal scaling by factor of the given floating-point value. +@item vscale=@var{[0,2]} +Set a vertical scaling by factor of the given floating-point value. @end table @item -vn (@emph{input/output}) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index f9ae76f76d..0759c08687 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -778,9 +778,24 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, if (ist->autorotate && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) { int32_t *displaymatrix = ifilter->displaymatrix; double theta; +double hscale = 1.0f; +double vscale = 1.0f; if (!displaymatrix) displaymatrix = (int32_t *)av_stream_get_side_data(ist->st, AV_PKT_DATA_DISPLAYMATRIX, NULL); + +if (displaymatrix) { +hscale = av_display_hscale_get(displaymatrix); +vscale = av_display_vscale_get(displaymatrix); + +if (hscale != 1.0f || vscale != 1.0f) { +char scale_buf[128]; +snprintf(scale_buf, sizeof(scale_buf), "%f*iw:%f*ih", hscale, vscale); +ret = insert_filter(&last_filter, &pad_idx, "scale", scale_buf); +} +} + + theta = get_rotation(displaymatrix); if (fabs(theta - 90) < 1.0) { diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index f6551621c3..4fae6cbfbf 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -121,6 +121,8 @@ static const char *const opt_name_bits_per_raw_sample[] = {"bits_per_raw_s double rotation; int hflip; int vflip; +double hscale; +double vscale; }; #define OFFSET(x) offsetof(struct display_matrix_s, x) static const AVOption display_matrix_args[] = { @@ -130,6 +132,10 @@ static const char *const opt_name_bits_per_raw_sample[] = {"bits_per_raw_s { .i64 = -1 }, 0, 1, AV_OPT_FLAG_ARGUMENT}, { "vflip","set vflip", OFFSET(vflip),AV_OPT_TYPE_BOOL, { .i64 = -1 }, 0, 1, AV_OPT_FLAG_ARGUMENT}, +{ "hscale", "set scale factor", OFFSET(hscale), AV_OPT_TYPE_DOUBLE, +{ .dbl = 1.0f }, 0.0f, 2.0f, AV_OPT_FLAG_ARGUMENT}, +{ "vscale", "set scale factor", OFFSET(vscale), AV_OPT_TYPE_DOUBLE, +{ .dbl = 1.0f }, 0.0f, 2.0f, AV_OPT_FLAG_ARGUMENT}, { NULL }, }; static const AVClass class_display_matrix_args = { @@ -848,6 +854,8 @@ static void add_display_matrix_to_stream(OptionsContext *o, .rotation = DBL_MAX, .hflip= -1, .vflip= -1, +.hscale= 1.0f, +.vscale= 1.0f, }; AVDictionary *global_args = NULL; @@ -903,6 +911,8 @@ static void add_display_matrix_to_stream(OptionsContext *o, av_display_matrix_flip((int32_t *)buf, hflip_set ? test_args.hflip : 0, vflip_set ? test_args.vflip : 0); + +av_display_matrix_scale((int32_t *)buf, test_args.hscale, test_args.vscale); } diff --git a/libavutil/display.c b/libavutil/display.c index d31061283c..b89763ff48 100644 --- a/libavutil/display.c +++ b/libavutil/display.c @@ -28,9 +28,11 @@ // fixed point to double #define CONV_FP(x) ((double) (x)) / (1 << 16) +#define CONV_FP2(x) ((double) (x)) / (1 << 30) // double to fixed point #define CONV_DB(x) (int32_t) ((x) * (1 << 16)) +#define CONV_DB2(x) (int32_t) ((x) * (1 << 30)) double av_display_rotation_get(const int32_t matrix[9]) { @@ -48,6 +50,17 @@ double av_display_rotation_get(const int32_t matrix[9]) return -rotation; } +double av_display_hscale_get(const int32_t matrix[9]) +{ +return fabs(CONV_FP2(matrix[2])); +} + +double av_display_vscale_get(const int32_t matrix[9]) +{ +return fabs(CONV_FP2(matrix[5])); +} + +#include void av_display_rotation_set(int32_t matrix[9], double angle) { double radians = -angle * M_PI / 180.0f; @@ -60,6 +73,8 @@ void av_display_rotation_set(int32_t matrix[9], double angle) matrix[1] = CONV_DB(-s); matrix[3] = CONV_DB(s); matrix[4] = CONV_DB(c); +matrix[2] = 1 << 30; +matrix[5] = 1 << 30; matrix[8] = 1 << 30; } @@ -72,3 +87,9 @@ void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip) for (i = 0; i < 9; i++) matrix[i] *= flip[i
Re: [FFmpeg-devel] [PATCH 5/5] ffmpeg: Add {h, v}scale argument to display_matrix option to allow for scaling via the display matrix
Am 16.08.22 um 15:30 schrieb Thilo Borgmann: --- doc/ffmpeg.texi | 4 fftools/ffmpeg_filter.c | 15 +++ fftools/ffmpeg_opt.c| 10 ++ libavutil/display.c | 21 + libavutil/display.h | 28 5 files changed, 78 insertions(+) [...] diff --git a/libavutil/display.c b/libavutil/display.c index d31061283c..b89763ff48 100644 --- a/libavutil/display.c +++ b/libavutil/display.c @@ -28,9 +28,11 @@ // fixed point to double #define CONV_FP(x) ((double) (x)) / (1 << 16) +#define CONV_FP2(x) ((double) (x)) / (1 << 30) // double to fixed point #define CONV_DB(x) (int32_t) ((x) * (1 << 16)) +#define CONV_DB2(x) (int32_t) ((x) * (1 << 30)) double av_display_rotation_get(const int32_t matrix[9]) { @@ -48,6 +50,17 @@ double av_display_rotation_get(const int32_t matrix[9]) return -rotation; } +double av_display_hscale_get(const int32_t matrix[9]) +{ +return fabs(CONV_FP2(matrix[2])); +} + +double av_display_vscale_get(const int32_t matrix[9]) +{ +return fabs(CONV_FP2(matrix[5])); +} + +#include obviously wrong and missed to remove... will be fixed locally. -Thilo ___ 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 2/4] ffmpeg: Add display_matrix option
Quoting Thilo Borgmann (2022-08-15 22:02:09) > $subject > > -Thilo > From fe2ff114cb004f897c7774753d9cf28298eba82d Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= > Date: Mon, 15 Aug 2022 21:09:27 +0200 > Subject: [PATCH v2 2/4] ffmpeg: Add display_matrix option > > This enables overriding the rotation as well as horizontal/vertical > flip state of a specific video stream on the input side. > > Additionally, switch the singular test that was utilizing the rotation > metadata to instead override the input display rotation, thus leading > to the same result. > --- I still don't see how it's better to squash multiple options into a single option. It requires all this extra infrastructure and in the end it's less user-friendly, because user-understandable things like rotation or flips are now hidden under "display matrix". How many users would know what a display matrix is? -- 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 1/5] fftools: Add support for dictionary options
Thilo Borgmann: > From: Jan Ekström > > --- > fftools/cmdutils.c | 18 ++ > fftools/cmdutils.h | 2 ++ > fftools/ffmpeg_opt.c | 11 +-- > 3 files changed, 29 insertions(+), 2 deletions(-) > > diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c > index 18e768b386..22ba654bb0 100644 > --- a/fftools/cmdutils.c > +++ b/fftools/cmdutils.c > @@ -131,6 +131,22 @@ int64_t parse_time_or_die(const char *context, const > char *timestr, > return us; > } > > +static AVDictionary *parse_dict_or_die(const char *context, > + const char *dict_str) > +{ > +AVDictionary *dict = NULL; > +int ret = av_dict_parse_string(&dict, dict_str, "=", ",", 0); > +if (ret < 0) { > +av_log(NULL, AV_LOG_FATAL, > + "Failed to create a dictionary from '%s': %s!\n", > + dict_str, av_err2str(ret)); > +exit_program(1); > +} > + > + > +return dict; > +} > + > void show_help_options(const OptionDef *options, const char *msg, int > req_flags, > int rej_flags, int alt_flags) > { > @@ -288,6 +304,8 @@ static int write_option(void *optctx, const OptionDef > *po, const char *opt, > *(float *)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, > INFINITY); > } else if (po->flags & OPT_DOUBLE) { > *(double *)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, > -INFINITY, INFINITY); > +} else if (po->flags & OPT_DICT) { > +*(AVDictionary **)dst = parse_dict_or_die(opt, arg); > } else if (po->u.func_arg) { > int ret = po->u.func_arg(optctx, opt, arg); > if (ret < 0) { > diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h > index d87e162ccd..6a519c6546 100644 > --- a/fftools/cmdutils.h > +++ b/fftools/cmdutils.h > @@ -129,6 +129,7 @@ typedef struct SpecifierOpt { > uint64_t ui64; > float f; > double dbl; > +AVDictionary *dict; > } u; > } SpecifierOpt; > > @@ -157,6 +158,7 @@ typedef struct OptionDef { > #define OPT_DOUBLE 0x2 > #define OPT_INPUT 0x4 > #define OPT_OUTPUT 0x8 > +#define OPT_DICT 0x10 > union { > void *dst_ptr; > int (*func_arg)(void *, const char *, const char *); > diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c > index 97f14b2a5b..cc038aae6b 100644 > --- a/fftools/ffmpeg_opt.c > +++ b/fftools/ffmpeg_opt.c > @@ -62,6 +62,7 @@ > #define SPECIFIER_OPT_FMT_ui64 "%"PRIu64 > #define SPECIFIER_OPT_FMT_f"%f" > #define SPECIFIER_OPT_FMT_dbl "%lf" > +#define SPECIFIER_OPT_FMT_dict "%p" > > static const char *const opt_name_codec_names[] = {"c", > "codec", "acodec", "vcodec", "scodec", "dcodec", NULL}; > static const char *const opt_name_audio_channels[]= {"ac", NULL}; > @@ -208,11 +209,17 @@ static void uninit_options(OptionsContext *o) > av_freep(&(*so)[i].specifier); > if (po->flags & OPT_STRING) > av_freep(&(*so)[i].u.str); > +else if (po->flags & OPT_DICT) > +av_dict_free(&(*so)[i].u.dict); > } > av_freep(so); > *count = 0; > -} else if (po->flags & OPT_OFFSET && po->flags & OPT_STRING) > -av_freep(dst); > +} else if (po->flags & OPT_OFFSET) { > +if (po->flags & OPT_STRING) > +av_freep(dst); > +else if (po->flags & OPT_DICT) > +av_dict_free((AVDictionary **)&dst); Did you test this (your patchset doesn't)? It shouldn't work: It should be av_dict_free((AVDictionary**)dst). > +} > po++; > } > ___ 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] ipfsgateway: Remove default gateway
On Mon, Aug 15, 2022 at 11:47:53PM +0200, Michael Niedermayer wrote: [...] > If one was concerned that using a default gateway could be seen > as endorsment by us. Be concerned please about how FFmpeg looks > when its developers attack other projects on its official development IRC > channels. ive writte a longer argument about crypto and NFTs on https://guru.multimedia.cx/why-crypto/ listing by humble oppinion about it, in case anyone cares. It kind of fits here but i didnt want to bore everyone who doesnt care with posting that long (off topic drifting) text here thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Republics decline into democracies and democracies degenerate into despotisms. -- Aristotle 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] mov: Compare frag times in correct time base when seeking a stream without a corresponding sidx
On 8/14/2022 7:55 AM, Zhao Zhili wrote: > Or just continue the loop, and print a warning message maybe? Done, and v3 sent. - Derek ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3] mov: Compare frag times in correct time base when seeking a stream without a corresponding sidx
Some muxers, such as GPAC, create files with only one sidx, but two streams muxed into the same fragments pointed to by this sidx. Prevously, in such a case, when we seeked in such files, we fell back to, for example, using the sidx associated with the video stream, to seek the audio stream, leaving the seekhead in the wrong place. We can still do this, but we need to take care to compare timestamps in the same time base. Signed-off-by: Derek Buitenhuis --- libavformat/mov.c | 38 -- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 31f3249ca6..1d8c5b2904 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1271,15 +1271,18 @@ static int64_t get_stream_info_time(MOVFragmentStreamInfo * frag_stream_info) return frag_stream_info->tfdt_dts; } -static int64_t get_frag_time(MOVFragmentIndex *frag_index, - int index, int track_id) +static int64_t get_frag_time(AVFormatContext *s, AVStream *dst_st, + MOVFragmentIndex *frag_index, int index) { MOVFragmentStreamInfo * frag_stream_info; +MOVStreamContext *sc = dst_st->priv_data; int64_t timestamp; -int i; +int i, j; -if (track_id >= 0) { -frag_stream_info = get_frag_stream_info(frag_index, index, track_id); +// If the stream is referenced by any sidx, limit the search +// to fragments that referenced this stream in the sidx +if (sc->has_sidx) { +frag_stream_info = get_frag_stream_info(frag_index, index, dst_st->id); if (frag_stream_info->sidx_pts != AV_NOPTS_VALUE) return frag_stream_info->sidx_pts; if (frag_stream_info->first_tfra_pts != AV_NOPTS_VALUE) @@ -1288,28 +1291,27 @@ static int64_t get_frag_time(MOVFragmentIndex *frag_index, } for (i = 0; i < frag_index->item[index].nb_stream_info; i++) { +AVStream *frag_stream = NULL; frag_stream_info = &frag_index->item[index].stream_info[i]; +for (j = 0; j < s->nb_streams; j++) +if (s->streams[j]->id == frag_stream_info->id) +frag_stream = s->streams[j]; +if (!frag_stream) { +av_log(s, AV_LOG_WARNING, "No stream matching sidx ID found.\n"); +continue; +} timestamp = get_stream_info_time(frag_stream_info); if (timestamp != AV_NOPTS_VALUE) -return timestamp; +return av_rescale_q(timestamp, frag_stream->time_base, dst_st->time_base); } return AV_NOPTS_VALUE; } -static int search_frag_timestamp(MOVFragmentIndex *frag_index, +static int search_frag_timestamp(AVFormatContext *s, MOVFragmentIndex *frag_index, AVStream *st, int64_t timestamp) { int a, b, m, m0; int64_t frag_time; -int id = -1; - -if (st) { -// If the stream is referenced by any sidx, limit the search -// to fragments that referenced this stream in the sidx -MOVStreamContext *sc = st->priv_data; -if (sc->has_sidx) -id = st->id; -} a = -1; b = frag_index->nb_items; @@ -1318,7 +1320,7 @@ static int search_frag_timestamp(MOVFragmentIndex *frag_index, m0 = m = (a + b) >> 1; while (m < b && - (frag_time = get_frag_time(frag_index, m, id)) == AV_NOPTS_VALUE) + (frag_time = get_frag_time(s, st, frag_index, m)) == AV_NOPTS_VALUE) m++; if (m < b && frag_time <= timestamp) @@ -8862,7 +8864,7 @@ static int mov_seek_fragment(AVFormatContext *s, AVStream *st, int64_t timestamp if (!mov->frag_index.complete) return 0; -index = search_frag_timestamp(&mov->frag_index, st, timestamp); +index = search_frag_timestamp(s, &mov->frag_index, st, timestamp); if (index < 0) index = 0; if (!mov->frag_index.item[index].headers_read) -- 2.36.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 2/5] ffmpeg: Add display_matrix option
Thilo Borgmann: > From: Jan Ekström > > This enables overriding the rotation as well as horizontal/vertical > flip state of a specific video stream on the input side. > > Additionally, switch the singular test that was utilizing the rotation > metadata to instead override the input display rotation, thus leading > to the same result. > --- > doc/ffmpeg.texi | 13 + > fftools/cmdutils.h | 1 + > fftools/ffmpeg.h| 2 + > fftools/ffmpeg_opt.c| 107 > tests/fate/filter-video.mak | 2 +- > 5 files changed, 124 insertions(+), 1 deletion(-) > > diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi > index 42440d93b4..5d3e3b3052 100644 > --- a/doc/ffmpeg.texi > +++ b/doc/ffmpeg.texi > @@ -912,6 +912,19 @@ If used together with @option{-vcodec copy}, it will > affect the aspect ratio > stored at container level, but not the aspect ratio stored in encoded > frames, if it exists. > > +@item -display_matrix[:@var{stream_specifier}] > @var{opt1=val1[,opt2=val2]...} (@emph{input,per-stream}) > +Set the video display matrix according to given options. > + > +@table @option > +@item rotation=@var{number} > +Set the rotation using a floating point number that describes a pure > +counter-clockwise rotation in degrees. > +The @code{-autorotate} logic will be affected. > +@item hflip=@var{[0,1]} > +@item vflip=@var{[0,1]} > +Set a horizontal or vertical flip. This documentation does not specify the order in which rotation and flipping will be applied. > +@end table > + > @item -vn (@emph{input/output}) > As an input option, blocks all video streams of a file from being filtered or > being automatically selected or mapped for any output. See @code{-discard} > diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h > index 6a519c6546..df90cc6958 100644 > --- a/fftools/cmdutils.h > +++ b/fftools/cmdutils.h > @@ -166,6 +166,7 @@ typedef struct OptionDef { > } u; > const char *help; > const char *argname; > +const AVClass *args; Never used(?) > } OptionDef; > > /** > diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h > index 6991ba7632..0ea730fd42 100644 > --- a/fftools/ffmpeg.h > +++ b/fftools/ffmpeg.h > @@ -193,6 +193,8 @@ typedef struct OptionsContext { > intnb_force_fps; > SpecifierOpt *frame_aspect_ratios; > intnb_frame_aspect_ratios; > +SpecifierOpt *display_matrixes; > +intnb_display_matrixes; > SpecifierOpt *rc_overrides; > intnb_rc_overrides; > SpecifierOpt *intra_matrices; > diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c > index cc038aae6b..e184b4239c 100644 > --- a/fftools/ffmpeg_opt.c > +++ b/fftools/ffmpeg_opt.c > @@ -20,6 +20,7 @@ > > #include "config.h" > > +#include > #include > > #if HAVE_SYS_RESOURCE_H > @@ -45,6 +46,7 @@ > #include "libavutil/avutil.h" > #include "libavutil/bprint.h" > #include "libavutil/channel_layout.h" > +#include "libavutil/display.h" > #include "libavutil/getenv_utf8.h" > #include "libavutil/intreadwrite.h" > #include "libavutil/fifo.h" > @@ -87,6 +89,7 @@ static const char *const opt_name_forced_key_frames[] > = {"forced_key_fra > static const char *const opt_name_fps_mode[] = {"fps_mode", > NULL}; > static const char *const opt_name_force_fps[] = > {"force_fps", NULL}; > static const char *const opt_name_frame_aspect_ratios[] = {"aspect", > NULL}; > +static const char *const opt_name_display_matrixes[] = > {"display_matrix", NULL}; > static const char *const opt_name_rc_overrides[] = > {"rc_override", NULL}; > static const char *const opt_name_intra_matrices[]= > {"intra_matrix", NULL}; > static const char *const opt_name_inter_matrices[]= > {"inter_matrix", NULL}; > @@ -112,6 +115,32 @@ static const char *const opt_name_time_bases[] > = {"time_base", NU > static const char *const opt_name_enc_time_bases[]= > {"enc_time_base", NULL}; > static const char *const opt_name_bits_per_raw_sample[] = > {"bits_per_raw_sample", NULL}; > > +// XXX this should probably go into a seperate file _args.c and > #included here > +struct display_matrix_s { We actually use CamelCase for struct tags and typedefs. > +const AVClass *class; > +double rotation; > +int hflip; > +int vflip; > +}; > +#define OFFSET(x) offsetof(struct display_matrix_s, x) > +static const AVOption display_matrix_args[] = { > +{ "rotation", "set rotation", OFFSET(rotation), AV_OPT_TYPE_DOUBLE, > +{ .dbl = DBL_MAX }, -(DBL_MAX), DBL_MAX - 1.0f, > AV_OPT_FLAG_ARGUMENT}, > +{ "hflip","set hflip", OFFSET(hflip),AV_OPT_TYPE_BOOL, > +{ .i64 = -1 }, 0, 1, AV_OPT_FLAG_ARGUMENT}, > +{ "vflip","set vflip", OFFSET(vflip),AV_OPT_TYPE_BOOL, > +{ .i64 = -1 }, 0,
Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg: store a separate copy of input codec parameters
Quoting James Almer (2022-08-16 14:21:31) > On 8/13/2022 12:36 PM, Anton Khirnov wrote: > > Use it instead of AVStream.codecpar in the main thread. While > > AVStream.codecpar is documented to only be updated when the stream is > > added or avformat_find_stream_info(), it is actually updated during > > demuxing. Accessing it from a different thread then constitutes a race. > > Should we consider a bug that some demuxers update stream's codepars > post init? Or is the documentation not reflecting the actual behavior > what's wrong? Maybe? Disregarding the generic code we know about, I'd be interested to know which demuxers modify codecpar and whether they have a good reason for it. I already know dv updates the timebase all the time, which should be highly illegal. -- 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/5] ffmpeg: Add display_matrix option
Thilo Borgmann: > From: Jan Ekström > > This enables overriding the rotation as well as horizontal/vertical > flip state of a specific video stream on the input side. > > Additionally, switch the singular test that was utilizing the rotation > metadata to instead override the input display rotation, thus leading > to the same result. > --- > doc/ffmpeg.texi | 13 + > fftools/cmdutils.h | 1 + > fftools/ffmpeg.h| 2 + > fftools/ffmpeg_opt.c| 107 > tests/fate/filter-video.mak | 2 +- > 5 files changed, 124 insertions(+), 1 deletion(-) > > diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi > index 42440d93b4..5d3e3b3052 100644 > --- a/doc/ffmpeg.texi > +++ b/doc/ffmpeg.texi > @@ -912,6 +912,19 @@ If used together with @option{-vcodec copy}, it will > affect the aspect ratio > stored at container level, but not the aspect ratio stored in encoded > frames, if it exists. > > +@item -display_matrix[:@var{stream_specifier}] > @var{opt1=val1[,opt2=val2]...} (@emph{input,per-stream}) > +Set the video display matrix according to given options. > + > +@table @option > +@item rotation=@var{number} > +Set the rotation using a floating point number that describes a pure > +counter-clockwise rotation in degrees. > +The @code{-autorotate} logic will be affected. > +@item hflip=@var{[0,1]} > +@item vflip=@var{[0,1]} > +Set a horizontal or vertical flip. > +@end table > + > @item -vn (@emph{input/output}) > As an input option, blocks all video streams of a file from being filtered or > being automatically selected or mapped for any output. See @code{-discard} > diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h > index 6a519c6546..df90cc6958 100644 > --- a/fftools/cmdutils.h > +++ b/fftools/cmdutils.h > @@ -166,6 +166,7 @@ typedef struct OptionDef { > } u; > const char *help; > const char *argname; > +const AVClass *args; > } OptionDef; > > /** > diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h > index 6991ba7632..0ea730fd42 100644 > --- a/fftools/ffmpeg.h > +++ b/fftools/ffmpeg.h > @@ -193,6 +193,8 @@ typedef struct OptionsContext { > intnb_force_fps; > SpecifierOpt *frame_aspect_ratios; > intnb_frame_aspect_ratios; > +SpecifierOpt *display_matrixes; > +intnb_display_matrixes; > SpecifierOpt *rc_overrides; > intnb_rc_overrides; > SpecifierOpt *intra_matrices; > diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c > index cc038aae6b..e184b4239c 100644 > --- a/fftools/ffmpeg_opt.c > +++ b/fftools/ffmpeg_opt.c > @@ -20,6 +20,7 @@ > > #include "config.h" > > +#include > #include > > #if HAVE_SYS_RESOURCE_H > @@ -45,6 +46,7 @@ > #include "libavutil/avutil.h" > #include "libavutil/bprint.h" > #include "libavutil/channel_layout.h" > +#include "libavutil/display.h" > #include "libavutil/getenv_utf8.h" > #include "libavutil/intreadwrite.h" > #include "libavutil/fifo.h" > @@ -87,6 +89,7 @@ static const char *const opt_name_forced_key_frames[] > = {"forced_key_fra > static const char *const opt_name_fps_mode[] = {"fps_mode", > NULL}; > static const char *const opt_name_force_fps[] = > {"force_fps", NULL}; > static const char *const opt_name_frame_aspect_ratios[] = {"aspect", > NULL}; > +static const char *const opt_name_display_matrixes[] = > {"display_matrix", NULL}; > static const char *const opt_name_rc_overrides[] = > {"rc_override", NULL}; > static const char *const opt_name_intra_matrices[]= > {"intra_matrix", NULL}; > static const char *const opt_name_inter_matrices[]= > {"inter_matrix", NULL}; > @@ -112,6 +115,32 @@ static const char *const opt_name_time_bases[] > = {"time_base", NU > static const char *const opt_name_enc_time_bases[]= > {"enc_time_base", NULL}; > static const char *const opt_name_bits_per_raw_sample[] = > {"bits_per_raw_sample", NULL}; > > +// XXX this should probably go into a seperate file _args.c and > #included here > +struct display_matrix_s { > +const AVClass *class; > +double rotation; > +int hflip; > +int vflip; > +}; > +#define OFFSET(x) offsetof(struct display_matrix_s, x) > +static const AVOption display_matrix_args[] = { > +{ "rotation", "set rotation", OFFSET(rotation), AV_OPT_TYPE_DOUBLE, > +{ .dbl = DBL_MAX }, -(DBL_MAX), DBL_MAX - 1.0f, > AV_OPT_FLAG_ARGUMENT}, AV_OPT_FLAG_ARGUMENT is only added in 4/5. This commit will not compile at all. > +{ "hflip","set hflip", OFFSET(hflip),AV_OPT_TYPE_BOOL, > +{ .i64 = -1 }, 0, 1, AV_OPT_FLAG_ARGUMENT}, > +{ "vflip","set vflip", OFFSET(vflip),AV_OPT_TYPE_BOOL, > +{ .i64 = -1 }, 0, 1, AV_OPT_FLAG_ARGUMENT}, > +{ NULL }, > +}; > +static const AVClass cla
Re: [FFmpeg-devel] [PATCH 4/5] ffmpeg: Allow printing of option arguments in help output
Thilo Borgmann: > --- > fftools/cmdutils.c | 5 + > libavutil/opt.c| 14 +- > libavutil/opt.h| 8 > 3 files changed, 26 insertions(+), 1 deletion(-) > > diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c > index 22ba654bb0..dae018f83a 100644 > --- a/fftools/cmdutils.c > +++ b/fftools/cmdutils.c > @@ -172,6 +172,11 @@ void show_help_options(const OptionDef *options, const > char *msg, int req_flags, > av_strlcat(buf, po->argname, sizeof(buf)); > } > printf("-%-17s %s\n", buf, po->help); > + > +if (po->args) { > +const AVClass *p = po->args; > +av_arg_show(&p, NULL); > +} > } > printf("\n"); > } > diff --git a/libavutil/opt.c b/libavutil/opt.c > index a3940f47fb..89ef111690 100644 > --- a/libavutil/opt.c > +++ b/libavutil/opt.c > @@ -1256,7 +1256,7 @@ static void opt_list(void *obj, void *av_log_obj, const > char *unit, > av_log(av_log_obj, AV_LOG_INFO, " %-15s ", opt->name); > else > av_log(av_log_obj, AV_LOG_INFO, " %s%-17s ", > - (opt->flags & AV_OPT_FLAG_FILTERING_PARAM) ? " " : "-", > + (opt->flags & (AV_OPT_FLAG_FILTERING_PARAM | > AV_OPT_FLAG_ARGUMENT)) ? " " : "-", > opt->name); > > switch (opt->type) { > @@ -1329,6 +1329,7 @@ FF_ENABLE_DEPRECATION_WARNINGS > av_log(av_log_obj, AV_LOG_INFO, "%-12s ", ""); > break; > } > +if (!(opt->flags & AV_OPT_FLAG_ARGUMENT)) { > av_log(av_log_obj, AV_LOG_INFO, "%c%c%c%c%c%c%c%c%c%c%c", > (opt->flags & AV_OPT_FLAG_ENCODING_PARAM) ? 'E' : '.', > (opt->flags & AV_OPT_FLAG_DECODING_PARAM) ? 'D' : '.', > @@ -1341,6 +1342,7 @@ FF_ENABLE_DEPRECATION_WARNINGS > (opt->flags & AV_OPT_FLAG_BSF_PARAM) ? 'B' : '.', > (opt->flags & AV_OPT_FLAG_RUNTIME_PARAM) ? 'T' : '.', > (opt->flags & AV_OPT_FLAG_DEPRECATED) ? 'P' : '.'); > +} > > if (opt->help) > av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help); > @@ -1456,6 +1458,16 @@ int av_opt_show2(void *obj, void *av_log_obj, int > req_flags, int rej_flags) > return 0; > } > > +int av_arg_show(void *obj, void *av_log_obj) > +{ > +if (!obj) > +return -1; > + > +opt_list(obj, av_log_obj, NULL, AV_OPT_FLAG_ARGUMENT, 0, -1); > + > +return 0; > +} > + > void av_opt_set_defaults(void *s) > { > av_opt_set_defaults2(s, 0, 0); > diff --git a/libavutil/opt.h b/libavutil/opt.h > index 461b5d3b6b..dce3483237 100644 > --- a/libavutil/opt.h > +++ b/libavutil/opt.h > @@ -297,6 +297,7 @@ typedef struct AVOption { > #define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic parameter which > can be set by the user for filtering > #define AV_OPT_FLAG_DEPRECATED (1<<17) ///< set if option is > deprecated, users should refer to AVOption.help text for more information > #define AV_OPT_FLAG_CHILD_CONSTS(1<<18) ///< set if option constants can > also reside in child objects > +#define AV_OPT_FLAG_ARGUMENT(1<<19) ///< set if option is an > argument to another option > //FIXME think about enc-audio, ... style flags > > /** > @@ -386,6 +387,13 @@ typedef struct AVOptionRanges { > */ > int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags); > > +/** > + * Show the obj arguments. > + * > + * @param av_log_obj log context to use for showing the options > + */ > +int av_arg_show(void *obj, void *av_log_obj); > + > /** > * Set the values of all AVOption fields to their default values. > * 1. Changes to the tools and the libraries should be in separate patches. E.g. judging by the commit message one would not think that this would change libavutil by adding a public function; but it does! 2. I don't really get what the documentation of AV_OPT_FLAG_ARGUMENT means. It seems to be some magic parameter which allows one to request/reject AVOptions in av_opt_show2(). 3. av_arg_show(obj, av_log_obj) is equivalent to av_opt_show2(obj, av_log_obj, AV_OPT_FLAG_ARGUMENT, 0). - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3] mov: Compare frag times in correct time base when seeking a stream without a corresponding sidx
> -Original Message- > From: ffmpeg-devel-boun...@ffmpeg.org On > Behalf Of Derek Buitenhuis > Sent: 2022年8月16日 22:49 > To: ffmpeg-devel@ffmpeg.org > Subject: [FFmpeg-devel] [PATCH v3] mov: Compare frag times in correct time > base when seeking a stream without a corresponding sidx > > Some muxers, such as GPAC, create files with only one sidx, but two streams > muxed into the same fragments pointed to by this sidx. > > Prevously, in such a case, when we seeked in such files, we fell back > to, for example, using the sidx associated with the video stream, to > seek the audio stream, leaving the seekhead in the wrong place. > > We can still do this, but we need to take care to compare timestamps > in the same time base. > > Signed-off-by: Derek Buitenhuis > --- > libavformat/mov.c | 38 -- > 1 file changed, 20 insertions(+), 18 deletions(-) > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index 31f3249ca6..1d8c5b2904 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -1271,15 +1271,18 @@ static int64_t > get_stream_info_time(MOVFragmentStreamInfo * frag_stream_info) > return frag_stream_info->tfdt_dts; > } > > -static int64_t get_frag_time(MOVFragmentIndex *frag_index, > - int index, int track_id) > +static int64_t get_frag_time(AVFormatContext *s, AVStream *dst_st, > + MOVFragmentIndex *frag_index, int index) > { > MOVFragmentStreamInfo * frag_stream_info; > +MOVStreamContext *sc = dst_st->priv_data; > int64_t timestamp; > -int i; > +int i, j; > > -if (track_id >= 0) { > -frag_stream_info = get_frag_stream_info(frag_index, index, track_id); > +// If the stream is referenced by any sidx, limit the search > +// to fragments that referenced this stream in the sidx > +if (sc->has_sidx) { > +frag_stream_info = get_frag_stream_info(frag_index, index, > dst_st->id); > if (frag_stream_info->sidx_pts != AV_NOPTS_VALUE) > return frag_stream_info->sidx_pts; > if (frag_stream_info->first_tfra_pts != AV_NOPTS_VALUE) get_frag_time() can be called with an mp4 file which has no sidx at all. In that case, dst_st should have a higher priority than other streams, even if sc->has_sidx is false. And first_tfra_pts might be used here, which makes the check of sc->has_sidx unnatural. So in my opinion, the check on sc->has_sidx should be removed. Secondly, this part can be simplified with get_stream_info_time(), which is: +frag_stream_info = get_frag_stream_info(frag_index, index, dst_st->id); +timestamp = get_stream_info_time(frag_stream_info); +if (timestamp != AV_NOPTS_VALUE) +return timestamp; Sorry I missed this part with patch v2, because I can't remember what did myself mean in the replying to patch v1 😊 > @@ -1288,28 +1291,27 @@ static int64_t get_frag_time(MOVFragmentIndex > *frag_index, > } > > for (i = 0; i < frag_index->item[index].nb_stream_info; i++) { > +AVStream *frag_stream = NULL; > frag_stream_info = &frag_index->item[index].stream_info[i]; > +for (j = 0; j < s->nb_streams; j++) > +if (s->streams[j]->id == frag_stream_info->id) > +frag_stream = s->streams[j]; > +if (!frag_stream) { > +av_log(s, AV_LOG_WARNING, "No stream matching sidx ID found.\n"); Neither frag_stream_info->id nor s->streams[j]->id comes from sidx ID. > +continue; > +} > timestamp = get_stream_info_time(frag_stream_info); > if (timestamp != AV_NOPTS_VALUE) > -return timestamp; > +return av_rescale_q(timestamp, frag_stream->time_base, > dst_st->time_base); > } > return AV_NOPTS_VALUE; > } > > -static int search_frag_timestamp(MOVFragmentIndex *frag_index, > +static int search_frag_timestamp(AVFormatContext *s, MOVFragmentIndex > *frag_index, > AVStream *st, int64_t timestamp) > { > int a, b, m, m0; > int64_t frag_time; > -int id = -1; > - > -if (st) { > -// If the stream is referenced by any sidx, limit the search > -// to fragments that referenced this stream in the sidx > -MOVStreamContext *sc = st->priv_data; > -if (sc->has_sidx) > -id = st->id; > -} > > a = -1; > b = frag_index->nb_items; > @@ -1318,7 +1320,7 @@ static int search_frag_timestamp(MOVFragmentIndex > *frag_index, > m0 = m = (a + b) >> 1; > > while (m < b && > - (frag_time = get_frag_time(frag_index, m, id)) == > AV_NOPTS_VALUE) > + (frag_time = get_frag_time(s, st, frag_index, m)) == > AV_NOPTS_VALUE) > m++; > > if (m < b && frag_time <= timestamp) > @@ -8862,7 +8864,7 @@ static int mov_seek_fragment(AVFormatContext *s, > AVStream *st, int64_t timestamp > if (!mov->frag_index.co
Re: [FFmpeg-devel] [PATCH] lavu/tx: implement aarch64 NEON SIMD
On Tue, Aug 16, 2022 at 1:07 PM Anton Khirnov wrote: > Quoting Lynne (2022-08-14 06:31:50) > > New - Total for len 131072 reps 4096 = 1.942836 s > > Old - Segfaults > > ??? > It is trivial. The fft code in lavc crashes in such case. > > -- > Anton Khirnov > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel 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] mov: Compare frag times in correct time base when seeking a stream without a corresponding sidx
On 8/16/2022 5:21 PM, Zhao Zhili wrote: > get_frag_time() can be called with an mp4 file which has no sidx at all. In > that case, > dst_st should have a higher priority than other streams, even if sc->has_sidx > is false. > And first_tfra_pts might be used here, which makes the check of sc->has_sidx > unnatural. > So in my opinion, the check on sc->has_sidx should be removed. This seems like it should be in a separate patch, though - it is changing a different behavior than what this patch does. > +frag_stream_info = get_frag_stream_info(frag_index, index, dst_st->id); > +timestamp = get_stream_info_time(frag_stream_info); > +if (timestamp != AV_NOPTS_VALUE) > +return timestamp; I did look at that, but I do not think it can be. get_stream_info_time is not equivalent to what is here. get_stream_info_time will eventually fall back to frag_stream_info->tfdt_dts, where as this code falls back to frag_stream_info->sidx_pts even if it is AV_NOPTS_VALUE. It would be a behavior change do use get_stream_info_time here. - Derek ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 5/5] ffmpeg: Add {h, v}scale argument to display_matrix option to allow for scaling via the display matrix
Thilo Borgmann: > --- > doc/ffmpeg.texi | 4 > fftools/ffmpeg_filter.c | 15 +++ > fftools/ffmpeg_opt.c| 10 ++ > libavutil/display.c | 21 + > libavutil/display.h | 28 > 5 files changed, 78 insertions(+) > > diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi > index 5d3e3b3052..52cca7a407 100644 > --- a/doc/ffmpeg.texi > +++ b/doc/ffmpeg.texi > @@ -923,6 +923,10 @@ The @code{-autorotate} logic will be affected. > @item hflip=@var{[0,1]} > @item vflip=@var{[0,1]} > Set a horizontal or vertical flip. > +@item hscale=@var{[0,2]} > +Set a horizontal scaling by factor of the given floating-point value. > +@item vscale=@var{[0,2]} > +Set a vertical scaling by factor of the given floating-point value. > @end table > > @item -vn (@emph{input/output}) > diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c > index f9ae76f76d..0759c08687 100644 > --- a/fftools/ffmpeg_filter.c > +++ b/fftools/ffmpeg_filter.c > @@ -778,9 +778,24 @@ static int configure_input_video_filter(FilterGraph *fg, > InputFilter *ifilter, > if (ist->autorotate && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) { > int32_t *displaymatrix = ifilter->displaymatrix; > double theta; > +double hscale = 1.0f; > +double vscale = 1.0f; > > if (!displaymatrix) > displaymatrix = (int32_t *)av_stream_get_side_data(ist->st, > AV_PKT_DATA_DISPLAYMATRIX, NULL); > + > +if (displaymatrix) { > +hscale = av_display_hscale_get(displaymatrix); > +vscale = av_display_vscale_get(displaymatrix); > + > +if (hscale != 1.0f || vscale != 1.0f) { > +char scale_buf[128]; > +snprintf(scale_buf, sizeof(scale_buf), "%f*iw:%f*ih", > hscale, vscale); > +ret = insert_filter(&last_filter, &pad_idx, "scale", > scale_buf); > +} > +} > + > + > theta = get_rotation(displaymatrix); > > if (fabs(theta - 90) < 1.0) { > diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c > index f6551621c3..4fae6cbfbf 100644 > --- a/fftools/ffmpeg_opt.c > +++ b/fftools/ffmpeg_opt.c > @@ -121,6 +121,8 @@ static const char *const opt_name_bits_per_raw_sample[] > = {"bits_per_raw_s > double rotation; > int hflip; > int vflip; > +double hscale; > +double vscale; > }; > #define OFFSET(x) offsetof(struct display_matrix_s, x) > static const AVOption display_matrix_args[] = { > @@ -130,6 +132,10 @@ static const char *const opt_name_bits_per_raw_sample[] > = {"bits_per_raw_s > { .i64 = -1 }, 0, 1, AV_OPT_FLAG_ARGUMENT}, > { "vflip","set vflip", OFFSET(vflip),AV_OPT_TYPE_BOOL, > { .i64 = -1 }, 0, 1, AV_OPT_FLAG_ARGUMENT}, > +{ "hscale", "set scale factor", OFFSET(hscale), AV_OPT_TYPE_DOUBLE, > +{ .dbl = 1.0f }, 0.0f, 2.0f, AV_OPT_FLAG_ARGUMENT}, > +{ "vscale", "set scale factor", OFFSET(vscale), AV_OPT_TYPE_DOUBLE, > +{ .dbl = 1.0f }, 0.0f, 2.0f, AV_OPT_FLAG_ARGUMENT}, > { NULL }, > }; > static const AVClass class_display_matrix_args = { > @@ -848,6 +854,8 @@ static void add_display_matrix_to_stream(OptionsContext > *o, > .rotation = DBL_MAX, > .hflip= -1, > .vflip= -1, > +.hscale= 1.0f, > +.vscale= 1.0f, > }; > > AVDictionary *global_args = NULL; > @@ -903,6 +911,8 @@ static void add_display_matrix_to_stream(OptionsContext > *o, > av_display_matrix_flip((int32_t *)buf, > hflip_set ? test_args.hflip : 0, > vflip_set ? test_args.vflip : 0); > + > +av_display_matrix_scale((int32_t *)buf, test_args.hscale, > test_args.vscale); > } > > > diff --git a/libavutil/display.c b/libavutil/display.c > index d31061283c..b89763ff48 100644 > --- a/libavutil/display.c > +++ b/libavutil/display.c > @@ -28,9 +28,11 @@ > > // fixed point to double > #define CONV_FP(x) ((double) (x)) / (1 << 16) > +#define CONV_FP2(x) ((double) (x)) / (1 << 30) > > // double to fixed point > #define CONV_DB(x) (int32_t) ((x) * (1 << 16)) > +#define CONV_DB2(x) (int32_t) ((x) * (1 << 30)) > > double av_display_rotation_get(const int32_t matrix[9]) > { > @@ -48,6 +50,17 @@ double av_display_rotation_get(const int32_t matrix[9]) > return -rotation; > } > > +double av_display_hscale_get(const int32_t matrix[9]) > +{ > +return fabs(CONV_FP2(matrix[2])); > +} > + > +double av_display_vscale_get(const int32_t matrix[9]) > +{ > +return fabs(CONV_FP2(matrix[5])); > +} > + > +#include > void av_display_rotation_set(int32_t matrix[9], double angle) > { > double radians = -angle * M_PI / 180.0f; > @@ -60,6 +73,8 @@ void av_display_rotation_set(int32_t matrix[9], double > angle) > matrix[1] = CONV_DB(-
Re: [FFmpeg-devel] [PATCH 2/3] lavc/vaapi: Add support for remaining 10/12bit profiles
On Mon, Aug 15, 2022 at 03:23:29PM -0700, Philip Langdale wrote: > On Tue, 16 Aug 2022 00:10:49 +0200 > Michael Niedermayer wrote: > > > On Sun, Aug 14, 2022 at 02:33:12PM -0700, Philip Langdale wrote: > > > With the necessary pixel formats defined, we can now expose support > > > for the remaining 10/12bit combinations that VAAPI can handle. > > > > > > Specifically, we are adding support for: > > > > > > * HEVC > > > ** 12bit 420 > > > ** 10bit 422 > > > ** 12bit 422 > > > ** 10bit 444 > > > ** 12bit 444 > > > > > > * VP9 > > > ** 10bit 422 > > > ** 10bit 444 > > > > > > These obviously require actual hardware support to be usable, but > > > where that exists, it is now enabled. > > > > > > I had to make some adjustments to the encode logic for matching bit > > > depth as the existing code assumed that the picture depth and the > > > pixel format depth were always the same, which is not true for > > > 12bit content which uses 16bit pixel formats. > > > > breaks build on ubuntu x86-64, assuming i did not miss any patch > > make > > CC libavutil/hwcontext_vaapi.o > > libavutil/hwcontext_vaapi.c:103:9: error: ‘VA_RT_FORMAT_YUV420_12’ > > undeclared here (not in a function); did you mean > > ‘VA_RT_FORMAT_YUV420’? VA_RT_FORMAT_ ## rt, \ ^ > > libavutil/hwcontext_vaapi.c:137:5: note: in expansion of macro ‘MAP’ > > MAP(P016, YUV420_12, P016, 0), > > ^~~ > > ffbuild/common.mak:81: recipe for target > > 'libavutil/hwcontext_vaapi.o' failed make: *** > > [libavutil/hwcontext_vaapi.o] Error 1 > > > > I guess there's probably a libva version dependency I need to guard > for. What version do you have installed? ii libva-dev:amd64 2.1.0-3 amd64 Video Acceleration (VA) API for Linux -- development files ii libva-drm2:amd64 2.1.0-3 amd64 Video Acceleration (VA) API for Linux -- DRM runtime ii libva-glx2:amd64 2.1.0-3 amd64 Video Acceleration (VA) API for Linux -- GLX runtime ii libva-wayland2:amd64 2.1.0-3 amd64 Video Acceleration (VA) API for Linux -- Wayland runtime ii libva-x11-2:amd64 2.1.0-3 amd64 Video Acceleration (VA) API for Linux -- X11 runtime ii libva2:amd64 2.1.0-3 amd64 Video Acceleration (VA) API for Linux -- runtime thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Breaking DRM is a little like attempting to break through a door even though the window is wide open and the only thing in the house is a bunch of things you dont want and which you would get tomorrow for free anyway signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 2/4] ffmpeg: Add display_matrix option
Am 16.08.22 um 16:10 schrieb Anton Khirnov: Quoting Thilo Borgmann (2022-08-15 22:02:09) $subject -Thilo From fe2ff114cb004f897c7774753d9cf28298eba82d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= Date: Mon, 15 Aug 2022 21:09:27 +0200 Subject: [PATCH v2 2/4] ffmpeg: Add display_matrix option This enables overriding the rotation as well as horizontal/vertical flip state of a specific video stream on the input side. Additionally, switch the singular test that was utilizing the rotation metadata to instead override the input display rotation, thus leading to the same result. --- I still don't see how it's better to squash multiple options into a single option. It requires all this extra infrastructure and in the end it's less user-friendly, because user-understandable things like rotation or flips are now hidden under "display matrix". How many users would know what a display matrix is? FWIW I think Gyan's request to do this all in one option that effect one thing (the display matrix) is valid. For the inexperienced user the use of individual filters would be the natural choice. Though i don't care much about how it's done, I can adopt to what you guys finally agree on. Having a patch for AVDict options is worth it anyways (even just for future use). -Thilo ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [FFmpeg-cvslog] fftools/ffmpeg: move stream-dependent starttime correction to transcode_init()
On Sat, Aug 13, 2022 at 12:01:30PM +, Anton Khirnov wrote: > ffmpeg | branch: master | Anton Khirnov | Tue Aug 9 > 09:51:25 2022 +0200| [86e9cef77ba8a1481a6b83fd73638f24b645bdb4] | committer: > Anton Khirnov > > fftools/ffmpeg: move stream-dependent starttime correction to transcode_init() > > Currently this code is located in the discontinuity handling block, > where it does not belong. > > > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=86e9cef77ba8a1481a6b83fd73638f24b645bdb4 > --- > > fftools/ffmpeg.c | 40 ++-- > 1 file changed, 22 insertions(+), 18 deletions(-) This seems to change the output between "start_at_zero" and "": ./ffmpeg -i ~/tickets/3176/copyts_pictures_dup.ts -copyts -an -vcodec libx264 -profile:v baseline -r 25 -s 144x96 -b:v 200k -preset ultrafast -filter:v yadif -omit_video_pes_length 0 -f mpegts /tmp/before.ts ./ffmpeg -i ~/tickets/3176/copyts_pictures_dup.ts -copyts -start_at_zero -an -vcodec libx264 -profile:v baseline -r 25 -s 144x96 -b:v 200k -preset ultrafast -filter:v yadif -omit_video_pes_length 0 -f mpegts /tmp/before-saz.ts 3409c03a6e6554cc61afcb1f43d452fe384522e1 /tmp/after-saz.ts 3409c03a6e6554cc61afcb1f43d452fe384522e1 /tmp/after.ts 3409c03a6e6554cc61afcb1f43d452fe384522e1 /tmp/before-saz.ts 2950e5d60c2386f0b73f0f73ed1dd1dee6a2a88e /tmp/before.ts not sure that was intended or not thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Why not whip the teacher when the pupil misbehaves? -- 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".
Re: [FFmpeg-devel] [PATCH] avformat/mov: don't read duration from mvhd atom
On Mon, Aug 15, 2022 at 08:14:42PM -0300, James Almer wrote: > This duration is equal to the longest duration in all track's tkhd atoms, > which > may be comprised of the sum of all edit lists in each track. Empty edit lists > in tracks represent start_time, and the actual media duration is stored in the > mdhd atom. > This change lets the generic demux code derive the longest track duration > taken > from mdhd atoms, so the correct duration and start_time combination will be > reported. > > Should fix ticket #9775. > > Signed-off-by: James Almer > --- > libavformat/mov.c| 4 > tests/ref/fate/gaplessenc-itunes-to-ipod-aac | 2 +- > 2 files changed, 1 insertion(+), 5 deletions(-) No idea if its a bad or good change but this changes the output for: ./ffmpeg -f concat -i ~/tickets/3108/concatfile.txt -codec copy -bitexact /tmp/3108.avi thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No human being will ever know the Truth, for even if they happen to say it by chance, they would not even known they had done so. -- Xenophanes 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 4/6] avcodec/mpegpicture: Don't copy unnecessarily, fix race
On Sat, Aug 13, 2022 at 05:03:04PM +0200, Andreas Rheinhardt wrote: > mpegvideo uses an array of Pictures and when it is done with using > them, it only unreferences them incompletely: Some buffers are kept > so that they can be reused lateron if the same slot in the Picture > array is reused, making this a sort of a bufferpool. > (Basically, a Picture is considered used if the AVFrame's buf is set.) > Yet given that other pieces of the decoder may have a reference to > these buffers, they need not be writable and are made writable using > av_buffer_make_writable() when preparing a new Picture. This involves > reading the buffer's data, although the old content of the buffer > need not be retained. > > Worse, this read can be racy, because the buffer can be used by another > thread at the same time. This happens for Real Video 3 and 4. > > This commit fixes this race by no longer copying the data; > instead the old buffer is replaced by a new, zero-allocated buffer. > > (Here are the details of what happens with three or more decoding threads > when decoding rv30.rm from the FATE-suite as happens in the rv30 test: > The first decoding thread uses the first slot of its picture array > to store its current pic; update_thread_context copies this for the > second thread that decodes a P-frame. It uses the second slot in its > Picture array to store its P-frame. This arrangement is then copied > to the third decode thread, which decodes a B-frame. It uses the third > slot in its Picture array for its current frame. > update_thread_context copies this to the next thread. It unreferences > the third slot containing the other B-frame and then it reuses this > slot for its current frame. Because the pic array slots are only > incompletely unreferenced, the buffers of the previous B-frame are > still in there and they are not writable; in fact the previous > thread is concurrently writing to them, causing races when making > the buffer writable.) > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/mpegpicture.c | 16 +++- > 1 file changed, 15 insertions(+), 1 deletion(-) This causes a difference in some frames of: (i have not investigates why just reporting as i noticed) quite possibly thats just showing your bugfix in action ./ffmpeg -y -bitexact -i fate/svq3/Vertical400kbit.sorenson3.mov -ps 50 -bf 1 -bitexact -an -qscale 5 -ss 40 -error_rate 4 -threads 1 /tmp/out4.avi ./ffmpeg -y -bitexact -v -1 -loglevel 0 -i /tmp/out4.avi -bitexact -vsync drop -f framecrc - @@ -141,7 +141,7 @@ 0, 22, 22,1, 115200, 0x4cc933e9 0, 23, 23,1, 115200, 0x693a40a9 0, 24, 24,1, 115200, 0x956e3b15 -0, 25, 25,1, 115200, 0x61763ff4 +0, 25, 25,1, 115200, 0xc9e53d1c 0, 26, 26,1, 115200, 0x5c5c3dfc 0, 27, 27,1, 115200, 0x7de641ea 0, 28, 28,1, 115200, 0xe6cc4136 @@ -187,7 +187,7 @@ 0, 68, 68,1, 115200, 0x49dcbf4e 0, 69, 69,1, 115200, 0x1ea1c7d1 0, 70, 70,1, 115200, 0xdf77c67b -0, 71, 71,1, 115200, 0x7f6bd16d +0, 71, 71,1, 115200, 0x33d9d206 0, 72, 72,1, 115200, 0x5e37cb3a 0, 73, 73,1, 115200, 0x15abcda3 0, 74, 74,1, 115200, 0xbf4dcbd4 @@ -199,7 +199,7 @@ 0, 80, 80,1, 115200, 0x17d1d667 0, 81, 81,1, 115200, 0x0c1fdf9c 0, 82, 82,1, 115200, 0x7eabde6b -0, 83, 83,1, 115200, 0xe623e7af +0, 83, 83,1, 115200, 0x3bf6e873 0, 84, 84,1, 115200, 0xf480dc82 0, 85, 85,1, 115200, 0x5fd6e098 0, 86, 86,1, 115200, 0xf520de95 @@ -211,7 +211,7 @@ 0, 92, 92,1, 115200, 0x34cfe1c2 0, 93, 93,1, 115200, 0x1d94e1c3 0, 94, 94,1, 115200, 0x6d32e147 -0, 95, 95,1, 115200, 0x7e40ee91 +0, 95, 95,1, 115200, 0x09fbefd0 0, 96, 96,1, 115200, 0xa5f5eb43 0, 97, 97,1, 115200, 0x39b9ec3d 0, 98, 98,1, 115200, 0x3256ec18 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Awnsering whenever a program halts or runs forever is On a turing machine, in general impossible (turings halting problem). On any real computer, always possible as a real computer has a finite number of states N, and will either halt in less than N cycles or never halt. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https:/
Re: [FFmpeg-devel] [PATCH 4/6] avcodec/mpegpicture: Don't copy unnecessarily, fix race
Michael Niedermayer: > On Sat, Aug 13, 2022 at 05:03:04PM +0200, Andreas Rheinhardt wrote: >> mpegvideo uses an array of Pictures and when it is done with using >> them, it only unreferences them incompletely: Some buffers are kept >> so that they can be reused lateron if the same slot in the Picture >> array is reused, making this a sort of a bufferpool. >> (Basically, a Picture is considered used if the AVFrame's buf is set.) >> Yet given that other pieces of the decoder may have a reference to >> these buffers, they need not be writable and are made writable using >> av_buffer_make_writable() when preparing a new Picture. This involves >> reading the buffer's data, although the old content of the buffer >> need not be retained. >> >> Worse, this read can be racy, because the buffer can be used by another >> thread at the same time. This happens for Real Video 3 and 4. >> >> This commit fixes this race by no longer copying the data; >> instead the old buffer is replaced by a new, zero-allocated buffer. >> >> (Here are the details of what happens with three or more decoding threads >> when decoding rv30.rm from the FATE-suite as happens in the rv30 test: >> The first decoding thread uses the first slot of its picture array >> to store its current pic; update_thread_context copies this for the >> second thread that decodes a P-frame. It uses the second slot in its >> Picture array to store its P-frame. This arrangement is then copied >> to the third decode thread, which decodes a B-frame. It uses the third >> slot in its Picture array for its current frame. >> update_thread_context copies this to the next thread. It unreferences >> the third slot containing the other B-frame and then it reuses this >> slot for its current frame. Because the pic array slots are only >> incompletely unreferenced, the buffers of the previous B-frame are >> still in there and they are not writable; in fact the previous >> thread is concurrently writing to them, causing races when making >> the buffer writable.) >> >> Signed-off-by: Andreas Rheinhardt >> --- >> libavcodec/mpegpicture.c | 16 +++- >> 1 file changed, 15 insertions(+), 1 deletion(-) > > This causes a difference in some frames of: (i have not investigates why > just reporting as i noticed) > quite possibly thats just showing your bugfix in action > > ./ffmpeg -y -bitexact -i fate/svq3/Vertical400kbit.sorenson3.mov -ps 50 -bf 1 > -bitexact -an -qscale 5 -ss 40 -error_rate 4 -threads 1 /tmp/out4.avi > ./ffmpeg -y -bitexact -v -1 -loglevel 0 -i /tmp/out4.avi -bitexact -vsync > drop -f framecrc - > > @@ -141,7 +141,7 @@ > 0, 22, 22,1, 115200, 0x4cc933e9 > 0, 23, 23,1, 115200, 0x693a40a9 > 0, 24, 24,1, 115200, 0x956e3b15 > -0, 25, 25,1, 115200, 0x61763ff4 > +0, 25, 25,1, 115200, 0xc9e53d1c > 0, 26, 26,1, 115200, 0x5c5c3dfc > 0, 27, 27,1, 115200, 0x7de641ea > 0, 28, 28,1, 115200, 0xe6cc4136 > @@ -187,7 +187,7 @@ > 0, 68, 68,1, 115200, 0x49dcbf4e > 0, 69, 69,1, 115200, 0x1ea1c7d1 > 0, 70, 70,1, 115200, 0xdf77c67b > -0, 71, 71,1, 115200, 0x7f6bd16d > +0, 71, 71,1, 115200, 0x33d9d206 > 0, 72, 72,1, 115200, 0x5e37cb3a > 0, 73, 73,1, 115200, 0x15abcda3 > 0, 74, 74,1, 115200, 0xbf4dcbd4 > @@ -199,7 +199,7 @@ > 0, 80, 80,1, 115200, 0x17d1d667 > 0, 81, 81,1, 115200, 0x0c1fdf9c > 0, 82, 82,1, 115200, 0x7eabde6b > -0, 83, 83,1, 115200, 0xe623e7af > +0, 83, 83,1, 115200, 0x3bf6e873 > 0, 84, 84,1, 115200, 0xf480dc82 > 0, 85, 85,1, 115200, 0x5fd6e098 > 0, 86, 86,1, 115200, 0xf520de95 > @@ -211,7 +211,7 @@ > 0, 92, 92,1, 115200, 0x34cfe1c2 > 0, 93, 93,1, 115200, 0x1d94e1c3 > 0, 94, 94,1, 115200, 0x6d32e147 > -0, 95, 95,1, 115200, 0x7e40ee91 > +0, 95, 95,1, 115200, 0x09fbefd0 > 0, 96, 96,1, 115200, 0xa5f5eb43 > 0, 97, 97,1, 115200, 0x39b9ec3d > 0, 98, 98,1, 115200, 0x3256ec18 > > [...] > Decoding this sample uses earlier values of mbskip_table. If I zero mbskip_table_buf in every ff_alloc_picture(), nothing changes due to this patch and (most importantly) the output of decoding does not depend upon the number of threads used (which it currently does -- with and without this patch). I don't know exactly where the bug is or
Re: [FFmpeg-devel] [PATCH 4/6] avcodec/mpegpicture: Don't copy unnecessarily, fix race
On Tue, Aug 16, 2022 at 10:38:55PM +0200, Andreas Rheinhardt wrote: > Michael Niedermayer: > > On Sat, Aug 13, 2022 at 05:03:04PM +0200, Andreas Rheinhardt wrote: > >> mpegvideo uses an array of Pictures and when it is done with using > >> them, it only unreferences them incompletely: Some buffers are kept > >> so that they can be reused lateron if the same slot in the Picture > >> array is reused, making this a sort of a bufferpool. > >> (Basically, a Picture is considered used if the AVFrame's buf is set.) > >> Yet given that other pieces of the decoder may have a reference to > >> these buffers, they need not be writable and are made writable using > >> av_buffer_make_writable() when preparing a new Picture. This involves > >> reading the buffer's data, although the old content of the buffer > >> need not be retained. > >> > >> Worse, this read can be racy, because the buffer can be used by another > >> thread at the same time. This happens for Real Video 3 and 4. > >> > >> This commit fixes this race by no longer copying the data; > >> instead the old buffer is replaced by a new, zero-allocated buffer. > >> > >> (Here are the details of what happens with three or more decoding threads > >> when decoding rv30.rm from the FATE-suite as happens in the rv30 test: > >> The first decoding thread uses the first slot of its picture array > >> to store its current pic; update_thread_context copies this for the > >> second thread that decodes a P-frame. It uses the second slot in its > >> Picture array to store its P-frame. This arrangement is then copied > >> to the third decode thread, which decodes a B-frame. It uses the third > >> slot in its Picture array for its current frame. > >> update_thread_context copies this to the next thread. It unreferences > >> the third slot containing the other B-frame and then it reuses this > >> slot for its current frame. Because the pic array slots are only > >> incompletely unreferenced, the buffers of the previous B-frame are > >> still in there and they are not writable; in fact the previous > >> thread is concurrently writing to them, causing races when making > >> the buffer writable.) > >> > >> Signed-off-by: Andreas Rheinhardt > >> --- > >> libavcodec/mpegpicture.c | 16 +++- > >> 1 file changed, 15 insertions(+), 1 deletion(-) > > > > This causes a difference in some frames of: (i have not investigates why > > just reporting as i noticed) > > quite possibly thats just showing your bugfix in action > > > > ./ffmpeg -y -bitexact -i fate/svq3/Vertical400kbit.sorenson3.mov -ps 50 -bf > > 1 -bitexact -an -qscale 5 -ss 40 -error_rate 4 -threads 1 /tmp/out4.avi > > ./ffmpeg -y -bitexact -v -1 -loglevel 0 -i /tmp/out4.avi -bitexact -vsync > > drop -f framecrc - > > > > @@ -141,7 +141,7 @@ > > 0, 22, 22,1, 115200, 0x4cc933e9 > > 0, 23, 23,1, 115200, 0x693a40a9 > > 0, 24, 24,1, 115200, 0x956e3b15 > > -0, 25, 25,1, 115200, 0x61763ff4 > > +0, 25, 25,1, 115200, 0xc9e53d1c > > 0, 26, 26,1, 115200, 0x5c5c3dfc > > 0, 27, 27,1, 115200, 0x7de641ea > > 0, 28, 28,1, 115200, 0xe6cc4136 > > @@ -187,7 +187,7 @@ > > 0, 68, 68,1, 115200, 0x49dcbf4e > > 0, 69, 69,1, 115200, 0x1ea1c7d1 > > 0, 70, 70,1, 115200, 0xdf77c67b > > -0, 71, 71,1, 115200, 0x7f6bd16d > > +0, 71, 71,1, 115200, 0x33d9d206 > > 0, 72, 72,1, 115200, 0x5e37cb3a > > 0, 73, 73,1, 115200, 0x15abcda3 > > 0, 74, 74,1, 115200, 0xbf4dcbd4 > > @@ -199,7 +199,7 @@ > > 0, 80, 80,1, 115200, 0x17d1d667 > > 0, 81, 81,1, 115200, 0x0c1fdf9c > > 0, 82, 82,1, 115200, 0x7eabde6b > > -0, 83, 83,1, 115200, 0xe623e7af > > +0, 83, 83,1, 115200, 0x3bf6e873 > > 0, 84, 84,1, 115200, 0xf480dc82 > > 0, 85, 85,1, 115200, 0x5fd6e098 > > 0, 86, 86,1, 115200, 0xf520de95 > > @@ -211,7 +211,7 @@ > > 0, 92, 92,1, 115200, 0x34cfe1c2 > > 0, 93, 93,1, 115200, 0x1d94e1c3 > > 0, 94, 94,1, 115200, 0x6d32e147 > > -0, 95, 95,1, 115200, 0x7e40ee91 > > +0, 95, 95,1, 115200, 0x09fbefd0 > > 0, 96, 96,1, 115200, 0xa5f5eb43 > > 0, 97, 97,1, 115200, 0x39b9ec3d > > 0, 98, 98,1, 115200, 0x3256ec18 > > > > [...] > > > > Decoding this sample uses earlier values of mbskip_table. If I zero > mbskip_table_buf in eve
Re: [FFmpeg-devel] [PATCH] ffprobe: restore reporting error code for failed inputs
On date Tuesday 2022-08-16 00:04:10 +0530, Gyan Doshi wrote: > c11fb46731 led to a regression whereby the return code for missing > input or input probe is overridden by writer close return code and > hence not conveyed in the exit code. > --- > fftools/ffprobe.c | 6 +- > 1 file changed, 5 insertions(+), 1 deletion(-) > > Affects 5.1 so will need to be backported there. > > diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c > index ad633ccc44..8983dc28cc 100644 > --- a/fftools/ffprobe.c > +++ b/fftools/ffprobe.c > @@ -4032,7 +4032,7 @@ int main(int argc, char **argv) > WriterContext *wctx; > char *buf; > char *w_name = NULL, *w_args = NULL; > -int ret, i; > +int ret, input_ret, i; > > init_dynload(); > > @@ -4156,10 +4156,14 @@ int main(int argc, char **argv) > show_error(wctx, ret); > } > > +input_ret = ret; > + > writer_print_section_footer(wctx); > ret = writer_close(&wctx); > if (ret < 0) > av_log(NULL, AV_LOG_ERROR, "Writing output failed: %s\n", > av_err2str(ret)); > + > +ret = FFMIN(ret, input_ret); maybe we should give priority to input_ret in case they are both negative? return input_ret < 0 ? input_ret : ret; ? ___ 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] API enhancements / broken promises
On date Monday 2022-08-15 18:47:34 +0200, Nicolas George wrote: > Hi. > > Over the years, I have promised quite a few enhancement to FFmpeg's API, > some of them connecting to user interface: stored error messages instead > of just logging, universal serialization of objects into various formats > (JSON, XML, etc.), a way to exfiltrate data from filters and other > components, better options parsing avoiding multiple levels of escaping, > asynchronous interface for protocols and later formats, avoiding global > state including a more reliable control of allowed components, and I > might be forgetting a few of them. > > I will not be able to make good on these promises, mostly for no fault > of mine. > > I have detailed plans on how to achieve any of these goals; I would not > have proposed otherwise. I can explain them if somebody is interested. > > A lot of these projects require a good string API. Unfortunately, my > proposal for that is being blocked by a member of the tech committee > who, by their own admission, almost never deals with strings and never > used BPrint, and whose arguments amount to “I am not convinced we need > it”, and the others members of the committee do not care enough to > override them. Just my two cents since I've admittedly not being active for the past several years, but I appreciate your contributions over the years and I like the direction you put the project on. I commented on the string API (in fact I did with the idea to kickstart a proper review process). About the tech committee, I don't know how much this changed but as far as there is a review going on and no documented technical objections during review, there should be no reason to block a new API. [...] ___ 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/ffprobe.c: avoid overriding error code.
Similar approach as: [FFmpeg-devel] [PATCH] ffprobe: restore reporting error code for failed inputs On date Monday 2022-07-18 20:40:03 +, Yubo Xie wrote: > From 7c28459fa1e8d0a375a239257601bb4e47460053 Mon Sep 17 00:00:00 2001 > From: xyb > Date: Mon, 18 Jul 2022 13:31:51 -0700 > Subject: [PATCH] [fftools/ffprobe.c] avoid overriding error code. > > --- > fftools/ffprobe.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c > index f156663019..cdd62de696 100644 > --- a/fftools/ffprobe.c > +++ b/fftools/ffprobe.c > @@ -4026,7 +4026,7 @@ int main(int argc, char **argv) > WriterContext *wctx; > char *buf; > char *w_name = NULL, *w_args = NULL; > -int ret, i; > +int ret, i, ret2 = 0; > > init_dynload(); > > @@ -4151,8 +4151,8 @@ int main(int argc, char **argv) > } > > writer_print_section_footer(wctx); > -ret = writer_close(&wctx); > -if (ret < 0) > +ret2 = writer_close(&wctx); > +if (ret2 < 0) > av_log(NULL, AV_LOG_ERROR, "Writing output failed: %s\n", > av_err2str(ret)); ret2 > } > > @@ -4167,5 +4167,5 @@ end: > > avformat_network_deinit(); > > -return ret < 0; > +return ret < 0 || ret2 < 0; LGTM otherwise (it's probably better if we just return 1 in case of failure, no need to propagate the negative error code from the main routine). ___ 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/ffprobe.c: avoid overriding error code.
Related to: [FFmpeg-devel] [PATCH] ffprobe: restore reporting error code for failed inputs On date Monday 2022-07-18 20:40:03 +, Yubo Xie wrote: > fftools/ffprobe.c: avoid overriding error code. > From 7c28459fa1e8d0a375a239257601bb4e47460053 Mon Sep 17 00:00:00 2001 > From: xyb > Date: Mon, 18 Jul 2022 13:31:51 -0700 > Subject: [PATCH] [fftools/ffprobe.c] avoid overriding error code. > > --- > fftools/ffprobe.c | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c > index f156663019..cdd62de696 100644 > --- a/fftools/ffprobe.c > +++ b/fftools/ffprobe.c > @@ -4026,7 +4026,7 @@ int main(int argc, char **argv) > WriterContext *wctx; > char *buf; > char *w_name = NULL, *w_args = NULL; > -int ret, i; > +int ret, i, ret2 = 0; > > init_dynload(); > > @@ -4151,8 +4151,8 @@ int main(int argc, char **argv) > } > > writer_print_section_footer(wctx); > -ret = writer_close(&wctx); > -if (ret < 0) > +ret2 = writer_close(&wctx); > +if (ret2 < 0) > av_log(NULL, AV_LOG_ERROR, "Writing output failed: %s\n", > av_err2str(ret)); ret2 > } > > @@ -4167,5 +4167,5 @@ end: > > avformat_network_deinit(); > > -return ret < 0; > +return ret < 0 || ret2 < 0; LGTM 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 v3] mov: Compare frag times in correct time base when seeking a stream without a corresponding sidx
On Tue, 2022-08-16 at 17:32 +0100, Derek Buitenhuis wrote: > On 8/16/2022 5:21 PM, Zhao Zhili wrote: > > get_frag_time() can be called with an mp4 file which has no sidx at > > all. In that case, > > dst_st should have a higher priority than other streams, even if > > sc->has_sidx is false. > > And first_tfra_pts might be used here, which makes the check of sc- > > >has_sidx unnatural. > > So in my opinion, the check on sc->has_sidx should be removed. > > This seems like it should be in a separate patch, though - it is > changing a different > behavior than what this patch does. OK. > > > +frag_stream_info = get_frag_stream_info(frag_index, index, > > dst_st->id); > > +timestamp = get_stream_info_time(frag_stream_info); > > +if (timestamp != AV_NOPTS_VALUE) > > +return timestamp; > > I did look at that, but I do not think it can be. > > get_stream_info_time is not equivalent to what is here. > get_stream_info_time will > eventually fall back to frag_stream_info->tfdt_dts, where as this > code falls back > to frag_stream_info->sidx_pts even if it is AV_NOPTS_VALUE. It would > be a behavior > change do use get_stream_info_time here. OK, it make sense together with `if (sc->has_sidx)`. No more comments from me. > > - Derek > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3] libavcodec/cbs_av1: Add size check before parse obu
cbs_av1_write_unit() check pbc size after parsing obu frame, and return AVERROR(ENOSPC) if pbc is small. pbc will be reallocated and this obu frame will be parsed again, but this may cause error because CodedBitstreamAV1Context has already been updated, for example ref_order_hint is updated and will not match the same obu frame. Now size check is added before parsing obu frame to avoid this error. Signed-off-by: Wenbin Chen --- libavcodec/cbs_av1.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c index 154d9156cf..9c51a8c7c8 100644 --- a/libavcodec/cbs_av1.c +++ b/libavcodec/cbs_av1.c @@ -1075,6 +1075,9 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, put_bits32(pbc, 0); } +if (8 * (unit->data_size + obu->obu_size) > put_bits_left(pbc)) +return AVERROR(ENOSPC); + td = NULL; start_pos = put_bits_count(pbc); -- 2.32.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] ffprobe: restore reporting error code for failed inputs
On 2022-08-17 04:36 am, Stefano Sabatini wrote: On date Tuesday 2022-08-16 00:04:10 +0530, Gyan Doshi wrote: c11fb46731 led to a regression whereby the return code for missing input or input probe is overridden by writer close return code and hence not conveyed in the exit code. --- fftools/ffprobe.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) Affects 5.1 so will need to be backported there. diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index ad633ccc44..8983dc28cc 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -4032,7 +4032,7 @@ int main(int argc, char **argv) WriterContext *wctx; char *buf; char *w_name = NULL, *w_args = NULL; -int ret, i; +int ret, input_ret, i; init_dynload(); @@ -4156,10 +4156,14 @@ int main(int argc, char **argv) show_error(wctx, ret); } +input_ret = ret; + writer_print_section_footer(wctx); ret = writer_close(&wctx); if (ret < 0) av_log(NULL, AV_LOG_ERROR, "Writing output failed: %s\n", av_err2str(ret)); + +ret = FFMIN(ret, input_ret); maybe we should give priority to input_ret in case they are both negative? return input_ret < 0 ? input_ret : ret; Scripts usually depend on exit code being 0 or something else. Also, error is logged for both input failure and writer_close failure, so it doesn't matter. Finally, input_ret is not initialized if writer_open fails, so we shouldn't be referencing it outside. Regards, Gyan ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] qsvenc_{hevc,h264}: add scenario option
On Tue, 2022-08-16 at 12:32 +0200, Anton Khirnov wrote: > Quoting Xiang, Haihao (2022-08-12 06:52:53) > > +#define QSV_OPTION_SCENARIO \ > > +{ "scenario", "A hint to encoder about the scenario for the encoding > > session", OFFSET(qsv.scenario), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 8, VE, > > "scenario" }, \ > > The default should probably be one of the MFX_SCENARIO flags (unknown > makes most sense I suppose) rather than 0. > Thanks for the comment, I'll change it to MFX_SCENARIO_UNKNOWN. BRs Haihao ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 2/4] ffmpeg: Add display_matrix option
On Mon, 15 Aug 2022, Thilo Borgmann wrote: diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 18e768b386..22ba654bb0 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -131,6 +131,22 @@ int64_t parse_time_or_die(const char *context, const char *timestr, return us; } +static AVDictionary *parse_dict_or_die(const char *context, + const char *dict_str) +{ +AVDictionary *dict = NULL; +int ret = av_dict_parse_string(&dict, dict_str, "=", ",", 0); Please use the av_opt syntax for the dictionary for better consistency: av_dict_parse_string(&options, val, "=", ":", 0) +if (ret < 0) { +av_log(NULL, AV_LOG_FATAL, + "Failed to create a dictionary from '%s': %s!\n", + dict_str, av_err2str(ret)); +exit_program(1); +} + + +return dict; +} + void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags, int alt_flags) { @@ -288,6 +304,8 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt, *(float *)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY); } else if (po->flags & OPT_DOUBLE) { *(double *)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY); +} else if (po->flags & OPT_DICT) { +*(AVDictionary **)dst = parse_dict_or_die(opt, arg); } else if (po->u.func_arg) { int ret = po->u.func_arg(optctx, opt, arg); if (ret < 0) { diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index d87e162ccd..6a519c6546 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -129,6 +129,7 @@ typedef struct SpecifierOpt { uint64_t ui64; float f; double dbl; +AVDictionary *dict; } u; } SpecifierOpt; @@ -157,6 +158,7 @@ typedef struct OptionDef { #define OPT_DOUBLE 0x2 #define OPT_INPUT 0x4 #define OPT_OUTPUT 0x8 +#define OPT_DICT 0x10 union { void *dst_ptr; int (*func_arg)(void *, const char *, const char *); diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 97f14b2a5b..cc038aae6b 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -62,6 +62,7 @@ #define SPECIFIER_OPT_FMT_ui64 "%"PRIu64 #define SPECIFIER_OPT_FMT_f"%f" #define SPECIFIER_OPT_FMT_dbl "%lf" +#define SPECIFIER_OPT_FMT_dict "%p" The error message which uses this will make no sense. You should modify WARN_MULTIPLE_OPT_USAGE to make something sensible out of a dict. E.g. make SPECIFIER_OPT_FMT_dict "%s" and create #define SPECIFIER_OPT_FUNC_dict as a dumper function. (the dumper function of other types can be #defined as identities) Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] libavcodec/qsvenc_hevc: add main10sp support to hevc_qsv
Main10sp is a combination of Main10 and one_pic_only flag. This profile encode 10bit single still picture. A option "main10sp" is added to ffmpeg-qsv. This option set MFX_PROFILE_HEVC_MAIN10 profile and MFX_HEVC_CONSTR_REXT_ONE_PICTURE_ONLY flag to enable main10sp in ffmpeg-qsv. Signed-off-by: Wenbin Chen --- doc/encoders.texi| 4 libavcodec/qsvenc.c | 33 +++-- libavcodec/qsvenc.h | 6 +- libavcodec/qsvenc_hevc.c | 3 +++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 6d73f74196..da6f1213c8 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -3627,6 +3627,10 @@ range is [-63, 63] for 10 bit-depth or [-75, 75] for 12 bit-depth respectively. @item @var{int_ref_cycle_dist} Distance between the beginnings of the intra-refresh cycles in frames. +@item @var{main10sp} +This option allows to encode 10 bit single still picture. This feature is only +supported in vpl runtime. + @item @var{max_qp_i} Maximum video quantizer scale for I frame. diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 4831640868..ab3500403e 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -185,6 +185,7 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, mfxExtCodingOption3 *co3 = NULL; mfxExtHEVCTiles *exthevctiles = NULL; const char *tmp_str = NULL; +mfxExtHEVCParam *exthevcparam = NULL; if (q->co2_idx > 0) co2 = (mfxExtCodingOption2*)coding_opts[q->co2_idx]; @@ -195,6 +196,8 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, if (q->exthevctiles_idx > 0) exthevctiles = (mfxExtHEVCTiles *)coding_opts[q->exthevctiles_idx]; +if (q->exthevcparam_idx > 0) +exthevcparam = (mfxExtHEVCParam *)coding_opts[q->exthevcparam_idx]; av_log(avctx, AV_LOG_VERBOSE, "profile: %s; level: %"PRIu16"\n", print_profile(avctx->codec_id, info->CodecProfile), info->CodecLevel); @@ -343,6 +346,12 @@ static void dump_video_param(AVCodecContext *avctx, QSVEncContext *q, av_log(avctx, AV_LOG_VERBOSE, "NumTileColumns: %"PRIu16"; NumTileRows: %"PRIu16"\n", exthevctiles->NumTileColumns, exthevctiles->NumTileRows); } + +if (exthevcparam && +exthevcparam->GeneralConstraintFlags == MFX_HEVC_CONSTR_REXT_ONE_PICTURE_ONLY && +avctx->codec_id == AV_CODEC_ID_HEVC && +info->CodecProfile == MFX_PROFILE_HEVC_MAIN10) +av_log(avctx, AV_LOG_VERBOSE, "Main10sp (Main10 profile and one_pic_only flag): enable\n"); } static void dump_video_vp9_param(AVCodecContext *avctx, QSVEncContext *q, @@ -956,6 +965,18 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->exthevctiles; } +if (avctx->codec_id == AV_CODEC_ID_HEVC && q->main10sp) { +if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 2, 0)) { +q->param.mfx.CodecProfile = MFX_PROFILE_HEVC_MAIN10; +q->exthevcparam.Header.BufferId = MFX_EXTBUFF_HEVC_PARAM; +q->exthevcparam.Header.BufferSz = sizeof(q->exthevcparam); +q->exthevcparam.GeneralConstraintFlags = MFX_HEVC_CONSTR_REXT_ONE_PICTURE_ONLY; +q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer *)&q->exthevcparam; +} else +av_log(avctx, AV_LOG_WARNING, + "This version of runtime doesn't support 10bit single still picture\n"); +} + q->extvsi.VideoFullRange = (avctx->color_range == AVCOL_RANGE_JPEG); q->extvsi.ColourDescriptionPresent = 0; @@ -1098,12 +1119,16 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) .Header.BufferSz = sizeof(hevc_tile_buf), }; -mfxExtBuffer *ext_buffers[6]; +mfxExtHEVCParam hevc_param_buf = { +.Header.BufferId = MFX_EXTBUFF_HEVC_PARAM, +.Header.BufferSz = sizeof(hevc_param_buf), +}; +mfxExtBuffer *ext_buffers[7]; int need_pps = avctx->codec_id != AV_CODEC_ID_MPEG2VIDEO; int ret, ext_buf_num = 0, extradata_offset = 0; -q->co2_idx = q->co3_idx = q->exthevctiles_idx = -1; +q->co2_idx = q->co3_idx = q->exthevctiles_idx = q->exthevcparam_idx = -1; ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&extradata; ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&co; @@ -1125,6 +1150,10 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) q->exthevctiles_idx = ext_buf_num; ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&hevc_tile_buf; } +if (avctx->codec_id == AV_CODEC_ID_HEVC && QSV_RUNTIME_VERSION_ATLEAST(q->ver, 2, 0)) { +q->exthevcparam_idx = ext_buf_num; +ext_buffers[ext_buf_num++] = (mfxExtBuffer*)&hevc_param_buf; +} q->param.ExtParam= ext_buffers; q->param.NumExtParam = ext_buf_num; diff --git a/lib