Re: [FFmpeg-devel] [PATCH 3/3] avfilter/vf_convolution: add X86 SIMD for filter_column()
Hi, chen - 原始邮件 - > 发件人: "chen" > 收件人: "FFmpeg development discussions and patches" > 发送时间: 星期二, 2019年 12 月 03日 下午 4:59:06 > 主题: Re: [FFmpeg-devel] [PATCH 3/3] avfilter/vf_convolution: add X86 SIMD for > filter_column() > comments inline in code > > > At 2019-12-03 15:52:07, xuju...@sjtu.edu.cn wrote: >>From: Xu Jun >> >>+; void filter_column(uint8_t *dst, int height, >>+; float rdiv, float bias, const int *const matrix, >>+; const uint8_t *c[], int length, int radius, >>+; int dstride, int stride); >>+ >>+%if ARCH_X86_64 >>+INIT_XMM sse4 >>+%if UNIX64 >>+cglobal filter_column, 8, 15, 7, dst, height, matrix, ptr, width, rad, >>dstride, >>stride, i, ci, dst_off, off16, c_off, sum, r >>+%else >>+cglobal filter_column, 8, 15, 7, dst, height, rdiv, bias, matrix, ptr, width, >>rad, dstride, stride, i, ci, dst_off, off16, c_off, sum, r > >>+%endif > no idea, these are difficult to read and understand I will rename some variables to make it more readable. Do I need to add some notes here? > > > > >>+ >>+%if WIN64 >>+SWAP m0, m2 >>+SWAP m1, m3 >>+mov r2q, matrixmp >>+mov r3q, ptrmp >>+mov r4q, widthmp >>+mov r5q, radmp >>+mov r6q, dstridemp >>+mov r7q, stridemp >>+DEFINE_ARGS dst, height, matrix, ptr, width, rad, dstride, stride, i, ci, >>dst_off, off16, c_off, sum, r >>+%endif >>+ >>+movsxdifnidn widthq, widthd >>+movsxdifnidn radq, radd >>+movsxdifnidn dstrideq, dstrided >>+movsxdifnidn strideq, strided >>+sal radq, 1 > >>+add radq, 1 ;2*radius+1 > I don't know how about compare to "LEA x,[y*2+1]" > AndI want not discuss in between SAL and SHL > I think lea is better and I will change in the next version. > >>+movsxdifnidn heightq, heightd >>+VBROADCASTSS m0, m0 >>+VBROADCASTSS m1, m1 >>+pxor m6, m6 >>+movss m5, [half] >>+VBROADCASTSS m5, m5 >>+ >>+xor dst_offq, dst_offq >>+xor c_offq, c_offq >>+ >>+.loopy: >>+xor off16q, off16q >>+cmp widthq, mmsize/4 >>+jl .loopr >>+ >>+mov rq, widthq >>+and rq, mmsize/4-1 >>+sub widthq, rq >>+ > >>+.loop16: ;parallel process 16 elements in a row > Processing 4 column per loop, are you means, we want to save lots of unused > register? > We claim X64, so we have 16 of XMMs Will use more XMMs and process 16 column at a time. > > >>+pxor m4, m4 >>+xor iq, iq >>+.loopi: > >>+movss m2, [matrixq + 4*iq] > no idea that you working on Float data path, we are lucky, Intel CPU sounds > not > penalty in here. Will change to Interger data path using movd. And movd seems to have less CPI than movss. > > >>+VBROADCASTSS m2, m2 >>+mov ciq, [ptrq + iq * gprsize] >>+movss m3, [ciq + c_offq] ;c[i][y*stride + off16] >>+punpcklbw m3, m6 > >>+punpcklwd m3, m6 > Since you claim SSE4, the instruction PMOVZXBD available, moreover, SSE4 > register can be full fill 16 of uint8, but load 4 of them only. I thought that since I would multiply 4 ints, loading 4 uint8s per loop is OK. Now I know that read 16 uint8s and shuffle them is faster. Will change in next version. > >>+pmulld m2, m3 >>+paddd m4, m2 >>+ >>+add iq, 1 > >>+cmp iq, radq > When you initial iq to radq and decrement per loop, you can reduce one > instruction > I know iq is work as index in the loop, but we can found some trick over > there. Will change in next V. >>+jl .loopi >>+ >>+cvtdq2ps m4, m4 >>+mulps m4, m0 ; sum *= rdiv >>+addps m4, m1 ; sum += bias > >>+addps m4, m5 ; sum += 0.5 > I don't know how about precision mismatch if we pre-compute (bias+0.5) Here may not be modified after discussions. > > >>+cvttps2dq m4, m4 >>+packssdw m4, m4 >>+packuswb m4, m4 >>+movss [dstq + dst_offq], m4 >>+add c_offq, mmsize/4 >>+add dst_offq, mmsize/4 >>+ >>+add off16q, mmsize/4 >>+cmp off16q, widthq >>+jl .loop16 >>+ >>+add widthq, rq >>+cmp off16q, widthq >>+jge .paraend >>+ > >>+.loopr: > no idea about this loop, if we can read beyond, we can reuse above SIMD code Here may not be modified too. Xu Jun > > >>+xor sumd, sumd >>+xor iq, iq >>+.loopr_i: >>+mov ciq, [ptrq + iq * gprsize] >>+movzx rd, byte [ciq + c_offq] >>+imul rd, [matrixq + 4*iq] >>+add sumd, rd >>+ >>+add iq, 1 >>+cmp iq, radq >>+jl .loopr_i >>+ >>+pxor m4, m4 >>+cvtsi2ss m4, sumd >>+mulss m4, m0 ; sum *= rdiv >>+addss m4, m1 ; sum += bias >>+addss m4, m5 ; sum += 0.5 >>+cvttps2dq m4, m4 >>+packssdw m4, m4 >>+packuswb m4, m4 >>+movd sumd, m4 >>+mov [dstq + dst_offq], sumb >>+add c_offq, 1 >>+
Re: [FFmpeg-devel] [PATCH 6/8] avformat/matroskadec: Remove unnecessary check
On 12/3/2019 2:09 PM, Andreas Rheinhardt wrote: > 870e7552 introduced validating the lace sizes when they are parsed and > removed the old check; yet when merging this libav commit in 6902c3ac, > the old check for whether the frame extends beyond the frame has been kept. > It is unnecessary and has been removed. > > Signed-off-by: Andreas Rheinhardt > --- > Same as https://ffmpeg.org/pipermail/ffmpeg-devel/2019-August/248369.html > > libavformat/matroskadec.c | 13 +++-- > 1 file changed, 3 insertions(+), 10 deletions(-) Added a xiph lacing test (since unlike ebml and fixed lacing, it was currently untested) and pushed the whole set. Thanks. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] libswscale/swscale_unscaled.c: remove redundant code
Signed-off-by: Ting Fu --- libswscale/swscale_unscaled.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c index d9260c151a..0d109da2d7 100644 --- a/libswscale/swscale_unscaled.c +++ b/libswscale/swscale_unscaled.c @@ -2032,7 +2032,6 @@ void ff_get_unscaled_swscale(SwsContext *c) IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BAYER_GRBG16) || IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR444) || IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR48) || -IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGRA64) || IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR555) || IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR565) || IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGRA64) || @@ -2053,7 +2052,6 @@ void ff_get_unscaled_swscale(SwsContext *c) IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GBRAP16) || IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB444) || IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB48) || -IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGBA64) || IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB555) || IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB565) || IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGBA64) || -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [aarch64] improve performance of ff_hscale_8_to_15_neon
Hi Clément, please find attached the updated patch addressing all your comments. Let me know if there is anything else that I missed and that I need to address. Thanks, Sebastian On Sun, Dec 1, 2019 at 3:01 PM Martin Storsjö wrote: > > On Sun, 1 Dec 2019, Clément Bœsch wrote: > > > On Wed, Nov 27, 2019 at 12:30:35PM -0600, Sebastian Pop wrote: > > [...] > >> From 9ecaa99fab4b8bedf3884344774162636eaa5389 Mon Sep 17 00:00:00 2001 > >> From: Sebastian Pop > >> Date: Sun, 17 Nov 2019 14:13:13 -0600 > >> Subject: [PATCH] [aarch64] use FMA and increase vector factor to 4 > >> > >> This patch implements ff_hscale_8_to_15_neon with NEON fused multiply > >> accumulate > >> and bumps the vectorization factor from 2 to 4. > >> The speedup is of 34% on Graviton A1 instances based on A-72 cpus: > >> > >> $ ffmpeg -nostats -f lavfi -i testsrc2=4k:d=2 -vf > >> bench=start,scale=1024x1024,bench=stop -f null - > >> before: t:0.040303 avg:0.040287 max:0.040371 min:0.039214 > >> after: t:0.030079 avg:0.030102 max:0.030462 min:0.030051 > >> > >> Tested with `make check` on aarch64-linux. > > FWIW, I'm not certain how much this routine actually is tested by that - > in particular, there's no checkasm test for it as far as I can see. > > >> +add x17, x3, x18// srcp + > >> filterPos[0] > >> +add x18, x3, x0 // srcp + > >> filterPos[1] > >> +add x0, x3, x2 // srcp + > >> filterPos[2] > >> +add x2, x3, x6 // srcp + > >> filterPos[3] > > > >> +2: ldr d4, [x17, x15] // > >> srcp[filterPos[0] + {0..7}] > >> +ldr q5, [x16] // load 8x16-bit > >> filter values, part 1 > >> +ldr d6, [x18, x15] // > >> srcp[filterPos[1] + {0..7}] > >> +ldr q7, [x16, x12] // load 8x16-bit > >> at filter+filterSize > > > > Why not use ld1 {v4.8B} etc like it was before? The use of Dn/Qn in is > > very confusing here. > > The ldr instruction, instead of ld1, allows you to to do a load (or store, > similarly, for str instead of st1) with a constant/register offset, like > [x17, x15] here, without incrementing the source register inbetween for > each load (which can help with latency between individual load > instructions, or can avoid extra instructions for incrementing the > register inbetween). > > That works for loading the first 1/2/4/8/16 bytes of a vector, but can't > be used e.g. for loading a lane other than the first (e.g. ld1 {v4.s}[1]). > But it does require using the b/h/s/d/q names for the registers instead of > v. > > I didn't check the changes here if they're essential for the optimization > though. > > // Martin > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". 0001-aarch64-use-FMA-and-increase-vector-factor-to-4.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@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] Next developer meeting...
Hello Folks, Following the previous discussions, and the decisions taken during the last IRL meeting, summarized here: https://ffmpeg.org/pipermail/ffmpeg-devel/2019-November/253153.html we will do our next meeting, Monday 9 December 2019, at 17:00 Berlin/Paris/Brussels time. The time is selected so that people in China and in South America can join us. It will be online, with live comments/discussion on IRC. Topics are going to be the decisions, the committees and the next meetings :) Stay tuned for more info... -- Jean-Baptiste Kempf - President +33 672 704 734 ___ ffmpeg-devel mailing list ffmpeg-devel@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] avdevice/xcbgrab: Improve non-shm performance
On Wed, 4 Dec 2019, Kusanagi Kouichi wrote: On 2019-12-03 21:25:37 +0100, Marton Balint wrote: On Tue, 3 Dec 2019, Kusanagi Kouichi wrote: > On 2019-11-19 22:59:56 +0900, Kusanagi Kouichi wrote: > > Use AVBufferPool. You don't need a buffer pool for the non-shm case, you should wrap the XCB data in a buffer ref instead. I will reply with a patch that shows how it is done, please check if it works correctly, as I am not 100% sure how xcb data structures should be allocated/freed. Is it safe to omit AV_INPUT_BUFFER_PADDING_SIZE bytes padding? My first version is identical to yours. Valgrind reported no error. But I'm not sure. Strictly speaking it is against the API, but the performance gains IMHO are too big to respect the API requirement blindly. Also I see little chance that it will cause issues, because typically avcodec/rawdec.c will simply reassign the buffer ref to an AVFrame and keep the data untouched. And AVFrame data does not have this requirement. If something breaks, we can always reconsider this or find another solution. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 5/5] lavc/libxavs2.c: optimize error descriptions
On Tue, Dec 03, 2019 at 10:41:26AM +0800, hwren wrote: > Signed-off-by: hwren > --- > libavcodec/libxavs2.c | 12 ++-- > 1 file changed, 6 insertions(+), 6 deletions(-) will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB While the State exists there can be no freedom; when there is freedom there will be no State. -- Vladimir Lenin signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 3/5] lavc/libxavs2.c: fix code style - spaces
On Tue, Dec 03, 2019 at 10:41:24AM +0800, hwren wrote: > Signed-off-by: hwren > --- > libavcodec/libxavs2.c | 13 + > 1 file changed, 5 insertions(+), 8 deletions(-) will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Rewriting code that is poorly written but fully understood is good. Rewriting code that one doesnt understand is a sign that one is less smart then the original author, trying to rewrite it will not make it better. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 2/5] lavc/libxavs2.c: avoid recomputations of pointers in xavs2_copy_frame* functions
On Tue, Dec 03, 2019 at 10:41:23AM +0800, hwren wrote: > Signed-off-by: hwren > --- > libavcodec/libxavs2.c | 32 +++- > 1 file changed, 23 insertions(+), 9 deletions(-) will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 1/5] lavc/libxavs2.c: use more descriptive variable names in xavs2_copy_frame* functions
On Tue, Dec 03, 2019 at 10:41:22AM +0800, hwren wrote: > Signed-off-by: hwren > --- > libavcodec/libxavs2.c | 29 ++--- > 1 file changed, 14 insertions(+), 15 deletions(-) will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The smallest minority on earth is the individual. Those who deny individual rights cannot claim to be defenders of minorities. - Ayn Rand signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 1/3] avfilter/vf_elbg: Fix for the seed type
On Fri, Nov 22, 2019 at 09:50:36AM +0800, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavfilter/vf_elbg.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have never wished to cater to the crowd; for what I know they do not approve, and what they approve I do not know. -- Epicurus signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/rmdec: Use av_packet_move_ref() for packet ownership transfer
On Tue, Dec 03, 2019 at 11:28:07AM +0100, Andreas Rheinhardt wrote: > Signed-off-by: Andreas Rheinhardt > --- > libavformat/rmdec.c | 5 + > 1 file changed, 1 insertion(+), 4 deletions(-) will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Into a blind darkness they enter who follow after the Ignorance, they as if into a greater darkness enter who devote themselves to the Knowledge alone. -- Isha Upanishad 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 V1 2/2] lavfi/avf_showspectrum: Fix the memory leak in error handle path
On Tue, Dec 03, 2019 at 07:01:00PM +0800, Jun Zhao wrote: > From: Jun Zhao > > Fix the memory leak in error handle path. > > Signed-off-by: Jun Zhao > --- > libavfilter/avf_showspectrum.c |5 ++--- > 1 files changed, 2 insertions(+), 3 deletions(-) probably ok, iam not maintainer of this file though thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I know you won't believe me, but the highest form of Human Excellence is to question oneself and others. -- Socrates 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 v3] avformat/matroskaenc: Use random TrackUID
On Tue, Dec 03, 2019 at 04:19:47PM +0100, Andreas Rheinhardt wrote: > Up until now, the TrackUID of a Matroska track which is supposed to be > random was not random at all: It always coincided with the TrackNumber > which is usually the 1-based index of the corresponding stream in the > array of AVStreams. This has been changed: It is now set via an AVLFG > if AVFMT_FLAG_BITEXACT is not set. Otherwise it is set like it is set > now (the only change happens if an explicit track number has been > chosen via dash_track_number, because the system used in the normal > situation is now used, too). In particular, no FATE tests need to be > updated. > > This also fixes a bug in case the dash_track_number option was used: > In this case the TrackUID was set to the track number, but the tags were > written with a TagTrackUID simply based upon the index, so that the tags > didn't apply to the track they ought to apply to. LGTM thx > > Signed-off-by: Andreas Rheinhardt > --- > I have updated the patchset to rely on the AVLFG to provide sufficiently > many distinct values, as you said. I could add a check and a for if we still > have a collision after (say) 1000 tries in order to avoid the > potentially infinite loop. You could replace the LFG if you dont trust it. But i dont understand why you would use it when you dont trust it and then add a check Thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User questions about the command line tools should be sent to the ffmpeg-user ML. And questions about how to use libav* should be sent to the libav-user ML. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2] avcodec/v4l2_m2m_enc: Check encoder pix_fmt matches pix_fmt on device
On Sat, 23. Nov 06:18, Andriy Gelman wrote: > On Tue, 12. Nov 22:46, Andriy Gelman wrote: > > From: Andriy Gelman > > > > Fixes #8079 > > > > During initialization of a v4l2m2m device, the configured pix_fmt can be > > different to the pix_fmt of the encoder (i.e. avctx->pix_fmt). > > > > For example on the Odroid XU4: > > ./ffmpeg -f lavfi -i yuvtestsrc -codec:v h264_v4l2m2m out.h264 > > > > will configure the v4l2 encoder to pix_fmt nv21, whereas the input > > frames will be yuv444p. > > > > This commit checks that the configured v4l2 pix_fmt on device is the > > same as avctx->pix_fmt. If they are different the initialization fails > > and an error is returned. Tested on RPI4 and Odroid XU4. > > > > Signed-off-by: Andriy Gelman > > --- > > libavcodec/v4l2_m2m_enc.c | 15 +++ > > 1 file changed, 15 insertions(+) > > > > diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c > > index 474e6bef897..c0e82afe354 100644 > > --- a/libavcodec/v4l2_m2m_enc.c > > +++ b/libavcodec/v4l2_m2m_enc.c > > @@ -30,6 +30,7 @@ > > #include "libavutil/opt.h" > > #include "v4l2_context.h" > > #include "v4l2_m2m.h" > > +#include "v4l2_fmt.h" > > > > #define MPEG_CID(x) V4L2_CID_MPEG_VIDEO_##x > > #define MPEG_VIDEO(x) V4L2_MPEG_VIDEO_##x > > @@ -288,6 +289,8 @@ static av_cold int v4l2_encode_init(AVCodecContext > > *avctx) > > V4L2Context *capture, *output; > > V4L2m2mContext *s; > > V4L2m2mPriv *priv = avctx->priv_data; > > +enum AVPixelFormat pix_fmt_output; > > +uint32_t v4l2_fmt_output; > > int ret; > > > > ret = ff_v4l2_m2m_create_context(priv, ); > > @@ -316,6 +319,18 @@ static av_cold int v4l2_encode_init(AVCodecContext > > *avctx) > > } > > s->avctx = avctx; > > > > +if (V4L2_TYPE_IS_MULTIPLANAR(output->type)) > > +v4l2_fmt_output = output->format.fmt.pix_mp.pixelformat; > > +else > > +v4l2_fmt_output = output->format.fmt.pix.pixelformat; > > + > > +pix_fmt_output = ff_v4l2_format_v4l2_to_avfmt(v4l2_fmt_output, > > AV_CODEC_ID_RAWVIDEO); > > +if (pix_fmt_output != avctx->pix_fmt) { > > +const AVPixFmtDescriptor *desc = > > av_pix_fmt_desc_get(pix_fmt_output); > > +av_log(priv, AV_LOG_ERROR, "Encoder requires %s pixel format.\n", > > desc->name); > > +return AVERROR(EINVAL); > > +} > > + > > return v4l2_prepare_encoder(s); > > } > > > > -- > > 2.23.0 > > > > ping > The underlying issue is that supported .pix_fmts may vary for different v4l2m2m devices. Ideally, if .pix_fmts could be set at runtime that would solve problem. I did see that libx264 sets .pix_fmts via .init_static_data function. But I don't think we want to call this v4l2m2m initialization each time avcodec_register() is called. Perhaps figuring out supported .pix_fmts via configure, and then creating a define symbol for the supported option? Anyone have suggestions? -- Andriy ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v1 1/2] avformat/libsrt: change tlpktdrop, nakreport, messageapi options to boolean type
ping the very old patch, please review and push it. On Fri, Sep 20, 2019 at 07:17:27PM +0800, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavformat/libsrt.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c > index b5568089fa..2fc6328c4e 100644 > --- a/libavformat/libsrt.c > +++ b/libavformat/libsrt.c > @@ -111,8 +111,8 @@ static const AVOption libsrt_options[] = { > { "tsbpddelay", "deprecated, same effect as latency option", >OFFSET(latency), AV_OPT_TYPE_INT64, { .i64 = -1 > }, -1, INT64_MAX, .flags = D|E }, > { "rcvlatency", "receive latency", >OFFSET(rcvlatency), AV_OPT_TYPE_INT64, { .i64 = -1 > }, -1, INT64_MAX, .flags = D|E }, > { "peerlatency","peer latency", >OFFSET(peerlatency), AV_OPT_TYPE_INT64, { .i64 = -1 > }, -1, INT64_MAX, .flags = D|E }, > -{ "tlpktdrop", "Enable receiver pkt drop", >OFFSET(tlpktdrop),AV_OPT_TYPE_INT, { .i64 = > -1 }, -1, 1, .flags = D|E }, > -{ "nakreport", "Enable receiver to send periodic NAK reports", >OFFSET(nakreport),AV_OPT_TYPE_INT, { .i64 = > -1 }, -1, 1, .flags = D|E }, > +{ "tlpktdrop", "Enable receiver pkt drop", >OFFSET(tlpktdrop),AV_OPT_TYPE_BOOL, { .i64 = > -1 }, -1, 1, .flags = D|E }, > +{ "nakreport", "Enable receiver to send periodic NAK reports", >OFFSET(nakreport),AV_OPT_TYPE_BOOL, { .i64 = > -1 }, -1, 1, .flags = D|E }, > { "connect_timeout", "Connect timeout. Caller default: 3000, rendezvous > (x 10)",OFFSET(connect_timeout), AV_OPT_TYPE_INT64, { .i64 = -1 > }, -1, INT64_MAX, .flags = D|E }, > { "mode", "Connection mode (caller, listener, rendezvous)", >OFFSET(mode), AV_OPT_TYPE_INT, { .i64 = > SRT_MODE_CALLER }, SRT_MODE_CALLER, SRT_MODE_RENDEZVOUS, .flags = D|E, "mode" > }, > { "caller", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = > SRT_MODE_CALLER }, INT_MIN, INT_MAX, .flags = D|E, "mode" }, > @@ -124,7 +124,7 @@ static const AVOption libsrt_options[] = { > { "minversion", "The minimum SRT version that is required from the > peer", OFFSET(minversion), AV_OPT_TYPE_INT, { .i64 = > -1 }, -1, INT_MAX, .flags = D|E }, > { "streamid", "A string of up to 512 characters that an Initiator > can pass to a Responder", OFFSET(streamid), AV_OPT_TYPE_STRING, { .str = > NULL }, .flags = D|E }, > { "smoother", "The type of Smoother used for the transmission for > that socket", OFFSET(smoother), AV_OPT_TYPE_STRING, { .str = > NULL }, .flags = D|E }, > -{ "messageapi", "Enable message API", >OFFSET(messageapi), AV_OPT_TYPE_INT, { .i64 = > -1 }, -1, 1, .flags = D|E }, > +{ "messageapi", "Enable message API", >OFFSET(messageapi), AV_OPT_TYPE_BOOL, { .i64 = > -1 }, -1, 1, .flags = D|E }, > { "transtype", "The transmission type for the socket", >OFFSET(transtype),AV_OPT_TYPE_INT, { .i64 = > SRTT_INVALID }, SRTT_LIVE, SRTT_INVALID, .flags = D|E, "transtype" }, > { "live", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SRTT_LIVE }, > INT_MIN, INT_MAX, .flags = D|E, "transtype" }, > { "file", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SRTT_FILE }, > INT_MIN, INT_MAX, .flags = D|E, "transtype" }, > -- > 2.21.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] lavc/x265: set preferred_transfer_characteristics for HLG
"HEVC HDR UHDTV Bitstreams using HLG10 shall also contain the alternative_transfer_characteristics SEI message. The alternative_transfer_characteristics SEI message shall be inserted on the HEVC DVB_RAP, and preferred_transfer_characteristics shall be set equal to "18", indicating Recommendation ITU-R BT. 2100 [45] HLG system." Signed-off-by: Zhong Li --- libavcodec/libx265.c | 4 1 file changed, 4 insertions(+) diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 4e75077..963c28f 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -159,6 +159,10 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx) // x265 validates the parameters internally ctx->params->vui.colorPrimaries = avctx->color_primaries; ctx->params->vui.transferCharacteristics = avctx->color_trc; +#if X265_BUILD >= 159 +if (avctx->color_trc == AVCOL_TRC_ARIB_STD_B67) +ctx->params->preferredTransferCharacteristics = ctx->params->vui.transferCharacteristics; +#endif ctx->params->vui.matrixCoeffs= avctx->colorspace; } -- 1.8.3.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] lavc/qsvenc: Add support for 4:4:4 8/10 bit HEVC REXT encoding
Enables HEVC Range Extension encoding support for 4:4:4 8/10 bit on ICL(gen11 +) platform with VDENC(low power mode). CMD: ffmpeg -hwaccel qsv -init_hw_device qsv=hw -filter_hw_device hw -f rawvideo -video_size 1920x1080 -pix_fmt 0yuv -i ./0yuv.yuv -vf hwupload=extra_hw_frames=64,format=qsv -c:v hevc_qsv -profile rext -level 62 -low_power 1 -y ./qsv_444_8.h265 ffmpeg -hwaccel qsv -init_hw_device qsv=hw -filter_hw_device hw -f rawvideo -video_size 400x384 -pix_fmt y410 -i ./y410.yuv -vf hwupload=extra_hw_frames=64,format=qsv -c:v hevc_qsv -profile rext -level 62 -low_power 1 -y ./qsv_444_10.h265 Signed-off-by: Linjie Fu --- libavcodec/qsvenc.c | 4 +++- libavcodec/qsvenc_hevc.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 2068853..f0c06fb 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -66,6 +66,7 @@ static const struct { { MFX_PROFILE_HEVC_MAIN,"main" }, { MFX_PROFILE_HEVC_MAIN10, "main10"}, { MFX_PROFILE_HEVC_MAINSP, "mainsp"}, +{ MFX_PROFILE_HEVC_REXT,"rext" }, #endif }; @@ -529,7 +530,8 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->param.mfx.FrameInfo.CropH = avctx->height; q->param.mfx.FrameInfo.AspectRatioW = avctx->sample_aspect_ratio.num; q->param.mfx.FrameInfo.AspectRatioH = avctx->sample_aspect_ratio.den; -q->param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420; +q->param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420 + +!desc->log2_chroma_w + !desc->log2_chroma_h; q->param.mfx.FrameInfo.BitDepthLuma = desc->comp[0].depth; q->param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth; q->param.mfx.FrameInfo.Shift = desc->comp[0].shift > 0; diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c index da64b4c..3d72fcb 100644 --- a/libavcodec/qsvenc_hevc.c +++ b/libavcodec/qsvenc_hevc.c @@ -240,6 +240,7 @@ static const AVOption options[] = { { "main",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_MAIN }, INT_MIN, INT_MAX, VE, "profile" }, { "main10", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_MAIN10 }, INT_MIN, INT_MAX, VE, "profile" }, { "mainsp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_MAINSP }, INT_MIN, INT_MAX, VE, "profile" }, +{ "rext",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_HEVC_REXT }, INT_MIN, INT_MAX, VE, "profile" }, { "gpb", "1: GPB (generalized P/B frame); 0: regular P frame", OFFSET(qsv.gpb), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE}, -- 2.7.4 ___ ffmpeg-devel mailing list ffmpeg-devel@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] lavc/qsv: Add decoding support for HEVC Range Extension
Add some pix_fmt, fourcc and frame map support for new pixel formats. This enables decoding support for HEVC Range Extension. 4:2:2 8 bit: yuyv422 4:2:2 10 bit:y210 4:4:4 8 bit:0yuv 4:4:4 10 bit:y410 Signed-off-by: Linjie Fu --- libavcodec/qsv.c | 26 ++ libavutil/hwcontext_qsv.c | 39 +++ 2 files changed, 65 insertions(+) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index b00e427..74e4f29 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -247,6 +247,14 @@ enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc) case MFX_FOURCC_NV12: return AV_PIX_FMT_NV12; case MFX_FOURCC_P010: return AV_PIX_FMT_P010; case MFX_FOURCC_P8: return AV_PIX_FMT_PAL8; +case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422; +#if QSV_VERSION_ATLEAST(1, 17) +case MFX_FOURCC_AYUV: return AV_PIX_FMT_0YUV; +#endif +#if QSV_VERSION_ATLEAST(1, 27) +case MFX_FOURCC_Y210: return AV_PIX_FMT_Y210; +case MFX_FOURCC_Y410: return AV_PIX_FMT_Y410; +#endif } return AV_PIX_FMT_NONE; } @@ -259,6 +267,24 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc) case AV_PIX_FMT_NV12: *fourcc = MFX_FOURCC_NV12; return AV_PIX_FMT_NV12; +case AV_PIX_FMT_YUV422P: +*fourcc = MFX_FOURCC_YUY2; +return AV_PIX_FMT_YUYV422; +#if QSV_VERSION_ATLEAST(1, 17) +case AV_PIX_FMT_0YUV: +case AV_PIX_FMT_YUV444P: +*fourcc = MFX_FOURCC_AYUV; +return AV_PIX_FMT_0YUV; +#endif +#if QSV_VERSION_ATLEAST(1, 27) +case AV_PIX_FMT_YUV422P10: +*fourcc = MFX_FOURCC_Y210; +return AV_PIX_FMT_Y210; +case AV_PIX_FMT_Y410: +case AV_PIX_FMT_YUV444P10: +*fourcc = MFX_FOURCC_Y410; +return AV_PIX_FMT_Y410; +#endif case AV_PIX_FMT_YUV420P10: case AV_PIX_FMT_P010: *fourcc = MFX_FOURCC_P010; diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 9e3f2af..097b185 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -44,6 +44,10 @@ #include "pixdesc.h" #include "time.h" +#define QSV_VERSION_ATLEAST(MAJOR, MINOR) \ +(MFX_VERSION_MAJOR > (MAJOR) || \ + MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR)) + typedef struct QSVDevicePriv { AVBufferRef *child_device_ctx; } QSVDevicePriv; @@ -103,6 +107,18 @@ static const struct { { AV_PIX_FMT_BGRA, MFX_FOURCC_RGB4 }, { AV_PIX_FMT_P010, MFX_FOURCC_P010 }, { AV_PIX_FMT_PAL8, MFX_FOURCC_P8 }, +{ AV_PIX_FMT_YUYV422, + MFX_FOURCC_YUY2 }, +#if QSV_VERSION_ATLEAST(1, 17) +{ AV_PIX_FMT_0YUV, + MFX_FOURCC_AYUV }, +#endif +#if QSV_VERSION_ATLEAST(1, 27) +{ AV_PIX_FMT_Y210, + MFX_FOURCC_Y210 }, +{ AV_PIX_FMT_Y410, + MFX_FOURCC_Y410 }, +#endif }; static uint32_t qsv_fourcc_from_pix_fmt(enum AVPixelFormat pix_fmt) @@ -774,6 +790,29 @@ static int map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 *surface) surface->Data.A = frame->data[0] + 3; break; +case AV_PIX_FMT_YUYV422: +surface->Data.Y = frame->data[0]; +surface->Data.U = frame->data[0] + 1; +surface->Data.V = frame->data[0] + 3; +break; + +case AV_PIX_FMT_Y210: +surface->Data.Y16 = frame->data[0]; +surface->Data.U16 = frame->data[0] + 2; +surface->Data.V16 = frame->data[0] + 6; +break; + +case AV_PIX_FMT_0YUV: +surface->Data.V = frame->data[0]; +surface->Data.U = frame->data[0] + 1; +surface->Data.Y = frame->data[0] + 2; +surface->Data.A = frame->data[0] + 3; +break; + +case AV_PIX_FMT_Y410: +surface->Data.U = frame->data[0]; +break; + default: return MFX_ERR_UNSUPPORTED; } -- 2.7.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH, v3, 5/7] qsv: get FrameInfo.Shift by desc->comp[0].shift
Since Y410 is a pixel format with depth > 8 but shift = 0, get Shift info by depth is not quite accurate. Signed-off-by: Linjie Fu --- libavcodec/qsvenc.c | 4 ++-- libavutil/hwcontext_qsv.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 4f103b9..2068853 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -437,7 +437,7 @@ static int init_video_param_jpeg(AVCodecContext *avctx, QSVEncContext *q) q->param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420; q->param.mfx.FrameInfo.BitDepthLuma = desc->comp[0].depth; q->param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth; -q->param.mfx.FrameInfo.Shift = desc->comp[0].depth > 8; +q->param.mfx.FrameInfo.Shift = desc->comp[0].shift > 0; q->param.mfx.FrameInfo.Width = FFALIGN(avctx->width, 16); q->param.mfx.FrameInfo.Height = FFALIGN(avctx->height, 16); @@ -532,7 +532,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) q->param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420; q->param.mfx.FrameInfo.BitDepthLuma = desc->comp[0].depth; q->param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth; -q->param.mfx.FrameInfo.Shift = desc->comp[0].depth > 8; +q->param.mfx.FrameInfo.Shift = desc->comp[0].shift > 0; // If the minor version is greater than or equal to 19, // then can use the same alignment settings as H.264 for HEVC diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index b1b6740..9e3f2af 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -315,7 +315,7 @@ static int qsv_init_surface(AVHWFramesContext *ctx, mfxFrameSurface1 *surf) surf->Info.BitDepthLuma = desc->comp[0].depth; surf->Info.BitDepthChroma = desc->comp[0].depth; -surf->Info.Shift = desc->comp[0].depth > 8; +surf->Info.Shift = desc->comp[0].shift > 0; if (desc->log2_chroma_w && desc->log2_chroma_h) surf->Info.ChromaFormat = MFX_CHROMAFORMAT_YUV420; -- 2.7.4 ___ ffmpeg-devel mailing list ffmpeg-devel@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] lavu/hwcontext_vaapi: add vaapi_format_map support for 0YUV/Y210/Y410
VA_RT_FORMAT describes the desired sampling format for surface. When creating surface, VA_RT_FORMAT will be used firstly to choose the expected fourcc/media_format for the surface. And the fourcc will be revised by the value of VASurfaceAttribPixelFormat. Add vaapi_format_map support for new pixel_format. This is fundamental for both VA-API and QSV. Signed-off-by: Linjie Fu --- libavutil/hwcontext_vaapi.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index cf11764..296234b 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -116,6 +116,13 @@ static const VAAPIFormatDescriptor vaapi_format_map[] = { #endif MAP(UYVY, YUV422, UYVY422, 0), MAP(YUY2, YUV422, YUYV422, 0), +#ifdef VA_FOURCC_Y210 +MAP(Y210, YUV422_10, Y210, 0), +#endif +MAP(AYUV, YUV444,0YUV, 0), +#ifdef VA_FOURCC_Y410 +MAP(Y410, YUV444_10, Y410, 0), +#endif MAP(411P, YUV411, YUV411P, 0), MAP(422V, YUV422, YUV440P, 0), MAP(444P, YUV444, YUV444P, 0), -- 2.7.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH, v3, 3/7] swscale: Add swscale input support for Y210
Add swscale input support for Y210, output support and fate test could be added later if there is requirement for software CSC to this packed format. Signed-off-by: Linjie Fu --- libswscale/input.c | 48 libswscale/utils.c | 2 ++ 2 files changed, 50 insertions(+) diff --git a/libswscale/input.c b/libswscale/input.c index 4973b8c..e98a034 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -571,6 +571,42 @@ static void XyuvToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, con av_assert1(src1 == src2); } +static void y210le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, +const uint8_t *unused1, int width, uint32_t *unused2) +{ +int i; +for (i = 0; i < width; i++) { +AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 2) >> 6); +AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6) >> 6); +} +} + +static void y210be_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src, +const uint8_t *unused1, int width, uint32_t *unused2) +{ +int i; +for (i = 0; i < width; i++) { +AV_WN16(dstU + i * 2, AV_RB16(src + i * 8 + 2) >> 6); +AV_WN16(dstV + i * 2, AV_RB16(src + i * 8 + 6) >> 6); +} +} + +static void y210le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, + const uint8_t *unused1, int width, uint32_t *unused2) +{ +int i; +for (i = 0; i < width; i++) +AV_WN16(dst + i * 2, AV_RL16(src + i * 4) >> 6); +} + +static void y210be_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, + const uint8_t *unused1, int width, uint32_t *unused2) +{ +int i; +for (i = 0; i < width; i++) +AV_WN16(dst + i * 2 ,AV_RB16(src + i * 4) >> 6); +} + static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused) { @@ -1176,6 +1212,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) case AV_PIX_FMT_0YUV: c->chrToYV12 = XyuvToUV_c; break; +case AV_PIX_FMT_Y210LE: +c->chrToYV12 = y210le_UV_c; +break; +case AV_PIX_FMT_Y210BE: +c->chrToYV12 = y210be_UV_c; +break; } if (c->chrSrcHSubSample) { switch (srcFormat) { @@ -1611,6 +1653,12 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) case AV_PIX_FMT_0YUV: c->lumToYV12 = XyuvToY_c; break; +case AV_PIX_FMT_Y210LE: +c->lumToYV12 = y210le_Y_c; +break; +case AV_PIX_FMT_Y210BE: +c->chrToYV12 = y210be_Y_c; +break; } if (c->needAlpha) { if (is16BPS(srcFormat) || isNBPS(srcFormat)) { diff --git a/libswscale/utils.c b/libswscale/utils.c index 6ed9d3d..653c5c1 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -266,6 +266,8 @@ static const FormatEntry format_entries[AV_PIX_FMT_NB] = { [AV_PIX_FMT_YUVA444P12LE] = { 1, 1 }, [AV_PIX_FMT_NV24]= { 1, 1 }, [AV_PIX_FMT_NV42]= { 1, 1 }, +[AV_PIX_FMT_Y210BE] = { 1, 0 }, +[AV_PIX_FMT_Y210LE] = { 1, 0 }, [AV_PIX_FMT_0YUV]= { 1, 1 }, }; -- 2.7.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH, v3, 1/7] lavu/pixfmt: add new pixel format 0yuv/y210/y410
Previously, media driver provided planar format(like 420 8 bit), but for HEVC Range Extension (422/444 8/10 bit), the decoded image is produced in packed format because Windows expects it. Add some packed pixel formats for hardware decode support in VAAPI and QSV: 4:2:2 10 bit: Y210 4:4:4 8 bit: 0YUV 4:4:4 10 bit: Y410 Add query support in fate and update the minor version. Signed-off-by: Linjie Fu --- libavutil/pixdesc.c | 60 libavutil/pixfmt.h | 9 ++ libavutil/version.h | 4 +-- tests/ref/fate/sws-pixdesc-query | 18 4 files changed, 89 insertions(+), 2 deletions(-) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 05dd4a1..5fa934f 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -205,6 +205,66 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { { 0, 4, 1, 0, 8, 3, 7, 2 },/* V */ }, }, +[AV_PIX_FMT_Y210LE] = { +.name = "y210le", +.nb_components = 3, +.log2_chroma_w = 1, +.log2_chroma_h = 0, +.comp = { +{ 0, 4, 0, 6, 10, 3, 9, 1 },/* Y */ +{ 0, 8, 2, 6, 10, 7, 9, 3 },/* U */ +{ 0, 8, 6, 6, 10, 7, 9, 7 },/* V */ +}, +}, +[AV_PIX_FMT_Y210BE] = { +.name = "y210be", +.nb_components = 3, +.log2_chroma_w = 1, +.log2_chroma_h = 0, +.comp = { +{ 0, 4, 0, 6, 10, 3, 9, 1 },/* Y */ +{ 0, 8, 2, 6, 10, 7, 9, 3 },/* U */ +{ 0, 8, 6, 6, 10, 7, 9, 7 },/* V */ +}, +.flags = AV_PIX_FMT_FLAG_BE, +}, +[AV_PIX_FMT_0YUV] = { +.name = "0yuv", +.nb_components = 3, +.log2_chroma_w = 0, +.log2_chroma_h = 0, +.comp = { +{ 0, 4, 1, 0, 8, 3, 7, 2 },/* Y */ +{ 0, 4, 2, 0, 8, 3, 7, 3 },/* U */ +{ 0, 4, 3, 0, 8, 3, 7, 4 },/* V */ +}, +}, +[AV_PIX_FMT_Y410LE] = { +.name = "y410le", +.nb_components = 4, +.log2_chroma_w = 0, +.log2_chroma_h = 0, +.comp = { +{ 0, 32, 10, 0, 10, 31, 9, 11 },/* Y */ +{ 0, 32, 0, 0, 10, 31, 9, 1 },/* U */ +{ 0, 32, 20, 0, 10, 31, 9, 21 },/* V */ +{ 0, 32, 30, 0, 2, 31, 1, 31 },/* A */ +}, +.flags = AV_PIX_FMT_FLAG_ALPHA | AV_PIX_FMT_FLAG_BITSTREAM, +}, +[AV_PIX_FMT_Y410BE] = { +.name = "y410be", +.nb_components = 4, +.log2_chroma_w = 0, +.log2_chroma_h = 0, +.comp = { +{ 0, 32, 10, 0, 10, 31, 9, 11 },/* Y */ +{ 0, 32, 0, 0, 10, 31, 9, 1 },/* U */ +{ 0, 32, 20, 0, 10, 31, 9, 21 },/* V */ +{ 0, 32, 30, 0, 2, 31, 1, 31 },/* A */ +}, +.flags = AV_PIX_FMT_FLAG_ALPHA | AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_BE, +}, [AV_PIX_FMT_RGB24] = { .name = "rgb24", .nb_components = 3, diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index d78e863..a163350 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -348,6 +348,12 @@ enum AVPixelFormat { AV_PIX_FMT_NV24, ///< planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V) AV_PIX_FMT_NV42, ///< as above, but U and V bytes are swapped +AV_PIX_FMT_Y210BE,///< packed YUV 4:2:2, 32bpp, Y0 Cb Y1 Cr, big-endian +AV_PIX_FMT_Y210LE,///< packed YUV 4:2:2, 32bpp, Y0 Cb Y1 Cr, little-endian +AV_PIX_FMT_0YUV, ///< packed YUV 4:4:4, 32bpp, X Y Cb Cr, X=unused/undefined +AV_PIX_FMT_Y410LE,///< packed YUV 4:4:4, 32bpp, Cr Y Cb A, little-endian +AV_PIX_FMT_Y410BE,///< packed YUV 4:4:4, 32bpp, Cr Y Cb A, big-endian + AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; @@ -436,6 +442,9 @@ enum AVPixelFormat { #define AV_PIX_FMT_P010 AV_PIX_FMT_NE(P010BE, P010LE) #define AV_PIX_FMT_P016 AV_PIX_FMT_NE(P016BE, P016LE) +#define AV_PIX_FMT_Y210 AV_PIX_FMT_NE(Y210BE, Y210LE) +#define AV_PIX_FMT_Y410 AV_PIX_FMT_NE(Y410BE, Y410LE) + /** * Chromaticity coordinates of the source primaries. * These values match the ones defined by ISO/IEC 23001-8_2013 § 7.1. diff --git a/libavutil/version.h b/libavutil/version.h index e181633..4de0fa1 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,8 +79,8 @@ */ #define LIBAVUTIL_VERSION_MAJOR 56 -#define LIBAVUTIL_VERSION_MINOR 36 -#define LIBAVUTIL_VERSION_MICRO 101 +#define LIBAVUTIL_VERSION_MINOR 37 +#define LIBAVUTIL_VERSION_MICRO 100 #define
[FFmpeg-devel] [PATCH, v3, 2/7] swscale: Add swscale and fate support for 0YUV
Add input and output support in swscale for 0YUV. Since AV_PIX_FMT_0RGB would be treated as AV_PIX_FMT_ARGB, the default X(0) channel for 0YUV is set to 0xFF as well. Add fate test for 0YUV. Signed-off-by: Linjie Fu --- libswscale/input.c | 25 libswscale/output.c | 50 libswscale/swscale_unscaled.c| 40 + libswscale/utils.c | 1 + libswscale/version.h | 2 +- tests/ref/fate/filter-pixdesc-0yuv | 1 + tests/ref/fate/filter-pixfmts-copy | 1 + tests/ref/fate/filter-pixfmts-crop | 1 + tests/ref/fate/filter-pixfmts-field | 1 + tests/ref/fate/filter-pixfmts-fieldorder | 1 + tests/ref/fate/filter-pixfmts-hflip | 1 + tests/ref/fate/filter-pixfmts-il | 1 + tests/ref/fate/filter-pixfmts-null | 1 + tests/ref/fate/filter-pixfmts-pad| 1 + tests/ref/fate/filter-pixfmts-scale | 1 + tests/ref/fate/filter-pixfmts-transpose | 1 + tests/ref/fate/filter-pixfmts-vflip | 1 + 17 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 tests/ref/fate/filter-pixdesc-0yuv diff --git a/libswscale/input.c b/libswscale/input.c index 064f8da..4973b8c 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -552,6 +552,25 @@ static void yvy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, con av_assert1(src1 == src2); } +static void XyuvToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, + uint32_t *unused) +{ +int i; +for (i = 0; i < width; i++) +dst[i] = src[4 * i + 2]; +} + +static void XyuvToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1, + const uint8_t *src2, int width, uint32_t *unused) +{ +int i; +for (i = 0; i < width; i++) { +dstV[i] = src1[4 * i]; +dstU[i] = src1[4 * i + 1]; +} +av_assert1(src1 == src2); +} + static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused) { @@ -1154,6 +1173,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) case AV_PIX_FMT_P016BE: c->chrToYV12 = p016BEToUV_c; break; +case AV_PIX_FMT_0YUV: +c->chrToYV12 = XyuvToUV_c; +break; } if (c->chrSrcHSubSample) { switch (srcFormat) { @@ -1586,6 +1608,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) c->lumToYV12 = grayf32ToY16_bswap_c; #endif break; +case AV_PIX_FMT_0YUV: +c->lumToYV12 = XyuvToY_c; +break; } if (c->needAlpha) { if (is16BPS(srcFormat) || isNBPS(srcFormat)) { diff --git a/libswscale/output.c b/libswscale/output.c index d192ea8..e18955d 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -2406,6 +2406,53 @@ yuv2ya8_X_c(SwsContext *c, const int16_t *lumFilter, } static void +yuv2Xyuv_X_c(SwsContext *c, const int16_t *lumFilter, + const int16_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int16_t **chrUSrc, + const int16_t **chrVSrc, int chrFilterSize, + const int16_t **alpSrc, uint8_t *dest, int dstW, int y) +{ +int hasAlpha = !!alpSrc; +int i; + +for (i = 0; i < dstW; i++) { +int j; +int A = 1 << 18; +int Y = 1 << 18; +int U = 1 << 18; +int V = 1 << 18; + +for (j = 0; j < lumFilterSize; j++) { +Y += lumSrc[j][i] * lumFilter[j]; +} +for (j = 0; j < chrFilterSize; j++) { +U += chrUSrc[j][i] * chrFilter[j]; +V += chrVSrc[j][i] * chrFilter[j]; +} +if (hasAlpha) +for (j = 0; j < lumFilterSize; j++) +A += alpSrc[j][i] * lumFilter[j]; +A >>= 19; +Y >>= 19; +U >>= 19; +V >>= 19; +A = hasAlpha ? A : 255; + +if ((A | Y | U | V) & 0x100) { +A = av_clip_uint8(A); +Y = av_clip_uint8(Y); +U = av_clip_uint8(U); +V = av_clip_uint8(V); +} + +dest[4*i] = V; +dest[4*i + 1] = U; +dest[4*i + 2] = Y; +dest[4*i + 3] = A; +} +} + +static void yuv2ayuv64le_X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **_lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **_chrUSrc, @@ -2935,6 +2982,9 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, *yuv2packed2 = yuv2ya16be_2_c; *yuv2packedX = yuv2ya16be_X_c; break; +case AV_PIX_FMT_0YUV: +*yuv2packedX = yuv2Xyuv_X_c; +break; case AV_PIX_FMT_AYUV64LE: *yuv2packedX = yuv2ayuv64le_X_c; break; diff --git
[FFmpeg-devel] [PATCH 0/7] Add decoding/encoding support for QSV HEVC REXT
Add decoding support for: 4:2:2 8 bit: yuyv422 4:2:2 10 bit:y210 4:4:4 8 bit:0yuv 4:4:4 10 bit:y410 Add encoding support for: 4:4:4 8 bit:0yuv 4:4:4 10 bit:y410 Linjie Fu (7): lavu/pixfmt: add new pixel format 0yuv/y210/y410 swscale: Add swscale and fate support for 0YUV swscale: Add swscale input support for Y210 lavu/hwcontext_vaapi: add vaapi_format_map support for 0YUV/Y210/Y410 qsv: get FrameInfo.Shift by desc->comp[0].shift lavc/qsv: Add decoding support for HEVC Range Extension lavc/qsvenc: Add support for 4:4:4 8/10 bit HEVC REXT encoding libavcodec/qsv.c | 26 libavcodec/qsvenc.c | 8 ++-- libavcodec/qsvenc_hevc.c | 1 + libavutil/hwcontext_qsv.c| 41 +- libavutil/hwcontext_vaapi.c | 7 +++ libavutil/pixdesc.c | 60 ++ libavutil/pixfmt.h | 9 libavutil/version.h | 4 +- libswscale/input.c | 73 libswscale/output.c | 50 ++ libswscale/swscale_unscaled.c| 40 + libswscale/utils.c | 3 ++ libswscale/version.h | 2 +- tests/ref/fate/filter-pixdesc-0yuv | 1 + tests/ref/fate/filter-pixfmts-copy | 1 + tests/ref/fate/filter-pixfmts-crop | 1 + tests/ref/fate/filter-pixfmts-field | 1 + tests/ref/fate/filter-pixfmts-fieldorder | 1 + tests/ref/fate/filter-pixfmts-hflip | 1 + tests/ref/fate/filter-pixfmts-il | 1 + tests/ref/fate/filter-pixfmts-null | 1 + tests/ref/fate/filter-pixfmts-pad| 1 + tests/ref/fate/filter-pixfmts-scale | 1 + tests/ref/fate/filter-pixfmts-transpose | 1 + tests/ref/fate/filter-pixfmts-vflip | 1 + tests/ref/fate/sws-pixdesc-query | 18 26 files changed, 347 insertions(+), 7 deletions(-) create mode 100644 tests/ref/fate/filter-pixdesc-0yuv -- 2.7.4 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 1/3] lavc/hevc_mp4toannexb: Fix integer overflow
On Tue, 03. Dec 21:42, Andriy Gelman wrote: > On Wed, 04. Dec 01:26, Andreas Rheinhardt wrote: > > On Wed, Dec 4, 2019 at 1:04 AM Andriy Gelman > > wrote: > > > > > From: Andriy Gelman > > > > > > Check packet grow size against INT_MAX instead of SIZE_MAX. > > > > > > Found with libFuzzer: > > > 4294967044 cannot be represented as int. > > > > > > Signed-off-by: Andriy Gelman > > > --- > > > libavcodec/hevc_mp4toannexb_bsf.c | 6 +++--- > > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > > > diff --git a/libavcodec/hevc_mp4toannexb_bsf.c > > > b/libavcodec/hevc_mp4toannexb_bsf.c > > > index 09bce5b34c2..bf4c25b3b7b 100644 > > > --- a/libavcodec/hevc_mp4toannexb_bsf.c > > > +++ b/libavcodec/hevc_mp4toannexb_bsf.c > > > @@ -66,7 +66,7 @@ static int hevc_extradata_to_annexb(AVBSFContext *ctx) > > > for (j = 0; j < cnt; j++) { > > > int nalu_len = bytestream2_get_be16(); > > > > > > -if (4 + AV_INPUT_BUFFER_PADDING_SIZE + nalu_len > SIZE_MAX - > > > new_extradata_size) { > > > +if (4 + AV_INPUT_BUFFER_PADDING_SIZE + nalu_len > INT_MAX - > > > new_extradata_size) { > > > > > > > > There is actually FF_MAX_EXTRADATA_SIZE constant to limit the size of > > extradata (it is chosen so small that one can parse the extradata via a > > GetBitContext). (But honestly, it is not used consistently.) > > If we decide to use it should be a separate commit IMO. > > > > > > > > ret = AVERROR_INVALIDDATA; > > > goto fail; > > > } > > > @@ -152,8 +152,8 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, > > > AVPacket *out) > > > extra_size= add_extradata * ctx->par_out->extradata_size; > > > got_irap |= is_irap; > > > > > > -if (SIZE_MAX - nalu_size < 4 || > > > -SIZE_MAX - 4 - nalu_size < extra_size) { > > > +if (INT_MAX < 4 + (uint64_t)nalu_size || > > > > > > > The cast is unnecessary: INT_MAX - 4 < nalu_size does the same. And INT_MAX > > - 4 can even be computed at compile-time. > > > > > > > > +INT_MAX - 4 < extra_size + (uint64_t)nalu_size) { > > > > > > > If you check that the extradata is not too big (namely <= INT_MAX - 4), > > then you can simplify this to INT_MAX - 4 - extra_size < nalu_size. The > > left side is positive, so it does not wrap around when converting it to > > uint32_t. This makes the first check superfluous. > > Yes, that's a good idea. And I think that extra_size <= INT_MAX - 4 always > holds > because we pad extradata with AV_INPUT_PADDING_SIZE (and the checks are done > in > the initialization). But I'll double check. The above check also needs to take into account the current packet size, i.e.: INT_MAX - 4 - extra_size < (uint64_t)nalu_size + out->size I don't think it's possible to get rid of the cast on the rhs then. Thanks, -- Andriy ___ ffmpeg-devel mailing list ffmpeg-devel@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 V4 2/2] lavf/libsrt: enable other encryption parameters
From: Jun Zhao Enable the SRTO_ENFORCEDENCRYPTION/SRTO_KMREFRESHRATE/ SRTO_KMPREANNOUNCE for srt encryption control. Signed-off-by: Jun Zhao --- doc/protocols.texi | 20 libavformat/libsrt.c | 18 ++ 2 files changed, 38 insertions(+), 0 deletions(-) diff --git a/doc/protocols.texi b/doc/protocols.texi index 886c3b8..d2935fc 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -1282,6 +1282,26 @@ only if @option{pbkeylen} is non-zero. It is used on the receiver only if the received data is encrypted. The configured passphrase cannot be recovered (write-only). +@item enforced_encryption=@var{1|0} +If true, both connection parties must have the same password +set (including empty, that is, with no encryption). If the +password doesn't match or only one side is unencrypted, +the connection is rejected. Default is true. + +@item kmrefreshrate=@var{packets} +The number of packets to be transmitted after which the +encryption key is switched to a new key. Default is -1. +-1 means auto (0x100 in srt library). The range for +this option is integers in the 0 - @code{INT_MAX}. + +@item kmpreannounce=@var{packets} +The interval between when a new encryption key is sent and +when switchover occurs. This value also applies to the +subsequent interval between when switchover occurs and +when the old encryption key is decommissioned. Default is -1. +-1 means auto (0x1000 in srt library). The range for +this option is integers in the 0 - @code{INT_MAX}. + @item payload_size=@var{bytes} Sets the maximum declared size of a packet transferred during the single call to the sending function in Live diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index 0a748a1..05a46c6 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -62,6 +62,9 @@ typedef struct SRTContext { int64_t maxbw; int pbkeylen; char *passphrase; +int enforced_encryption; +int kmrefreshrate; +int kmpreannounce; int mss; int ffs; int ipttl; @@ -102,6 +105,9 @@ static const AVOption libsrt_options[] = { { "maxbw", "Maximum bandwidth (bytes per second) that the connection can use", OFFSET(maxbw),AV_OPT_TYPE_INT64,{ .i64 = -1 }, -1, INT64_MAX, .flags = D|E }, { "pbkeylen", "Crypto key len in bytes {16,24,32} Default: 16 (128-bit)", OFFSET(pbkeylen), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 32,.flags = D|E }, { "passphrase", "Crypto PBKDF2 Passphrase size[0,10..64] 0:disable crypto", OFFSET(passphrase), AV_OPT_TYPE_STRING, { .str = NULL }, .flags = D|E }, +{ "enforced_encryption", "Enforces that both connection parties have the same passphrase set ", OFFSET(enforced_encryption), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, .flags = D|E }, +{ "kmrefreshrate", "The number of packets to be transmitted after which the encryption key is switched to a new key", OFFSET(kmrefreshrate), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, +{ "kmpreannounce", "The interval between when a new encryption key is sent and when switchover occurs", OFFSET(kmpreannounce), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { "mss","The Maximum Segment Size", OFFSET(mss), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1500, .flags = D|E }, { "ffs","Flight flag size (window size) (in bytes)", OFFSET(ffs), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { "ipttl", "IP Time To Live", OFFSET(ipttl),AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 255, .flags = D|E }, @@ -321,6 +327,9 @@ static int libsrt_set_options_pre(URLContext *h, int fd) (s->maxbw >= 0 && libsrt_setsockopt(h, fd, SRTO_MAXBW, "SRTO_MAXBW", >maxbw, sizeof(s->maxbw)) < 0) || (s->pbkeylen >= 0 && libsrt_setsockopt(h, fd, SRTO_PBKEYLEN, "SRTO_PBKEYLEN", >pbkeylen, sizeof(s->pbkeylen)) < 0) || (s->passphrase && libsrt_setsockopt(h, fd, SRTO_PASSPHRASE, "SRTO_PASSPHRASE", s->passphrase, strlen(s->passphrase)) < 0) || +(s->enforced_encryption >= 0 && libsrt_setsockopt(h, fd, SRTO_ENFORCEDENCRYPTION, "SRTO_ENFORCEDENCRYPTION", >enforced_encryption, sizeof(s->enforced_encryption)) < 0) || +(s->kmrefreshrate >= 0 && libsrt_setsockopt(h, fd, SRTO_KMREFRESHRATE, "SRTO_KMREFRESHRATE", >kmrefreshrate, sizeof(s->kmrefreshrate)) < 0) || +(s->kmpreannounce >= 0 && libsrt_setsockopt(h, fd, SRTO_KMPREANNOUNCE, "SRTO_KMPREANNOUNCE", >kmpreannounce, sizeof(s->kmpreannounce)) < 0) || (s->mss >= 0 && libsrt_setsockopt(h, fd, SRTO_MSS, "SRTO_MMS", >mss, sizeof(s->mss)) < 0) || (s->ffs
[FFmpeg-devel] [PATCH V4 0/2] Enable other srt options.
V4: - changed the option enforced_encryption type from int to bool. tks Michael & Moritz's comments. - add range info in the docs. tks Gyan's comments. V3: - add more details for linger options. tks Andriy Gelman's comments. - fix minor typo in commit message. V2: - correct the commit message. Jun Zhao (2): lavf/libsrt: add linger parameter to libsrt lavf/libsrt: enable other encryption parameters doc/protocols.texi | 26 ++ libavformat/libsrt.c | 31 +++ 2 files changed, 57 insertions(+), 0 deletions(-) ___ ffmpeg-devel mailing list ffmpeg-devel@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 V4 1/2] lavf/libsrt: add linger parameter to libsrt
From: Jun Zhao add linger parameter to libsrt, it's setting the number of seconds that the socket waits for unsent data when closing. Reviewed-by: Andriy Gelman Signed-off-by: Jun Zhao --- doc/protocols.texi |6 ++ libavformat/libsrt.c | 13 + 2 files changed, 19 insertions(+), 0 deletions(-) diff --git a/doc/protocols.texi b/doc/protocols.texi index 0e18a49..886c3b8 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -1426,6 +1426,12 @@ the overhead transmission (retransmitted and control packets). file: Set options as for non-live transmission. See @option{messageapi} for further explanations +@item linger=@var{seconds} +The number of seconds that the socket waits for unsent data when closing. +Default is -1. -1 means auto (off with 0 seconds in live mode, on with 180 +seconds in file mode). The range for this option is integers in the +0 - @code{INT_MAX}. + @end table For more information see: @url{https://github.com/Haivision/srt}. diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index 1c34ec5..0a748a1 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -84,6 +84,7 @@ typedef struct SRTContext { char *smoother; int messageapi; SRT_TRANSTYPE transtype; +int linger; } SRTContext; #define D AV_OPT_FLAG_DECODING_PARAM @@ -128,6 +129,7 @@ static const AVOption libsrt_options[] = { { "transtype", "The transmission type for the socket", OFFSET(transtype),AV_OPT_TYPE_INT, { .i64 = SRTT_INVALID }, SRTT_LIVE, SRTT_INVALID, .flags = D|E, "transtype" }, { "live", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SRTT_LIVE }, INT_MIN, INT_MAX, .flags = D|E, "transtype" }, { "file", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SRTT_FILE }, INT_MIN, INT_MAX, .flags = D|E, "transtype" }, +{ "linger", "Number of seconds that the socket waits for unsent data when closing", OFFSET(linger), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { NULL } }; @@ -340,6 +342,14 @@ static int libsrt_set_options_pre(URLContext *h, int fd) ((h->flags & AVIO_FLAG_WRITE) && libsrt_setsockopt(h, fd, SRTO_SENDER, "SRTO_SENDER", , sizeof(yes)) < 0)) { return AVERROR(EIO); } + +if (s->linger >= 0) { +struct linger lin; +lin.l_linger = s->linger; +lin.l_onoff = lin.l_linger > 0 ? 1 : 0; +if (libsrt_setsockopt(h, fd, SRTO_LINGER, "SRTO_LINGER", , sizeof(lin)) < 0) +return AVERROR(EIO); +} return 0; } @@ -591,6 +601,9 @@ static int libsrt_open(URLContext *h, const char *uri, int flags) goto err; } } +if (av_find_info_tag(buf, sizeof(buf), "linger", p)) { +s->linger = strtol(buf, NULL, 10); +} } return libsrt_setup(h, uri, flags); err: -- 1.7.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] avfilter/buffersrc: remove redundant flag
From: Zhao Zhili !(c->pix_fmt != AV_PIX_FMT_NONE || c->got_format_from_params) equals (c->pix_fmt == AV_PIX_FMT_NONE) && !c->got_format_from_params 1. When (c->pix_fmt == AV_PIX_FMT_NONE) is true, got_format_from_params is always false, the flag doesn't contribute to the result. 2. When the first part is false, the second part doesn't matter, the flag doesn't contribute to the result. The result only depends on c->pix_fmt. --- libavfilter/buffersrc.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index bae7d86695..b7ff40b045 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -63,7 +63,6 @@ typedef struct BufferSourceContext { uint64_t channel_layout; char*channel_layout_str; -int got_format_from_params; int eof; } BufferSourceContext; @@ -105,7 +104,6 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *par switch (ctx->filter->outputs[0].type) { case AVMEDIA_TYPE_VIDEO: if (param->format != AV_PIX_FMT_NONE) { -s->got_format_from_params = 1; s->pix_fmt = param->format; } if (param->width > 0) @@ -125,7 +123,6 @@ int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *par break; case AVMEDIA_TYPE_AUDIO: if (param->format != AV_SAMPLE_FMT_NONE) { -s->got_format_from_params = 1; s->sample_fmt = param->format; } if (param->sample_rate > 0) @@ -278,7 +275,7 @@ static av_cold int init_video(AVFilterContext *ctx) { BufferSourceContext *c = ctx->priv; -if (!(c->pix_fmt != AV_PIX_FMT_NONE || c->got_format_from_params) || !c->w || !c->h || +if (c->pix_fmt == AV_PIX_FMT_NONE || !c->w || !c->h || av_q2d(c->time_base) <= 0) { av_log(ctx, AV_LOG_ERROR, "Invalid parameters provided.\n"); return AVERROR(EINVAL); @@ -334,7 +331,7 @@ static av_cold int init_audio(AVFilterContext *ctx) BufferSourceContext *s = ctx->priv; int ret = 0; -if (!(s->sample_fmt != AV_SAMPLE_FMT_NONE || s->got_format_from_params)) { +if (s->sample_fmt == AV_SAMPLE_FMT_NONE) { av_log(ctx, AV_LOG_ERROR, "Sample format was not set or was invalid\n"); return AVERROR(EINVAL); } -- 2.22.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] fftools/ffmpeg_filter: remove sws_param option from buffersrc
From: Zhao Zhili The option is deprecated and ignored by buffersrc. --- fftools/ffmpeg_filter.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 72838de1e2..40cc4c191c 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -786,10 +786,9 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, av_bprint_init(, 0, AV_BPRINT_SIZE_AUTOMATIC); av_bprintf(, "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:" - "pixel_aspect=%d/%d:sws_param=flags=%d", + "pixel_aspect=%d/%d", ifilter->width, ifilter->height, ifilter->format, - tb.num, tb.den, sar.num, sar.den, - SWS_BILINEAR + ((ist->dec_ctx->flags_CODEC_FLAG_BITEXACT) ? SWS_BITEXACT:0)); + tb.num, tb.den, sar.num, sar.den); if (fr.num && fr.den) av_bprintf(, ":frame_rate=%d/%d", fr.num, fr.den); snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index, -- 2.22.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/3] avformat/mpeg: Fix leaks of AVFormatContext and subtitle packets
If an error happens in vobsub_read_header() after allocating the AVFormatContext intended to read the sub-file, both the AVFormatContext as well as the data in the subtitles queues leaks. This has been fixed. Signed-off-by: Andreas Rheinhardt --- Supersedes https://ffmpeg.org/pipermail/ffmpeg-devel/2019-October/252075.html Resending because of merge conflicts. libavformat/mpeg.c | 27 ++- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index e4fe16c7d2..e61851bba5 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -713,6 +713,18 @@ static int vobsub_probe(const AVProbeData *p) return 0; } +static int vobsub_read_close(AVFormatContext *s) +{ +VobSubDemuxContext *vobsub = s->priv_data; +int i; + +for (i = 0; i < s->nb_streams; i++) +ff_subtitles_queue_clean(>q[i]); +if (vobsub->sub_ctx) +avformat_close_input(>sub_ctx); +return 0; +} + static int vobsub_read_header(AVFormatContext *s) { int i, ret = 0, header_parsed = 0, langidx = 0; @@ -896,7 +908,8 @@ static int vobsub_read_header(AVFormatContext *s) memcpy(par->extradata, header.str, header.len); } end: - +if (ret < 0) +vobsub_read_close(s); av_bprint_finalize(, NULL); return ret; } @@ -1021,18 +1034,6 @@ static int vobsub_read_seek(AVFormatContext *s, int stream_index, min_ts, ts, max_ts, flags); } -static int vobsub_read_close(AVFormatContext *s) -{ -VobSubDemuxContext *vobsub = s->priv_data; -int i; - -for (i = 0; i < s->nb_streams; i++) -ff_subtitles_queue_clean(>q[i]); -if (vobsub->sub_ctx) -avformat_close_input(>sub_ctx); -return 0; -} - static const AVOption options[] = { { "sub_name", "URI for .sub file", offsetof(VobSubDemuxContext, sub_name), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_DECODING_PARAM }, { NULL } -- 2.20.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/3] avformat/mpeg: Don't copy or leak string in AVBPrint
vobsub_read_header() uses an AVBPrint to write a string and up until now, it collected the string stored in the AVBPrint via av_bprint_finalize(), which might involve an allocation and copy of the string. But this is unnecessary, as the lifetime of the returned string does not exceed the lifetime of the AVBPrint. So use the string in the AVBPrint directly. This also makes it possible to easily fix a memleak: In certain error situations, the string stored in the AVBPrint would not be freed (if it was dynamically allocated). This has been fixed, too. Signed-off-by: Andreas Rheinhardt --- Supersedes https://ffmpeg.org/pipermail/ffmpeg-devel/2019-October/252074.html Resending because of merge conflict. libavformat/mpeg.c | 22 -- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 80983f8a81..e4fe16c7d2 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -718,7 +718,6 @@ static int vobsub_read_header(AVFormatContext *s) int i, ret = 0, header_parsed = 0, langidx = 0; VobSubDemuxContext *vobsub = s->priv_data; size_t fname_len; -char *header_str = NULL; AVBPrint header; int64_t delay = 0; AVStream *st = NULL; @@ -731,8 +730,7 @@ static int vobsub_read_header(AVFormatContext *s) char *ext; vobsub->sub_name = av_strdup(s->url); if (!vobsub->sub_name) { -ret = AVERROR(ENOMEM); -goto end; +return AVERROR(ENOMEM); } fname_len = strlen(vobsub->sub_name); @@ -740,24 +738,23 @@ static int vobsub_read_header(AVFormatContext *s) if (fname_len < 4 || *(ext - 1) != '.') { av_log(s, AV_LOG_ERROR, "The input index filename is too short " "to guess the associated .SUB file\n"); -ret = AVERROR_INVALIDDATA; -goto end; +return AVERROR_INVALIDDATA; } memcpy(ext, !strncmp(ext, "IDX", 3) ? "SUB" : "sub", 3); av_log(s, AV_LOG_VERBOSE, "IDX/SUB: %s -> %s\n", s->url, vobsub->sub_name); } if (!(iformat = av_find_input_format("mpeg"))) { -ret = AVERROR_DEMUXER_NOT_FOUND; -goto end; +return AVERROR_DEMUXER_NOT_FOUND; } vobsub->sub_ctx = avformat_alloc_context(); if (!vobsub->sub_ctx) { -ret = AVERROR(ENOMEM); -goto end; +return AVERROR(ENOMEM); } +av_bprint_init(, 0, INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE); + if ((ret = ff_copy_whiteblacklists(vobsub->sub_ctx, s)) < 0) goto end; @@ -767,7 +764,6 @@ static int vobsub_read_header(AVFormatContext *s) goto end; } -av_bprint_init(, 0, INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE); while (!avio_feof(s->pb)) { char line[MAX_LINE_SIZE]; int len = ff_get_line(s->pb, line, sizeof(line)); @@ -888,22 +884,20 @@ static int vobsub_read_header(AVFormatContext *s) } if (!av_bprint_is_complete()) { -av_bprint_finalize(, NULL); ret = AVERROR(ENOMEM); goto end; } -av_bprint_finalize(, _str); for (i = 0; i < s->nb_streams; i++) { AVCodecParameters *par = s->streams[i]->codecpar; ret = ff_alloc_extradata(par, header.len); if (ret < 0) { goto end; } -memcpy(par->extradata, header_str, header.len); +memcpy(par->extradata, header.str, header.len); } end: -av_free(header_str); +av_bprint_finalize(, NULL); return ret; } -- 2.20.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/3] avformat/mpeg: Make VobSub demuxer have its own context struct
When the VobSub demuxer was added, the fields it required were simply added to the MpegDemuxContext (if the VobSub demuxer was selected at all). The mpeg demuxer of course doesn't use these fields even if they are there; and the VobSub demuxer doesn't use the old ones: It opens an mpeg subdemuxer of its own and uses this where a mpeg demuxer is required. Hence the two contexts can be split, saving memory. Furthermore several headers can now be moved to the section that is guarded by #if CONFIG_VOBSUB_DEMUXER (this even includes avassert.h which was unguarded and has been added in 9cde9f70 despite not being used in that patch). Signed-off-by: Andreas Rheinhardt --- libavformat/mpeg.c | 38 ++ 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 46c59163fd..80983f8a81 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -24,14 +24,6 @@ #include "internal.h" #include "mpeg.h" -#if CONFIG_VOBSUB_DEMUXER -# include "subtitles.h" -# include "libavutil/bprint.h" -# include "libavutil/opt.h" -#endif - -#include "libavutil/avassert.h" - /*/ /* demux code */ @@ -123,18 +115,12 @@ static int mpegps_probe(const AVProbeData *p) } typedef struct MpegDemuxContext { -AVClass *class; int32_t header_state; unsigned char psm_es_type[256]; int sofdec; int dvd; int imkh_cctv; int raw_ac3; -#if CONFIG_VOBSUB_DEMUXER -AVFormatContext *sub_ctx; -FFDemuxSubtitlesQueue q[32]; -char *sub_name; -#endif } MpegDemuxContext; static int mpegps_read_header(AVFormatContext *s) @@ -705,9 +691,21 @@ AVInputFormat ff_mpegps_demuxer = { #if CONFIG_VOBSUB_DEMUXER +#include "subtitles.h" +#include "libavutil/avassert.h" +#include "libavutil/bprint.h" +#include "libavutil/opt.h" + #define REF_STRING "# VobSub index file," #define MAX_LINE_SIZE 2048 +typedef struct VobSubDemuxContext { +const AVClass *class; +AVFormatContext *sub_ctx; +FFDemuxSubtitlesQueue q[32]; +char *sub_name; +} VobSubDemuxContext; + static int vobsub_probe(const AVProbeData *p) { if (!strncmp(p->buf, REF_STRING, sizeof(REF_STRING) - 1)) @@ -718,7 +716,7 @@ static int vobsub_probe(const AVProbeData *p) static int vobsub_read_header(AVFormatContext *s) { int i, ret = 0, header_parsed = 0, langidx = 0; -MpegDemuxContext *vobsub = s->priv_data; +VobSubDemuxContext *vobsub = s->priv_data; size_t fname_len; char *header_str = NULL; AVBPrint header; @@ -911,7 +909,7 @@ end: static int vobsub_read_packet(AVFormatContext *s, AVPacket *pkt) { -MpegDemuxContext *vobsub = s->priv_data; +VobSubDemuxContext *vobsub = s->priv_data; FFDemuxSubtitlesQueue *q; AVIOContext *pb = vobsub->sub_ctx->pb; int ret, psize, total_read = 0, i; @@ -999,7 +997,7 @@ fail: static int vobsub_read_seek(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags) { -MpegDemuxContext *vobsub = s->priv_data; +VobSubDemuxContext *vobsub = s->priv_data; /* Rescale requested timestamps based on the first stream (timebase is the * same for all subtitles stream within a .idx/.sub). Rescaling is done just @@ -1031,8 +1029,8 @@ static int vobsub_read_seek(AVFormatContext *s, int stream_index, static int vobsub_read_close(AVFormatContext *s) { +VobSubDemuxContext *vobsub = s->priv_data; int i; -MpegDemuxContext *vobsub = s->priv_data; for (i = 0; i < s->nb_streams; i++) ff_subtitles_queue_clean(>q[i]); @@ -1042,7 +1040,7 @@ static int vobsub_read_close(AVFormatContext *s) } static const AVOption options[] = { -{ "sub_name", "URI for .sub file", offsetof(MpegDemuxContext, sub_name), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_DECODING_PARAM }, +{ "sub_name", "URI for .sub file", offsetof(VobSubDemuxContext, sub_name), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_DECODING_PARAM }, { NULL } }; @@ -1056,7 +1054,7 @@ static const AVClass vobsub_demuxer_class = { AVInputFormat ff_vobsub_demuxer = { .name = "vobsub", .long_name = NULL_IF_CONFIG_SMALL("VobSub subtitle format"), -.priv_data_size = sizeof(MpegDemuxContext), +.priv_data_size = sizeof(VobSubDemuxContext), .read_probe = vobsub_probe, .read_header= vobsub_read_header, .read_packet= vobsub_read_packet, -- 2.20.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] avfilter/vf_convolution: add X86 SIMD for filter_column()
At 2019-12-04 16:51:52, "Paul B Mahol" wrote: >On 12/4/19, Song, Ruiling wrote: >>> -Original Message- >>> From: ffmpeg-devel On Behalf Of >>> chen >>> >> At 2019-12-03 15:52:07, xuju...@sjtu.edu.cn wrote: >>> >> >From: Xu Jun >>> >[...] >>> >> >+ >>> >> >+cvtdq2ps m4, m4 >>> >> >+mulps m4, m0 ; sum *= rdiv >>> >> >+addps m4, m1 ; sum += bias >>> >> >>> >> >+addps m4, m5 ; sum += 0.5 >>> >> I don't know how about precision mismatch if we pre-compute (bias+0.5) >>> >>> >I think it is hard to prove it is safe to do pre-compute. >>> Agree, I also worried precision issue since float operator is execute >>> order >>> dependent. >>> How about ROUNDPS? >> Seems no exactly match. Funny, I guess it is other issue, such as mistake on instruction's imm field. >>> >> >+cvttps2dq m4, m4 >>> >> >+packssdw m4, m4 >>> >> >+packuswb m4, m4 >>> >> >+movss [dstq + dst_offq], m4 >>> >> >+add c_offq, mmsize/4 >>> >> >+add dst_offq, mmsize/4 >>> >> >+ >>> >> >+add off16q, mmsize/4 >>> >> >+cmp off16q, widthq >>> >> >+jl .loop16 >>> >> >+ >>> >> >+add widthq, rq >>> >> >+cmp off16q, widthq >>> >> >+jge .paraend >>> >> >+ >>> >> >>> >> >+.loopr: >>> >> no idea about this loop, if we can read beyond, we can reuse above >>> >> SIMD >>> >> code >>> >Reuse above SIMD code may write to the memory that does not belong to >>> this slice-thread. >>> >>> >IMO, the code to handle remainder columns is still necessary. >>> >>> >>> Depends on algorithm & size, >>> For example width=23 >>> Process #0 [0:15] >>> Process #1 [7:22] >>> Both of them is multiple of 16 >> Sounds interesting. But FFmpeg does not do like this now. >> One question is will this get a penalty for writing to same address of >> memory (both are writing to 7-15) from different threads? > >Yes, and even bad results may happen. > This is my problem, I don't speak clean, the "Process #x" is one step of loops, I guess the function must be atomic, we can place any threading that work on same address area. ___ ffmpeg-devel mailing list ffmpeg-devel@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 v4] avfilter/buffersrc: deprecate sws_param option
From: Zhao Zhili --- patch v4: update doc doc/filters.texi| 8 libavfilter/buffersrc.c | 14 -- libavfilter/version.h | 5 - 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 5fdec6f015..d15cf74c84 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -21014,9 +21014,9 @@ Specify the frame rate expected for the video stream. The sample (pixel) aspect ratio of the input video. @item sws_param -Specify the optional parameters to be used for the scale filter which -is automatically inserted when an input change is detected in the -input size or format. +This option is deprecated and ignored. Prepend @code{sws_flags=@var{flags};} +to the filtergraph description to specify swscale flags for automatically +inserted scalers. See @ref{Filtergraph syntax}. @item hw_frames_ctx When using a hardware pixel format, this should be a reference to an @@ -21041,7 +21041,7 @@ buffer=size=320x240:pixfmt=6:time_base=1/24:pixel_aspect=1/1 Alternatively, the options can be specified as a flat string, but this syntax is deprecated: -@var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den}[:@var{sws_param}] +@var{width}:@var{height}:@var{pix_fmt}:@var{time_base.num}:@var{time_base.den}:@var{pixel_aspect.num}:@var{pixel_aspect.den} @section cellauto diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index bae7d86695..73a7eb82ca 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -52,7 +52,9 @@ typedef struct BufferSourceContext { int w, h; enum AVPixelFormat pix_fmt; AVRationalpixel_aspect; +#if FF_API_SWS_PARAM_OPTION char *sws_param; +#endif AVBufferRef *hw_frames_ctx; @@ -287,10 +289,16 @@ static av_cold int init_video(AVFilterContext *ctx) if (!(c->fifo = av_fifo_alloc(sizeof(AVFrame* return AVERROR(ENOMEM); -av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s tb:%d/%d fr:%d/%d sar:%d/%d sws_param:%s\n", +av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s tb:%d/%d fr:%d/%d sar:%d/%d\n", c->w, c->h, av_get_pix_fmt_name(c->pix_fmt), c->time_base.num, c->time_base.den, c->frame_rate.num, c->frame_rate.den, - c->pixel_aspect.num, c->pixel_aspect.den, (char *)av_x_if_null(c->sws_param, "")); + c->pixel_aspect.num, c->pixel_aspect.den); + +#if FF_API_SWS_PARAM_OPTION +if (c->sws_param) +av_log(ctx, AV_LOG_WARNING, "sws_param option is deprecated and ignored\n"); +#endif + return 0; } @@ -312,7 +320,9 @@ static const AVOption buffer_options[] = { { "pixel_aspect", "sample aspect ratio",OFFSET(pixel_aspect), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V }, { "time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V }, { "frame_rate",NULL, OFFSET(frame_rate), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V }, +#if FF_API_SWS_PARAM_OPTION { "sws_param", NULL, OFFSET(sws_param), AV_OPT_TYPE_STRING,.flags = V }, +#endif { NULL }, }; diff --git a/libavfilter/version.h b/libavfilter/version.h index 7e8d849e0c..bf57d64d1f 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -31,7 +31,7 @@ #define LIBAVFILTER_VERSION_MAJOR 7 #define LIBAVFILTER_VERSION_MINOR 67 -#define LIBAVFILTER_VERSION_MICRO 100 +#define LIBAVFILTER_VERSION_MICRO 101 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ @@ -59,6 +59,9 @@ #ifndef FF_API_FILTER_GET_SET #define FF_API_FILTER_GET_SET (LIBAVFILTER_VERSION_MAJOR < 8) #endif +#ifndef FF_API_SWS_PARAM_OPTION +#define FF_API_SWS_PARAM_OPTION (LIBAVFILTER_VERSION_MAJOR < 8) +#endif #ifndef FF_API_NEXT #define FF_API_NEXT (LIBAVFILTER_VERSION_MAJOR < 8) #endif -- 2.22.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] Thoughts about error reporting
Hi. This mail is more specifically addressed to people who develop applications with the FFmpeg libraries, especially non-console applications (GUI, web). Please reply on libav-u...@ffmpeg.org exclusively. My question is: do you find the error reporting mechanism satisfactory? I mean not only the few error codes, but the logging to add a human-readable explanation to the code: is it convenient? If you do not find it convenient, can you explain what you do not like? Or even better, if you have given it some thought, can you explain what kind of API you would prefer? I am asking because I myself find it inconvenient, and I would like to propose something better. 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] avfilter/crop: avoid premature eval error
Valid width expressions were being rejected. Regards, Gyan From be3aacc114a0b2b6c8ec9e8b73be38f414ecbb3d Mon Sep 17 00:00:00 2001 From: Gyan Doshi Date: Wed, 4 Dec 2019 16:03:11 +0530 Subject: [PATCH] avfilter/crop: avoid premature eval error Width and height expressions can refer to each other. Width is evaluated twice to allow for reference to output height. So we should not error out upon failure of first evaluation of width. --- libavfilter/vf_crop.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c index d6b4feb513..9bf4077c5d 100644 --- a/libavfilter/vf_crop.c +++ b/libavfilter/vf_crop.c @@ -174,10 +174,9 @@ static int config_input(AVFilterLink *link) s->vsub = pix_desc->log2_chroma_h; } -if ((ret = av_expr_parse_and_eval(, (expr = s->w_expr), - var_names, s->var_values, - NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) -goto fail_expr; +av_expr_parse_and_eval(, (expr = s->w_expr), + var_names, s->var_values, + NULL, NULL, NULL, NULL, NULL, 0, ctx); s->var_values[VAR_OUT_W] = s->var_values[VAR_OW] = res; if ((ret = av_expr_parse_and_eval(, (expr = s->h_expr), var_names, s->var_values, -- 2.24.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 3/3] avfilter/vf_convolution: add X86 SIMD for filter_column()
On 12/4/19, Song, Ruiling wrote: >> -Original Message- >> From: ffmpeg-devel On Behalf Of >> chen >> Sent: Wednesday, December 4, 2019 9:36 AM >> To: FFmpeg development discussions and patches > de...@ffmpeg.org> >> Subject: Re: [FFmpeg-devel] [PATCH 3/3] avfilter/vf_convolution: add X86 >> SIMD for filter_column() >> >> >> >> At 2019-12-04 08:59:08, "Song, Ruiling" wrote: >> >> -Original Message- >> >> From: ffmpeg-devel On Behalf Of >> >> chen >> >> Sent: Tuesday, December 3, 2019 4:59 PM >> >> To: FFmpeg development discussions and patches > >> de...@ffmpeg.org> >> >> Subject: Re: [FFmpeg-devel] [PATCH 3/3] avfilter/vf_convolution: add >> >> X86 >> >> SIMD for filter_column() >> >> >> >> comments inline in code >> >> >> >> >> >> At 2019-12-03 15:52:07, xuju...@sjtu.edu.cn wrote: >> >> >From: Xu Jun >> >[...] >> >> >+ >> >> >+cvtdq2ps m4, m4 >> >> >+mulps m4, m0 ; sum *= rdiv >> >> >+addps m4, m1 ; sum += bias >> >> >> >> >+addps m4, m5 ; sum += 0.5 >> >> I don't know how about precision mismatch if we pre-compute (bias+0.5) >> >> >I think it is hard to prove it is safe to do pre-compute. >> Agree, I also worried precision issue since float operator is execute >> order >> dependent. >> How about ROUNDPS? > Seems no exactly match. >> >> >> > >> >> >> >> >> >> >+cvttps2dq m4, m4 >> >> >+packssdw m4, m4 >> >> >+packuswb m4, m4 >> >> >+movss [dstq + dst_offq], m4 >> >> >+add c_offq, mmsize/4 >> >> >+add dst_offq, mmsize/4 >> >> >+ >> >> >+add off16q, mmsize/4 >> >> >+cmp off16q, widthq >> >> >+jl .loop16 >> >> >+ >> >> >+add widthq, rq >> >> >+cmp off16q, widthq >> >> >+jge .paraend >> >> >+ >> >> >> >> >+.loopr: >> >> no idea about this loop, if we can read beyond, we can reuse above >> >> SIMD >> >> code >> >Reuse above SIMD code may write to the memory that does not belong to >> this slice-thread. >> >> >IMO, the code to handle remainder columns is still necessary. >> >> >> Depends on algorithm & size, >> For example width=23 >> Process #0 [0:15] >> Process #1 [7:22] >> Both of them is multiple of 16 > Sounds interesting. But FFmpeg does not do like this now. > One question is will this get a penalty for writing to same address of > memory (both are writing to 7-15) from different threads? Yes, and even bad results may happen. > >> >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH V3 2/2] lavf/libsrt: enable other encryption parameters
On Wed, Dec 04, 2019 at 10:46:44AM +0100, Moritz Barsnick wrote: > On Wed, Dec 04, 2019 at 10:20:00 +0800, myp...@gmail.com wrote: > > > > +{ "enforced_encryption", "Enforces that both connection > > > > parties have the same passphrase set ", OFFSET(enforced_encryption), > > > > AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, .flags = D|E }, > > > > > > is this intended to be INT and not AV_OPT_TYPE_BOOL ? > > > > Now -1 means auto (default value depend on libsrt library itself) , > > this is the reason don't use the AV_OPT_TYPE_BOOL same as other srt > > option in FFmpeg. > > AV_OPT_TYPE_BOOL accepts -1 as a default. Yes, I recall I have sumit a patch to change several flag to BOOL and haven't anybody review yet. I have tested -1 is accetable as default, please confirm it and review my old pending patch also. https://patchwork.ffmpeg.org/patch/15183/ > > Moritz > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH V3 2/2] lavf/libsrt: enable other encryption parameters
On Wed, Dec 4, 2019 at 5:46 PM Moritz Barsnick wrote: > > On Wed, Dec 04, 2019 at 10:20:00 +0800, myp...@gmail.com wrote: > > > > +{ "enforced_encryption", "Enforces that both connection > > > > parties have the same passphrase set ", OFFSET(enforced_encryption), > > > > AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, .flags = D|E }, > > > > > > is this intended to be INT and not AV_OPT_TYPE_BOOL ? > > > > Now -1 means auto (default value depend on libsrt library itself) , > > this is the reason don't use the AV_OPT_TYPE_BOOL same as other srt > > option in FFmpeg. > > AV_OPT_TYPE_BOOL accepts -1 as a default. > Will follow the comments, thx ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH V3 2/2] lavf/libsrt: enable other encryption parameters
On Wed, Dec 04, 2019 at 10:20:00 +0800, myp...@gmail.com wrote: > > > +{ "enforced_encryption", "Enforces that both connection parties > > > have the same passphrase set ", OFFSET(enforced_encryption), > > > AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, .flags = D|E }, > > > > is this intended to be INT and not AV_OPT_TYPE_BOOL ? > > Now -1 means auto (default value depend on libsrt library itself) , > this is the reason don't use the AV_OPT_TYPE_BOOL same as other srt > option in FFmpeg. AV_OPT_TYPE_BOOL accepts -1 as a default. Moritz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3] avfilter/buffersrc: deprecate sws_param option
quinkbl...@foxmail.com (12019-12-04): > From: Zhao Zhili > > --- > patch v3: document how to set the parameters for automatically inserted > filters. > > doc/filters.texi| 7 +++ > libavfilter/buffersrc.c | 14 -- > libavfilter/version.h | 5 - > 3 files changed, 19 insertions(+), 7 deletions(-) > > diff --git a/doc/filters.texi b/doc/filters.texi > index 5fdec6f015..7a700c7cc4 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -21014,9 +21014,8 @@ Specify the frame rate expected for the video stream. > The sample (pixel) aspect ratio of the input video. > > @item sws_param > -Specify the optional parameters to be used for the scale filter which > -is automatically inserted when an input change is detected in the > -input size or format. > +This option is deprecated and ignored. Use > @ref{sws_flags,,sws_flags,ffmpeg-scaler} > +instead to specify swscale flags for those automatically inserted scalers. It says what option to use, but it does not say HOW to use it. It seems to be set on the filter graph itself, but IIRC there is a syntax to do it. 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] avformat/cache: rename the class name fro Cache to cache
Because the protocol name is cache, but the class name is Cache. for example: ffmpeg -protocols will show: Supported file protocols: Input: async bluray cache concat crypto data ffrtmphttp file ftp gopher hls http httpproxy https mmsh mmst pipe rtmp rtmps rtmpt rtmpts rtp srtp subfile tcp tls udp udplite unix Output: crypto ffrtmphttp file ftp gopher http httpproxy https icecast md5 pipe prompeg rtmp rtmps rtmpt rtmpts rtp srtp tee tcp tls udp udplite unix But i cannot find the cache protocol in help message liuqideMacBook-Pro:build liuqi$ ffmpeg --help full | grep cache ffmpeg version N-95812-gd73f062706 Copyright (c) 2000-2019 the FFmpeg developers built with Apple LLVM version 10.0.0 (clang-1000.11.45.5) configuration: --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libspeex --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-version3 --enable-nonfree --enable-videotoolbox --enable-libxml2 --samples=fate-suite/ --enable-libopencv libavutil 56. 36.100 / 56. 36.100 libavcodec 58. 62.100 / 58. 62.100 libavformat58. 35.100 / 58. 35.100 libavdevice58. 9.101 / 58. 9.101 libavfilter 7. 66.100 / 7. 66.100 libswscale 5. 6.100 / 5. 6.100 libswresample 3. 6.100 / 3. 6.100 libpostproc55. 6.100 / 55. 6.100 -hls_allow_cache E. explicitly set whether the client MAY (1) or MUST NOT (0) cache media segments (from INT_MIN to INT_MAX) (default -1) -segment_list_flags E. set flags affecting segment list generation (default cache) cacheE. allow list caching -segment_list_flags E. set flags affecting segment list generation (default cache) cacheE. allow list caching frames..FV.. set number of frames in cache (from 2 to 512) (default 30) liuqideMacBook-Pro:build liuqi$ after patch: bogon:dash liuqi$ ./ffmpeg --help full | grep cache ffmpeg version N-95942-gece617e849 Copyright (c) 2000-2019 the FFmpeg developers built with Apple LLVM version 10.0.0 (clang-1000.11.45.5) configuration: --enable-fontconfig --enable-gpl --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libspeex --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-version3 --enable-nonfree --enable-videotoolbox --enable-libxml2 --samples=fate-suite/ --enable-libopencv --enable-libopus libavutil 56. 36.101 / 56. 36.101 libavcodec 58. 64.101 / 58. 64.101 libavformat58. 35.100 / 58. 35.100 libavdevice58. 9.101 / 58. 9.101 libavfilter 7. 67.100 / 7. 67.100 libswscale 5. 6.100 / 5. 6.100 libswresample 3. 6.100 / 3. 6.100 libpostproc55. 6.100 / 55. 6.100 cache AVOptions: -hls_allow_cache E. explicitly set whether the client MAY (1) or MUST NOT (0) cache media segments (from INT_MIN to INT_MAX) (default -1) -segment_list_flags E. set flags affecting segment list generation (default cache) cacheE. allow list caching -segment_list_flags E. set flags affecting segment list generation (default cache) cacheE. allow list caching frames..FV.. set number of frames in cache (from 2 to 512) (default 30) bogon:dash liuqi$ can find the cache AVOptions after patch. Signed-off-by: Steven Liu --- libavformat/cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/cache.c b/libavformat/cache.c index 3425be9350..09e5d5f832 100644 --- a/libavformat/cache.c +++ b/libavformat/cache.c @@ -326,7 +326,7 @@ static const AVOption options[] = { }; static const AVClass cache_context_class = { -.class_name = "Cache", +.class_name = "cache", .item_name = av_default_item_name, .option = options, .version= LIBAVUTIL_VERSION_INT, -- 2.15.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] avfilter/scale.c: factorize ff_scale_eval_dimensions
Will help reduce code duplication when adding animation support to vf_scale. See Michael's last comment in https://patchwork.ffmpeg.org/patch/16272/ Gyan From 138a8dba766674a1b017614c58fa99aeca98e9e5 Mon Sep 17 00:00:00 2001 From: Gyan Doshi Date: Mon, 2 Dec 2019 21:11:21 +0530 Subject: [PATCH] avfilter/scale.c: factorize ff_scale_eval_dimensions Adjustment of evaluated values shifted to ff_adjust_scale_dimensions Shifted code for force_original_aspect_ratio and force_divisble_by from vf_scale so it is now available for scale_cuda, scale_npp and scale_vaapi as well. --- doc/filters.texi | 40 libavfilter/scale.c | 59 +--- libavfilter/scale.h | 4 +++ libavfilter/vf_scale.c | 28 ++--- libavfilter/vf_scale_cuda.c | 11 +++ libavfilter/vf_scale_npp.c | 11 +++ libavfilter/vf_scale_vaapi.c | 11 +++ 7 files changed, 128 insertions(+), 36 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 5fdec6f015..9129f7e3a5 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16210,6 +16210,46 @@ Supersampling @item lanczos @end table +@item force_original_aspect_ratio +Enable decreasing or increasing output video width or height if necessary to +keep the original aspect ratio. Possible values: + +@table @samp +@item disable +Scale the video as specified and disable this feature. + +@item decrease +The output video dimensions will automatically be decreased if needed. + +@item increase +The output video dimensions will automatically be increased if needed. + +@end table + +One useful instance of this option is that when you know a specific device's +maximum allowed resolution, you can use this to limit the output video to +that, while retaining the aspect ratio. For example, device A allows +1280x720 playback, and your video is 1920x800. Using this option (set it to +decrease) and specifying 1280x720 to the command line makes the output +1280x533. + +Please note that this is a different thing than specifying -1 for @option{w} +or @option{h}, you still need to specify the output resolution for this option +to work. + +@item force_divisible_by +Ensures that both the output dimensions, width and height, are divisible by the +given integer when used together with @option{force_original_aspect_ratio}. This +works similar to using @code{-n} in the @option{w} and @option{h} options. + +This option respects the value set for @option{force_original_aspect_ratio}, +increasing or decreasing the resolution accordingly. The video's aspect ratio +may be slightly modified. + +This option can be handy if you need to have a video fit within or exceed +a defined resolution using @option{force_original_aspect_ratio} but also have +encoder restrictions on width or height divisibility. + @end table @section scale2ref diff --git a/libavfilter/scale.c b/libavfilter/scale.c index eaee95fac6..5e9f97230c 100644 --- a/libavfilter/scale.c +++ b/libavfilter/scale.c @@ -111,8 +111,6 @@ int ff_scale_eval_dimensions(void *log_ctx, const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); const AVPixFmtDescriptor *out_desc = av_pix_fmt_desc_get(outlink->format); const char *expr; -int w, h; -int factor_w, factor_h; int eval_w, eval_h; int ret; const char scale2ref = outlink->src->nb_inputs == 2 && outlink->src->inputs[1] == inlink; @@ -172,8 +170,28 @@ int ff_scale_eval_dimensions(void *log_ctx, goto fail; eval_w = (int) res == 0 ? inlink->w : (int) res; -w = eval_w; -h = eval_h; +*ret_w = eval_w; +*ret_h = eval_h; + +return 0; + +fail: +av_log(log_ctx, AV_LOG_ERROR, + "Error when evaluating the expression '%s'.\n" + "Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n", + expr, w_expr, h_expr); +return ret; +} + +int ff_scale_adjust_dimensions(AVFilterLink *inlink, +int *ret_w, int *ret_h, +int force_original_aspect_ratio, int force_divisible_by) +{ +int w, h; +int factor_w, factor_h; + +w = *ret_w; +h = *ret_h; /* Check if it is requested that the result has to be divisible by a some * factor (w or h = -n with n being the factor). */ @@ -199,15 +217,34 @@ int ff_scale_eval_dimensions(void *log_ctx, if (h < 0) h = av_rescale(w, inlink->h, inlink->w * factor_h) * factor_h; +/* Note that force_original_aspect_ratio may overwrite the previous set + * dimensions so that it is not divisible by the set factors anymore + * unless force_divisible_by is defined as well */ +if (force_original_aspect_ratio) { +int tmp_w = av_rescale(h, inlink->w, inlink->h); +int tmp_h = av_rescale(w, inlink->h, inlink->w); + +if (force_original_aspect_ratio == 1) { + w = FFMIN(tmp_w, w); + h = FFMIN(tmp_h, h); + if (force_divisible_by > 1) { +