[FFmpeg-devel] [PATCH 2/3] avfilter/vf_convolution: Add x86 SIMD optimizations for filter_row()

2019-12-02 Thread xujunzz
From: Xu Jun 

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=477 q=-0.0 Lsize=N/A time=00:02:52.68 bitrate=N/A speed=19.1x
video:2260kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing 
overhead: unknown
bench: utime=29.840s stime=2.121s rtime=9.047s
bench: maxrss=15156kB

before patch:
frame= 4317 fps=187 q=-0.0 Lsize=N/A time=00:02:52.68 bitrate=N/A speed= 7.5x
video:2260kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing 
overhead: unknown
bench: utime=106.948s stime=2.382s rtime=23.039s
bench: maxrss=15224kB

Signed-off-by: Xu Jun 
---
 libavfilter/x86/vf_convolution.asm| 104 ++
 libavfilter/x86/vf_convolution_init.c |   9 +++
 2 files changed, 113 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..b71e9720fb
--- a/libavfilter/x86/vf_convolution.asm
+++ b/libavfilter/x86/vf_convolution.asm
@@ -154,3 +154,107 @@ 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)
+%if ARCH_X86_64
+INIT_XMM sse4
+%if UNIX64
+cglobal filter_row, 6, 10, 7, dst, width, matrix, ptr, mult, rad, r, x, i, ci
+%else
+cglobal filter_row, 4, 10, 7, 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 radq, radd
+sal radq, 1
+add radq, 1 ;   2*radius+1
+movsxdifnidn widthq, widthd
+VBROADCASTSS m0, m0
+VBROADCASTSS m1, m1
+pxor m6, m6
+movss m5, [half]
+VBROADCASTSS m5, m5
+
+xor xq, xq
+cmp widthq, mmsize/4
+jl .loop2
+
+mov rq, widthq
+and rq, mmsize/4-1
+sub widthq, rq
+
+.loop1:
+pxor m4, m4
+xor iq, iq
+.loop1_1:
+movss m2, [matrixq + 4*iq]
+VBROADCASTSS m2, m2
+mov ciq, [ptrq + iq * gprsize]
+movss m3, [ciq + xq]
+punpcklbw m3, m6
+punpcklwd m3, m6
+pmulld m2, m3
+paddd m4, m2
+
+add iq, 1
+cmp iq, radq
+jl .loop1_1
+
+cvtdq2ps m4, m4
+mulps m4, m0 ; sum *= rdiv
+addps m4, m1 ; sum += bias
+addps m4, m5 ; sum += 0.5
+cvttps2dq m4, m4
+packssdw m4, m4
+packuswb m4, m4
+movss [dstq + xq], m4
+
+add xq, mmsize/4
+cmp xq, widthq
+jl .loop1
+
+add widthq, rq
+cmp xq, widthq
+jge .end
+
+.loop2:
+xor rd, rd
+xor iq, iq
+.loop2_2:
+mov ciq, [ptrq + iq * gprsize]
+movzx multd, byte [ciq + xq]
+imul multd, [matrixq + 4*iq]
+add rd, multd
+
+add iq, 1
+cmp iq, radq
+jl .loop2_2
+
+pxor m4, m4
+cvtsi2ss m4, rd
+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 rd, m4
+mov [dstq + xq], rb
+
+add xq, 1
+cmp xq, widthq
+jl .loop2
+.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,
 const uint8_t *c[], int peak, int radius,
 int dstride, int stride);
 
+void ff_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);
+
 av_cold void ff_convolution_init_x86(ConvolutionContext *s)
 {
 #if ARCH_X86_64
@@ -41,6 +46,10 @@ av_cold void ff_convolution_init_x86(ConvolutionContext *s)
 s->filter[i] = ff_filter_3x3_sse4;
 }
 }
+if (s->mode[i] == MATRIX_ROW) {
+if (EXTERNAL_SSE4(cpu_flags))
+s->filter[i] = ff_filter_row_sse4;
+}
 }
 #endif
 }
-- 
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".

[FFmpeg-devel] [PATCH 1/3] avfilter/vf_convolution: add 16-column operation for filter_column() and modify filter_slice().

2019-12-02 Thread xujunzz
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 | 33 ++---
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c
index 5909feaad1..ed45ffdc37 100644
--- a/libavfilter/vf_convolution.c
+++ b/libavfilter/vf_convolution.c
@@ -389,19 +389,27 @@ 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;
 
+// 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 +529,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 +542,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 +555,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/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/3] avfilter/vf_convolution: add X86 SIMD for filter_column()

2019-12-02 Thread xujunzz
From: Xu Jun 

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=464 q=-0.0 Lsize=N/A time=00:02:52.68 bitrate=N/A speed=18.6x
video:2260kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing 
overhead: unknown
bench: utime=30.556s stime=2.361s rtime=9.307s
bench: maxrss=15156kB

before 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

Signed-off-by: Xu Jun 
---
 libavfilter/x86/vf_convolution.asm| 129 ++
 libavfilter/x86/vf_convolution_init.c |   9 ++
 2 files changed, 138 insertions(+)

diff --git a/libavfilter/x86/vf_convolution.asm 
b/libavfilter/x86/vf_convolution.asm
index b71e9720fb..3dbfb26978 100755
--- a/libavfilter/x86/vf_convolution.asm
+++ b/libavfilter/x86/vf_convolution.asm
@@ -258,3 +258,132 @@ 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);
+
+%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
+
+%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
+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
+pxor m4, m4
+xor iq, iq
+.loopi:
+movss m2, [matrixq + 4*iq]
+VBROADCASTSS m2, m2
+mov ciq, [ptrq + iq * gprsize]
+movss m3, [ciq + c_offq] ;c[i][y*stride + off16]
+punpcklbw m3, m6
+punpcklwd m3, m6
+pmulld m2, m3
+paddd m4, m2
+
+add iq, 1
+cmp iq, radq
+jl .loopi
+
+cvtdq2ps m4, m4
+mulps m4, m0 ; sum *= rdiv
+addps m4, m1 ; sum += bias
+addps m4, m5 ; sum += 0.5
+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:
+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
+add dst_offq, 1
+add off16q, 1
+cmp off16q, widthq
+jl .loopr
+
+.paraend:
+sub c_offq, widthq
+sub dst_offq, widthq
+add c_offq, strideq
+add dst_offq, dstrideq
+
+sub heightq, 1
+cmp heightq, 0
+jg .loopy
+
+.end:
+RET
+%endif
diff --git a/libavfilter/x86/vf_convolution_init.c 
b/libavfilter/x86/vf_convolution_init.c
index 5eb3b3bee1..da39b8a400 100644
--- a/libavfilter/x86/vf_convolution_init.c
+++ b/libavfilter/x86/vf_convolution_init.c
@@ -34,6 +34,11 @@ void ff_filter_row_sse4(uint8_t *dst, int width,
 const uint8_t *c[], int peak, int radius,
 int dstride, int stride);
 
+void ff_filter_column_sse4(uint8_t *dst, int height,
+float rdiv, float bias, 

Re: [FFmpeg-devel] [PATCH v2] Patch for memory optimization with QuickTime/MP4

2019-12-02 Thread Jörg Beckmann
> -Ursprüngliche Nachricht-
> Von: ffmpeg-devel  Im Auftrag von Michael
> Niedermayer
> Gesendet: Montag, 2. Dezember 2019 21:54
> An: FFmpeg development discussions and patches 
> Betreff: Re: [FFmpeg-devel] [PATCH v2] Patch for memory optimization with
> QuickTime/MP4
> 
> On Mon, Dec 02, 2019 at 02:12:14PM +, Jörg Beckmann wrote:
> > After discussion with Carl Eugen, I replaced the "if" in line 7737 with an 
> > assert().
> >
> > There is still the question, whether mov_switch_root() might be called when
> reading from a file. If someone is really really sure that it cannot happen 
> at all, the
> check in mov_read_seek() could be removed.
> >
> > Jörg
> >
> > ---
> > libavformat/isom.h |  1 +
> > libavformat/mov.c  | 50
> > +-
> > 2 files changed, 50 insertions(+), 1 deletion(-)
> 
> this patch seems to have been damaged
> 

I'll try it again. Thank you.

> Applying: Patch for memory optimization with QuickTime/MP4
> error: corrupt patch at line 24
> error: could not build fake ancestor
> Patch failed at 0001 Patch for memory optimization with QuickTime/MP4
> 
> 
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> "Nothing to hide" only works if the folks in power share the values of you and
> everyone you know entirely and always will -- Tom Scott

___
ffmpeg-devel mailing list
ffmpeg-devel@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] avfilter/buffersrc: deprecate sws_param option

2019-12-02 Thread quinkblack
From: Zhao Zhili 

---
 doc/filters.texi|  4 +---
 libavfilter/buffersrc.c | 14 --
 libavfilter/version.h   |  5 -
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 5fdec6f015..9b3c2d7c2d 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -21014,9 +21014,7 @@ 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.
 
 @item hw_frames_ctx
 When using a hardware pixel format, this should be a reference to an
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] [PATCH] avformat, avcodec: add dfcmv demuxer and decoder

