[FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_convolution: Add x86 SIMD optimizations for filter_row()
From: Xu Jun Read 16 elements from memory, shuffle and parallally compute 4 rows at a time, shuffle and parallelly write 16 results to memory. Performance improves about 15% compared to v1. Tested using this command: ./ffmpeg_g -s 1280*720 -pix_fmt yuv420p -i test.yuv -vf convolution="1 2 3 4 5 6 7 8 9:1 2 3 4 5 6 7 8 9:1 2 3 4 5 6 7 8 9:1 2 3 4 5 6 7 8 9:1/45:1/45:1/45:1/45:1:2:3:4:row:row:row:row" -an -vframes 5000 -f null /dev/null -benchmark after patch: frame= 4317 fps=622 q=-0.0 Lsize=N/A time=00:02:52.68 bitrate=N/A speed=24.9x video:2260kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown bench: utime=20.539s stime=1.834s rtime=6.943s before patch(c version): frame= 4317 fps=306 q=-0.0 Lsize=N/A time=00:02:52.68 bitrate=N/A speed=12.2x video:2260kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown bench: utime=60.591s stime=1.787s rtime=14.100s Signed-off-by: Xu Jun --- libavfilter/x86/vf_convolution.asm| 131 ++ libavfilter/x86/vf_convolution_init.c | 9 ++ 2 files changed, 140 insertions(+) mode change 100644 => 100755 libavfilter/x86/vf_convolution.asm diff --git a/libavfilter/x86/vf_convolution.asm b/libavfilter/x86/vf_convolution.asm old mode 100644 new mode 100755 index 754d4d1064..2a09374b00 --- a/libavfilter/x86/vf_convolution.asm +++ b/libavfilter/x86/vf_convolution.asm @@ -154,3 +154,134 @@ cglobal filter_3x3, 4, 15, 7, dst, width, rdiv, bias, matrix, ptr, c0, c1, c2, c INIT_XMM sse4 FILTER_3X3 %endif + +; void filter_row_sse4(uint8_t *dst, int width, +; float rdiv, float bias, const int *const matrix, +; const uint8_t *c[], int peak, int radius, +; int dstride, int stride) + +%macro COMPUTE_4ROW 1 +pshufb m7, m6, m4 ; get 4 uint8s from the 16 uint8s +pmulld m7, m5 +paddd m1%1, m7 +%endmacro + +%macro CVT_PACK_ROW 1 +cvtdq2ps m1%1, m1%1 +mulps m1%1, m0 ; sum *= rdiv +addps m1%1, m1 ; sum += bias +addps m1%1, m3 ; sum += 0.5 +cvttps2dq m1%1, m1%1 +packssdw m1%1, m1%1 +packuswb m1%1, m1%1 +%endmacro + +%if ARCH_X86_64 +INIT_XMM sse4 +%if UNIX64 +cglobal filter_row, 6, 10, 14, dst, width, matrix, ptr, mult, rad, r, x, i, ci +%else +cglobal filter_row, 4, 10, 14, dst, width, rdiv, bias, matrix, ptr, mult, rad, r, x, i, ci +%endif + +%if WIN64 +SWAP m0, m2 +SWAP m1, m3 +mov r2q, matrixmp +mov r3q, ptrmp +mov r5q, radmp +DEFINE_ARGS dst, width, matrix, ptr, mult, rad, r, x, i, ci +%endif + +movsxdifnidn widthq, widthd +movsxdifnidn radq, radd +lea radq, [radq * 2 + 1] +VBROADCASTSS m0, m0 +VBROADCASTSS m1, m1 +pxor m2, m2 ; zero +movss m3, [half] +VBROADCASTSS m3, m3 ; 0.5 +movdqu m8, [shuf_init] ; shuffle initialization +movdqu m9, [shuf_step] ; shuffle step + +xor xq, xq +cmp widthq, mmsize +jl .less16 + +mov rq, widthq +and rq, mmsize-1 +sub widthq, rq + +.equal16: +pxor m10, m10 +pxor m11, m11 +pxor m12, m12 +pxor m13, m13 +; m10-13 hold sums + + lea iq, [radq - 1] +.loopi: +movd m5, [matrixq + 4*iq] ; matrix[i] +VBROADCASTSS m5, m5 +mov ciq, [ptrq + iq * gprsize] +movdqu m6, [ciq + xq] ; c[i][y*stride] 16 uint8s + +;m4 controls shuffle +movdqa m4, m8 +COMPUTE_4ROW 0 ; process 0-3 rows, sum in m10 +paddd m4, m9 +COMPUTE_4ROW 1 ; process 4-7 rows, sum in m11 +paddd m4, m9 +COMPUTE_4ROW 2 ; process 8-11 rows, sum in m12 +paddd m4, m9 +COMPUTE_4ROW 3 ; process 12-15 rows, sum in m13 + +sub iq, 1 +jns .loopi + +CVT_PACK_ROW 0 ; process 0-3 rows, result in m10's low 32bit +CVT_PACK_ROW 1 ; process 4-7 rows, result in m11's low 32bit +CVT_PACK_ROW 2 ; process 8-11 rows, result in m12's low 32bit +CVT_PACK_ROW 3 ; process 12-15 rows, result in m13's low 32bit +punpckldq m10, m11 +punpckldq m12, m13 +punpcklqdq m10, m12 ; pack 16 results in m10 +movdqu [dstq+xq], m10 + +add xq, mmsize +cmp xq, widthq +jl .equal16 + +add widthq, rq +cmp xq, widthq +jge .end + +.less16: +xor rd, rd +lea iq, [radq - 1] +.loopr_i: +mov ciq, [ptrq + iq * gprsize] +movzx multd, byte [ciq + xq] +imul multd, [matrixq + 4*iq] +add rd, multd + +sub iq, 1 +jns .loopr_i + +pxor m7, m7 +cvtsi2ss m7, rd +mulss m7, m0 ; sum *= rdiv +addss m7, m1 ; sum += bias +addss m7, m3 ; sum += 0.5 +cvttps2dq m7, m7 +packssdw m7, m7 +packuswb m7, m7 +movd rd, m7 +mov [dstq + xq], rb + +add xq, 1 +cmp xq, widthq +jl .less16 +.end: +RET +%endif diff --git a/libavfilter/x86/vf_convolution_init.c b/libavfilter/x86/vf_convolution_init.c index 51432406ed..5eb3b3bee1 100644 --- a/libavfilter/x86/vf_convolution_init.c +++ b/libavfilter/x86/vf_convolution_init.c @@ -29,6 +29,11 @@ void ff_filter_3x3_sse4(uint8_t *dst, int width,
[FFmpeg-devel] [PATCH v2 3/3] avfilter/vf_convolution: Add X86 SIMD optimizations for filter_column()
From: Xu Jun Performance improves about 10% compared to v1. Tested using this command: ./ffmpeg_g -s 1280*720 -pix_fmt yuv420p -i test.yuv -vf convolution="1 2 3 4 5 6 7 8 9:1 2 3 4 5 6 7 8 9:1 2 3 4 5 6 7 8 9:1 2 3 4 5 6 7 8 9:1/45:1/45:1/45:1/45:1:2:3:4:column:column:column:column" -an -vframes 5000 -f null /dev/null -benchmark after patch: frame= 4317 fps=600 q=-0.0 Lsize=N/A time=00:02:52.68 bitrate=N/A speed= 24x video:2260kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown bench: utime=21.540s stime=2.091s rtime=7.197s before patch: frame= 4317 fps=263 q=-0.0 Lsize=N/A time=00:02:52.68 bitrate=N/A speed=10.5x video:2260kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown bench: utime=74.377s stime=1.880s rtime=16.420s Signed-off-by: Xu Jun --- libavfilter/x86/vf_convolution.asm| 202 ++ libavfilter/x86/vf_convolution_init.c | 9 ++ 2 files changed, 211 insertions(+) diff --git a/libavfilter/x86/vf_convolution.asm b/libavfilter/x86/vf_convolution.asm index 2a09374b00..4c700656d6 100755 --- a/libavfilter/x86/vf_convolution.asm +++ b/libavfilter/x86/vf_convolution.asm @@ -22,6 +22,8 @@ SECTION_RODATA half: dd 0.5 +shuf_init: ddq 0x80808003808080028080800180808000 +shuf_step: ddq 0x0004000400040004 SECTION .text @@ -285,3 +287,203 @@ sub widthq, rq .end: RET %endif + +; 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); + +%macro COMPUTE_4COL 1 +pshufb m7, m6, m4; get 4 uint8s from the 16 uint8s +pmulld m7, m5 +paddd m1%1, m7 +%endmacro + +%macro CVT_PACK_COL 1 +cvtdq2ps m1%1, m1%1 +mulps m1%1, m0 ; sum *= rdiv +addps m1%1, m1 ; sum += bias +addps m1%1, m3 ; sum += 0.5 +cvttps2dq m1%1, m1%1 +packssdw m1%1, m1%1 +packuswb m1%1, m1%1 +%endmacro + +%if ARCH_X86_64 +INIT_XMM sse4 +%if UNIX64 +cglobal filter_column, 8, 14, 14, dst, height, matrix, ptr, width, rad, dstride, stride, \ +i, ci, ystride, sum, r, off16 +%else +cglobal filter_column, 8, 14, 14, dst, height, rdiv, bias, matrix, ptr, width, rad, dstride, stride, \ +i, ci, ystride, sum, r, off16 +%endif + +%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, ystride, sum, r, off16 +%endif + +movsxdifnidn widthq, widthd +movsxdifnidn radq, radd +lea radq, [radq * 2 + 1] +movsxdifnidn dstrideq, dstrided +movsxdifnidn strideq, strided +movsxdifnidn heightq, heightd + +VBROADCASTSS m0, m0; rdiv +VBROADCASTSS m1, m1; bias +pxor m2, m2; zero +movss m3, [half] +VBROADCASTSS m3, m3; 0.5 +movdqu m8, [shuf_init] ; shuffle initialization +movdqu m9, [shuf_step]; shuffle step + +xor ystrideq, ystrideq; y*stride + +cmp widthq, mmsize;if width<16 run loopr, width=16 run 16 parallel +jl .less16 + +.equal16: +pxor m10, m10 +pxor m11, m11 +pxor m12, m12 +pxor m13, m13 +; m10-13 hold sums + +lea iq, [radq - 1] +.loopi: +movd m5, [matrixq + 4*iq]; matrix[i] +VBROADCASTSS m5, m5 +mov ciq, [ptrq + iq * gprsize] +movdqu m6, [ciq + ystrideq]; c[i][y*stride] 16 uint8s + +;m4 controls shuffle +movdqa m4, m8 +COMPUTE_4COL 0; process 0-3 cols, sum in m10 +paddd m4, m9 +COMPUTE_4COL 1; process 4-7 cols, sum in m11 +paddd m4, m9 +COMPUTE_4COL 2; process 8-11 cols, sum in m12 +paddd m4, m9 +COMPUTE_4COL 3; process 12-15 cols, sum in m13 + +sub iq, 1 +jns .loopi + +CVT_PACK_COL 0; process 0-3 cols, result in m10's low 32bit +CVT_PACK_COL 1; process 4-7 cols, result in m11's low 32bit +CVT_PACK_COL 2; process 8-11 cols, result in m12's low 32bit +CVT_PACK_COL 3; process 12-15 cols, result in m13's low 32bit +punpckldq m10, m11 +punpckldq m12, m13 +punpcklqdq m10, m12; pack 16 results in m10 +movdqu [dstq], m10 + +add dstq, dstrideq +add ystrideq, strideq +sub heightq, 1 +jnz .equal16 +jmp .end + +.less16: +xor off16q, off16q +cmp widthq, mmsize/4 +jl .loopr + +mov rq, widthq +and rq, mmsize/4-1 +sub widthq, rq + +pxor m10, m10 +pxor m11, m11 +pxor m12, m12 + +lea iq, [radq - 1] +.loopi_4: +movd m5, [matrixq + 4*iq]; matrix[i] +VBROADCASTSS m5, m5 +mov ciq, [ptrq + iq * gprsize] +movdqu m6, [ciq + ystrideq]; c[i][y*stride] 16 uint8s + +;m4 controls shuffle +movdqa m4, m8 +COMPUTE_4COL 0; process
[FFmpeg-devel] [PATCH v2 1/3] avfilter/vf_convolution: add 16-column operation for filter_column() and modify filter_slice().
From: chen Replace the existing C code for filter_column() with chen's code. Modify filter_slice() to be compatible with this change. Tested using the command: ./ffmpeg_g -s 1280*720 -pix_fmt yuv420p -i test.yuv -vf convolution="1 2 3 4 5 6 7 8 9:1 2 3 4 5 6 7 8 9:1 2 3 4 5 6 7 8 9:1 2 3 4 5 6 7 8 9:1/45:1/45:1/45:1/45:1:2:3:4:column:column:column:column" -an -vframes 5000 -f null /dev/null -benchmark after patch: frame= 4317 fps=271 q=-0.0 Lsize=N/A time=00:02:52.68 bitrate=N/A speed=10.8x video:2260kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown bench: utime=76.097s stime=1.676s rtime=15.929s bench: maxrss=15160kB before patch: frame= 4317 fps=192 q=-0.0 Lsize=N/A time=00:02:52.68 bitrate=N/A speed= 7.7x video:2260kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown bench: utime=104.253s stime=2.668s rtime=22.426s bench: maxrss=15216kB Signed-off-by: Xu Jun --- libavfilter/vf_convolution.c | 36 +--- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c index 5909feaad1..bc816b58bb 100644 --- a/libavfilter/vf_convolution.c +++ b/libavfilter/vf_convolution.c @@ -24,6 +24,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" +#include "libavutil/avassert.h" #include "avfilter.h" #include "convolution.h" #include "formats.h" @@ -389,19 +390,29 @@ static void filter_row(uint8_t *dst, int width, static void filter_column(uint8_t *dst, int height, float rdiv, float bias, const int *const matrix, - const uint8_t *c[], int peak, int radius, + const uint8_t *c[], int length, int radius, int dstride, int stride) { -int y; +int y, off16; + +av_assert2(length <= 16); +// NOTE: alignment to 64-bytes, so 16 of int can be fill into full of a cache line +DECLARE_ALIGNED(64, int, sum)[16]; for (y = 0; y < height; y++) { -int i, sum = 0; +int i; +memset(sum, 0, sizeof(sum)); -for (i = 0; i < 2 * radius + 1; i++) -sum += c[i][0 + y * stride] * matrix[i]; +for (i = 0; i < 2 * radius + 1; i++) { +for (off16 = 0; off16 < length; off16++) { +sum[off16] += c[i][0 + y * stride + off16] * matrix[i]; +} +} -sum = (int)(sum * rdiv + bias + 0.5f); -dst[0] = av_clip_uint8(sum); +for (off16 = 0; off16 < length; off16++) { +sum[off16] = (int)(sum[off16] * rdiv + bias + 0.5f); +dst[off16] = av_clip_uint8(sum[off16]); +} dst += dstride; } } @@ -521,7 +532,10 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) continue; } -for (y = slice_start; y < slice_end; y++) { +const int step = mode == MATRIX_COLUMN ? 16 : 1; +int smax = mode == MATRIX_COLUMN ? 16: s->max; +for (y = slice_start; y < slice_end; y += step) { +if (mode == MATRIX_COLUMN && slice_end - y < 16) smax = slice_end - y; const int xoff = mode == MATRIX_COLUMN ? (y - slice_start) * bpc : radius * bpc; const int yoff = mode == MATRIX_COLUMN ? radius * stride : 0; @@ -531,12 +545,12 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) s->setup[plane](radius, c, src, stride, x, width, y, height, bpc); s->filter[plane](dst + yoff + xoff, 1, rdiv, - bias, matrix, c, s->max, radius, + bias, matrix, c, smax, radius, dstride, stride); } s->setup[plane](radius, c, src, stride, radius, width, y, height, bpc); s->filter[plane](dst + yoff + xoff, sizew - 2 * radius, - rdiv, bias, matrix, c, s->max, radius, + rdiv, bias, matrix, c, smax, radius, dstride, stride); for (x = sizew - radius; x < sizew; x++) { const int xoff = mode == MATRIX_COLUMN ? (y - slice_start) * bpc : x * bpc; @@ -544,7 +558,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) s->setup[plane](radius, c, src, stride, x, width, y, height, bpc); s->filter[plane](dst + yoff + xoff, 1, rdiv, - bias, matrix, c, s->max, radius, + bias, matrix, c, smax, radius, dstride, stride); } if (mode != MATRIX_COLUMN) -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listi
[FFmpeg-devel] [DISCUSS]
Hi, I would like to work on a "per output" -progress option in order to get real-time encoding reports for multiple outputs encoding. I will try to implement this myself but before putting my hands on it I wanted to discuss about the different solutions with the community. I have three of them in mind Proposition 1. to put all output progress feedback in the same progress payload Proposition 2.to change the behavior of the progress option. make it an output option instead of a global option Proposition 3.to create a new per output progress option in order to do not break the current API I also wanted to add the duration of each output in the progress payload. Actually we can not infer the duration from the frame count because we are not always aware of the framerate. Does it seem relevant to you? 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".
Re: [FFmpeg-devel] [PATCH] Fix spelling in ID3v1 genres and extend the list of Winamp extensions.
Am Sa., 21. Dez. 2019 um 09:07 Uhr schrieb Ulrich Spörlein : > > Source: https://en.wikipedia.org/wiki/List_of_ID3v1_Genres and taglib. > > Further patches to harmonize the spelling have been sent to taglib and > libid3tag. > --- > Note that neither taglib nor libid3tag use the typos for Psychedelic or > A cappella. Preserving these typos is IMHO not worth it, spec be damned. > > libavformat/id3v1.c | 58 +++-- > libavformat/id3v1.h | 2 +- > 2 files changed, 52 insertions(+), 8 deletions(-) > > diff --git a/libavformat/id3v1.c b/libavformat/id3v1.c > index 19be42121d..eb66098f51 100644 > --- a/libavformat/id3v1.c > +++ b/libavformat/id3v1.c > @@ -92,7 +92,7 @@ const char * const ff_id3v1_genre_str[ID3v1_GENRE_MAX + 1] > = { > [64] = "Native American", > [65] = "Cabaret", > [66] = "New Wave", > - [67] = "Psychadelic", /* sic, the misspelling is used in the > specification */ > + [67] = "Psychedelic", > [68] = "Rave", > [69] = "Showtunes", > [70] = "Trailer", > @@ -110,7 +110,7 @@ const char * const ff_id3v1_genre_str[ID3v1_GENRE_MAX + > 1] = { > [82] = "National Folk", > [83] = "Swing", > [84] = "Fast Fusion", > - [85] = "Bebob", > + [85] = "Bebop", > [86] = "Latin", > [87] = "Revival", > [88] = "Celtic", > @@ -148,20 +148,20 @@ const char * const ff_id3v1_genre_str[ID3v1_GENRE_MAX + > 1] = { > [120] = "Duet", > [121] = "Punk Rock", > [122] = "Drum Solo", > -[123] = "A capella", > +[123] = "A Cappella", > [124] = "Euro-House", > [125] = "Dance Hall", > [126] = "Goa", > [127] = "Drum & Bass", > [128] = "Club-House", > -[129] = "Hardcore", > +[129] = "Hardcore Techno", > [130] = "Terror", > [131] = "Indie", > [132] = "BritPop", > [133] = "Negerpunk", > [134] = "Polsk Punk", > [135] = "Beat", > -[136] = "Christian Gangsta", > +[136] = "Christian Gangsta Rap", > [137] = "Heavy Metal", > [138] = "Black Metal", > [139] = "Crossover", > @@ -171,8 +171,52 @@ const char * const ff_id3v1_genre_str[ID3v1_GENRE_MAX + > 1] = { > [143] = "Salsa", > [144] = "Thrash Metal", > [145] = "Anime", > -[146] = "JPop", > -[147] = "SynthPop", > +[146] = "Jpop", > +[147] = "Synthpop", > +[148] = "Abstract", > +[149] = "Art Rock", > +[150] = "Baroque", > +[151] = "Bhangra", > +[152] = "Big Beat", > +[153] = "Breakbeat", > +[154] = "Chillout", > +[155] = "Downtempo", > +[156] = "Dub", > +[157] = "EBM", > +[158] = "Eclectic", > +[159] = "Electro", > +[160] = "Electroclash", > +[161] = "Emo", > +[162] = "Experimental", > +[163] = "Garage", > +[164] = "Global", > +[165] = "IDM", > +[166] = "Illbient", > +[167] = "Industro-Goth", > +[168] = "Jam Band", > +[169] = "Krautrock", > +[170] = "Leftfield", > +[171] = "Lounge", > +[172] = "Math Rock", > +[173] = "New Romantic", > +[174] = "Nu-Breakz", > +[175] = "Post-Punk", > +[176] = "Post-Rock", > +[177] = "Psytrance", > +[178] = "Shoegaze", > +[179] = "Space Rock", > +[180] = "Trop Rock", > +[181] = "World Music", > +[182] = "Neoclassical", > +[183] = "Audiobook", > +[184] = "Audio Theatre", > +[185] = "Neue Deutsche Welle", > +[186] = "Podcast", > +[187] = "Indie Rock", > +[188] = "G-Funk", > +[189] = "Dubstep", > +[190] = "Garage Rock", > +[191] = "Psybient" > }; > > static void get_string(AVFormatContext *s, const char *key, > diff --git a/libavformat/id3v1.h b/libavformat/id3v1.h > index d5dca35873..b3ad16df6c 100644 > --- a/libavformat/id3v1.h > +++ b/libavformat/id3v1.h > @@ -26,7 +26,7 @@ > > #define ID3v1_TAG_SIZE 128 > > -#define ID3v1_GENRE_MAX 147 > +#define ID3v1_GENRE_MAX 191 > > /** > * ID3v1 genres > -- > 2.24.0 > please keep me CC'ed on emails taglib is using the same extended WinAmp genre IDs. And you can find these in various places over the web. Obviously, I don't have access to Winamp's source code nor is that spec being published widely, being defunct and all. https://github.com/taglib/taglib/blob/master/taglib/mpeg/id3v1/id3v1genres.cpp Here's a printed copy: https://books.google.de/books?id=kvIoDwAAQBAJ&pg=PA6457&lpg=PA6457&dq=winamp+genre&source=bl&ots=eRknt5u6HS&sig=ACfU3U3heV82sGD9-mWaLi5Tv0-pBI89PQ&hl=de&sa=X&ved=2ahUKEwiEo8-wj8nmAhUNT8AKHd0QAMMQ6AEwB3oECAkQAQ#v=onepage&q=winamp%20genre&f=false Cheers Uli ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v1] avcodec/mpeg12dec: switch to AVBufferRef buffer for a53 caption
From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/mpeg12dec.c | 73 +++--- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 775579f..86cdebd 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -57,8 +57,7 @@ typedef struct Mpeg1Context { AVPanScan pan_scan; /* some temporary storage for the panscan */ AVStereo3D stereo3d; int has_stereo3d; -uint8_t *a53_caption; -int a53_caption_size; +AVBufferRef *a53_buf_ref; uint8_t afd; int has_afd; int slice_count; @@ -1630,13 +1629,13 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size) return AVERROR(ENOMEM); memcpy(pan_scan->data, &s1->pan_scan, sizeof(s1->pan_scan)); -if (s1->a53_caption) { -AVFrameSideData *sd = av_frame_new_side_data( +if (s1->a53_buf_ref) { +AVFrameSideData *sd = av_frame_new_side_data_from_buf( s->current_picture_ptr->f, AV_FRAME_DATA_A53_CC, -s1->a53_caption_size); -if (sd) -memcpy(sd->data, s1->a53_caption, s1->a53_caption_size); -av_freep(&s1->a53_caption); +s1->a53_buf_ref); +if (!sd) +av_buffer_unref(&s1->a53_buf_ref); +s1->a53_buf_ref = NULL; } if (s1->has_stereo3d) { @@ -2238,14 +2237,18 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx, /* extract A53 Part 4 CC data */ int cc_count = p[5] & 0x1f; if (cc_count > 0 && buf_size >= 7 + cc_count * 3) { -av_freep(&s1->a53_caption); -s1->a53_caption_size = cc_count * 3; -s1->a53_caption = av_malloc(s1->a53_caption_size); -if (!s1->a53_caption) { -s1->a53_caption_size = 0; -} else { -memcpy(s1->a53_caption, p + 7, s1->a53_caption_size); -} +int old_size = s1->a53_buf_ref ? s1->a53_buf_ref->size : 0; +const uint64_t new_size = (old_size + cc_count +* UINT64_C(3)); +int ret; + +if (new_size > INT_MAX) +return AVERROR(EINVAL); + +ret = av_buffer_realloc(&s1->a53_buf_ref, new_size); +if (ret >= 0) +memcpy(s1->a53_buf_ref->data + old_size, p + 7, cc_count * UINT64_C(3)); + avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; } return 1; @@ -2254,19 +2257,21 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx, /* extract SCTE-20 CC data */ GetBitContext gb; int cc_count = 0; -int i; +int i, ret; init_get_bits(&gb, p + 2, buf_size - 2); cc_count = get_bits(&gb, 5); if (cc_count > 0) { -av_freep(&s1->a53_caption); -s1->a53_caption_size = cc_count * 3; -s1->a53_caption = av_mallocz(s1->a53_caption_size); -if (!s1->a53_caption) { -s1->a53_caption_size = 0; -} else { +int old_size = s1->a53_buf_ref ? s1->a53_buf_ref->size : 0; +const uint64_t new_size = (old_size + cc_count +* UINT64_C(3)); +if (new_size > INT_MAX) +return AVERROR(EINVAL); + +ret = av_buffer_realloc(&s1->a53_buf_ref, new_size); +if (ret >= 0) { uint8_t field, cc1, cc2; -uint8_t *cap = s1->a53_caption; +uint8_t *cap = s1->a53_buf_ref->data; for (i = 0; i < cc_count && get_bits_left(&gb) >= 26; i++) { skip_bits(&gb, 2); // priority field = get_bits(&gb, 2); @@ -2318,21 +2323,23 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx, * on the even field. There also exist DVDs in the wild that encode an odd field count and the * caption_extra_field_added/caption_odd_field_first bits change per packet to allow that. */ int cc_count = 0; -int i; +int i, ret; // There is a caption count field in the data, but it is often // incorrect. So count the number of captions present. for (i = 5; i + 6 <= buf_size && ((p[i] & 0xfe) == 0xfe); i += 6) cc_count++; // Transform the DVD format into A53 Part 4 format if (cc_count > 0) { -av_freep(&s1->a53_caption); -s1->a53_caption_size = cc_count * 6; -s1->a53_caption = av_malloc(s1->a53_caption_size); -if (!s1->a53_caption) { -s1->a53_caption_size = 0; -} else { +int old_size = s1->a53_buf_ref ? s1->a53_buf_ref->size : 0; +const uint64_t new_size = (old_size + cc_count +
[FFmpeg-devel] [PATCH] lavc/midivid: FIX CID 1456088
Signed-off-by: Zhong Li --- libavcodec/midivid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/midivid.c b/libavcodec/midivid.c index 38465c5..6877c60 100644 --- a/libavcodec/midivid.c +++ b/libavcodec/midivid.c @@ -73,7 +73,8 @@ static int decode_mvdv(MidiVidContext *s, AVCodecContext *avctx, AVFrame *frame) if (bytestream2_get_bytes_left(gb) < mask_size) return AVERROR_INVALIDDATA; -init_get_bits8(&mask, mask_start, mask_size); +if (init_get_bits8(&mask, mask_start, mask_size) < 0) +return AVERROR_INVALIDDATA; bytestream2_skip(gb, mask_size); skip = s->skip; -- 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".
Re: [FFmpeg-devel] [PATCH] lavc/midivid: FIX CID 1456088
Not ok, please use ret variable. On 12/22/19, Zhong Li wrote: > Signed-off-by: Zhong Li > --- > libavcodec/midivid.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/midivid.c b/libavcodec/midivid.c > index 38465c5..6877c60 100644 > --- a/libavcodec/midivid.c > +++ b/libavcodec/midivid.c > @@ -73,7 +73,8 @@ static int decode_mvdv(MidiVidContext *s, AVCodecContext > *avctx, AVFrame *frame) > if (bytestream2_get_bytes_left(gb) < mask_size) > return AVERROR_INVALIDDATA; > > -init_get_bits8(&mask, mask_start, mask_size); > +if (init_get_bits8(&mask, mask_start, mask_size) < 0) > +return AVERROR_INVALIDDATA; > bytestream2_skip(gb, mask_size); > skip = s->skip; > > -- > 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 mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/wmavoice: sanity check block_align
This limit is roughly based on the bitreader limit, its likely a much tighter limit could be used Fixes: left shift of 1965039647 by 1 places cannot be represented in type 'int' Fixes: 19545/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMAVOICE_fuzzer-5695391899320320 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/wmavoice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index c61ecfbe3b..f6550c6a71 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -386,7 +386,7 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx) ctx->extradata_size); return AVERROR_INVALIDDATA; } -if (ctx->block_align <= 0) { +if (ctx->block_align <= 0 || ctx->block_align > (1<<22)) { av_log(ctx, AV_LOG_ERROR, "Invalid block alignment %d.\n", ctx->block_align); return AVERROR_INVALIDDATA; } -- 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".
[FFmpeg-devel] [PATCH V2] lavc/midivid: FIX CID 1456088
Signed-off-by: Zhong Li --- libavcodec/midivid.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavcodec/midivid.c b/libavcodec/midivid.c index 38465c5..3dac3f1 100644 --- a/libavcodec/midivid.c +++ b/libavcodec/midivid.c @@ -63,17 +63,20 @@ static int decode_mvdv(MidiVidContext *s, AVCodecContext *avctx, AVFrame *frame) if (intra_flag) { nb_blocks = (avctx->width / 2) * (avctx->height / 2); } else { -int skip_linesize; +int ret, skip_linesize; nb_blocks = bytestream2_get_le32(gb); skip_linesize = avctx->width >> 1; mask_start = gb->buffer_start + bytestream2_tell(gb); mask_size = (avctx->width >> 5) * (avctx->height >> 2); -if (bytestream2_get_bytes_left(gb) < mask_size) +ret = bytestream2_get_bytes_left(gb); +if (ret < mask_size) return AVERROR_INVALIDDATA; -init_get_bits8(&mask, mask_start, mask_size); +ret = init_get_bits8(&mask, mask_start, mask_size); +if (ret < 0) +return AVERROR_INVALIDDATA; bytestream2_skip(gb, mask_size); skip = s->skip; -- 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".
Re: [FFmpeg-devel] [PATCH V2] lavc/midivid: FIX CID 1456088
On 12/22/2019 12:26 PM, Zhong Li wrote: > Signed-off-by: Zhong Li > --- > libavcodec/midivid.c | 9 ++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/midivid.c b/libavcodec/midivid.c > index 38465c5..3dac3f1 100644 > --- a/libavcodec/midivid.c > +++ b/libavcodec/midivid.c > @@ -63,17 +63,20 @@ static int decode_mvdv(MidiVidContext *s, AVCodecContext > *avctx, AVFrame *frame) > if (intra_flag) { > nb_blocks = (avctx->width / 2) * (avctx->height / 2); > } else { > -int skip_linesize; > +int ret, skip_linesize; > > nb_blocks = bytestream2_get_le32(gb); > skip_linesize = avctx->width >> 1; > mask_start = gb->buffer_start + bytestream2_tell(gb); > mask_size = (avctx->width >> 5) * (avctx->height >> 2); > > -if (bytestream2_get_bytes_left(gb) < mask_size) > +ret = bytestream2_get_bytes_left(gb); > +if (ret < mask_size) What is this fixing? > return AVERROR_INVALIDDATA; > > -init_get_bits8(&mask, mask_start, mask_size); > +ret = init_get_bits8(&mask, mask_start, mask_size); > +if (ret < 0) > +return AVERROR_INVALIDDATA; > bytestream2_skip(gb, mask_size); > skip = s->skip; > > ___ ffmpeg-devel mailing list ffmpeg-devel@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 11/15] avformat/movenc: add a flag to enable CMAF compatability
James, On Sat, 21. Dec 15:02, James Almer wrote: > Sets some required constrains and reports compatibility with the relevant > compatible brand. > > Signed-off-by: James Almer > --- > libavformat/movenc.c | 25 +++-- > libavformat/movenc.h | 1 + > 2 files changed, 24 insertions(+), 2 deletions(-) > Fate is failing from patch 11-15: https://unofficial.patchwork-ffmpeg.org/project/FFmpeg/list/?series=25 -- 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 v2 2/3] avfilter/vf_convolution: Add x86 SIMD optimizations for filter_row()
Xu, On Sun, 22. Dec 16:37, xuju...@sjtu.edu.cn wrote: > From: Xu Jun > > Read 16 elements from memory, shuffle and parallally compute 4 rows at a > time, shuffle and parallelly write 16 results to memory. > Performance improves about 15% compared to v1. > > Tested using this command: > ./ffmpeg_g -s 1280*720 -pix_fmt yuv420p -i test.yuv -vf convolution="1 2 3 4 > 5 6 7 8 9:1 2 3 4 5 6 7 8 9:1 2 3 4 5 6 7 8 9:1 2 3 4 5 6 7 8 > 9:1/45:1/45:1/45:1/45:1:2:3:4:row:row:row:row" -an -vframes 5000 -f null > /dev/null -benchmark > > after patch: > frame= 4317 fps=622 q=-0.0 Lsize=N/A time=00:02:52.68 bitrate=N/A speed=24.9x > video:2260kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB > muxing overhead: unknown > bench: utime=20.539s stime=1.834s rtime=6.943s > > before patch(c version): > frame= 4317 fps=306 q=-0.0 Lsize=N/A time=00:02:52.68 bitrate=N/A speed=12.2x > video:2260kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB > muxing overhead: unknown > bench: utime=60.591s stime=1.787s rtime=14.100s > > Signed-off-by: Xu Jun > --- > libavfilter/x86/vf_convolution.asm| 131 ++ > libavfilter/x86/vf_convolution_init.c | 9 ++ > 2 files changed, 140 insertions(+) > mode change 100644 => 100755 libavfilter/x86/vf_convolution.asm > > diff --git a/libavfilter/x86/vf_convolution.asm > b/libavfilter/x86/vf_convolution.asm > old mode 100644 > new mode 100755 > index 754d4d1064..2a09374b00 > --- a/libavfilter/x86/vf_convolution.asm > +++ b/libavfilter/x86/vf_convolution.asm > @@ -154,3 +154,134 @@ cglobal filter_3x3, 4, 15, 7, dst, width, rdiv, bias, > matrix, ptr, c0, c1, c2, c > INIT_XMM sse4 > FILTER_3X3 > %endif > + Patch 2-3 are failing to build: https://unofficial.patchwork-ffmpeg.org/project/FFmpeg/list/?series=26 -- 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] avcodec/mpeg12dec: switch to AVBufferRef buffer for a53 caption
On Sun, 22 Dec 2019 at 13:27, wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavcodec/mpeg12dec.c | 73 > +++--- > 1 file changed, 40 insertions(+), 33 deletions(-) > Does this fix a particular issue? My patch to H.264 fixed a particular case of field mode captions but this doesn't look like it fixes it? Kieran ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] Fix spelling in ID3v1 genres and extend the list of Winamp extensions.
On Sun, Dec 22, 2019 at 12:18:28PM +0100, Ulrich Spörlein wrote: > Am Sa., 21. Dez. 2019 um 09:07 Uhr schrieb Ulrich Spörlein > : > > > > Source: https://en.wikipedia.org/wiki/List_of_ID3v1_Genres and taglib. > > > > Further patches to harmonize the spelling have been sent to taglib and > > libid3tag. > > --- > > Note that neither taglib nor libid3tag use the typos for Psychedelic or > > A cappella. Preserving these typos is IMHO not worth it, spec be damned. > > > > libavformat/id3v1.c | 58 +++-- > > libavformat/id3v1.h | 2 +- > > 2 files changed, 52 insertions(+), 8 deletions(-) > > > > diff --git a/libavformat/id3v1.c b/libavformat/id3v1.c > > index 19be42121d..eb66098f51 100644 > > --- a/libavformat/id3v1.c > > +++ b/libavformat/id3v1.c > > @@ -92,7 +92,7 @@ const char * const ff_id3v1_genre_str[ID3v1_GENRE_MAX + > > 1] = { > > [64] = "Native American", > > [65] = "Cabaret", > > [66] = "New Wave", > > - [67] = "Psychadelic", /* sic, the misspelling is used in the > > specification */ > > + [67] = "Psychedelic", > > [68] = "Rave", > > [69] = "Showtunes", > > [70] = "Trailer", > > @@ -110,7 +110,7 @@ const char * const ff_id3v1_genre_str[ID3v1_GENRE_MAX + > > 1] = { > > [82] = "National Folk", > > [83] = "Swing", > > [84] = "Fast Fusion", > > - [85] = "Bebob", > > + [85] = "Bebop", > > [86] = "Latin", > > [87] = "Revival", > > [88] = "Celtic", > > @@ -148,20 +148,20 @@ const char * const ff_id3v1_genre_str[ID3v1_GENRE_MAX > > + 1] = { > > [120] = "Duet", > > [121] = "Punk Rock", > > [122] = "Drum Solo", > > -[123] = "A capella", > > +[123] = "A Cappella", > > [124] = "Euro-House", > > [125] = "Dance Hall", > > [126] = "Goa", > > [127] = "Drum & Bass", > > [128] = "Club-House", > > -[129] = "Hardcore", > > +[129] = "Hardcore Techno", > > [130] = "Terror", > > [131] = "Indie", > > [132] = "BritPop", > > [133] = "Negerpunk", > > [134] = "Polsk Punk", > > [135] = "Beat", > > -[136] = "Christian Gangsta", > > +[136] = "Christian Gangsta Rap", > > [137] = "Heavy Metal", > > [138] = "Black Metal", > > [139] = "Crossover", > > @@ -171,8 +171,52 @@ const char * const ff_id3v1_genre_str[ID3v1_GENRE_MAX > > + 1] = { > > [143] = "Salsa", > > [144] = "Thrash Metal", > > [145] = "Anime", > > -[146] = "JPop", > > -[147] = "SynthPop", > > +[146] = "Jpop", > > +[147] = "Synthpop", > > +[148] = "Abstract", > > +[149] = "Art Rock", > > +[150] = "Baroque", > > +[151] = "Bhangra", > > +[152] = "Big Beat", > > +[153] = "Breakbeat", > > +[154] = "Chillout", > > +[155] = "Downtempo", > > +[156] = "Dub", > > +[157] = "EBM", > > +[158] = "Eclectic", > > +[159] = "Electro", > > +[160] = "Electroclash", > > +[161] = "Emo", > > +[162] = "Experimental", > > +[163] = "Garage", > > +[164] = "Global", > > +[165] = "IDM", > > +[166] = "Illbient", > > +[167] = "Industro-Goth", > > +[168] = "Jam Band", > > +[169] = "Krautrock", > > +[170] = "Leftfield", > > +[171] = "Lounge", > > +[172] = "Math Rock", > > +[173] = "New Romantic", > > +[174] = "Nu-Breakz", > > +[175] = "Post-Punk", > > +[176] = "Post-Rock", > > +[177] = "Psytrance", > > +[178] = "Shoegaze", > > +[179] = "Space Rock", > > +[180] = "Trop Rock", > > +[181] = "World Music", > > +[182] = "Neoclassical", > > +[183] = "Audiobook", > > +[184] = "Audio Theatre", > > +[185] = "Neue Deutsche Welle", > > +[186] = "Podcast", > > +[187] = "Indie Rock", > > +[188] = "G-Funk", > > +[189] = "Dubstep", > > +[190] = "Garage Rock", > > +[191] = "Psybient" > > }; > > > > static void get_string(AVFormatContext *s, const char *key, > > diff --git a/libavformat/id3v1.h b/libavformat/id3v1.h > > index d5dca35873..b3ad16df6c 100644 > > --- a/libavformat/id3v1.h > > +++ b/libavformat/id3v1.h > > @@ -26,7 +26,7 @@ > > > > #define ID3v1_TAG_SIZE 128 > > > > -#define ID3v1_GENRE_MAX 147 > > +#define ID3v1_GENRE_MAX 191 > > > > /** > > * ID3v1 genres > > -- > > 2.24.0 > > > > > please keep me CC'ed on emails > > taglib is using the same extended WinAmp genre IDs. And you can find > these in various places over the web. Obviously, I don't have access > to Winamp's source code nor is that spec being published widely, being > defunct and all. > https://github.com/taglib/taglib/blob/master/taglib/mpeg/id3v1/id3v1genres.cpp a reference to a VCS should include the version similarly for wikipedia some revission of the page should be mentioned in the commit message [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Everything should be made as simple as possible, but not simpler. -- Albert Einstein signature.asc Descript
[FFmpeg-devel] [PATCHv2 1/2] avutil/buffer: add av_buffer_pool_buffer_get_opaque
In order to access the original opaque parameter of a buffer in the buffer pool. (The buffer pool implementation overrides the normal opaque parameter but also saves it so it is accessible). v2: add assertion check before dereferencing the BufferPoolEntry. Signed-off-by: Marton Balint --- doc/APIchanges | 3 +++ libavutil/buffer.c | 8 libavutil/buffer.h | 13 + libavutil/version.h | 4 ++-- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 401c65a753..5b8d801f06 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2019-12-xx - xx - lavu 56.37.100 - buffer.h + Add av_buffer_pool_buffer_get_opaque(). + 2019-11-17 - 1c23abc88f - lavu 56.36.100 - eval API Add av_expr_count_vars(). diff --git a/libavutil/buffer.c b/libavutil/buffer.c index f0034b026a..6d9cb7428e 100644 --- a/libavutil/buffer.c +++ b/libavutil/buffer.c @@ -20,6 +20,7 @@ #include #include +#include "avassert.h" #include "buffer_internal.h" #include "common.h" #include "mem.h" @@ -355,3 +356,10 @@ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool) return ret; } + +void *av_buffer_pool_buffer_get_opaque(AVBufferRef *ref) +{ +BufferPoolEntry *buf = ref->buffer->opaque; +av_assert0(buf); +return buf->opaque; +} diff --git a/libavutil/buffer.h b/libavutil/buffer.h index 73b6bd0b14..e0f94314f4 100644 --- a/libavutil/buffer.h +++ b/libavutil/buffer.h @@ -284,6 +284,19 @@ void av_buffer_pool_uninit(AVBufferPool **pool); */ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool); +/** + * Query the original opaque parameter of an allocated buffer in the pool. + * + * @param ref a buffer reference to a buffer returned by av_buffer_pool_get. + * @return the opaque parameter set by the buffer allocator function of the + * buffer pool. + * + * @note the opaque parameter of ref is used by the buffer pool implementation, + * therefore you have to use this function to access the original opaque + * parameter of an allocated buffer. + */ +void *av_buffer_pool_buffer_get_opaque(AVBufferRef *ref); + /** * @} */ diff --git a/libavutil/version.h b/libavutil/version.h index e18163388d..4de0fa1fc3 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 LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ -- 2.16.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 V4] avfilter: Add tonemap vaapi filter for H2S
On Thu, 12 Dec 2019, Ruiling Song wrote: From: Xinpeng Sun It performs HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion with tone-mapping. It only supports HDR10 as input temporarily. An example command to use this filter with vaapi codecs: FFMPEG -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format vaapi \ -i INPUT -vf 'tonemap_vaapi=format=p010' -c:v hevc_vaapi -profile 2 OUTPUT Signed-off-by: Xinpeng Sun Signed-off-by: Zachary Zhou Signed-off-by: Ruiling Song --- When I re-think about the document part. I find it is not necessary to repeat how to set up vaapi device in this filter part. There is already good explanation of it(https://trac.ffmpeg.org/wiki/Hardware/VAAPI), so I add a link to it. I only make code changes requested by Vittoria and me. So if no further comment, I am going to apply the patch next week. Thanks! Ruiling configure | 2 + doc/filters.texi | 59 + libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_tonemap_vaapi.c | 419 + 5 files changed, 482 insertions(+) create mode 100644 libavfilter/vf_tonemap_vaapi.c diff --git a/configure b/configure index 42e7df3941..74f2d38317 100755 --- a/configure +++ b/configure @@ -3576,6 +3576,7 @@ tinterlace_filter_deps="gpl" tinterlace_merge_test_deps="tinterlace_filter" tinterlace_pad_test_deps="tinterlace_filter" tonemap_filter_deps="const_nan" +tonemap_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer_output_hdr_metadata" tonemap_opencl_filter_deps="opencl const_nan" transpose_opencl_filter_deps="opencl" transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags" @@ -6577,6 +6578,7 @@ if enabled vaapi; then check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC" check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth +check_struct "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer" output_hdr_metadata This check does not seem to be enough, I am getting errors like this for libva 2.3.0: libavfilter/vf_tonemap_vaapi.c: In function ‘tonemap_vaapi_set_filter_params’: libavfilter/vf_tonemap_vaapi.c:156:5: error: unknown type name ‘VAProcFilterParameterBufferHDRToneMapping’; did you mean ‘VAProcFilterParameterBufferDeinterlacing’? VAProcFilterParameterBufferHDRToneMapping *hdrtm_param; ^ VAProcFilterParameterBufferDeinterlacing 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] avfilter/image2: Add source file path and basename to each packet side data.
On Sat, Dec 21, 2019 at 05:32:26PM +, Alexandre Heitor Schmidt wrote: > > In the commit msg, > > > >> libavformat/img2dec.c: Modify image2 demuxer to make available > >> two special metadata entries called lavf.image2dec.source_basename > >> and lavf.image2dec.source_basename, which represents, respectively, > >> the complete path to the source image for the current frame and > >> the basename i.e. the file name related to the current frame. > >> These can then be used by filters like drawtext and others. > > > > First key name should end in source_path > > Damn! You're right! New patch attached with this minor change corrected. > > Thanks! > > Alex. > > doc/demuxers.texi | 11 +++ > doc/filters.texi |7 +++ > libavformat/img2dec.c | 32 > 3 files changed, 50 insertions(+) > c75f4fef2f9595bc69315d450219adda125aaf25 > 0001-avformat-image2-Metadata-identifying-the-source-path.patch > >From 95ebffed3784ba12a32966128136e8deae0d8386 Mon Sep 17 00:00:00 2001 > From: Alexandre Heitor Schmidt > Date: Sat, 21 Dec 2019 16:19:31 + > Subject: [PATCH] avformat/image2: Metadata identifying the source path of > input filename and documentation for its usage. > > libavformat/img2dec.c: Modify image2 demuxer to make available > two special metadata entries called lavf.image2dec.source_path > and lavf.image2dec.source_basename, which represents, respectively, > the complete path to the source image for the current frame and > the basename i.e. the file name related to the current frame. > These can then be used by filters like drawtext and others. not sure why i just now realize it but Storing the source path is problematic privacy and security wise Thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No snowflake in an avalanche ever feels responsible. -- Voltaire signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avfilter/image2: Add source file path and basename to each packet side data.
> > not sure why i just now realize it but > > Storing the source path is problematic privacy and security wise > > Thanks > What does this means? That it won't be applied? Can you give an example on why this would be a security issue, considering you already have it anywhere, only not available to filters until now? Besides, isn't metadata way more sensitive than a simple file path? Thanks. Alex. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH V2] lavc/midivid: FIX CID 1456088
On Sun, Dec 22, 2019 at 03:26:58PM +, Zhong Li wrote: > Signed-off-by: Zhong Li > --- > libavcodec/midivid.c | 9 ++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/midivid.c b/libavcodec/midivid.c > index 38465c5..3dac3f1 100644 > --- a/libavcodec/midivid.c > +++ b/libavcodec/midivid.c > @@ -63,17 +63,20 @@ static int decode_mvdv(MidiVidContext *s, AVCodecContext > *avctx, AVFrame *frame) > if (intra_flag) { > nb_blocks = (avctx->width / 2) * (avctx->height / 2); > } else { > -int skip_linesize; > +int ret, skip_linesize; > > nb_blocks = bytestream2_get_le32(gb); > skip_linesize = avctx->width >> 1; > mask_start = gb->buffer_start + bytestream2_tell(gb); > mask_size = (avctx->width >> 5) * (avctx->height >> 2); > > -if (bytestream2_get_bytes_left(gb) < mask_size) > +ret = bytestream2_get_bytes_left(gb); > +if (ret < mask_size) > return AVERROR_INVALIDDATA; don't need change it I think. > > -init_get_bits8(&mask, mask_start, mask_size); > +ret = init_get_bits8(&mask, mask_start, mask_size); > +if (ret < 0) > +return AVERROR_INVALIDDATA; return ret. That's why use ret. > bytestream2_skip(gb, mask_size); > skip = s->skip; > > -- > 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 mailing list ffmpeg-devel@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] avcodec/mpeg12dec: switch to AVBufferRef buffer for a53 caption
On Sun, Dec 22, 2019 at 05:37:21PM +, Kieran Kunhya wrote: > On Sun, 22 Dec 2019 at 13:27, wrote: > > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > libavcodec/mpeg12dec.c | 73 > > +++--- > > 1 file changed, 40 insertions(+), 33 deletions(-) > > > > Does this fix a particular issue? > My patch to H.264 fixed a particular case of field mode captions but this > doesn't look like it fixes it? No, it's just switch to the new reference buffer as H.264 and HEVC as it has more benefit to export the data, I try my best to keep the function same. One difference is keep the old_size and realloc process from H.264, I can't sure whether it'll happed as I don't own such sample. Now I have tested with one mpeg2 with normal CC by showinfo only. If you have old sample broken, please let me know. > > Kieran ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH V2] lavc/midivid: FIX CID 1456088
On Mon, Dec 23, 2019 at 1:53 AM Limin Wang wrote: > On Sun, Dec 22, 2019 at 03:26:58PM +, Zhong Li wrote: > > Signed-off-by: Zhong Li > > --- > > libavcodec/midivid.c | 9 ++--- > > 1 file changed, 6 insertions(+), 3 deletions(-) > > > > diff --git a/libavcodec/midivid.c b/libavcodec/midivid.c > > index 38465c5..3dac3f1 100644 > > --- a/libavcodec/midivid.c > > +++ b/libavcodec/midivid.c > > @@ -63,17 +63,20 @@ static int decode_mvdv(MidiVidContext *s, > AVCodecContext *avctx, AVFrame *frame) > > if (intra_flag) { > > nb_blocks = (avctx->width / 2) * (avctx->height / 2); > > } else { > > -int skip_linesize; > > +int ret, skip_linesize; > > > > nb_blocks = bytestream2_get_le32(gb); > > skip_linesize = avctx->width >> 1; > > mask_start = gb->buffer_start + bytestream2_tell(gb); > > mask_size = (avctx->width >> 5) * (avctx->height >> 2); > > > > -if (bytestream2_get_bytes_left(gb) < mask_size) > > +ret = bytestream2_get_bytes_left(gb); > > +if (ret < mask_size) > > return AVERROR_INVALIDDATA; > > don't need change it I think. > > > > > -init_get_bits8(&mask, mask_start, mask_size); > > +ret = init_get_bits8(&mask, mask_start, mask_size); > > +if (ret < 0) > > +return AVERROR_INVALIDDATA; > > return ret. That's why use ret. > > But you are not returning ret. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 03/16] avformat/hlsenc: Only allocate when data is known to be needed
> 在 2019年12月16日,08:04,Andreas Rheinhardt 写道: > > hls_init() would allocate a buffer, although it is only needed in one of > two branches that follow. This commit moves the allocation to the branch > that actually needs the buffer. > > Signed-off-by: Andreas Rheinhardt > --- > libavformat/hlsenc.c | 11 +-- > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c > index 965c05c560..87bbfb8086 100644 > --- a/libavformat/hlsenc.c > +++ b/libavformat/hlsenc.c > @@ -2906,22 +2906,21 @@ static int hls_init(AVFormatContext *s) > ret = AVERROR(ENOMEM); > goto fail; > } > -vs->vtt_m3u8_name = av_malloc(vtt_basename_size); > -if (!vs->vtt_m3u8_name ) { > -ret = AVERROR(ENOMEM); > -goto fail; > -} > av_strlcpy(vs->vtt_basename, vs->m3u8_name, vtt_basename_size); > p = strrchr(vs->vtt_basename, '.'); > if (p) > *p = '\0'; > > if ( hls->subtitle_filename ) { > -av_freep(&vs->vtt_m3u8_name); > ret = format_name(hls->subtitle_filename, &vs->vtt_m3u8_name, > i, vs->varname); > if (ret < 0) > goto fail; > } else { > +vs->vtt_m3u8_name = av_malloc(vtt_basename_size); > +if (!vs->vtt_m3u8_name) { > +ret = AVERROR(ENOMEM); > +goto fail; > +} > strcpy(vs->vtt_m3u8_name, vs->vtt_basename); > av_strlcat(vs->vtt_m3u8_name, "_vtt.m3u8", vtt_basename_size); > } > -- > 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”. LGTM Thanks Steven ___ ffmpeg-devel mailing list ffmpeg-devel@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 04/16] avformat/hlsenc: Fix leak of options when initializing muxing fails
> 在 2019年12月16日,08:04,Andreas Rheinhardt 写道: > > hls_mux_init() currently leaks an AVDictionary if opening a dynamic > buffer fails or if avformat_init_output fails. This has been fixed by > moving the initialization resp. the freeing of the dictionary around: > In the former case to a place after opening the dynamic buffer, in the > latter to a place before the check for initialization failure so that it > is done unconditionally. > > Furthermore, the dictionary is now only copied and freed if the options > in it are actually used (namely when in SEGMENT_TYPE_FMP4 mode). > > Finally, a similar situation in hls_start() has been fixed, too. > > Signed-off-by: Andreas Rheinhardt > --- > libavformat/hlsenc.c | 18 ++ > 1 file changed, 10 insertions(+), 8 deletions(-) > > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c > index 87bbfb8086..5695af2208 100644 > --- a/libavformat/hlsenc.c > +++ b/libavformat/hlsenc.c > @@ -835,18 +835,19 @@ static int hls_mux_init(AVFormatContext *s, > VariantStream *vs) > > vs->packets_written = 0; > vs->init_range_length = 0; > -set_http_options(s, &options, hls); > + > if ((ret = avio_open_dyn_buf(&oc->pb)) < 0) > return ret; > > if (hls->segment_type == SEGMENT_TYPE_FMP4) { > +set_http_options(s, &options, hls); > if (byterange_mode) { > ret = hlsenc_io_open(s, &vs->out, vs->basename, &options); > } else { > ret = hlsenc_io_open(s, &vs->out, vs->base_output_dirname, > &options); > } > +av_dict_free(&options); > } > -av_dict_free(&options); > if (ret < 0) { > av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", > vs->fmp4_init_filename); > return ret; > @@ -861,21 +862,23 @@ static int hls_mux_init(AVFormatContext *s, > VariantStream *vs) > } > } > > -av_dict_copy(&options, hls->format_options, 0); > if (hls->segment_type == SEGMENT_TYPE_FMP4) { > +int remaining_options; > + > +av_dict_copy(&options, hls->format_options, 0); > av_dict_set(&options, "fflags", "-autobsf", 0); > av_dict_set(&options, "movflags", "+frag_custom+dash+delay_moov", > AV_DICT_APPEND); > ret = avformat_init_output(oc, &options); > +remaining_options = av_dict_count(options); > +av_dict_free(&options); > if (ret < 0) > return ret; > -if (av_dict_count(options)) { > +if (remaining_options) { > av_log(s, AV_LOG_ERROR, "Some of the provided format options in > '%s' are not recognized\n", hls->format_options_str); > -av_dict_free(&options); > return AVERROR(EINVAL); > } > } > avio_flush(oc->pb); > -av_dict_free(&options); > return 0; > } > > @@ -1650,8 +1653,6 @@ static int hls_start(AVFormatContext *s, VariantStream > *vs) > } > vs->number++; > > -set_http_options(s, &options, c); > - > proto = avio_find_protocol_name(oc->url); > use_temp_file = proto && !strcmp(proto, "file") && (c->flags & > HLS_TEMP_FILE); > > @@ -1702,6 +1703,7 @@ static int hls_start(AVFormatContext *s, VariantStream > *vs) > av_opt_set(oc->priv_data, "pat_period", period, 0); > } > if (c->flags & HLS_SINGLE_FILE) { > +set_http_options(s, &options, c); > if ((err = hlsenc_io_open(s, &vs->out, oc->url, &options)) < 0) { > if (c->ignore_io_errors) > err = 0; > -- > 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”. LGTM Thanks Steven ___ ffmpeg-devel mailing list ffmpeg-devel@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 05/16] avformat/hlsenc: Fix leak of options when writing packets
> 在 2019年12月16日,08:04,Andreas Rheinhardt 写道: > > Under certain circumstances hls_write_packet() would add options to an > AVDictionary. Said dictionary was never explicitly freed, instead it was > presumed that these options would be consumed when opening a new > IO-context. This left several possibilities for memleaks: > > a) When no new IO-context would be opened at all. This is possible when > using both the flags temp_file and single_file together with a file > output. > b) When an error happens before one actually tries to open the new > IO-context. > c) When the new IO-context does not consume all options. > > All three have been fixed; furthermore, the AVDictionary has been put > into a smaller scope (namely the only part of hls_write_packet() where > it is actually used). > > Signed-off-by: Andreas Rheinhardt > --- > This patch is concerned with fixing memleaks. Yet I noticed a > discrepancy in the handling of options between the first try to open > output and the second one (the one for reflushing in case the first one > fails): The second one only gets the options not consumed in the first > one. Is this intended? > > libavformat/hlsenc.c | 19 --- > 1 file changed, 12 insertions(+), 7 deletions(-) > > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c > index 5695af2208..5b3856099c 100644 > --- a/libavformat/hlsenc.c > +++ b/libavformat/hlsenc.c > @@ -2241,7 +2241,6 @@ static int hls_write_packet(AVFormatContext *s, > AVPacket *pkt) > int use_temp_file = 0; > uint8_t *buffer = NULL; > VariantStream *vs = NULL; > -AVDictionary *options = NULL; > char *old_filename = NULL; > > for (i = 0; i < hls->nb_varstreams; i++) { > @@ -2343,11 +2342,6 @@ static int hls_write_packet(AVFormatContext *s, > AVPacket *pkt) > use_temp_file = proto && !strcmp(proto, "file") && (hls->flags & > HLS_TEMP_FILE); > } > > -// look to rename the asset name > -if (use_temp_file) { > -av_dict_set(&options, "mpegts_flags", "resend_headers", 0); > -} > - > if (hls->flags & HLS_SINGLE_FILE) { > ret = flush_dynbuf(vs, &range_length); > av_freep(&vs->temp_buffer); > @@ -2356,8 +2350,8 @@ static int hls_write_packet(AVFormatContext *s, > AVPacket *pkt) > } > vs->size = range_length; > } else { > -set_http_options(s, &options, hls); > if ((hls->max_seg_size > 0 && (vs->size >= hls->max_seg_size)) || > !byterange_mode) { > +AVDictionary *options = NULL; > char *filename = NULL; > if (hls->key_info_file || hls->encrypt) { > av_dict_set(&options, "encryption_key", hls->key_string, > 0); > @@ -2367,12 +2361,21 @@ static int hls_write_packet(AVFormatContext *s, > AVPacket *pkt) > filename = av_asprintf("%s", oc->url); > } > if (!filename) { > +av_dict_free(&options); > return AVERROR(ENOMEM); > } > + > +// look to rename the asset name > +if (use_temp_file) > +av_dict_set(&options, "mpegts_flags", "resend_headers", > 0); > + > +set_http_options(s, &options, hls); > + > ret = hlsenc_io_open(s, &vs->out, filename, &options); > if (ret < 0) { > av_log(s, hls->ignore_io_errors ? AV_LOG_WARNING : > AV_LOG_ERROR, >"Failed to open file '%s'\n", filename); > +av_dict_free(&options); > return hls->ignore_io_errors ? 0 : ret; > } > if (hls->segment_type == SEGMENT_TYPE_FMP4) { > @@ -2380,6 +2383,7 @@ static int hls_write_packet(AVFormatContext *s, > AVPacket *pkt) > } > ret = flush_dynbuf(vs, &range_length); > if (ret < 0) { > +av_dict_free(&options); > return ret; > } > ret = hlsenc_io_close(s, &vs->out, filename); > @@ -2391,6 +2395,7 @@ static int hls_write_packet(AVFormatContext *s, > AVPacket *pkt) > reflush_dynbuf(vs, &range_length); > ret = hlsenc_io_close(s, &vs->out, filename); > } > +av_dict_free(&options); > av_freep(&vs->temp_buffer); > av_freep(&filename); > } > -- > 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". LGTM Thanks Steven ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-deve
Re: [FFmpeg-devel] [PATCH 09/16] avformat/hlsenc: Check some unchecked allocations
> 在 2019年12月16日,08:04,Andreas Rheinhardt 写道: > > Signed-off-by: Andreas Rheinhardt > --- > libavformat/hlsenc.c | 13 - > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c > index 8f142fd475..b3f9582267 100644 > --- a/libavformat/hlsenc.c > +++ b/libavformat/hlsenc.c > @@ -1614,6 +1614,8 @@ static int hls_start(AVFormatContext *s, VariantStream > *vs) > if (c->use_localtime_mkdir) { > const char *dir; > char *fn_copy = av_strdup(oc->url); > +if (!fn_copy) > +return AVERROR(ENOMEM); > dir = av_dirname(fn_copy); > if (ff_mkdir_p(dir) == -1 && errno != EEXIST) { > av_log(oc, AV_LOG_ERROR, "Could not create directory %s > with use_localtime_mkdir\n", dir); > @@ -1781,6 +1783,8 @@ static int validate_name(int nb_vs, const char *fn) > } > > fn_dup = av_strdup(fn); > +if (!fn_dup) > +return AVERROR(ENOMEM); > filename = av_basename(fn); > subdir_name = av_dirname(fn_dup); > > @@ -2143,6 +2147,8 @@ static int update_master_pl_info(AVFormatContext *s) > int ret = 0; > > fn1 = av_strdup(s->url); > +if (!fn1) > +return AVERROR(ENOMEM); > dir = av_dirname(fn1); > > /** > @@ -2151,6 +2157,10 @@ static int update_master_pl_info(AVFormatContext *s) > */ > if (dir && av_stristr(av_basename(dir), "%v")) { > fn2 = av_strdup(dir); > +if (!fn2) { > +ret = AVERROR(ENOMEM); > +goto fail; > +} > dir = av_dirname(fn2); > } > > @@ -2866,7 +2876,8 @@ static int hls_init(AVFormatContext *s) > if (hls->nb_varstreams > 1) { > if (av_stristr(vs->fmp4_init_filename, "%v")) { > av_freep(&vs->fmp4_init_filename); > -format_name(hls->fmp4_init_filename, > &vs->fmp4_init_filename, i, vs->varname); > +ret = format_name(hls->fmp4_init_filename, > + &vs->fmp4_init_filename, i, > vs->varname); > } else { > ret = append_postfix(vs->fmp4_init_filename, > fmp4_init_filename_len, i); > } > -- > 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”. donnot need check, because the av_dirname has checked it. Thanks Steven ___ ffmpeg-devel mailing list ffmpeg-devel@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 07/16] avformat/hlsenc: Fix potential segfault upon allocation failure
> 在 2019年12月16日,08:04,Andreas Rheinhardt 写道: > > The hls muxer allocates an array of VariantStreams, a structure that > contains pointers to objects that need to be freed on their own. This > means that the number of allocated VariantStreams needs to be correct > when they are freed; yet the number of VariantStreams is set in > update_variant_stream_info() resp. parse_variant_stream_mapstring() > before the allocation has been checked for success, so that upon error > an attempt would be made to free the objects whose pointers are > positioned at position NULL (the location of VariantStreams) + > offsetof(VariantStream, the corresponding pointer). > > Furthermore d1fe1344 added another possibility for the first function > to leave an inconsistent state behind: If an allocation of one of the > objects referenced by the VariantStream fails, the VariantStream will be > freed, but the number of allocated VariantStreams isn't reset, leading > to the same problem as above. (This was done in the mistaken belief that > the VariantStreams array would leak otherwise.) > > Essentially the same also happens for the number of cc-streams. It has > been fixed, too. > > Signed-off-by: Andreas Rheinhardt > --- > libavformat/hlsenc.c | 21 ++--- > 1 file changed, 10 insertions(+), 11 deletions(-) > > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c > index 62f66c4c65..7fcc71264b 100644 > --- a/libavformat/hlsenc.c > +++ b/libavformat/hlsenc.c > @@ -1875,7 +1875,7 @@ static int > parse_variant_stream_mapstring(AVFormatContext *s) > VariantStream *vs; > int stream_index, i, j; > enum AVMediaType codec_type; > -int nb_varstreams, nb_streams; > +int nb_varstreams = 0, nb_streams; > char *p, *q, *saveptr1, *saveptr2, *varstr, *keyval; > const char *val; > > @@ -1900,13 +1900,14 @@ static int > parse_variant_stream_mapstring(AVFormatContext *s) > q = p; > while (av_strtok(q, " \t", &saveptr1)) { > q = NULL; > -hls->nb_varstreams++; > +nb_varstreams++; > } > av_freep(&p); > > -hls->var_streams = av_mallocz(sizeof(*hls->var_streams) * > hls->nb_varstreams); > +hls->var_streams = av_mallocz(sizeof(*hls->var_streams) * nb_varstreams); > if (!hls->var_streams) > return AVERROR(ENOMEM); > +hls->nb_varstreams = nb_varstreams; > > p = hls->var_stream_map; > nb_varstreams = 0; > @@ -2011,7 +2012,7 @@ static int > parse_variant_stream_mapstring(AVFormatContext *s) > static int parse_cc_stream_mapstring(AVFormatContext *s) > { > HLSContext *hls = s->priv_data; > -int nb_ccstreams; > +int nb_ccstreams = 0; > char *p, *q, *ccstr, *keyval; > char *saveptr1 = NULL, *saveptr2 = NULL; > const char *val; > @@ -2024,13 +2025,14 @@ static int parse_cc_stream_mapstring(AVFormatContext > *s) > q = p; > while (av_strtok(q, " \t", &saveptr1)) { > q = NULL; > -hls->nb_ccstreams++; > +nb_ccstreams++; > } > av_freep(&p); > > -hls->cc_streams = av_mallocz(sizeof(*hls->cc_streams) * > hls->nb_ccstreams); > +hls->cc_streams = av_mallocz(sizeof(*hls->cc_streams) * nb_ccstreams); > if (!hls->cc_streams) > return AVERROR(ENOMEM); > +hls->nb_ccstreams = nb_ccstreams; > > p = hls->cc_stream_map; > nb_ccstreams = 0; > @@ -2106,18 +2108,16 @@ static int update_variant_stream_info(AVFormatContext > *s) > return parse_variant_stream_mapstring(s); > } else { > //By default, a single variant stream with all the codec streams is > created > -hls->nb_varstreams = 1; > -hls->var_streams = av_mallocz(sizeof(*hls->var_streams) * > - hls->nb_varstreams); > +hls->var_streams = av_mallocz(sizeof(*hls->var_streams)); > if (!hls->var_streams) > return AVERROR(ENOMEM); > +hls->nb_varstreams = 1; > > hls->var_streams[0].var_stream_idx = 0; > hls->var_streams[0].nb_streams = s->nb_streams; > hls->var_streams[0].streams = av_mallocz(sizeof(AVStream *) * > hls->var_streams[0].nb_streams); > if (!hls->var_streams[0].streams) { > -av_freep(&hls->var_streams); > return AVERROR(ENOMEM); > } > > @@ -2125,7 +2125,6 @@ static int update_variant_stream_info(AVFormatContext > *s) > if (hls->nb_ccstreams) { > hls->var_streams[0].ccgroup = > av_strdup(hls->cc_streams[0].ccgroup); > if (!hls->var_streams[0].ccgroup) { > -av_freep(&hls->var_streams); > return AVERROR(ENOMEM); > } > } > -- > 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 "unsubsc
Re: [FFmpeg-devel] [PATCH v2 3/3] avfilter/vf_convolution: Add X86 SIMD optimizations for filter_column()
comments inlined At 2019-12-22 16:37:03, xuju...@sjtu.edu.cn wrote: >From: Xu Jun > >Performance improves about 10% compared to v1. > >Tested using this command: >./ffmpeg_g -s 1280*720 -pix_fmt yuv420p -i test.yuv -vf convolution="1 2 3 4 5 >6 7 8 9:1 2 3 4 5 6 7 8 9:1 2 3 4 5 6 7 8 9:1 2 3 4 5 6 7 8 >9:1/45:1/45:1/45:1/45:1:2:3:4:column:column:column:column" -an -vframes 5000 >-f null /dev/null -benchmark > >after patch: >frame= 4317 fps=600 q=-0.0 Lsize=N/A time=00:02:52.68 bitrate=N/A speed= 24x >video:2260kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB >muxing overhead: unknown >bench: utime=21.540s stime=2.091s rtime=7.197s > >before patch: >frame= 4317 fps=263 q=-0.0 Lsize=N/A time=00:02:52.68 bitrate=N/A speed=10.5x >video:2260kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB >muxing overhead: unknown >bench: utime=74.377s stime=1.880s rtime=16.420s > >Signed-off-by: Xu Jun >--- > libavfilter/x86/vf_convolution.asm| 202 ++ > libavfilter/x86/vf_convolution_init.c | 9 ++ > 2 files changed, 211 insertions(+) > >diff --git a/libavfilter/x86/vf_convolution.asm >b/libavfilter/x86/vf_convolution.asm >index 2a09374b00..4c700656d6 100755 >--- a/libavfilter/x86/vf_convolution.asm >+++ b/libavfilter/x86/vf_convolution.asm >@@ -22,6 +22,8 @@ > > SECTION_RODATA > half: dd 0.5 >+shuf_init: ddq 0x80808003808080028080800180808000 TBD ps: constant define as Byte (db) or Word (dw) have more readable, in this case, you use it with psuhfb, so Byte. >+shuf_step: ddq 0x0004000400040004 > > SECTION .text > >@@ -285,3 +287,203 @@ sub widthq, rq > .end: > RET > %endif >+ >+; 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); >+ >+%macro COMPUTE_4COL 1 >+pshufb m7, m6, m4; get 4 uint8s from the 16 uint8s Unnecessary, see below comment >+pmulld m7, m5 >+paddd m1%1, m7 not error, generally, this sum operator made new dependency link, it may stall pipeline, I suggest sum 4 of register in parallelism. In this case, I am not sure dynamic range of Matrix, so I am not sure it is good or overflow if sum element of (2 * radius + 1) times. >+%endmacro >+ >+%macro CVT_PACK_COL 1 >+cvtdq2ps m1%1, m1%1 >+mulps m1%1, m0 ; sum *= rdiv >+addps m1%1, m1 ; sum += bias >+addps m1%1, m3 ; sum += 0.5 >+cvttps2dq m1%1, m1%1 >+packssdw m1%1, m1%1 >+packuswb m1%1, m1%1 >+%endmacro >+ >+%if ARCH_X86_64 >+INIT_XMM sse4 >+%if UNIX64 >+cglobal filter_column, 8, 14, 14, dst, height, matrix, ptr, width, rad, >dstride, stride, \ >+i, ci, ystride, sum, r, off16 >+%else >+cglobal filter_column, 8, 14, 14, dst, height, rdiv, bias, matrix, ptr, >width, rad, dstride, stride, \ >+i, ci, ystride, sum, r, off16 >+%endif >+ >+%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, ystride, sum, r, off16 >+%endif >+ >+movsxdifnidn widthq, widthd >+movsxdifnidn radq, radd >+lea radq, [radq * 2 + 1] >+movsxdifnidn dstrideq, dstrided >+movsxdifnidn strideq, strided >+movsxdifnidn heightq, heightd >+ >+VBROADCASTSS m0, m0; rdiv >+VBROADCASTSS m1, m1; bias >+pxor m2, m2; zero >+movss m3, [half] >+VBROADCASTSS m3, m3; 0.5 >+movdqu m8, [shuf_init] ; shuffle initialization TBD >+movdqu m9, [shuf_step]; shuffle step >+ >+xor ystrideq, ystrideq; y*stride >+ >+cmp widthq, mmsize;if width<16 run loopr, width=16 run 16 parallel >+jl .less16 >+ >+.equal16: >+pxor m10, m10 >+pxor m11, m11 >+pxor m12, m12 >+pxor m13, m13 >+; m10-13 hold sums not error, however, use m0-m7 can be save 1 byte instruction prefix, in the inner loop, it made a little performance improvement. >+ >+lea iq, [radq - 1] >+.loopi: >+movd m5, [matrixq + 4*iq]; matrix[i] >+VBROADCASTSS m5, m5 since you claim SSE4, PSHUFD maybe better, however, it is not problem if you want to upgrade to AVX and above >+mov ciq, [ptrq + iq * gprsize] >+movdqu m6, [ciq + ystrideq]; c[i][y*stride] 16 uint8s SSE4 provided MOVZXBD, it make you reduce above PSHUFB and series constant load >+ >+;m4 controls shuffle >+movdqa m4, m8 >+COMPUTE_4COL 0; process 0-3 cols, sum in m10 >+paddd m4, m9 >+COMPUTE_4COL 1; process 4-7 cols, sum in m11 >+paddd m4, m9 >+COMPUTE_4COL 2; process 8-11 cols, sum in m12 >+paddd m4, m9 >+COMPUTE_4COL 3; process 12-15 cols, sum in m13 >+ >+sub iq, 1 >+jns .loopi >+ >+CVT_PACK_COL 0; process 0-3 cols, result in m10's l
[FFmpeg-devel] [PATCH v1] avfilter/vf_readeia608: fix check for failed av_calloc
From: Limin Wang Signed-off-by: Limin Wang --- libavfilter/vf_readeia608.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_readeia608.c b/libavfilter/vf_readeia608.c index ff096189a9..43c57268fa 100644 --- a/libavfilter/vf_readeia608.c +++ b/libavfilter/vf_readeia608.c @@ -121,7 +121,8 @@ static int config_input(AVFilterLink *inlink) s->signal = av_calloc(size, sizeof(*s->signal)); s->code = av_calloc(size, sizeof(*s->code)); s->temp = av_calloc(size, sizeof(*s->temp)); -if (!s->temp) +if (!s->unfiltered || !s->filtered || !s->avg_filter || +!s->std_filter || !s->signal || !s->code || !s->temp) return AVERROR(ENOMEM); return 0; -- 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".
Re: [FFmpeg-devel] [PATCH V2] lavc/midivid: FIX CID 1456088
On Mon, Dec 23, 2019 at 02:00:10AM +0100, Andreas Rheinhardt wrote: > On Mon, Dec 23, 2019 at 1:53 AM Limin Wang wrote: > > > On Sun, Dec 22, 2019 at 03:26:58PM +, Zhong Li wrote: > > > Signed-off-by: Zhong Li > > > --- > > > libavcodec/midivid.c | 9 ++--- > > > 1 file changed, 6 insertions(+), 3 deletions(-) > > > > > > diff --git a/libavcodec/midivid.c b/libavcodec/midivid.c > > > index 38465c5..3dac3f1 100644 > > > --- a/libavcodec/midivid.c > > > +++ b/libavcodec/midivid.c > > > @@ -63,17 +63,20 @@ static int decode_mvdv(MidiVidContext *s, > > AVCodecContext *avctx, AVFrame *frame) > > > if (intra_flag) { > > > nb_blocks = (avctx->width / 2) * (avctx->height / 2); > > > } else { > > > -int skip_linesize; > > > +int ret, skip_linesize; > > > > > > nb_blocks = bytestream2_get_le32(gb); > > > skip_linesize = avctx->width >> 1; > > > mask_start = gb->buffer_start + bytestream2_tell(gb); > > > mask_size = (avctx->width >> 5) * (avctx->height >> 2); > > > > > > -if (bytestream2_get_bytes_left(gb) < mask_size) > > > +ret = bytestream2_get_bytes_left(gb); > > > +if (ret < mask_size) > > > return AVERROR_INVALIDDATA; > > > > don't need change it I think. > > > > > > > > -init_get_bits8(&mask, mask_start, mask_size); > > > +ret = init_get_bits8(&mask, mask_start, mask_size); > > > +if (ret < 0) > > > +return AVERROR_INVALIDDATA; > > > > return ret. That's why use ret. > > > > > But you are not returning ret. But It's not my code, I'm a code reviewer. > > - Andreas > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH V2] lavc/midivid: FIX CID 1456088
On Mon, Dec 23, 2019 at 6:03 AM Limin Wang wrote: > On Mon, Dec 23, 2019 at 02:00:10AM +0100, Andreas Rheinhardt wrote: > > On Mon, Dec 23, 2019 at 1:53 AM Limin Wang > wrote: > > > > > On Sun, Dec 22, 2019 at 03:26:58PM +, Zhong Li wrote: > > > > Signed-off-by: Zhong Li > > > > --- > > > > libavcodec/midivid.c | 9 ++--- > > > > 1 file changed, 6 insertions(+), 3 deletions(-) > > > > > > > > diff --git a/libavcodec/midivid.c b/libavcodec/midivid.c > > > > index 38465c5..3dac3f1 100644 > > > > --- a/libavcodec/midivid.c > > > > +++ b/libavcodec/midivid.c > > > > @@ -63,17 +63,20 @@ static int decode_mvdv(MidiVidContext *s, > > > AVCodecContext *avctx, AVFrame *frame) > > > > if (intra_flag) { > > > > nb_blocks = (avctx->width / 2) * (avctx->height / 2); > > > > } else { > > > > -int skip_linesize; > > > > +int ret, skip_linesize; > > > > > > > > nb_blocks = bytestream2_get_le32(gb); > > > > skip_linesize = avctx->width >> 1; > > > > mask_start = gb->buffer_start + bytestream2_tell(gb); > > > > mask_size = (avctx->width >> 5) * (avctx->height >> 2); > > > > > > > > -if (bytestream2_get_bytes_left(gb) < mask_size) > > > > +ret = bytestream2_get_bytes_left(gb); > > > > +if (ret < mask_size) > > > > return AVERROR_INVALIDDATA; > > > > > > don't need change it I think. > > > > > > > > > > > -init_get_bits8(&mask, mask_start, mask_size); > > > > +ret = init_get_bits8(&mask, mask_start, mask_size); > > > > +if (ret < 0) > > > > +return AVERROR_INVALIDDATA; > > > > > > return ret. That's why use ret. > > > > > > > > But you are not returning ret. > > But It's not my code, I'm a code reviewer. > > You are right. Forget my previous mail, it's just nonsense then. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/mpegtsenc: warn users if codec isn't supported
On 20-12-2019 04:55 pm, Gyan wrote: Regards, Gyan Will push tonight. Gyan ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".