[FFmpeg-devel] [PATCH 2/2] configure: bump minimum AviSynth+ header version
AVISYNTH_INTERFACE_VERSION 10 fell in-between the releases of 3.7.2 and 3.7.3, and is required to be able to read the channel layout information. --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index dab3fb9036..a85122921e 100755 --- a/configure +++ b/configure @@ -6657,8 +6657,8 @@ done # these are off by default, so fail if requested and not available enabled avisynth && { require_headers "avisynth/avisynth_c.h avisynth/avs/version.h" && - { test_cpp_condition avisynth/avs/version.h "AVS_MAJOR_VER >= 3 && AVS_MINOR_VER >= 7 && AVS_BUGFIX_VER >= 1 || AVS_MAJOR_VER >= 3 && AVS_MINOR_VER > 7 || AVS_MAJOR_VER > 3" || - die "ERROR: AviSynth+ header version must be >= 3.7.1"; } } + { test_cpp_condition avisynth/avs/version.h "AVS_MAJOR_VER >= 3 && AVS_MINOR_VER >= 7 && AVS_BUGFIX_VER >= 3 || AVS_MAJOR_VER >= 3 && AVS_MINOR_VER > 7 || AVS_MAJOR_VER > 3" || + die "ERROR: AviSynth+ header version must be >= 3.7.3"; } } enabled cuda_nvcc && { check_nvcc cuda_nvcc || die "ERROR: failed checking for nvcc."; } enabled chromaprint && { check_pkg_config chromaprint libchromaprint "chromaprint.h" chromaprint_get_version || require chromaprint chromaprint.h chromaprint_get_version -lchromaprint; } -- 2.39.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] avisynth: pass audio channel layout
--- libavformat/avisynth.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index b426ac343e..027e8c63f6 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -62,6 +62,7 @@ typedef struct AviSynthLibrary { AVSC_DECLARE_FUNC(avs_create_script_environment); AVSC_DECLARE_FUNC(avs_delete_script_environment); AVSC_DECLARE_FUNC(avs_get_audio); +AVSC_DECLARE_FUNC(avs_get_channel_mask); AVSC_DECLARE_FUNC(avs_get_error); AVSC_DECLARE_FUNC(avs_get_frame); AVSC_DECLARE_FUNC(avs_get_version); @@ -157,6 +158,7 @@ static av_cold int avisynth_load_library(void) LOAD_AVS_FUNC(avs_create_script_environment, 0); LOAD_AVS_FUNC(avs_delete_script_environment, 0); LOAD_AVS_FUNC(avs_get_audio, 0); +LOAD_AVS_FUNC(avs_get_channel_mask, 1); LOAD_AVS_FUNC(avs_get_error, 1); // New to AviSynth 2.6 LOAD_AVS_FUNC(avs_get_frame, 0); LOAD_AVS_FUNC(avs_get_version, 0); @@ -793,6 +795,10 @@ static int avisynth_create_stream_audio(AVFormatContext *s, AVStream *st) st->duration= avs->vi->num_audio_samples; avpriv_set_pts_info(st, 64, 1, avs->vi->audio_samples_per_second); +if (avs_library.avs_get_version(avs->clip) >= 10) +av_channel_layout_from_mask(>codecpar->ch_layout, +avs_library.avs_get_channel_mask(avs->vi)); + switch (avs->vi->sample_type) { case AVS_SAMPLE_INT8: st->codecpar->codec_id = AV_CODEC_ID_PCM_U8; -- 2.39.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 0/2] avisynth: pass audio channel layout
AviSynth+ 3.7.3 adds the ability to define audio channel layouts, and adding it to the libavformat demuxer is trivial. Bumps the minimum required version of the AviSynth+ headers to 3.7.3. Stephen Hutchinson (2): avisynth: pass audio channel layout configure: bump minimum AviSynth+ header version configure | 4 ++-- libavformat/avisynth.c | 6 ++ 2 files changed, 8 insertions(+), 2 deletions(-) -- 2.39.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/x86/mathops: use constrained immediate operands
Should fix assembling with binutil as >= 2.41 Signed-off-by: James Almer --- This is IMO a big breakage. binutil's as has until now clipped these values on its own, and never required the compiler to do it. libavcodec/x86/mathops.h | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h index 6298f5ed19..a08c6193bf 100644 --- a/libavcodec/x86/mathops.h +++ b/libavcodec/x86/mathops.h @@ -39,7 +39,7 @@ static av_always_inline av_const int MULL(int a, int b, unsigned shift) "imull %3 \n\t" "shrdl %4, %%edx, %%eax \n\t" :"=a"(rt), "=d"(dummy) -:"a"(a), "rm"(b), "ci"((uint8_t)shift) +:"a"(a), "rm"(b), "cI"((uint8_t)shift) ); return rt; } @@ -115,16 +115,17 @@ __asm__ volatile(\ static inline int32_t NEG_SSR32( int32_t a, int8_t s){ __asm__ ("sarl %1, %0\n\t" : "+r" (a) - : "ic" ((uint8_t)(-s)) + : "Ic" ((uint8_t)(-s)) ); return a; } #define NEG_USR32 NEG_USR32 static inline uint32_t NEG_USR32(uint32_t a, int8_t s){ + __asm__ ("shrl %1, %0\n\t" : "+r" (a) - : "ic" ((uint8_t)(-s)) + : "Ic" ((uint8_t)(-s)) ); return a; } -- 2.41.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lavc/audiotoolbox: fix build failure on osx 10.5 (v3)
On 7/15/2023 4:54 PM, Marvin Scholz wrote: On 15 Jul 2023, at 21:36, Pavel Koshevoy wrote: --- libavcodec/audiotoolboxdec.c | 2 ++ libavcodec/audiotoolboxenc.c | 4 2 files changed, 6 insertions(+) diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c index 82babe3d31..5456f916cf 100644 --- a/libavcodec/audiotoolboxdec.c +++ b/libavcodec/audiotoolboxdec.c @@ -71,10 +71,12 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile) return kAudioFormatAMR; case AV_CODEC_ID_EAC3: return kAudioFormatEnhancedAC3; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 case AV_CODEC_ID_GSM_MS: return kAudioFormatMicrosoftGSM; case AV_CODEC_ID_ILBC: return kAudioFormatiLBC; +#endif case AV_CODEC_ID_MP1: return kAudioFormatMPEGLayer1; case AV_CODEC_ID_MP2: diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c index 1ccfda4d20..46aca4c7ff 100644 --- a/libavcodec/audiotoolboxenc.c +++ b/libavcodec/audiotoolboxenc.c @@ -69,15 +69,19 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile) return kAudioFormatMPEG4AAC_HE_V2; case FF_PROFILE_AAC_LD: return kAudioFormatMPEG4AAC_LD; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 case FF_PROFILE_AAC_ELD: return kAudioFormatMPEG4AAC_ELD; +#endif } case AV_CODEC_ID_ADPCM_IMA_QT: return kAudioFormatAppleIMA4; case AV_CODEC_ID_ALAC: return kAudioFormatAppleLossless; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 case AV_CODEC_ID_ILBC: return kAudioFormatiLBC; +#endif case AV_CODEC_ID_PCM_ALAW: return kAudioFormatALaw; case AV_CODEC_ID_PCM_MULAW: -- 2.35.3 Thanks, LGTM from my side though I can not push it as I have no commit access, so someone else has to do that. Applied. ___ 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 06/22] lavfi: make sure frame SAR matches the link value
On Fri, Jul 07, 2023 at 11:48:31AM +0200, Anton Khirnov wrote: > --- > libavfilter/avfilter.c | 2 ++ > 1 file changed, 2 insertions(+) Breaks aspect ratio of this, and likely others ./ffmpeg -i ~/tickets/4161/VR_MOVIE_GuyMartinsSpitfireBcast169\ qsf\ lappyAspectNoChnge_extract.mpg -bitexact -vcodec libx264 -an -vsync cfr -y file-169.ts ./ffplay file-169.ts the ffplay displays the wrong aspect and it also shows the video with the wrong aspect after this change ffmpeg-bugs/trac/ticket4161/VR_MOVIE_GuyMartinsSpitfireBcast169 qsf lappyAspectNoChnge_extract.mpg thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Old school: Use the lowest level language in which you can solve the problem conveniently. New school: Use the highest level language in which the latest supercomputer can solve the problem without the user falling asleep waiting. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] lavc/aacpsdsp: unroll RISC-V V add_squares
This does not make much difference with the Device Under Test, but since we can: Before: ps_add_squares_rvv_f32: 11973.7 After: ps_add_squares_rvv_f32: 11958.2 --- libavcodec/riscv/aacpsdsp_rvv.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/riscv/aacpsdsp_rvv.S b/libavcodec/riscv/aacpsdsp_rvv.S index b7ea314fc3..bd8f905334 100644 --- a/libavcodec/riscv/aacpsdsp_rvv.S +++ b/libavcodec/riscv/aacpsdsp_rvv.S @@ -23,15 +23,15 @@ func ff_ps_add_squares_rvv, zve32f li t1, 32 1: -vsetvli t0, a2, e32, m1, ta, ma +vsetvli t0, a2, e32, m4, ta, ma vle64.v v8, (a1) vnsrl.wxv24, v8, zero vle32.v v16, (a0) sub a2, a2, t0 -vnsrl.wxv25, v8, t1 +vnsrl.wxv28, v8, t1 vfmacc.vv v16, v24, v24 sh3add a1, t0, a1 -vfmacc.vv v16, v25, v25 +vfmacc.vv v16, v28, v28 vse32.v v16, (a0) sh2add a0, t0, a0 bneza2, 1b -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] lavc/aacpsdsp: rework RISC-V add_squares
Segmented loads are kinda slow, so this advantageously uses a unit-strided load and narrowing shifts instead. Before: ps_add_squares_rvv_f32: 30352.2 After: ps_add_squares_rvv_f32: 11973.7 --- libavcodec/riscv/aacpsdsp_rvv.S | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libavcodec/riscv/aacpsdsp_rvv.S b/libavcodec/riscv/aacpsdsp_rvv.S index 80bd19f6ad..b7ea314fc3 100644 --- a/libavcodec/riscv/aacpsdsp_rvv.S +++ b/libavcodec/riscv/aacpsdsp_rvv.S @@ -1,5 +1,5 @@ /* - * Copyright © 2022 Rémi Denis-Courmont. + * Copyright © 2022-2023 Rémi Denis-Courmont. * * This file is part of FFmpeg. * @@ -21,13 +21,16 @@ #include "libavutil/riscv/asm.S" func ff_ps_add_squares_rvv, zve32f +li t1, 32 1: vsetvli t0, a2, e32, m1, ta, ma -vlseg2e32.v v24, (a1) -sub a2, a2, t0 +vle64.v v8, (a1) +vnsrl.wxv24, v8, zero vle32.v v16, (a0) -sh3add a1, t0, a1 +sub a2, a2, t0 +vnsrl.wxv25, v8, t1 vfmacc.vv v16, v24, v24 +sh3add a1, t0, a1 vfmacc.vv v16, v25, v25 vse32.v v16, (a0) sh2add a0, t0, a0 -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/3] swscale/x86/yuv2yuvX: Process tails by jumping back into the main loop.
On Fri, Jul 14, 2023 at 12:08:46PM +0200, Alan Kelly wrote: > --- > libswscale/x86/swscale.c| 11 --- > libswscale/x86/yuv2yuvX.asm | 12 ++-- > 2 files changed, 14 insertions(+), 9 deletions(-) seems to segfault with ./ffmpeg_g -i mm-short.mpg -an -vcodec snow -t 0.2 -bitexact -pix_fmt yuv410p -s 199x199 -vstrict -2 -y snow3914-199-410.avi Thread 79 "ffmpeg_g" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fffaffef700 (LWP 23533)] 0x5658a0f6 in ff_yuv2yuvX_sse3 () (gdb) bt #0 0x5658a0f6 in ff_yuv2yuvX_sse3 () #1 0x56585bc6 in chr_planar_vscale () #2 0x565817d1 in scale_internal () #3 0x565827d9 in ff_sws_slice_worker () #4 0x5662b06e in thread_worker () #5 0x775fc6db in start_thread (arg=0x7fffaffef700) at pthread_create.c:463 #6 0x7fffed12861f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 (gdb) disassemble $rip-32,$rip+32 Dump of assembler code from 0x5658a0d6 to 0x5658a116: 0x5658a0d6 :std 0x5658a0d7 :fldenv 0xf(%rsi) 0x5658a0da :outsl %ds:(%rsi),(%dx) 0x5658a0db :sti 0x5658a0dc :psraw $0x4,%xmm7 0x5658a0e1 :movdqa %xmm7,%xmm4 0x5658a0e5 : movdqa %xmm7,%xmm3 0x5658a0e9 : movdqa %xmm7,%xmm6 0x5658a0ed : movdqa %xmm7,%xmm1 0x5658a0f1 : movddup 0x8(%rsi),%xmm0 => 0x5658a0f6 : movdqa (%rdx,%rax,2),%xmm2 0x5658a0fb : pmulhw %xmm0,%xmm2 0x5658a0ff : movdqa 0x10(%rdx,%rax,2),%xmm5 0x5658a105 : pmulhw %xmm0,%xmm5 0x5658a109 : paddw %xmm2,%xmm3 0x5658a10d : paddw %xmm5,%xmm4 0x5658a111 : movdqa 0x20(%rdx,%rax,2),%xmm2 End of assembler dump. (gdb) info all-registers rax0x12 18 rbx0x32 50 rcx0x57915480 93825029723264 rdx0x57687680 93825027044992 rsi0x5758 93825026909784 rdi0x5758 93825026909784 rbp0x5765b880 0x5765b880 rsp0x7fffaffee7a8 0x7fffaffee7a8 r8 0x20 32 r9 0x32 50 r100x56589860 93825009227872 r110x576f9dc0 93825027513792 r120x5763b280 93825026732672 r130x5758 93825026909784 r140x577b5800 93825028282368 r150x57622640 93825026631232 rip0x5658a0f6 0x5658a0f6 eflags 0x10297 [ CF PF AF SF IF RF ] cs 0x33 51 ss 0x2b 43 ds 0x0 0 es 0x0 0 fs 0x0 0 gs 0x0 0 st00(raw 0x) st10(raw 0x) st20(raw 0x) st30(raw 0x) st40(raw 0x) st50(raw 0x) st60(raw 0x) st70(raw 0x) fctrl 0x 65535 fstat 0x 65535 ftag 0x 43690 fiseg 0x1 1 fioff 0x0 0 foseg 0x5646 22086 fooff 0xa 10 fop0x7ff2047 mxcsr 0x1fa8 [ OE PE IM DM ZM OM UM PM ] > > diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c > index 52423a1199..71434f58d3 100644 > --- a/libswscale/x86/swscale.c > +++ b/libswscale/x86/swscale.c > @@ -202,17 +202,14 @@ static void yuv2yuvX_ ##opt(const int16_t *filter, int > filterSize, \ > const int16_t **src, uint8_t *dest, int dstW, \ > const uint8_t *dither, int offset) \ > { \ > -int remainder = (dstW % step); \ > -int pixelsProcessed = dstW - remainder; \ > if(((uintptr_t)dest) & 15){ \ > yuv2yuvX_mmxext(filter, filterSize, src, dest, dstW, dither, > offset); \ > return; \ > } \ > -if(pixelsProcessed > 0) \ > -ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset, > pixelsProcessed + offset, dither, offset); \ > -if(remainder > 0){ \ > - yuv2yuvX_ ##tail(filter, filterSize, src, dest, dstW, dither, offset); > \ > -} \ > +if (dstW >= step) \ > +ff_yuv2yuvX_ ##opt(filter, filterSize - 1, 0, dest - offset, dstW + > offset, dither, offset); \ > +else \ > +yuv2yuvX_ ##tail(filter, filterSize, src, dest, dstW, dither, > offset); \ > return; \ > } > > diff --git a/libswscale/x86/yuv2yuvX.asm b/libswscale/x86/yuv2yuvX.asm > index 57bfa09d66..ad0e8bd448 100644 > --- a/libswscale/x86/yuv2yuvX.asm > +++ b/libswscale/x86/yuv2yuvX.asm > @@ -54,6 +54,8 @@ cglobal yuv2yuvX, 7, 7, 8, filter, filterSize, src, dest, > dstW, dither, offset > %else > movq
Re: [FFmpeg-devel] [PATCH 4/7] checkasm: use pointers for start/stop functions
Le lauantaina 15. heinäkuuta 2023, 20.43.26 EEST Lynne a écrit : > Jul 15, 2023, 10:26 by r...@remlab.net: > > Le lauantaina 15. heinäkuuta 2023, 11.05.51 EEST Lynne a écrit : > >> Jul 14, 2023, 20:29 by r...@remlab.net: > >> > This makes all calls to the bench start and stop functions via > >> > function pointers. While the primary goal is to support run-time > >> > selection of the performance measurement back-end in later commits, > >> > this has the side benefit of containing platform dependencies in to > >> > checkasm.c and out of checkasm.h. > >> > --- > >> > > >> > tests/checkasm/checkasm.c | 33 - > >> > tests/checkasm/checkasm.h | 31 --- > >> > 2 files changed, 32 insertions(+), 32 deletions(-) > >> > >> Not sure I agree with this commit, the overhead can be detectable, > >> and we have a lot of small functions with runtime a few times that > >> of a null function call. > > > > I don't think the function call is ever null. The pointers are left NULL > > only if none of the backend initialise. But then, checkasm will bail out > > and exit before we try to benchmark anything anyway. > > > > As for the real functions, they always do *something*. None of them "just > > return 0". > > I meant a no-op function call to measure the overhead of function > calls themselves, complete with all the ABI stuff. I > > >> Can you store the function pointers out of the loop to reduce > >> the derefs needed? > > > > Taking just the two loads is out of the loop should be feasible but it > > seems a rather vain. You will still have the overhead of the indirect > > function call, the function, and most importantly in the case of Linux > > perf and MacOS kperf, the system calls. > > > > The only way to avoid the indirect function calls are to use IFUNC (tricky > > and not portable), or to make horrible macros to spawn one bench loop for > > each backend. > > > > In the end, I think we should rather aim for as constant time as possible, > > rather than as fast as possible, so that the nop loop can estimate the > > benchmarking overhead as well as possible. In this respect, I think it is > > actually marginally better *not* to cache the function pointers in local > > variables, which could end up spilled on the stack, or not, depending on > > local compiler optimisations for any given test case. > > I disagree, uninlining the timer fetches adds another source of > inconsistency. Err, outlining the timer makes sure that it's always the exact same code that's run, and not differently optimised inlinings, at least if LTO is absent. (And even with LTO, it vastly reduces the compiler's ability to optimise and vary the compilation.) Again, given how the calculations are made at the moment, the stability of the overhead is important, so that we can *compare* measurements. The absolute value of the overhead, not so much. But I still argue that that is, either way, completely negligible compared to the *existing* overhead. Each loop is making 4 system calls, and each of those system call requires a direct call (to PLT) and an indirect branch (from GOT). If you have a problem with the two additional function calls, then you can't be using Linux perf in the first place. -- レミ・デニ-クールモン http://www.remlab.net/ ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] git email hook
On Sat, Jul 15, 2023 at 08:34:10PM +0200, Nicolas George wrote: > Michael Niedermayer (12023-07-14): > > I today added and tested git-multimail to git.ffmpeg.org as our git mail > > sending script is old and unmaintained > > > > I intend to use libavradio for testing it, this will result in > > different looking mails for avradio. (probably on the next push in a day or > > 2) > > If that goes well i intend to switch ffmpeg-web and all repositories > > that are on git.ffmpeg.org over to it too. But its easy to leave some > > on the old script if people prefer. > > I hope though the new will produce nicer mails. > > (this is unrelated to git master for which videolan is doing the git mail) > > > > No ill sideeffects are expected but unexpected things are always possible. > > Hi. > > Can the "branch master updated:" be removed? We only work on master > anyway, it takes up space and the interesting part of the commit subject > gets truncated. send me a patch for git-multimail-py or suggest something to replace: (but it has to work for all repos we have, i dont want to have to maintain this per repo really) REF_CREATED_SUBJECT_TEMPLATE = ( '%(emailprefix)s%(refname_type)s %(short_refname)s created' ' (now %(newrev_short)s)' ) REF_UPDATED_SUBJECT_TEMPLATE = ( '%(emailprefix)s%(refname_type)s %(short_refname)s updated' ' (%(oldrev_short)s -> %(newrev_short)s)' ) REF_DELETED_SUBJECT_TEMPLATE = ( '%(emailprefix)s%(refname_type)s %(short_refname)s deleted' ' (was %(oldrev_short)s)' ) COMBINED_REFCHANGE_REVISION_SUBJECT_TEMPLATE = ( '%(emailprefix)s%(refname_type)s %(short_refname)s updated: %(oneline)s' ) thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many that live deserve death. And some that die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement. For even the very wise cannot see all ends. -- Gandalf 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 25/33] fftools/ffmpeg_filter: stop disregarding user-specified pixel format
Hi On Fri, Jul 14, 2023 at 07:06:15PM +0200, Anton Khirnov wrote: > Quoting Michael Niedermayer (2023-07-14 17:47:19) > > On Fri, Jul 14, 2023 at 11:44:07AM +0200, Anton Khirnov wrote: > > > Quoting Michael Niedermayer (2023-07-14 01:11:07) > > > > On Thu, Jul 13, 2023 at 12:55:45PM +0200, Anton Khirnov wrote: > > > > > When the user explicitly specifies a pixel format that is not > > > > > supported > > > > > by the encoder, ffmpeg CLI will currently use some heuristics to pick > > > > > another supported format. This is wrong and the correct action here is > > > > > to fail. > > > > > > > > > > Surprisingly, a number of FATE tests are affected by this and actually > > > > > use a different pixel format than is specified in the makefiles. > > > > > --- > > > > > doc/ffmpeg.texi | 3 +- > > > > > fftools/ffmpeg_filter.c | 35 > > > > > +-- > > > > > tests/fate/fits.mak | 6 ++-- > > > > > tests/fate/lavf-video.mak | 2 +- > > > > > tests/fate/vcodec.mak | 4 +-- > > > > > .../{fitsdec-gbrap16le => fitsdec-gbrap16be} | 4 +-- > > > > > .../fate/{fitsdec-gbrp16 => fitsdec-gbrp16be} | 4 +-- > > > > > tests/ref/lavf/gif| 2 +- > > > > > 8 files changed, 13 insertions(+), 47 deletions(-) > > > > > rename tests/ref/fate/{fitsdec-gbrap16le => fitsdec-gbrap16be} (79%) > > > > > rename tests/ref/fate/{fitsdec-gbrp16 => fitsdec-gbrp16be} (79%) > > > > > > > > > > diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi > > > > > index 6769f8d305..08b11097b7 100644 > > > > > --- a/doc/ffmpeg.texi > > > > > +++ b/doc/ffmpeg.texi > > > > > @@ -1014,8 +1014,7 @@ Disable autoscale at your own risk. > > > > > @item -pix_fmt[:@var{stream_specifier}] @var{format} > > > > > (@emph{input/output,per-stream}) > > > > > Set pixel format. Use @code{-pix_fmts} to show all the supported > > > > > pixel formats. > > > > > -If the selected pixel format can not be selected, ffmpeg will print a > > > > > -warning and select the best pixel format supported by the encoder. > > > > > + > > > > > If @var{pix_fmt} is prefixed by a @code{+}, ffmpeg will exit with an > > > > > error > > > > > if the requested pixel format can not be selected, and automatic > > > > > conversions > > > > > inside filtergraphs are disabled. > > > > > > > > The commit message makes this sound like a bugfix, while really this is > > > > removing a documented feature. > > > > > > It is a bugfix in my eyes. When you explicitly tell a program to perform > > > a specific action, and the program just decides to do something else, > > > then that program is broken. > > > > > > As far as I can tell, this "feature" was added by you in 89f86379797 > > > with no explanation or documentation beyond 'fix regression with png'. > > > It was later documented in a largely-unrelated commit that added > > > something else. > > > > > > I see no argument whatsoever for why we should have such a "smart" > > > > As said previously, > > The user cannot be expected to know if a implementation uses planar > > or packed rgb, bgr or rgb. > > Which is why > * libavfilter will by default convert to a format supported by the > encoder If the user uses -pix_fmt she likely doesnt want "any" format but has a preferrance for some reason like 8bit or rgb for example > * libavcodec will now helpfully print a list of formats supported by the > encoder if the caller gives it a wrong one Thats good, but its a case per case adjustment. > > > This is not a inherent part of the file/stream/input in many cases > > its not a problem for you because you are a FFmpeg developer and work > > with this every day but it is a inconvenience for users > > Should we then replace any failing commandline with something that will > not fail? Ignore any options with incorrect values? All in the name of > convenience? Maybe you should try web development. -pix_fmt is not "any command line" https://en.wikipedia.org/wiki/Straw_man > > Programs that try to second-guess user's explicit instructions are > broken by design. Maybe but the pix_fmt has 2 syntaxes one for explicit instructions and one for a close one. Your patch modifies the "pick a close one" path > This "convenience" argument is entirely specious: > * users who do not know what they want get something that works by > default Thats not true, 16bit yuv might not work for example for the users case > * users who specify a wrong format get a list of correct formats they > can just pick from; that is as convenient as it gets for this kind of > a program it works probably for most cases but its an extra step for the user and a change in command line syntax > * users who require yet more convenience and/or handholding can use a > graphical program such as Handbrake; we should not try to be > Handbrake, they are better at it than us I dont understand
Re: [FFmpeg-devel] [PATCH] lavc/audiotoolbox: fix build failure on osx 10.5 (v3)
On 15 Jul 2023, at 21:36, Pavel Koshevoy wrote: > --- > libavcodec/audiotoolboxdec.c | 2 ++ > libavcodec/audiotoolboxenc.c | 4 > 2 files changed, 6 insertions(+) > > diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c > index 82babe3d31..5456f916cf 100644 > --- a/libavcodec/audiotoolboxdec.c > +++ b/libavcodec/audiotoolboxdec.c > @@ -71,10 +71,12 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, > int profile) > return kAudioFormatAMR; > case AV_CODEC_ID_EAC3: > return kAudioFormatEnhancedAC3; > +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 > case AV_CODEC_ID_GSM_MS: > return kAudioFormatMicrosoftGSM; > case AV_CODEC_ID_ILBC: > return kAudioFormatiLBC; > +#endif > case AV_CODEC_ID_MP1: > return kAudioFormatMPEGLayer1; > case AV_CODEC_ID_MP2: > diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c > index 1ccfda4d20..46aca4c7ff 100644 > --- a/libavcodec/audiotoolboxenc.c > +++ b/libavcodec/audiotoolboxenc.c > @@ -69,15 +69,19 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, > int profile) > return kAudioFormatMPEG4AAC_HE_V2; > case FF_PROFILE_AAC_LD: > return kAudioFormatMPEG4AAC_LD; > +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 > case FF_PROFILE_AAC_ELD: > return kAudioFormatMPEG4AAC_ELD; > +#endif > } > case AV_CODEC_ID_ADPCM_IMA_QT: > return kAudioFormatAppleIMA4; > case AV_CODEC_ID_ALAC: > return kAudioFormatAppleLossless; > +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 > case AV_CODEC_ID_ILBC: > return kAudioFormatiLBC; > +#endif > case AV_CODEC_ID_PCM_ALAW: > return kAudioFormatALaw; > case AV_CODEC_ID_PCM_MULAW: > -- > 2.35.3 Thanks, LGTM from my side though I can not push it as I have no commit access, so someone else has to do that. > > ___ > 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] lavc/audiotoolbox: fix build failure on osx 10.5 (v2)
On Sat, Jul 15, 2023 at 10:11 AM Marvin Scholz wrote: > On 15 Jul 2023, at 17:40, Pavel Koshevoy wrote: > > > --- > > libavcodec/audiotoolboxdec.c | 2 ++ > > libavcodec/audiotoolboxenc.c | 4 > > 2 files changed, 6 insertions(+) > > > > Hi, thanks for the patch, small remark below: > > > diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c > > index 82babe3d31..e336aade8b 100644 > > --- a/libavcodec/audiotoolboxdec.c > > +++ b/libavcodec/audiotoolboxdec.c > > @@ -71,10 +71,12 @@ static UInt32 ffat_get_format_id(enum AVCodecID > codec, int profile) > > return kAudioFormatAMR; > > case AV_CODEC_ID_EAC3: > > return kAudioFormatEnhancedAC3; > > +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060 > > case AV_CODEC_ID_GSM_MS: > > return kAudioFormatMicrosoftGSM; > > case AV_CODEC_ID_ILBC: > > return kAudioFormatiLBC; > > +#endif > > case AV_CODEC_ID_MP1: > > return kAudioFormatMPEGLayer1; > > case AV_CODEC_ID_MP2: > > diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c > > index 1ccfda4d20..e5217d952d 100644 > > --- a/libavcodec/audiotoolboxenc.c > > +++ b/libavcodec/audiotoolboxenc.c > > @@ -69,15 +69,19 @@ static UInt32 ffat_get_format_id(enum AVCodecID > codec, int profile) > > return kAudioFormatMPEG4AAC_HE_V2; > > case FF_PROFILE_AAC_LD: > > return kAudioFormatMPEG4AAC_LD; > > +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060 > > I think you should use __MAC_OS_X_VERSION_MIN_REQUIRED, as the > __ENVIRONMENT_* is > an implementation detail and not documented IIRC. (Same below) > Okay, I've sent v3 with MAC_OS_X_VERSION_MIN_REQUIRED. Thank you, Pavel. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] lavc/audiotoolbox: fix build failure on osx 10.5 (v3)
--- libavcodec/audiotoolboxdec.c | 2 ++ libavcodec/audiotoolboxenc.c | 4 2 files changed, 6 insertions(+) diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c index 82babe3d31..5456f916cf 100644 --- a/libavcodec/audiotoolboxdec.c +++ b/libavcodec/audiotoolboxdec.c @@ -71,10 +71,12 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile) return kAudioFormatAMR; case AV_CODEC_ID_EAC3: return kAudioFormatEnhancedAC3; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 case AV_CODEC_ID_GSM_MS: return kAudioFormatMicrosoftGSM; case AV_CODEC_ID_ILBC: return kAudioFormatiLBC; +#endif case AV_CODEC_ID_MP1: return kAudioFormatMPEGLayer1; case AV_CODEC_ID_MP2: diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c index 1ccfda4d20..46aca4c7ff 100644 --- a/libavcodec/audiotoolboxenc.c +++ b/libavcodec/audiotoolboxenc.c @@ -69,15 +69,19 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile) return kAudioFormatMPEG4AAC_HE_V2; case FF_PROFILE_AAC_LD: return kAudioFormatMPEG4AAC_LD; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 case FF_PROFILE_AAC_ELD: return kAudioFormatMPEG4AAC_ELD; +#endif } case AV_CODEC_ID_ADPCM_IMA_QT: return kAudioFormatAppleIMA4; case AV_CODEC_ID_ALAC: return kAudioFormatAppleLossless; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 case AV_CODEC_ID_ILBC: return kAudioFormatiLBC; +#endif case AV_CODEC_ID_PCM_ALAW: return kAudioFormatALaw; case AV_CODEC_ID_PCM_MULAW: -- 2.35.3 ___ 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] git email hook
Michael Niedermayer (12023-07-14): > I today added and tested git-multimail to git.ffmpeg.org as our git mail > sending script is old and unmaintained > > I intend to use libavradio for testing it, this will result in > different looking mails for avradio. (probably on the next push in a day or 2) > If that goes well i intend to switch ffmpeg-web and all repositories > that are on git.ffmpeg.org over to it too. But its easy to leave some > on the old script if people prefer. > I hope though the new will produce nicer mails. > (this is unrelated to git master for which videolan is doing the git mail) > > No ill sideeffects are expected but unexpected things are always possible. Hi. Can the "branch master updated:" be removed? We only work on master anyway, it takes up space and the interesting part of the commit subject gets truncated. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] fftools: Avoid build failure on OSX 10.6 with gcc 4.2.1
... and make code more readable / human friendly. --- fftools/ffmpeg_mux_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 6458414b5f..bade35896f 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1648,7 +1648,8 @@ read_fail: static int create_streams(Muxer *mux, const OptionsContext *o) { -static const int (*map_func[])(Muxer *mux, const OptionsContext *o) = { +typedef int(*TMapFunc)(Muxer *, const OptionsContext *); +static const TMapFunc map_func[] = { [AVMEDIA_TYPE_VIDEO]= map_auto_video, [AVMEDIA_TYPE_AUDIO]= map_auto_audio, [AVMEDIA_TYPE_SUBTITLE] = map_auto_subtitle, -- 2.35.3 ___ 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/7] checkasm: use pointers for start/stop functions
Jul 15, 2023, 10:26 by r...@remlab.net: > Le lauantaina 15. heinäkuuta 2023, 11.05.51 EEST Lynne a écrit : > >> Jul 14, 2023, 20:29 by r...@remlab.net: >> > This makes all calls to the bench start and stop functions via >> > function pointers. While the primary goal is to support run-time >> > selection of the performance measurement back-end in later commits, >> > this has the side benefit of containing platform dependencies in to >> > checkasm.c and out of checkasm.h. >> > --- >> > >> > tests/checkasm/checkasm.c | 33 - >> > tests/checkasm/checkasm.h | 31 --- >> > 2 files changed, 32 insertions(+), 32 deletions(-) >> >> Not sure I agree with this commit, the overhead can be detectable, >> and we have a lot of small functions with runtime a few times that >> of a null function call. >> > > I don't think the function call is ever null. The pointers are left NULL only > if none of the backend initialise. But then, checkasm will bail out and exit > before we try to benchmark anything anyway. > > As for the real functions, they always do *something*. None of them "just > return 0". > I meant a no-op function call to measure the overhead of function calls themselves, complete with all the ABI stuff. >> Can you store the function pointers out of the loop to reduce >> the derefs needed? >> > > Taking just the two loads is out of the loop should be feasible but it seems > a > rather vain. You will still have the overhead of the indirect function call, > the function, and most importantly in the case of Linux perf and MacOS kperf, > the system calls. > > The only way to avoid the indirect function calls are to use IFUNC (tricky > and > not portable), or to make horrible macros to spawn one bench loop for each > backend. > > In the end, I think we should rather aim for as constant time as possible, > rather than as fast as possible, so that the nop loop can estimate the > benchmarking overhead as well as possible. In this respect, I think it is > actually marginally better *not* to cache the function pointers in local > variables, which could end up spilled on the stack, or not, depending on > local > compiler optimisations for any given test case. > I disagree, uninlining the timer fetches adds another source of inconsistency. It may be messy, but I think accuracy here is more important than cleanliness, especially as it's a development tool. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/mpegvideo_dec: properly set output frames as keyframes
On Fri, Jul 14, 2023 at 3:32 PM James Almer wrote: > > Should fix ticket #10426. > > Signed-off-by: James Almer > --- > libavcodec/mpegvideo_dec.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c > index fcca147cd6..670b0912e2 100644 > --- a/libavcodec/mpegvideo_dec.c > +++ b/libavcodec/mpegvideo_dec.c > @@ -344,9 +344,9 @@ FF_ENABLE_DEPRECATION_WARNINGS > > s->current_picture_ptr->f->pict_type = s->pict_type; > if (s->pict_type == AV_PICTURE_TYPE_I) > -s->current_picture.f->flags |= AV_FRAME_FLAG_KEY; > +s->current_picture_ptr->f->flags |= AV_FRAME_FLAG_KEY; > else > -s->current_picture.f->flags &= ~AV_FRAME_FLAG_KEY; > +s->current_picture_ptr->f->flags &= ~AV_FRAME_FLAG_KEY; > Seems to fix the not-meant-to-happen switch from `s->current_picture_ptr->f` to `s->current_picture.f` that occurred in dc7bd7c5a5ad5ea800dfb63cc5dd15670d065527 . Thus LGTM. Jan ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avradio/sdrdemux: avoid repeated litteral number
On Fri, Jul 14, 2023 at 08:03:40PM +0200, Michael Niedermayer wrote: > Signed-off-by: Michael Niedermayer > --- > libavradio/sdrdemux.c | 16 +--- > 1 file changed, 9 insertions(+), 7 deletions(-) will apply patchset [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Take away the freedom of one citizen and you will be jailed, take away the freedom of all citizens and you will be congratulated by your peers in Parliament. 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] lavc/audiotoolbox: fix build failure on osx 10.5 (v2)
On 15 Jul 2023, at 17:40, Pavel Koshevoy wrote: > --- > libavcodec/audiotoolboxdec.c | 2 ++ > libavcodec/audiotoolboxenc.c | 4 > 2 files changed, 6 insertions(+) > Hi, thanks for the patch, small remark below: > diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c > index 82babe3d31..e336aade8b 100644 > --- a/libavcodec/audiotoolboxdec.c > +++ b/libavcodec/audiotoolboxdec.c > @@ -71,10 +71,12 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, > int profile) > return kAudioFormatAMR; > case AV_CODEC_ID_EAC3: > return kAudioFormatEnhancedAC3; > +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060 > case AV_CODEC_ID_GSM_MS: > return kAudioFormatMicrosoftGSM; > case AV_CODEC_ID_ILBC: > return kAudioFormatiLBC; > +#endif > case AV_CODEC_ID_MP1: > return kAudioFormatMPEGLayer1; > case AV_CODEC_ID_MP2: > diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c > index 1ccfda4d20..e5217d952d 100644 > --- a/libavcodec/audiotoolboxenc.c > +++ b/libavcodec/audiotoolboxenc.c > @@ -69,15 +69,19 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, > int profile) > return kAudioFormatMPEG4AAC_HE_V2; > case FF_PROFILE_AAC_LD: > return kAudioFormatMPEG4AAC_LD; > +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060 I think you should use __MAC_OS_X_VERSION_MIN_REQUIRED, as the __ENVIRONMENT_* is an implementation detail and not documented IIRC. (Same below) > case FF_PROFILE_AAC_ELD: > return kAudioFormatMPEG4AAC_ELD; > +#endif > } > case AV_CODEC_ID_ADPCM_IMA_QT: > return kAudioFormatAppleIMA4; > case AV_CODEC_ID_ALAC: > return kAudioFormatAppleLossless; > +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060 > case AV_CODEC_ID_ILBC: > return kAudioFormatiLBC; > +#endif > case AV_CODEC_ID_PCM_ALAW: > return kAudioFormatALaw; > case AV_CODEC_ID_PCM_MULAW: > -- > 2.35.3 > > ___ > 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] lavc/audiotoolbox: fix build failure on osx 10.5
On Fri, Jul 14, 2023 at 7:34 PM James Almer wrote: > On 7/11/2023 11:10 AM, Pavel Koshevoy wrote: > > --- > > libavcodec/audiotoolboxdec.c | 2 ++ > > libavcodec/audiotoolboxenc.c | 4 > > 2 files changed, 6 insertions(+) > > > > diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c > > index 82babe3d31..7b33cdf87d 100644 > > --- a/libavcodec/audiotoolboxdec.c > > +++ b/libavcodec/audiotoolboxdec.c > > @@ -71,10 +71,12 @@ static UInt32 ffat_get_format_id(enum AVCodecID > codec, int profile) > > return kAudioFormatAMR; > > case AV_CODEC_ID_EAC3: > > return kAudioFormatEnhancedAC3; > > +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1058 > > Wouldn't it be better to do >= with the actual version where all this is > first available? > I suppose... I've submitted a 2nd version of the patch. Thank you, Pavel. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] lavc/audiotoolbox: fix build failure on osx 10.5 (v2)
--- libavcodec/audiotoolboxdec.c | 2 ++ libavcodec/audiotoolboxenc.c | 4 2 files changed, 6 insertions(+) diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c index 82babe3d31..e336aade8b 100644 --- a/libavcodec/audiotoolboxdec.c +++ b/libavcodec/audiotoolboxdec.c @@ -71,10 +71,12 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile) return kAudioFormatAMR; case AV_CODEC_ID_EAC3: return kAudioFormatEnhancedAC3; +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060 case AV_CODEC_ID_GSM_MS: return kAudioFormatMicrosoftGSM; case AV_CODEC_ID_ILBC: return kAudioFormatiLBC; +#endif case AV_CODEC_ID_MP1: return kAudioFormatMPEGLayer1; case AV_CODEC_ID_MP2: diff --git a/libavcodec/audiotoolboxenc.c b/libavcodec/audiotoolboxenc.c index 1ccfda4d20..e5217d952d 100644 --- a/libavcodec/audiotoolboxenc.c +++ b/libavcodec/audiotoolboxenc.c @@ -69,15 +69,19 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, int profile) return kAudioFormatMPEG4AAC_HE_V2; case FF_PROFILE_AAC_LD: return kAudioFormatMPEG4AAC_LD; +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060 case FF_PROFILE_AAC_ELD: return kAudioFormatMPEG4AAC_ELD; +#endif } case AV_CODEC_ID_ADPCM_IMA_QT: return kAudioFormatAppleIMA4; case AV_CODEC_ID_ALAC: return kAudioFormatAppleLossless; +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060 case AV_CODEC_ID_ILBC: return kAudioFormatiLBC; +#endif case AV_CODEC_ID_PCM_ALAW: return kAudioFormatALaw; case AV_CODEC_ID_PCM_MULAW: -- 2.35.3 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 6/7] checkasm: allow run-time fallback to AV_READ_TIME
On Linux RISC-V, depending on kernel version and configuration, the cycle counters may be available: - via Linux perf (as on Arm), - directly with RDCYCLE (which is considered legacy), - neither (if admistratively disabled), or - or both (in legacy compatibility mode). This allows to try Linux perf, with a fallback to RDCYCLE. Without this, bench will stop working in upcoming kernel releases. --- tests/checkasm/checkasm.c | 29 - 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 2e327de3a4..ad2dc9ab5a 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -708,7 +708,8 @@ static int bench_init_linux(void) checkasm_bench_close = checkasm_bench_linux_perf_close; return 0; } -#elif CONFIG_MACOS_KPERF +#endif +#if CONFIG_MACOS_KPERF static int bench_init_kperf(void) { ff_kperf_init(); @@ -727,25 +728,27 @@ static int bench_init_ffmpeg(void) checkasm_bench_start = checkasm_bench_stop = ff_read_time; return 0; } -#else -static int bench_init_ffmpeg(void) -{ -fprintf(stderr, "checkasm: --bench is not supported on your system\n"); -return -1; -} #endif static int bench_init(void) { +int ret = -1; #if CONFIG_LINUX_PERF -int ret = bench_init_linux(); -#elif CONFIG_MACOS_KPERF -int ret = bench_init_kperf(); -#else -int ret = bench_init_ffmpeg(); +if (ret < 0) +ret = bench_init_linux(); +#endif +#if CONFIG_MACOS_KPERF +if (ret < 0) +ret = bench_init_kperf(); #endif +#ifdef AV_READ_TIME if (ret < 0) -return ret; +ret = bench_init_ffmpeg(); +#endif +if (ret < 0) { +fputs("checkasm: --bench is not supported on your system\n", stderr); +return -1; +} state.nop_time = measure_nop_time(); printf("nop: %d.%d\n", state.nop_time/10, state.nop_time%10); -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 5/7] checkasm: make bench clean-up also a function pointer
Because we might as well at this point. This incidentally fixes a corner case bug that state.sys_fd == 0 could be either the initial value from .bss or a valid file descriptor (in which case it didn't get closed). --- tests/checkasm/checkasm.c | 20 +++- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index c90f361ff7..2e327de3a4 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -319,7 +319,9 @@ static struct { /* perf */ int nop_time; +#ifdef CONFIG_LINUX_PERF int sysfd; +#endif int cpu_flag; const char *cpu_flag_name; @@ -516,6 +518,7 @@ static int cmp_nop(const void *a, const void *b) static uint64_t (*checkasm_bench_start)(void); static uint64_t (*checkasm_bench_stop)(void); +static void (*checkasm_bench_close)(void); /* Measure the overhead of the timing code (in decicycles) */ static int measure_nop_time(void) @@ -677,6 +680,11 @@ static uint64_t checkasm_bench_linux_perf_stop(void) return (read(fd, , sizeof(t)) == sizeof (t)) ? t : 0; } +static void checkasm_bench_linux_perf_close(void) +{ +close(state.sysfd); +} + static int bench_init_linux(void) { struct perf_event_attr attr = { @@ -697,6 +705,7 @@ static int bench_init_linux(void) } checkasm_bench_start = checkasm_bench_linux_perf_start; checkasm_bench_stop = checkasm_bench_linux_perf_stop; +checkasm_bench_close = checkasm_bench_linux_perf_close; return 0; } #elif CONFIG_MACOS_KPERF @@ -743,14 +752,6 @@ static int bench_init(void) return 0; } -static void bench_uninit(void) -{ -#if CONFIG_LINUX_PERF -if (state.sysfd > 0) -close(state.sysfd); -#endif -} - int main(int argc, char *argv[]) { unsigned int seed = av_get_random_seed(); @@ -805,7 +806,8 @@ int main(int argc, char *argv[]) } destroy_func_tree(state.funcs); -bench_uninit(); +if (checkasm_bench_close != NULL) +checkasm_bench_close(); return ret; } -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 7/7] configure: enable Linux perf on RISC-V by default
Now that checkasm can automatically fall back to RDCYCLE, it is safe to enable this for forward compatibility with kernel versions mitigating the "Cycle Drift" side channel attack. Where available, this should also reduce measurement noise, since kernel and hypervisor cycles should no longer be counted. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 0ab0761011..3be074e15b 100755 --- a/configure +++ b/configure @@ -5754,7 +5754,7 @@ case $target_os in ;; linux) enable section_data_rel_ro -enabled_any arm aarch64 && enable_weak linux_perf +enabled_any arm aarch64 riscv && enable_weak linux_perf ;; irix*) target_os=irix -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/7] checkasm: remove unused variables
--- tests/checkasm/checkasm.c | 2 -- tests/checkasm/checkasm.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index e921257257..c90f361ff7 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -522,7 +522,6 @@ static int measure_nop_time(void) { uint16_t nops[1]; int i, nop_sum = 0; -av_unused const int sysfd = state.sysfd; for (i = 0; i < 1; i++) { uint64_t t = checkasm_bench_start(); @@ -889,7 +888,6 @@ CheckasmPerf *checkasm_get_perf_context(void) { CheckasmPerf *perf = _func_ver->perf; memset(perf, 0, sizeof(*perf)); -perf->sysfd = state.sysfd; perf->start = checkasm_bench_start; perf->stop = checkasm_bench_start; return perf; diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 8f966f49af..6a3f826a7f 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -224,7 +224,6 @@ void *checkasm_get_wrapper(void); #endif typedef struct CheckasmPerf { -int sysfd; uint64_t cycles; int iterations; uint64_t (*start)(void); @@ -236,7 +235,6 @@ typedef struct CheckasmPerf { do {\ if (checkasm_bench_func()) {\ struct CheckasmPerf *perf = checkasm_get_perf_context();\ -av_unused const int sysfd = perf->sysfd;\ uint64_t (*const start)(void) = perf->start;\ uint64_t (*const stop)(void) = perf->stop;\ func_type *tfunc = func_new;\ -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/7] checkasm: use pointers for start/stop functions
This makes all calls to the bench start and stop functions via function pointers. While the primary goal is to support run-time selection of the performance measurement back-end in later commits, this has the side benefit of containing platform dependencies in to checkasm.c and out of checkasm.h. --- tests/checkasm/checkasm.c | 33 - tests/checkasm/checkasm.h | 33 ++--- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index d8f571f301..e921257257 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -57,6 +57,14 @@ #if HAVE_UNISTD_H #include #endif +#if CONFIG_LINUX_PERF +#include +#include +#include +#endif +#if CONFIG_MACOS_KPERF +#include "libavutil/macos_kperf.h" +#endif #if !HAVE_ISATTY #define isatty(fd) 1 @@ -506,6 +514,9 @@ static int cmp_nop(const void *a, const void *b) return *(const uint16_t*)a - *(const uint16_t*)b; } +static uint64_t (*checkasm_bench_start)(void); +static uint64_t (*checkasm_bench_stop)(void); + /* Measure the overhead of the timing code (in decicycles) */ static int measure_nop_time(void) { @@ -649,7 +660,7 @@ static void print_cpu_name(void) } #if CONFIG_LINUX_PERF -uint64_t checkasm_bench_linux_perf_start(void) +static uint64_t checkasm_bench_linux_perf_start(void) { int fd = state.sysfd; @@ -658,7 +669,7 @@ uint64_t checkasm_bench_linux_perf_start(void) return 0; } -uint64_t checkasm_bench_linux_perf_stop(void) +static uint64_t checkasm_bench_linux_perf_stop(void) { uint64_t t; int fd = state.sysfd; @@ -685,24 +696,34 @@ static int bench_init_linux(void) perror("perf_event_open"); return -1; } +checkasm_bench_start = checkasm_bench_linux_perf_start; +checkasm_bench_stop = checkasm_bench_linux_perf_stop; return 0; } #elif CONFIG_MACOS_KPERF static int bench_init_kperf(void) { ff_kperf_init(); +checkasm_bench_start = checkasm_bench_stop = ff_kperf_cycles; return 0; } -#else +#elif defined (AV_READ_TIME) +static uint64_t ff_read_time(void) +{ +return AV_READ_TIME(); +} + static int bench_init_ffmpeg(void) { -#ifdef AV_READ_TIME printf("benchmarking with native FFmpeg timers\n"); +checkasm_bench_start = checkasm_bench_stop = ff_read_time; return 0; +} #else +static int bench_init_ffmpeg(void) +{ fprintf(stderr, "checkasm: --bench is not supported on your system\n"); return -1; -#endif } #endif @@ -869,6 +890,8 @@ CheckasmPerf *checkasm_get_perf_context(void) CheckasmPerf *perf = _func_ver->perf; memset(perf, 0, sizeof(*perf)); perf->sysfd = state.sysfd; +perf->start = checkasm_bench_start; +perf->stop = checkasm_bench_start; return perf; } diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 8a62b98f3e..8f966f49af 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -26,15 +26,6 @@ #include #include "config.h" -#if CONFIG_LINUX_PERF -#include // read(3) -#include -#include -#include -#elif CONFIG_MACOS_KPERF -#include "libavutil/macos_kperf.h" -#endif - #include "libavutil/avstring.h" #include "libavutil/cpu.h" #include "libavutil/internal.h" @@ -236,41 +227,29 @@ typedef struct CheckasmPerf { int sysfd; uint64_t cycles; int iterations; +uint64_t (*start)(void); +uint64_t (*stop)(void); } CheckasmPerf; -#if CONFIG_LINUX_PERF -uint64_t checkasm_bench_linux_perf_start(void); -uint64_t checkasm_bench_linux_perf_stop(void); -#define checkasm_bench_start() checkasm_bench_linux_perf_start() -#define checkasm_bench_stop() checkasm_bench_linux_perf_stop() -#elif CONFIG_MACOS_KPERF -#define checkasm_bench_start() ff_kperf_cycles() -#define checkasm_bench_stop() ff_kperf_cycles() -#elif defined (AV_READ_TIME) -#define checkasm_bench_start() AV_READ_TIME() -#define checkasm_bench_stop() AV_READ_TIME() -#else -#define checkasm_bench_start() UINT64_C(0) -#define checkasm_bench_stop() UINT64_C(0) -#endif - /* Benchmark the function */ #define bench_new(...)\ do {\ if (checkasm_bench_func()) {\ struct CheckasmPerf *perf = checkasm_get_perf_context();\ av_unused const int sysfd = perf->sysfd;\ +uint64_t (*const start)(void) = perf->start;\ +uint64_t (*const stop)(void) = perf->stop;\ func_type *tfunc = func_new;\ uint64_t tsum = 0;\ int ti, tcount = 0;\ uint64_t t = 0; \ for (ti = 0; ti < BENCH_RUNS; ti++) {\ -t = checkasm_bench_start(); \ +t = start(); \ tfunc(__VA_ARGS__);\ tfunc(__VA_ARGS__);\ tfunc(__VA_ARGS__);\ tfunc(__VA_ARGS__);\ -t = checkasm_bench_stop() - t;\ +t = stop() - t;\ if (t*tcount <= tsum*4 &&
[FFmpeg-devel] [PATCH 2/7] checkasm: make perf macros functional
This converts the bench/perf start/stop macros into functional macros, and for that to work, take the Linux perf code out of line. --- tests/checkasm/checkasm.c | 24 tests/checkasm/checkasm.h | 36 +--- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 8702c9a30a..d8f571f301 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -513,11 +513,9 @@ static int measure_nop_time(void) int i, nop_sum = 0; av_unused const int sysfd = state.sysfd; -uint64_t t = 0; for (i = 0; i < 1; i++) { -PERF_START(t); -PERF_STOP(t); -nops[i] = t; +uint64_t t = checkasm_bench_start(); +nops[i] = checkasm_bench_stop() - t; } qsort(nops, 1, sizeof(uint16_t), cmp_nop); @@ -651,6 +649,24 @@ static void print_cpu_name(void) } #if CONFIG_LINUX_PERF +uint64_t checkasm_bench_linux_perf_start(void) +{ +int fd = state.sysfd; + +ioctl(fd, PERF_EVENT_IOC_RESET, 0); +ioctl(fd, PERF_EVENT_IOC_ENABLE, 0); +return 0; +} + +uint64_t checkasm_bench_linux_perf_stop(void) +{ +uint64_t t; +int fd = state.sysfd; + +ioctl(fd, PERF_EVENT_IOC_DISABLE, 0); +return (read(fd, , sizeof(t)) == sizeof (t)) ? t : 0; +} + static int bench_init_linux(void) { struct perf_event_attr attr = { diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 117d4dd35c..8a62b98f3e 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -238,25 +238,20 @@ typedef struct CheckasmPerf { int iterations; } CheckasmPerf; -#if defined(AV_READ_TIME) || CONFIG_LINUX_PERF || CONFIG_MACOS_KPERF - #if CONFIG_LINUX_PERF -#define PERF_START(t) do { \ -ioctl(sysfd, PERF_EVENT_IOC_RESET, 0); \ -ioctl(sysfd, PERF_EVENT_IOC_ENABLE, 0); \ -} while (0) -#define PERF_STOP(t) do { \ -int ret;\ -ioctl(sysfd, PERF_EVENT_IOC_DISABLE, 0);\ -ret = read(sysfd, , sizeof(t)); \ -(void)ret; \ -} while (0) +uint64_t checkasm_bench_linux_perf_start(void); +uint64_t checkasm_bench_linux_perf_stop(void); +#define checkasm_bench_start() checkasm_bench_linux_perf_start() +#define checkasm_bench_stop() checkasm_bench_linux_perf_stop() #elif CONFIG_MACOS_KPERF -#define PERF_START(t) t = ff_kperf_cycles() -#define PERF_STOP(t) t = ff_kperf_cycles() - t +#define checkasm_bench_start() ff_kperf_cycles() +#define checkasm_bench_stop() ff_kperf_cycles() +#elif defined (AV_READ_TIME) +#define checkasm_bench_start() AV_READ_TIME() +#define checkasm_bench_stop() AV_READ_TIME() #else -#define PERF_START(t) t = AV_READ_TIME() -#define PERF_STOP(t) t = AV_READ_TIME() - t +#define checkasm_bench_start() UINT64_C(0) +#define checkasm_bench_stop() UINT64_C(0) #endif /* Benchmark the function */ @@ -270,12 +265,12 @@ typedef struct CheckasmPerf { int ti, tcount = 0;\ uint64_t t = 0; \ for (ti = 0; ti < BENCH_RUNS; ti++) {\ -PERF_START(t);\ +t = checkasm_bench_start(); \ tfunc(__VA_ARGS__);\ tfunc(__VA_ARGS__);\ tfunc(__VA_ARGS__);\ tfunc(__VA_ARGS__);\ -PERF_STOP(t);\ +t = checkasm_bench_stop() - t;\ if (t*tcount <= tsum*4 && ti > 0) {\ tsum += t;\ tcount++;\ @@ -286,11 +281,6 @@ typedef struct CheckasmPerf { perf->iterations++;\ }\ } while (0) -#else -#define bench_new(...) while(0) -#define PERF_START(t) while(0) -#define PERF_STOP(t) while(0) -#endif #define DECL_CHECKASM_CHECK_FUNC(type) \ int checkasm_check_##type(const char *const file, const int line, \ -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/7] checkasm: improve Linux perf error message
Report the failing system call name, as is convention, rather than just a rather unhelpful "syscall". --- tests/checkasm/checkasm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 4311a8ffcb..8702c9a30a 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -666,7 +666,7 @@ static int bench_init_linux(void) state.sysfd = syscall(__NR_perf_event_open, , 0, -1, -1, 0); if (state.sysfd == -1) { -perror("syscall"); +perror("perf_event_open"); return -1; } return 0; -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCHv2 0/7] checkasm: RISC-V Linux perf enablement
Changes since v1: - Purge additional no longer used variable. - Deinitialise benchmarking through function pointer. - Cache function pointers outside bench loop. -- レミ・デニ-クールモン http://www.remlab.net/ ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [RFC] [PATCH] avcodec/codec_par: Keep format channel layout if specified
Hello, Tagging this as RFC in case there is disagreement on the correct/desired behavior. For context: I am working with spatial audio and noticed that FFmpeg does not honor the SA3D box metadata, which is used to signal ambisonic audio channel layouts. FFmpeg does parse the SA3D box and applies the specified channel layout properties to the codec parameters. However, they are later reset based on codec-level parameters in avcodec_parameters_from_context(), which is called from multiple locations between SA3D being parsed and the channel layout being resolved in FFprobe. The result is that only codecs which support ambisonic signaling (I don't know of any besides Opus) can be recognized as ambisonic, despite container-level metadata being present. Since a lot of ambisonic content is distributed in AAC or PCM/Wave format, I think that the SA3D metadata should take precedence over codec-level metadata in this case. Obviously this means ignoring the codec-level metadata which may not match. If there are reasons to prioritize the channel layout defined at the codec level at the expense of SA3D, please let me know the rationale. Also, I am aware that at least libswresample is also ignoring the container-level metadata, so other changes may be needed to propagate the SA3D properties when decoding/filtering ambisonic tracks, but this allows for detection as a first step. The implementation could be greatly simplified by not resetting the channel layout, but that would require removing av_channel_layout_uninit() from codec_parameters_reset() or adding an argument to skip it. I would favor the former, but this affects a few other functions in this file so let me know if you have a preference. I assume this would be a micro version bump (or minor?) but will add that once other details are sorted out. Thanks, Raphaël Zumer Signed-off-by: Raphaël Zumer --- libavcodec/codec_par.c | 32 +--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/libavcodec/codec_par.c b/libavcodec/codec_par.c index 775c187073..0cd707d431 100644 --- a/libavcodec/codec_par.c +++ b/libavcodec/codec_par.c @@ -100,10 +100,34 @@ int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src int avcodec_parameters_from_context(AVCodecParameters *par, const AVCodecContext *codec) { +int keep_ch_layout = par->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC; +AVChannelLayout ch_layout; int ret; +/* + * The stream codec parameters may have a channel layout set + * already that is not represented in the codec context. + * For example, spatial audio channel layouts in codecs with no + * signaling for them may be decoded from container-level metadata. + * + * Assume that if the channel order is specified, we should + * preserve the existing layout rather than let + * avcodec_parameters_from_context() override it. + */ +if (keep_ch_layout) { +ret = av_channel_layout_copy(_layout, >ch_layout); +if (ret < 0) +return ret; +} + codec_parameters_reset(par); +if (keep_ch_layout) { +ret = av_channel_layout_copy(>ch_layout, _layout); +if (ret < 0) +return ret; +} + par->codec_type = codec->codec_type; par->codec_id = codec->codec_id; par->codec_tag = codec->codec_tag; @@ -146,9 +170,11 @@ FF_DISABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS } else { #endif -ret = av_channel_layout_copy(>ch_layout, >ch_layout); -if (ret < 0) -return ret; +if (!keep_ch_layout) { +ret = av_channel_layout_copy(>ch_layout, >ch_layout); +if (ret < 0) +return ret; +} #if FF_API_OLD_CHANNEL_LAYOUT FF_DISABLE_DEPRECATION_WARNINGS } -- 2.41.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 44/47] fftools/opt_common: replace report_and_exit() with returning an error code
Remove report_and_exit(), as it has no more users. --- fftools/cmdutils.c | 6 -- fftools/cmdutils.h | 11 --- fftools/opt_common.c | 10 +++--- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index f37b7d44d6..bceb778ff0 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -90,12 +90,6 @@ void register_exit(void (*cb)(int ret)) program_exit = cb; } -void report_and_exit(int ret) -{ -av_log(NULL, AV_LOG_FATAL, "%s\n", av_err2str(ret)); -exit_program(AVUNERROR(ret)); -} - void exit_program(int ret) { if (program_exit) diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 97e49850c5..cc2180f768 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -54,17 +54,6 @@ extern int hide_banner; */ void register_exit(void (*cb)(int ret)); -/** - * Reports an error corresponding to the provided - * AVERROR code and calls exit_program() with the - * corresponding POSIX error code. - * @note ret must be an AVERROR-value of a POSIX error code - * (i.e. AVERROR(EFOO) and not AVERROR_FOO). - * library functions can return both, so call this only - * with AVERROR(EFOO) of your own. - */ -void report_and_exit(int ret) av_noreturn; - /** * Wraps exit with a program-specific cleanup routine. */ diff --git a/fftools/opt_common.c b/fftools/opt_common.c index 39258bb46c..913932c914 100644 --- a/fftools/opt_common.c +++ b/fftools/opt_common.c @@ -632,7 +632,7 @@ static int compare_codec_desc(const void *a, const void *b) strcmp((*da)->name, (*db)->name); } -static unsigned get_codecs_sorted(const AVCodecDescriptor ***rcodecs) +static int get_codecs_sorted(const AVCodecDescriptor ***rcodecs) { const AVCodecDescriptor *desc = NULL; const AVCodecDescriptor **codecs; @@ -641,7 +641,7 @@ static unsigned get_codecs_sorted(const AVCodecDescriptor ***rcodecs) while ((desc = avcodec_descriptor_next(desc))) nb_codecs++; if (!(codecs = av_calloc(nb_codecs, sizeof(*codecs -report_and_exit(AVERROR(ENOMEM)); +return AVERROR(ENOMEM); desc = NULL; while ((desc = avcodec_descriptor_next(desc))) codecs[i++] = desc; @@ -666,7 +666,11 @@ static char get_media_type_char(enum AVMediaType type) int show_codecs(void *optctx, const char *opt, const char *arg) { const AVCodecDescriptor **codecs; -unsigned i, nb_codecs = get_codecs_sorted(); +unsigned i; +int nb_codecs = get_codecs_sorted(); + +if (nb_codecs < 0) +return nb_codecs; printf("Codecs:\n" " D. = Decoding supported\n" -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 30/47] fftools/ffmpeg_opt: replace exit_program() with returning error codes
--- fftools/ffmpeg_opt.c | 49 ++-- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 5a5a26d0a5..293397a8b7 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -190,7 +190,7 @@ int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_id else if (!is_global && !av_strcasecmp(arg, "auto")) *vsync_var = VSYNC_AUTO; else if (!is_global) { av_log(NULL, AV_LOG_FATAL, "Invalid value %s specified for fps_mode of #%d:%d.\n", arg, file_idx, st_idx); -exit_program(1); +return AVERROR(EINVAL); } if (is_global && *vsync_var == VSYNC_AUTO) { @@ -250,12 +250,12 @@ static int apply_sync_offsets(void) if (self->input_sync_ref == -1 || self->input_sync_ref == i) continue; if (self->input_sync_ref >= nb_input_files || self->input_sync_ref < -1) { av_log(NULL, AV_LOG_FATAL, "-isync for input %d references non-existent input %d.\n", i, self->input_sync_ref); -exit_program(1); +return AVERROR(EINVAL); } if (copy_ts && !start_at_zero) { av_log(NULL, AV_LOG_FATAL, "Use of -isync requires that start_at_zero be set if copyts is set.\n"); -exit_program(1); +return AVERROR(EINVAL); } ref = input_files[self->input_sync_ref]; @@ -397,7 +397,7 @@ static int opt_map(void *optctx, const char *opt, const char *arg) m->linklabel = av_get_token(, "]"); if (!m->linklabel) { av_log(NULL, AV_LOG_ERROR, "Invalid output link label: %s.\n", map); -exit_program(1); +return AVERROR(EINVAL); } } else { if (allow_unused = strchr(map, '?')) @@ -405,7 +405,7 @@ static int opt_map(void *optctx, const char *opt, const char *arg) file_idx = strtol(map, , 0); if (file_idx >= nb_input_files || file_idx < 0) { av_log(NULL, AV_LOG_FATAL, "Invalid input file index: %d.\n", file_idx); -exit_program(1); +return AVERROR(EINVAL); } if (negative) /* disable some already defined maps */ @@ -443,11 +443,11 @@ static int opt_map(void *optctx, const char *opt, const char *arg) } else if (disabled) { av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches disabled streams.\n" "To ignore this, add a trailing '?' to the map.\n", arg); -exit_program(1); +return AVERROR(EINVAL); } else { av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches no streams.\n" "To ignore this, add a trailing '?' to the map.\n", arg); -exit_program(1); +return AVERROR(EINVAL); } } @@ -509,7 +509,7 @@ static int opt_map_channel(void *optctx, const char *opt, const char *arg) if (n != 3 && n != 5) { av_log(NULL, AV_LOG_FATAL, "Syntax error, mapchan usage: " "[file.stream.channel|-1][:syncfile:syncstream]\n"); -exit_program(1); +goto fail; } if (n != 5) // only file.stream.channel specified @@ -519,19 +519,19 @@ static int opt_map_channel(void *optctx, const char *opt, const char *arg) if (m->file_idx < 0 || m->file_idx >= nb_input_files) { av_log(NULL, AV_LOG_FATAL, "mapchan: invalid input file index: %d\n", m->file_idx); -exit_program(1); +goto fail; } if (m->stream_idx < 0 || m->stream_idx >= input_files[m->file_idx]->nb_streams) { av_log(NULL, AV_LOG_FATAL, "mapchan: invalid input file stream index #%d.%d\n", m->file_idx, m->stream_idx); -exit_program(1); +goto fail; } st = input_files[m->file_idx]->ctx->streams[m->stream_idx]; if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) { av_log(NULL, AV_LOG_FATAL, "mapchan: stream #%d.%d is not an audio stream.\n", m->file_idx, m->stream_idx); -exit_program(1); +goto fail; } /* allow trailing ? to map_channel */ if (allow_unused = strchr(mapchan, '?')) @@ -545,12 +545,15 @@ static int opt_map_channel(void *optctx, const char *opt, const char *arg) av_log(NULL, AV_LOG_FATAL, "mapchan: invalid audio channel #%d.%d.%d\n" "To ignore this, add a trailing '?' to the map_channel.\n", m->file_idx, m->stream_idx, m->channel_idx); -exit_program(1); +goto fail; } } av_free(mapchan); return 0; +fail: +av_free(mapchan); +return AVERROR(EINVAL); } #endif @@ -602,7 +605,7 @@ static int opt_init_hw_device(void *optctx, const char *opt, const char *arg) AV_HWDEVICE_TYPE_NONE) printf("%s\n",
[FFmpeg-devel] [PATCH 36/47] fftools/cmdutils: add error handling to filter_codec_opts()
--- fftools/cmdutils.c| 41 ++- fftools/cmdutils.h| 8 +--- fftools/ffmpeg_demux.c| 5 - fftools/ffmpeg_mux_init.c | 11 --- fftools/ffplay.c | 6 +- fftools/ffprobe.c | 8 ++-- 6 files changed, 56 insertions(+), 23 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 137e69f2c3..9d9d8d44a6 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -943,8 +943,9 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec) return ret; } -AVDictionary *filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_id, -AVFormatContext *s, AVStream *st, const AVCodec *codec) +int filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_id, + AVFormatContext *s, AVStream *st, const AVCodec *codec, + AVDictionary **dst) { AVDictionary*ret = NULL; const AVDictionaryEntry *t = NULL; @@ -977,12 +978,16 @@ AVDictionary *filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_i char *p = strchr(t->key, ':'); /* check stream specification in opt name */ -if (p) -switch (check_stream_specifier(s, st, p + 1)) { -case 1: *p = 0; break; -case 0: continue; -default: exit_program(1); -} +if (p) { +int err = check_stream_specifier(s, st, p + 1); +if (err < 0) { +av_dict_free(); +return err; +} else if (!err) +continue; + +*p = 0; +} if (av_opt_find(, t->key, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ) || !codec || @@ -998,14 +1003,16 @@ AVDictionary *filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_i if (p) *p = ':'; } -return ret; + +*dst = ret; +return 0; } int setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts, AVDictionary ***dst) { -int i; +int ret; AVDictionary **opts; *dst = NULL; @@ -1017,11 +1024,19 @@ int setup_find_stream_info_opts(AVFormatContext *s, if (!opts) return AVERROR(ENOMEM); -for (i = 0; i < s->nb_streams; i++) -opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codecpar->codec_id, -s, s->streams[i], NULL); +for (int i = 0; i < s->nb_streams; i++) { +ret = filter_codec_opts(codec_opts, s->streams[i]->codecpar->codec_id, +s, s->streams[i], NULL, [i]); +if (ret < 0) +goto fail; +} *dst = opts; return 0; +fail: +for (int i = 0; i < s->nb_streams; i++) +av_dict_free([i]); +av_freep(); +return ret; } int grow_array(void **array, int elem_size, int *size, int new_size) diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 7e7fb700b7..97e49850c5 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -333,10 +333,12 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec); * @param st A stream from s for which the options should be filtered. * @param codec The particular codec for which the options should be filtered. * If null, the default one is looked up according to the codec id. - * @return a pointer to the created dictionary + * @param dst a pointer to the created dictionary + * @return a non-negative number on success, a negative error code on failure */ -AVDictionary *filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_id, -AVFormatContext *s, AVStream *st, const AVCodec *codec); +int filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_id, + AVFormatContext *s, AVStream *st, const AVCodec *codec, + AVDictionary **dst); /** * Setup AVCodecContext options for avformat_find_stream_info(). diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index a41b59ceb8..d612c5f434 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -1176,7 +1176,10 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) if (ret < 0) return ret; -ist->decoder_opts = filter_codec_opts(o->g->codec_opts, ist->st->codecpar->codec_id, ic, st, ist->dec); +ret = filter_codec_opts(o->g->codec_opts, ist->st->codecpar->codec_id, +ic, st, ist->dec, >decoder_opts); +if (ret < 0) +return ret; ist->reinit_filters = -1; MATCH_PER_STREAM_OPT(reinit_filters, i, ist->reinit_filters, ic, st); diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 92d62c7b89..63d86209ff 100644 --- a/fftools/ffmpeg_mux_init.c +++
[FFmpeg-devel] [PATCH 31/47] fftools/opt_common: replace exit_program() with returning error codes
--- fftools/opt_common.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fftools/opt_common.c b/fftools/opt_common.c index f6fe9815e1..39258bb46c 100644 --- a/fftools/opt_common.c +++ b/fftools/opt_common.c @@ -1159,7 +1159,9 @@ int init_report(const char *env, FILE **file) report_file_level = strtol(val, , 10); if (*tail) { av_log(NULL, AV_LOG_FATAL, "Invalid report file level\n"); -exit_program(1); +av_free(key); +av_free(val); +return AVERROR(EINVAL); } envlevel = 1; } else { @@ -1219,7 +1221,7 @@ int opt_max_alloc(void *optctx, const char *opt, const char *arg) max = strtol(arg, , 10); if (*tail) { av_log(NULL, AV_LOG_FATAL, "Invalid max_alloc \"%s\".\n", arg); -exit_program(1); +return AVERROR(EINVAL); } av_max_alloc(max); return 0; @@ -1293,7 +1295,7 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg) "Possible levels are numbers or:\n", arg); for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) av_log(NULL, AV_LOG_FATAL, "\"%s\"\n", log_levels[i].name); -exit_program(1); +return AVERROR(EINVAL); } end: -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 40/47] fftools/ffmpeg: return an error from assert_avoptions() instead of aborting
Rename it to check_avoptions(). --- fftools/ffmpeg.c | 6 -- fftools/ffmpeg.h | 2 +- fftools/ffmpeg_dec.c | 5 - fftools/ffmpeg_demux.c | 5 - fftools/ffmpeg_enc.c | 5 - 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 50d6658472..ecb3f89f85 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -457,13 +457,15 @@ void remove_avoptions(AVDictionary **a, AVDictionary *b) } } -void assert_avoptions(AVDictionary *m) +int check_avoptions(AVDictionary *m) { const AVDictionaryEntry *t; if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) { av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key); -exit_program(1); +return AVERROR_OPTION_NOT_FOUND; } + +return 0; } void update_benchmark(const char *fmt, ...) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 60dff87436..73baad238c 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -705,7 +705,7 @@ void term_exit(void); void show_usage(void); void remove_avoptions(AVDictionary **a, AVDictionary *b); -void assert_avoptions(AVDictionary *m); +int check_avoptions(AVDictionary *m); int assert_file_overwrite(const char *filename); char *file_read(const char *filename); diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index 62c1baf287..8a3b52fd7e 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -1119,7 +1119,10 @@ int dec_open(InputStream *ist) av_err2str(ret)); return ret; } -assert_avoptions(ist->decoder_opts); + +ret = check_avoptions(ist->decoder_opts); +if (ret < 0) +return ret; ret = dec_thread_start(ist); if (ret < 0) { diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index d612c5f434..48edbd7f6b 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -1511,7 +1511,10 @@ int ifile_open(const OptionsContext *o, const char *filename) if (scan_all_pmts_set) av_dict_set(>g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE); remove_avoptions(>g->format_opts, o->g->codec_opts); -assert_avoptions(o->g->format_opts); + +ret = check_avoptions(o->g->format_opts); +if (ret < 0) +return ret; /* apply forced codec ids */ for (i = 0; i < ic->nb_streams; i++) { diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 01e1b0656c..dde239657f 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -411,7 +411,10 @@ int enc_open(OutputStream *ost, AVFrame *frame) ost->sq_idx_encode, ost->enc_ctx->frame_size); } -assert_avoptions(ost->encoder_opts); +ret = check_avoptions(ost->encoder_opts); +if (ret < 0) +return ret; + if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000 && ost->enc_ctx->codec_id != AV_CODEC_ID_CODEC2 /* don't complain about 700 bit/s modes */) av_log(ost, AV_LOG_WARNING, "The bitrate parameter is set too low." -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 35/47] fftools/cmdutils: constify the first parameter of filter_codec_opts()
--- fftools/cmdutils.c | 2 +- fftools/cmdutils.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 330b9c2aba..137e69f2c3 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -943,7 +943,7 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec) return ret; } -AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, +AVDictionary *filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, const AVCodec *codec) { AVDictionary*ret = NULL; diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 210d52e998..7e7fb700b7 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -335,7 +335,7 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec); * If null, the default one is looked up according to the codec id. * @return a pointer to the created dictionary */ -AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, +AVDictionary *filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, const AVCodec *codec); /** -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 45/47] fftools/ffprobe: inline opt_output_file() into its only caller
There is no reason to keep them separate. Also, replace exit_program() with returning an error code. --- fftools/ffprobe.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 6180a5c952..e234c92904 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -3795,22 +3795,18 @@ static int opt_input_file_i(void *optctx, const char *opt, const char *arg) return 0; } -static void opt_output_file(void *optctx, const char *arg) +static int opt_output_file_o(void *optctx, const char *opt, const char *arg) { if (output_filename) { av_log(NULL, AV_LOG_ERROR, "Argument '%s' provided as output filename, but '%s' was already specified.\n", arg, output_filename); -exit_program(1); +return AVERROR(EINVAL); } if (!strcmp(arg, "-")) arg = "fd:"; output_filename = arg; -} -static int opt_output_file_o(void *optctx, const char *opt, const char *arg) -{ -opt_output_file(optctx, arg); return 0; } -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 41/47] fftools/ffmpeg: return an error from MATCH_PER_STREAM_OPT() instead of aborting
--- fftools/ffmpeg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 73baad238c..5c93b3aa29 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -912,7 +912,7 @@ static inline int err_merge(int err0, int err1) so = >name[_i];\ _matches++;\ } else if (_ret < 0)\ -exit_program(1);\ +return _ret;\ }\ if (_matches > 1)\ WARN_MULTIPLE_OPT_USAGE(name, type, so, st);\ -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 38/47] fftools/ffmpeg: consolidate exiting from main() on error
--- fftools/ffmpeg.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index b4ea52ac1d..0c5e553c72 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1339,17 +1339,19 @@ int main(int argc, char **argv) /* parse options and open all input/output files */ ret = ffmpeg_parse_options(argc, argv); if (ret < 0) -exit_program(1); +goto finish; if (nb_output_files <= 0 && nb_input_files == 0) { show_usage(); av_log(NULL, AV_LOG_WARNING, "Use -h to get full help or, even better, run 'man %s'\n", program_name); -exit_program(1); +ret = 1; +goto finish; } if (nb_output_files <= 0) { av_log(NULL, AV_LOG_FATAL, "At least one output file must be specified\n"); -exit_program(1); +ret = 1; +goto finish; } current_time = ti = get_benchmark_time_stamps(); @@ -1368,6 +1370,7 @@ int main(int argc, char **argv) ret = received_nb_signals ? 255 : err_rate_exceeded ? 69 : ret; +finish: exit_program(ret); return ret; } -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 47/47] fftools/ffmpeg: stop calling exit_program()
Remove exit_program() and register_exit(), as they are no longer used. --- fftools/cmdutils.c | 15 --- fftools/cmdutils.h | 10 -- fftools/ffmpeg.c | 4 +--- 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index bceb778ff0..8a3b4bd285 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -83,21 +83,6 @@ void init_dynload(void) #endif } -static void (*program_exit)(int ret); - -void register_exit(void (*cb)(int ret)) -{ -program_exit = cb; -} - -void exit_program(int ret) -{ -if (program_exit) -program_exit(ret); - -exit(ret); -} - int parse_number(const char *context, const char *numstr, int type, double min, double max, double *dst) { diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index cc2180f768..4779b280fd 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -49,16 +49,6 @@ extern AVDictionary *swr_opts; extern AVDictionary *format_opts, *codec_opts; extern int hide_banner; -/** - * Register a program-specific cleanup routine. - */ -void register_exit(void (*cb)(int ret)); - -/** - * Wraps exit with a program-specific cleanup routine. - */ -void exit_program(int ret) av_noreturn; - /** * Initialize dynamic library loading */ diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index ecb3f89f85..6130fd06fc 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1324,8 +1324,6 @@ int main(int argc, char **argv) init_dynload(); -register_exit(ffmpeg_cleanup); - setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */ av_log_set_flags(AV_LOG_SKIP_REPEATED); @@ -1376,6 +1374,6 @@ finish: if (ret == AVERROR_EXIT) ret = 0; -exit_program(ret); +ffmpeg_cleanup(ret); return ret; } -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 46/47] fftools/ffprobe: stop calling exit_program()
Inline the relevant part of ffprobe_cleanup() into main() and drop the rest. --- fftools/ffprobe.c | 22 -- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index e234c92904..a39185f6fe 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -381,17 +381,6 @@ static void log_callback(void *ptr, int level, const char *fmt, va_list vl) #endif } -static void ffprobe_cleanup(int ret) -{ -int i; -for (i = 0; i < FF_ARRAY_ELEMS(sections); i++) -av_dict_free(&(sections[i].entries_to_show)); - -#if HAVE_THREADS -pthread_mutex_destroy(_mutex); -#endif -} - struct unit_value { union { double d; long long int i; } val; const char *unit; @@ -4113,7 +4102,6 @@ int main(int argc, char **argv) } #endif av_log_set_flags(AV_LOG_SKIP_REPEATED); -register_exit(ffprobe_cleanup); options = real_options; parse_loglevel(argc, argv, options); @@ -4124,8 +4112,10 @@ int main(int argc, char **argv) show_banner(argc, argv, options); ret = parse_options(NULL, argc, argv, options, opt_input_file); -if (ret < 0) -exit_program(ret == AVERROR_EXIT ? 0 : 1); +if (ret < 0) { +ret = AVERROR_EXIT ? 0 : ret; +goto end; +} if (do_show_log) av_log_set_callback(log_callback); @@ -4249,5 +4239,9 @@ end: avformat_network_deinit(); +#if HAVE_THREADS +pthread_mutex_destroy(_mutex); +#endif + return ret < 0; } -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 42/47] fftools/ffprobe: replace report_and_exit() with returning error codes
--- fftools/ffprobe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index c83d20995e..6180a5c952 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -3350,7 +3350,7 @@ static int open_input_file(InputFile *ifile, const char *filename, fmt_ctx = avformat_alloc_context(); if (!fmt_ctx) -report_and_exit(AVERROR(ENOMEM)); +return AVERROR(ENOMEM); if (!av_dict_get(format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) { av_dict_set(_opts, "scan_all_pmts", "1", AV_DICT_DONT_OVERWRITE); @@ -3377,7 +3377,7 @@ static int open_input_file(InputFile *ifile, const char *filename, err = setup_find_stream_info_opts(fmt_ctx, codec_opts, ); if (err < 0) -report_and_exit(err); +return err; err = avformat_find_stream_info(fmt_ctx, opts); -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 43/47] fftools/ffplay: replace report_and_exit() with returning an error code
--- fftools/ffplay.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index a491fdd9e3..5212ad053e 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -2784,8 +2784,12 @@ static int read_thread(void *arg) int orig_nb_streams = ic->nb_streams; err = setup_find_stream_info_opts(ic, codec_opts, ); -if (err < 0) -report_and_exit(err); +if (err < 0) { +av_log(NULL, AV_LOG_ERROR, + "Error setting up avformat_find_stream_info() options\n"); +ret = err; +goto fail; +} err = avformat_find_stream_info(ic, opts); -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 27/47] fftools/cmdutils: add error handling to grow_array()
--- fftools/cmdutils.c | 19 --- fftools/cmdutils.h | 14 +- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 6c627ee815..63b29c7a3a 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -262,6 +262,7 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt, void *dst = po->flags & (OPT_OFFSET | OPT_SPEC) ? (uint8_t *)optctx + po->u.off : po->u.dst_ptr; int *dstcount; +int ret; if (po->flags & OPT_SPEC) { SpecifierOpt **so = dst; @@ -269,7 +270,10 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt, char *str; dstcount = (int *)(so + 1); -*so = grow_array(*so, sizeof(**so), dstcount, *dstcount + 1); +ret = grow_array((void**)so, sizeof(**so), dstcount, *dstcount + 1); +if (ret < 0) +return ret; + str = av_strdup(p ? p + 1 : ""); if (!str) return AVERROR(ENOMEM); @@ -979,21 +983,22 @@ int setup_find_stream_info_opts(AVFormatContext *s, return 0; } -void *grow_array(void *array, int elem_size, int *size, int new_size) +int grow_array(void **array, int elem_size, int *size, int new_size) { if (new_size >= INT_MAX / elem_size) { av_log(NULL, AV_LOG_ERROR, "Array too big.\n"); -exit_program(1); +return AVERROR(ERANGE); } if (*size < new_size) { -uint8_t *tmp = av_realloc_array(array, new_size, elem_size); +uint8_t *tmp = av_realloc_array(*array, new_size, elem_size); if (!tmp) -report_and_exit(AVERROR(ENOMEM)); +return AVERROR(ENOMEM); memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size); *size = new_size; -return tmp; +*array = tmp; +return 0; } -return array; +return 0; } void *allocate_array_elem(void *ptr, size_t elem_size, int *nb_elems) diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 6b9d7f80ae..0dfe8b313c 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -416,15 +416,15 @@ FILE *get_preset_file(char *filename, size_t filename_size, /** * Realloc array to hold new_size elements of elem_size. - * Calls exit() on failure. * - * @param array array to reallocate + * @param array pointer to the array to reallocate, will be updated + * with a new pointer on success * @param elem_size size in bytes of each element * @param size new element count will be written here * @param new_size number of elements to place in reallocated array - * @return reallocated array + * @return a non-negative number on success, a negative error code on failure */ -void *grow_array(void *array, int elem_size, int *size, int new_size); +int grow_array(void **array, int elem_size, int *size, int new_size); /** * Atomically add a new element to an array of pointers, i.e. allocate @@ -440,7 +440,11 @@ void *grow_array(void *array, int elem_size, int *size, int new_size); void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems); #define GROW_ARRAY(array, nb_elems)\ -array = grow_array(array, sizeof(*array), _elems, nb_elems + 1) +do {\ +int _ret = grow_array((void**), sizeof(*array), _elems, nb_elems + 1); \ +if (_ret < 0) \ +report_and_exit(_ret); \ +} while (0) #define GET_PIX_FMT_NAME(pix_fmt)\ const char *name = av_get_pix_fmt_name(pix_fmt); -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 20/47] fftools/ffmpeg_filter: return error codes from fg_create() instead of aborting
--- fftools/ffmpeg.h| 2 +- fftools/ffmpeg_filter.c | 38 ++ fftools/ffmpeg_opt.c| 8 ++-- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 043eb5e6ec..ba73dcffdc 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -752,7 +752,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost); * @param graph_desc Graph description; an av_malloc()ed string, filtergraph * takes ownership of it. */ -FilterGraph *fg_create(char *graph_desc); +int fg_create(FilterGraph **pfg, char *graph_desc); void fg_free(FilterGraph **pfg); diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 2a3204121a..485154a448 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -538,16 +538,11 @@ static char *describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in) AVFilterContext *ctx = inout->filter_ctx; AVFilterPad *pads = in ? ctx->input_pads : ctx->output_pads; int nb_pads = in ? ctx->nb_inputs : ctx->nb_outputs; -char *res; if (nb_pads > 1) -res = av_strdup(ctx->filter->name); -else -res = av_asprintf("%s:%s", ctx->filter->name, - avfilter_pad_get_name(pads, inout->pad_idx)); -if (!res) -report_and_exit(AVERROR(ENOMEM)); -return res; +return av_strdup(ctx->filter->name); +return av_asprintf("%s:%s", ctx->filter->name, + avfilter_pad_get_name(pads, inout->pad_idx)); } static OutputFilter *ofilter_alloc(FilterGraph *fg) @@ -799,7 +794,7 @@ static const AVClass fg_class = { .category = AV_CLASS_CATEGORY_FILTER, }; -FilterGraph *fg_create(char *graph_desc) +int fg_create(FilterGraph **pfg, char *graph_desc) { FilterGraphPriv *fgp = allocate_array_elem(, sizeof(*fgp), _filtergraphs); FilterGraph *fg = >fg; @@ -808,6 +803,9 @@ FilterGraph *fg_create(char *graph_desc) AVFilterGraph *graph; int ret = 0; +if (pfg) +*pfg = fg; + fg->class = _class; fg->index = nb_filtergraphs - 1; fgp->graph_desc = graph_desc; @@ -817,13 +815,13 @@ FilterGraph *fg_create(char *graph_desc) fgp->frame = av_frame_alloc(); if (!fgp->frame) -report_and_exit(AVERROR(ENOMEM)); +return AVERROR(ENOMEM); /* this graph is only used for determining the kinds of inputs * and outputs we have, and is discarded on exit from this function */ graph = avfilter_graph_alloc(); if (!graph) -report_and_exit(AVERROR(ENOMEM)); +return AVERROR(ENOMEM);; graph->nb_threads = 1; ret = graph_parse(graph, fgp->graph_desc, , , NULL); @@ -840,6 +838,10 @@ FilterGraph *fg_create(char *graph_desc) ifp->type = avfilter_pad_get_type(cur->filter_ctx->input_pads, cur->pad_idx); ifilter->name = describe_filter_link(fg, cur, 1); +if (!ifilter->name) { +ret = AVERROR(ENOMEM); +goto fail; +} } for (AVFilterInOut *cur = outputs; cur; cur = cur->next) { @@ -851,6 +853,10 @@ FilterGraph *fg_create(char *graph_desc) ofilter->type = avfilter_pad_get_type(cur->filter_ctx->output_pads, cur->pad_idx); ofilter->name = describe_filter_link(fg, cur, 0); +if (!ofilter->name) { +ret = AVERROR(ENOMEM); +goto fail; +} } if (!fg->nb_outputs) { @@ -865,9 +871,9 @@ fail: avfilter_graph_free(); if (ret < 0) -report_and_exit(ret); +return ret; -return fg; +return 0; } int init_simple_filtergraph(InputStream *ist, OutputStream *ost, @@ -877,9 +883,9 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost, FilterGraphPriv *fgp; int ret; -fg = fg_create(graph_desc); -if (!fg) -report_and_exit(AVERROR(ENOMEM)); +ret = fg_create(, graph_desc); +if (ret < 0) +return ret; fgp = fgp_from_fg(fg); fgp->is_simple = 1; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 44bf263621..25a1083366 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1112,9 +1112,7 @@ static int opt_filter_complex(void *optctx, const char *opt, const char *arg) if (!graph_desc) return AVERROR(ENOMEM); -fg_create(graph_desc); - -return 0; +return fg_create(NULL, graph_desc); } static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg) @@ -1123,9 +1121,7 @@ static int opt_filter_complex_script(void *optctx, const char *opt, const char * if (!graph_desc) return AVERROR(EINVAL); -fg_create(graph_desc); - -return 0; +return fg_create(NULL, graph_desc); } void show_help_default(const char *opt, const char
[FFmpeg-devel] [PATCH 25/47] fftools/cmdutils: drop unused ALLOC_ARRAY_ELEM()
--- fftools/cmdutils.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index f54f3322ef..decd23040f 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -443,9 +443,6 @@ void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems); #define GROW_ARRAY(array, nb_elems)\ array = grow_array(array, sizeof(*array), _elems, nb_elems + 1) -#define ALLOC_ARRAY_ELEM(array, nb_elems)\ -allocate_array_elem(, sizeof(*array[0]), _elems) - #define GET_PIX_FMT_NAME(pix_fmt)\ const char *name = av_get_pix_fmt_name(pix_fmt); -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 39/47] fftools/cmdutils: return AVERROR_EXIT for OPT_EXIT options instead of aborting()
--- fftools/cmdutils.c | 2 +- fftools/ffmpeg.c | 3 +++ fftools/ffmpeg_opt.c | 2 +- fftools/ffplay.c | 2 +- fftools/ffprobe.c| 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 9d9d8d44a6..f37b7d44d6 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -320,7 +320,7 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt, } } if (po->flags & OPT_EXIT) -exit_program(0); +return AVERROR_EXIT; return 0; } diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0c5e553c72..50d6658472 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1371,6 +1371,9 @@ int main(int argc, char **argv) err_rate_exceeded ? 69 : ret; finish: +if (ret == AVERROR_EXIT) +ret = 0; + exit_program(ret); return ret; } diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 14b292f202..700db706a1 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1345,7 +1345,7 @@ int ffmpeg_parse_options(int argc, char **argv) fail: uninit_parse_context(); -if (ret < 0) { +if (ret < 0 && ret != AVERROR_EXIT) { av_log(NULL, AV_LOG_FATAL, "Error %s: %s\n", errmsg ? errmsg : "", av_err2str(ret)); } diff --git a/fftools/ffplay.c b/fftools/ffplay.c index df20c6a29d..a491fdd9e3 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -3657,7 +3657,7 @@ int main(int argc, char **argv) ret = parse_options(NULL, argc, argv, options, opt_input_file); if (ret < 0) -exit(1); +exit(ret == AVERROR_EXIT ? 0 : 1); if (!input_filename) { show_usage(); diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index da8fc89830..c83d20995e 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -4129,7 +4129,7 @@ int main(int argc, char **argv) show_banner(argc, argv, options); ret = parse_options(NULL, argc, argv, options, opt_input_file); if (ret < 0) -exit_program(1); +exit_program(ret == AVERROR_EXIT ? 0 : 1); if (do_show_log) av_log_set_callback(log_callback); -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 32/47] fftools: return errors from parse_number_or_die() instead of aborting
Rename the function to just parse_number(). --- fftools/cmdutils.c| 39 +-- fftools/cmdutils.h| 6 ++ fftools/ffmpeg_mux_init.c | 7 +-- fftools/ffmpeg_opt.c | 23 ++- fftools/ffplay.c | 25 + fftools/ffprobe.c | 10 -- 6 files changed, 83 insertions(+), 27 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index fb35245f0a..48a81ca201 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -104,8 +104,8 @@ void exit_program(int ret) exit(ret); } -double parse_number_or_die(const char *context, const char *numstr, int type, - double min, double max) +int parse_number(const char *context, const char *numstr, int type, + double min, double max, double *dst) { char *tail; const char *error; @@ -118,11 +118,13 @@ double parse_number_or_die(const char *context, const char *numstr, int type, error = "Expected int64 for %s but found %s\n"; else if (type == OPT_INT && (int)d != d) error = "Expected int for %s but found %s\n"; -else -return d; +else { +*dst = d; +return 0; +} + av_log(NULL, AV_LOG_FATAL, error, context, numstr, min, max); -exit_program(1); -return 0; +return AVERROR(EINVAL); } int64_t parse_time_or_die(const char *context, const char *timestr, @@ -262,6 +264,7 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt, void *dst = po->flags & (OPT_OFFSET | OPT_SPEC) ? (uint8_t *)optctx + po->u.off : po->u.dst_ptr; int *dstcount; +double num; int ret; if (po->flags & OPT_SPEC) { @@ -289,15 +292,31 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt, return AVERROR(ENOMEM); *(char **)dst = str; } else if (po->flags & OPT_BOOL || po->flags & OPT_INT) { -*(int *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX); +ret = parse_number(opt, arg, OPT_INT64, INT_MIN, INT_MAX, ); +if (ret < 0) +return ret; + +*(int *)dst = num; } else if (po->flags & OPT_INT64) { -*(int64_t *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX); +ret = parse_number(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX, ); +if (ret < 0) +return ret; + +*(int64_t *)dst = num; } else if (po->flags & OPT_TIME) { *(int64_t *)dst = parse_time_or_die(opt, arg, 1); } else if (po->flags & OPT_FLOAT) { -*(float *)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY); +ret = parse_number(opt, arg, OPT_FLOAT, -INFINITY, INFINITY, ); +if (ret < 0) +return ret; + +*(float *)dst = num; } else if (po->flags & OPT_DOUBLE) { -*(double *)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY); +ret = parse_number(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY, ); +if (ret < 0) +return ret; + +*(double *)dst = num; } 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 69c2123804..68de0bcb7f 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -100,8 +100,6 @@ int opt_timelimit(void *optctx, const char *opt, const char *arg); /** * Parse a string and return its corresponding value as a double. - * Exit from the application if the string cannot be correctly - * parsed or the corresponding value is invalid. * * @param context the context of the value to be set (e.g. the * corresponding command line option name) @@ -111,8 +109,8 @@ int opt_timelimit(void *optctx, const char *opt, const char *arg); * @param min the minimum valid accepted value * @param max the maximum valid accepted value */ -double parse_number_or_die(const char *context, const char *numstr, int type, - double min, double max); +int parse_number(const char *context, const char *numstr, int type, + double min, double max, double *dst); /** * Parse a string specifying a time and return its corresponding diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index aebec0c573..02d71588ad 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -795,8 +795,11 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, ost->vsync_method = video_sync_method; MATCH_PER_STREAM_OPT(fps_mode, str, fps_mode, oc, st); -if (fps_mode) -parse_and_set_vsync(fps_mode, >vsync_method, ost->file_index, ost->index, 0); +if (fps_mode) { +ret = parse_and_set_vsync(fps_mode, >vsync_method, ost->file_index, ost->index, 0); +if (ret < 0) +
[FFmpeg-devel] [PATCH 23/47] fftools/cmdutils: return error codes from setup_find_stream_info_opts() instead of aborting
--- fftools/cmdutils.c | 30 +- fftools/cmdutils.h | 8 +++- fftools/ffmpeg_demux.c | 6 +- fftools/ffplay.c | 6 +- fftools/ffprobe.c | 6 +- 5 files changed, 39 insertions(+), 17 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 9ec00add30..e2fa08c116 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -645,8 +645,8 @@ static void add_opt(OptionParseContext *octx, const OptionDef *opt, g->opts[g->nb_opts - 1].val = val; } -static void init_parse_context(OptionParseContext *octx, - const OptionGroupDef *groups, int nb_groups) +static int init_parse_context(OptionParseContext *octx, + const OptionGroupDef *groups, int nb_groups) { static const OptionGroupDef global_group = { "global" }; int i; @@ -656,13 +656,15 @@ static void init_parse_context(OptionParseContext *octx, octx->nb_groups = nb_groups; octx->groups= av_calloc(octx->nb_groups, sizeof(*octx->groups)); if (!octx->groups) -report_and_exit(AVERROR(ENOMEM)); +return AVERROR(ENOMEM); for (i = 0; i < octx->nb_groups; i++) octx->groups[i].group_def = [i]; octx->global_opts.group_def = _group; octx->global_opts.arg = ""; + +return 0; } void uninit_parse_context(OptionParseContext *octx) @@ -694,13 +696,17 @@ int split_commandline(OptionParseContext *octx, int argc, char *argv[], const OptionDef *options, const OptionGroupDef *groups, int nb_groups) { +int ret; int optindex = 1; int dashdash = -2; /* perform system-dependent conversions for arguments list */ prepare_app_arguments(, ); -init_parse_context(octx, groups, nb_groups); +ret = init_parse_context(octx, groups, nb_groups); +if (ret < 0) +return ret; + av_log(NULL, AV_LOG_DEBUG, "Splitting the commandline.\n"); while (optindex < argc) { @@ -950,21 +956,27 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, return ret; } -AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, - AVDictionary *codec_opts) +int setup_find_stream_info_opts(AVFormatContext *s, +AVDictionary *codec_opts, +AVDictionary ***dst) { int i; AVDictionary **opts; +*dst = NULL; + if (!s->nb_streams) -return NULL; +return 0; + opts = av_calloc(s->nb_streams, sizeof(*opts)); if (!opts) -report_and_exit(AVERROR(ENOMEM)); +return AVERROR(ENOMEM); + for (i = 0; i < s->nb_streams; i++) opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codecpar->codec_id, s, s->streams[i], NULL); -return opts; +*dst = opts; +return 0; } void *grow_array(void *array, int elem_size, int *size, int new_size) diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 0115940225..f54f3322ef 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -364,12 +364,10 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, * contained in s. * Each dictionary will contain the options from codec_opts which can * be applied to the corresponding stream codec context. - * - * @return pointer to the created array of dictionaries. - * Calls exit() on failure. */ -AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, - AVDictionary *codec_opts); +int setup_find_stream_info_opts(AVFormatContext *s, +AVDictionary *codec_opts, +AVDictionary ***dst); /** * Print an error message to stderr, indicating filename and a human diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 9e7f13a2b4..a43c39b843 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -1482,9 +1482,13 @@ int ifile_open(const OptionsContext *o, const char *filename) choose_decoder(o, ic, ic->streams[i], HWACCEL_NONE, AV_HWDEVICE_TYPE_NONE); if (o->find_stream_info) { -AVDictionary **opts = setup_find_stream_info_opts(ic, o->g->codec_opts); +AVDictionary **opts; int orig_nb_streams = ic->nb_streams; +ret = setup_find_stream_info_opts(ic, o->g->codec_opts, ); +if (ret < 0) +return ret; + /* If not enough info to get the stream parameters, we decode the first frames to get it. (used in mpeg case for example) */ ret = avformat_find_stream_info(ic, opts); diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 51cde0d208..99700dc6f2 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -2773,9 +2773,13 @@ static int read_thread(void *arg) av_format_inject_global_side_data(ic); if
[FFmpeg-devel] [PATCH 28/47] fftools/cmdutils: add error handling to GROW_ARRAY()
--- fftools/cmdutils.c| 44 ++- fftools/cmdutils.h| 6 +- fftools/ffmpeg_demux.c| 10 +++-- fftools/ffmpeg_mux_init.c | 15 ++--- fftools/ffmpeg_opt.c | 24 - fftools/ffplay.c | 5 - 6 files changed, 78 insertions(+), 26 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 63b29c7a3a..fb35245f0a 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -609,13 +609,17 @@ static int match_group_separator(const OptionGroupDef *groups, int nb_groups, * @param group_idx which group definition should this group belong to * @param arg argument of the group delimiting option */ -static void finish_group(OptionParseContext *octx, int group_idx, - const char *arg) +static int finish_group(OptionParseContext *octx, int group_idx, +const char *arg) { OptionGroupList *l = >groups[group_idx]; OptionGroup *g; +int ret; + +ret = GROW_ARRAY(l->groups, l->nb_groups); +if (ret < 0) +return ret; -GROW_ARRAY(l->groups, l->nb_groups); g = >groups[l->nb_groups - 1]; *g = octx->cur_group; @@ -632,21 +636,29 @@ static void finish_group(OptionParseContext *octx, int group_idx, swr_opts= NULL; memset(>cur_group, 0, sizeof(octx->cur_group)); + +return ret; } /* * Add an option instance to currently parsed group. */ -static void add_opt(OptionParseContext *octx, const OptionDef *opt, -const char *key, const char *val) +static int add_opt(OptionParseContext *octx, const OptionDef *opt, + const char *key, const char *val) { int global = !(opt->flags & (OPT_PERFILE | OPT_SPEC | OPT_OFFSET)); OptionGroup *g = global ? >global_opts : >cur_group; +int ret; + +ret = GROW_ARRAY(g->opts, g->nb_opts); +if (ret < 0) +return ret; -GROW_ARRAY(g->opts, g->nb_opts); g->opts[g->nb_opts - 1].opt = opt; g->opts[g->nb_opts - 1].key = key; g->opts[g->nb_opts - 1].val = val; + +return 0; } static int init_parse_context(OptionParseContext *octx, @@ -726,7 +738,10 @@ int split_commandline(OptionParseContext *octx, int argc, char *argv[], } /* unnamed group separators, e.g. output filename */ if (opt[0] != '-' || !opt[1] || dashdash+1 == optindex) { -finish_group(octx, 0, opt); +ret = finish_group(octx, 0, opt); +if (ret < 0) +return ret; + av_log(NULL, AV_LOG_DEBUG, " matched as %s.\n", groups[0].name); continue; } @@ -744,7 +759,10 @@ do { \ /* named group separators, e.g. -i */ if ((ret = match_group_separator(groups, nb_groups, opt)) >= 0) { GET_ARG(arg); -finish_group(octx, ret, arg); +ret = finish_group(octx, ret, arg); +if (ret < 0) +return ret; + av_log(NULL, AV_LOG_DEBUG, " matched as %s with argument '%s'.\n", groups[ret].name, arg); continue; @@ -762,7 +780,10 @@ do { \ arg = "1"; } -add_opt(octx, po, opt, arg); +ret = add_opt(octx, po, opt, arg); +if (ret < 0) +return ret; + av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with " "argument '%s'.\n", po->name, po->help, arg); continue; @@ -787,7 +808,10 @@ do { \ if (opt[0] == 'n' && opt[1] == 'o' && (po = find_option(options, opt + 2)) && po->name && po->flags & OPT_BOOL) { -add_opt(octx, po, opt, "0"); +ret = add_opt(octx, po, opt, "0"); +if (ret < 0) +return ret; + av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with " "argument 0.\n", po->name, po->help); continue; diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 0dfe8b313c..69c2123804 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -440,11 +440,7 @@ int grow_array(void **array, int elem_size, int *size, int new_size); void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems); #define GROW_ARRAY(array, nb_elems)\ -do {\ -int _ret = grow_array((void**), sizeof(*array), _elems, nb_elems + 1); \ -if (_ret < 0) \ -report_and_exit(_ret); \ -} while (0) +grow_array((void**), sizeof(*array), _elems, nb_elems +
[FFmpeg-devel] [PATCH 34/47] fftools: handle errors in parse_options()
--- fftools/cmdutils.c | 15 ++- fftools/cmdutils.h | 4 ++-- fftools/ffplay.c | 12 fftools/ffprobe.c | 10 +++--- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index b401b8fb89..330b9c2aba 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -364,8 +364,8 @@ int parse_option(void *optctx, const char *opt, const char *arg, return !!(po->flags & HAS_ARG); } -void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, - void (*parse_arg_function)(void *, const char*)) +int parse_options(void *optctx, int argc, char **argv, const OptionDef *options, + int (*parse_arg_function)(void *, const char*)) { const char *opt; int optindex, handleoptions = 1, ret; @@ -386,13 +386,18 @@ void parse_options(void *optctx, int argc, char **argv, const OptionDef *options opt++; if ((ret = parse_option(optctx, opt, argv[optindex], options)) < 0) -exit_program(1); +return ret; optindex += ret; } else { -if (parse_arg_function) -parse_arg_function(optctx, opt); +if (parse_arg_function) { +ret = parse_arg_function(optctx, opt); +if (ret < 0) +return ret; +} } } + +return 0; } int parse_optgroup(void *optctx, OptionGroup *g) diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index dc041d9fa2..210d52e998 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -194,8 +194,8 @@ void show_help_default(const char *opt, const char *arg); * argument without a leading option name flag. NULL if such arguments do * not have to be processed. */ -void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, - void (* parse_arg_function)(void *optctx, const char*)); +int parse_options(void *optctx, int argc, char **argv, const OptionDef *options, + int (* parse_arg_function)(void *optctx, const char*)); /** * Parse one given option. diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 89cea4d876..4e26b3309d 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -3501,17 +3501,19 @@ static int opt_show_mode(void *optctx, const char *opt, const char *arg) return 0; } -static void opt_input_file(void *optctx, const char *filename) +static int opt_input_file(void *optctx, const char *filename) { if (input_filename) { av_log(NULL, AV_LOG_FATAL, "Argument '%s' provided as input filename, but '%s' was already specified.\n", filename, input_filename); -exit(1); +return AVERROR(EINVAL); } if (!strcmp(filename, "-")) filename = "fd:"; input_filename = filename; + +return 0; } static int opt_codec(void *optctx, const char *opt, const char *arg) @@ -3630,7 +3632,7 @@ void show_help_default(const char *opt, const char *arg) /* Called from the main */ int main(int argc, char **argv) { -int flags; +int flags, ret; VideoState *is; init_dynload(); @@ -3649,7 +3651,9 @@ int main(int argc, char **argv) show_banner(argc, argv, options); -parse_options(NULL, argc, argv, options, opt_input_file); +ret = parse_options(NULL, argc, argv, options, opt_input_file); +if (ret < 0) +exit(1); if (!input_filename) { show_usage(); diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index e6fd33492d..ba55437760 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -3770,17 +3770,19 @@ static int opt_show_entries(void *optctx, const char *opt, const char *arg) return ret; } -static void opt_input_file(void *optctx, const char *arg) +static int opt_input_file(void *optctx, const char *arg) { if (input_filename) { av_log(NULL, AV_LOG_ERROR, "Argument '%s' provided as input filename, but '%s' was already specified.\n", arg, input_filename); -exit_program(1); +return AVERROR(EINVAL); } if (!strcmp(arg, "-")) arg = "fd:"; input_filename = arg; + +return 0; } static int opt_input_file_i(void *optctx, const char *opt, const char *arg) @@ -4121,7 +4123,9 @@ int main(int argc, char **argv) #endif show_banner(argc, argv, options); -parse_options(NULL, argc, argv, options, opt_input_file); +ret = parse_options(NULL, argc, argv, options, opt_input_file); +if (ret < 0) +exit_program(1); if (do_show_log) av_log_set_callback(log_callback); -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 21/47] fftools/ffmpeg_filter: return error codes from set_channel_layout() instead of aborting
--- fftools/ffmpeg_filter.c | 18 +++--- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 485154a448..470d7b1f02 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -583,7 +583,7 @@ static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist) return 0; } -static void set_channel_layout(OutputFilterPriv *f, OutputStream *ost) +static int set_channel_layout(OutputFilterPriv *f, OutputStream *ost) { const AVCodec *c = ost->enc_ctx->codec; int i, err; @@ -592,8 +592,8 @@ static void set_channel_layout(OutputFilterPriv *f, OutputStream *ost) /* Pass the layout through for all orders but UNSPEC */ err = av_channel_layout_copy(>ch_layout, >enc_ctx->ch_layout); if (err < 0) -report_and_exit(AVERROR(ENOMEM)); -return; +return err; +return 0; } /* Requested layout is of order UNSPEC */ @@ -601,7 +601,7 @@ static void set_channel_layout(OutputFilterPriv *f, OutputStream *ost) /* Use the default native layout for the requested amount of channels when the encoder doesn't have a list of supported layouts */ av_channel_layout_default(>ch_layout, ost->enc_ctx->ch_layout.nb_channels); -return; +return 0; } /* Encoder has a list of supported layouts. Pick the first layout in it with the same amount of channels as the requested layout */ @@ -613,12 +613,14 @@ static void set_channel_layout(OutputFilterPriv *f, OutputStream *ost) /* Use it if one is found */ err = av_channel_layout_copy(>ch_layout, >ch_layouts[i]); if (err < 0) -report_and_exit(AVERROR(ENOMEM)); -return; +return err; +return 0; } /* If no layout for the amount of channels requested was found, use the default native layout for it. */ av_channel_layout_default(>ch_layout, ost->enc_ctx->ch_layout.nb_channels); + +return 0; } int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost) @@ -682,7 +684,9 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost) ofp->sample_rates = c->supported_samplerates; } if (ost->enc_ctx->ch_layout.nb_channels) { -set_channel_layout(ofp, ost); +int ret = set_channel_layout(ofp, ost); +if (ret < 0) +return ret; } else if (c->ch_layouts) { ofp->ch_layouts = c->ch_layouts; } -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 33/47] fftools: remove parse_time_or_die()
Replace it with calling av_parse_time() directly, which provides graceful error handling and more accurate error messages. --- fftools/cmdutils.c| 19 ++- fftools/cmdutils.h| 17 - fftools/ffmpeg_mux_init.c | 30 -- fftools/ffmpeg_opt.c | 17 ++--- fftools/ffplay.c | 16 ++-- 5 files changed, 46 insertions(+), 53 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 48a81ca201..b401b8fb89 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -127,18 +127,6 @@ int parse_number(const char *context, const char *numstr, int type, return AVERROR(EINVAL); } -int64_t parse_time_or_die(const char *context, const char *timestr, - int is_duration) -{ -int64_t us; -if (av_parse_time(, timestr, is_duration) < 0) { -av_log(NULL, AV_LOG_FATAL, "Invalid %s specification for %s: %s\n", - is_duration ? "duration" : "date", context, timestr); -exit_program(1); -} -return us; -} - void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags, int alt_flags) { @@ -304,7 +292,12 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt, *(int64_t *)dst = num; } else if (po->flags & OPT_TIME) { -*(int64_t *)dst = parse_time_or_die(opt, arg, 1); +ret = av_parse_time(dst, arg, 1); +if (ret < 0) { +av_log(NULL, AV_LOG_ERROR, "Invalid duration for option %s: %s\n", + opt, arg); +return ret; +} } else if (po->flags & OPT_FLOAT) { ret = parse_number(opt, arg, OPT_FLOAT, -INFINITY, INFINITY, ); if (ret < 0) diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 68de0bcb7f..dc041d9fa2 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -112,23 +112,6 @@ int opt_timelimit(void *optctx, const char *opt, const char *arg); int parse_number(const char *context, const char *numstr, int type, double min, double max, double *dst); -/** - * Parse a string specifying a time and return its corresponding - * value as a number of microseconds. Exit from the application if - * the string cannot be correctly parsed. - * - * @param context the context of the value to be set (e.g. the - * corresponding command line option name) - * @param timestr the string to be parsed - * @param is_duration a flag which tells how to interpret timestr, if - * not zero timestr is interpreted as a duration, otherwise as a - * date - * - * @see av_parse_time() - */ -int64_t parse_time_or_die(const char *context, const char *timestr, - int is_duration); - typedef struct SpecifierOpt { char *specifier;/**< stream/chapter/program/... specifier */ union { diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 02d71588ad..92d62c7b89 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -2410,11 +2410,11 @@ static int compare_int64(const void *a, const void *b) return FFDIFFSIGN(*(const int64_t *)a, *(const int64_t *)b); } -static int parse_forced_key_frames(KeyframeForceCtx *kf, const Muxer *mux, - const char *spec) +static int parse_forced_key_frames(void *log, KeyframeForceCtx *kf, + const Muxer *mux, const char *spec) { const char *p; -int n = 1, i, size, index = 0; +int n = 1, i, ret, size, index = 0; int64_t t, *pts; for (p = spec; *p; p++) @@ -2441,7 +2441,16 @@ static int parse_forced_key_frames(KeyframeForceCtx *kf, const Muxer *mux, !(pts = av_realloc_f(pts, size += nb_ch - 1, sizeof(*pts return AVERROR(ENOMEM); -t = p[8] ? parse_time_or_die("force_key_frames", p + 8, 1) : 0; + +if (p[8]) { +ret = av_parse_time(, p + 8, 1); +if (ret < 0) { +av_log(log, AV_LOG_ERROR, + "Invalid chapter time offset: %s\n", p + 8); +goto fail; +} +} else +t = 0; for (j = 0; j < nb_ch; j++) { const AVChapter *c = ch[j]; @@ -2452,7 +2461,13 @@ static int parse_forced_key_frames(KeyframeForceCtx *kf, const Muxer *mux, } else { av_assert1(index < size); -pts[index++] = parse_time_or_die("force_key_frames", p, 1); +ret = av_parse_time(, p, 1); +if (ret < 0) { +av_log(log, AV_LOG_ERROR, "Invalid keyframe time: %s\n", p); +goto fail; +} + +pts[index++] = t; } p = next; @@ -2464,6 +2479,9 @@ static int parse_forced_key_frames(KeyframeForceCtx *kf, const Muxer
[FFmpeg-devel] [PATCH 09/47] fftools/ffmpeg_enc: return errors from enc_open() instead of aborting
--- fftools/ffmpeg_enc.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 6130e3e221..f84641b1c4 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -165,19 +165,19 @@ static int hw_device_setup_for_encode(OutputStream *ost, AVBufferRef *frames_ref return 0; } -static void set_encoder_id(OutputFile *of, OutputStream *ost) +static int set_encoder_id(OutputFile *of, OutputStream *ost) { const char *cname = ost->enc_ctx->codec->name; uint8_t *encoder_string; int encoder_string_len; if (av_dict_get(ost->st->metadata, "encoder", NULL, 0)) -return; +return 0; encoder_string_len = sizeof(LIBAVCODEC_IDENT) + strlen(cname) + 2; encoder_string = av_mallocz(encoder_string_len); if (!encoder_string) -report_and_exit(AVERROR(ENOMEM)); +return AVERROR(ENOMEM); if (!of->bitexact && !ost->bitexact) av_strlcpy(encoder_string, LIBAVCODEC_IDENT " ", encoder_string_len); @@ -186,6 +186,8 @@ static void set_encoder_id(OutputFile *of, OutputStream *ost) av_strlcat(encoder_string, cname, encoder_string_len); av_dict_set(>st->metadata, "encoder", encoder_string, AV_DICT_DONT_STRDUP_VAL | AV_DICT_DONT_OVERWRITE); + +return 0; } int enc_open(OutputStream *ost, AVFrame *frame) @@ -211,7 +213,9 @@ int enc_open(OutputStream *ost, AVFrame *frame) return AVERROR(ENOMEM); } -set_encoder_id(output_files[ost->file_index], ost); +ret = set_encoder_id(output_files[ost->file_index], ost); +if (ret < 0) +return ret; if (ist) { dec_ctx = ist->dec_ctx; @@ -417,7 +421,7 @@ int enc_open(OutputStream *ost, AVFrame *frame) if (ret < 0) { av_log(ost, AV_LOG_FATAL, "Error initializing the output stream codec context.\n"); -exit_program(1); +return ret; } if (ost->enc_ctx->nb_coded_side_data) { -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 13/47] fftools/ffmpeg_mux: return errors from of_output_packet() instead of aborting
--- fftools/ffmpeg.c | 4 +++- fftools/ffmpeg.h | 2 +- fftools/ffmpeg_enc.c | 12 fftools/ffmpeg_mux.c | 20 +--- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 926fdea23a..ddb011741a 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1120,7 +1120,9 @@ static int process_input(int file_index) OutputStream *ost = ist->outputs[oidx]; OutputFile*of = output_files[ost->file_index]; close_output_stream(ost); -of_output_packet(of, ost, NULL); +ret = of_output_packet(of, ost, NULL); +if (ret < 0) +return ret; } } diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 7329df6607..62b56a8cd8 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -831,7 +831,7 @@ void of_close(OutputFile **pof); void of_enc_stats_close(void); -void of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt); +int of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt); /** * @param dts predicted packet dts in AV_TIME_BASE_Q diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 9ca3940b93..01e1b0656c 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -563,7 +563,9 @@ int enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub) } pkt->dts = pkt->pts; -of_output_packet(of, ost, pkt); +ret = of_output_packet(of, ost, pkt); +if (ret < 0) +return ret; } return 0; @@ -756,8 +758,8 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) av_assert0(frame); // should never happen during flushing return 0; } else if (ret == AVERROR_EOF) { -of_output_packet(of, ost, NULL); -return ret; +ret = of_output_packet(of, ost, NULL); +return ret < 0 ? ret : AVERROR_EOF; } else if (ret < 0) { av_log(ost, AV_LOG_ERROR, "%s encoding failed\n", type_desc); return ret; @@ -794,7 +796,9 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) e->packets_encoded++; -of_output_packet(of, ost, pkt); +ret = of_output_packet(of, ost, pkt); +if (ret < 0) +return ret; } av_assert0(0); diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index a6cc824496..24cdf00469 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -330,7 +330,7 @@ static int submit_packet(Muxer *mux, AVPacket *pkt, OutputStream *ost) return 0; } -void of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) +int of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) { Muxer *mux = mux_from_of(of); MuxStream *ms = ms_from_ost(ost); @@ -359,7 +359,7 @@ void of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) while (!bsf_eof) { ret = av_bsf_receive_packet(ms->bsf_ctx, ms->bsf_pkt); if (ret == AVERROR(EAGAIN)) -return; +return 0; else if (ret == AVERROR_EOF) bsf_eof = 1; else if (ret < 0) { @@ -377,16 +377,14 @@ void of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt) goto mux_fail; } -return; +return 0; mux_fail: err_msg = "submitting a packet to the muxer"; fail: av_log(ost, AV_LOG_ERROR, "Error %s\n", err_msg); -if (exit_on_error) -exit_program(1); - +return exit_on_error ? ret : 0; } int of_streamcopy(OutputStream *ost, const AVPacket *pkt, int64_t dts) @@ -405,10 +403,8 @@ int of_streamcopy(OutputStream *ost, const AVPacket *pkt, int64_t dts) pkt = NULL; // EOF: flush output bitstream filters. -if (!pkt) { -of_output_packet(of, ost, NULL); -return 0; -} +if (!pkt) +return of_output_packet(of, ost, NULL); if (!ms->streamcopy_started && !(pkt->flags & AV_PKT_FLAG_KEY) && !ms->copy_initial_nonkeyframes) @@ -461,7 +457,9 @@ int of_streamcopy(OutputStream *ost, const AVPacket *pkt, int64_t dts) } } -of_output_packet(of, ost, opkt); +ret = of_output_packet(of, ost, opkt); +if (ret < 0) +return ret; ms->streamcopy_started = 1; -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 37/47] fftools/ffmpeg_opt: consolidate printing errors in ffmpeg_parse_options()
--- fftools/ffmpeg_opt.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 44a6b49ed7..14b292f202 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1289,6 +1289,7 @@ static int open_files(OptionGroupList *l, const char *inout, int ffmpeg_parse_options(int argc, char **argv) { OptionParseContext octx; +const char *errmsg = NULL; int ret; memset(, 0, sizeof(octx)); @@ -1297,14 +1298,14 @@ int ffmpeg_parse_options(int argc, char **argv) ret = split_commandline(, argc, argv, options, groups, FF_ARRAY_ELEMS(groups)); if (ret < 0) { -av_log(NULL, AV_LOG_FATAL, "Error splitting the argument list: "); +errmsg = "splitting the argument list"; goto fail; } /* apply global options */ ret = parse_optgroup(NULL, _opts); if (ret < 0) { -av_log(NULL, AV_LOG_FATAL, "Error parsing global options: "); +errmsg = "parsing global options"; goto fail; } @@ -1314,21 +1315,21 @@ int ffmpeg_parse_options(int argc, char **argv) /* open input files */ ret = open_files([GROUP_INFILE], "input", ifile_open); if (ret < 0) { -av_log(NULL, AV_LOG_FATAL, "Error opening input files: "); +errmsg = "opening input files"; goto fail; } /* create the complex filtergraphs */ ret = init_complex_filters(); if (ret < 0) { -av_log(NULL, AV_LOG_FATAL, "Error initializing complex filters.\n"); +errmsg = "initializing complex filters"; goto fail; } /* open output files */ ret = open_files([GROUP_OUTFILE], "output", of_open); if (ret < 0) { -av_log(NULL, AV_LOG_FATAL, "Error opening output files: "); +errmsg = "opening output files"; goto fail; } @@ -1345,7 +1346,8 @@ int ffmpeg_parse_options(int argc, char **argv) fail: uninit_parse_context(); if (ret < 0) { -av_log(NULL, AV_LOG_FATAL, "%s\n", av_err2str(ret)); +av_log(NULL, AV_LOG_FATAL, "Error %s: %s\n", + errmsg ? errmsg : "", av_err2str(ret)); } return ret; } -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 15/47] fftools/ffmpeg_dec: drop redundant handling of AVERROR_EXPERIMENTAL
Normal error handling does the job just as well. --- fftools/ffmpeg_dec.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index f5f764b6fa..62c1baf287 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -1115,9 +1115,6 @@ int dec_open(InputStream *ist) } if ((ret = avcodec_open2(ist->dec_ctx, codec, >decoder_opts)) < 0) { -if (ret == AVERROR_EXPERIMENTAL) -exit_program(1); - av_log(ist, AV_LOG_ERROR, "Error while opening decoder: %s\n", av_err2str(ret)); return ret; -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 17/47] fftools/ffmpeg_filter: return error codes from init_input_filter() instead of aborting
--- fftools/ffmpeg_filter.c | 21 + 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index cdf5610620..79e034d248 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -908,7 +908,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost, return 0; } -static void init_input_filter(FilterGraph *fg, InputFilter *ifilter) +static int init_input_filter(FilterGraph *fg, InputFilter *ifilter) { FilterGraphPriv *fgp = fgp_from_fg(fg); InputFilterPriv *ifp = ifp_from_ifilter(ifilter); @@ -920,7 +920,7 @@ static void init_input_filter(FilterGraph *fg, InputFilter *ifilter) if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO) { av_log(fg, AV_LOG_FATAL, "Only video and audio filters supported " "currently.\n"); -exit_program(1); +return AVERROR(ENOSYS); } if (ifp->linklabel) { @@ -932,7 +932,7 @@ static void init_input_filter(FilterGraph *fg, InputFilter *ifilter) if (file_idx < 0 || file_idx >= nb_input_files) { av_log(fg, AV_LOG_FATAL, "Invalid file index %d in filtergraph description %s.\n", file_idx, fgp->graph_desc); -exit_program(1); +return AVERROR(EINVAL); } s = input_files[file_idx]->ctx; @@ -950,7 +950,7 @@ static void init_input_filter(FilterGraph *fg, InputFilter *ifilter) if (!st) { av_log(fg, AV_LOG_FATAL, "Stream specifier '%s' in filtergraph description %s " "matches no streams.\n", p, fgp->graph_desc); -exit_program(1); +return AVERROR(EINVAL); } ist = input_files[file_idx]->streams[st->index]; } else { @@ -958,7 +958,7 @@ static void init_input_filter(FilterGraph *fg, InputFilter *ifilter) if (!ist) { av_log(fg, AV_LOG_FATAL, "Cannot find a matching stream for " "unlabeled input pad %s\n", ifilter->name); -exit_program(1); +return AVERROR(EINVAL); } } av_assert0(ist); @@ -968,15 +968,20 @@ static void init_input_filter(FilterGraph *fg, InputFilter *ifilter) av_log(fg, AV_LOG_ERROR, "Error binding an input stream to complex filtergraph input %s.\n", ifilter->name); -exit_program(1); +return ret; } + +return 0; } int init_complex_filtergraph(FilterGraph *fg) { // bind filtergraph inputs to input streams -for (int i = 0; i < fg->nb_inputs; i++) -init_input_filter(fg, fg->inputs[i]); +for (int i = 0; i < fg->nb_inputs; i++) { +int ret = init_input_filter(fg, fg->inputs[i]); +if (ret < 0) +return ret; +} return 0; } -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 19/47] fftools/ffmpeg_filter: return error codes from choose_pix_fmts() instead of aborting
--- fftools/ffmpeg_filter.c | 32 +++- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index ed0df9f320..2a3204121a 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -270,20 +270,20 @@ static void sub2video_update(InputFilterPriv *ifp, int64_t heartbeat_pts, ifp->sub2video.initialize = 0; } -/* May return NULL (no pixel format found), a static string or a string - * backed by the bprint. Nothing has been written to the AVBPrint in case +/* *dst may return be set to NULL (no pixel format found), a static string or a + * string backed by the bprint. Nothing has been written to the AVBPrint in case * NULL is returned. The AVBPrint provided should be clean. */ -static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint) +static int choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint, + const char **dst) { OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); OutputStream *ost = ofilter->ost; -if (ost->keep_pix_fmt) { -return ofp->format == AV_PIX_FMT_NONE ? NULL : +*dst = NULL; + +if (ost->keep_pix_fmt || ofp->format != AV_PIX_FMT_NONE) { +*dst = ofp->format == AV_PIX_FMT_NONE ? NULL : av_get_pix_fmt_name(ofp->format); -} -if (ofp->format != AV_PIX_FMT_NONE) { -return av_get_pix_fmt_name(ofp->format); } else if (ofp->formats) { const enum AVPixelFormat *p = ofp->formats; @@ -292,10 +292,12 @@ static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint) av_bprintf(bprint, "%s%c", name, p[1] == AV_PIX_FMT_NONE ? '\0' : '|'); } if (!av_bprint_is_complete(bprint)) -report_and_exit(AVERROR(ENOMEM)); -return bprint->str; -} else -return NULL; +return AVERROR(ENOMEM); + +*dst = bprint->str; +} + +return 0; } /* Define a function for appending a list of allowed formats @@ -1103,7 +1105,11 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, } av_bprint_init(, 0, AV_BPRINT_SIZE_UNLIMITED); -if ((pix_fmts = choose_pix_fmts(ofilter, ))) { +ret = choose_pix_fmts(ofilter, , _fmts); +if (ret < 0) +return ret; + +if (pix_fmts) { AVFilterContext *filter; ret = avfilter_graph_create_filter(, -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 18/47] fftools/ffmpeg_filter: replace remaining exit_program() with error codes
--- fftools/ffmpeg.h| 2 +- fftools/ffmpeg_filter.c | 15 ++- fftools/ffmpeg_opt.c| 4 +++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index d7e16d034f..043eb5e6ec 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -717,7 +717,7 @@ const AVCodec *find_codec_or_die(void *logctx, const char *name, enum AVMediaType type, int encoder); int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global); -void check_filter_outputs(void); +int check_filter_outputs(void); int filtergraph_is_simple(const FilterGraph *fg); int init_simple_filtergraph(InputStream *ist, OutputStream *ost, char *graph_desc); diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 79e034d248..ed0df9f320 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1246,7 +1246,7 @@ static int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, { if (!ofilter->ost) { av_log(fg, AV_LOG_FATAL, "Filter %s has an unconnected output\n", ofilter->name); -exit_program(1); +return AVERROR(EINVAL); } switch (avfilter_pad_get_type(out->filter_ctx->output_pads, out->pad_idx)) { @@ -1256,7 +1256,7 @@ static int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, } } -void check_filter_outputs(void) +int check_filter_outputs(void) { int i; for (i = 0; i < nb_filtergraphs; i++) { @@ -1266,10 +1266,12 @@ void check_filter_outputs(void) if (!output->ost) { av_log(filtergraphs[i], AV_LOG_FATAL, "Filter %s has an unconnected output\n", output->name); -exit_program(1); +return AVERROR(EINVAL); } } } + +return 0; } static void sub2video_prepare(InputFilterPriv *ifp) @@ -1570,8 +1572,11 @@ static int configure_filtergraph(FilterGraph *fg) } avfilter_inout_free(); -for (cur = outputs, i = 0; cur; cur = cur->next, i++) -configure_output_filter(fg, fg->outputs[i], cur); +for (cur = outputs, i = 0; cur; cur = cur->next, i++) { +ret = configure_output_filter(fg, fg->outputs[i], cur); +if (ret < 0) +return ret; +} avfilter_inout_free(); if (fgp->disable_conversions) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 300f042660..44bf263621 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1301,7 +1301,9 @@ int ffmpeg_parse_options(int argc, char **argv) apply_sync_offsets(); -check_filter_outputs(); +ret = check_filter_outputs(); +if (ret < 0) +goto fail; fail: uninit_parse_context(); -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 29/47] fftools/ffmpeg: return errors from find_codec_or_die() instead of aborting
Rename the function to just find_codec(). --- fftools/ffmpeg.h | 4 +-- fftools/ffmpeg_demux.c| 54 +++ fftools/ffmpeg_mux_init.c | 4 ++- fftools/ffmpeg_opt.c | 13 ++ 4 files changed, 50 insertions(+), 25 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 8a94cd7861..60dff87436 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -710,8 +710,8 @@ void assert_avoptions(AVDictionary *m); int assert_file_overwrite(const char *filename); char *file_read(const char *filename); AVDictionary *strip_specifiers(const AVDictionary *dict); -const AVCodec *find_codec_or_die(void *logctx, const char *name, - enum AVMediaType type, int encoder); +int find_codec(void *logctx, const char *name, + enum AVMediaType type, int encoder, const AVCodec **codec); int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global); int check_filter_outputs(void); diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 5a41db9b21..a41b59ceb8 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -911,19 +911,22 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple) return 0; } -static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s, AVStream *st, - enum HWAccelID hwaccel_id, enum AVHWDeviceType hwaccel_device_type) +static int choose_decoder(const OptionsContext *o, AVFormatContext *s, AVStream *st, + enum HWAccelID hwaccel_id, enum AVHWDeviceType hwaccel_device_type, + const AVCodec **pcodec) { char *codec_name = NULL; MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st); if (codec_name) { -const AVCodec *codec = find_codec_or_die(NULL, codec_name, st->codecpar->codec_type, 0); -st->codecpar->codec_id = codec->id; -if (recast_media && st->codecpar->codec_type != codec->type) -st->codecpar->codec_type = codec->type; -return codec; +int ret = find_codec(NULL, codec_name, st->codecpar->codec_type, 0, pcodec); +if (ret < 0) +return ret; +st->codecpar->codec_id = (*pcodec)->id; +if (recast_media && st->codecpar->codec_type != (*pcodec)->type) +st->codecpar->codec_type = (*pcodec)->type; +return 0; } else { if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && hwaccel_id == HWACCEL_GENERIC && @@ -942,13 +945,15 @@ static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s if (config->device_type == hwaccel_device_type) { av_log(NULL, AV_LOG_VERBOSE, "Selecting decoder '%s' because of requested hwaccel method %s\n", c->name, av_hwdevice_get_type_name(hwaccel_device_type)); -return c; +*pcodec = c; +return 0; } } } } -return avcodec_find_decoder(st->codecpar->codec_id); +*pcodec = avcodec_find_decoder(st->codecpar->codec_id); +return 0; } } @@ -1166,7 +1171,11 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) } } -ist->dec = choose_decoder(o, ic, st, ist->hwaccel_id, ist->hwaccel_device_type); +ret = choose_decoder(o, ic, st, ist->hwaccel_id, ist->hwaccel_device_type, + >dec); +if (ret < 0) +return ret; + ist->decoder_opts = filter_codec_opts(o->g->codec_opts, ist->st->codecpar->codec_id, ic, st, ist->dec); ist->reinit_filters = -1; @@ -1357,7 +1366,7 @@ int ifile_open(const OptionsContext *o, const char *filename) InputFile *f; AVFormatContext *ic; const AVInputFormat *file_iformat = NULL; -int err, i, ret; +int err, i, ret = 0; int64_t timestamp; AVDictionary *unused_opts = NULL; const AVDictionaryEntry *e = NULL; @@ -1455,13 +1464,19 @@ int ifile_open(const OptionsContext *o, const char *filename) MATCH_PER_TYPE_OPT(codec_names, str, data_codec_name, ic, "d"); if (video_codec_name) -ic->video_codec= find_codec_or_die(NULL, video_codec_name , AVMEDIA_TYPE_VIDEO , 0); +ret = err_merge(ret, find_codec(NULL, video_codec_name , AVMEDIA_TYPE_VIDEO , 0, +>video_codec)); if (audio_codec_name) -ic->audio_codec= find_codec_or_die(NULL, audio_codec_name , AVMEDIA_TYPE_AUDIO , 0); +ret = err_merge(ret, find_codec(NULL, audio_codec_name , AVMEDIA_TYPE_AUDIO , 0, +>audio_codec)); if (subtitle_codec_name) -ic->subtitle_codec = find_codec_or_die(NULL, subtitle_codec_name,
[FFmpeg-devel] [PATCH 10/47] fftools/ffmpeg_enc: return errors from do_*_out() instead of aborting
--- fftools/ffmpeg_enc.c | 29 ++--- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index f84641b1c4..72ba56a03d 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -839,8 +839,8 @@ static int submit_encode_frame(OutputFile *of, OutputStream *ost, } } -static void do_audio_out(OutputFile *of, OutputStream *ost, - AVFrame *frame) +static int do_audio_out(OutputFile *of, OutputStream *ost, +AVFrame *frame) { Encoder *e = ost->enc; AVCodecContext *enc = ost->enc_ctx; @@ -850,7 +850,7 @@ static void do_audio_out(OutputFile *of, OutputStream *ost, enc->ch_layout.nb_channels != frame->ch_layout.nb_channels) { av_log(ost, AV_LOG_ERROR, "Audio channel count changed and encoder does not support parameter changes\n"); -return; +return 0; } if (frame->pts == AV_NOPTS_VALUE) @@ -866,13 +866,12 @@ static void do_audio_out(OutputFile *of, OutputStream *ost, enc->time_base); if (!check_recording_time(ost, frame->pts, frame->time_base)) -return; +return 0; e->next_pts = frame->pts + frame->nb_samples; ret = submit_encode_frame(of, ost, frame); -if (ret < 0 && ret != AVERROR_EOF) -exit_program(1); +return (ret < 0 && ret != AVERROR_EOF) ? ret : 0; } static double adjust_frame_pts_to_encoder_tb(OutputFile *of, OutputStream *ost, @@ -1059,7 +1058,7 @@ force_keyframe: } /* May modify/reset frame */ -static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) +static int do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) { int ret; Encoder *e = ost->enc; @@ -1090,7 +1089,7 @@ static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) if (nb_frames > dts_error_threshold * 30) { av_log(ost, AV_LOG_ERROR, "%"PRId64" frame duplication too large, skipping\n", nb_frames - 1); ost->nb_frames_drop++; -return; +return 0; } ost->nb_frames_dup += nb_frames - (nb_frames_prev && ost->last_dropped) - (nb_frames > nb_frames_prev); av_log(ost, AV_LOG_VERBOSE, "*** %"PRId64" dup!\n", nb_frames - 1); @@ -1112,12 +,12 @@ static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) in_picture = frame; if (!in_picture) -return; +return 0; in_picture->pts = e->next_pts; if (!check_recording_time(ost, in_picture->pts, ost->enc_ctx->time_base)) -return; +return 0; in_picture->quality = enc->global_quality; in_picture->pict_type = forced_kf_apply(ost, >kf, enc->time_base, in_picture, i); @@ -1126,7 +1125,7 @@ static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) if (ret == AVERROR_EOF) break; else if (ret < 0) -exit_program(1); +return ret; e->next_pts++; e->vsync_frame_number++; @@ -1135,6 +1134,8 @@ static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) av_frame_unref(e->last_frame); if (frame) av_frame_move_ref(e->last_frame, frame); + +return 0; } int enc_frame(OutputStream *ost, AVFrame *frame) @@ -1146,10 +1147,8 @@ int enc_frame(OutputStream *ost, AVFrame *frame) if (ret < 0) return ret; -if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) do_video_out(of, ost, frame); -elsedo_audio_out(of, ost, frame); - -return 0; +return ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO ? + do_video_out(of, ost, frame) : do_audio_out(of, ost, frame); } void enc_flush(void) -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 12/47] fftools/ffmpeg_enc: return errors from encode_frame() instead of aborting
--- fftools/ffmpeg_enc.c | 20 ++-- 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 728c09dcad..9ca3940b93 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -641,7 +641,7 @@ static inline double psnr(double d) return -10.0 * log10(d); } -static void update_video_stats(OutputStream *ost, const AVPacket *pkt, int write_vstats) +static int update_video_stats(OutputStream *ost, const AVPacket *pkt, int write_vstats) { Encoder*e = ost->enc; const uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, @@ -663,14 +663,14 @@ static void update_video_stats(OutputStream *ost, const AVPacket *pkt, int write } if (!write_vstats) -return; +return 0; /* this is executed just the first time update_video_stats is called */ if (!vstats_file) { vstats_file = fopen(vstats_filename, "w"); if (!vstats_file) { perror("fopen"); -exit_program(1); +return AVERROR(errno); } } @@ -697,6 +697,8 @@ static void update_video_stats(OutputStream *ost, const AVPacket *pkt, int write fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ", (double)e->data_size / 1024, ti1, bitrate, avg_bitrate); fprintf(vstats_file, "type= %c\n", av_get_picture_type_char(pict_type)); + +return 0; } static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) @@ -738,6 +740,8 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) } while (1) { +av_packet_unref(pkt); + ret = avcodec_receive_packet(enc, pkt); update_benchmark("%s_%s %d.%d", action, type_desc, ost->file_index, ost->index); @@ -759,8 +763,12 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) return ret; } -if (enc->codec_type == AVMEDIA_TYPE_VIDEO) -update_video_stats(ost, pkt, !!vstats_filename); +if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { +ret = update_video_stats(ost, pkt, !!vstats_filename); +if (ret < 0) +return ret; +} + if (ost->enc_stats_post.io) enc_stats_write(ost, >enc_stats_post, NULL, pkt, e->packets_encoded); @@ -779,7 +787,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) av_log(NULL, AV_LOG_ERROR, "Subtitle heartbeat logic failed in %s! (%s)\n", __func__, av_err2str(ret)); -exit_program(1); +return ret; } e->data_size += pkt->size; -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 14/47] fftools/ffmpeg_dec: return error codes from dec_packet() instead of aborting
--- fftools/ffmpeg.c | 5 - fftools/ffmpeg_dec.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index ddb011741a..b4ea52ac1d 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -814,8 +814,11 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo int eof_reached = 0; int duration_exceeded; -if (ist->decoding_needed) +if (ist->decoding_needed) { ret = dec_packet(ist, pkt, no_eof); +if (ret < 0 && ret != AVERROR_EOF) +return ret; +} if (ret == AVERROR_EOF || (!pkt && !ist->decoding_needed)) eof_reached = 1; diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index 5c1be9..f5f764b6fa 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -816,7 +816,7 @@ finish: } // non-EOF errors here are all fatal if (ret < 0 && ret != AVERROR_EOF) -report_and_exit(ret); +return ret; // signal EOF to our downstreams if (ist->dec->type == AVMEDIA_TYPE_SUBTITLE) @@ -825,7 +825,7 @@ finish: ret = send_filter_eof(ist); if (ret < 0) { av_log(NULL, AV_LOG_FATAL, "Error marking filters as finished\n"); -exit_program(1); +return ret; } } -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 08/47] fftools/ffmpeg_enc: return errors from enc_frame() instead of aborting
--- fftools/ffmpeg.h| 2 +- fftools/ffmpeg_enc.c| 6 -- fftools/ffmpeg_filter.c | 12 +--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 0189bee0f3..38f2b1ef66 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -815,7 +815,7 @@ void enc_free(Encoder **penc); int enc_open(OutputStream *ost, AVFrame *frame); int enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub); -void enc_frame(OutputStream *ost, AVFrame *frame); +int enc_frame(OutputStream *ost, AVFrame *frame); void enc_flush(void); /* diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 1489b2f179..6130e3e221 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -1133,17 +1133,19 @@ static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *frame) av_frame_move_ref(e->last_frame, frame); } -void enc_frame(OutputStream *ost, AVFrame *frame) +int enc_frame(OutputStream *ost, AVFrame *frame) { OutputFile *of = output_files[ost->file_index]; int ret; ret = enc_open(ost, frame); if (ret < 0) -exit_program(1); +return ret; if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) do_video_out(of, ost, frame); elsedo_audio_out(of, ost, frame); + +return 0; } void enc_flush(void) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 49e0800e6e..d373d8c002 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1722,8 +1722,11 @@ int reap_filters(FilterGraph *fg, int flush) av_log(fgp, AV_LOG_WARNING, "Error in av_buffersink_get_frame_flags(): %s\n", av_err2str(ret)); } else if (flush && ret == AVERROR_EOF && ofp->got_frame && - av_buffersink_get_type(filter) == AVMEDIA_TYPE_VIDEO) -enc_frame(ost, NULL); + av_buffersink_get_type(filter) == AVMEDIA_TYPE_VIDEO) { +ret = enc_frame(ost, NULL); +if (ret < 0) +return ret; +} break; } @@ -1759,8 +1762,11 @@ int reap_filters(FilterGraph *fg, int flush) if (ost->type == AVMEDIA_TYPE_VIDEO) fd->frame_rate_filter = av_buffersink_get_frame_rate(filter); -enc_frame(ost, filtered_frame); +ret = enc_frame(ost, filtered_frame); av_frame_unref(filtered_frame); +if (ret < 0) +return ret; + ofp->got_frame = 1; } } -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 26/47] fftools/cmdutils: add error handling to allocate_array_elem()
--- fftools/cmdutils.c| 2 +- fftools/cmdutils.h| 3 +-- fftools/ffmpeg_demux.c| 16 ++-- fftools/ffmpeg_filter.c | 28 +--- fftools/ffmpeg_mux_init.c | 16 ++-- 5 files changed, 51 insertions(+), 14 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index e2fa08c116..6c627ee815 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -1002,7 +1002,7 @@ void *allocate_array_elem(void *ptr, size_t elem_size, int *nb_elems) if (!(new_elem = av_mallocz(elem_size)) || av_dynarray_add_nofree(ptr, nb_elems, new_elem) < 0) -report_and_exit(AVERROR(ENOMEM)); +return NULL; return new_elem; } diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index decd23040f..6b9d7f80ae 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -430,13 +430,12 @@ void *grow_array(void *array, int elem_size, int *size, int new_size); * Atomically add a new element to an array of pointers, i.e. allocate * a new entry, reallocate the array of pointers and make the new last * member of this array point to the newly allocated buffer. - * Calls exit() on failure. * * @param array array of pointers to reallocate * @param elem_size size of the new element to allocate * @param nb_elems pointer to the number of elements of the array array; * *nb_elems will be incremented by one by this function. - * @return pointer to the newly allocated entry + * @return pointer to the newly allocated entry or NULL on failure */ void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems); diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index a43c39b843..72b94ea44f 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -1018,8 +1018,11 @@ static DemuxStream *demux_stream_alloc(Demuxer *d, AVStream *st) { const char *type_str = av_get_media_type_string(st->codecpar->codec_type); InputFile*f = >f; -DemuxStream *ds = allocate_array_elem(>streams, sizeof(*ds), - >nb_streams); +DemuxStream *ds; + +ds = allocate_array_elem(>streams, sizeof(*ds), >nb_streams); +if (!ds) +return NULL; ds->ist.st = st; ds->ist.file_index = f->index; @@ -1051,6 +1054,9 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) int ret; ds = demux_stream_alloc(d, st); +if (!ds) +return AVERROR(ENOMEM); + ist = >ist; ist->discard = 1; @@ -1328,6 +1334,9 @@ static Demuxer *demux_alloc(void) { Demuxer *d = allocate_array_elem(_files, sizeof(*d), _input_files); +if (!d) +return NULL; + d->f.class = _file_class; d->f.index = nb_input_files - 1; @@ -1358,6 +1367,9 @@ int ifile_open(const OptionsContext *o, const char *filename) int64_t recording_time = o->recording_time; d = demux_alloc(); +if (!d) +return AVERROR(ENOMEM); + f = >f; if (stop_time != INT64_MAX && recording_time != INT64_MAX) { diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 26aff9c328..880d883064 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -550,8 +550,10 @@ static OutputFilter *ofilter_alloc(FilterGraph *fg) OutputFilterPriv *ofp; OutputFilter *ofilter; -ofp = allocate_array_elem(>outputs, sizeof(*ofp), ->nb_outputs); +ofp = allocate_array_elem(>outputs, sizeof(*ofp), >nb_outputs); +if (!ofp) +return NULL; + ofilter = >ofilter; ofilter->graph= fg; ofp->format = -1; @@ -715,10 +717,14 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost) static InputFilter *ifilter_alloc(FilterGraph *fg) { -InputFilterPriv *ifp = allocate_array_elem(>inputs, sizeof(*ifp), - >nb_inputs); -InputFilter *ifilter = >ifilter; +InputFilterPriv *ifp; +InputFilter *ifilter; +ifp = allocate_array_elem(>inputs, sizeof(*ifp), >nb_inputs); +if (!ifp) +return NULL; + +ifilter = >ifilter; ifilter->graph = fg; ifp->frame = av_frame_alloc(); @@ -800,13 +806,18 @@ static const AVClass fg_class = { int fg_create(FilterGraph **pfg, char *graph_desc) { -FilterGraphPriv *fgp = allocate_array_elem(, sizeof(*fgp), _filtergraphs); -FilterGraph *fg = >fg; +FilterGraphPriv *fgp; +FilterGraph *fg; AVFilterInOut *inputs, *outputs; AVFilterGraph *graph; int ret = 0; +fgp = allocate_array_elem(, sizeof(*fgp), _filtergraphs); +if (!fgp) +return AVERROR(ENOMEM); +fg = >fg; + if (pfg) *pfg = fg; @@ -851,6 +862,9 @@ int fg_create(FilterGraph **pfg, char *graph_desc) for (AVFilterInOut *cur = outputs; cur; cur = cur->next) { OutputFilter *const ofilter =
[FFmpeg-devel] [PATCH 11/47] fftools/ffmpeg_enc: return errors from enc_flush() instead of aborting
--- fftools/ffmpeg.c | 2 +- fftools/ffmpeg.h | 2 +- fftools/ffmpeg_enc.c | 6 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 27c4e7ef26..926fdea23a 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1250,7 +1250,7 @@ static int transcode(int *err_rate_exceeded) } else if (err_rate) av_log(ist, AV_LOG_VERBOSE, "Decode error rate %g\n", err_rate); } -enc_flush(); +ret = err_merge(ret, enc_flush()); term_exit(); diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 38f2b1ef66..7329df6607 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -816,7 +816,7 @@ void enc_free(Encoder **penc); int enc_open(OutputStream *ost, AVFrame *frame); int enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub); int enc_frame(OutputStream *ost, AVFrame *frame); -void enc_flush(void); +int enc_flush(void); /* * Initialize muxing state for the given stream, should be called diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 72ba56a03d..728c09dcad 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -1151,7 +1151,7 @@ int enc_frame(OutputStream *ost, AVFrame *frame) do_video_out(of, ost, frame) : do_audio_out(of, ost, frame); } -void enc_flush(void) +int enc_flush(void) { int ret; @@ -1172,6 +1172,8 @@ void enc_flush(void) ret = submit_encode_frame(of, ost, NULL); if (ret != AVERROR_EOF) -exit_program(1); +return ret; } + +return 0; } -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 07/47] fftools/ffmpeg_mux_init: avoid invalid memory access in set_dispositions()
This function assumes AVMEDIA_* are always positive, while in fact it can also handle AVMEDIA_TYPE_UNKNOWN, which is -1. --- fftools/ffmpeg_mux_init.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 03d60f2a19..cc5ec68040 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -2296,8 +2296,9 @@ static int set_dispositions(Muxer *mux, const OptionsContext *o) OutputFile*of = >of; AVFormatContext *ctx = mux->fc; -int nb_streams[AVMEDIA_TYPE_NB] = { 0 }; -int have_default[AVMEDIA_TYPE_NB] = { 0 }; +// indexed by type+1, because AVMEDIA_TYPE_UNKNOWN=-1 +int nb_streams[AVMEDIA_TYPE_NB + 1] = { 0 }; +int have_default[AVMEDIA_TYPE_NB + 1] = { 0 }; int have_manual = 0; int ret = 0; @@ -2311,7 +2312,7 @@ static int set_dispositions(Muxer *mux, const OptionsContext *o) for (int i = 0; i < ctx->nb_streams; i++) { OutputStream *ost = of->streams[i]; -nb_streams[ost->type]++; +nb_streams[ost->type + 1]++; MATCH_PER_STREAM_OPT(disposition, str, dispositions[i], ctx, ost->st); @@ -2321,7 +2322,7 @@ static int set_dispositions(Muxer *mux, const OptionsContext *o) ost->st->disposition = ost->ist->st->disposition; if (ost->st->disposition & AV_DISPOSITION_DEFAULT) -have_default[ost->type] = 1; +have_default[ost->type + 1] = 1; } } @@ -2346,12 +2347,12 @@ static int set_dispositions(Muxer *mux, const OptionsContext *o) OutputStream *ost = of->streams[i]; enum AVMediaType type = ost->type; -if (nb_streams[type] < 2 || have_default[type] || +if (nb_streams[type + 1] < 2 || have_default[type + 1] || ost->st->disposition & AV_DISPOSITION_ATTACHED_PIC) continue; ost->st->disposition |= AV_DISPOSITION_DEFAULT; -have_default[type] = 1; +have_default[type + 1] = 1; } } -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 06/47] fftools/ffmpeg_filter: restrict reap_filters() to a single filtergraph
This is more natural, as all except one of its callers require processing only one filtergraph. --- fftools/ffmpeg.c| 10 +- fftools/ffmpeg.h| 4 ++-- fftools/ffmpeg_filter.c | 33 - 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index cbeddab125..27c4e7ef26 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1171,7 +1171,15 @@ static int transcode_step(OutputStream *ost) if (ret < 0) return ret == AVERROR_EOF ? 0 : ret; -return reap_filters(0); +// process_input() above might have caused output to become available +// in multiple filtergraphs, so we process all of them +for (int i = 0; i < nb_filtergraphs; i++) { +ret = reap_filters(filtergraphs[i], 0); +if (ret < 0) +return ret; +} + +return 0; } /* diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 7c4f4365c6..0189bee0f3 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -766,12 +766,12 @@ void fg_free(FilterGraph **pfg); int fg_transcode_step(FilterGraph *graph, InputStream **best_ist); /** - * Get and encode new output from any of the filtergraphs, without causing + * Get and encode new output from specified filtergraph, without causing * activity. * * @return 0 for success, <0 for severe errors */ -int reap_filters(int flush); +int reap_filters(FilterGraph *fg, int flush); int ffmpeg_parse_options(int argc, char **argv); diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index e14b8f0f3c..49e0800e6e 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1695,24 +1695,23 @@ int filtergraph_is_simple(const FilterGraph *fg) return fgp->is_simple; } -int reap_filters(int flush) +int reap_filters(FilterGraph *fg, int flush) { +FilterGraphPriv*fgp = fgp_from_fg(fg); +AVFrame *filtered_frame = fgp->frame; + +if (!fg->graph) +return 0; + /* Reap all buffers present in the buffer sinks */ -for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { -OutputFilterPriv *ofp; -FilterGraphPriv *fgp; -AVFrame *filtered_frame; -AVFilterContext *filter; +for (int i = 0; i < fg->nb_outputs; i++) { +OutputFilter *ofilter = fg->outputs[i]; +OutputStream *ost = ofilter->ost; +OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); +AVFilterContext *filter = ofp->filter; + int ret = 0; -if (!ost->filter || !ost->filter->graph->graph) -continue; -fgp= fgp_from_fg(ost->filter->graph); -ofp= ofp_from_ofilter(ost->filter); -filter = ofp->filter; - -filtered_frame = fgp->frame; - while (1) { FrameData *fd; @@ -1931,7 +1930,7 @@ int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame, int keep_reference) return ret; } -ret = reap_filters(0); +ret = reap_filters(fg, 0); if (ret < 0 && ret != AVERROR_EOF) { av_log(fg, AV_LOG_ERROR, "Error while filtering: %s\n", av_err2str(ret)); return ret; @@ -2000,10 +1999,10 @@ int fg_transcode_step(FilterGraph *graph, InputStream **best_ist) *best_ist = NULL; ret = avfilter_graph_request_oldest(graph->graph); if (ret >= 0) -return reap_filters(0); +return reap_filters(graph, 0); if (ret == AVERROR_EOF) { -reap_filters(1); +reap_filters(graph, 1); for (int i = 0; i < graph->nb_outputs; i++) { OutputFilter *ofilter = graph->outputs[i]; OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 24/47] fftools/ffmpeg_opt: reimplement -streamid using a dictionary
This does not require an arbitrary limit on the number of streams. Also, return error codes from opt_streamid() instead of aborting. --- fftools/ffmpeg.h | 7 ++- fftools/ffmpeg_mux_init.c | 18 +++--- fftools/ffmpeg_opt.c | 12 +--- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index ba73dcffdc..8a94cd7861 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -73,8 +73,6 @@ enum EncTimeBase { ENC_TIME_BASE_FILTER = -2, }; -#define MAX_STREAMS 1024/* arbitrary sanity check value */ - enum HWAccelID { HWACCEL_NONE = 0, HWACCEL_AUTO, @@ -184,9 +182,8 @@ typedef struct OptionsContext { int subtitle_disable; int data_disable; -/* indexed by output file stream index */ -int *streamid_map; -int nb_streamid_map; +// keys are stream indices +AVDictionary *streamid; SpecifierOpt *metadata; intnb_metadata; diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 359a5149d4..ac4ef328a6 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -,12 +,24 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, if (!st) return AVERROR(ENOMEM); -if (oc->nb_streams - 1 < o->nb_streamid_map) -st->id = o->streamid_map[oc->nb_streams - 1]; - ms = mux_stream_alloc(mux, type); ost = >ost; +if (o->streamid) { +AVDictionaryEntry *e; +char idx[16], *p; +snprintf(idx, sizeof(idx), "%d", ost->index); + +e = av_dict_get(o->streamid, idx, NULL, 0); +if (e) { +st->id = strtol(e->value, , 0); +if (!e->value[0] || *p) { +av_log(ost, AV_LOG_FATAL, "Invalid stream id: %s\n", e->value); +return AVERROR(EINVAL); +} +} +} + ost->par_in = avcodec_parameters_alloc(); if (!ost->par_in) return AVERROR(ENOMEM); diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 25a1083366..7002986369 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -128,8 +128,9 @@ static void uninit_options(OptionsContext *o) #if FFMPEG_OPT_MAP_CHANNEL av_freep(>audio_channel_maps); #endif -av_freep(>streamid_map); av_freep(>attachments); + +av_dict_free(>streamid); } static void init_options(OptionsContext *o) @@ -727,7 +728,6 @@ char *file_read(const char *filename) static int opt_streamid(void *optctx, const char *opt, const char *arg) { OptionsContext *o = optctx; -int idx; char *p; char idx_str[16]; @@ -737,13 +737,11 @@ static int opt_streamid(void *optctx, const char *opt, const char *arg) av_log(NULL, AV_LOG_FATAL, "Invalid value '%s' for option '%s', required syntax is 'index:value'\n", arg, opt); -exit_program(1); +return AVERROR(EINVAL); } *p++ = '\0'; -idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1); -o->streamid_map = grow_array(o->streamid_map, sizeof(*o->streamid_map), >nb_streamid_map, idx+1); -o->streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX); -return 0; + +return av_dict_set(>streamid, idx_str, p, 0); } static int init_complex_filters(void) -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 16/47] fftools/ffmpeg_filter: return error codes from ofilter_bind_ost() instead of aborting
--- fftools/ffmpeg.h | 2 +- fftools/ffmpeg_filter.c | 12 fftools/ffmpeg_mux_init.c | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 62b56a8cd8..d7e16d034f 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -744,7 +744,7 @@ void ifilter_sub2video_heartbeat(InputFilter *ifilter, int64_t pts, AVRational t */ int ifilter_parameters_from_dec(InputFilter *ifilter, const AVCodecContext *dec); -void ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost); +int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost); /** * Create a new filtergraph in the global filtergraph list. diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index d373d8c002..cdf5610620 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -624,7 +624,7 @@ static void set_channel_layout(OutputFilterPriv *f, OutputStream *ost) av_channel_layout_default(>ch_layout, ost->enc_ctx->ch_layout.nb_channels); } -void ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost) +int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost) { OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); FilterGraph *fg = ofilter->graph; @@ -699,15 +699,17 @@ void ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost) for (int i = 0; i < fg->nb_outputs; i++) if (!fg->outputs[i]->ost) -return; +return 0; ret = configure_filtergraph(fg); if (ret < 0) { av_log(fg, AV_LOG_ERROR, "Error configuring filter graph: %s\n", av_err2str(ret)); -exit_program(1); +return ret; } } + +return 0; } static InputFilter *ifilter_alloc(FilterGraph *fg) @@ -899,7 +901,9 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost, if (ret < 0) return ret; -ofilter_bind_ost(fg->outputs[0], ost); +ret = ofilter_bind_ost(fg->outputs[0], ost); +if (ret < 0) +return ret; return 0; } diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index cc5ec68040..359a5149d4 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -1393,7 +1393,9 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type, (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) { if (ofilter) { ost->filter = ofilter; -ofilter_bind_ost(ofilter, ost); +ret = ofilter_bind_ost(ofilter, ost); +if (ret < 0) +return ret; } else { ret = init_simple_filtergraph(ost->ist, ost, filters); if (ret < 0) { -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 22/47] fftools/ffmpeg_filter: replace remaining report_and_exit() with error codes
--- fftools/ffmpeg_filter.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 470d7b1f02..26aff9c328 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -723,14 +723,14 @@ static InputFilter *ifilter_alloc(FilterGraph *fg) ifp->frame = av_frame_alloc(); if (!ifp->frame) -report_and_exit(AVERROR(ENOMEM)); +return NULL; ifp->format = -1; ifp->fallback.format = -1; ifp->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW); if (!ifp->frame_queue) -report_and_exit(AVERROR(ENOMEM)); +return NULL; return ifilter; } @@ -1781,7 +1781,7 @@ int reap_filters(FilterGraph *fg, int flush) fd = frame_data(filtered_frame); if (!fd) { av_frame_unref(filtered_frame); -report_and_exit(AVERROR(ENOMEM)); +return AVERROR(ENOMEM); } // only use bits_per_raw_sample passed through from the decoder -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 03/47] fftools/ffmpeg_mux_init: deprecate "smart" pixel format selection
It may override a format explicitly requested with -pix_fmt and instead select something completely unrelated, which is a user-hostile behaviour and is inconsistent with how other options generally work. Print a warning and delay for a second to make the users aware of the deprecation. --- doc/ffmpeg.texi | 3 +-- fftools/ffmpeg.h | 1 + fftools/ffmpeg_mux_init.c | 15 +-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 2273c39214..a6ef5590c7 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1014,8 +1014,7 @@ Disable autoscale at your own risk. @item -pix_fmt[:@var{stream_specifier}] @var{format} (@emph{input/output,per-stream}) Set pixel format. Use @code{-pix_fmts} to show all the supported pixel formats. -If the selected pixel format can not be selected, ffmpeg will print a -warning and select the best pixel format supported by the encoder. + If @var{pix_fmt} is prefixed by a @code{+}, ffmpeg will exit with an error if the requested pixel format can not be selected, and automatic conversions inside filtergraphs are disabled. diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index f45ddf33b2..7c4f4365c6 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -57,6 +57,7 @@ #define FFMPEG_OPT_QPHIST 1 #define FFMPEG_OPT_ADRIFT_THRESHOLD 1 #define FFMPEG_OPT_ENC_TIME_BASE_NUM 1 +#define FFMPEG_OPT_SMART_PIXFMT 1 enum VideoSyncMethod { VSYNC_AUTO = -1, diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 3fe157c2e4..03d60f2a19 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -45,6 +45,7 @@ #include "libavutil/opt.h" #include "libavutil/parseutils.h" #include "libavutil/pixdesc.h" +#include "libavutil/time.h" #define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass" @@ -503,6 +504,7 @@ static int fmt_in_list(const int *formats, int format) return 0; } +#if FFMPEG_OPT_SMART_PIXFMT static enum AVPixelFormat choose_pixel_fmt(const AVCodec *codec, enum AVPixelFormat target) { @@ -518,16 +520,23 @@ choose_pixel_fmt(const AVCodec *codec, enum AVPixelFormat target) break; } if (*p == AV_PIX_FMT_NONE) { -if (target != AV_PIX_FMT_NONE) +if (target != AV_PIX_FMT_NONE) { av_log(NULL, AV_LOG_WARNING, - "Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n", + "Requested pixel format '%s' is nut supported by encoder '%s', " + "auto-selecting format '%s'\n", av_get_pix_fmt_name(target), codec->name, av_get_pix_fmt_name(best)); +av_log(NULL, AV_LOG_WARNING, "This behaviour is deprecated and will " + "be removed. Use -h encoder=%s to check supported pixel " + "formats and select one of them.\n", codec->name); +av_usleep(100); +} return best; } return target; } +#endif static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) { @@ -566,8 +575,10 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) } } +#if FFMPEG_OPT_SMART_PIXFMT if (fmts && !fmt_in_list(fmts, fmt)) fmt = choose_pixel_fmt(ost->enc_ctx->codec, fmt); +#endif return fmt; } -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 05/47] fftools/ffmpeg_filter: stop accessing encoder from pixfmt selection
ffmpeg CLI pixel format selection for filtering currently special-cases MJPEG encoding, where it will restrict the supported list of pixel formats depending on the value of the -strict option. In order to get that value it will apply it from the options dict into the encoder context, which is a highly invasive action even now, and would become a race once encoding is moved to its own thread. The ugliness of this code can be much reduced by moving the special handling of MJPEG into ofilter_bind_ost(), which is called from encoder init and is thus synchronized with it. There is also no need to write anything to the encoder context, we can evaluate the option into our stack variable. There is also no need to access AVCodec at all during pixel format selection, as the pixel formats array is already stored in OutputFilterPriv. --- fftools/ffmpeg_filter.c | 64 - 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 71595513f3..e14b8f0f3c 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -270,46 +270,22 @@ static void sub2video_update(InputFilterPriv *ifp, int64_t heartbeat_pts, ifp->sub2video.initialize = 0; } -// FIXME: YUV420P etc. are actually supported with full color range, -// yet the latter information isn't available here. -static const enum AVPixelFormat *get_compliance_normal_pix_fmts(const AVCodec *codec, const enum AVPixelFormat default_formats[]) -{ -static const enum AVPixelFormat mjpeg_formats[] = -{ AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, - AV_PIX_FMT_NONE }; - -if (!strcmp(codec->name, "mjpeg")) { -return mjpeg_formats; -} else { -return default_formats; -} -} - /* May return NULL (no pixel format found), a static string or a string * backed by the bprint. Nothing has been written to the AVBPrint in case * NULL is returned. The AVBPrint provided should be clean. */ static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint) { +OutputFilterPriv *ofp = ofp_from_ofilter(ofilter); OutputStream *ost = ofilter->ost; -AVCodecContext *enc = ost->enc_ctx; -const AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0); -if (strict_dict) -av_opt_set(ost->enc_ctx, "strict", strict_dict->value, 0); - if (ost->keep_pix_fmt) { -if (ost->enc_ctx->pix_fmt == AV_PIX_FMT_NONE) -return NULL; -return av_get_pix_fmt_name(ost->enc_ctx->pix_fmt); +if (ost->keep_pix_fmt) { +return ofp->format == AV_PIX_FMT_NONE ? NULL : + av_get_pix_fmt_name(ofp->format); } -if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) { -return av_get_pix_fmt_name(enc->pix_fmt); -} else if (enc->codec->pix_fmts) { -const enum AVPixelFormat *p; - -p = enc->codec->pix_fmts; -if (ost->enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) { -p = get_compliance_normal_pix_fmts(enc->codec, p); -} +if (ofp->format != AV_PIX_FMT_NONE) { +return av_get_pix_fmt_name(ofp->format); +} else if (ofp->formats) { +const enum AVPixelFormat *p = ofp->formats; for (; *p != AV_PIX_FMT_NONE; p++) { const char *name = av_get_pix_fmt_name(*p); @@ -668,6 +644,30 @@ void ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost) ofp->format = ost->enc_ctx->pix_fmt; } else { ofp->formats = c->pix_fmts; + +// MJPEG encoder exports a full list of supported pixel formats, +// but the full-range ones are experimental-only. +// Restrict the auto-conversion list unless -strict experimental +// has been specified. +if (!strcmp(c->name, "mjpeg")) { +// FIXME: YUV420P etc. are actually supported with full color range, +// yet the latter information isn't available here. +static const enum AVPixelFormat mjpeg_formats[] = +{ AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, + AV_PIX_FMT_NONE }; + +const AVDictionaryEntry *strict = av_dict_get(ost->encoder_opts, "strict", NULL, 0); +int strict_val = ost->enc_ctx->strict_std_compliance; + +if (strict) { +const AVOption *o = av_opt_find(ost->enc_ctx, strict->key, NULL, 0, 0); +av_assert0(o); +av_opt_eval_int(ost->enc_ctx, o, strict->value, _val); +} + +if (strict_val > FF_COMPLIANCE_UNOFFICIAL) +ofp->formats = mjpeg_formats; +} } fgp->disable_conversions |= ost->keep_pix_fmt; -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org
[FFmpeg-devel] [PATCH 02/47] fftools/ffmpeg_filter: move "smart" pixfmt selection to ffmpeg_mux_init
This code works on encoder information and has no interaction with filtering, so it does not belong in ffmpeg_filter. --- fftools/ffmpeg_filter.c | 36 +--- fftools/ffmpeg_mux_init.c | 29 + 2 files changed, 30 insertions(+), 35 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index de75c9970e..71595513f3 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -285,38 +285,6 @@ static const enum AVPixelFormat *get_compliance_normal_pix_fmts(const AVCodec *c } } -static enum AVPixelFormat -choose_pixel_fmt(const AVCodec *codec, enum AVPixelFormat target, - int strict_std_compliance) -{ -if (codec && codec->pix_fmts) { -const enum AVPixelFormat *p = codec->pix_fmts; -const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(target); -//FIXME: This should check for AV_PIX_FMT_FLAG_ALPHA after PAL8 pixel format without alpha is implemented -int has_alpha = desc ? desc->nb_components % 2 == 0 : 0; -enum AVPixelFormat best= AV_PIX_FMT_NONE; - -if (strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) { -p = get_compliance_normal_pix_fmts(codec, p); -} -for (; *p != AV_PIX_FMT_NONE; p++) { -best = av_find_best_pix_fmt_of_2(best, *p, target, has_alpha, NULL); -if (*p == target) -break; -} -if (*p == AV_PIX_FMT_NONE) { -if (target != AV_PIX_FMT_NONE) -av_log(NULL, AV_LOG_WARNING, - "Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n", - av_get_pix_fmt_name(target), - codec->name, - av_get_pix_fmt_name(best)); -return best; -} -} -return target; -} - /* May return NULL (no pixel format found), a static string or a string * backed by the bprint. Nothing has been written to the AVBPrint in case * NULL is returned. The AVBPrint provided should be clean. */ @@ -326,7 +294,6 @@ static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint) AVCodecContext *enc = ost->enc_ctx; const AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0); if (strict_dict) -// used by choose_pixel_fmt() and below av_opt_set(ost->enc_ctx, "strict", strict_dict->value, 0); if (ost->keep_pix_fmt) { @@ -335,8 +302,7 @@ static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint) return av_get_pix_fmt_name(ost->enc_ctx->pix_fmt); } if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) { -return av_get_pix_fmt_name(choose_pixel_fmt(enc->codec, enc->pix_fmt, - ost->enc_ctx->strict_std_compliance)); +return av_get_pix_fmt_name(enc->pix_fmt); } else if (enc->codec->pix_fmts) { const enum AVPixelFormat *p; diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 2d45fa7c7c..3fe157c2e4 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -503,6 +503,32 @@ static int fmt_in_list(const int *formats, int format) return 0; } +static enum AVPixelFormat +choose_pixel_fmt(const AVCodec *codec, enum AVPixelFormat target) +{ +const enum AVPixelFormat *p = codec->pix_fmts; +const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(target); +//FIXME: This should check for AV_PIX_FMT_FLAG_ALPHA after PAL8 pixel format without alpha is implemented +int has_alpha = desc ? desc->nb_components % 2 == 0 : 0; +enum AVPixelFormat best= AV_PIX_FMT_NONE; + +for (; *p != AV_PIX_FMT_NONE; p++) { +best = av_find_best_pix_fmt_of_2(best, *p, target, has_alpha, NULL); +if (*p == target) +break; +} +if (*p == AV_PIX_FMT_NONE) { +if (target != AV_PIX_FMT_NONE) +av_log(NULL, AV_LOG_WARNING, + "Incompatible pixel format '%s' for codec '%s', auto-selecting format '%s'\n", + av_get_pix_fmt_name(target), + codec->name, + av_get_pix_fmt_name(best)); +return best; +} +return target; +} + static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) { const enum AVPixelFormat *fmts = ost->enc_ctx->codec->pix_fmts; @@ -540,6 +566,9 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) } } +if (fmts && !fmt_in_list(fmts, fmt)) +fmt = choose_pixel_fmt(ost->enc_ctx->codec, fmt); + return fmt; } -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 04/47] tests/fate: fix mismatches between requested and actually used pixel formats
--- tests/fate/fits.mak | 6 +++--- tests/fate/lavf-video.mak | 2 +- tests/fate/vcodec.mak | 4 ++-- tests/ref/fate/{fitsdec-gbrap16le => fitsdec-gbrap16be} | 4 ++-- tests/ref/fate/{fitsdec-gbrp16 => fitsdec-gbrp16be} | 4 ++-- tests/ref/lavf/gif | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) rename tests/ref/fate/{fitsdec-gbrap16le => fitsdec-gbrap16be} (79%) rename tests/ref/fate/{fitsdec-gbrp16 => fitsdec-gbrp16be} (79%) diff --git a/tests/fate/fits.mak b/tests/fate/fits.mak index b9e99d97ee..d85946bc1a 100644 --- a/tests/fate/fits.mak +++ b/tests/fate/fits.mak @@ -8,8 +8,8 @@ tests/data/fits-multi.fits: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data # TODO: Use an actual 64bit input file and fix the gbrp16 test on big-endian fits-png-map-gray := gray8 fits-png-map-gbrp := rgb24 -fits-png-map-gbrp16:= rgb48 -fits-png-map-gbrap16le := rgba64 +fits-png-map-gbrp16be := rgb48 +fits-png-map-gbrap16be := rgba64 FATE_FITS_DEC-$(call FRAMECRC, FITS, FITS, SCALE_FILTER) += fate-fitsdec-ext_data_min_max fate-fitsdec-ext_data_min_max: CMD = framecrc -i $(TARGET_SAMPLES)/fits/x0cj010ct_d0h.fit -pix_fmt gray16le -vf scale @@ -30,7 +30,7 @@ fate-fitsdec-multi: CMD = framecrc -i $(TARGET_PATH)/tests/data/fits-multi.fits fate-fitsdec%: PIXFMT = $(word 3, $(subst -, ,$(@))) fate-fitsdec%: CMD = transcode image2 $(TARGET_SAMPLES)/png1/lena-$(fits-png-map-$(PIXFMT)).png fits "-vf scale -pix_fmt $(PIXFMT)" -FATE_FITS_DEC_PIXFMT = gray gbrp gbrp16 gbrap16le +FATE_FITS_DEC_PIXFMT = gray gbrp gbrp16be gbrap16be FATE_FITS_DEC-$(call TRANSCODE, FITS, FITS, IMAGE2_DEMUXER PNG_DECODER SCALE_FILTER) += $(FATE_FITS_DEC_PIXFMT:%=fate-fitsdec-%) FATE_FITS += $(FATE_FITS_DEC-yes) diff --git a/tests/fate/lavf-video.mak b/tests/fate/lavf-video.mak index e73f8f203b..da3b114bc8 100644 --- a/tests/fate/lavf-video.mak +++ b/tests/fate/lavf-video.mak @@ -27,7 +27,7 @@ fate-lavf-gbrp.fits: CMD = lavf_video "-pix_fmt gbrp" fate-lavf-gbrap.fits: CMD = lavf_video "-pix_fmt gbrap" fate-lavf-gbrp16be.fits: CMD = lavf_video "-pix_fmt gbrp16be" fate-lavf-gbrap16be.fits: CMD = lavf_video "-pix_fmt gbrap16be" -fate-lavf-gif: CMD = lavf_video "-pix_fmt rgb24" +fate-lavf-gif: CMD = lavf_video "-pix_fmt rgb8" FATE_AVCONV += $(FATE_LAVF_VIDEO) fate-lavf-video fate-lavf: $(FATE_LAVF_VIDEO) diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak index 2839e54de8..e32d28c556 100644 --- a/tests/fate/vcodec.mak +++ b/tests/fate/vcodec.mak @@ -210,9 +210,9 @@ fate-vsynth%-h263p: ENCOPTS = -qscale 2 -flags +aic -umv 1 -aiv 1 - FATE_VCODEC_SCALE-$(call ENCDEC, HUFFYUV, AVI) += huffyuv huffyuvbgr24 huffyuvbgra fate-vsynth%-huffyuv:ENCOPTS = -c:v huffyuv -pix_fmt yuv422p -sws_flags neighbor fate-vsynth%-huffyuv:DECOPTS = -sws_flags neighbor -fate-vsynth%-huffyuvbgr24: ENCOPTS = -c:v huffyuv -pix_fmt bgr24 -sws_flags neighbor +fate-vsynth%-huffyuvbgr24: ENCOPTS = -c:v huffyuv -pix_fmt rgb24 -sws_flags neighbor fate-vsynth%-huffyuvbgr24: DECOPTS = -sws_flags neighbor -fate-vsynth%-huffyuvbgra:ENCOPTS = -c:v huffyuv -pix_fmt bgr32 -sws_flags neighbor +fate-vsynth%-huffyuvbgra:ENCOPTS = -c:v huffyuv -pix_fmt rgb32 -sws_flags neighbor fate-vsynth%-huffyuvbgra:DECOPTS = -sws_flags neighbor FATE_VCODEC_SCALE-$(call ENCDEC, JPEGLS, AVI) += jpegls diff --git a/tests/ref/fate/fitsdec-gbrap16le b/tests/ref/fate/fitsdec-gbrap16be similarity index 79% rename from tests/ref/fate/fitsdec-gbrap16le rename to tests/ref/fate/fitsdec-gbrap16be index 53ef980b13..1174a0f1d8 100644 --- a/tests/ref/fate/fitsdec-gbrap16le +++ b/tests/ref/fate/fitsdec-gbrap16be @@ -1,5 +1,5 @@ -64526d8da12d1fa07ceea5725647076f *tests/data/fate/fitsdec-gbrap16le.fits -135360 tests/data/fate/fitsdec-gbrap16le.fits +64526d8da12d1fa07ceea5725647076f *tests/data/fate/fitsdec-gbrap16be.fits +135360 tests/data/fate/fitsdec-gbrap16be.fits #tb 0: 1/1 #media_type 0: video #codec_id 0: rawvideo diff --git a/tests/ref/fate/fitsdec-gbrp16 b/tests/ref/fate/fitsdec-gbrp16be similarity index 79% rename from tests/ref/fate/fitsdec-gbrp16 rename to tests/ref/fate/fitsdec-gbrp16be index 9250690e9b..ff4ca9e65c 100644 --- a/tests/ref/fate/fitsdec-gbrp16 +++ b/tests/ref/fate/fitsdec-gbrp16be @@ -1,5 +1,5 @@ -2078208c93ba417d3fe150ba42bf5a30 *tests/data/fate/fitsdec-gbrp16.fits -103680 tests/data/fate/fitsdec-gbrp16.fits +2078208c93ba417d3fe150ba42bf5a30 *tests/data/fate/fitsdec-gbrp16be.fits +103680 tests/data/fate/fitsdec-gbrp16be.fits #tb 0: 1/1 #media_type 0: video #codec_id 0: rawvideo diff --git a/tests/ref/lavf/gif b/tests/ref/lavf/gif index fc94b9df3d..7f353df286 100644 --- a/tests/ref/lavf/gif +++ b/tests/ref/lavf/gif @@ -1,3 +1,3 @@ e35f5ea283bbcb249818e0078ec72664 *tests/data/lavf/lavf.gif 2011766 tests/data/lavf/lavf.gif
[FFmpeg-devel] [PATCH 01/47] fftools/ffmpeg_mux_init: handle pixel format endianness
When -pix_fmt designates a BE/LE pixel format, it gets translated into the native one by av_get_pix_fmt(). This may not always be the best choice, as the encoder might only support one endianness. In such a case, explicitly choose the endianness supported by the encoder. While this is currently redundant with choose_pixel_fmt() in ffmpeg_filter.c, the latter code will be deprecated in following commits. --- fftools/ffmpeg_mux_init.c | 55 --- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index 6458414b5f..2d45fa7c7c 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -495,6 +495,54 @@ static int parse_matrix_coeffs(void *logctx, uint16_t *dest, const char *str) return 0; } +static int fmt_in_list(const int *formats, int format) +{ +for (; *formats != -1; formats++) +if (*formats == format) +return 1; +return 0; +} + +static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name) +{ +const enum AVPixelFormat *fmts = ost->enc_ctx->codec->pix_fmts; +enum AVPixelFormat fmt; + +fmt = av_get_pix_fmt(name); +if (fmt == AV_PIX_FMT_NONE) { +av_log(ost, AV_LOG_FATAL, "Unknown pixel format requested: %s.\n", name); +return AV_PIX_FMT_NONE; +} + +/* when the user specified-format is an alias for an endianness-specific + * one (e.g. rgb48 -> rgb48be/le), it gets translated into the native + * endianness by av_get_pix_fmt(); + * the following code handles the case when the native endianness is not + * supported by the encoder, but the other one is */ +if (fmts && !fmt_in_list(fmts, fmt)) { +const char *name_canonical = av_get_pix_fmt_name(fmt); +int len = strlen(name_canonical); + +if (strcmp(name, name_canonical) && +(!strcmp(name_canonical + len - 2, "le") || + !strcmp(name_canonical + len - 2, "be"))) { +char name_other[64]; +enum AVPixelFormat fmt_other; + +snprintf(name_other, sizeof(name_other), "%s%ce", + name, name_canonical[len - 2] == 'l' ? 'b' : 'l'); +fmt_other = av_get_pix_fmt(name_other); +if (fmt_other != AV_PIX_FMT_NONE && fmt_in_list(fmts, fmt_other)) { +av_log(ost, AV_LOG_VERBOSE, "Mapping pixel format %s->%s\n", + name, name_other); +fmt = fmt_other; +} +} +} + +return fmt; +} + static int new_stream_video(Muxer *mux, const OptionsContext *o, OutputStream *ost) { @@ -558,9 +606,10 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o, if (!*++frame_pix_fmt) frame_pix_fmt = NULL; } -if (frame_pix_fmt && (video_enc->pix_fmt = av_get_pix_fmt(frame_pix_fmt)) == AV_PIX_FMT_NONE) { -av_log(ost, AV_LOG_FATAL, "Unknown pixel format requested: %s.\n", frame_pix_fmt); -return AVERROR(EINVAL); +if (frame_pix_fmt) { +video_enc->pix_fmt = pix_fmt_parse(ost, frame_pix_fmt); +if (video_enc->pix_fmt == AV_PIX_FMT_NONE) +return AVERROR(EINVAL); } MATCH_PER_STREAM_OPT(intra_matrices, str, intra_matrix, oc, st); -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avcodec: add ambient viewing environment packet side data.
On Tue, Jul 11, 2023 at 6:45 PM Anton Khirnov wrote: > A FATE test would be much appreciated. > Is there some documentation on how to write a FATE test? I've got a small sample (2 bytes) ready, but I am not too sure how to write the test. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] avformat/mov: add support for 'amve' ambient viewing environment box. As defined in ISOBMFF (ISO/IEC 14496-12) document.
On Tue, Jul 11, 2023 at 6:53 PM James Almer wrote: > On 7/11/2023 4:41 AM, Damiano Galassi wrote: > > AVDictionaryEntry *encoder; > > @@ -2430,6 +2451,7 @@ static int mov_write_video_tag(AVFormatContext *s, > AVIOContext *pb, MOVMuxContex > > if (track->mode == MODE_MOV || track->mode == MODE_MP4) { > > Is it allowed in mov? > Yes, it’s currently used on movie recorded on recent iOS versions: https://developer.apple.com/documentation/technotes/tn3145-hdr-video-metadata ___ 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 0/3] avcodec: move HDR10 (MDCV/CLL) SEI handling to h2645_sei
On Wed, Jul 12, 2023 at 9:33 PM Jan Ekström wrote: > > This allows parsing code to be re-utilized from H.264, as well as probably > from VVC in the future. > > This additionally eases verification of the AVCodecContext side data patch > set, which includes libx264 integration for HDR10 side data. > > Notes: > * At least in ffprobe and FATE tests the code works even without the > additional > sync in "update_thread_context" in either HEVC or H.264 (as the viewing > environment SEI patch set showed earlier). As the current HEVC code had such > sync, I kept it and added a similar thing to the H.264 decoder. > ** If this is required for all things, the sync should possibly be added to >ff_h2645_sei_ctx_replace? As currently both the HEVC and H.264 decoders are >synchronizing various structs by themselves in addition to calling >ctx_replace. > * I did not add a simlar decrementing logic to the H.264 decoder for now, > as not sure how it should be handled exactly. > > Jan Ping for the set. Jan ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 25/33] fftools/ffmpeg_filter: stop disregarding user-specified pixel format
On Fri, Jul 14, 2023 at 7:06 PM Anton Khirnov wrote: > Quoting Michael Niedermayer (2023-07-14 17:47:19) > > On Fri, Jul 14, 2023 at 11:44:07AM +0200, Anton Khirnov wrote: > > > Quoting Michael Niedermayer (2023-07-14 01:11:07) > > > > On Thu, Jul 13, 2023 at 12:55:45PM +0200, Anton Khirnov wrote: > > > > > When the user explicitly specifies a pixel format that is not > supported > > > > > by the encoder, ffmpeg CLI will currently use some heuristics to > pick > > > > > another supported format. This is wrong and the correct action > here is > > > > > to fail. > > > > > > > > > > Surprisingly, a number of FATE tests are affected by this and > actually > > > > > use a different pixel format than is specified in the makefiles. > > > > > --- > > > > > doc/ffmpeg.texi | 3 +- > > > > > fftools/ffmpeg_filter.c | 35 > +-- > > > > > tests/fate/fits.mak | 6 ++-- > > > > > tests/fate/lavf-video.mak | 2 +- > > > > > tests/fate/vcodec.mak | 4 +-- > > > > > .../{fitsdec-gbrap16le => fitsdec-gbrap16be} | 4 +-- > > > > > .../fate/{fitsdec-gbrp16 => fitsdec-gbrp16be} | 4 +-- > > > > > tests/ref/lavf/gif| 2 +- > > > > > 8 files changed, 13 insertions(+), 47 deletions(-) > > > > > rename tests/ref/fate/{fitsdec-gbrap16le => fitsdec-gbrap16be} > (79%) > > > > > rename tests/ref/fate/{fitsdec-gbrp16 => fitsdec-gbrp16be} (79%) > > > > > > > > > > diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi > > > > > index 6769f8d305..08b11097b7 100644 > > > > > --- a/doc/ffmpeg.texi > > > > > +++ b/doc/ffmpeg.texi > > > > > @@ -1014,8 +1014,7 @@ Disable autoscale at your own risk. > > > > > @item -pix_fmt[:@var{stream_specifier}] @var{format} > (@emph{input/output,per-stream}) > > > > > Set pixel format. Use @code{-pix_fmts} to show all the supported > > > > > pixel formats. > > > > > -If the selected pixel format can not be selected, ffmpeg will > print a > > > > > -warning and select the best pixel format supported by the encoder. > > > > > + > > > > > If @var{pix_fmt} is prefixed by a @code{+}, ffmpeg will exit with > an error > > > > > if the requested pixel format can not be selected, and automatic > conversions > > > > > inside filtergraphs are disabled. > > > > > > > > The commit message makes this sound like a bugfix, while really this > is > > > > removing a documented feature. > > > > > > It is a bugfix in my eyes. When you explicitly tell a program to > perform > > > a specific action, and the program just decides to do something else, > > > then that program is broken. > > > > > > As far as I can tell, this "feature" was added by you in 89f86379797 > > > with no explanation or documentation beyond 'fix regression with png'. > > > It was later documented in a largely-unrelated commit that added > > > something else. > > > > > > I see no argument whatsoever for why we should have such a "smart" > > > > As said previously, > > The user cannot be expected to know if a implementation uses planar > > or packed rgb, bgr or rgb. > > Which is why > * libavfilter will by default convert to a format supported by the > encoder > * libavcodec will now helpfully print a list of formats supported by the > encoder if the caller gives it a wrong one > > > This is not a inherent part of the file/stream/input in many cases > > its not a problem for you because you are a FFmpeg developer and work > > with this every day but it is a inconvenience for users > > Should we then replace any failing commandline with something that will > not fail? Ignore any options with incorrect values? All in the name of > convenience? Maybe you should try web development. > > Programs that try to second-guess user's explicit instructions are > broken by design. This "convenience" argument is entirely specious: > * users who do not know what they want get something that works by > default > * users who specify a wrong format get a list of correct formats they > can just pick from; that is as convenient as it gets for this kind of > a program > * users who require yet more convenience and/or handholding can use a > graphical program such as Handbrake; we should not try to be > Handbrake, they are better at it than us > > > > > To me as a lazy person it surely feels usefull to be able to ask for > > > > both "exactly rgb" as well as something close to rgb (like bgr or > gbrp) > > > > without needing to know what each individual codec uses to return > R,G,B > > > > > > > > 1) This code does not give you the ability to specify "something close > to rgb". > > >You specify a precise pixel format, and this code gives you > > >something. That something might be what you asked for, or something > > >close to it, or something completely unrelated. > > >E.g. > > > ffmpeg -i in.mkv -map 0:v -c:v libx264 -pix_fmt pal8 -t 1 out.mkv > > >produces
Re: [FFmpeg-devel] [PATCH 4/7] checkasm: use pointers for start/stop functions
Le lauantaina 15. heinäkuuta 2023, 11.05.51 EEST Lynne a écrit : > Jul 14, 2023, 20:29 by r...@remlab.net: > > This makes all calls to the bench start and stop functions via > > function pointers. While the primary goal is to support run-time > > selection of the performance measurement back-end in later commits, > > this has the side benefit of containing platform dependencies in to > > checkasm.c and out of checkasm.h. > > --- > > > > tests/checkasm/checkasm.c | 33 - > > tests/checkasm/checkasm.h | 31 --- > > 2 files changed, 32 insertions(+), 32 deletions(-) > > Not sure I agree with this commit, the overhead can be detectable, > and we have a lot of small functions with runtime a few times that > of a null function call. I don't think the function call is ever null. The pointers are left NULL only if none of the backend initialise. But then, checkasm will bail out and exit before we try to benchmark anything anyway. As for the real functions, they always do *something*. None of them "just return 0". > Can you store the function pointers out of the loop to reduce > the derefs needed? Taking just the two loads is out of the loop should be feasible but it seems a rather vain. You will still have the overhead of the indirect function call, the function, and most importantly in the case of Linux perf and MacOS kperf, the system calls. The only way to avoid the indirect function calls are to use IFUNC (tricky and not portable), or to make horrible macros to spawn one bench loop for each backend. In the end, I think we should rather aim for as constant time as possible, rather than as fast as possible, so that the nop loop can estimate the benchmarking overhead as well as possible. In this respect, I think it is actually marginally better *not* to cache the function pointers in local variables, which could end up spilled on the stack, or not, depending on local compiler optimisations for any given test case. -- 雷米‧德尼-库尔蒙 http://www.remlab.net/ ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/7] checkasm: use pointers for start/stop functions
Jul 14, 2023, 20:29 by r...@remlab.net: > This makes all calls to the bench start and stop functions via > function pointers. While the primary goal is to support run-time > selection of the performance measurement back-end in later commits, > this has the side benefit of containing platform dependencies in to > checkasm.c and out of checkasm.h. > --- > tests/checkasm/checkasm.c | 33 - > tests/checkasm/checkasm.h | 31 --- > 2 files changed, 32 insertions(+), 32 deletions(-) > Not sure I agree with this commit, the overhead can be detectable, and we have a lot of small functions with runtime a few times that of a null function call. Can you store the function pointers out of the loop to reduce the derefs needed? ___ 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".