2019-12-02 Thread Ben Lubar
A few example CMV files can be found in the data/initial_movies folder
of Dwarf Fortress (http://www.bay12games.com/dwarves/).

The demuxer does not currently handle audio cues. There are warning
messages logged for each audio file that should be played. As far as I
know, the only two existing CMV files with audio cues in them are in the
examples folder mentioned above.

Signed-off-by: Ben Lubar 
---
 Changelog|   1 +
 configure|   1 +
 doc/general.texi |   2 +
 libavcodec/Makefile  |   1 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/avcodec.h |   1 +
 libavcodec/codec_desc.c  |   7 +
 libavcodec/dfcmv.c   | 383 +++
 libavcodec/version.h |   4 +-
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/dfcmv.c  | 222 +++
 libavformat/version.h|   2 +-
 13 files changed, 624 insertions(+), 3 deletions(-)
 create mode 100644 libavcodec/dfcmv.c
 create mode 100644 libavformat/dfcmv.c

diff --git a/Changelog b/Changelog
index f30f398a9f..eed4fa8a50 100644
--- a/Changelog
+++ b/Changelog
@@ -27,6 +27,7 @@ version :
 - axcorrelate filter
 - mvdv decoder
 - mvha decoder
+- Dwarf Fortress CMV demuxer and decoder


 version 4.2:
diff --git a/configure b/configure
index ca7137f341..622deed689 100755
--- a/configure
+++ b/configure
@@ -3258,6 +3258,7 @@ caf_demuxer_select="iso_media riffdec"
 caf_muxer_select="iso_media"
 dash_muxer_select="mp4_muxer"
 dash_demuxer_deps="libxml2"
+dfcmv_demuxer_deps="zlib"
 dirac_demuxer_select="dirac_parser"
 dts_demuxer_select="dca_parser"
 dtshd_demuxer_select="dca_parser"
diff --git a/doc/general.texi b/doc/general.texi
index a5b77e0de1..bbc90a2f58 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -429,6 +429,7 @@ library:
 @tab Video format used by CD+G karaoke disks
 @item Phantom Cine  @tab   @tab X
 @item Cineform HD   @tab   @tab X
+@item Dwarf Fortress Curses MoVie (.cmv files)  @tab   @tab X
 @item Commodore CDXL@tab   @tab X
 @tab Amiga CD video format
 @item Core Audio Format @tab X @tab X
@@ -843,6 +844,7 @@ following image formats are supported:
 @item Delphine Software International CIN video  @tab @tab  X
 @tab Codec used in Delphine Software International games.
 @item Discworld II BMV Video @tab @tab  X
+@item Dwarf Fortess Curses MoVie (CMV)  @tab @tab  X
 @item Canopus Lossless Codec @tab @tab  X
 @item Cinepak@tab @tab  X
 @item Cirrus Logic AccuPak   @tab  X  @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c1f35b40d8..24e146e90f 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -267,6 +267,7 @@ OBJS-$(CONFIG_DDS_DECODER) += dds.o
 OBJS-$(CONFIG_DIRAC_DECODER)   += diracdec.o dirac.o
diracdsp.o diractab.o \
   dirac_arith.o dirac_dwt.o dirac_vlc.o
 OBJS-$(CONFIG_DFA_DECODER) += dfa.o
+OBJS-$(CONFIG_DFCMV_DECODER)   += dfcmv.o
 OBJS-$(CONFIG_DNXHD_DECODER)   += dnxhddec.o dnxhddata.o
 OBJS-$(CONFIG_DNXHD_ENCODER)   += dnxhdenc.o dnxhddata.o
 OBJS-$(CONFIG_DOLBY_E_DECODER) += dolby_e.o kbdwin.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index c33edf23c9..8571cce906 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -83,6 +83,7 @@ extern AVCodec ff_cscd_decoder;
 extern AVCodec ff_cyuv_decoder;
 extern AVCodec ff_dds_decoder;
 extern AVCodec ff_dfa_decoder;
+extern AVCodec ff_dfcmv_decoder;
 extern AVCodec ff_dirac_decoder;
 extern AVCodec ff_dnxhd_encoder;
 extern AVCodec ff_dnxhd_decoder;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 735a3c2d76..bd0446fe92 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -410,6 +410,7 @@ enum AVCodecID {
 AV_CODEC_ID_SCREENPRESSO,
 AV_CODEC_ID_RSCC,
 AV_CODEC_ID_AVS2,
+AV_CODEC_ID_DFCMV,

 AV_CODEC_ID_Y41P = 0x8000,
 AV_CODEC_ID_AVRP,
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 570bd2f382..4ce8416b8e 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1403,6 +1403,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("AVS2-P2/IEEE1857.4"),
 .props = AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_DFCMV,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "dfcmv",
+.long_name = NULL_IF_CONFIG_SMALL("Dwarf Fortress Curses MoVie"),
+.props = AV_CODEC_PROP_INTRA_ONLY,
+},
 {
 .id= AV_CODEC_ID_Y41P,
 .type  = AVMEDIA_TYPE_VIDEO,
diff --git a/libavcodec/dfcmv.c b/libavcodec/dfcmv.c
new file mode 100644
index 00..2c692ca9bd
--- /dev/null
+++ b/libavcodec/dfcmv.c
@@ -0,0 +1,383 @@
+#include "avcodec.h"
+#include "internal.h"
+#include "thread.h"
+#include 

Re: [FFmpeg-devel] [PATCH v3] avfilter: Add tonemap vaapi filter for H2S

2019-12-02 Thread Sun, Xinpeng

> -Original Message-
> From: Song, Ruiling 
> Sent: Tuesday, December 3, 2019 1:37 PM
> To: FFmpeg development discussions and patches 
> Cc: Sun, Xinpeng ; Zhou, Zachary
> 
> Subject: RE: [FFmpeg-devel] [PATCH v3] avfilter: Add tonemap vaapi filter for
> H2S
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Vittorio Giovara
> > Sent: Tuesday, December 3, 2019 2:28 AM
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Cc: Sun, Xinpeng ; Zhou, Zachary
> > 
> > Subject: Re: [FFmpeg-devel] [PATCH v3] avfilter: Add tonemap vaapi
> > filter for H2S
> >
> > On Mon, Dec 2, 2019 at 2:19 AM Xinpeng Sun 
> > wrote:
> >
> > > 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 
> > > ---
> > >  configure  |   2 +
> > >  doc/filters.texi   |  81 +++
> > >  libavfilter/Makefile   |   1 +
> > >  libavfilter/allfilters.c   |   1 +
> > >  libavfilter/vf_tonemap_vaapi.c | 420
> > +
> > >  5 files changed, 505 insertions(+)
> > >  create mode 100644 libavfilter/vf_tonemap_vaapi.c
> > >
> [...]
> > > +static int tonemap_vaapi_save_metadata(AVFilterContext *avctx,
> > AVFrame
> > > *input_frame)
> > > +{
> > > +HDRVAAPIContext *ctx = avctx->priv;
> > > +AVMasteringDisplayMetadata *hdr_meta;
> > > +AVContentLightMetadata *light_meta;
> > > +
> > > +if (input_frame->color_trc != AVCOL_TRC_SMPTE2084) {
> > > +av_log(avctx, AV_LOG_WARNING, "Only support HDR10 as input
> > > + for
> > > vaapi tone-mapping\n");
> > > +input_frame->color_trc = AVCOL_TRC_SMPTE2084;
> I think we don't need to modify the input->color_trc here. I am not sure if 
> this
> has any side-effect, but may be misleading if you want to check that value 
> when
> debugging.
> Simply remove this single line would be ok.
> 
> [...]
> > > +err = av_frame_copy_props(output_frame, input_frame);
> > > +if (err < 0)
> > > +return err;
> > > +
> > > +if (ctx->color_primaries != AVCOL_PRI_UNSPECIFIED)
> > > +output_frame->color_primaries = ctx->color_primaries;
> > > +
> > > +if (ctx->color_transfer != AVCOL_TRC_UNSPECIFIED)
> > > +output_frame->color_trc = ctx->color_transfer;
> > > +else
> > > +output_frame->color_trc = AVCOL_TRC_BT709
> > >
> >
> > why does only this setting get special treatment?
> Basically for other properties we can copy from the source, but for color_trc,
> we cannot.
> And I guess bt709 is a widely used sdr format. So even if user does not give a
> target transfer characteristic, we use this default one.
> 
> [...]
> >
> > Overall this lgtm, I'd push it but I don't have a platform to test it on.
Thanks a lot. I confirmed with the iHD driver team and this feature is also 
supported
 on other Intel platforms (like kabylake, coffeelake, etc) other than icelake. 
However, this change has not been updated in the README.md on the github:
https://github.com/intel/media-driver

Xinpeng 

> Really appreciate that. I borrow an icelake from other team member and have a
> test on this patch, the tone-mapping result video basically looks good.
> 
> Ruiling
> > --
> > Vittorio
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@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] avfilter: Add tonemap vaapi filter for H2S

2019-12-02 Thread Song, Ruiling
> -Original Message-
> From: ffmpeg-devel  On Behalf Of Fu,
> Linjie
> Sent: Tuesday, December 3, 2019 11:23 AM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Cc: Sun, Xinpeng ; Zhou, Zachary
> 
> Subject: Re: [FFmpeg-devel] [PATCH v3] avfilter: Add tonemap vaapi filter for
> H2S
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Xinpeng Sun
> > Sent: Monday, December 2, 2019 15:17
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Sun, Xinpeng ; Zhou, Zachary
> > 
> > Subject: [FFmpeg-devel] [PATCH v3] avfilter: Add tonemap vaapi filter for
> > H2S
> >
> > 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 
> > ---
> >  configure  |   2 +
> >  doc/filters.texi   |  81 +++
> >  libavfilter/Makefile   |   1 +
> >  libavfilter/allfilters.c   |   1 +
> >  libavfilter/vf_tonemap_vaapi.c | 420
> > +
> >  5 files changed, 505 insertions(+)
> >  create mode 100644 libavfilter/vf_tonemap_vaapi.c
> >
> > diff --git a/configure b/configure
> > index ca7137f341..5272fb2a57 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"
> > @@ -6576,6 +6577,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
> >  check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps"
> rotation_flags
> >  check_type "va/va.h va/va_enc_hevc.h"
> > "VAEncPictureParameterBufferHEVC"
> >  check_type "va/va.h va/va_enc_jpeg.h"
> > "VAEncPictureParameterBufferJPEG"
> > diff --git a/doc/filters.texi b/doc/filters.texi
> > index 5fdec6f015..7223ab89a3 100644
> > --- a/doc/filters.texi
> > +++ b/doc/filters.texi
> > @@ -20972,6 +20972,87 @@ Apply a strong blur of both luma and chroma
> > parameters:
> >
> >  @c man end OPENCL VIDEO FILTERS
> >
> > +@chapter VAAPI Video Filters
> > +@c man begin VAAPI VIDEO FILTERS
> > +
> > +VAAPI Video filters are usually used with VAAPI decoder and VAAPI
> > encoder. Below is a description of VAAPI video filters.
> > +
> > +To enable compilation of these filters you need to configure FFmpeg with
> > +@code{--enable-vaapi}.
> > +
> > +Running VAAPI filters requires you to initialize a hardware device and to
> > pass that device to all filters in any filter graph.
> > +@table @option
> > +
> > +@item -hwaccel vaapi
> > +Specify the hardware accelerator as @var{vaapi}.
> > +
> > +@item -vaapi_device @var{driver_path}
> > +Specify the vaapi driver path with @var{driver_path}.
> > +
> > +@item -hwaccel_output_format @var{vaapi}
> > +Specify the output format of hardware accelerator as @var{vaapi}. All
> > VAAPI hardware surfaces in ffmpeg are represented by the @var{vaapi}
> > pixfmt.
> > +
> > +@end table
> > +
> > +@itemize
> > +@item
> > +Example of running tonemap_vaapi filter with default parameters on it.
> > +@example
> > +-hwaccel vaapi -vaapi_device /dev/dri/renderD128 -
> > hwaccel_output_format vaapi -i INPUT -vf "tonemap_vaapi, hwdownload"
> > OUTPUT
> > +@end example
> > +@end itemize
> > +
> > +Since VAAPI filters are not able to access frame data in arbitrary memory,
> so
> > if you use a decoder other than VAAPI decoder before VAAPI filters, all
> > frame data needs to be uploaded(@ref{hwupload}) to hardware surfaces
> > connected to the appropriate device before being used. Also if you add a
> > encoder other than VAAPI encoder after VAAPI filters,
> 
> How about VAAPI decoder/filter + QSV encoder?
I think hwmap may help on this. anyway we can further enhance the document 
later if you have good idea.

Ruiling
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@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

Re: [FFmpeg-devel] [PATCH v3] avfilter: Add tonemap vaapi filter for H2S

2019-12-02 Thread Song, Ruiling
> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Vittorio Giovara
> Sent: Tuesday, December 3, 2019 2:28 AM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Cc: Sun, Xinpeng ; Zhou, Zachary
> 
> Subject: Re: [FFmpeg-devel] [PATCH v3] avfilter: Add tonemap vaapi filter for
> H2S
> 
> On Mon, Dec 2, 2019 at 2:19 AM Xinpeng Sun 
> wrote:
> 
> > 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 
> > ---
> >  configure  |   2 +
> >  doc/filters.texi   |  81 +++
> >  libavfilter/Makefile   |   1 +
> >  libavfilter/allfilters.c   |   1 +
> >  libavfilter/vf_tonemap_vaapi.c | 420
> +
> >  5 files changed, 505 insertions(+)
> >  create mode 100644 libavfilter/vf_tonemap_vaapi.c
> >
[...]
> > +static int tonemap_vaapi_save_metadata(AVFilterContext *avctx,
> AVFrame
> > *input_frame)
> > +{
> > +HDRVAAPIContext *ctx = avctx->priv;
> > +AVMasteringDisplayMetadata *hdr_meta;
> > +AVContentLightMetadata *light_meta;
> > +
> > +if (input_frame->color_trc != AVCOL_TRC_SMPTE2084) {
> > +av_log(avctx, AV_LOG_WARNING, "Only support HDR10 as input for
> > vaapi tone-mapping\n");
> > +input_frame->color_trc = AVCOL_TRC_SMPTE2084;
I think we don't need to modify the input->color_trc here. I am not sure if 
this has any side-effect, but may be misleading if you want to check that value 
when debugging.
Simply remove this single line would be ok.

[...]
> > +err = av_frame_copy_props(output_frame, input_frame);
> > +if (err < 0)
> > +return err;
> > +
> > +if (ctx->color_primaries != AVCOL_PRI_UNSPECIFIED)
> > +output_frame->color_primaries = ctx->color_primaries;
> > +
> > +if (ctx->color_transfer != AVCOL_TRC_UNSPECIFIED)
> > +output_frame->color_trc = ctx->color_transfer;
> > +else
> > +output_frame->color_trc = AVCOL_TRC_BT709
> >
> 
> why does only this setting get special treatment?
Basically for other properties we can copy from the source, but for color_trc, 
we cannot.
And I guess bt709 is a widely used sdr format. So even if user does not give a 
target transfer characteristic, we use this default one.

[...]
> 
> Overall this lgtm, I'd push it but I don't have a platform to test it on.
Really appreciate that. I borrow an icelake from other team member and have a 
test on this patch, the tone-mapping result video basically looks good.

Ruiling
> --
> Vittorio
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] libswscale/x86/yuv2rgb: Change inline assembly into nasm code

2019-12-02 Thread Fu, Ting


> -Original Message-
> From: ffmpeg-devel  On Behalf Of Carl
> Eugen Hoyos
> Sent: Monday, December 2, 2019 05:49 PM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH 1/2] libswscale/x86/yuv2rgb: Change inline
> assembly into nasm code
> 
> Am Mo., 2. Dez. 2019 um 04:17 Uhr schrieb Fu, Ting :
> >
> >
> >
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > > Michael Niedermayer
> > > Sent: Friday, November 29, 2019 05:33 AM
> > > To: FFmpeg development discussions and patches
> > > 
> > > Subject: Re: [FFmpeg-devel] [PATCH 1/2] libswscale/x86/yuv2rgb:
> > > Change inline assembly into nasm code
> > >
> > > On Thu, Nov 28, 2019 at 02:07:07PM +0800, Ting Fu wrote:
> > > > Signed-off-by: Ting Fu 
> > > > ---
> > > >  libswscale/x86/Makefile   |   1 +
> > > >  libswscale/x86/swscale.c  |  16 +-
> > > >  libswscale/x86/yuv2rgb.c  |  81 ++
> > > >  libswscale/x86/yuv2rgb_template.c | 441 ++
> > > >  libswscale/x86/yuv_2_rgb.asm  | 270 ++
> > > >  5 files changed, 394 insertions(+), 415 deletions(-)  create mode
> > > > 100644 libswscale/x86/yuv_2_rgb.asm
> > >
> > > This changes the output, i presume that is unintentional
> > >
> > > ./ffmpeg -cpuflags 0 -i matrixbench_mpeg2.mpg -t 1 -vf
> > > format=yuv420p,format=rgb565le -an -f framecrc -
> > >
> > > 0,  0,  0,1,   829440, 0x1bd78b86
> > > 0,  1,  1,1,   829440, 0x85910b33
> > > ...
> > > vs.
> > > 0,  0,  0,1,   829440, 0x31f4a2bd
> > > 0,  1,  1,1,   829440, 0xf0c66218
> > > ...
> > >
> > >
> >
> > Hi Michael,
> >
> > This unexpected change is because of the missing verify of current SIMD
> support.
> > So, when cpuflag=0, ffmpeg used mmx code to compute as default.
> > I added if (EXTERNAL_XXX(cpu_flags)) to verify the SIMD in
> libswscale/x86/yuv2rgb.c.
> 
> Could the patch be split to make this change easier to understand?

Hi Carl,

I didn’t come across any good idea to separate the PATCH. 
Since the [PATCH 1/2] is consisted of mmx code for 
yuv2rgb24/bgr24/rgb32/bgr32/rgb15/rgb16 and they're all come from former inline 
assembly.
Should it be separated into something like 
PATCH 1: mmx yuv2rgb24/bgr24
PATCH 2: mmx yuv2rgb32/bgr32
PATCH 3: mmx yuv2rgb15/rgb16
Or adding more comments in nasm file would be more helpful?

Can you show me if there is any better solution? I cannot be more grateful to 
it.

Thank you,
Ting Fu

> 
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@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] avfilter: Add tonemap vaapi filter for H2S

2019-12-02 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Xinpeng Sun
> Sent: Monday, December 2, 2019 15:17
> To: ffmpeg-devel@ffmpeg.org
> Cc: Sun, Xinpeng ; Zhou, Zachary
> 
> Subject: [FFmpeg-devel] [PATCH v3] avfilter: Add tonemap vaapi filter for
> H2S
> 
> 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 
> ---
>  configure  |   2 +
>  doc/filters.texi   |  81 +++
>  libavfilter/Makefile   |   1 +
>  libavfilter/allfilters.c   |   1 +
>  libavfilter/vf_tonemap_vaapi.c | 420
> +
>  5 files changed, 505 insertions(+)
>  create mode 100644 libavfilter/vf_tonemap_vaapi.c
> 
> diff --git a/configure b/configure
> index ca7137f341..5272fb2a57 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"
> @@ -6576,6 +6577,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
>  check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags
>  check_type "va/va.h va/va_enc_hevc.h"
> "VAEncPictureParameterBufferHEVC"
>  check_type "va/va.h va/va_enc_jpeg.h"
> "VAEncPictureParameterBufferJPEG"
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 5fdec6f015..7223ab89a3 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -20972,6 +20972,87 @@ Apply a strong blur of both luma and chroma
> parameters:
> 
>  @c man end OPENCL VIDEO FILTERS
> 
> +@chapter VAAPI Video Filters
> +@c man begin VAAPI VIDEO FILTERS
> +
> +VAAPI Video filters are usually used with VAAPI decoder and VAAPI
> encoder. Below is a description of VAAPI video filters.
> +
> +To enable compilation of these filters you need to configure FFmpeg with
> +@code{--enable-vaapi}.
> +
> +Running VAAPI filters requires you to initialize a hardware device and to
> pass that device to all filters in any filter graph.
> +@table @option
> +
> +@item -hwaccel vaapi
> +Specify the hardware accelerator as @var{vaapi}.
> +
> +@item -vaapi_device @var{driver_path}
> +Specify the vaapi driver path with @var{driver_path}.
> +
> +@item -hwaccel_output_format @var{vaapi}
> +Specify the output format of hardware accelerator as @var{vaapi}. All
> VAAPI hardware surfaces in ffmpeg are represented by the @var{vaapi}
> pixfmt.
> +
> +@end table
> +
> +@itemize
> +@item
> +Example of running tonemap_vaapi filter with default parameters on it.
> +@example
> +-hwaccel vaapi -vaapi_device /dev/dri/renderD128 -
> hwaccel_output_format vaapi -i INPUT -vf "tonemap_vaapi, hwdownload"
> OUTPUT
> +@end example
> +@end itemize
> +
> +Since VAAPI filters are not able to access frame data in arbitrary memory, so
> if you use a decoder other than VAAPI decoder before VAAPI filters, all
> frame data needs to be uploaded(@ref{hwupload}) to hardware surfaces
> connected to the appropriate device before being used. Also if you add a
> encoder other than VAAPI encoder after VAAPI filters,

How about VAAPI decoder/filter + QSV encoder?

___
ffmpeg-devel mailing list
ffmpeg-devel@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 2/5] lavc/libxavs2.c: avoid recomputations of pointers in xavs2_copy_frame* functions

2019-12-02 Thread hwren
Signed-off-by: hwren 
---
 libavcodec/libxavs2.c | 32 +++-
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 3896f3b..0e525ee 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -132,28 +132,42 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 
 static void xavs2_copy_frame_with_shift(xavs2_picture_t *pic, const AVFrame 
*frame, const int shift_in)
 {
-int plane, hIdx, wIdx;
+uint16_t *p_plane;
+uint8_t *p_buffer;
+int plane;
+int hIdx;
+int wIdx;
+
 for (plane = 0; plane < 3; plane++) {
-int i_stride = pic->img.i_stride[plane];
+p_plane = (uint16_t *)pic->img.img_planes[plane];
+p_buffer = frame->data[plane];
 for (hIdx = 0; hIdx < pic->img.i_lines[plane]; hIdx++) {
-uint16_t *p_plane = (uint16_t *)>img.img_planes[plane][hIdx * 
i_stride];
-uint8_t *p_buffer = frame->data[plane] + frame->linesize[plane] * 
hIdx;
-memset(p_plane, 0, i_stride);
+memset(p_plane, 0, pic->img.i_stride[plane]);
 for (wIdx = 0; wIdx < pic->img.i_width[plane]; wIdx++) {
 p_plane[wIdx] = p_buffer[wIdx] << shift_in;
 }
+p_plane += pic->img.i_stride[plane];
+p_buffer += frame->linesize[plane];
 }
 }
 }
 
 static void xavs2_copy_frame(xavs2_picture_t *pic, const AVFrame *frame)
 {
-int plane, hIdx;
+uint8_t *p_plane;
+uint8_t *p_buffer;
+int plane;
+int hIdx;
+int stride;
+
 for (plane = 0; plane < 3; plane++) {
+p_plane = pic->img.img_planes[plane];
+p_buffer = frame->data[plane];
+stride = pic->img.i_width[plane] * pic->img.in_sample_size;
 for (hIdx = 0; hIdx < pic->img.i_lines[plane]; hIdx++) {
-memcpy( pic->img.img_planes[plane] + pic->img.i_stride[plane] * 
hIdx,
-frame->data[plane]+frame->linesize[plane] * hIdx,
-pic->img.i_width[plane] * pic->img.in_sample_size);
+memcpy(p_plane, p_buffer, stride);
+p_plane += pic->img.i_stride[plane];
+p_buffer += frame->linesize[plane];
 }
 }
 }
-- 
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 v2 5/5] lavc/libxavs2.c: optimize error descriptions

2019-12-02 Thread hwren
Signed-off-by: hwren 
---
 libavcodec/libxavs2.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 3dfe755..6ee2280 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -72,13 +72,13 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 /* get API handler */
 cae->api = xavs2_api_get(bit_depth);
 if (!cae->api) {
-av_log(avctx, AV_LOG_ERROR, "api get failed\n");
+av_log(avctx, AV_LOG_ERROR, "Failed to get xavs2 api context\n");
 return AVERROR_EXTERNAL;
 }
 
 cae->param = cae->api->opt_alloc();
 if (!cae->param) {
-av_log(avctx, AV_LOG_ERROR, "param alloc failed\n");
+av_log(avctx, AV_LOG_ERROR, "Failed to alloc xavs2 parameters\n");
 return AVERROR(ENOMEM);
 }
 
@@ -124,7 +124,7 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 cae->encoder = cae->api->encoder_create(cae->param);
 
 if (!cae->encoder) {
-av_log(avctx, AV_LOG_ERROR, "Can not create encoder. Null pointer 
returned\n");
+av_log(avctx, AV_LOG_ERROR, "Failed to create xavs2 encoder 
instance.\n");
 return AVERROR(EINVAL);
 }
 
@@ -183,7 +183,7 @@ static int xavs2_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 /* create the XAVS2 video encoder */
 /* read frame data and send to the XAVS2 video encoder */
 if (cae->api->encoder_get_buffer(cae->encoder, ) < 0) {
-av_log(avctx, AV_LOG_ERROR, "failed to get frame buffer\n");
+av_log(avctx, AV_LOG_ERROR, "Failed to get xavs2 frame buffer\n");
 return AVERROR_EXTERNAL;
 }
 if (frame) {
@@ -214,7 +214,7 @@ static int xavs2_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 ret = cae->api->encoder_encode(cae->encoder, , >packet);
 
 if (ret) {
-av_log(avctx, AV_LOG_ERROR, "encode failed\n");
+av_log(avctx, AV_LOG_ERROR, "Encoding error occured.\n");
 return AVERROR_EXTERNAL;
 }
 
@@ -224,7 +224,7 @@ static int xavs2_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 
 if ((cae->packet.len) && (cae->packet.state != XAVS2_STATE_FLUSH_END)) {
 if (av_new_packet(pkt, cae->packet.len) < 0) {
-av_log(avctx, AV_LOG_ERROR, "packet alloc failed\n");
+av_log(avctx, AV_LOG_ERROR, "Failed to alloc xavs2 packet.\n");
 cae->api->encoder_packet_unref(cae->encoder, >packet);
 return AVERROR(ENOMEM);
 }
-- 
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 v2 3/5] lavc/libxavs2.c: fix code style - spaces

2019-12-02 Thread hwren
Signed-off-by: hwren 
---
 libavcodec/libxavs2.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 0e525ee..0aa4d31 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -59,7 +59,7 @@ typedef struct XAVS2EContext {
 
 static av_cold int xavs2_init(AVCodecContext *avctx)
 {
-XAVS2EContext *cae= avctx->priv_data;
+XAVS2EContext *cae = avctx->priv_data;
 int bit_depth, code;
 
 bit_depth = avctx->pix_fmt == AV_PIX_FMT_YUV420P ? 8 : 10;
@@ -115,15 +115,13 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 xavs2_opt_set2("InitialQP", "%d", cae->qp);
 }
 
-
 ff_mpeg12_find_best_frame_rate(avctx->framerate, , NULL, NULL, 0);
-
 xavs2_opt_set2("FrameRate",   "%d", code);
 
 cae->encoder = cae->api->encoder_create(cae->param);
 
 if (!cae->encoder) {
-av_log(avctx,AV_LOG_ERROR, "Can not create encoder. Null pointer 
returned\n");
+av_log(avctx, AV_LOG_ERROR, "Can not create encoder. Null pointer 
returned\n");
 return AVERROR(EINVAL);
 }
 
@@ -182,7 +180,7 @@ static int xavs2_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 /* create the XAVS2 video encoder */
 /* read frame data and send to the XAVS2 video encoder */
 if (cae->api->encoder_get_buffer(cae->encoder, ) < 0) {
-av_log(avctx,AV_LOG_ERROR, "failed to get frame buffer\n");
+av_log(avctx, AV_LOG_ERROR, "failed to get frame buffer\n");
 return AVERROR_EXTERNAL;
 }
 if (frame) {
@@ -221,9 +219,8 @@ static int xavs2_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 cae->api->encoder_encode(cae->encoder, NULL, >packet);
 }
 
-if ((cae->packet.len) && (cae->packet.state != XAVS2_STATE_FLUSH_END)){
-
-if (av_new_packet(pkt, cae->packet.len) < 0){
+if ((cae->packet.len) && (cae->packet.state != XAVS2_STATE_FLUSH_END)) {
+if (av_new_packet(pkt, cae->packet.len) < 0) {
 av_log(avctx, AV_LOG_ERROR, "packet alloc failed\n");
 cae->api->encoder_packet_unref(cae->encoder, >packet);
 return AVERROR(ENOMEM);
-- 
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 v2 1/5] lavc/libxavs2.c: use more descriptive variable names in xavs2_copy_frame* functions

2019-12-02 Thread hwren
Signed-off-by: hwren 
---
 libavcodec/libxavs2.c | 29 ++---
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 0179a1e..3896f3b 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -132,16 +132,15 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 
 static void xavs2_copy_frame_with_shift(xavs2_picture_t *pic, const AVFrame 
*frame, const int shift_in)
 {
-int j, k;
-for (k = 0; k < 3; k++) {
-int i_stride = pic->img.i_stride[k];
-for (j = 0; j < pic->img.i_lines[k]; j++) {
-uint16_t *p_plane = (uint16_t *)>img.img_planes[k][j * 
i_stride];
-int i;
-uint8_t *p_buffer = frame->data[k] + frame->linesize[k] * j;
+int plane, hIdx, wIdx;
+for (plane = 0; plane < 3; plane++) {
+int i_stride = pic->img.i_stride[plane];
+for (hIdx = 0; hIdx < pic->img.i_lines[plane]; hIdx++) {
+uint16_t *p_plane = (uint16_t *)>img.img_planes[plane][hIdx * 
i_stride];
+uint8_t *p_buffer = frame->data[plane] + frame->linesize[plane] * 
hIdx;
 memset(p_plane, 0, i_stride);
-for (i = 0; i < pic->img.i_width[k]; i++) {
-p_plane[i] = p_buffer[i] << shift_in;
+for (wIdx = 0; wIdx < pic->img.i_width[plane]; wIdx++) {
+p_plane[wIdx] = p_buffer[wIdx] << shift_in;
 }
 }
 }
@@ -149,12 +148,12 @@ static void xavs2_copy_frame_with_shift(xavs2_picture_t 
*pic, const AVFrame *fra
 
 static void xavs2_copy_frame(xavs2_picture_t *pic, const AVFrame *frame)
 {
-int j, k;
-for (k = 0; k < 3; k++) {
-for (j = 0; j < pic->img.i_lines[k]; j++) {
-memcpy( pic->img.img_planes[k] + pic->img.i_stride[k] * j,
-frame->data[k]+frame->linesize[k] * j,
-pic->img.i_width[k] * pic->img.in_sample_size);
+int plane, hIdx;
+for (plane = 0; plane < 3; plane++) {
+for (hIdx = 0; hIdx < pic->img.i_lines[plane]; hIdx++) {
+memcpy( pic->img.img_planes[plane] + pic->img.i_stride[plane] * 
hIdx,
+frame->data[plane]+frame->linesize[plane] * hIdx,
+pic->img.i_width[plane] * pic->img.in_sample_size);
 }
 }
 }
-- 
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 v2 4/5] lavc/libxavs2.c: replace deprecated parameter 'FrameRate' with new parameter 'fps'

2019-12-02 Thread hwren
Signed-off-by: hwren 
---
 libavcodec/libxavs2.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 0aa4d31..3dfe755 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -60,10 +60,15 @@ typedef struct XAVS2EContext {
 static av_cold int xavs2_init(AVCodecContext *avctx)
 {
 XAVS2EContext *cae = avctx->priv_data;
-int bit_depth, code;
+int bit_depth;
+double framerate = 30.0;
 
 bit_depth = avctx->pix_fmt == AV_PIX_FMT_YUV420P ? 8 : 10;
 
+if (avctx->framerate.den > 0 && avctx->framerate.num > 0) {
+framerate = av_q2d(avctx->framerate);
+}
+
 /* get API handler */
 cae->api = xavs2_api_get(bit_depth);
 if (!cae->api) {
@@ -83,6 +88,7 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 xavs2_opt_set2("BitDepth",  "%d", bit_depth);
 xavs2_opt_set2("Log",   "%d", cae->log_level);
 xavs2_opt_set2("Preset","%d", cae->preset_level);
+xavs2_opt_set2("fps",   "%.3lf", framerate);
 
 xavs2_opt_set2("IntraPeriodMax","%d", avctx->gop_size);
 xavs2_opt_set2("IntraPeriodMin","%d", avctx->gop_size);
@@ -115,9 +121,6 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 xavs2_opt_set2("InitialQP", "%d", cae->qp);
 }
 
-ff_mpeg12_find_best_frame_rate(avctx->framerate, , NULL, NULL, 0);
-xavs2_opt_set2("FrameRate",   "%d", code);
-
 cae->encoder = cae->api->encoder_create(cae->param);
 
 if (!cae->encoder) {
-- 
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] MAINTAINERS: add myself to libavfilter/dnn

2019-12-02 Thread Pedro Arthur
LGTM.

Em seg, 2 de dez de 2019 06:17, Steven Liu  escreveu:

>
>
> > 在 2019年11月30日,12:24,Guo, Yejun  写道:
> >
> > Signed-off-by: Guo, Yejun 
> > ---
> > MAINTAINERS | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 7f60ef0..5d02520 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -369,6 +369,8 @@ Filters:
> > Sources:
> >   vsrc_mandelbrot.c Michael Niedermayer
> >
> > +dnn Yejun Guo
> > +
> > libavformat
> > ===
> >
> > --
> > 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".
> Patch will be applied after 24 hours if there have no objections.
> Because Yejun Guo is interested in this part, he continuous focus on
> optimization the dnn codes.
>
> 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".
___
ffmpeg-devel mailing list
ffmpeg-devel@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] Patch for memory optimization with QuickTime/MP4

2019-12-02 Thread Michael Niedermayer
On Mon, Dec 02, 2019 at 02:12:14PM +, Jörg Beckmann wrote:
> After discussion with Carl Eugen, I replaced the "if" in line 7737 with an 
> assert().
> 
> There is still the question, whether mov_switch_root() might be called when 
> reading from a file. If someone is really really sure that it cannot happen 
> at all, the check in mov_read_seek() could be removed.
> 
> Jörg
> 
> ---
> libavformat/isom.h |  1 +
> libavformat/mov.c  | 50 +-
> 2 files changed, 50 insertions(+), 1 deletion(-)

this patch seems to have been damaged

Applying: Patch for memory optimization with QuickTime/MP4
error: corrupt patch at line 24
error: could not build fake ancestor
Patch failed at 0001 Patch for memory optimization with QuickTime/MP4


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

"Nothing to hide" only works if the folks in power share the values of
you and everyone you know entirely and always will -- Tom Scott



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] ffmpeg_filter: enhance reporting of unconnected pads.

2019-12-02 Thread Nicolas George
Carl Eugen Hoyos (12019-12-02):
> Does this change behaviour apart from printing an error message?

I thought it did not, but I re-checked to reply, and it does. Patch
withdrawn, for now.

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".

Re: [FFmpeg-devel] [PATCH v3] avfilter: Add tonemap vaapi filter for H2S

2019-12-02 Thread Vittorio Giovara
On Mon, Dec 2, 2019 at 2:19 AM Xinpeng Sun  wrote:

> 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 
> ---
>  configure  |   2 +
>  doc/filters.texi   |  81 +++
>  libavfilter/Makefile   |   1 +
>  libavfilter/allfilters.c   |   1 +
>  libavfilter/vf_tonemap_vaapi.c | 420 +
>  5 files changed, 505 insertions(+)
>  create mode 100644 libavfilter/vf_tonemap_vaapi.c
>
> diff --git a/configure b/configure
> index ca7137f341..5272fb2a57 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"
> @@ -6576,6 +6577,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
>  check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags
>  check_type "va/va.h va/va_enc_hevc.h"
> "VAEncPictureParameterBufferHEVC"
>  check_type "va/va.h va/va_enc_jpeg.h"
> "VAEncPictureParameterBufferJPEG"
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 5fdec6f015..7223ab89a3 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -20972,6 +20972,87 @@ Apply a strong blur of both luma and chroma
> parameters:
>
>  @c man end OPENCL VIDEO FILTERS
>
> +@chapter VAAPI Video Filters
> +@c man begin VAAPI VIDEO FILTERS
> +
> +VAAPI Video filters are usually used with VAAPI decoder and VAAPI
> encoder. Below is a description of VAAPI video filters.
> +
> +To enable compilation of these filters you need to configure FFmpeg with
> +@code{--enable-vaapi}.
> +
> +Running VAAPI filters requires you to initialize a hardware device and to
> pass that device to all filters in any filter graph.
> +@table @option
> +
> +@item -hwaccel vaapi
> +Specify the hardware accelerator as @var{vaapi}.
> +
> +@item -vaapi_device @var{driver_path}
> +Specify the vaapi driver path with @var{driver_path}.
> +
> +@item -hwaccel_output_format @var{vaapi}
> +Specify the output format of hardware accelerator as @var{vaapi}. All
> VAAPI hardware surfaces in ffmpeg are represented by the @var{vaapi} pixfmt.
> +
> +@end table
> +
> +@itemize
> +@item
> +Example of running tonemap_vaapi filter with default parameters on it.
> +@example
> +-hwaccel vaapi -vaapi_device /dev/dri/renderD128 -hwaccel_output_format
> vaapi -i INPUT -vf "tonemap_vaapi, hwdownload" OUTPUT
> +@end example
> +@end itemize
> +
> +Since VAAPI filters are not able to access frame data in arbitrary
> memory, so if you use a decoder other than VAAPI decoder before VAAPI
> filters, all frame data needs to be uploaded(@ref{hwupload}) to hardware
> surfaces connected to the appropriate device before being used. Also if you
> add a encoder other than VAAPI encoder after VAAPI filters, the hardware
> surfaces should be downloaded(@ref{hwdownload}) back to normal memory. Note
> that @ref{hwupload} will upload to a surface with the same layout as the
> software frame, so it may be necessary to add a @ref{format} filter
> immediately before to get the input into the right format and
> @ref{hwdownload} does not support all formats on the output - it may be
> necessary to insert an additional @ref{format} filter immediately following
> in the graph to get the output in a supported format.
> +
> +@section tonemap_vappi
> +
> +Perform HDR(High Dynamic Range) to SDR(Standard Dynamic Range) conversion
> with tone-mapping.
> +It maps the dynamic range of HDR10 content to the SDR content.
> +It only accepts HDR10 as input temporarily.
> +
> +It accepts the following parameters:
> +
> +@table @option
> +@item format
> +Specify the output pixel format.
> +
> +Currently supported formats are:
> +@table @var
> +@item p010
> +@item nv12
> +@end table
> +
> +Default is nv12.
> +
> +@item primaries, p
> +Set the output color primaries.
> +
> +Default is same as input.
> +
> +@item transfer, t
> +Set the output transfer characteristics.
> +
> +Default is bt709.
> +
> +@item matrix, m
> +Set the output colorspace matrix.
> +
> +Default is same as input.
> +
> +@end table
> +
> +@subsection Example
> 

Re: [FFmpeg-devel] [PATCH] ffmpeg_filter: enhance reporting of unconnected pads.

2019-12-02 Thread Carl Eugen Hoyos
Am Mo., 2. Dez. 2019 um 19:19 Uhr schrieb Nicolas George :
>
> Signed-off-by: Nicolas George 
> ---
>  fftools/ffmpeg_filter.c | 7 +++
>  1 file changed, 7 insertions(+)
>
> diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
> index 72838de1e2..ff46ffab01 100644
> --- a/fftools/ffmpeg_filter.c
> +++ b/fftools/ffmpeg_filter.c
> @@ -269,6 +269,13 @@ static void init_input_filter(FilterGraph *fg, 
> AVFilterInOut *in)
>  char *p;
>  int file_idx = strtol(in->name, , 0);
>
> +av_log(0, 16, "name = %s\n", in->name);
> +if (p == in->name) {
> +av_log(NULL, AV_LOG_FATAL,
> +   "Unconnected pad [%s] is not a stream selector in 
> filtergraph description %s.\n",
> +   in->name, fg->graph_desc);

> +exit_program(1);

Does this change behaviour apart from printing an error message?

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@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] ffmpeg_filter: enhance reporting of unconnected pads.

2019-12-02 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 fftools/ffmpeg_filter.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 72838de1e2..ff46ffab01 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -269,6 +269,13 @@ static void init_input_filter(FilterGraph *fg, 
AVFilterInOut *in)
 char *p;
 int file_idx = strtol(in->name, , 0);
 
+av_log(0, 16, "name = %s\n", in->name);
+if (p == in->name) {
+av_log(NULL, AV_LOG_FATAL,
+   "Unconnected pad [%s] is not a stream selector in 
filtergraph description %s.\n",
+   in->name, fg->graph_desc);
+exit_program(1);
+}
 if (file_idx < 0 || file_idx >= nb_input_files) {
 av_log(NULL, AV_LOG_FATAL, "Invalid file index %d in filtergraph 
description %s.\n",
file_idx, fg->graph_desc);
-- 
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 2/3] avformat/movenc: ensure we don't write the major brand as a compatible brand more than once

2019-12-02 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/movenc.c | 32 +-
 tests/ref/fate/binsub-movtextenc |  2 +-
 tests/ref/fate/copy-psp  |  2 +-
 tests/ref/fate/movenc| 74 
 tests/ref/lavf/ismv  | 12 +++---
 5 files changed, 67 insertions(+), 55 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index afce95042e..a632882ab2 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4800,20 +4800,32 @@ static int mov_write_ftyp_tag(AVIOContext *pb, 
AVFormatContext *s)
 // Write the major brand as the first compatible brand as well
 mov_write_ftyp_tag_internal(pb, s, has_h264, has_video, 0);
 
+// Write compatible brands, ensuring that we don't write the major brand 
as a
+// compatible brand a second time.
 if (mov->mode == MODE_ISM) {
 ffio_wfourcc(pb, "piff");
-} else if (!(mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF)) {
-ffio_wfourcc(pb, "isom");
-ffio_wfourcc(pb, "iso2");
-if (has_h264)
-ffio_wfourcc(pb, "avc1");
+} else if (mov->mode != MODE_MOV) {
+// We add tfdt atoms when fragmenting, signal this with the iso6 
compatible
+// brand. This is compatible with users that don't understand tfdt.
+if (mov->flags & FF_MOV_FLAG_FRAGMENT)
+ffio_wfourcc(pb, "iso6");
+if (mov->mode != MODE_MP4) {
+if (mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF)
+ffio_wfourcc(pb, "iso5");
+else if (mov->flags & FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS)
+ffio_wfourcc(pb, "iso4");
+}
+// Brands prior to iso5 can't be signaled when using 
default-base-is-moof
+if (!(mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF)) {
+// write isom for mp4 only if it it's not the major brand already.
+if (mov->mode != MODE_MP4 || mov->flags & 
FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS)
+ffio_wfourcc(pb, "isom");
+ffio_wfourcc(pb, "iso2");
+if (has_h264)
+ffio_wfourcc(pb, "avc1");
+}
 }
 
-// We add tfdt atoms when fragmenting, signal this with the iso6 compatible
-// brand. This is compatible with users that don't understand tfdt.
-if (mov->flags & FF_MOV_FLAG_FRAGMENT && mov->mode != MODE_ISM)
-ffio_wfourcc(pb, "iso6");
-
 if (mov->mode == MODE_MP4)
 ffio_wfourcc(pb, "mp41");
 
diff --git a/tests/ref/fate/binsub-movtextenc b/tests/ref/fate/binsub-movtextenc
index dacee0931e..78c05f4376 100644
--- a/tests/ref/fate/binsub-movtextenc
+++ b/tests/ref/fate/binsub-movtextenc
@@ -1 +1 @@
-66b25412f7ca699ee525ba162246edb6
+35adf776cd73e808186ae7124445f4b8
diff --git a/tests/ref/fate/copy-psp b/tests/ref/fate/copy-psp
index 44ec461265..8b2cef87fa 100644
--- a/tests/ref/fate/copy-psp
+++ b/tests/ref/fate/copy-psp
@@ -1,4 +1,4 @@
-65a177552e03123c9a62ddb942970d05 *tests/data/fate/copy-psp.psp
+8578401522773d0832f538ac915ad0b0 *tests/data/fate/copy-psp.psp
 2041445 tests/data/fate/copy-psp.psp
 #extradata 0:   51, 0xaf6d1012
 #extradata 1:2, 0x00b200a1
diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc
index 5e8f324ea3..68ce3f6cd9 100644
--- a/tests/ref/fate/movenc
+++ b/tests/ref/fate/movenc
@@ -2,127 +2,127 @@ write_data len 36, time nopts, type header atom ftyp
 write_data len 2389, time nopts, type header atom -
 write_data len 788, time 100, type sync atom moof
 write_data len 110, time nopts, type trailer atom -
-17a37691eba8b858cf15e60aa9a7dbf7 3323 non-empty-moov
+66cf48604f039aa9a51711786f5c8778 3323 non-empty-moov
 write_data len 36, time nopts, type header atom ftyp
 write_data len 2721, time nopts, type header atom -
 write_data len 908, time 97, type sync atom moof
 write_data len 110, time nopts, type trailer atom -
-0026ffe059c06c592021f972bf2c5e79 3775 non-empty-moov-elst
+04b2e86f455af94f9258b8d66dbf71f5 3775 non-empty-moov-elst
 write_data len 36, time nopts, type header atom ftyp
 write_data len 2629, time nopts, type header atom -
 write_data len 908, time 100, type sync atom moof
 write_data len 110, time nopts, type trailer atom -
-c184e168ac1e5bb3d9c70e580ab6179c 3683 non-empty-moov-no-elst
-write_data len 20, time nopts, type header atom ftyp
+e9f6fa032d6d8265d67aef5de81a48bf 3683 non-empty-moov-no-elst
+write_data len 24, time nopts, type header atom ftyp
 write_data len 1171, time nopts, type header atom -
 write_data len 728, time 0, type sync atom moof
 write_data len 828, time nopts, type unknown atom -
 write_data len 728, time 1046439, type sync atom moof
 write_data len 812, time nopts, type unknown atom -
 write_data len 148, time nopts, type trailer atom -
-49bf122c4c732a344ef68b58acd19be5 4435 ismv
+a7c93f998e88fee1159580b6ca7e3d2b 4439 ismv
 write_data len 36, time nopts, type header atom ftyp
 write_data len 1123, time nopts, type header atom -
 write_data len 796, time 0, type sync atom moof
 

[FFmpeg-devel] [PATCH 3/5] lavfi/buffersrc: remove poll_frame.

2019-12-02 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/buffersrc.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index d0ddc6b950..e95d9c4f49 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -455,19 +455,11 @@ static int request_frame(AVFilterLink *link)
 return ret;
 }
 
-static int poll_frame(AVFilterLink *link)
-{
-BufferSourceContext *c = link->src->priv;
-av_assert0(c->queued_frame == NULL);
-return c->eof ? AVERROR_EOF : 0;
-}
-
 static const AVFilterPad avfilter_vsrc_buffer_outputs[] = {
 {
 .name  = "default",
 .type  = AVMEDIA_TYPE_VIDEO,
 .request_frame = request_frame,
-.poll_frame= poll_frame,
 .config_props  = config_props,
 },
 { NULL }
@@ -492,7 +484,6 @@ static const AVFilterPad avfilter_asrc_abuffer_outputs[] = {
 .name  = "default",
 .type  = AVMEDIA_TYPE_AUDIO,
 .request_frame = request_frame,
-.poll_frame= poll_frame,
 .config_props  = config_props,
 },
 { NULL }
-- 
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 2/5] lavfi: remove ff_poll_frame().

2019-12-02 Thread Nicolas George
It is never used.

Signed-off-by: Nicolas George 
---
 libavfilter/avfilter.c | 18 --
 libavfilter/internal.h |  9 -
 2 files changed, 27 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 1004a6ee1d..baafd029e9 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -467,24 +467,6 @@ static int ff_request_frame_to_filter(AVFilterLink *link)
 return ret;
 }
 
-int ff_poll_frame(AVFilterLink *link)
-{
-int i, min = INT_MAX;
-
-if (link->srcpad->poll_frame)
-return link->srcpad->poll_frame(link);
-
-for (i = 0; i < link->src->nb_inputs; i++) {
-int val;
-if (!link->src->inputs[i])
-return AVERROR(EINVAL);
-val = ff_poll_frame(link->src->inputs[i]);
-min = FFMIN(min, val);
-}
-
-return min;
-}
-
 static const char *const var_names[] = {
 "t",
 "n",
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index 1d77808082..f98127c442 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -289,15 +289,6 @@ static inline int ff_insert_outpad(AVFilterContext *f, 
unsigned index,
   >output_pads, >outputs, p);
 }
 
-/**
- * Poll a frame from the filter chain.
- *
- * @param  link the input link
- * @return the number of immediately available frames, a negative
- * number in case of error
- */
-int ff_poll_frame(AVFilterLink *link);
-
 /**
  * Request an input frame from the filter at the other end of the link.
  *
-- 
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 4/5] lavfi: remove AVFilterPad.poll_frame().

2019-12-02 Thread Nicolas George
This design is no longer used and was replaced a long time ago.

Signed-off-by: Nicolas George 
---
 libavfilter/internal.h | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index f98127c442..abe7537b5d 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -92,17 +92,6 @@ struct AVFilterPad {
  */
 int (*filter_frame)(AVFilterLink *link, AVFrame *frame);
 
-/**
- * Frame poll callback. This returns the number of immediately available
- * samples. It should return a positive value if the next request_frame()
- * is guaranteed to return one frame (with no delay).
- *
- * Defaults to just calling the source poll_frame() method.
- *
- * Output pads only.
- */
-int (*poll_frame)(AVFilterLink *link);
-
 /**
  * Frame request callback. A call to this should result in some progress
  * towards producing output over the given link. This should return zero
-- 
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 5/5] lavfi/buffersrc: push frame directly.

2019-12-02 Thread Nicolas George
This allows to remove the queued frame entirely.

Signed-off-by: Nicolas George 
---
 libavfilter/buffersrc.c | 24 
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index e95d9c4f49..0eaa6812fc 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -43,7 +43,6 @@
 
 typedef struct BufferSourceContext {
 const AVClass*class;
-AVFrame  *queued_frame;
 AVRationaltime_base; ///< time_base to set in the output link
 AVRationalframe_rate;///< frame_rate to set in the output link
 unsigned  nb_failed_requests;
@@ -241,11 +240,11 @@ static int 
av_buffersrc_add_frame_internal(AVFilterContext *ctx,
 }
 }
 
-av_assert0(s->queued_frame == NULL);
-s->queued_frame = copy;
-if ((ret = ctx->output_pads[0].request_frame(ctx->outputs[0])) < 0)
+ret = ff_filter_frame(ctx->outputs[0], copy);
+if (ret < 0) {
+av_frame_free();
 return ret;
-av_assert0(s->queued_frame == NULL);
+}
 
 if ((flags & AV_BUFFERSRC_FLAG_PUSH)) {
 ret = push_frame(ctx->graph);
@@ -369,7 +368,6 @@ static av_cold int init_audio(AVFilterContext *ctx)
 static av_cold void uninit(AVFilterContext *ctx)
 {
 BufferSourceContext *s = ctx->priv;
-av_assert0(s->queued_frame == NULL);
 av_buffer_unref(>hw_frames_ctx);
 }
 
@@ -443,16 +441,10 @@ static int request_frame(AVFilterLink *link)
 AVFrame *frame;
 int ret;
 
-if (!c->queued_frame) {
-if (c->eof)
-return AVERROR_EOF;
-c->nb_failed_requests++;
-return AVERROR(EAGAIN);
-}
-frame = c->queued_frame;
-c->queued_frame = NULL;
-ret = ff_filter_frame(link, frame);
-return ret;
+if (c->eof)
+return AVERROR_EOF;
+c->nb_failed_requests++;
+return AVERROR(EAGAIN);
 }
 
 static const AVFilterPad avfilter_vsrc_buffer_outputs[] = {
-- 
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 1/5] lavfi/buffersrc: remove fifo.

2019-12-02 Thread Nicolas George
The frame is immediately pushed, the fifo has never more than one.

Signed-off-by: Nicolas George 
---
 libavfilter/buffersrc.c | 45 ++---
 1 file changed, 11 insertions(+), 34 deletions(-)

diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index bae7d86695..d0ddc6b950 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -25,9 +25,9 @@
 
 #include 
 
+#include "libavutil/avassert.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
-#include "libavutil/fifo.h"
 #include "libavutil/frame.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
@@ -43,7 +43,7 @@
 
 typedef struct BufferSourceContext {
 const AVClass*class;
-AVFifoBuffer *fifo;
+AVFrame  *queued_frame;
 AVRationaltime_base; ///< time_base to set in the output link
 AVRationalframe_rate;///< frame_rate to set in the output link
 unsigned  nb_failed_requests;
@@ -228,11 +228,6 @@ static int av_buffersrc_add_frame_internal(AVFilterContext 
*ctx,
 
 }
 
-if (!av_fifo_space(s->fifo) &&
-(ret = av_fifo_realloc2(s->fifo, av_fifo_size(s->fifo) +
- sizeof(copy))) < 0)
-return ret;
-
 if (!(copy = av_frame_alloc()))
 return AVERROR(ENOMEM);
 
@@ -246,15 +241,11 @@ static int 
av_buffersrc_add_frame_internal(AVFilterContext *ctx,
 }
 }
 
-if ((ret = av_fifo_generic_write(s->fifo, , sizeof(copy), NULL)) < 0) 
{
-if (refcounted)
-av_frame_move_ref(frame, copy);
-av_frame_free();
-return ret;
-}
-
+av_assert0(s->queued_frame == NULL);
+s->queued_frame = copy;
 if ((ret = ctx->output_pads[0].request_frame(ctx->outputs[0])) < 0)
 return ret;
+av_assert0(s->queued_frame == NULL);
 
 if ((flags & AV_BUFFERSRC_FLAG_PUSH)) {
 ret = push_frame(ctx->graph);
@@ -284,9 +275,6 @@ static av_cold int init_video(AVFilterContext *ctx)
 return AVERROR(EINVAL);
 }
 
-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",
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,
@@ -367,9 +355,6 @@ static av_cold int init_audio(AVFilterContext *ctx)
 return AVERROR(EINVAL);
 }
 
-if (!(s->fifo = av_fifo_alloc(sizeof(AVFrame*
-return AVERROR(ENOMEM);
-
 if (!s->time_base.num)
 s->time_base = (AVRational){1, s->sample_rate};
 
@@ -384,13 +369,8 @@ static av_cold int init_audio(AVFilterContext *ctx)
 static av_cold void uninit(AVFilterContext *ctx)
 {
 BufferSourceContext *s = ctx->priv;
-while (s->fifo && av_fifo_size(s->fifo)) {
-AVFrame *frame;
-av_fifo_generic_read(s->fifo, , sizeof(frame), NULL);
-av_frame_free();
-}
+av_assert0(s->queued_frame == NULL);
 av_buffer_unref(>hw_frames_ctx);
-av_fifo_freep(>fifo);
 }
 
 static int query_formats(AVFilterContext *ctx)
@@ -463,26 +443,23 @@ static int request_frame(AVFilterLink *link)
 AVFrame *frame;
 int ret;
 
-if (!av_fifo_size(c->fifo)) {
+if (!c->queued_frame) {
 if (c->eof)
 return AVERROR_EOF;
 c->nb_failed_requests++;
 return AVERROR(EAGAIN);
 }
-av_fifo_generic_read(c->fifo, , sizeof(frame), NULL);
-
+frame = c->queued_frame;
+c->queued_frame = NULL;
 ret = ff_filter_frame(link, frame);
-
 return ret;
 }
 
 static int poll_frame(AVFilterLink *link)
 {
 BufferSourceContext *c = link->src->priv;
-int size = av_fifo_size(c->fifo);
-if (!size && c->eof)
-return AVERROR_EOF;
-return size/sizeof(AVFrame*);
+av_assert0(c->queued_frame == NULL);
+return c->eof ? AVERROR_EOF : 0;
 }
 
 static const AVFilterPad avfilter_vsrc_buffer_outputs[] = {
-- 
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 1/2] avfilter/buffersrc: remove write-only variable

2019-12-02 Thread Nicolas George
Nicolas George (12019-12-02):
> Then ok, and it can probably be simplified further, I will look into it.

See incoming patch series.

> Patch ok in the meantime.

Patch applied. Thank you.

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 3/3] avformat/movenc: use iso6 major brand when signed CTS offsets are used in trun boxes

2019-12-02 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/movenc.c  | 15 +++
 tests/ref/fate/movenc |  8 
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index a632882ab2..bffd56644a 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4756,6 +4756,9 @@ static void mov_write_ftyp_tag_internal(AVIOContext *pb, 
AVFormatContext *s,
 minor = has_h264 ? 0x2 : 0x1;
 } else if (mov->mode == MODE_PSP)
 ffio_wfourcc(pb, "MSNV");
+else if (mov->mode == MODE_MP4 && mov->flags & FF_MOV_FLAG_FRAGMENT &&
+  mov->flags & 
FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS)
+ffio_wfourcc(pb, "iso6"); // Required when using signed CTS offsets in 
trun boxes
 else if (mov->mode == MODE_MP4 && mov->flags & 
FF_MOV_FLAG_DEFAULT_BASE_MOOF)
 ffio_wfourcc(pb, "iso5"); // Required when using default-base-is-moof
 else if (mov->mode == MODE_MP4 && mov->flags & 
FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS)
@@ -4806,10 +4809,14 @@ static int mov_write_ftyp_tag(AVIOContext *pb, 
AVFormatContext *s)
 ffio_wfourcc(pb, "piff");
 } else if (mov->mode != MODE_MOV) {
 // We add tfdt atoms when fragmenting, signal this with the iso6 
compatible
-// brand. This is compatible with users that don't understand tfdt.
-if (mov->flags & FF_MOV_FLAG_FRAGMENT)
-ffio_wfourcc(pb, "iso6");
-if (mov->mode != MODE_MP4) {
+// brand, if not already the major brand. This is compatible with 
users that
+// don't understand tfdt.
+if (mov->mode == MODE_MP4) {
+if (mov->flags & FF_MOV_FLAG_FRAGMENT && !(mov->flags & 
FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS))
+ffio_wfourcc(pb, "iso6");
+} else {
+if (mov->flags & FF_MOV_FLAG_FRAGMENT)
+ffio_wfourcc(pb, "iso6");
 if (mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF)
 ffio_wfourcc(pb, "iso5");
 else if (mov->flags & FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS)
diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc
index 68ce3f6cd9..5c6a054c1a 100644
--- a/tests/ref/fate/movenc
+++ b/tests/ref/fate/movenc
@@ -140,14 +140,14 @@ write_data len 668, time 157, type sync atom moof
 write_data len 440, time 223, type boundary atom moof
 write_data len 262, time nopts, type trailer atom -
 47cc2460c4b18390c67991cf3251409b 4209 vfr-noduration-interleave
-write_data len 1235, time nopts, type header atom ftyp
+write_data len 1231, time nopts, type header atom ftyp
 write_data len 916, time 0, type sync atom moof
 write_data len 908, time 100, type sync atom moof
 write_data len 148, time nopts, type trailer atom -
-c272739705fb78f9d9bffd4c6376c8ce 3207 delay-moov-elst-neg-cts
-write_data len 40, time nopts, type header atom ftyp
+c200a345c365dd35a31e7e62a9ae6c10 3203 delay-moov-elst-neg-cts
+write_data len 36, time nopts, type header atom ftyp
 write_data len 1123, time nopts, type header atom -
 write_data len 1188, time 0, type sync atom moof
 write_data len 908, time 103, type sync atom moof
 write_data len 148, time nopts, type trailer atom -
-26c05cd931471319def6f3d5257a6a7a 3407 empty-moov-neg-cts
+38a287dc98272ba9da0a0bf8feb72fef 3403 empty-moov-neg-cts
-- 
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 1/3] avformat/movenc: write the major brand also as the first compatible brand

2019-12-02 Thread James Almer
Signed-off-by: James Almer 
---
This is meant to be squashed with patch 2/3, otherwise it will write duplicate
compatible brands, and a lot of tests will have to be updated twice.

I'm sending it like this to make reviewing/reading easier.

 libavformat/movenc.c | 61 +++-
 1 file changed, 32 insertions(+), 29 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index dd144ae20a..afce95042e 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4740,27 +4740,11 @@ static int mov_write_mdat_tag(AVIOContext *pb, 
MOVMuxContext *mov)
 return 0;
 }
 
-/* TODO: This needs to be more general */
-static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
+static void mov_write_ftyp_tag_internal(AVIOContext *pb, AVFormatContext *s,
+int has_h264, int has_video, int 
write_minor)
 {
 MOVMuxContext *mov = s->priv_data;
-int64_t pos = avio_tell(pb);
-int has_h264 = 0, has_video = 0;
 int minor = 0x200;
-int i;
-
-for (i = 0; i < s->nb_streams; i++) {
-AVStream *st = s->streams[i];
-if (is_cover_image(st))
-continue;
-if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
-has_video = 1;
-if (st->codecpar->codec_id == AV_CODEC_ID_H264)
-has_h264 = 1;
-}
-
-avio_wb32(pb, 0); /* size */
-ffio_wfourcc(pb, "ftyp");
 
 if (mov->major_brand && strlen(mov->major_brand) >= 4)
 ffio_wfourcc(pb, mov->major_brand);
@@ -4787,11 +4771,36 @@ static int mov_write_ftyp_tag(AVIOContext *pb, 
AVFormatContext *s)
 else
 ffio_wfourcc(pb, "qt  ");
 
-avio_wb32(pb, minor);
+if (write_minor)
+avio_wb32(pb, minor);
+}
 
-if (mov->mode == MODE_MOV)
-ffio_wfourcc(pb, "qt  ");
-else if (mov->mode == MODE_ISM) {
+static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
+{
+MOVMuxContext *mov = s->priv_data;
+int64_t pos = avio_tell(pb);
+int has_h264 = 0, has_video = 0;
+int i;
+
+for (i = 0; i < s->nb_streams; i++) {
+AVStream *st = s->streams[i];
+if (is_cover_image(st))
+continue;
+if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+has_video = 1;
+if (st->codecpar->codec_id == AV_CODEC_ID_H264)
+has_h264 = 1;
+}
+
+avio_wb32(pb, 0); /* size */
+ffio_wfourcc(pb, "ftyp");
+
+// Write major brand
+mov_write_ftyp_tag_internal(pb, s, has_h264, has_video, 1);
+// Write the major brand as the first compatible brand as well
+mov_write_ftyp_tag_internal(pb, s, has_h264, has_video, 0);
+
+if (mov->mode == MODE_ISM) {
 ffio_wfourcc(pb, "piff");
 } else if (!(mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF)) {
 ffio_wfourcc(pb, "isom");
@@ -4805,13 +4814,7 @@ static int mov_write_ftyp_tag(AVIOContext *pb, 
AVFormatContext *s)
 if (mov->flags & FF_MOV_FLAG_FRAGMENT && mov->mode != MODE_ISM)
 ffio_wfourcc(pb, "iso6");
 
-if (mov->mode == MODE_3GP)
-ffio_wfourcc(pb, has_h264 ? "3gp6":"3gp4");
-else if (mov->mode & MODE_3G2)
-ffio_wfourcc(pb, has_h264 ? "3g2b":"3g2a");
-else if (mov->mode == MODE_PSP)
-ffio_wfourcc(pb, "MSNV");
-else if (mov->mode == MODE_MP4)
+if (mov->mode == MODE_MP4)
 ffio_wfourcc(pb, "mp41");
 
 if (mov->flags & FF_MOV_FLAG_DASH && mov->flags & FF_MOV_FLAG_GLOBAL_SIDX)
-- 
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] tools: add a fuzzer tool for bitstream filters

2019-12-02 Thread James Almer
Signed-off-by: James Almer 
---
Untested.

The BSF can be set the same way a decoder can in target_dec_fuzzer. The
codec_id will be randomly chosen from the supported list, if any.

 tools/Makefile|   3 +
 tools/target_bsf_fuzzer.c | 166 ++
 2 files changed, 169 insertions(+)
 create mode 100644 tools/target_bsf_fuzzer.c

diff --git a/tools/Makefile b/tools/Makefile
index 370ee35416..001093105b 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -5,6 +5,9 @@ TOOLS-$(CONFIG_ZLIB) += cws2fws
 tools/target_dec_%_fuzzer.o: tools/target_dec_fuzzer.c
$(COMPILE_C) -DFFMPEG_DECODER=$*
 
+tools/target_bsf_%_fuzzer.o: tools/target_bsf_fuzzer.c
+   $(COMPILE_C) -DFFMPEG_BSF=$*
+
 tools/target_dem_fuzzer.o: tools/target_dem_fuzzer.c
$(COMPILE_C)
 
diff --git a/tools/target_bsf_fuzzer.c b/tools/target_bsf_fuzzer.c
new file mode 100644
index 00..6849aaed0d
--- /dev/null
+++ b/tools/target_bsf_fuzzer.c
@@ -0,0 +1,166 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "libavutil/imgutils.h"
+
+#include "libavcodec/avcodec.h"
+#include "libavcodec/bsf.h"
+#include "libavcodec/bytestream.h"
+#include "libavcodec/internal.h"
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
+
+static void error(const char *err)
+{
+fprintf(stderr, "%s", err);
+exit(1);
+}
+
+static AVBitStreamFilter *f = NULL;
+
+static const uint64_t FUZZ_TAG = 0x4741542D5A5A5546ULL;
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+const uint64_t fuzz_tag = FUZZ_TAG;
+const uint8_t *last = data;
+const uint8_t *end = data + size;
+AVBSFContext *bsf = NULL;
+AVPacket in, out;
+uint64_t keyframes = 0;
+int res;
+
+if (!f) {
+#ifdef FFMPEG_BSF
+#define BSF_SYMBOL0(BSF) ff_##BSF##_bsf
+#define BSF_SYMBOL(BSF) BSF_SYMBOL0(BSF)
+extern AVBitStreamFilter BSF_SYMBOL(FFMPEG_BSF);
+f = _SYMBOL(FFMPEG_BSF);
+#else
+extern AVBitStreamFilter ff_null_bsf;
+f = _null_bsf;
+#endif
+av_log_set_level(AV_LOG_PANIC);
+}
+
+res = av_bsf_alloc(f, );
+if (res < 0)
+error("Failed memory allocation");
+
+if (size > 1024) {
+GetByteContext gbc;
+int extradata_size;
+size -= 1024;
+bytestream2_init(, data + size, 1024);
+bsf->par_in->width  = bytestream2_get_le32();
+bsf->par_in->height = bytestream2_get_le32();
+bsf->par_in->bit_rate   = bytestream2_get_le64();
+bsf->par_in->bits_per_coded_sample  = bytestream2_get_le32();
+
+if (f->codec_ids) {
+int i, j, idx = bytestream2_get_byte();
+int id = AV_CODEC_ID_NONE;
+for (i = 0, j = 0; f->codec_ids[i] != AV_CODEC_ID_NONE; i++) {
+// Iterate through all supported codec ids and get a random one
+if (idx & (1 << j)) {
+// There's at least one bsf that reports supporting more 
than eight codecs
+if (++j == 8) {
+idx = bytestream2_get_byte();
+j = 0;
+}
+continue;
+}
+id = f->codec_ids[i];
+break;
+}
+// Force using a codec if all were skipped
+if (id == AV_CODEC_ID_NONE)
+id = f->codec_ids[0];
+bsf->par_in->codec_id = id;
+bsf->par_in->codec_tag  = bytestream2_get_le32();
+}
+
+extradata_size = bytestream2_get_le32();
+
+bsf->par_in->sample_rate= bytestream2_get_le32();
+bsf->par_in->channels   = 
(unsigned)bytestream2_get_le32() % FF_SANE_NB_CHANNELS;
+bsf->par_in->block_align= bytestream2_get_le32();
+keyframes   = bytestream2_get_le64();
+
+if (extradata_size < size) {
+bsf->par_in->extradata = av_mallocz(extradata_size + 
AV_INPUT_BUFFER_PADDING_SIZE);
+if (bsf->par_in->extradata) {
+bsf->par_in->extradata_size = extradata_size;
+size 

Re: [FFmpeg-devel] [PATCH] avformat/utils.c: allows av_read_frame to return after a timeout period.

2019-12-02 Thread gga


On 1/12/19 09:05, Andreas Rheinhardt wrote:

ggarr...@gmail.com:

From: Gonzalo Garramuño 

Moved the check inside and at the end of the if (pktl) as per Michael 
Niedermayer's suggestion.
This patch is based on one from Blake Senftner ( bsenftner at earthlink.net ).

The hanging in av_read_frame can be reproduced with an rtmp stream that is 
aborted midway and ffplay (for example) playing that stream.
---
  libavformat/utils.c | 5 +
  1 file changed, 5 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 8196442dd1..653918d5a5 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1836,6 +1836,11 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
 
>internal->packet_buffer_end, pkt);
  goto return_packet;
  }
+
+if (ff_check_interrupt(>interrupt_callback)) {
+av_log(s, AV_LOG_DEBUG, "interrupted\n");
+return AVERROR_EXIT;
+}
  }
  
  ret = read_frame_internal(s, pkt);

This patch makes it possible for pkt to be still uninitialised after

the call to av_read_frame() if I am not mistaken (namely if the packet
list was initially not empty and the interrupt was triggered before
read_frame_internal() has been called). If so, this clashes with a
recently proposed patch by me
(https://ffmpeg.org/pipermail/ffmpeg-devel/2019-December/253662.html).
One could either allow av_read_frame() to return unclean packets on
error or you would have to add the necessary initializations in your
code (or you would have to make sure that your code is not triggered
before the first call to read_frame_internal()).

- Andreas
I am afraid I do not know enough of the ffmpeg internals to make the 
initialization changes you propose.

___
ffmpeg-devel mailing list
ffmpeg-devel@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/2] avformat/utils: simplify the ff_mkdir_p with SEPARATOR

2019-12-02 Thread Hendrik Leppkes
On Mon, Dec 2, 2019 at 3:36 PM Limin Wang  wrote:
>
> On Mon, Dec 02, 2019 at 09:26:11AM +0100, Hendrik Leppkes wrote:
> > On Mon, Dec 2, 2019 at 3:16 AM Limin Wang  wrote:
> > >
> > > On Sun, Dec 01, 2019 at 05:33:16PM +0100, Hendrik Leppkes wrote:
> > > > On Sun, Dec 1, 2019 at 3:08 PM  wrote:
> > > > >
> > > > > From: Limin Wang 
> > > > >
> > > > > Signed-off-by: Limin Wang 
> > > > > ---
> > > > >  libavformat/utils.c | 16 ++--
> > > > >  1 file changed, 10 insertions(+), 6 deletions(-)
> > > > >
> > > > > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > > > > index 579e6d6..993e6d2 100644
> > > > > --- a/libavformat/utils.c
> > > > > +++ b/libavformat/utils.c
> > > > > @@ -4843,12 +4843,17 @@ void av_url_split(char *proto, int proto_size,
> > > > >  }
> > > > >  }
> > > > >
> > > > > +#if HAVE_DOS_PATHS
> > > > > +#define SEPARATOR '\\'
> > > > > +#else
> > > > > +#define SEPARATOR '/'
> > > > > +#endif
> > > > > +
> > > > >  int ff_mkdir_p(const char *path)
> > > > >  {
> > > > >  int ret = 0;
> > > > >  char *temp = av_strdup(path);
> > > > >  char *pos = temp;
> > > > > -char tmp_ch = '\0';
> > > > >
> > > > >  if (!path || !temp) {
> > > > >  return -1;
> > > > > @@ -4856,19 +4861,18 @@ int ff_mkdir_p(const char *path)
> > > > >
> > > > >  if (*temp == '.')
> > > > >  pos++;
> > > > > -if (*temp == '/' || *temp == '\\')
> > > > > +if (*temp == SEPARATOR)
> > > > >  pos++;
> > > > >
> > > > >  for ( ; *pos != '\0'; ++pos) {
> > > > > -if (*pos == '/' || *pos == '\\') {
> > > > > -tmp_ch = *pos;
> > > > > +if (*pos == SEPARATOR) {
> > > > >  *pos = '\0';
> > > > >  ret = mkdir(temp, 0755);
> > > > > -*pos = tmp_ch;
> > > > > +*pos = SEPARATOR;
> > > > >  }
> > > > >  }
> > > > >
> > > > > -if ((*(pos - 1) != '/') || (*(pos - 1) != '\\')) {
> > > > > +if (*(pos - 1) != SEPARATOR) {
> > > > >  ret = mkdir(temp, 0755);
> > > > >  }
> > > >
> > > > I think there is some value to be able to specify a path with both
> > > > kinds of slashes. For example, most of everything else on Windows will
> > > > accept normal slashes, in addition to the default backslash.
> > > Hendrik, I haven't got your point yet, can you make it clear so that I
> > > can change the patch for your case.
> > >
> > > For example, on Linux, if the path is:
> > >  ~/Movies/hl\\s/vs%v/manifest.m3u8
> > >
> > > The current code will mkdir below path:
> > > path: /Users
> > > path: /Users/lmwang
> > > path: /Users/lmwang/Movies
> > > path: /Users/lmwang/Movies/hl   >>> unexpected
> > > path: /Users/lmwang/Movies/hl\s
> > > path: /Users/lmwang/Movies/hl\s/vs0
> > >
> > > You can see /Users/lmwang/Movies/hl directory isn't expected directory 
> > > which is created.
> > >
> > > After applied the patch, it'll not create it anymore.
> > >
> >
> > But if I'm on Windows and I specify a path with normal slashes (where
> > SEPARATOR  is backslash), I would absolutely expect it to create it
> > like that. Which it does right now.
>
> Now I haven't windows system in hand, so I can't test your condition.
> For windows, the old code will consider normal slashes(/) as path separator
> instead of special charactor. Maybe I have misunderstanding for that.
>

Yes, it does, and it should continue to do so, because everything else
on Windows does as well. Both slash and backslash are valid path
seperators.

- Hendrik
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] avfilter/buffersrc: deprecate sws_param option

2019-12-02 Thread Nicolas George
zhilizhao (12019-12-02):
> You mean add attribute_deprecated? I will update the patch.

Possibly that, but most of all an FF_API_ constant like in this commit.
That way, the option will disappear automatically in a few months and
the cleanup is made easier.

https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/3aa6208db9666c0f1351855262d8c839002d9de1

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".

Re: [FFmpeg-devel] [PATCH 1/2] avfilter/buffersrc: remove write-only variable

2019-12-02 Thread Nicolas George
zhilizhao (12019-12-02):
> I can restore it, but I’m not sure whether the issue disappeared or not. 
> Current code
> call request_frame immediately after av_fifo_generic_write, while the old code
> call request_frame conditionally.

Oh, I missed that.

Then ok, and it can probably be simplified further, I will look into it.
Patch ok in the meantime.

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".

Re: [FFmpeg-devel] [PATCH 1/2] avfilter/buffersrc: remove write-only variable

2019-12-02 Thread zhilizhao


> On Dec 2, 2019, at 9:33 PM, Nicolas George  wrote:
> 
> quinkbl...@foxmail.com  (12019-12-02):
>> From: Zhao Zhili 
>> 
>> ---
>> libavfilter/buffersrc.c | 3 ---
>> 1 file changed, 3 deletions(-)
>> 
>> diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
>> index e0ff7e4dd8..bae7d86695 100644
>> --- a/libavfilter/buffersrc.c
>> +++ b/libavfilter/buffersrc.c
>> @@ -47,7 +47,6 @@ typedef struct BufferSourceContext {
>> AVRationaltime_base; ///< time_base to set in the output link
>> AVRationalframe_rate;///< frame_rate to set in the output 
>> link
>> unsigned  nb_failed_requests;
>> -unsigned  warning_limit;
>> 
>> /* video only */
>> int   w, h;
>> @@ -292,7 +291,6 @@ static av_cold int init_video(AVFilterContext *ctx)
>>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->warning_limit = 100;
>> return 0;
>> }
>> 
>> @@ -379,7 +377,6 @@ static av_cold int init_audio(AVFilterContext *ctx)
>>"tb:%d/%d samplefmt:%s samplerate:%d chlayout:%s\n",
>>s->time_base.num, s->time_base.den, 
>> av_get_sample_fmt_name(s->sample_fmt),
>>s->sample_rate, s->channel_layout_str);
>> -s->warning_limit = 100;
>> 
>> return ret;
>> }
> 
> The warning that this variable helped implement was lost during the
> merge in commit a05a44e205, but it is still relevant. It would probably
> be better to restore it, at least until buffersrc no longer include its
> own FIFO.

I can restore it, but I’m not sure whether the issue disappeared or not. 
Current code
call request_frame immediately after av_fifo_generic_write, while the old code
call request_frame conditionally.

> 
> Regards,
> 
> -- 
>  Nicolas George
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@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 2/2] avfilter/buffersrc: deprecate sws_param option

2019-12-02 Thread zhilizhao


> On Dec 2, 2019, at 9:49 PM, Nicolas George  wrote:
> 
> quinkbl...@foxmail.com (12019-12-02):
>> From: Zhao Zhili 
>> 
>> ---
>> doc/filters.texi| 4 +---
>> libavfilter/buffersrc.c | 8 ++--
>> 2 files changed, 7 insertions(+), 5 deletions(-)
> 
> Ok. But ideally you would include deprecation guards so that it is
> automatically removed in two versions.

You mean add attribute_deprecated? I will update the patch.

> 
> Regards,
> 
> -- 
>  Nicolas George
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@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 2/2] avformat/utils: simplify the ff_mkdir_p with SEPARATOR

2019-12-02 Thread Limin Wang
On Mon, Dec 02, 2019 at 09:26:11AM +0100, Hendrik Leppkes wrote:
> On Mon, Dec 2, 2019 at 3:16 AM Limin Wang  wrote:
> >
> > On Sun, Dec 01, 2019 at 05:33:16PM +0100, Hendrik Leppkes wrote:
> > > On Sun, Dec 1, 2019 at 3:08 PM  wrote:
> > > >
> > > > From: Limin Wang 
> > > >
> > > > Signed-off-by: Limin Wang 
> > > > ---
> > > >  libavformat/utils.c | 16 ++--
> > > >  1 file changed, 10 insertions(+), 6 deletions(-)
> > > >
> > > > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > > > index 579e6d6..993e6d2 100644
> > > > --- a/libavformat/utils.c
> > > > +++ b/libavformat/utils.c
> > > > @@ -4843,12 +4843,17 @@ void av_url_split(char *proto, int proto_size,
> > > >  }
> > > >  }
> > > >
> > > > +#if HAVE_DOS_PATHS
> > > > +#define SEPARATOR '\\'
> > > > +#else
> > > > +#define SEPARATOR '/'
> > > > +#endif
> > > > +
> > > >  int ff_mkdir_p(const char *path)
> > > >  {
> > > >  int ret = 0;
> > > >  char *temp = av_strdup(path);
> > > >  char *pos = temp;
> > > > -char tmp_ch = '\0';
> > > >
> > > >  if (!path || !temp) {
> > > >  return -1;
> > > > @@ -4856,19 +4861,18 @@ int ff_mkdir_p(const char *path)
> > > >
> > > >  if (*temp == '.')
> > > >  pos++;
> > > > -if (*temp == '/' || *temp == '\\')
> > > > +if (*temp == SEPARATOR)
> > > >  pos++;
> > > >
> > > >  for ( ; *pos != '\0'; ++pos) {
> > > > -if (*pos == '/' || *pos == '\\') {
> > > > -tmp_ch = *pos;
> > > > +if (*pos == SEPARATOR) {
> > > >  *pos = '\0';
> > > >  ret = mkdir(temp, 0755);
> > > > -*pos = tmp_ch;
> > > > +*pos = SEPARATOR;
> > > >  }
> > > >  }
> > > >
> > > > -if ((*(pos - 1) != '/') || (*(pos - 1) != '\\')) {
> > > > +if (*(pos - 1) != SEPARATOR) {
> > > >  ret = mkdir(temp, 0755);
> > > >  }
> > >
> > > I think there is some value to be able to specify a path with both
> > > kinds of slashes. For example, most of everything else on Windows will
> > > accept normal slashes, in addition to the default backslash.
> > Hendrik, I haven't got your point yet, can you make it clear so that I
> > can change the patch for your case.
> >
> > For example, on Linux, if the path is:
> >  ~/Movies/hl\\s/vs%v/manifest.m3u8
> >
> > The current code will mkdir below path:
> > path: /Users
> > path: /Users/lmwang
> > path: /Users/lmwang/Movies
> > path: /Users/lmwang/Movies/hl   >>> unexpected
> > path: /Users/lmwang/Movies/hl\s
> > path: /Users/lmwang/Movies/hl\s/vs0
> >
> > You can see /Users/lmwang/Movies/hl directory isn't expected directory 
> > which is created.
> >
> > After applied the patch, it'll not create it anymore.
> >
> 
> But if I'm on Windows and I specify a path with normal slashes (where
> SEPARATOR  is backslash), I would absolutely expect it to create it
> like that. Which it does right now.

Now I haven't windows system in hand, so I can't test your condition.
For windows, the old code will consider normal slashes(/) as path separator 
instead of special charactor. Maybe I have misunderstanding for that.

> 
> - Hendrik
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] lavc/h2645_parse: Don't automatically remove nuh_layer_id > 0 packets

2019-12-02 Thread Andriy Gelman
On Mon, 02. Dec 07:50, Andreas Rheinhardt wrote:
> On Mon, Dec 2, 2019 at 3:49 AM Andriy Gelman 
> wrote:
> 
> > From: Andriy Gelman 
> >
> > HEVC standard supports multi-layer streams (ITU-T H.265 02/2018 Annex
> > F). Each NAL unit belongs to a particular layer defined by nuh_layer_id
> > in the header.
> >
> > Currently, all NAL units that do not belong to a base layer are
> > automatically removed in ff_h2645_packet_split(). Some data may
> > therefore be lost when future filters/decoders are designed to support
> > multi-layer streams.
> >
> > A better approach is to forward nuh_layer_id > 0 packets and let blocks
> > down the chain decide how to process them. The condition to remove
> > packets has been moved to hevcdec and cbs bsf where such packets are
> > currently not supported.
> > ---
> >  libavcodec/cbs_h2645.c   | 3 +++
> >  libavcodec/h2645_parse.c | 7 +++
> >  libavcodec/h2645_parse.h | 5 +
> >  libavcodec/hevc_parse.c  | 2 ++
> >  libavcodec/hevc_parser.c | 2 ++
> >  libavcodec/hevcdec.c | 2 +-
> >  6 files changed, 16 insertions(+), 5 deletions(-)
> >
> > diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> > index 88fa0029cd6..9f89f1c5a55 100644
> > --- a/libavcodec/cbs_h2645.c
> > +++ b/libavcodec/cbs_h2645.c
> > @@ -562,6 +562,9 @@ static int
> > cbs_h2645_fragment_add_nals(CodedBitstreamContext *ctx,
> >
> >  for (i = 0; i < packet->nb_nals; i++) {
> >  const H2645NAL *nal = >nals[i];
> > +if (nal->nuh_layer_id > 0)
> > +continue;
> > +
> >
> 
> Mixed declaration and code. But, as James has already said: cbs should not
> drop higher layers by default.
> 
> 
> >  AVBufferRef *ref;
> >  size_t size = nal->size;
> >
> > diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
> > index 4808f79a67f..0f3343004f9 100644
> > --- a/libavcodec/h2645_parse.c
> > +++ b/libavcodec/h2645_parse.c
> > @@ -292,23 +292,22 @@ static int get_bit_length(H2645NAL *nal, int
> > skip_trailing_zeros)
> >  static int hevc_parse_nal_header(H2645NAL *nal, void *logctx)
> >  {
> >  GetBitContext *gb = >gb;
> > -int nuh_layer_id;
> >
> >  if (get_bits1(gb) != 0)
> >  return AVERROR_INVALIDDATA;
> >
> >  nal->type = get_bits(gb, 6);
> >
> > -nuh_layer_id   = get_bits(gb, 6);
> > +nal->nuh_layer_id = get_bits(gb, 6);
> >  nal->temporal_id = get_bits(gb, 3) - 1;
> >  if (nal->temporal_id < 0)
> >  return AVERROR_INVALIDDATA;
> >
> >  av_log(logctx, AV_LOG_DEBUG,
> > "nal_unit_type: %d(%s), nuh_layer_id: %d, temporal_id: %d\n",
> > -   nal->type, hevc_nal_unit_name(nal->type), nuh_layer_id,
> > nal->temporal_id);
> > +   nal->type, hevc_nal_unit_name(nal->type), nal->nuh_layer_id,
> > nal->temporal_id);
> >
> > -return nuh_layer_id == 0;
> > +return 1;
> >  }
> >
> >  static int h264_parse_nal_header(H2645NAL *nal, void *logctx)
> > diff --git a/libavcodec/h2645_parse.h b/libavcodec/h2645_parse.h
> > index 2acf882d3da..3e47f86c53b 100644
> > --- a/libavcodec/h2645_parse.h
> > +++ b/libavcodec/h2645_parse.h
> > @@ -56,6 +56,11 @@ typedef struct H2645NAL {
> >   */
> >  int temporal_id;
> >
> > +/*
> > + * HEVC only, identifier of layer to which nal unit belongs
> > + */
> > +int nuh_layer_id;
> > +
> >
> 
> You might want to add a commit on top of that to reorder the H2645NAL
> entries so that the size doesn't increase.
> 

Thanks for looking over patch. 
I'll update and resend.

-- 
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 v2] Patch for memory optimization with QuickTime/MP4

2019-12-02 Thread Jörg Beckmann
After discussion with Carl Eugen, I replaced the "if" in line 7737 with an 
assert().

There is still the question, whether mov_switch_root() might be called when 
reading from a file. If someone is really really sure that it cannot happen at 
all, the check in mov_read_seek() could be removed.

Jörg

---
libavformat/isom.h |  1 +
libavformat/mov.c  | 50 +-
2 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 4943b80ccf..9b4753f4d7 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -268,6 +268,7 @@ typedef struct MOVContext {
 int advanced_editlist;
 int ignore_chapters;
 int seek_individually;
+int discard_fragments;
 int64_t next_root_atom; ///< offset of the next root atom
 int export_all;
 int export_xmp;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 7553a7fdfc..97c02725c5 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7698,8 +7698,11 @@ static int should_retry(AVIOContext *pb, int error_code) 
{
 static int mov_switch_root(AVFormatContext *s, int64_t target, int index)
{
-int ret;
+int ret, i;
 MOVContext *mov = s->priv_data;
+AVStream *st = NULL;
+MOVStreamContext *sc;
+MOVFragment *frag;
 if (index >= 0 && index < mov->frag_index.nb_items)
 target = mov->frag_index.item[index].moof_offset;
@@ -7721,6 +7724,44 @@ static int mov_switch_root(AVFormatContext *s, int64_t 
target, int index)
 mov->found_mdat = 0;
+if (mov->discard_fragments) {
+frag = >fragment;
+
+for (i = 0; i < mov->fc->nb_streams; i++) {
+if (mov->fc->streams[i]->id == frag->track_id) {
+st = mov->fc->streams[i];
+break;
+}
+}
+
+av_assert0(st);
+
+sc = st->priv_data;
+
+switch (st->codecpar->codec_type) {
+case AVMEDIA_TYPE_AUDIO:
+case AVMEDIA_TYPE_SUBTITLE:
+/* Freeing VIDEO tables leads to corrupted video when writing 
to eg. MKV */
+av_freep(>index_entries);
+st->nb_index_entries = 0;
+st->index_entries_allocated_size = 0;
+
+sc->current_index = 0;
+sc->current_sample = 0;
+
+av_freep(>ctts_data);
+sc->ctts_data = NULL;
+sc->ctts_allocated_size = 0;
+sc->ctts_count = 0;
+break;
+}
+
+av_free(mov->frag_index.item->stream_info);
+av_freep(>frag_index.item);
+mov->frag_index.allocated_size = 0;
+mov->frag_index.nb_items = 0;
+}
+
 ret = mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX 
});
 if (ret < 0)
 return ret;
@@ -7975,6 +8016,9 @@ static int mov_read_seek(AVFormatContext *s, int 
stream_index, int64_t sample_ti
 int sample;
 int i;
+if (mc->discard_fragments)  // Seeking is not possible if fragments are 
discarded.
+return AVERROR(ENOTSUP);
+
 if (stream_index >= s->nb_streams)
 return AVERROR_INVALIDDATA;
@@ -8063,6 +8107,10 @@ static const AVOption mov_options[] = {
 { "decryption_key", "The media decryption key (hex)", 
OFFSET(decryption_key), AV_OPT_TYPE_BINARY, .flags = AV_OPT_FLAG_DECODING_PARAM 
},
 { "enable_drefs", "Enable external track support.", OFFSET(enable_drefs), 
AV_OPT_TYPE_BOOL,
 {.i64 = 0}, 0, 1, FLAGS },
+{"discard_fragments",
+"Discards fragments after they have been read to support live 
streams.",
+OFFSET(discard_fragments), AV_OPT_TYPE_BOOL, { .i64 = 0 },
+0, 1, FLAGS },
 { NULL },
};
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] avfilter/buffersrc: deprecate sws_param option

2019-12-02 Thread Nicolas George
quinkbl...@foxmail.com (12019-12-02):
> From: Zhao Zhili 
> 
> ---
>  doc/filters.texi| 4 +---
>  libavfilter/buffersrc.c | 8 ++--
>  2 files changed, 7 insertions(+), 5 deletions(-)

Ok. But ideally you would include deprecation guards so that it is
automatically removed in two versions.

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".

Re: [FFmpeg-devel] [PATCH V2 1/2] lavf/libsrt: add linger parameter to libsrt

2019-12-02 Thread Andriy Gelman
On Mon, 02. Dec 14:25, myp...@gmail.com wrote:
> On Mon, Dec 2, 2019 at 12:57 PM Andriy Gelman 
> wrote:
> >
> > On Sun, 01. Dec 21:31, Jun Zhao wrote:
> > > From: Jun Zhao 
> > >
> > > add linger parameter to libsrt, it's setting he number of seconds
> > > that the socket waits for unsent data when closing.
> >
> > minor spelling
> >
> Will fix
> > >
> > > Signed-off-by: Jun Zhao 
> > > ---
> > >  doc/protocols.texi   |4 
> > >  libavformat/libsrt.c |   13 +
> > >  2 files changed, 17 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/doc/protocols.texi b/doc/protocols.texi
> > > index 0e18a49..f34f246 100644
> > > --- a/doc/protocols.texi
> > > +++ b/doc/protocols.texi
> > > @@ -1426,6 +1426,10 @@ 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.
> >
> > I'd add infinite in brackets.
> Can't get your point, more details?

It would be good to add what -1 means here.

I initially thought it's an infinite wait but from the srt docs it looks that
SRTO_LINGER defaults to on/180 seconds.

> > Are some other parameters (latency, rcvlatency, connect_timeout) in
> milliseconds? (It's not that clear from the docs).
> > If yes, it may be good to set linger to milliseconds as well.
> >
> The SRT docs (https://github.com/Haivision/srt/blob/master/docs/API.md)
> used the seconds,  and I think SRT borrow the option from socket SO_LINGER
> (http://man7.org/linux/man-pages/man7/socket.7.html), we can keep the
> similar semantics with seconds.

ok

-- 
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 1/2] avfilter/buffersrc: remove write-only variable

2019-12-02 Thread Nicolas George
quinkbl...@foxmail.com (12019-12-02):
> From: Zhao Zhili 
> 
> ---
>  libavfilter/buffersrc.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
> index e0ff7e4dd8..bae7d86695 100644
> --- a/libavfilter/buffersrc.c
> +++ b/libavfilter/buffersrc.c
> @@ -47,7 +47,6 @@ typedef struct BufferSourceContext {
>  AVRationaltime_base; ///< time_base to set in the output link
>  AVRationalframe_rate;///< frame_rate to set in the output 
> link
>  unsigned  nb_failed_requests;
> -unsigned  warning_limit;
>  
>  /* video only */
>  int   w, h;
> @@ -292,7 +291,6 @@ static av_cold int init_video(AVFilterContext *ctx)
> 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->warning_limit = 100;
>  return 0;
>  }
>  
> @@ -379,7 +377,6 @@ static av_cold int init_audio(AVFilterContext *ctx)
> "tb:%d/%d samplefmt:%s samplerate:%d chlayout:%s\n",
> s->time_base.num, s->time_base.den, 
> av_get_sample_fmt_name(s->sample_fmt),
> s->sample_rate, s->channel_layout_str);
> -s->warning_limit = 100;
>  
>  return ret;
>  }

The warning that this variable helped implement was lost during the
merge in commit a05a44e205, but it is still relevant. It would probably
be better to restore it, at least until buffersrc no longer include its
own FIFO.

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 1/2] avfilter/buffersrc: remove write-only variable

2019-12-02 Thread quinkblack
From: Zhao Zhili 

---
 libavfilter/buffersrc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index e0ff7e4dd8..bae7d86695 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -47,7 +47,6 @@ typedef struct BufferSourceContext {
 AVRationaltime_base; ///< time_base to set in the output link
 AVRationalframe_rate;///< frame_rate to set in the output link
 unsigned  nb_failed_requests;
-unsigned  warning_limit;
 
 /* video only */
 int   w, h;
@@ -292,7 +291,6 @@ static av_cold int init_video(AVFilterContext *ctx)
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->warning_limit = 100;
 return 0;
 }
 
@@ -379,7 +377,6 @@ static av_cold int init_audio(AVFilterContext *ctx)
"tb:%d/%d samplefmt:%s samplerate:%d chlayout:%s\n",
s->time_base.num, s->time_base.den, 
av_get_sample_fmt_name(s->sample_fmt),
s->sample_rate, s->channel_layout_str);
-s->warning_limit = 100;
 
 return ret;
 }
-- 
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 2/2] avfilter/buffersrc: deprecate sws_param option

2019-12-02 Thread quinkblack
From: Zhao Zhili 

---
 doc/filters.texi| 4 +---
 libavfilter/buffersrc.c | 8 ++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 5fdec6f015..9b3c2d7c2d 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -21014,9 +21014,7 @@ 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.
 
 @item hw_frames_ctx
 When using a hardware pixel format, this should be a reference to an
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index bae7d86695..af6039f9b3 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -287,10 +287,14 @@ 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 (c->sws_param)
+av_log(ctx, AV_LOG_WARNING, "sws_param option is deprecated and 
ignored\n");
+
 return 0;
 }
 
-- 
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".

Re: [FFmpeg-devel] [PATCH 2/5] lavc/libxavs2.c: avoid recomputations of pointers in xavs2_copy_frame* functions

2019-12-02 Thread Moritz Barsnick
On Mon, Dec 02, 2019 at 15:29:37 +0800, hwren wrote:
> -int plane, hIdx, wIdx;
> -for (plane = 0; plane < 3; plane++) {
[...]
> +for (plane = 0; plane < 3; ++plane) {

ffmpeg prefers the plane++ syntax style. Same further below.

Thanks,
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] Patch for memory optimization with QuickTime/MP4

2019-12-02 Thread Jörg Beckmann
You cannot discard whatever is possible AND also try to seek. If you want to 
seek, you must not use this option. Even if I did not manage to create an 
example where switch root was called while reading from a file, I'm not sure 
that it is really impossible. And if switch root is called and the option is 
set, there is nothing left to search in. Therefore I believe that seeking shall 
not be allowed if the option is set. If someone stands up and declares that 
this cannot happen, we can remove the if from the seek. Obviously, there is 
some more documentation needed. I'll write some as soon as we agree on what to 
document. 

I'll use assert() instead of the if and the warning.

Jörg

-Ursprüngliche Nachricht-
Von: ffmpeg-devel  Im Auftrag von Carl Eugen 
Hoyos
Gesendet: Montag, 2. Dezember 2019 11:29
An: FFmpeg development discussions and patches 
Betreff: [SCISYS Possible Spam] Re: [FFmpeg-devel] [SCISYS Possible Spam] Re: 
[PATCH] Patch for memory optimization with QuickTime/MP4

Am Mo., 2. Dez. 2019 um 11:06 Uhr schrieb Jörg Beckmann
:

> The for-loop and the warning are copied from somewhere else in the decoder. 
> I'm also quite sure that it cannot really happen.

Then use an assert().

> One cannot set the option to discard old frames and also try to seek. I did 
> not manage to create an example with calls to switch_root while reading from 
> a file. But if it is possible somehow and the option is set, there are no old 
> fragments to seek in. Therefore I think, seek should be forbidden if the 
> option is set.

But if you read from a file and use the option, seeking does not work although 
it would be possible or do I misunderstand?

Please find out what top-posting means and avoid it here.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@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] [SCISYS Possible Spam] Re: [PATCH] Patch for memory optimization with QuickTime/MP4

2019-12-02 Thread Carl Eugen Hoyos
Am Mo., 2. Dez. 2019 um 11:06 Uhr schrieb Jörg Beckmann
:

> The for-loop and the warning are copied from somewhere else in the decoder. 
> I'm also quite sure that it cannot really happen.

Then use an assert().

> One cannot set the option to discard old frames and also try to seek. I did 
> not manage to create an example with calls to switch_root while reading from 
> a file. But if it is possible somehow and the option is set, there are no old 
> fragments to seek in. Therefore I think, seek should be forbidden if the 
> option is set.

But if you read from a file and use the option, seeking does not work
although it would be possible or do I misunderstand?

Please find out what top-posting means and avoid it here.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@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] [SCISYS Possible Spam] Re: [PATCH] Patch for memory optimization with QuickTime/MP4

2019-12-02 Thread Jörg Beckmann
The for-loop and the warning are copied from somewhere else in the decoder. I'm 
also quite sure that it cannot really happen. 

One cannot set the option to discard old frames and also try to seek. I did not 
manage to create an example with calls to switch_root while reading from a 
file. But if it is possible somehow and the option is set, there are no old 
fragments to seek in. Therefore I think, seek should be forbidden if the option 
is set.

Cheers,
Jörg

-Ursprüngliche Nachricht-
Von: ffmpeg-devel  Im Auftrag von Carl Eugen 
Hoyos
Gesendet: Montag, 2. Dezember 2019 10:15
An: FFmpeg development discussions and patches 
Betreff: [SCISYS Possible Spam] Re: [FFmpeg-devel] [PATCH] Patch for memory 
optimization with QuickTime/MP4

Am Mo., 2. Dez. 2019 um 10:05 Uhr schrieb Jörg Beckmann
:
>
> Hi,
>
> this patch invents a new option "discard_fragments" for the MP4/Quicktime/MOV 
> decoder. If the option is not set, nothing changes at all. If it is set, old 
> fragments are discarded as far as possible on each call to switch_root. For 
> pure audio streams, the memory usage is now constant. For video streams, the 
> memory usage is reduced. I've tested it with audio streams received from a 
> professional DAB+ receiver and with video streams created on my own with 
> "ffmpeg -i .m4v -c:a:0 copy -c:v copy -c:s copy -f ismv -movflags 
> frag_keyframe -movflags faststart tcp://localhost:1234?listen" and "ffmpeg -i 
> tcp://localhost:1234 -c:a copy -c:v copy -c:s copy -y ". Does someone 
> know sources for MP4 video streams? I could not find any with more than a few 
> minutes. That's not sufficient to test memory usage.
>
> Cheers,
> Jörg
> ---
> libavformat/isom.h |  1 +
> libavformat/mov.c  | 52 +-
> 2 files changed, 52 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/isom.h b/libavformat/isom.h index 
> 4943b80ccf..9b4753f4d7 100644
> --- a/libavformat/isom.h
> +++ b/libavformat/isom.h
> @@ -268,6 +268,7 @@ typedef struct MOVContext {
>  int advanced_editlist;
>  int ignore_chapters;
>  int seek_individually;
> +int discard_fragments;
>  int64_t next_root_atom; ///< offset of the next root atom
>  int export_all;
>  int export_xmp;
> diff --git a/libavformat/mov.c b/libavformat/mov.c index 
> 7553a7fdfc..3a5cfa23f8 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -7698,8 +7698,11 @@ static int should_retry(AVIOContext *pb, int 
> error_code) {  static int mov_switch_root(AVFormatContext *s, int64_t 
> target, int index) {
> -int ret;
> +int ret, i;
>  MOVContext *mov = s->priv_data;
> +AVStream *st = NULL;
> +MOVStreamContext *sc;
> +MOVFragment *frag;
>  if (index >= 0 && index < mov->frag_index.nb_items)
>  target = mov->frag_index.item[index].moof_offset;
> @@ -7721,6 +7724,46 @@ static int mov_switch_root(AVFormatContext *s, int64_t 
> target, int index)
>  mov->found_mdat = 0;
> +if (mov->discard_fragments) {
> +frag = >fragment;
> +
> +for (i = 0; i < mov->fc->nb_streams; i++) {
> +if (mov->fc->streams[i]->id == frag->track_id) {
> +st = mov->fc->streams[i];
> +break;
> +}
> +}
> +

> +if (!st) {
> +av_log(mov->fc, AV_LOG_WARNING, "could not find 
> + corresponding track id %u\n", frag->track_id);

How can this happen?

> +} else {
> +sc = st->priv_data;
> +
> +switch (st->codecpar->codec_type) {
> +case AVMEDIA_TYPE_AUDIO:
> +case AVMEDIA_TYPE_SUBTITLE:
> +/* Freeing VIDEO tables leads to corrupted video when 
> writing to eg. MKV */
> +av_freep(>index_entries);
> +st->nb_index_entries = 0;
> +st->index_entries_allocated_size = 0;
> +
> +sc->current_index = 0;
> +sc->current_sample = 0;
> +
> +av_freep(>ctts_data);
> +sc->ctts_data = NULL;
> +sc->ctts_allocated_size = 0;
> +sc->ctts_count = 0;
> +break;
> +}
> +
> +av_free(mov->frag_index.item->stream_info);
> +av_freep(>frag_index.item);
> +mov->frag_index.allocated_size = 0;
> +mov->frag_index.nb_items = 0;
> +}
> +}
> +
>  ret = mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX 
> });
>  if (ret < 0)
>  return ret;
> @@ -7975,6 +8018,9 @@ static int mov_read_seek(AVFormatContext *s, int 
> stream_index, int64_t sample_ti
>  int sample;
>  int i;
> +if (mc->discard_fragments)  // Seeking is not possible if fragments are 
> discarded.
> +return AVERROR(ENOTSUP);

I guess this is only true if the stream actually is fragmented.

> +
>  if (stream_index >= s->nb_streams)
>  return 

Re: [FFmpeg-devel] [PATCH] qsv: get FrameInfo.Shift by desc->comp[0].shift

2019-12-02 Thread Fu, Linjie
> -Original Message-
> From: Li, Zhong 
> Sent: Thursday, September 12, 2019 21:23
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Cc: Fu, Linjie 
> Subject: RE: [FFmpeg-devel] [PATCH] qsv: get FrameInfo.Shift by desc-
> >comp[0].shift
> 
> > From: ffmpeg-devel  On Behalf Of
> Linjie Fu
> > Sent: Wednesday, September 11, 2019 12:09 AM
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Fu, Linjie 
> > Subject: [FFmpeg-devel] [PATCH] 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
> 9bf8574..912f2a8
> > 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;
> 
> Is it safe enough?
> As MSDK docs: "Not all codecs and SDK implementations support this value.
> Use Query function to check if this feature is supported."

Checked the MSDK doc:
https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxFrameInfo

It shows that not only Shift, but also BitDepthLuma and BitDepthChroma are 
warned with:
"Not all codecs and SDK implementations support this value. Use Query function 
to check if this feature is supported."

Hence I think we could fix this in a separate patch to make the usage of 
FrameInfo.Shift/BitDepthLuma/BitDepthChroma
Safer if necessary.

Thanks,
- linjie

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] libswscale/x86/yuv2rgb: Change inline assembly into nasm code

2019-12-02 Thread Carl Eugen Hoyos
Am Mo., 2. Dez. 2019 um 04:17 Uhr schrieb Fu, Ting :
>
>
>
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Michael Niedermayer
> > Sent: Friday, November 29, 2019 05:33 AM
> > To: FFmpeg development discussions and patches 
> > Subject: Re: [FFmpeg-devel] [PATCH 1/2] libswscale/x86/yuv2rgb: Change 
> > inline
> > assembly into nasm code
> >
> > On Thu, Nov 28, 2019 at 02:07:07PM +0800, Ting Fu wrote:
> > > Signed-off-by: Ting Fu 
> > > ---
> > >  libswscale/x86/Makefile   |   1 +
> > >  libswscale/x86/swscale.c  |  16 +-
> > >  libswscale/x86/yuv2rgb.c  |  81 ++
> > >  libswscale/x86/yuv2rgb_template.c | 441 ++
> > >  libswscale/x86/yuv_2_rgb.asm  | 270 ++
> > >  5 files changed, 394 insertions(+), 415 deletions(-)  create mode
> > > 100644 libswscale/x86/yuv_2_rgb.asm
> >
> > This changes the output, i presume that is unintentional
> >
> > ./ffmpeg -cpuflags 0 -i matrixbench_mpeg2.mpg -t 1 -vf
> > format=yuv420p,format=rgb565le -an -f framecrc -
> >
> > 0,  0,  0,1,   829440, 0x1bd78b86
> > 0,  1,  1,1,   829440, 0x85910b33
> > ...
> > vs.
> > 0,  0,  0,1,   829440, 0x31f4a2bd
> > 0,  1,  1,1,   829440, 0xf0c66218
> > ...
> >
> >
>
> Hi Michael,
>
> This unexpected change is because of the missing verify of current SIMD 
> support.
> So, when cpuflag=0, ffmpeg used mmx code to compute as default.
> I added if (EXTERNAL_XXX(cpu_flags)) to verify the SIMD in 
> libswscale/x86/yuv2rgb.c.

Could the patch be split to make this change easier to understand?

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@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/hls: Use av_packet_move_ref() for packet ownership transfer

2019-12-02 Thread Steven Liu


> 在 2019年12月1日,13:21,Andreas Rheinhardt  写道:
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> libavformat/hls.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 21353bbad7..f60396f246 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -2201,9 +2201,8 @@ static int hls_read_packet(AVFormatContext *s, AVPacket 
> *pkt)
> ist = pls->ctx->streams[pls->pkt.stream_index];
> st = pls->main_streams[pls->pkt.stream_index];
> 
> -*pkt = pls->pkt;
> +av_packet_move_ref(pkt, >pkt);
> pkt->stream_index = st->index;
> -reset_packet(>playlists[minplaylist]->pkt);
> 
> if (pkt->dts != AV_NOPTS_VALUE)
> c->cur_timestamp = av_rescale_q(pkt->dts,
> -- 
> 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] avfilter/vf_convolution: add 16-column operation for filter_column() to prepare for x86 SIMD.

2019-12-02 Thread chen
This is toy only, it depends on compiler
On my PC, it helpful my old version compiler generate movaps other than movups.


At 2019-12-02 17:21:58, "Carl Eugen Hoyos"  wrote:
>Am Mo., 2. Dez. 2019 um 08:33 Uhr schrieb chen :
>
>> +#define __assume(cond) do { if (!(cond)) __builtin_unreachable(); } 
>> while (0)
>
>We currently don't do that.
>
>If you have a testcase where it makes a big difference,
>adding it could be discussed but has to be checked in
>configure and added to a libavutil header.
>
>Carl Eugen
>___
>ffmpeg-devel mailing list
>ffmpeg-devel@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] Patch for memory optimization with QuickTime/MP4

2019-12-02 Thread Carl Eugen Hoyos
Am Mo., 2. Dez. 2019 um 10:05 Uhr schrieb Jörg Beckmann
:
>
> Hi,
>
> this patch invents a new option "discard_fragments" for the MP4/Quicktime/MOV 
> decoder. If the option is not set, nothing changes at all. If it is set, old 
> fragments are discarded as far as possible on each call to switch_root. For 
> pure audio streams, the memory usage is now constant. For video streams, the 
> memory usage is reduced. I've tested it with audio streams received from a 
> professional DAB+ receiver and with video streams created on my own with 
> "ffmpeg -i .m4v -c:a:0 copy -c:v copy -c:s copy -f ismv -movflags 
> frag_keyframe -movflags faststart tcp://localhost:1234?listen" and "ffmpeg -i 
> tcp://localhost:1234 -c:a copy -c:v copy -c:s copy -y ". Does someone 
> know sources for MP4 video streams? I could not find any with more than a few 
> minutes. That's not sufficient to test memory usage.
>
> Cheers,
> Jörg
> ---
> libavformat/isom.h |  1 +
> libavformat/mov.c  | 52 +-
> 2 files changed, 52 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/isom.h b/libavformat/isom.h
> index 4943b80ccf..9b4753f4d7 100644
> --- a/libavformat/isom.h
> +++ b/libavformat/isom.h
> @@ -268,6 +268,7 @@ typedef struct MOVContext {
>  int advanced_editlist;
>  int ignore_chapters;
>  int seek_individually;
> +int discard_fragments;
>  int64_t next_root_atom; ///< offset of the next root atom
>  int export_all;
>  int export_xmp;
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 7553a7fdfc..3a5cfa23f8 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -7698,8 +7698,11 @@ static int should_retry(AVIOContext *pb, int 
> error_code) {
>  static int mov_switch_root(AVFormatContext *s, int64_t target, int index)
> {
> -int ret;
> +int ret, i;
>  MOVContext *mov = s->priv_data;
> +AVStream *st = NULL;
> +MOVStreamContext *sc;
> +MOVFragment *frag;
>  if (index >= 0 && index < mov->frag_index.nb_items)
>  target = mov->frag_index.item[index].moof_offset;
> @@ -7721,6 +7724,46 @@ static int mov_switch_root(AVFormatContext *s, int64_t 
> target, int index)
>  mov->found_mdat = 0;
> +if (mov->discard_fragments) {
> +frag = >fragment;
> +
> +for (i = 0; i < mov->fc->nb_streams; i++) {
> +if (mov->fc->streams[i]->id == frag->track_id) {
> +st = mov->fc->streams[i];
> +break;
> +}
> +}
> +

> +if (!st) {
> +av_log(mov->fc, AV_LOG_WARNING, "could not find corresponding 
> track id %u\n", frag->track_id);

How can this happen?

> +} else {
> +sc = st->priv_data;
> +
> +switch (st->codecpar->codec_type) {
> +case AVMEDIA_TYPE_AUDIO:
> +case AVMEDIA_TYPE_SUBTITLE:
> +/* Freeing VIDEO tables leads to corrupted video when 
> writing to eg. MKV */
> +av_freep(>index_entries);
> +st->nb_index_entries = 0;
> +st->index_entries_allocated_size = 0;
> +
> +sc->current_index = 0;
> +sc->current_sample = 0;
> +
> +av_freep(>ctts_data);
> +sc->ctts_data = NULL;
> +sc->ctts_allocated_size = 0;
> +sc->ctts_count = 0;
> +break;
> +}
> +
> +av_free(mov->frag_index.item->stream_info);
> +av_freep(>frag_index.item);
> +mov->frag_index.allocated_size = 0;
> +mov->frag_index.nb_items = 0;
> +}
> +}
> +
>  ret = mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX 
> });
>  if (ret < 0)
>  return ret;
> @@ -7975,6 +8018,9 @@ static int mov_read_seek(AVFormatContext *s, int 
> stream_index, int64_t sample_ti
>  int sample;
>  int i;
> +if (mc->discard_fragments)  // Seeking is not possible if fragments are 
> discarded.
> +return AVERROR(ENOTSUP);

I guess this is only true if the stream actually is fragmented.

> +
>  if (stream_index >= s->nb_streams)
>  return AVERROR_INVALIDDATA;
> @@ -8063,6 +8109,10 @@ static const AVOption mov_options[] = {
>  { "decryption_key", "The media decryption key (hex)", 
> OFFSET(decryption_key), AV_OPT_TYPE_BINARY, .flags = 
> AV_OPT_FLAG_DECODING_PARAM },
>  { "enable_drefs", "Enable external track support.", 
> OFFSET(enable_drefs), AV_OPT_TYPE_BOOL,
>  {.i64 = 0}, 0, 1, FLAGS },
> +{"discard_fragments",
> +"Discards fragments after they have been read to support live 
> streams.",
> +OFFSET(discard_fragments), AV_OPT_TYPE_BOOL, { .i64 = 0 },
> +0, 1, FLAGS },

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To 

Re: [FFmpeg-devel] [PATCH] avfilter/vf_convolution: add 16-column operation for filter_column() to prepare for x86 SIMD.

2019-12-02 Thread Carl Eugen Hoyos
Am Mo., 2. Dez. 2019 um 08:33 Uhr schrieb chen :

> +#define __assume(cond) do { if (!(cond)) __builtin_unreachable(); } 
> while (0)

We currently don't do that.

If you have a testcase where it makes a big difference,
adding it could be discussed but has to be checked in
configure and added to a libavutil header.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@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/vf_convolution: add 16-column operation for filter_column() to prepare for x86 SIMD.

2019-12-02 Thread Carl Eugen Hoyos
Am Mo., 2. Dez. 2019 um 03:42 Uhr schrieb 徐鋆 :

> I'm sorry not to reply in time.

Definitely in time!

> The performance of this C code is about 10% better than the existing C code.

Please add this to the commit message.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@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] MAINTAINERS: add myself to libavfilter/dnn

2019-12-02 Thread Steven Liu


> 在 2019年11月30日,12:24,Guo, Yejun  写道:
> 
> Signed-off-by: Guo, Yejun 
> ---
> MAINTAINERS | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 7f60ef0..5d02520 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -369,6 +369,8 @@ Filters:
> Sources:
>   vsrc_mandelbrot.c Michael Niedermayer
> 
> +dnn Yejun Guo
> +
> libavformat
> ===
> 
> -- 
> 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".
Patch will be applied after 24 hours if there have no objections.
Because Yejun Guo is interested in this part, he continuous focus on 
optimization the dnn codes.

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".

[FFmpeg-devel] [PATCH] Patch for memory optimization with QuickTime/MP4

2019-12-02 Thread Jörg Beckmann
Hi,

this patch invents a new option "discard_fragments" for the MP4/Quicktime/MOV 
decoder. If the option is not set, nothing changes at all. If it is set, old 
fragments are discarded as far as possible on each call to switch_root. For 
pure audio streams, the memory usage is now constant. For video streams, the 
memory usage is reduced. I've tested it with audio streams received from a 
professional DAB+ receiver and with video streams created on my own with 
"ffmpeg -i .m4v -c:a:0 copy -c:v copy -c:s copy -f ismv -movflags 
frag_keyframe -movflags faststart tcp://localhost:1234?listen" and "ffmpeg -i 
tcp://localhost:1234 -c:a copy -c:v copy -c:s copy -y ". Does someone 
know sources for MP4 video streams? I could not find any with more than a few 
minutes. That's not sufficient to test memory usage.

Cheers,
Jörg
---
libavformat/isom.h |  1 +
libavformat/mov.c  | 52 +-
2 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 4943b80ccf..9b4753f4d7 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -268,6 +268,7 @@ typedef struct MOVContext {
 int advanced_editlist;
 int ignore_chapters;
 int seek_individually;
+int discard_fragments;
 int64_t next_root_atom; ///< offset of the next root atom
 int export_all;
 int export_xmp;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 7553a7fdfc..3a5cfa23f8 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7698,8 +7698,11 @@ static int should_retry(AVIOContext *pb, int error_code) 
{
 static int mov_switch_root(AVFormatContext *s, int64_t target, int index)
{
-int ret;
+int ret, i;
 MOVContext *mov = s->priv_data;
+AVStream *st = NULL;
+MOVStreamContext *sc;
+MOVFragment *frag;
 if (index >= 0 && index < mov->frag_index.nb_items)
 target = mov->frag_index.item[index].moof_offset;
@@ -7721,6 +7724,46 @@ static int mov_switch_root(AVFormatContext *s, int64_t 
target, int index)
 mov->found_mdat = 0;
+if (mov->discard_fragments) {
+frag = >fragment;
+
+for (i = 0; i < mov->fc->nb_streams; i++) {
+if (mov->fc->streams[i]->id == frag->track_id) {
+st = mov->fc->streams[i];
+break;
+}
+}
+
+if (!st) {
+av_log(mov->fc, AV_LOG_WARNING, "could not find corresponding 
track id %u\n", frag->track_id);
+} else {
+sc = st->priv_data;
+
+switch (st->codecpar->codec_type) {
+case AVMEDIA_TYPE_AUDIO:
+case AVMEDIA_TYPE_SUBTITLE:
+/* Freeing VIDEO tables leads to corrupted video when 
writing to eg. MKV */
+av_freep(>index_entries);
+st->nb_index_entries = 0;
+st->index_entries_allocated_size = 0;
+
+sc->current_index = 0;
+sc->current_sample = 0;
+
+av_freep(>ctts_data);
+sc->ctts_data = NULL;
+sc->ctts_allocated_size = 0;
+sc->ctts_count = 0;
+break;
+}
+
+av_free(mov->frag_index.item->stream_info);
+av_freep(>frag_index.item);
+mov->frag_index.allocated_size = 0;
+mov->frag_index.nb_items = 0;
+}
+}
+
 ret = mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX 
});
 if (ret < 0)
 return ret;
@@ -7975,6 +8018,9 @@ static int mov_read_seek(AVFormatContext *s, int 
stream_index, int64_t sample_ti
 int sample;
 int i;
+if (mc->discard_fragments)  // Seeking is not possible if fragments are 
discarded.
+return AVERROR(ENOTSUP);
+
 if (stream_index >= s->nb_streams)
 return AVERROR_INVALIDDATA;
@@ -8063,6 +8109,10 @@ static const AVOption mov_options[] = {
 { "decryption_key", "The media decryption key (hex)", 
OFFSET(decryption_key), AV_OPT_TYPE_BINARY, .flags = AV_OPT_FLAG_DECODING_PARAM 
},
 { "enable_drefs", "Enable external track support.", OFFSET(enable_drefs), 
AV_OPT_TYPE_BOOL,
 {.i64 = 0}, 0, 1, FLAGS },
+{"discard_fragments",
+"Discards fragments after they have been read to support live 
streams.",
+OFFSET(discard_fragments), AV_OPT_TYPE_BOOL, { .i64 = 0 },
+0, 1, FLAGS },
 { NULL },
};
___
ffmpeg-devel mailing list
ffmpeg-devel@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/2] avformat/utils: simplify the ff_mkdir_p with SEPARATOR

2019-12-02 Thread Hendrik Leppkes
On Mon, Dec 2, 2019 at 3:16 AM Limin Wang  wrote:
>
> On Sun, Dec 01, 2019 at 05:33:16PM +0100, Hendrik Leppkes wrote:
> > On Sun, Dec 1, 2019 at 3:08 PM  wrote:
> > >
> > > From: Limin Wang 
> > >
> > > Signed-off-by: Limin Wang 
> > > ---
> > >  libavformat/utils.c | 16 ++--
> > >  1 file changed, 10 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > > index 579e6d6..993e6d2 100644
> > > --- a/libavformat/utils.c
> > > +++ b/libavformat/utils.c
> > > @@ -4843,12 +4843,17 @@ void av_url_split(char *proto, int proto_size,
> > >  }
> > >  }
> > >
> > > +#if HAVE_DOS_PATHS
> > > +#define SEPARATOR '\\'
> > > +#else
> > > +#define SEPARATOR '/'
> > > +#endif
> > > +
> > >  int ff_mkdir_p(const char *path)
> > >  {
> > >  int ret = 0;
> > >  char *temp = av_strdup(path);
> > >  char *pos = temp;
> > > -char tmp_ch = '\0';
> > >
> > >  if (!path || !temp) {
> > >  return -1;
> > > @@ -4856,19 +4861,18 @@ int ff_mkdir_p(const char *path)
> > >
> > >  if (*temp == '.')
> > >  pos++;
> > > -if (*temp == '/' || *temp == '\\')
> > > +if (*temp == SEPARATOR)
> > >  pos++;
> > >
> > >  for ( ; *pos != '\0'; ++pos) {
> > > -if (*pos == '/' || *pos == '\\') {
> > > -tmp_ch = *pos;
> > > +if (*pos == SEPARATOR) {
> > >  *pos = '\0';
> > >  ret = mkdir(temp, 0755);
> > > -*pos = tmp_ch;
> > > +*pos = SEPARATOR;
> > >  }
> > >  }
> > >
> > > -if ((*(pos - 1) != '/') || (*(pos - 1) != '\\')) {
> > > +if (*(pos - 1) != SEPARATOR) {
> > >  ret = mkdir(temp, 0755);
> > >  }
> >
> > I think there is some value to be able to specify a path with both
> > kinds of slashes. For example, most of everything else on Windows will
> > accept normal slashes, in addition to the default backslash.
> Hendrik, I haven't got your point yet, can you make it clear so that I
> can change the patch for your case.
>
> For example, on Linux, if the path is:
>  ~/Movies/hl\\s/vs%v/manifest.m3u8
>
> The current code will mkdir below path:
> path: /Users
> path: /Users/lmwang
> path: /Users/lmwang/Movies
> path: /Users/lmwang/Movies/hl   >>> unexpected
> path: /Users/lmwang/Movies/hl\s
> path: /Users/lmwang/Movies/hl\s/vs0
>
> You can see /Users/lmwang/Movies/hl directory isn't expected directory which 
> is created.
>
> After applied the patch, it'll not create it anymore.
>

But if I'm on Windows and I specify a path with normal slashes (where
SEPARATOR  is backslash), I would absolutely expect it to create it
like that. Which it does right now.

- Hendrik
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 4/5] lavc/libxavs2.c: replace deprecated parameter 'FrameRate' with new parameter 'fps'

2019-12-02 Thread hwren
Signed-off-by: hwren 
---
 libavcodec/libxavs2.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index cf448be..41b7a29 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -60,10 +60,15 @@ typedef struct XAVS2EContext {
 static av_cold int xavs2_init(AVCodecContext *avctx)
 {
 XAVS2EContext *cae = avctx->priv_data;
-int bit_depth, code;
+int bit_depth;
+double framerate = 30.0;
 
 bit_depth = avctx->pix_fmt == AV_PIX_FMT_YUV420P ? 8 : 10;
 
+if (avctx->framerate.den > 0 && avctx->framerate.num > 0) {
+framerate = av_q2d(avctx->framerate);
+}
+
 /* get API handler */
 cae->api = xavs2_api_get(bit_depth);
 if (!cae->api) {
@@ -83,6 +88,7 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 xavs2_opt_set2("BitDepth",  "%d", bit_depth);
 xavs2_opt_set2("Log",   "%d", cae->log_level);
 xavs2_opt_set2("Preset","%d", cae->preset_level);
+xavs2_opt_set2("fps",   "%.3lf", framerate);
 
 xavs2_opt_set2("IntraPeriodMax","%d", avctx->gop_size);
 xavs2_opt_set2("IntraPeriodMin","%d", avctx->gop_size);
@@ -115,9 +121,6 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 xavs2_opt_set2("InitialQP", "%d", cae->qp);
 }
 
-ff_mpeg12_find_best_frame_rate(avctx->framerate, , NULL, NULL, 0);
-xavs2_opt_set2("FrameRate",   "%d", code);
-
 cae->encoder = cae->api->encoder_create(cae->param);
 
 if (!cae->encoder) {
-- 
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 5/5] lavc/libxavs2.c: optimize error descriptions

2019-12-02 Thread hwren
Signed-off-by: hwren 
---
 libavcodec/libxavs2.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 41b7a29..e3ba808 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -72,13 +72,13 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 /* get API handler */
 cae->api = xavs2_api_get(bit_depth);
 if (!cae->api) {
-av_log(avctx, AV_LOG_ERROR, "api get failed\n");
+av_log(avctx, AV_LOG_ERROR, "Failed to get xavs2 api context\n");
 return AVERROR_EXTERNAL;
 }
 
 cae->param = cae->api->opt_alloc();
 if (!cae->param) {
-av_log(avctx, AV_LOG_ERROR, "param alloc failed\n");
+av_log(avctx, AV_LOG_ERROR, "Failed to alloc xavs2 parameters\n");
 return AVERROR(ENOMEM);
 }
 
@@ -124,7 +124,7 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 cae->encoder = cae->api->encoder_create(cae->param);
 
 if (!cae->encoder) {
-av_log(avctx, AV_LOG_ERROR, "Can not create encoder. Null pointer 
returned\n");
+av_log(avctx, AV_LOG_ERROR, "Failed to create xavs2 encoder 
instance.\n");
 return AVERROR(EINVAL);
 }
 
@@ -183,7 +183,7 @@ static int xavs2_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 /* create the XAVS2 video encoder */
 /* read frame data and send to the XAVS2 video encoder */
 if (cae->api->encoder_get_buffer(cae->encoder, ) < 0) {
-av_log(avctx, AV_LOG_ERROR, "failed to get frame buffer\n");
+av_log(avctx, AV_LOG_ERROR, "Failed to get xavs2 frame buffer\n");
 return AVERROR_EXTERNAL;
 }
 if (frame) {
@@ -214,7 +214,7 @@ static int xavs2_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 ret = cae->api->encoder_encode(cae->encoder, , >packet);
 
 if (ret) {
-av_log(avctx, AV_LOG_ERROR, "encode failed\n");
+av_log(avctx, AV_LOG_ERROR, "Encoder error occured.\n");
 return AVERROR_EXTERNAL;
 }
 
@@ -224,7 +224,7 @@ static int xavs2_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 
 if ((cae->packet.len) && (cae->packet.state != XAVS2_STATE_FLUSH_END)) {
 if (av_new_packet(pkt, cae->packet.len) < 0) {
-av_log(avctx, AV_LOG_ERROR, "packet alloc failed\n");
+av_log(avctx, AV_LOG_ERROR, "Failed to alloc xavs2 packet.\n");
 cae->api->encoder_packet_unref(cae->encoder, >packet);
 return AVERROR(ENOMEM);
 }
-- 
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 2/5] lavc/libxavs2.c: avoid recomputations of pointers in xavs2_copy_frame* functions

2019-12-02 Thread hwren
Signed-off-by: hwren 
---
 libavcodec/libxavs2.c | 42 --
 1 file changed, 28 insertions(+), 14 deletions(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 3896f3b..6ec6349 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -132,28 +132,42 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 
 static void xavs2_copy_frame_with_shift(xavs2_picture_t *pic, const AVFrame 
*frame, const int shift_in)
 {
-int plane, hIdx, wIdx;
-for (plane = 0; plane < 3; plane++) {
-int i_stride = pic->img.i_stride[plane];
-for (hIdx = 0; hIdx < pic->img.i_lines[plane]; hIdx++) {
-uint16_t *p_plane = (uint16_t *)>img.img_planes[plane][hIdx * 
i_stride];
-uint8_t *p_buffer = frame->data[plane] + frame->linesize[plane] * 
hIdx;
-memset(p_plane, 0, i_stride);
-for (wIdx = 0; wIdx < pic->img.i_width[plane]; wIdx++) {
+uint16_t *p_plane;
+uint8_t *p_buffer;
+int plane;
+int hIdx;
+int wIdx;
+
+for (plane = 0; plane < 3; ++plane) {
+p_plane = (uint16_t *)pic->img.img_planes[plane];
+p_buffer = frame->data[plane];
+for (hIdx = 0; hIdx < pic->img.i_lines[plane]; ++hIdx) {
+memset(p_plane, 0, pic->img.i_stride[plane]);
+for (wIdx = 0; wIdx < pic->img.i_width[plane]; ++wIdx) {
 p_plane[wIdx] = p_buffer[wIdx] << shift_in;
 }
+p_plane += pic->img.i_stride[plane];
+p_buffer += frame->linesize[plane];
 }
 }
 }
 
 static void xavs2_copy_frame(xavs2_picture_t *pic, const AVFrame *frame)
 {
-int plane, hIdx;
-for (plane = 0; plane < 3; plane++) {
-for (hIdx = 0; hIdx < pic->img.i_lines[plane]; hIdx++) {
-memcpy( pic->img.img_planes[plane] + pic->img.i_stride[plane] * 
hIdx,
-frame->data[plane]+frame->linesize[plane] * hIdx,
-pic->img.i_width[plane] * pic->img.in_sample_size);
+uint8_t *p_plane;
+uint8_t *p_buffer;
+int plane;
+int hIdx;
+int stride;
+
+for (plane = 0; plane < 3; ++plane) {
+p_plane = pic->img.img_planes[plane];
+p_buffer = frame->data[plane];
+stride = pic->img.i_width[plane] * pic->img.in_sample_size;
+for (hIdx = 0; hIdx < pic->img.i_lines[plane]; ++hIdx) {
+memcpy(p_plane, p_buffer, stride);
+p_plane += pic->img.i_stride[plane];
+p_buffer += frame->linesize[plane];
 }
 }
 }
-- 
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 1/5] lavc/libxavs2.c: use more descriptive variable names in xavs2_copy_frame* functions

2019-12-02 Thread hwren
Signed-off-by: hwren 
---
 libavcodec/libxavs2.c | 29 ++---
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 0179a1e..3896f3b 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -132,16 +132,15 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 
 static void xavs2_copy_frame_with_shift(xavs2_picture_t *pic, const AVFrame 
*frame, const int shift_in)
 {
-int j, k;
-for (k = 0; k < 3; k++) {
-int i_stride = pic->img.i_stride[k];
-for (j = 0; j < pic->img.i_lines[k]; j++) {
-uint16_t *p_plane = (uint16_t *)>img.img_planes[k][j * 
i_stride];
-int i;
-uint8_t *p_buffer = frame->data[k] + frame->linesize[k] * j;
+int plane, hIdx, wIdx;
+for (plane = 0; plane < 3; plane++) {
+int i_stride = pic->img.i_stride[plane];
+for (hIdx = 0; hIdx < pic->img.i_lines[plane]; hIdx++) {
+uint16_t *p_plane = (uint16_t *)>img.img_planes[plane][hIdx * 
i_stride];
+uint8_t *p_buffer = frame->data[plane] + frame->linesize[plane] * 
hIdx;
 memset(p_plane, 0, i_stride);
-for (i = 0; i < pic->img.i_width[k]; i++) {
-p_plane[i] = p_buffer[i] << shift_in;
+for (wIdx = 0; wIdx < pic->img.i_width[plane]; wIdx++) {
+p_plane[wIdx] = p_buffer[wIdx] << shift_in;
 }
 }
 }
@@ -149,12 +148,12 @@ static void xavs2_copy_frame_with_shift(xavs2_picture_t 
*pic, const AVFrame *fra
 
 static void xavs2_copy_frame(xavs2_picture_t *pic, const AVFrame *frame)
 {
-int j, k;
-for (k = 0; k < 3; k++) {
-for (j = 0; j < pic->img.i_lines[k]; j++) {
-memcpy( pic->img.img_planes[k] + pic->img.i_stride[k] * j,
-frame->data[k]+frame->linesize[k] * j,
-pic->img.i_width[k] * pic->img.in_sample_size);
+int plane, hIdx;
+for (plane = 0; plane < 3; plane++) {
+for (hIdx = 0; hIdx < pic->img.i_lines[plane]; hIdx++) {
+memcpy( pic->img.img_planes[plane] + pic->img.i_stride[plane] * 
hIdx,
+frame->data[plane]+frame->linesize[plane] * hIdx,
+pic->img.i_width[plane] * pic->img.in_sample_size);
 }
 }
 }
-- 
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 3/5] lavc/libxavs2.c: fix code style - spaces

2019-12-02 Thread hwren
Signed-off-by: hwren 
---
 libavcodec/libxavs2.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
index 6ec6349..cf448be 100644
--- a/libavcodec/libxavs2.c
+++ b/libavcodec/libxavs2.c
@@ -59,7 +59,7 @@ typedef struct XAVS2EContext {
 
 static av_cold int xavs2_init(AVCodecContext *avctx)
 {
-XAVS2EContext *cae= avctx->priv_data;
+XAVS2EContext *cae = avctx->priv_data;
 int bit_depth, code;
 
 bit_depth = avctx->pix_fmt == AV_PIX_FMT_YUV420P ? 8 : 10;
@@ -115,15 +115,13 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
 xavs2_opt_set2("InitialQP", "%d", cae->qp);
 }
 
-
 ff_mpeg12_find_best_frame_rate(avctx->framerate, , NULL, NULL, 0);
-
 xavs2_opt_set2("FrameRate",   "%d", code);
 
 cae->encoder = cae->api->encoder_create(cae->param);
 
 if (!cae->encoder) {
-av_log(avctx,AV_LOG_ERROR, "Can not create encoder. Null pointer 
returned\n");
+av_log(avctx, AV_LOG_ERROR, "Can not create encoder. Null pointer 
returned\n");
 return AVERROR(EINVAL);
 }
 
@@ -182,7 +180,7 @@ static int xavs2_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 /* create the XAVS2 video encoder */
 /* read frame data and send to the XAVS2 video encoder */
 if (cae->api->encoder_get_buffer(cae->encoder, ) < 0) {
-av_log(avctx,AV_LOG_ERROR, "failed to get frame buffer\n");
+av_log(avctx, AV_LOG_ERROR, "failed to get frame buffer\n");
 return AVERROR_EXTERNAL;
 }
 if (frame) {
@@ -221,9 +219,8 @@ static int xavs2_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 cae->api->encoder_encode(cae->encoder, NULL, >packet);
 }
 
-if ((cae->packet.len) && (cae->packet.state != XAVS2_STATE_FLUSH_END)){
-
-if (av_new_packet(pkt, cae->packet.len) < 0){
+if ((cae->packet.len) && (cae->packet.state != XAVS2_STATE_FLUSH_END)) {
+if (av_new_packet(pkt, cae->packet.len) < 0) {
 av_log(avctx, AV_LOG_ERROR, "packet alloc failed\n");
 cae->api->encoder_packet_unref(cae->encoder, >packet);
 return AVERROR(ENOMEM);
-- 
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".