[FFmpeg-devel] [loongson] Optimize H264 decoding.

2020-09-04 Thread Shiyou Yin
H264 decoding speed: 154fps ==> 165fps, 5.14x ==> 5.53x (tested on 3A4000)

[PATCH 1/3] avcodec/mips: Restore the initialization sequence of MSA. 
[PATCH 2/3] avcodec/mips: Refine get_cabac_inline_mips.
[PATCH 3/3] avcodec/mips: Optimize function ff_h264_loop_filter_strength_msa.

___
ffmpeg-devel mailing list
ffmpeg-devel@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] avcodec/mips: Restore the initialization sequence of MSA and MMI in ff_h264chroma_init_mips.

2020-09-04 Thread Shiyou Yin
Speed of decoding H264: 5.14x ==> 5.23x (tested on 3A4000).
---
 libavcodec/mips/h264chroma_init_mips.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/libavcodec/mips/h264chroma_init_mips.c 
b/libavcodec/mips/h264chroma_init_mips.c
index 6bb19d3..755cc04 100644
--- a/libavcodec/mips/h264chroma_init_mips.c
+++ b/libavcodec/mips/h264chroma_init_mips.c
@@ -28,7 +28,15 @@ av_cold void ff_h264chroma_init_mips(H264ChromaContext *c, 
int bit_depth)
 int cpu_flags = av_get_cpu_flags();
 int high_bit_depth = bit_depth > 8;
 
-/* MMI apears to be faster than MSA here */
+if (have_mmi(cpu_flags)) {
+if (!high_bit_depth) {
+c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_mmi;
+c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_mmi;
+c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_mmi;
+c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_mmi;
+}
+}
+
 if (have_msa(cpu_flags)) {
 if (!high_bit_depth) {
 c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_msa;
@@ -40,13 +48,4 @@ av_cold void ff_h264chroma_init_mips(H264ChromaContext *c, 
int bit_depth)
 c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_msa;
 }
 }
-
-if (have_mmi(cpu_flags)) {
-if (!high_bit_depth) {
-c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_mmi;
-c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_mmi;
-c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_mmi;
-c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_mmi;
-}
-}
 }
-- 
2.1.0

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

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

[FFmpeg-devel] [PATCH 3/3] avcodec/mips: Optimize function ff_h264_loop_filter_strength_msa.

2020-09-04 Thread Shiyou Yin
From: gxw 

Speed of decoding H264: 5.45x ==> 5.53x

Signed-off-by: Shiyou Yin 
---
 libavcodec/mips/Makefile|   3 +-
 libavcodec/mips/h264_deblock_msa.c  | 153 
 libavcodec/mips/h264dsp_init_mips.c |   2 +
 libavcodec/mips/h264dsp_mips.h  |   4 +
 4 files changed, 161 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/mips/h264_deblock_msa.c

diff --git a/libavcodec/mips/Makefile b/libavcodec/mips/Makefile
index 2be4d9b..81a73a4 100644
--- a/libavcodec/mips/Makefile
+++ b/libavcodec/mips/Makefile
@@ -57,7 +57,8 @@ MSA-OBJS-$(CONFIG_VP8_DECODER)+= 
mips/vp8_mc_msa.o \
  mips/vp8_lpf_msa.o
 MSA-OBJS-$(CONFIG_VP3DSP) += mips/vp3dsp_idct_msa.o
 MSA-OBJS-$(CONFIG_H264DSP)+= mips/h264dsp_msa.o\
- mips/h264idct_msa.o
+ mips/h264idct_msa.o   \
+ mips/h264_deblock_msa.o
 MSA-OBJS-$(CONFIG_H264QPEL)   += mips/h264qpel_msa.o
 MSA-OBJS-$(CONFIG_H264CHROMA) += mips/h264chroma_msa.o
 MSA-OBJS-$(CONFIG_H264PRED)   += mips/h264pred_msa.o
diff --git a/libavcodec/mips/h264_deblock_msa.c 
b/libavcodec/mips/h264_deblock_msa.c
new file mode 100644
index 000..4fed55c
--- /dev/null
+++ b/libavcodec/mips/h264_deblock_msa.c
@@ -0,0 +1,153 @@
+/*
+ * MIPS SIMD optimized H.264 deblocking code
+ *
+ * Copyright (c) 2020 Loongson Technology Corporation Limited
+ *Gu Xiwei 
+ *
+ * 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 "libavcodec/bit_depth_template.c"
+#include "h264dsp_mips.h"
+#include "libavutil/mips/generic_macros_msa.h"
+#include "libavcodec/mips/h264dsp_mips.h"
+
+#define h264_loop_filter_strength_iteration_msa(edges, step, mask_mv, dir, \
+d_idx, mask_dir)   \
+do {   \
+int b_idx = 0; \
+int step_x4 = step << 2; \
+int d_idx_12 = d_idx + 12; \
+int d_idx_52 = d_idx + 52; \
+int d_idx_x4 = d_idx << 2; \
+int d_idx_x4_48 = d_idx_x4 + 48; \
+int dir_x32  = dir * 32; \
+uint8_t *ref_t = (uint8_t*)ref; \
+uint8_t *mv_t  = (uint8_t*)mv; \
+uint8_t *nnz_t = (uint8_t*)nnz; \
+uint8_t *bS_t  = (uint8_t*)bS; \
+mask_mv <<= 3; \
+for (; b_idx < edges; b_idx += step) { \
+out &= mask_dir; \
+if (!(mask_mv & b_idx)) { \
+if (bidir) { \
+ref_2 = LD_SB(ref_t + d_idx_12); \
+ref_3 = LD_SB(ref_t + d_idx_52); \
+ref_0 = LD_SB(ref_t + 12); \
+ref_1 = LD_SB(ref_t + 52); \
+ref_2 = (v16i8)__msa_ilvr_w((v4i32)ref_3, (v4i32)ref_2); \
+ref_0 = (v16i8)__msa_ilvr_w((v4i32)ref_0, (v4i32)ref_0); \
+ref_1 = (v16i8)__msa_ilvr_w((v4i32)ref_1, (v4i32)ref_1); \
+ref_3 = (v16i8)__msa_shf_h((v8i16)ref_2, 0x4e); \
+ref_0 -= ref_2; \
+ref_1 -= ref_3; \
+ref_0 = (v16i8)__msa_or_v((v16u8)ref_0, (v16u8)ref_1); \
+\
+tmp_2 = LD_SH(mv_t + d_idx_x4_48);   \
+tmp_3 = LD_SH(mv_t + 48); \
+tmp_4 = LD_SH(mv_t + 208); \
+tmp_5 = tmp_2 - tmp_3; \
+tmp_6 = tmp_2 - tmp_4; \
+SAT_SH2_SH(tmp_5, tmp_6, 7); \
+tmp_0 = __msa_pckev_b((v16i8)tmp_6, (v16i8)tmp_5); \
+tmp_0 += cnst_1; \
+tmp_0 = (v16i8)__msa_subs_u_b((v16u8)tmp_0, (v16u8)cnst_0);\
+tmp_0 = (v16i8)__msa_sat_s_h((v8i16)tmp_0, 7); \
+tmp_0 = __msa_pckev_b(tmp_0, tmp_0); \
+out   = (v16i8)__msa_or_v((v16u8)ref_0, (v16u8)tmp_0); \
+\
+tmp_2 = LD_SH(mv_t + 208 + d_idx_x4); \
+tmp_5 = tmp_2 - tmp_3; \
+tmp_6 = tmp_2 - tmp_4; \
+SAT_SH2_SH(tmp_5, tmp_6, 7); \
+tmp_1 = __msa_pckev_b((v16i8)tmp_6, (v16i8)tmp_5); \
+tmp_1 += cnst_1; \
+tmp_1 = (v16i8)__msa_subs

Re: [FFmpeg-devel] [PATCH] avcodec/dxtory: unbreak decoding after 6e1a167c556

2020-09-04 Thread Michael Niedermayer
On Fri, Sep 04, 2020 at 12:27:11AM +0200, Paul B Mahol wrote:
> On 9/3/20, Michael Niedermayer  wrote:
> > On Thu, Sep 03, 2020 at 07:03:23PM +0200, Paul B Mahol wrote:
> >> get_unary() takes at minimum only 1 bit.
> >>
> >> Signed-off-by: Paul B Mahol 
> >> ---
> >>
> >> As this is important fix, will apply in next 5 minutes.
> >> I kindly ask authors of various timeouts changes to kindly
> >> test their changes more carefully.
> >
> > Can you provide test samples and a fate test ?
> 
> Why should I? Nobody uploads my request to wav CUE thing.

You have access to upload yourself and 
post the request to the wrong address, it is
FFmpeg sample uploads 


> 
> Test samples can be generated by installing trial dxtory capture and recording
> mainly black frames from some simple game. On windows, or under virtualbox.
> 
> I can upload files, but I value my time and will not do it for nothing
> in return.

The time someone else needs to setup a windows machiene, trial dxtory capture,
some game and so forth is several times that of just providing existing files.

So by providing existing files you give others more time to work on 
other things like reviewing your patches, or uploading your files to
fate, or working on anything else, which can then also benefit you ...
Is that enough in return ?

Thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] libopenjpeg decoder not correctly setting the pixel format for cinema JP2K wrapped MXF

2020-09-04 Thread Tomas Härdin
tis 2020-09-01 klockan 11:06 +0100 skrev Rémi Achard:
> > If you want the IS_KLV_KEY() check to be more lenient then you should
> > make mxf_jp2k_rsiz[] shorter, not replace the end of it with NULs
> 
> This UL come straight from SMPTE ST 422M, not sure what you mean but I
> didn't replace it with arbitrary NULs values.

You're right, it's right there on page 10 of S422M-2006. This makes me
wonder where the old value came from. I missed that many bytes of it
were different, not just that the end was nulled. There is also no
match for "0d.01" in S422M like there is for "04.01.06.03".

In short: the UL matches the spec so it is fine

/Tomas

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

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

Re: [FFmpeg-devel] [PATCH] avcodec/dxtory: unbreak decoding after 6e1a167c556

2020-09-04 Thread Paul B Mahol
On 9/4/20, Michael Niedermayer  wrote:
> On Fri, Sep 04, 2020 at 12:27:11AM +0200, Paul B Mahol wrote:
>> On 9/3/20, Michael Niedermayer  wrote:
>> > On Thu, Sep 03, 2020 at 07:03:23PM +0200, Paul B Mahol wrote:
>> >> get_unary() takes at minimum only 1 bit.
>> >>
>> >> Signed-off-by: Paul B Mahol 
>> >> ---
>> >>
>> >> As this is important fix, will apply in next 5 minutes.
>> >> I kindly ask authors of various timeouts changes to kindly
>> >> test their changes more carefully.
>> >
>> > Can you provide test samples and a fate test ?
>>
>> Why should I? Nobody uploads my request to wav CUE thing.
>
> You have access to upload yourself and
> post the request to the wrong address, it is
> FFmpeg sample uploads 
>

I never received anything of sort of access to something.

>
>>
>> Test samples can be generated by installing trial dxtory capture and
>> recording
>> mainly black frames from some simple game. On windows, or under
>> virtualbox.
>>
>> I can upload files, but I value my time and will not do it for nothing
>> in return.
>
> The time someone else needs to setup a windows machiene, trial dxtory
> capture,
> some game and so forth is several times that of just providing existing
> files.
>
> So by providing existing files you give others more time to work on
> other things like reviewing your patches, or uploading your files to
> fate, or working on anything else, which can then also benefit you ...
> Is that enough in return ?

No, I will leave this decoder broken. So be it.
And I wish you happy breaking of every single other decoder,
you have enormous potential.

I'm completely unpaid in this what I do.
___
ffmpeg-devel mailing list
ffmpeg-devel@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] request to upload sample

2020-09-04 Thread Andreas Rheinhardt
Paul B Mahol:
> Hi.
> 
> Please upload this file to FATE servers.
> 
> http://trac.ffmpeg.org/raw-attachment/ticket/8872/200828-005.wav
> 
> Will add chapter/cue test later.

Can't the file be made smaller?

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

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

Re: [FFmpeg-devel] [PATCH] avcodec/dxtory: unbreak decoding after 6e1a167c556

2020-09-04 Thread Paul B Mahol
On 9/4/20, Michael Niedermayer  wrote:
> On Fri, Sep 04, 2020 at 12:27:11AM +0200, Paul B Mahol wrote:
>> On 9/3/20, Michael Niedermayer  wrote:
>> > On Thu, Sep 03, 2020 at 07:03:23PM +0200, Paul B Mahol wrote:
>> >> get_unary() takes at minimum only 1 bit.
>> >>
>> >> Signed-off-by: Paul B Mahol 
>> >> ---
>> >>
>> >> As this is important fix, will apply in next 5 minutes.
>> >> I kindly ask authors of various timeouts changes to kindly
>> >> test their changes more carefully.
>> >
>> > Can you provide test samples and a fate test ?
>>
>> Why should I? Nobody uploads my request to wav CUE thing.
>
> You have access to upload yourself and
> post the request to the wrong address, it is
> FFmpeg sample uploads 
>
>
>>
>> Test samples can be generated by installing trial dxtory capture and
>> recording
>> mainly black frames from some simple game. On windows, or under
>> virtualbox.
>>
>> I can upload files, but I value my time and will not do it for nothing
>> in return.
>
> The time someone else needs to setup a windows machiene, trial dxtory
> capture,
> some game and so forth is several times that of just providing existing
> files.
>
> So by providing existing files you give others more time to work on
> other things like reviewing your patches, or uploading your files to
> fate, or working on anything else, which can then also benefit you ...
> Is that enough in return ?

https://drive.google.com/drive/folders/1RV0NSfkAvNA8Ju59SBuzKg7pWosIVLQd?usp=sharing

>
> Thanks
>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Republics decline into democracies and democracies degenerate into
> despotisms. -- Aristotle
>
___
ffmpeg-devel mailing list
ffmpeg-devel@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] request to upload sample

2020-09-04 Thread Paul B Mahol
On 9/4/20, Andreas Rheinhardt  wrote:
> Paul B Mahol:
>> Hi.
>>
>> Please upload this file to FATE servers.
>>
>> http://trac.ffmpeg.org/raw-attachment/ticket/8872/200828-005.wav
>>
>> Will add chapter/cue test later.
>
> Can't the file be made smaller?

No because cue stuff is at end of file.

Are you short on resource somehow?
2mb is nothing.
___
ffmpeg-devel mailing list
ffmpeg-devel@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] avcodec/dxtory: unbreak decoding after 6e1a167c556

2020-09-04 Thread Paul B Mahol
get_unary() takes at minimum only 1 bit.

Signed-off-by: Paul B Mahol 
---
 libavcodec/dxtory.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/dxtory.c b/libavcodec/dxtory.c
index bc19f27951..3cd95afe80 100644
--- a/libavcodec/dxtory.c
+++ b/libavcodec/dxtory.c
@@ -395,7 +395,7 @@ static int dx2_decode_slice_5x5(GetBitContext *gb, AVFrame 
*frame,
 int stride   = frame->linesize[0];
 uint8_t *dst = frame->data[0] + stride * line;
 
-for (y = 0; y < left && get_bits_left(gb) > 6 * width; y++) {
+for (y = 0; y < left && get_bits_left(gb) >= 3 * width; y++) {
 for (x = 0; x < width; x++) {
 b = decode_sym_565(gb, lru[0], 5);
 g = decode_sym_565(gb, lru[1], is_565 ? 6 : 5);
@@ -462,7 +462,7 @@ static int dx2_decode_slice_rgb(GetBitContext *gb, AVFrame 
*frame,
 int stride   = frame->linesize[0];
 uint8_t *dst = frame->data[0] + stride * line;
 
-for (y = 0; y < left && get_bits_left(gb) > 6 * width; y++) {
+for (y = 0; y < left && get_bits_left(gb) >= 3 * width; y++) {
 for (x = 0; x < width; x++) {
 dst[x * 3 + 0] = decode_sym(gb, lru[0]);
 dst[x * 3 + 1] = decode_sym(gb, lru[1]);
@@ -508,7 +508,7 @@ static int dx2_decode_slice_410(GetBitContext *gb, AVFrame 
*frame,
 uint8_t *U  = frame->data[1] + (ustride >> 2) * line;
 uint8_t *V  = frame->data[2] + (vstride >> 2) * line;
 
-for (y = 0; y < left - 3 && get_bits_left(gb) > 9 * width; y += 4) {
+for (y = 0; y < left - 3 && get_bits_left(gb) >= 4 * width; y += 4) {
 for (x = 0; x < width; x += 4) {
 for (j = 0; j < 4; j++)
 for (i = 0; i < 4; i++)
@@ -553,7 +553,7 @@ static int dx2_decode_slice_420(GetBitContext *gb, AVFrame 
*frame,
 uint8_t *V  = frame->data[2] + (vstride >> 1) * line;
 
 
-for (y = 0; y < left - 1 && get_bits_left(gb) > 6 * width; y += 2) {
+for (y = 0; y < left - 1 && get_bits_left(gb) >= 3 * width; y += 2) {
 for (x = 0; x < width; x += 2) {
 Y[x + 0 + 0 * ystride] = decode_sym(gb, lru[0]);
 Y[x + 1 + 0 * ystride] = decode_sym(gb, lru[0]);
@@ -597,7 +597,7 @@ static int dx2_decode_slice_444(GetBitContext *gb, AVFrame 
*frame,
 uint8_t *U  = frame->data[1] + ustride * line;
 uint8_t *V  = frame->data[2] + vstride * line;
 
-for (y = 0; y < left && get_bits_left(gb) > 6 * width; y++) {
+for (y = 0; y < left && get_bits_left(gb) >= 3 * width; y++) {
 for (x = 0; x < width; x++) {
 Y[x] = decode_sym(gb, lru[0]);
 U[x] = decode_sym(gb, lru[1]) ^ 0x80;
-- 
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 2/3] avcodec/dxtory: support subsample formats with non-aligned dimensions

2020-09-04 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/dxtory.c | 191 
 1 file changed, 175 insertions(+), 16 deletions(-)

diff --git a/libavcodec/dxtory.c b/libavcodec/dxtory.c
index 3cd95afe80..123833741b 100644
--- a/libavcodec/dxtory.c
+++ b/libavcodec/dxtory.c
@@ -32,6 +32,25 @@
 #include "internal.h"
 #include "unary.h"
 
+static int64_t get_raw_size(enum AVPixelFormat fmt, int width, int height)
+{
+switch (fmt) {
+case AV_PIX_FMT_RGB555LE:
+case AV_PIX_FMT_RGB565LE:
+return width * height * 2LL;
+case AV_PIX_FMT_RGB24:
+case AV_PIX_FMT_BGR24:
+case AV_PIX_FMT_YUV444P:
+return width * height * 3LL;
+case AV_PIX_FMT_YUV420P:
+return (int64_t)(width * height) + AV_CEIL_RSHIFT(width, 1) * 
AV_CEIL_RSHIFT(height, 1);
+case AV_PIX_FMT_YUV410P:
+return (int64_t)(width * height) + AV_CEIL_RSHIFT(width, 2) * 
AV_CEIL_RSHIFT(height, 2);
+}
+
+return 0;
+}
+
 static void do_vflip(AVCodecContext *avctx, AVFrame *pic, int vflip)
 {
 if (!vflip)
@@ -51,17 +70,17 @@ static void do_vflip(AVCodecContext *avctx, AVFrame *pic, 
int vflip)
 case AV_PIX_FMT_YUV410P:
 pic->data[0] += (avctx->height - 1) * pic->linesize[0];
 pic->linesize[0] = -pic->linesize[0];
-pic->data[1] += ((avctx->height >> 2) - 1) * pic->linesize[1];
+pic->data[1] += (AV_CEIL_RSHIFT(avctx->height, 2) - 1) * 
pic->linesize[1];
 pic->linesize[1] = -pic->linesize[1];
-pic->data[2] += ((avctx->height >> 2) - 1) * pic->linesize[2];
+pic->data[2] += (AV_CEIL_RSHIFT(avctx->height, 2) - 1) * 
pic->linesize[2];
 pic->linesize[2] = -pic->linesize[2];
 break;
 case AV_PIX_FMT_YUV420P:
 pic->data[0] += (avctx->height - 1) * pic->linesize[0];
 pic->linesize[0] = -pic->linesize[0];
-pic->data[1] += ((avctx->height >> 1) - 1) * pic->linesize[1];
+pic->data[1] += (AV_CEIL_RSHIFT(avctx->height, 1) - 1) * 
pic->linesize[1];
 pic->linesize[1] = -pic->linesize[1];
-pic->data[2] += ((avctx->height >> 1) - 1) * pic->linesize[2];
+pic->data[2] += (AV_CEIL_RSHIFT(avctx->height, 1) - 1) * 
pic->linesize[2];
 pic->linesize[2] = -pic->linesize[2];
 break;
 }
@@ -75,7 +94,7 @@ static int dxtory_decode_v1_rgb(AVCodecContext *avctx, 
AVFrame *pic,
 uint8_t *dst;
 int ret;
 
-if (src_size < avctx->width * avctx->height * (int64_t)bpp) {
+if (src_size < get_raw_size(id, avctx->width, avctx->height)) {
 av_log(avctx, AV_LOG_ERROR, "packet too small\n");
 return AVERROR_INVALIDDATA;
 }
@@ -104,9 +123,11 @@ static int dxtory_decode_v1_410(AVCodecContext *avctx, 
AVFrame *pic,
 {
 int h, w;
 uint8_t *Y1, *Y2, *Y3, *Y4, *U, *V;
+int height, width, hmargin, vmargin;
+int huvborder;
 int ret;
 
-if (src_size < FFALIGN(avctx->width, 4) * FFALIGN(avctx->height, 4) * 9LL 
/ 8) {
+if (src_size < get_raw_size(AV_PIX_FMT_YUV410P, avctx->width, 
avctx->height)) {
 av_log(avctx, AV_LOG_ERROR, "packet too small\n");
 return AVERROR_INVALIDDATA;
 }
@@ -117,14 +138,20 @@ static int dxtory_decode_v1_410(AVCodecContext *avctx, 
AVFrame *pic,
 
 do_vflip(avctx, pic, vflipped);
 
+height = avctx->height & ~3;
+width  = avctx->width  & ~3;
+hmargin = avctx->width  - width;
+vmargin = avctx->height - height;
+huvborder = AV_CEIL_RSHIFT(avctx->width, 2) - 1;
+
 Y1 = pic->data[0];
 Y2 = pic->data[0] + pic->linesize[0];
 Y3 = pic->data[0] + pic->linesize[0] * 2;
 Y4 = pic->data[0] + pic->linesize[0] * 3;
 U  = pic->data[1];
 V  = pic->data[2];
-for (h = 0; h < avctx->height; h += 4) {
-for (w = 0; w < avctx->width; w += 4) {
+for (h = 0; h < height; h += 4) {
+for (w = 0; w < width; w += 4) {
 AV_COPY32U(Y1 + w, src);
 AV_COPY32U(Y2 + w, src + 4);
 AV_COPY32U(Y3 + w, src + 8);
@@ -133,6 +160,18 @@ static int dxtory_decode_v1_410(AVCodecContext *avctx, 
AVFrame *pic,
 V[w >> 2] = src[17] + 0x80;
 src += 18;
 }
+if (hmargin) {
+for (w = 0; w < hmargin; w++) {
+Y1[width + w] = src[w];
+Y2[width + w] = src[w + hmargin * 1];
+Y3[width + w] = src[w + hmargin * 2];
+Y4[width + w] = src[w + hmargin * 3];
+}
+src += 4 * hmargin;
+U[huvborder] = src[0] + 0x80;
+V[huvborder] = src[1] + 0x80;
+src += 2;
+}
 Y1 += pic->linesize[0] << 2;
 Y2 += pic->linesize[0] << 2;
 Y3 += pic->linesize[0] << 2;
@@ -141,6 +180,33 @@ static int dxtory_decode_v1_410(AVCodecContext *avctx, 
AVFrame *pic,
 V  += pic->linesize[2];
 }
 
+if (vmargin) {
+for (w = 0; w < width; w += 4) {
+AV_COPY32U(Y1 + w, src);
+if (vmargin > 1)
+

[FFmpeg-devel] [PATCH 3/3] avcodec/dxtory: add missed rgb555/rgb565 formats for vflip case

2020-09-04 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/dxtory.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/dxtory.c b/libavcodec/dxtory.c
index 123833741b..e239abe233 100644
--- a/libavcodec/dxtory.c
+++ b/libavcodec/dxtory.c
@@ -62,6 +62,8 @@ static void do_vflip(AVCodecContext *avctx, AVFrame *pic, int 
vflip)
 pic->linesize[1] = -pic->linesize[1];
 pic->data[2] += (avctx->height - 1) * pic->linesize[2];
 pic->linesize[2] = -pic->linesize[2];
+case AV_PIX_FMT_RGB555LE:
+case AV_PIX_FMT_RGB565LE:
 case AV_PIX_FMT_BGR24:
 case AV_PIX_FMT_RGB24:
 pic->data[0] += (avctx->height - 1) * pic->linesize[0];
-- 
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 2/2] avformat/yuv4mpegenc: Add const where appropriate

2020-09-04 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/yuv4mpegenc.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavformat/yuv4mpegenc.c b/libavformat/yuv4mpegenc.c
index fdd020e13b..6b53780ba0 100644
--- a/libavformat/yuv4mpegenc.c
+++ b/libavformat/yuv4mpegenc.c
@@ -184,12 +184,10 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 {
 AVStream *st = s->streams[pkt->stream_index];
 AVIOContext *pb = s->pb;
-AVFrame *frame;
+const AVFrame *frame = (const AVFrame *)pkt->data;
 int width, height, h_chroma_shift, v_chroma_shift;
 int i;
-uint8_t *ptr, *ptr1, *ptr2;
-
-frame = (AVFrame *)pkt->data;
+const uint8_t *ptr, *ptr1, *ptr2;
 
 /* construct frame header */
 
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 1/2] avformat/yuv4mpegenc: Simplify writing global and packet headers

2020-09-04 Thread Andreas Rheinhardt
YUV4MPEG writes a string as header for both the file itself as well as
for every frame; these strings contain magic strings and these were up
until now included in the string to write via %s. Yet they are compile
time constants, so one can use the compile-time string concatentation
instead of inserting these strings at runtime.
Furthermore, the global header has been written via snprintf() to
a local buffer first before writing it. This can be simplified by using
avio_printf().

Signed-off-by: Andreas Rheinhardt 
---
That snprintf() call was weird: The buffer used had a size of
Y4M_LINE_MAX + 1, yet snprintf has been told that the size was
Y4M_LINE_MAX, despite snprintf always adding a trailing zero (i.e. it
writes at most Y4M_LINE_MAX - 1 chars and then adds a zero).
Furthermore, snprintf only returns something negative on format errors,
not if the buffer is too small (this can be checked via the return
value). And returning AVERROR(EIO) for this error is strange, too.

 libavformat/yuv4mpegenc.c | 21 +++--
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/libavformat/yuv4mpegenc.c b/libavformat/yuv4mpegenc.c
index c4781042bd..fdd020e13b 100644
--- a/libavformat/yuv4mpegenc.c
+++ b/libavformat/yuv4mpegenc.c
@@ -24,18 +24,15 @@
 #include "internal.h"
 #include "yuv4mpeg.h"
 
-#define Y4M_LINE_MAX 256
-
 static int yuv4_write_header(AVFormatContext *s)
 {
 AVStream *st;
 AVIOContext *pb = s->pb;
 int width, height;
-int raten, rated, aspectn, aspectd, n;
+int raten, rated, aspectn, aspectd, ret;
 char inter;
 const char *colorspace = "";
 const char *colorrange = "";
-char buf[Y4M_LINE_MAX + 1];
 int field_order;
 
 st = s->streams[0];
@@ -170,19 +167,15 @@ static int yuv4_write_header(AVFormatContext *s)
 break;
 }
 
-/* construct stream header, if this is the first frame */
-n = snprintf(buf, Y4M_LINE_MAX, "%s W%d H%d F%d:%d I%c A%d:%d%s%s\n",
- Y4M_MAGIC, width, height, raten, rated, inter,
- aspectn, aspectd, colorspace, colorrange);
-
-if (n < 0) {
+ret = avio_printf(pb, Y4M_MAGIC " W%d H%d F%d:%d I%c A%d:%d%s%s\n",
+  width, height, raten, rated, inter,
+  aspectn, aspectd, colorspace, colorrange);
+if (ret < 0) {
 av_log(s, AV_LOG_ERROR,
"Error. YUV4MPEG stream header write failed.\n");
-return AVERROR(EIO);
+return ret;
 }
 
-avio_write(pb, buf, strlen(buf));
-
 return 0;
 }
 
@@ -200,7 +193,7 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 /* construct frame header */
 
-avio_printf(s->pb, "%s\n", Y4M_FRAME_MAGIC);
+avio_printf(s->pb, Y4M_FRAME_MAGIC "\n");
 
 width  = st->codecpar->width;
 height = st->codecpar->height;
-- 
2.20.1

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avformat/yuv4mpegenc: Simplify writing global and packet headers

2020-09-04 Thread Paul B Mahol
On 9/4/20, Andreas Rheinhardt  wrote:
> YUV4MPEG writes a string as header for both the file itself as well as
> for every frame; these strings contain magic strings and these were up
> until now included in the string to write via %s. Yet they are compile
> time constants, so one can use the compile-time string concatentation
> instead of inserting these strings at runtime.
> Furthermore, the global header has been written via snprintf() to
> a local buffer first before writing it. This can be simplified by using
> avio_printf().
>
> Signed-off-by: Andreas Rheinhardt 
> ---


lgtm

> That snprintf() call was weird: The buffer used had a size of
> Y4M_LINE_MAX + 1, yet snprintf has been told that the size was
> Y4M_LINE_MAX, despite snprintf always adding a trailing zero (i.e. it
> writes at most Y4M_LINE_MAX - 1 chars and then adds a zero).
> Furthermore, snprintf only returns something negative on format errors,
> not if the buffer is too small (this can be checked via the return
> value). And returning AVERROR(EIO) for this error is strange, too.
>
>  libavformat/yuv4mpegenc.c | 21 +++--
>  1 file changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/libavformat/yuv4mpegenc.c b/libavformat/yuv4mpegenc.c
> index c4781042bd..fdd020e13b 100644
> --- a/libavformat/yuv4mpegenc.c
> +++ b/libavformat/yuv4mpegenc.c
> @@ -24,18 +24,15 @@
>  #include "internal.h"
>  #include "yuv4mpeg.h"
>
> -#define Y4M_LINE_MAX 256
> -
>  static int yuv4_write_header(AVFormatContext *s)
>  {
>  AVStream *st;
>  AVIOContext *pb = s->pb;
>  int width, height;
> -int raten, rated, aspectn, aspectd, n;
> +int raten, rated, aspectn, aspectd, ret;
>  char inter;
>  const char *colorspace = "";
>  const char *colorrange = "";
> -char buf[Y4M_LINE_MAX + 1];
>  int field_order;
>
>  st = s->streams[0];
> @@ -170,19 +167,15 @@ static int yuv4_write_header(AVFormatContext *s)
>  break;
>  }
>
> -/* construct stream header, if this is the first frame */
> -n = snprintf(buf, Y4M_LINE_MAX, "%s W%d H%d F%d:%d I%c A%d:%d%s%s\n",
> - Y4M_MAGIC, width, height, raten, rated, inter,
> - aspectn, aspectd, colorspace, colorrange);
> -
> -if (n < 0) {
> +ret = avio_printf(pb, Y4M_MAGIC " W%d H%d F%d:%d I%c A%d:%d%s%s\n",
> +  width, height, raten, rated, inter,
> +  aspectn, aspectd, colorspace, colorrange);
> +if (ret < 0) {
>  av_log(s, AV_LOG_ERROR,
> "Error. YUV4MPEG stream header write failed.\n");
> -return AVERROR(EIO);
> +return ret;
>  }
>
> -avio_write(pb, buf, strlen(buf));
> -
>  return 0;
>  }
>
> @@ -200,7 +193,7 @@ static int yuv4_write_packet(AVFormatContext *s,
> AVPacket *pkt)
>
>  /* construct frame header */
>
> -avio_printf(s->pb, "%s\n", Y4M_FRAME_MAGIC);
> +avio_printf(s->pb, Y4M_FRAME_MAGIC "\n");
>
>  width  = st->codecpar->width;
>  height = st->codecpar->height;
> --
> 2.20.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/2] avformat/yuv4mpegenc: Add const where appropriate

2020-09-04 Thread Paul B Mahol
On 9/4/20, Andreas Rheinhardt  wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/yuv4mpegenc.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
>

lgtm

> diff --git a/libavformat/yuv4mpegenc.c b/libavformat/yuv4mpegenc.c
> index fdd020e13b..6b53780ba0 100644
> --- a/libavformat/yuv4mpegenc.c
> +++ b/libavformat/yuv4mpegenc.c
> @@ -184,12 +184,10 @@ static int yuv4_write_packet(AVFormatContext *s,
> AVPacket *pkt)
>  {
>  AVStream *st = s->streams[pkt->stream_index];
>  AVIOContext *pb = s->pb;
> -AVFrame *frame;
> +const AVFrame *frame = (const AVFrame *)pkt->data;
>  int width, height, h_chroma_shift, v_chroma_shift;
>  int i;
> -uint8_t *ptr, *ptr1, *ptr2;
> -
> -frame = (AVFrame *)pkt->data;
> +const uint8_t *ptr, *ptr1, *ptr2;
>
>  /* construct frame header */
>
> --
> 2.20.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@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 v5]libavfilter/asrc_fluidsynthmusic.c : generate algorithmic music

2020-09-04 Thread Paul B Mahol
On 8/25/20, Ashutosh Pradhan  wrote:
> Generate algorithmic music using riffs, lindenmayer systems, cellular
> automaton and rhythm algorithms.
>
>  Changelog  |1 +
>  configure  |4 +
>  doc/filters.texi   |  146 
>  libavfilter/Makefile   |1 +
>  libavfilter/allfilters.c   |1 +
>  libavfilter/asrc_fluidsynthmusic.c | 1344
> 
>  libavfilter/notedef.h  |  269 
>  libavfilter/version.h  |2 +-
>  8 files changed, 1767 insertions(+), 1 deletion(-)
>
> diff --git a/Changelog b/Changelog
> index 0108f8f1a8..fb60ea098f 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -89,6 +89,7 @@ version 4.3:
>  - PFM decoder
>  - dblur video filter
>  - Real War KVAG muxer
> +- fluidsynthmusic filter
>

This crashes for high gen option set.
___
ffmpeg-devel mailing list
ffmpeg-devel@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/2] dnn_backend_native.c: parse options in native backend

2020-09-04 Thread xujunzz
From: Xu Jun 

v2: use av_opt_set_from_string instead of function dnn_parse_option().

Signed-off-by: Xu Jun 
---
 libavfilter/dnn/dnn_backend_native.c | 19 ++-
 libavfilter/dnn/dnn_backend_native.h | 21 +
 2 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index a8fe6b94eb..b1ee6fb399 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -28,14 +28,6 @@
 #include "dnn_backend_native_layer_conv2d.h"
 #include "dnn_backend_native_layers.h"
 
-static const AVClass dnn_native_class = {
-.class_name = "dnn_native",
-.item_name  = av_default_item_name,
-.option = NULL,
-.version= LIBAVUTIL_VERSION_INT,
-.category   = AV_CLASS_CATEGORY_FILTER,
-};
-
 static DNNReturnType get_input_native(void *model, DNNData *input, const char 
*input_name)
 {
 NativeModel *native_model = (NativeModel *)model;
@@ -174,8 +166,18 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename, const char *optio
 }
 
 native_model->ctx.class = &dnn_native_class;
+model->options = options;
+if (av_opt_set_from_string(&native_model->ctx, model->options, 
"conv2d_threads", "=", "&") < 0)
+goto fail;
 model->model = (void *)native_model;
 
+#if !HAVE_PTHREAD_CANCEL
+if (native_model->ctx.options.conv2d_threads > 1){
+av_log(&native_model->ctx, AV_LOG_WARNING, "'conv2d_threads' option 
was set but it is not supported "
+   "on this build (pthread support is required)\n");
+}
+#endif
+
 avio_seek(model_file_context, file_size - 8, SEEK_SET);
 native_model->layers_num = (int32_t)avio_rl32(model_file_context);
 native_model->operands_num = (int32_t)avio_rl32(model_file_context);
@@ -248,7 +250,6 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename, const char *optio
 
 model->set_input = &set_input_native;
 model->get_input = &get_input_native;
-model->options = options;
 
 return model;
 
diff --git a/libavfilter/dnn/dnn_backend_native.h 
b/libavfilter/dnn/dnn_backend_native.h
index 197f557dee..3954fee199 100644
--- a/libavfilter/dnn/dnn_backend_native.h
+++ b/libavfilter/dnn/dnn_backend_native.h
@@ -29,6 +29,7 @@
 
 #include "../dnn_interface.h"
 #include "libavformat/avio.h"
+#include "libavutil/opt.h"
 
 /**
  * the enum value of DNNLayerType should not be changed,
@@ -106,10 +107,30 @@ typedef struct InputParams{
 int height, width, channels;
 } InputParams;
 
+typedef struct NativeOptions{
+uint32_t conv2d_threads;
+} NativeOptions;
+
 typedef struct NativeContext {
 const AVClass *class;
+NativeOptions options;
 } NativeContext;
 
+#define OFFSET(x) offsetof(NativeContext, x)
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM
+static const AVOption dnn_native_options[] = {
+{ "conv2d_threads", "threads num for conv2d layer", 
OFFSET(options.conv2d_threads), AV_OPT_TYPE_INT,  { .i64 = 0 }, INT_MIN, 
INT_MAX, FLAGS },
+{ NULL },
+};
+
+static const AVClass dnn_native_class = {
+.class_name = "dnn_native",
+.item_name  = av_default_item_name,
+.option = dnn_native_options,
+.version= LIBAVUTIL_VERSION_INT,
+.category   = AV_CLASS_CATEGORY_FILTER,
+};
+
 // Represents simple feed-forward convolutional network.
 typedef struct NativeModel{
 NativeContext ctx;
-- 
2.28.0

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

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

[FFmpeg-devel] [PATCH v2 2/2] dnn_backend_native_layer_conv2d.c:Add mutithread function

2020-09-04 Thread xujunzz
From: Xu Jun 

v2: add check for HAVE_PTHREAD_CANCEL and modify FATE test
dnn-layer-conv2d-test.c

Use pthread to multithread dnn_execute_layer_conv2d.
Can be tested with command "./ffmpeg_g -i input.png -vf \
format=yuvj420p,dnn_processing=dnn_backend=native:model= \
espcn.model:input=x:output=y:options=conv2d_threads=23 \
 -y sr_native.jpg -benchmark"

before patch: utime=11.238s stime=0.005s rtime=11.248s
after patch:  utime=20.817s stime=0.047s rtime=1.051s
on my 3900X 12c24t @4.2GHz

About the increase of utime, it's because that CPU HyperThreading
technology makes logical cores twice of physical cores while cpu's
counting performance improves less than double. And utime sums
all cpu's logical cores' runtime. As a result, using threads num
near cpu's logical core's number will double utime, while reduce
rtime less than half for HyperThreading CPUs.

Signed-off-by: Xu Jun 
---
 .../dnn/dnn_backend_native_layer_conv2d.c | 107 --
 tests/dnn/dnn-layer-conv2d-test.c |  12 +-
 2 files changed, 106 insertions(+), 13 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c 
b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
index d079795bf8..4068a13ab4 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
@@ -19,10 +19,27 @@
  */
 
 #include "libavutil/avassert.h"
+#include "libavutil/thread.h"
+#include "libavutil/cpu.h"
 #include "dnn_backend_native_layer_conv2d.h"
 
 #define CLAMP_TO_EDGE(x, w) ((x) < 0 ? 0 : ((x) >= (w) ? (w - 1) : (x)))
 
+//struct to pass parameters
+typedef struct thread_common_param{
+DnnOperand *operands;
+const int32_t *input_operand_indexes;
+int32_t output_operand_index;
+const void *parameters;
+NativeContext *ctx;
+int thread_num;
+} thread_common_param;
+
+typedef struct thread_param{
+thread_common_param *thread_common_param;
+int thread_index;
+} thread_param;
+
 int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int 
file_size, int operands_num)
 {
 ConvolutionalParams *conv_params;
@@ -88,17 +105,20 @@ int dnn_load_layer_conv2d(Layer *layer, AVIOContext 
*model_file_context, int fil
 return dnn_size;
 }
 
-int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t 
*input_operand_indexes,
- int32_t output_operand_index, const void 
*parameters, NativeContext *ctx)
+static void * dnn_execute_layer_conv2d_thread(void *threadarg)
 {
+//pass parameters
+thread_param *thread_param = (struct thread_param *)threadarg;
+thread_common_param *thread_common_param = 
thread_param->thread_common_param;
+DnnOperand *operands = thread_common_param->operands;
 float *output;
-int32_t input_operand_index = input_operand_indexes[0];
+int32_t input_operand_index = 
thread_common_param->input_operand_indexes[0];
 int number = operands[input_operand_index].dims[0];
 int height = operands[input_operand_index].dims[1];
 int width = operands[input_operand_index].dims[2];
 int channel = operands[input_operand_index].dims[3];
 const float *input = operands[input_operand_index].data;
-const ConvolutionalParams *conv_params = (const ConvolutionalParams 
*)parameters;
+const ConvolutionalParams *conv_params = (const ConvolutionalParams 
*)(thread_common_param->parameters);
 
 int radius = conv_params->kernel_size >> 1;
 int src_linesize = width * conv_params->input_num;
@@ -106,7 +126,11 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 int filter_size = conv_params->kernel_size * filter_linesize;
 int pad_size = (conv_params->padding_method == VALID) ? 
(conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0;
 
-DnnOperand *output_operand = &operands[output_operand_index];
+int thread_stride = (height - pad_size * 2) / 
thread_common_param->thread_num;
+int thread_start = thread_stride * thread_param->thread_index + pad_size;
+int thread_end = (thread_param->thread_index == 
thread_common_param->thread_num - 1) ? (height - pad_size) : (thread_start + 
thread_stride);
+
+DnnOperand *output_operand = 
&operands[thread_common_param->output_operand_index];
 output_operand->dims[0] = number;
 output_operand->dims[1] = height - pad_size * 2;
 output_operand->dims[2] = width - pad_size * 2;
@@ -114,19 +138,21 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 output_operand->data_type = operands[input_operand_index].data_type;
 output_operand->length = calculate_operand_data_length(output_operand);
 if (output_operand->length <= 0) {
-av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n");
-return DNN_ERROR;
+av_log(thread_common_param->ctx, AV_LOG_ERROR, "The output data length 
overflow\n");
+return (void *)DNN_ERROR;
 }
 output_operand->data = av_realloc(out

Re: [FFmpeg-devel] [PATCH] avcodec: add PhotoCD decoder

2020-09-04 Thread Paul B Mahol
On 8/30/20, Paul B Mahol  wrote:
> On 8/30/20, Andreas Rheinhardt  wrote:
> [...]
>>> +static int read_hufftable(AVCodecContext *avctx, VLC *vlc)
>>> +{
>>> +PhotoCDContext *s = avctx->priv_data;
>>> +GetByteContext *gb = &s->gb;
>>> +int start = s->streampos;
>>> +int count, ret;
>>> +
>>> +bytestream2_seek(gb, start, SEEK_SET);
>>> +
>>> +count = bytestream2_get_byte(gb) + 1;
>>> +
>>
>> With this information you can check once whether there is enough data
>> left, allowing you to use the unchecked versions of the bytestream2 API.
>
> Fixed locally.
>
>>
>>> +ff_free_vlc(vlc);
>>> +
>>> +for (int j = 0; j < count; j++) {
>>> +const int bit  = bytestream2_get_byte(gb) + 1;
>>> +const int code = bytestream2_get_be16(gb) >> (16 - bit);
>>
>> You are using bit here before having validated it.
>
> Fixed locally.
>
> [...]
>


Gonna apply with few other small changes.
___
ffmpeg-devel mailing list
ffmpeg-devel@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] dnn_backend_native.c: parse options in native backend

2020-09-04 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> xuju...@sjtu.edu.cn
> Sent: 2020年9月4日 20:46
> To: ffmpeg-devel@ffmpeg.org
> Cc: xuju...@sjtu.edu.cn
> Subject: [FFmpeg-devel] [PATCH v2 1/2] dnn_backend_native.c: parse options in
> native backend
> 
> From: Xu Jun 
> 
> v2: use av_opt_set_from_string instead of function dnn_parse_option().
> 
> Signed-off-by: Xu Jun 
> ---

please add your v2/v3 comments here, so it will not be shown in commit log.

>  libavfilter/dnn/dnn_backend_native.c | 19 ++-
> libavfilter/dnn/dnn_backend_native.h | 21 +
>  2 files changed, 31 insertions(+), 9 deletions(-)
> 
> diff --git a/libavfilter/dnn/dnn_backend_native.c
> b/libavfilter/dnn/dnn_backend_native.c
> index a8fe6b94eb..b1ee6fb399 100644
> --- a/libavfilter/dnn/dnn_backend_native.c
> +++ b/libavfilter/dnn/dnn_backend_native.c
> @@ -28,14 +28,6 @@
>  #include "dnn_backend_native_layer_conv2d.h"
>  #include "dnn_backend_native_layers.h"
> 
> -static const AVClass dnn_native_class = {
> -.class_name = "dnn_native",
> -.item_name  = av_default_item_name,
> -.option = NULL,
> -.version= LIBAVUTIL_VERSION_INT,
> -.category   = AV_CLASS_CATEGORY_FILTER,
> -};
> -
>  static DNNReturnType get_input_native(void *model, DNNData *input, const
> char *input_name)  {
>  NativeModel *native_model = (NativeModel *)model; @@ -174,8
> +166,18 @@ DNNModel *ff_dnn_load_model_native(const char
> *model_filename, const char *optio
>  }
> 
>  native_model->ctx.class = &dnn_native_class;
> +model->options = options;
> +if (av_opt_set_from_string(&native_model->ctx, model->options,
> "conv2d_threads", "=", "&") < 0)

should be  if (av_opt_set_from_string(&native_model->ctx, model->options, NULL, 
"=", "&") < 0) , 
so all the options are supported, not just conv2d_threads, and it also fixed 
the build warning.

___
ffmpeg-devel mailing list
ffmpeg-devel@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] dnn_backend_native_layer_conv2d.c:Add mutithread function

2020-09-04 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> xuju...@sjtu.edu.cn
> Sent: 2020年9月4日 20:46
> To: ffmpeg-devel@ffmpeg.org
> Cc: xuju...@sjtu.edu.cn
> Subject: [FFmpeg-devel] [PATCH v2 2/2]
> dnn_backend_native_layer_conv2d.c:Add mutithread function
> 
> From: Xu Jun 
> 
> v2: add check for HAVE_PTHREAD_CANCEL and modify FATE test
> dnn-layer-conv2d-test.c
> 
> Use pthread to multithread dnn_execute_layer_conv2d.
> Can be tested with command "./ffmpeg_g -i input.png -vf \
> format=yuvj420p,dnn_processing=dnn_backend=native:model= \
> espcn.model:input=x:output=y:options=conv2d_threads=23 \
>  -y sr_native.jpg -benchmark"
> 
> before patch: utime=11.238s stime=0.005s rtime=11.248s
> after patch:  utime=20.817s stime=0.047s rtime=1.051s
> on my 3900X 12c24t @4.2GHz
> 
> About the increase of utime, it's because that CPU HyperThreading
> technology makes logical cores twice of physical cores while cpu's
> counting performance improves less than double. And utime sums
> all cpu's logical cores' runtime. As a result, using threads num
> near cpu's logical core's number will double utime, while reduce
> rtime less than half for HyperThreading CPUs.
> 
> Signed-off-by: Xu Jun 
> ---
>  .../dnn/dnn_backend_native_layer_conv2d.c | 107 --
>  tests/dnn/dnn-layer-conv2d-test.c |  12 +-
>  2 files changed, 106 insertions(+), 13 deletions(-)
> 
> diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> index d079795bf8..4068a13ab4 100644
> --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> @@ -19,10 +19,27 @@
>   */
> 
>  #include "libavutil/avassert.h"
> +#include "libavutil/thread.h"
> +#include "libavutil/cpu.h"
>  #include "dnn_backend_native_layer_conv2d.h"
> 
>  #define CLAMP_TO_EDGE(x, w) ((x) < 0 ? 0 : ((x) >= (w) ? (w - 1) : (x)))
> 
> +//struct to pass parameters
> +typedef struct thread_common_param{
> +DnnOperand *operands;
> +const int32_t *input_operand_indexes;
> +int32_t output_operand_index;
> +const void *parameters;
> +NativeContext *ctx;
> +int thread_num;
> +} thread_common_param;
> +
> +typedef struct thread_param{
> +thread_common_param *thread_common_param;
> +int thread_index;
> +} thread_param;
> +
>  int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int
> file_size, int operands_num)
>  {
>  ConvolutionalParams *conv_params;
> @@ -88,17 +105,20 @@ int dnn_load_layer_conv2d(Layer *layer, AVIOContext
> *model_file_context, int fil
>  return dnn_size;
>  }
> 
> -int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t
> *input_operand_indexes,
> - int32_t output_operand_index, const void
> *parameters, NativeContext *ctx)
> +static void * dnn_execute_layer_conv2d_thread(void *threadarg)
>  {
> +//pass parameters
> +thread_param *thread_param = (struct thread_param *)threadarg;
> +thread_common_param *thread_common_param =
> thread_param->thread_common_param;
> +DnnOperand *operands = thread_common_param->operands;
>  float *output;
> -int32_t input_operand_index = input_operand_indexes[0];
> +int32_t input_operand_index =
> thread_common_param->input_operand_indexes[0];
>  int number = operands[input_operand_index].dims[0];
>  int height = operands[input_operand_index].dims[1];
>  int width = operands[input_operand_index].dims[2];
>  int channel = operands[input_operand_index].dims[3];
>  const float *input = operands[input_operand_index].data;
> -const ConvolutionalParams *conv_params = (const ConvolutionalParams
> *)parameters;
> +const ConvolutionalParams *conv_params = (const ConvolutionalParams
> *)(thread_common_param->parameters);
> 
>  int radius = conv_params->kernel_size >> 1;
>  int src_linesize = width * conv_params->input_num;
> @@ -106,7 +126,11 @@ int dnn_execute_layer_conv2d(DnnOperand
> *operands, const int32_t *input_operand_
>  int filter_size = conv_params->kernel_size * filter_linesize;
>  int pad_size = (conv_params->padding_method == VALID) ?
> (conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0;
> 
> -DnnOperand *output_operand = &operands[output_operand_index];
> +int thread_stride = (height - pad_size * 2) /
> thread_common_param->thread_num;
> +int thread_start = thread_stride * thread_param->thread_index +
> pad_size;
> +int thread_end = (thread_param->thread_index ==
> thread_common_param->thread_num - 1) ? (height - pad_size) : (thread_start
> + thread_stride);
> +
> +DnnOperand *output_operand =
> &operands[thread_common_param->output_operand_index];
>  output_operand->dims[0] = number;
>  output_operand->dims[1] = height - pad_size * 2;
>  output_operand->dims[2] = width - pad_size * 2;
> @@ -114,19 +138,21 @@ int dnn_execute_layer_conv2d(DnnOperand
> *operands, const int32_t *inp

Re: [FFmpeg-devel] [PATCH v5]libavfilter/asrc_fluidsynthmusic.c : generate algorithmic music

2020-09-04 Thread Ashutosh Pradhan
On Fri, Sep 4, 2020 at 6:08 PM Paul B Mahol  wrote:

> On 8/25/20, Ashutosh Pradhan  wrote:
> > Generate algorithmic music using riffs, lindenmayer systems, cellular
> > automaton and rhythm algorithms.
> >
> >  Changelog  |1 +
> >  configure  |4 +
> >  doc/filters.texi   |  146 
> >  libavfilter/Makefile   |1 +
> >  libavfilter/allfilters.c   |1 +
> >  libavfilter/asrc_fluidsynthmusic.c | 1344
> > 
> >  libavfilter/notedef.h  |  269 
> >  libavfilter/version.h  |2 +-
> >  8 files changed, 1767 insertions(+), 1 deletion(-)
> >
> > diff --git a/Changelog b/Changelog
> > index 0108f8f1a8..fb60ea098f 100644
> > --- a/Changelog
> > +++ b/Changelog
> > @@ -89,6 +89,7 @@ version 4.3:
> >  - PFM decoder
> >  - dblur video filter
> >  - Real War KVAG muxer
> > +- fluidsynthmusic filter
> >
>
> This crashes for high gen option set.
>
For the L system, the strings nextgen and prevgen are computed for every
generation until the final generation is reached. For very high values of
gen(number of generations), it takes significant time to compute the
nextgen.
But as given in the reference, higher generations say beyond 10 repeats the
sequence. I think I should set the maximum limit of gen to a more practical
value of around 10 to 20.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v3 1/2] dnn_backend_native.c: parse options in native backend

2020-09-04 Thread xujunzz
From: Xu Jun 

Signed-off-by: Xu Jun 
---
v2: use av_opt_set_from_string instead of function dnn_parse_option().
v3: make all the options supported, not just conv2d_threads

 libavfilter/dnn/dnn_backend_native.c | 19 ++-
 libavfilter/dnn/dnn_backend_native.h | 21 +
 2 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index a8fe6b94eb..031fb8c7df 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -28,14 +28,6 @@
 #include "dnn_backend_native_layer_conv2d.h"
 #include "dnn_backend_native_layers.h"
 
-static const AVClass dnn_native_class = {
-.class_name = "dnn_native",
-.item_name  = av_default_item_name,
-.option = NULL,
-.version= LIBAVUTIL_VERSION_INT,
-.category   = AV_CLASS_CATEGORY_FILTER,
-};
-
 static DNNReturnType get_input_native(void *model, DNNData *input, const char 
*input_name)
 {
 NativeModel *native_model = (NativeModel *)model;
@@ -174,8 +166,18 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename, const char *optio
 }
 
 native_model->ctx.class = &dnn_native_class;
+model->options = options;
+if (av_opt_set_from_string(&native_model->ctx, model->options, NULL, "=", 
"&") < 0)
+goto fail;
 model->model = (void *)native_model;
 
+#if !HAVE_PTHREAD_CANCEL
+if (native_model->ctx.options.conv2d_threads > 1){
+av_log(&native_model->ctx, AV_LOG_WARNING, "'conv2d_threads' option 
was set but it is not supported "
+   "on this build (pthread support is required)\n");
+}
+#endif
+
 avio_seek(model_file_context, file_size - 8, SEEK_SET);
 native_model->layers_num = (int32_t)avio_rl32(model_file_context);
 native_model->operands_num = (int32_t)avio_rl32(model_file_context);
@@ -248,7 +250,6 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename, const char *optio
 
 model->set_input = &set_input_native;
 model->get_input = &get_input_native;
-model->options = options;
 
 return model;
 
diff --git a/libavfilter/dnn/dnn_backend_native.h 
b/libavfilter/dnn/dnn_backend_native.h
index 197f557dee..3954fee199 100644
--- a/libavfilter/dnn/dnn_backend_native.h
+++ b/libavfilter/dnn/dnn_backend_native.h
@@ -29,6 +29,7 @@
 
 #include "../dnn_interface.h"
 #include "libavformat/avio.h"
+#include "libavutil/opt.h"
 
 /**
  * the enum value of DNNLayerType should not be changed,
@@ -106,10 +107,30 @@ typedef struct InputParams{
 int height, width, channels;
 } InputParams;
 
+typedef struct NativeOptions{
+uint32_t conv2d_threads;
+} NativeOptions;
+
 typedef struct NativeContext {
 const AVClass *class;
+NativeOptions options;
 } NativeContext;
 
+#define OFFSET(x) offsetof(NativeContext, x)
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM
+static const AVOption dnn_native_options[] = {
+{ "conv2d_threads", "threads num for conv2d layer", 
OFFSET(options.conv2d_threads), AV_OPT_TYPE_INT,  { .i64 = 0 }, INT_MIN, 
INT_MAX, FLAGS },
+{ NULL },
+};
+
+static const AVClass dnn_native_class = {
+.class_name = "dnn_native",
+.item_name  = av_default_item_name,
+.option = dnn_native_options,
+.version= LIBAVUTIL_VERSION_INT,
+.category   = AV_CLASS_CATEGORY_FILTER,
+};
+
 // Represents simple feed-forward convolutional network.
 typedef struct NativeModel{
 NativeContext ctx;
-- 
2.28.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] avcodec/dxtory: unbreak decoding after 6e1a167c556

2020-09-04 Thread James Almer
On 9/4/2020 6:29 AM, Paul B Mahol wrote:
> On 9/4/20, Michael Niedermayer  wrote:
>> On Fri, Sep 04, 2020 at 12:27:11AM +0200, Paul B Mahol wrote:
>>> On 9/3/20, Michael Niedermayer  wrote:
 On Thu, Sep 03, 2020 at 07:03:23PM +0200, Paul B Mahol wrote:
> get_unary() takes at minimum only 1 bit.
>
> Signed-off-by: Paul B Mahol 
> ---
>
> As this is important fix, will apply in next 5 minutes.
> I kindly ask authors of various timeouts changes to kindly
> test their changes more carefully.

 Can you provide test samples and a fate test ?
>>>
>>> Why should I? Nobody uploads my request to wav CUE thing.
>>
>> You have access to upload yourself and
>> post the request to the wrong address, it is
>> FFmpeg sample uploads 
>>
> 
> I never received anything of sort of access to something.

Your ssh pub key is in the server, which means you can connect to it and
upload samples using rsync.

See https://ffmpeg.org/fate.html#Uploading-new-samples-to-the-fate-suite

> 
>>
>>>
>>> Test samples can be generated by installing trial dxtory capture and
>>> recording
>>> mainly black frames from some simple game. On windows, or under
>>> virtualbox.
>>>
>>> I can upload files, but I value my time and will not do it for nothing
>>> in return.
>>
>> The time someone else needs to setup a windows machiene, trial dxtory
>> capture,
>> some game and so forth is several times that of just providing existing
>> files.
>>
>> So by providing existing files you give others more time to work on
>> other things like reviewing your patches, or uploading your files to
>> fate, or working on anything else, which can then also benefit you ...
>> Is that enough in return ?
> 
> No, I will leave this decoder broken. So be it.
> And I wish you happy breaking of every single other decoder,
> you have enormous potential.
> 
> I'm completely unpaid in this what I do.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@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] avcodec/dxtory: unbreak decoding after 6e1a167c556

2020-09-04 Thread Paul B Mahol
On 9/4/20, James Almer  wrote:
> On 9/4/2020 6:29 AM, Paul B Mahol wrote:
>> On 9/4/20, Michael Niedermayer  wrote:
>>> On Fri, Sep 04, 2020 at 12:27:11AM +0200, Paul B Mahol wrote:
 On 9/3/20, Michael Niedermayer  wrote:
> On Thu, Sep 03, 2020 at 07:03:23PM +0200, Paul B Mahol wrote:
>> get_unary() takes at minimum only 1 bit.
>>
>> Signed-off-by: Paul B Mahol 
>> ---
>>
>> As this is important fix, will apply in next 5 minutes.
>> I kindly ask authors of various timeouts changes to kindly
>> test their changes more carefully.
>
> Can you provide test samples and a fate test ?

 Why should I? Nobody uploads my request to wav CUE thing.
>>>
>>> You have access to upload yourself and
>>> post the request to the wrong address, it is
>>> FFmpeg sample uploads 
>>>
>>
>> I never received anything of sort of access to something.
>
> Your ssh pub key is in the server, which means you can connect to it and
> upload samples using rsync.
>
> See https://ffmpeg.org/fate.html#Uploading-new-samples-to-the-fate-suite

So I connect via ssh program?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/dxtory: unbreak decoding after 6e1a167c556

2020-09-04 Thread James Almer
On 9/4/2020 11:44 AM, Paul B Mahol wrote:
> On 9/4/20, James Almer  wrote:
>> On 9/4/2020 6:29 AM, Paul B Mahol wrote:
>>> On 9/4/20, Michael Niedermayer  wrote:
 On Fri, Sep 04, 2020 at 12:27:11AM +0200, Paul B Mahol wrote:
> On 9/3/20, Michael Niedermayer  wrote:
>> On Thu, Sep 03, 2020 at 07:03:23PM +0200, Paul B Mahol wrote:
>>> get_unary() takes at minimum only 1 bit.
>>>
>>> Signed-off-by: Paul B Mahol 
>>> ---
>>>
>>> As this is important fix, will apply in next 5 minutes.
>>> I kindly ask authors of various timeouts changes to kindly
>>> test their changes more carefully.
>>
>> Can you provide test samples and a fate test ?
>
> Why should I? Nobody uploads my request to wav CUE thing.

 You have access to upload yourself and
 post the request to the wrong address, it is
 FFmpeg sample uploads 

>>>
>>> I never received anything of sort of access to something.
>>
>> Your ssh pub key is in the server, which means you can connect to it and
>> upload samples using rsync.
>>
>> See https://ffmpeg.org/fate.html#Uploading-new-samples-to-the-fate-suite
> 
> So I connect via ssh program?

rsync will connect through ssh if you use the commands listed there.
Just replace the path to wherever you have the samples suite locally.
And please don't skip the dry-run, to ensure you don't make unwanted
changes to the remote repository.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/dxtory: unbreak decoding after 6e1a167c556

2020-09-04 Thread Paul B Mahol
On 9/4/20, James Almer  wrote:
> On 9/4/2020 11:44 AM, Paul B Mahol wrote:
>> On 9/4/20, James Almer  wrote:
>>> On 9/4/2020 6:29 AM, Paul B Mahol wrote:
 On 9/4/20, Michael Niedermayer  wrote:
> On Fri, Sep 04, 2020 at 12:27:11AM +0200, Paul B Mahol wrote:
>> On 9/3/20, Michael Niedermayer  wrote:
>>> On Thu, Sep 03, 2020 at 07:03:23PM +0200, Paul B Mahol wrote:
 get_unary() takes at minimum only 1 bit.

 Signed-off-by: Paul B Mahol 
 ---

 As this is important fix, will apply in next 5 minutes.
 I kindly ask authors of various timeouts changes to kindly
 test their changes more carefully.
>>>
>>> Can you provide test samples and a fate test ?
>>
>> Why should I? Nobody uploads my request to wav CUE thing.
>
> You have access to upload yourself and
> post the request to the wrong address, it is
> FFmpeg sample uploads 
>

 I never received anything of sort of access to something.
>>>
>>> Your ssh pub key is in the server, which means you can connect to it and
>>> upload samples using rsync.
>>>
>>> See https://ffmpeg.org/fate.html#Uploading-new-samples-to-the-fate-suite
>>
>> So I connect via ssh program?
>
> rsync will connect through ssh if you use the commands listed there.
> Just replace the path to wherever you have the samples suite locally.
> And please don't skip the dry-run, to ensure you don't make unwanted
> changes to the remote repository.

If I use first command listed there i get:

computer@localhost:~/git/ffmpeg$ rsync -vauL
--chmod=Dg+s,Duo+x,ug+rw,o+r,o-w,+X
fate-suite.ffmpeg.org:/home/samples/fate-suite/ ../fate-suite/
compu...@fate-suite.ffmpeg.org: Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: unexplained error (code 255) at io.c(235) [Receiver=3.1.2]
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/dxtory: unbreak decoding after 6e1a167c556

2020-09-04 Thread James Almer
On 9/4/2020 11:53 AM, Paul B Mahol wrote:
> On 9/4/20, James Almer  wrote:
>> On 9/4/2020 11:44 AM, Paul B Mahol wrote:
>>> On 9/4/20, James Almer  wrote:
 On 9/4/2020 6:29 AM, Paul B Mahol wrote:
> On 9/4/20, Michael Niedermayer  wrote:
>> On Fri, Sep 04, 2020 at 12:27:11AM +0200, Paul B Mahol wrote:
>>> On 9/3/20, Michael Niedermayer  wrote:
 On Thu, Sep 03, 2020 at 07:03:23PM +0200, Paul B Mahol wrote:
> get_unary() takes at minimum only 1 bit.
>
> Signed-off-by: Paul B Mahol 
> ---
>
> As this is important fix, will apply in next 5 minutes.
> I kindly ask authors of various timeouts changes to kindly
> test their changes more carefully.

 Can you provide test samples and a fate test ?
>>>
>>> Why should I? Nobody uploads my request to wav CUE thing.
>>
>> You have access to upload yourself and
>> post the request to the wrong address, it is
>> FFmpeg sample uploads 
>>
>
> I never received anything of sort of access to something.

 Your ssh pub key is in the server, which means you can connect to it and
 upload samples using rsync.

 See https://ffmpeg.org/fate.html#Uploading-new-samples-to-the-fate-suite
>>>
>>> So I connect via ssh program?
>>
>> rsync will connect through ssh if you use the commands listed there.
>> Just replace the path to wherever you have the samples suite locally.
>> And please don't skip the dry-run, to ensure you don't make unwanted
>> changes to the remote repository.
> 
> If I use first command listed there i get:
> 
> computer@localhost:~/git/ffmpeg$ rsync -vauL
> --chmod=Dg+s,Duo+x,ug+rw,o+r,o-w,+X
> fate-suite.ffmpeg.org:/home/samples/fate-suite/ ../fate-suite/
> compu...@fate-suite.ffmpeg.org: Permission denied (publickey).
> rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
> rsync error: unexplained error (code 255) at io.c(235) [Receiver=3.1.2]

Guess you're not using the key Michael saw was uploaded in the server.
Do you have more than one for different purposes? Maybe Michael can
chime in.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v4 1/2] dnn_backend_native.c: parse options in native backend

2020-09-04 Thread xujunzz
From: Xu Jun 

Signed-off-by: Xu Jun 
---
v2: use av_opt_set_from_string instead of function dnn_parse_option().
v3: make all the options supported, not just conv2d_threads
v4: move dnn_native_options and dnn_native_class to from .h to .c.

 libavfilter/dnn/dnn_backend_native.c | 22 +++---
 libavfilter/dnn/dnn_backend_native.h |  6 ++
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native.c 
b/libavfilter/dnn/dnn_backend_native.c
index a8fe6b94eb..a9ecbdc88b 100644
--- a/libavfilter/dnn/dnn_backend_native.c
+++ b/libavfilter/dnn/dnn_backend_native.c
@@ -28,10 +28,17 @@
 #include "dnn_backend_native_layer_conv2d.h"
 #include "dnn_backend_native_layers.h"
 
-static const AVClass dnn_native_class = {
+#define OFFSET(x) offsetof(NativeContext, x)
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM
+static const AVOption dnn_native_options[] = {
+{ "conv2d_threads", "threads num for conv2d layer", 
OFFSET(options.conv2d_threads), AV_OPT_TYPE_INT,  { .i64 = 0 }, INT_MIN, 
INT_MAX, FLAGS },
+{ NULL },
+};
+
+const AVClass dnn_native_class = {
 .class_name = "dnn_native",
 .item_name  = av_default_item_name,
-.option = NULL,
+.option = dnn_native_options,
 .version= LIBAVUTIL_VERSION_INT,
 .category   = AV_CLASS_CATEGORY_FILTER,
 };
@@ -174,8 +181,18 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename, const char *optio
 }
 
 native_model->ctx.class = &dnn_native_class;
+model->options = options;
+if (av_opt_set_from_string(&native_model->ctx, model->options, NULL, "=", 
"&") < 0)
+goto fail;
 model->model = (void *)native_model;
 
+#if !HAVE_PTHREAD_CANCEL
+if (native_model->ctx.options.conv2d_threads > 1){
+av_log(&native_model->ctx, AV_LOG_WARNING, "'conv2d_threads' option 
was set but it is not supported "
+   "on this build (pthread support is required)\n");
+}
+#endif
+
 avio_seek(model_file_context, file_size - 8, SEEK_SET);
 native_model->layers_num = (int32_t)avio_rl32(model_file_context);
 native_model->operands_num = (int32_t)avio_rl32(model_file_context);
@@ -248,7 +265,6 @@ DNNModel *ff_dnn_load_model_native(const char 
*model_filename, const char *optio
 
 model->set_input = &set_input_native;
 model->get_input = &get_input_native;
-model->options = options;
 
 return model;
 
diff --git a/libavfilter/dnn/dnn_backend_native.h 
b/libavfilter/dnn/dnn_backend_native.h
index 197f557dee..b1f8f3d6bf 100644
--- a/libavfilter/dnn/dnn_backend_native.h
+++ b/libavfilter/dnn/dnn_backend_native.h
@@ -29,6 +29,7 @@
 
 #include "../dnn_interface.h"
 #include "libavformat/avio.h"
+#include "libavutil/opt.h"
 
 /**
  * the enum value of DNNLayerType should not be changed,
@@ -106,8 +107,13 @@ typedef struct InputParams{
 int height, width, channels;
 } InputParams;
 
+typedef struct NativeOptions{
+uint32_t conv2d_threads;
+} NativeOptions;
+
 typedef struct NativeContext {
 const AVClass *class;
+NativeOptions options;
 } NativeContext;
 
 // Represents simple feed-forward convolutional network.
-- 
2.28.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 v4 2/2] dnn_backend_native_layer_conv2d.c:Add mutithread function

2020-09-04 Thread xujunzz
From: Xu Jun 

Use pthread to multithread dnn_execute_layer_conv2d.
Can be tested with command "./ffmpeg_g -i input.png -vf \
format=yuvj420p,dnn_processing=dnn_backend=native:model= \
espcn.model:input=x:output=y:options=conv2d_threads=23 \
 -y sr_native.jpg -benchmark"

before patch: utime=11.238s stime=0.005s rtime=11.248s
after patch:  utime=20.817s stime=0.047s rtime=1.051s
on my 3900X 12c24t @4.2GHz

About the increase of utime, it's because that CPU HyperThreading
technology makes logical cores twice of physical cores while cpu's
counting performance improves less than double. And utime sums
all cpu's logical cores' runtime. As a result, using threads num
near cpu's logical core's number will double utime, while reduce
rtime less than half for HyperThreading CPUs.

Signed-off-by: Xu Jun 
---
v2: add check for HAVE_PTHREAD_CANCEL and modify FATE test
dnn-layer-conv2d-test.c
v4: use extern to call dnn_native_class in dnn-layer-conv2d-test.c

 .../dnn/dnn_backend_native_layer_conv2d.c | 107 --
 tests/dnn/dnn-layer-conv2d-test.c |  14 ++-
 2 files changed, 108 insertions(+), 13 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c 
b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
index d079795bf8..4068a13ab4 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
@@ -19,10 +19,27 @@
  */
 
 #include "libavutil/avassert.h"
+#include "libavutil/thread.h"
+#include "libavutil/cpu.h"
 #include "dnn_backend_native_layer_conv2d.h"
 
 #define CLAMP_TO_EDGE(x, w) ((x) < 0 ? 0 : ((x) >= (w) ? (w - 1) : (x)))
 
+//struct to pass parameters
+typedef struct thread_common_param{
+DnnOperand *operands;
+const int32_t *input_operand_indexes;
+int32_t output_operand_index;
+const void *parameters;
+NativeContext *ctx;
+int thread_num;
+} thread_common_param;
+
+typedef struct thread_param{
+thread_common_param *thread_common_param;
+int thread_index;
+} thread_param;
+
 int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int 
file_size, int operands_num)
 {
 ConvolutionalParams *conv_params;
@@ -88,17 +105,20 @@ int dnn_load_layer_conv2d(Layer *layer, AVIOContext 
*model_file_context, int fil
 return dnn_size;
 }
 
-int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t 
*input_operand_indexes,
- int32_t output_operand_index, const void 
*parameters, NativeContext *ctx)
+static void * dnn_execute_layer_conv2d_thread(void *threadarg)
 {
+//pass parameters
+thread_param *thread_param = (struct thread_param *)threadarg;
+thread_common_param *thread_common_param = 
thread_param->thread_common_param;
+DnnOperand *operands = thread_common_param->operands;
 float *output;
-int32_t input_operand_index = input_operand_indexes[0];
+int32_t input_operand_index = 
thread_common_param->input_operand_indexes[0];
 int number = operands[input_operand_index].dims[0];
 int height = operands[input_operand_index].dims[1];
 int width = operands[input_operand_index].dims[2];
 int channel = operands[input_operand_index].dims[3];
 const float *input = operands[input_operand_index].data;
-const ConvolutionalParams *conv_params = (const ConvolutionalParams 
*)parameters;
+const ConvolutionalParams *conv_params = (const ConvolutionalParams 
*)(thread_common_param->parameters);
 
 int radius = conv_params->kernel_size >> 1;
 int src_linesize = width * conv_params->input_num;
@@ -106,7 +126,11 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 int filter_size = conv_params->kernel_size * filter_linesize;
 int pad_size = (conv_params->padding_method == VALID) ? 
(conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0;
 
-DnnOperand *output_operand = &operands[output_operand_index];
+int thread_stride = (height - pad_size * 2) / 
thread_common_param->thread_num;
+int thread_start = thread_stride * thread_param->thread_index + pad_size;
+int thread_end = (thread_param->thread_index == 
thread_common_param->thread_num - 1) ? (height - pad_size) : (thread_start + 
thread_stride);
+
+DnnOperand *output_operand = 
&operands[thread_common_param->output_operand_index];
 output_operand->dims[0] = number;
 output_operand->dims[1] = height - pad_size * 2;
 output_operand->dims[2] = width - pad_size * 2;
@@ -114,19 +138,21 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
int32_t *input_operand_
 output_operand->data_type = operands[input_operand_index].data_type;
 output_operand->length = calculate_operand_data_length(output_operand);
 if (output_operand->length <= 0) {
-av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n");
-return DNN_ERROR;
+av_log(thread_common_param->ctx, AV_LOG_ERROR, "The output data length 
overflow\n");
+return 

Re: [FFmpeg-devel] [PATCH] avcodec/dxtory: unbreak decoding after 6e1a167c556

2020-09-04 Thread Paul B Mahol
On 9/4/20, James Almer  wrote:
> On 9/4/2020 11:53 AM, Paul B Mahol wrote:
>> On 9/4/20, James Almer  wrote:
>>> On 9/4/2020 11:44 AM, Paul B Mahol wrote:
 On 9/4/20, James Almer  wrote:
> On 9/4/2020 6:29 AM, Paul B Mahol wrote:
>> On 9/4/20, Michael Niedermayer  wrote:
>>> On Fri, Sep 04, 2020 at 12:27:11AM +0200, Paul B Mahol wrote:
 On 9/3/20, Michael Niedermayer  wrote:
> On Thu, Sep 03, 2020 at 07:03:23PM +0200, Paul B Mahol wrote:
>> get_unary() takes at minimum only 1 bit.
>>
>> Signed-off-by: Paul B Mahol 
>> ---
>>
>> As this is important fix, will apply in next 5 minutes.
>> I kindly ask authors of various timeouts changes to kindly
>> test their changes more carefully.
>
> Can you provide test samples and a fate test ?

 Why should I? Nobody uploads my request to wav CUE thing.
>>>
>>> You have access to upload yourself and
>>> post the request to the wrong address, it is
>>> FFmpeg sample uploads 
>>>
>>
>> I never received anything of sort of access to something.
>
> Your ssh pub key is in the server, which means you can connect to it
> and
> upload samples using rsync.
>
> See
> https://ffmpeg.org/fate.html#Uploading-new-samples-to-the-fate-suite

 So I connect via ssh program?
>>>
>>> rsync will connect through ssh if you use the commands listed there.
>>> Just replace the path to wherever you have the samples suite locally.
>>> And please don't skip the dry-run, to ensure you don't make unwanted
>>> changes to the remote repository.
>>
>> If I use first command listed there i get:
>>
>> computer@localhost:~/git/ffmpeg$ rsync -vauL
>> --chmod=Dg+s,Duo+x,ug+rw,o+r,o-w,+X
>> fate-suite.ffmpeg.org:/home/samples/fate-suite/ ../fate-suite/
>> compu...@fate-suite.ffmpeg.org: Permission denied (publickey).
>> rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
>> rsync error: unexplained error (code 255) at io.c(235) [Receiver=3.1.2]
>
> Guess you're not using the key Michael saw was uploaded in the server.
> Do you have more than one for different purposes? Maybe Michael can
> chime in.

I use only one key, another one was made long time ago and never used again.
Perhaps that is source of confusion?
___
ffmpeg-devel mailing list
ffmpeg-devel@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] qsv: question on CONFIG macros

2020-09-04 Thread Rogozhkin, Dmitry V
Hi,

Can someone, please, help to clarify:
1. Where CONFIG_QSV and CONFIG_LIBMFX gets defined (I don't see that in
the grep output - attached below)?
2. What's relationship between these 2? Which one should actually be
used? /from the first glance they are about the same.../

$ fgrep -rsn CONFIG_QSV
doc/examples/Makefile:16:EXAMPLES-
$(CONFIG_QSVDEC_EXAMPLE)+= qsvdec
fftools/ffmpeg.h:621:#if CONFIG_QSV
fftools/ffmpeg_opt.c:3772:#if CONFIG_QSV
libavcodec/Makefile:137:OBJS-$(CONFIG_QSV) += qsv.o
libavcodec/Makefile:138:OBJS-$(CONFIG_QSVDEC)  +=
qsvdec.o
libavcodec/Makefile:139:OBJS-$(CONFIG_QSVENC)  +=
qsvenc.o
libavcodec/Makefile:1184:SKIPHEADERS-$(CONFIG_QSV)  +=
qsv.h qsv_internal.h
libavcodec/Makefile:1185:SKIPHEADERS-$(CONFIG_QSVDEC)   +=
qsvdec.h
libavcodec/Makefile:1186:SKIPHEADERS-$(CONFIG_QSVENC)   +=
qsvenc.h
libavcodec/qsv_api.c:27:#if CONFIG_QSV
libavfilter/Makefile:28:OBJS-$(CONFIG_QSVVPP)+= 
qsvvpp.o
libavfilter/Makefile:525:SKIPHEADERS-
$(CONFIG_QSVVPP) += qsvvpp.h
libavutil/Makefile:182:OBJS-$(CONFIG_QSV)  +=
hwcontext_qsv.o
libavutil/Makefile:198:SKIPHEADERS-$(CONFIG_QSV)  +=
hwcontext_qsv.h
libavutil/hwcontext.c:47:#if CONFIG_QSV

$ fgrep -rsn CONFIG_LIBMFX
fftools/Makefile:13:OBJS-ffmpeg-$(CONFIG_LIBMFX)   +=
fftools/ffmpeg_qsv.o
fftools/ffmpeg_opt.c:138:#if CONFIG_LIBMFX
libavutil/hwcontext_opencl.c:49:#if CONFIG_LIBMFX
libavutil/hwcontext_opencl.c:2249:#if CONFIG_LIBMFX

Regards,
Dmitry.
___
ffmpeg-devel mailing list
ffmpeg-devel@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] MLP Multichannel for DVD-Audio

2020-09-04 Thread fabrice nicol
I've recently been integrating the ffmpeg encoder into the DVD-Audio 
creating software dvda-author (https://dvd-audio.sourceforge.io), 
command-line options --encode and --mlp-files


1. The good news is that multichannel ffmpeg-encoded MLP audio overall 
plays back fine on a DVD-Audio player (using ffmpeg MLP encoder in its 
current git master branch).


2. The bad news is  that for 16-bit audio, for 6 channels 96 kHz only, 
the audio playback is audible, not hissing, but quite out of sync, with 
echo effects.


3. Hints at issues

Using 6/16/96 MLP files generated by a proprietary tool from the same 
wav files, the corresponding DVD-Audio discs play fine.


I made diffs of 6/16/96 MLP files and what comes out is that proprietary 
tools use 2 streams for multichannel, whilst the ffmpeg MLP encoder does 
seem to use just one. This strategy seems to fail for 6/16/96.


In the two bytes after sync major tags (0xF8726FBB): a 6/16/96 
proprietary-encoded mlp file will be encoded 0x00 11, which means the 
bit depth and sample rate are likewise encoded for two streams, whilst 
ffmpeg-encoded mlp files at corresponding offsets will be encoded 0F1F, 
which looks like the second stream bit depth and sample rate are not set.


4. Related issues

The compression rate of proprietary tools is massively higher when using 
channels with high audio redundancy. I built limit cases, in which the 
original PCM multichannel is just one channel identically replicated to 
the other channels. Below is a table of corresponding compression 
outcomes. The extra compression offered by the proprietary tool is 
massive for multichannel, noticeable for stereo 48 kHz and negligible in 
other cases.


channels/bit depth/sample rate kHz  ffmpeg (B) [a]
proprietary (B) [b]
Extra compression = [(b-a)/a]
1_16_1763037274 3041922 0 %
1_16_1923237328 3241950 0 %
1_16_88 1619992 1622424 0 %
1_16_96 1757208 1759616 0 %
2_16_1763073990 3078694 0 %
2_16_1923276318 3280994 0 %
2_16_48 1019046 753728  -26 %
2_24_48 1019046 753728  -26 %
2_24_88 1659590 1588338 -4 %
2_24_96 1799546 1684128 -6 %
3_16_44_Lf_Rf_S 1852486 611528  -67 %
3_16_48_Lf_Rf_C 2618092 765854  -71 %
3_16_88_Lf_Rf_C 4579130 848546  -81 %
3_16_96_Lf_Rf_C 4965218 883742  -82 %
3_24_44_Lf_Rf_S 2415790 1168382 -52 %
3_24_48_Lf_Rf_S 2618092 1614514 -38 %
3_24_88_Lf_Rf_S 4578426 1596642 -65 %
3_24_96_Lf_Rf_S 4962790 1692648 -66 %
4_16_44_Lf_Rf_Ls_Rs 2431314 618832  -75 %
4_16_48_Lf_Rf_Ls_Rs 3436386 774834  -77 %
4_16_88_Lf_Rf_Ls_Rs 6054248 857118  -86 %
4_16_96_Lf_Rf_C_LFE 6564428 893794  -86 %
4_24_44_Lf_Rf_Ls_Rs 3171060 1168038 -63 %
4_24_48_Lf_Rf_Ls_Rs 3436386 1671526 -51 %
4_24_88_Lf_Rf_Ls_Rs 6053300 1604566 -73 %
4_24_96_Lf_Rf_Ls_Rs 6560980 1701338 -74 %
5_16_44_Lf_Rf_LFE_Ls_Rs 3043118 626716  -79 %
5_16_48_Lf_Rf_C_Ls_Rs   4259698 785564  -82 %
5_16_88_Lf_Rf_LFE_Ls_Rs 7572646 866594  -89 %
5_16_96_Lf_Rf_LFE_Ls_Rs 8210736 903800  -89 %
5_24_44_Lf_Rf_Ls_Rs_LFE 3969708 1180472 -70 %
5_24_48_Lf_Rf_Ls_Rs_LFE 4301712 1712056 -60 %
5_24_88_Lf_Rf_Ls_Rs_LFE 7571414 1612840 -79 %
5_24_96_Lf_Rf_LFE_Ls_Rs 8206676 1710184 -79 %
6_16_44_Lf_Rf_C_LFE_Ls_Rs   3592854 633664  -82 %
6_16_48_Lf_Rf_C_LFE_Ls_Rs   5078744 796240  -84 %
6_16_88_Lf_Rf_C_LFE_Ls_Rs   9011680 876884  -90 %
6_16_96_Lf_Rf_C_LFE_Ls_Rs   9770740 914614  -91 %
6_24_44_Lf_Rf_C_LFE_Ls_Rs   4686942 1196392 -74 %
6_24_48_Lf_Rf_C_LFE_Ls_Rs   5078744 795452  -84 %
6_24_88_Lf_Rf_C_LFE_Ls_Rs   9010250 1621502 -82 %
6_24_96_Lf_Rf_C_LFE_Ls_Rs   9765734 1720278 -82 %

My question is: is this caused by the fact that the ffmpeg MLP encoder 
only uses one substream?


Fabrice Nicol



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

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

Re: [FFmpeg-devel] [PATCH] avcodec/dxtory: unbreak decoding after 6e1a167c556

2020-09-04 Thread Michael Niedermayer
On Fri, Sep 04, 2020 at 05:28:06PM +0200, Paul B Mahol wrote:
> On 9/4/20, James Almer  wrote:
> > On 9/4/2020 11:53 AM, Paul B Mahol wrote:
> >> On 9/4/20, James Almer  wrote:
> >>> On 9/4/2020 11:44 AM, Paul B Mahol wrote:
>  On 9/4/20, James Almer  wrote:
> > On 9/4/2020 6:29 AM, Paul B Mahol wrote:
> >> On 9/4/20, Michael Niedermayer  wrote:
> >>> On Fri, Sep 04, 2020 at 12:27:11AM +0200, Paul B Mahol wrote:
>  On 9/3/20, Michael Niedermayer  wrote:
> > On Thu, Sep 03, 2020 at 07:03:23PM +0200, Paul B Mahol wrote:
> >> get_unary() takes at minimum only 1 bit.
> >>
> >> Signed-off-by: Paul B Mahol 
> >> ---
> >>
> >> As this is important fix, will apply in next 5 minutes.
> >> I kindly ask authors of various timeouts changes to kindly
> >> test their changes more carefully.
> >
> > Can you provide test samples and a fate test ?
> 
>  Why should I? Nobody uploads my request to wav CUE thing.
> >>>
> >>> You have access to upload yourself and
> >>> post the request to the wrong address, it is
> >>> FFmpeg sample uploads 
> >>>
> >>
> >> I never received anything of sort of access to something.
> >
> > Your ssh pub key is in the server, which means you can connect to it
> > and
> > upload samples using rsync.
> >
> > See
> > https://ffmpeg.org/fate.html#Uploading-new-samples-to-the-fate-suite
> 
>  So I connect via ssh program?
> >>>
> >>> rsync will connect through ssh if you use the commands listed there.
> >>> Just replace the path to wherever you have the samples suite locally.
> >>> And please don't skip the dry-run, to ensure you don't make unwanted
> >>> changes to the remote repository.
> >>
> >> If I use first command listed there i get:
> >>
> >> computer@localhost:~/git/ffmpeg$ rsync -vauL
> >> --chmod=Dg+s,Duo+x,ug+rw,o+r,o-w,+X
> >> fate-suite.ffmpeg.org:/home/samples/fate-suite/ ../fate-suite/
> >> compu...@fate-suite.ffmpeg.org: Permission denied (publickey).
> >> rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
> >> rsync error: unexplained error (code 255) at io.c(235) [Receiver=3.1.2]
> >
> > Guess you're not using the key Michael saw was uploaded in the server.
> > Do you have more than one for different purposes? Maybe Michael can
> > chime in.
> 
> I use only one key, another one was made long time ago and never used again.
> Perhaps that is source of confusion?

your key on the git and fate samples servers is the same
but your user name is durandal on both not computer

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus


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] lavfi/vsrc_testsrc: switch to activate.

2020-09-04 Thread Paul B Mahol
On 7/7/20, Paul B Mahol  wrote:
> Why this was never applied?
>

Ping.

> On 6/26/20, Nicolas George  wrote:
>> Allow to set the EOF timestamp.
>>
>> Also: doc/filters/testsrc*: specify the rounding of the duration option.
>>
>> The changes in the ref files are right.
>>
>> For filter-fps-down, the graph is testsrc2=r=7:d=3.5,fps=3.
>> 3.5=24.5/7, so the EOF of testsrc2 will have PTS 25/7.
>> 25/7=(10+5/7)/3, so the EOF PTS for fps should be 11/7,
>> and the output should contain a frame at PTS 10.
>>
>> For filter-fps-up, the graph is testsrc2=r=3:d=2,fps=7,
>> for filter-fps-up-round-down and filter-fps-up-round-up
>> it is the same with explicit rounding options.
>> But there is no rounding: testsrc2 produces exactly 6 frames
>> and 2 seconds, fps converts it into exactly 14 frames.
>>
>> The tests should probably be adjusted to restore them to
>> a useful coverage.
>>
>> Signed-off-by: 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".

Re: [FFmpeg-devel] MLP Multichannel for DVD-Audio

2020-09-04 Thread Paul B Mahol
On 9/4/20, fabrice nicol  wrote:
> I've recently been integrating the ffmpeg encoder into the DVD-Audio
> creating software dvda-author (https://dvd-audio.sourceforge.io),
> command-line options --encode and --mlp-files
>
> 1. The good news is that multichannel ffmpeg-encoded MLP audio overall
> plays back fine on a DVD-Audio player (using ffmpeg MLP encoder in its
> current git master branch).
>
> 2. The bad news is  that for 16-bit audio, for 6 channels 96 kHz only,
> the audio playback is audible, not hissing, but quite out of sync, with
> echo effects.
>
> 3. Hints at issues
>
> Using 6/16/96 MLP files generated by a proprietary tool from the same
> wav files, the corresponding DVD-Audio discs play fine.
>
> I made diffs of 6/16/96 MLP files and what comes out is that proprietary
> tools use 2 streams for multichannel, whilst the ffmpeg MLP encoder does
> seem to use just one. This strategy seems to fail for 6/16/96.
>
> In the two bytes after sync major tags (0xF8726FBB): a 6/16/96
> proprietary-encoded mlp file will be encoded 0x00 11, which means the
> bit depth and sample rate are likewise encoded for two streams, whilst
> ffmpeg-encoded mlp files at corresponding offsets will be encoded 0F1F,
> which looks like the second stream bit depth and sample rate are not set.
>
> 4. Related issues
>
> The compression rate of proprietary tools is massively higher when using
> channels with high audio redundancy. I built limit cases, in which the
> original PCM multichannel is just one channel identically replicated to
> the other channels. Below is a table of corresponding compression
> outcomes. The extra compression offered by the proprietary tool is
> massive for multichannel, noticeable for stereo 48 kHz and negligible in
> other cases.
>
> channels/bit depth/sample rate kHzffmpeg (B) [a]
>   proprietary (B) [b]
>   Extra compression = [(b-a)/a]
> 1_16_176  3037274 3041922 0 %
> 1_16_192  3237328 3241950 0 %
> 1_16_88   1619992 1622424 0 %
> 1_16_96   1757208 1759616 0 %
> 2_16_176  3073990 3078694 0 %
> 2_16_192  3276318 3280994 0 %
> 2_16_48   1019046 753728  -26 %
> 2_24_48   1019046 753728  -26 %
> 2_24_88   1659590 1588338 -4 %
> 2_24_96   1799546 1684128 -6 %
> 3_16_44_Lf_Rf_S   1852486 611528  -67 %
> 3_16_48_Lf_Rf_C   2618092 765854  -71 %
> 3_16_88_Lf_Rf_C   4579130 848546  -81 %
> 3_16_96_Lf_Rf_C   4965218 883742  -82 %
> 3_24_44_Lf_Rf_S   2415790 1168382 -52 %
> 3_24_48_Lf_Rf_S   2618092 1614514 -38 %
> 3_24_88_Lf_Rf_S   4578426 1596642 -65 %
> 3_24_96_Lf_Rf_S   4962790 1692648 -66 %
> 4_16_44_Lf_Rf_Ls_Rs   2431314 618832  -75 %
> 4_16_48_Lf_Rf_Ls_Rs   3436386 774834  -77 %
> 4_16_88_Lf_Rf_Ls_Rs   6054248 857118  -86 %
> 4_16_96_Lf_Rf_C_LFE   6564428 893794  -86 %
> 4_24_44_Lf_Rf_Ls_Rs   3171060 1168038 -63 %
> 4_24_48_Lf_Rf_Ls_Rs   3436386 1671526 -51 %
> 4_24_88_Lf_Rf_Ls_Rs   6053300 1604566 -73 %
> 4_24_96_Lf_Rf_Ls_Rs   6560980 1701338 -74 %
> 5_16_44_Lf_Rf_LFE_Ls_Rs   3043118 626716  -79 %
> 5_16_48_Lf_Rf_C_Ls_Rs 4259698 785564  -82 %
> 5_16_88_Lf_Rf_LFE_Ls_Rs   7572646 866594  -89 %
> 5_16_96_Lf_Rf_LFE_Ls_Rs   8210736 903800  -89 %
> 5_24_44_Lf_Rf_Ls_Rs_LFE   3969708 1180472 -70 %
> 5_24_48_Lf_Rf_Ls_Rs_LFE   4301712 1712056 -60 %
> 5_24_88_Lf_Rf_Ls_Rs_LFE   7571414 1612840 -79 %
> 5_24_96_Lf_Rf_LFE_Ls_Rs   8206676 1710184 -79 %
> 6_16_44_Lf_Rf_C_LFE_Ls_Rs 3592854 633664  -82 %
> 6_16_48_Lf_Rf_C_LFE_Ls_Rs 5078744 796240  -84 %
> 6_16_88_Lf_Rf_C_LFE_Ls_Rs 9011680 876884  -90 %
> 6_16_96_Lf_Rf_C_LFE_Ls_Rs 9770740 914614  -91 %
> 6_24_44_Lf_Rf_C_LFE_Ls_Rs 4686942 1196392 -74 %
> 6_24_48_Lf_Rf_C_LFE_Ls_Rs 5078744 795452  -84 %
> 6_24_88_Lf_Rf_C_LFE_Ls_Rs 9010250 1621502 -82 %
> 6_24_96_Lf_Rf_C_LFE_Ls_Rs 9765734 1720278 -82 %
>
> My question is: is this caused by the fact that the ffmpeg MLP encoder
> only uses one substream?
>

Yea, most likely.

> Fabrice Nicol
>
>
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@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..

Re: [FFmpeg-devel] [PATCH] avcodec/dxtory: unbreak decoding after 6e1a167c556

2020-09-04 Thread Michael Niedermayer
On Fri, Sep 04, 2020 at 12:13:53PM +0200, Paul B Mahol wrote:
> On 9/4/20, Michael Niedermayer  wrote:
> > On Fri, Sep 04, 2020 at 12:27:11AM +0200, Paul B Mahol wrote:
> >> On 9/3/20, Michael Niedermayer  wrote:
> >> > On Thu, Sep 03, 2020 at 07:03:23PM +0200, Paul B Mahol wrote:
> >> >> get_unary() takes at minimum only 1 bit.
> >> >>
> >> >> Signed-off-by: Paul B Mahol 
> >> >> ---
> >> >>
> >> >> As this is important fix, will apply in next 5 minutes.
> >> >> I kindly ask authors of various timeouts changes to kindly
> >> >> test their changes more carefully.
> >> >
> >> > Can you provide test samples and a fate test ?
> >>
> >> Why should I? Nobody uploads my request to wav CUE thing.
> >
> > You have access to upload yourself and
> > post the request to the wrong address, it is
> > FFmpeg sample uploads 
> >
> >
> >>
> >> Test samples can be generated by installing trial dxtory capture and
> >> recording
> >> mainly black frames from some simple game. On windows, or under
> >> virtualbox.
> >>
> >> I can upload files, but I value my time and will not do it for nothing
> >> in return.
> >
> > The time someone else needs to setup a windows machiene, trial dxtory
> > capture,
> > some game and so forth is several times that of just providing existing
> > files.
> >
> > So by providing existing files you give others more time to work on
> > other things like reviewing your patches, or uploading your files to
> > fate, or working on anything else, which can then also benefit you ...
> > Is that enough in return ?
> 

> https://drive.google.com/drive/folders/1RV0NSfkAvNA8Ju59SBuzKg7pWosIVLQd?usp=sharing

Thanks

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

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 1/6] avcodec/bink: Fix memleak upon init failure

2020-09-04 Thread Andreas Rheinhardt
The init function first allocates an AVFrame and then some buffers; if
one of the buffers couldn't be allocated, the AVFrame leaks. Solve this
by setting the FF_CODEC_CAP_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/bink.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/bink.c b/libavcodec/bink.c
index f251ab4017..c7ef333bd4 100644
--- a/libavcodec/bink.c
+++ b/libavcodec/bink.c
@@ -1381,10 +1381,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
 ff_hpeldsp_init(&c->hdsp, avctx->flags);
 ff_binkdsp_init(&c->binkdsp);
 
-if ((ret = init_bundles(c)) < 0) {
-free_bundles(c);
+if ((ret = init_bundles(c)) < 0)
 return ret;
-}
 
 if (c->version == 'b') {
 if (!binkb_initialised) {
@@ -1424,4 +1422,5 @@ AVCodec ff_bink_decoder = {
 .decode = decode_frame,
 .flush  = flush,
 .capabilities   = AV_CODEC_CAP_DR1,
+.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 4/6] avcodec/binkaudio: Don't use static storage for context-dependent data

2020-09-04 Thread Andreas Rheinhardt
Move it to the context instead.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/binkaudio.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c
index 012190a955..f17164da91 100644
--- a/libavcodec/binkaudio.c
+++ b/libavcodec/binkaudio.c
@@ -40,8 +40,6 @@
 #include "rdft.h"
 #include "wma_freqs.h"
 
-static float quant_table[96];
-
 #define MAX_CHANNELS 2
 #define BINK_BLOCK_MAX_SIZE (MAX_CHANNELS << 11)
 
@@ -58,6 +56,7 @@ typedef struct BinkAudioContext {
 float root;
 DECLARE_ALIGNED(32, FFTSample, coeffs)[BINK_BLOCK_MAX_SIZE];
 float previous[MAX_CHANNELS][BINK_BLOCK_MAX_SIZE / 16];  ///< coeffs from 
previous audio block
+float quant_table[96];
 AVPacket *pkt;
 union {
 RDFTContext rdft;
@@ -116,7 +115,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 s->root = s->frame_len / (sqrt(s->frame_len) * 32768.0);
 for (i = 0; i < 96; i++) {
 /* constant is result of 0.06639/log10(M_E) */
-quant_table[i] = expf(i * 0.15289164787221953823f) * s->root;
+s->quant_table[i] = expf(i * 0.15289164787221953823f) * s->root;
 }
 
 /* calculate number of bands */
@@ -197,7 +196,7 @@ static int decode_block(BinkAudioContext *s, float **out, 
int use_dct)
 return AVERROR_INVALIDDATA;
 for (i = 0; i < s->num_bands; i++) {
 int value = get_bits(gb, 8);
-quant[i]  = quant_table[FFMIN(value, 95)];
+quant[i]  = s->quant_table[FFMIN(value, 95)];
 }
 
 k = 0;
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 3/6] avcodec/bink: Only keep what is used from HpelDSPContext

2020-09-04 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/bink.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/libavcodec/bink.c b/libavcodec/bink.c
index 9fdfa37395..ec164d0165 100644
--- a/libavcodec/bink.c
+++ b/libavcodec/bink.c
@@ -114,7 +114,7 @@ typedef struct Bundle {
 typedef struct BinkContext {
 AVCodecContext *avctx;
 BlockDSPContext bdsp;
-HpelDSPContext hdsp;
+op_pixels_func put_pixels_tab;
 BinkDSPContext binkdsp;
 AVFrame*last;
 intversion;  ///< internal Bink file version
@@ -927,7 +927,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame 
*frame, GetBitContext *gb,
 if (ref < ref_start || ref + 8*stride > ref_end) {
 av_log(c->avctx, AV_LOG_WARNING, "Reference block is out 
of bounds\n");
 } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
-c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8);
+c->put_pixels_tab(dst, ref, stride, 8);
 } else {
 put_pixels8x8_overlapped(dst, ref, stride);
 }
@@ -943,7 +943,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame 
*frame, GetBitContext *gb,
 if (ref < ref_start || ref + 8 * stride > ref_end) {
 av_log(c->avctx, AV_LOG_WARNING, "Reference block is out 
of bounds\n");
 } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
-c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8);
+c->put_pixels_tab(dst, ref, stride, 8);
 } else {
 put_pixels8x8_overlapped(dst, ref, stride);
 }
@@ -975,7 +975,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame 
*frame, GetBitContext *gb,
 if (ref < ref_start || ref + 8 * stride > ref_end) {
 av_log(c->avctx, AV_LOG_WARNING, "Reference block is out 
of bounds\n");
 } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
-c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8);
+c->put_pixels_tab(dst, ref, stride, 8);
 } else {
 put_pixels8x8_overlapped(dst, ref, stride);
 }
@@ -1010,7 +1010,7 @@ static int bink_put_pixels(BinkContext *c,
xoff, yoff);
 return AVERROR_INVALIDDATA;
 }
-c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8);
+c->put_pixels_tab(dst, ref, stride, 8);
 
 return 0;
 }
@@ -1093,7 +1093,7 @@ static int bink_decode_plane(BinkContext *c, AVFrame 
*frame, GetBitContext *gb,
 }
 switch (blk) {
 case SKIP_BLOCK:
-c->hdsp.put_pixels_tab[1][0](dst, prev, stride, 8);
+c->put_pixels_tab(dst, prev, stride, 8);
 break;
 case SCALED_BLOCK:
 blk = get_value(c, BINK_SRC_SUB_BLOCK_TYPES);
@@ -1345,6 +1345,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 BinkContext * const c = avctx->priv_data;
 static VLC_TYPE table[16 * 128][2];
 static int binkb_initialised = 0;
+HpelDSPContext hdsp;
 int i, ret;
 int flags;
 
@@ -1379,7 +1380,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
 avctx->color_range = c->version == 'k' ? AVCOL_RANGE_JPEG : 
AVCOL_RANGE_MPEG;
 
 ff_blockdsp_init(&c->bdsp, avctx);
-ff_hpeldsp_init(&c->hdsp, avctx->flags);
+ff_hpeldsp_init(&hdsp, avctx->flags);
+c->put_pixels_tab = hdsp.put_pixels_tab[1][0];
 ff_binkdsp_init(&c->binkdsp);
 
 if ((ret = init_bundles(c)) < 0)
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 2/6] avcodec/bink: Combine allocations of arrays into one

2020-09-04 Thread Andreas Rheinhardt
Saves allocations, checks for the allocations as well as frees.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/bink.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavcodec/bink.c b/libavcodec/bink.c
index c7ef333bd4..9fdfa37395 100644
--- a/libavcodec/bink.c
+++ b/libavcodec/bink.c
@@ -178,17 +178,20 @@ static void init_lengths(BinkContext *c, int width, int 
bw)
 static av_cold int init_bundles(BinkContext *c)
 {
 int bw, bh, blocks;
+uint8_t *tmp;
 int i;
 
 bw = (c->avctx->width  + 7) >> 3;
 bh = (c->avctx->height + 7) >> 3;
 blocks = bw * bh;
 
+tmp = av_calloc(blocks, 64 * BINKB_NB_SRC);
+if (!tmp)
+return AVERROR(ENOMEM);
 for (i = 0; i < BINKB_NB_SRC; i++) {
-c->bundle[i].data = av_mallocz(blocks * 64);
-if (!c->bundle[i].data)
-return AVERROR(ENOMEM);
-c->bundle[i].data_end = c->bundle[i].data + blocks * 64;
+c->bundle[i].data = tmp;
+tmp  += blocks * 64;
+c->bundle[i].data_end = tmp;
 }
 
 return 0;
@@ -201,9 +204,7 @@ static av_cold int init_bundles(BinkContext *c)
  */
 static av_cold void free_bundles(BinkContext *c)
 {
-int i;
-for (i = 0; i < BINKB_NB_SRC; i++)
-av_freep(&c->bundle[i].data);
+av_freep(&c->bundle[0].data);
 }
 
 /**
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 6/6] avcodec/binkaudio: Avoid allocation for array

2020-09-04 Thread Andreas Rheinhardt
The array in question can not be too large (only 26 elements), so it can
simply be put on the context.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/binkaudio.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c
index f7e9a37a1b..7b5965ede1 100644
--- a/libavcodec/binkaudio.c
+++ b/libavcodec/binkaudio.c
@@ -52,8 +52,8 @@ typedef struct BinkAudioContext {
 int overlap_len;///< overlap size (samples)
 int block_size;
 int num_bands;
-unsigned int *bands;
 float root;
+unsigned int bands[26];
 float previous[MAX_CHANNELS][BINK_BLOCK_MAX_SIZE / 16];  ///< coeffs from 
previous audio block
 float quant_table[96];
 AVPacket *pkt;
@@ -122,10 +122,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
 if (sample_rate_half <= ff_wma_critical_freqs[s->num_bands - 1])
 break;
 
-s->bands = av_malloc((s->num_bands + 1) * sizeof(*s->bands));
-if (!s->bands)
-return AVERROR(ENOMEM);
-
 /* populate bands data */
 s->bands[0] = 2;
 for (i = 1; i < s->num_bands; i++)
@@ -273,7 +269,6 @@ static int decode_block(BinkAudioContext *s, float **out, 
int use_dct)
 static av_cold int decode_end(AVCodecContext *avctx)
 {
 BinkAudioContext * s = avctx->priv_data;
-av_freep(&s->bands);
 if (CONFIG_BINKAUDIO_RDFT_DECODER && avctx->codec->id == 
AV_CODEC_ID_BINKAUDIO_RDFT)
 ff_rdft_end(&s->trans.rdft);
 else if (CONFIG_BINKAUDIO_DCT_DECODER)
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 5/6] avcodec/binkaudio: Remove unused array from context

2020-09-04 Thread Andreas Rheinhardt
Unused since 7bfd1766d1c18f07b0a2dd042418a874d49ea60d.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/binkaudio.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c
index f17164da91..f7e9a37a1b 100644
--- a/libavcodec/binkaudio.c
+++ b/libavcodec/binkaudio.c
@@ -54,7 +54,6 @@ typedef struct BinkAudioContext {
 int num_bands;
 unsigned int *bands;
 float root;
-DECLARE_ALIGNED(32, FFTSample, coeffs)[BINK_BLOCK_MAX_SIZE];
 float previous[MAX_CHANNELS][BINK_BLOCK_MAX_SIZE / 16];  ///< coeffs from 
previous audio block
 float quant_table[96];
 AVPacket *pkt;
-- 
2.20.1

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

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

Re: [FFmpeg-devel] [PATCH 1/6] avcodec/bink: Fix memleak upon init failure

2020-09-04 Thread Paul B Mahol
On 9/4/20, Andreas Rheinhardt  wrote:
> The init function first allocates an AVFrame and then some buffers; if
> one of the buffers couldn't be allocated, the AVFrame leaks. Solve this
> by setting the FF_CODEC_CAP_INIT_CLEANUP flag.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/bink.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>

LGTM

> diff --git a/libavcodec/bink.c b/libavcodec/bink.c
> index f251ab4017..c7ef333bd4 100644
> --- a/libavcodec/bink.c
> +++ b/libavcodec/bink.c
> @@ -1381,10 +1381,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
>  ff_hpeldsp_init(&c->hdsp, avctx->flags);
>  ff_binkdsp_init(&c->binkdsp);
>
> -if ((ret = init_bundles(c)) < 0) {
> -free_bundles(c);
> +if ((ret = init_bundles(c)) < 0)
>  return ret;
> -}
>
>  if (c->version == 'b') {
>  if (!binkb_initialised) {
> @@ -1424,4 +1422,5 @@ AVCodec ff_bink_decoder = {
>  .decode = decode_frame,
>  .flush  = flush,
>  .capabilities   = AV_CODEC_CAP_DR1,
> +.caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
>  };
> --
> 2.20.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 4/6] avcodec/binkaudio: Don't use static storage for context-dependent data

2020-09-04 Thread Paul B Mahol
On 9/4/20, Andreas Rheinhardt  wrote:
> Move it to the context instead.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/binkaudio.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
>

Wow, nice catch, LGTM.

> diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c
> index 012190a955..f17164da91 100644
> --- a/libavcodec/binkaudio.c
> +++ b/libavcodec/binkaudio.c
> @@ -40,8 +40,6 @@
>  #include "rdft.h"
>  #include "wma_freqs.h"
>
> -static float quant_table[96];
> -
>  #define MAX_CHANNELS 2
>  #define BINK_BLOCK_MAX_SIZE (MAX_CHANNELS << 11)
>
> @@ -58,6 +56,7 @@ typedef struct BinkAudioContext {
>  float root;
>  DECLARE_ALIGNED(32, FFTSample, coeffs)[BINK_BLOCK_MAX_SIZE];
>  float previous[MAX_CHANNELS][BINK_BLOCK_MAX_SIZE / 16];  ///< coeffs
> from previous audio block
> +float quant_table[96];
>  AVPacket *pkt;
>  union {
>  RDFTContext rdft;
> @@ -116,7 +115,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
>  s->root = s->frame_len / (sqrt(s->frame_len) * 32768.0);
>  for (i = 0; i < 96; i++) {
>  /* constant is result of 0.06639/log10(M_E) */
> -quant_table[i] = expf(i * 0.15289164787221953823f) * s->root;
> +s->quant_table[i] = expf(i * 0.15289164787221953823f) * s->root;
>  }
>
>  /* calculate number of bands */
> @@ -197,7 +196,7 @@ static int decode_block(BinkAudioContext *s, float
> **out, int use_dct)
>  return AVERROR_INVALIDDATA;
>  for (i = 0; i < s->num_bands; i++) {
>  int value = get_bits(gb, 8);
> -quant[i]  = quant_table[FFMIN(value, 95)];
> +quant[i]  = s->quant_table[FFMIN(value, 95)];
>  }
>
>  k = 0;
> --
> 2.20.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 5/6] avcodec/binkaudio: Remove unused array from context

2020-09-04 Thread Paul B Mahol
On 9/4/20, Andreas Rheinhardt  wrote:
> Unused since 7bfd1766d1c18f07b0a2dd042418a874d49ea60d.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/binkaudio.c | 1 -
>  1 file changed, 1 deletion(-)
>

LGTM

> diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c
> index f17164da91..f7e9a37a1b 100644
> --- a/libavcodec/binkaudio.c
> +++ b/libavcodec/binkaudio.c
> @@ -54,7 +54,6 @@ typedef struct BinkAudioContext {
>  int num_bands;
>  unsigned int *bands;
>  float root;
> -DECLARE_ALIGNED(32, FFTSample, coeffs)[BINK_BLOCK_MAX_SIZE];
>  float previous[MAX_CHANNELS][BINK_BLOCK_MAX_SIZE / 16];  ///< coeffs
> from previous audio block
>  float quant_table[96];
>  AVPacket *pkt;
> --
> 2.20.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@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 6/6] avcodec/binkaudio: Avoid allocation for array

2020-09-04 Thread Paul B Mahol
On 9/4/20, Andreas Rheinhardt  wrote:
> The array in question can not be too large (only 26 elements), so it can
> simply be put on the context.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/binkaudio.c | 7 +--
>  1 file changed, 1 insertion(+), 6 deletions(-)
>

LGTM

> diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c
> index f7e9a37a1b..7b5965ede1 100644
> --- a/libavcodec/binkaudio.c
> +++ b/libavcodec/binkaudio.c
> @@ -52,8 +52,8 @@ typedef struct BinkAudioContext {
>  int overlap_len;///< overlap size (samples)
>  int block_size;
>  int num_bands;
> -unsigned int *bands;
>  float root;
> +unsigned int bands[26];
>  float previous[MAX_CHANNELS][BINK_BLOCK_MAX_SIZE / 16];  ///< coeffs
> from previous audio block
>  float quant_table[96];
>  AVPacket *pkt;
> @@ -122,10 +122,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
>  if (sample_rate_half <= ff_wma_critical_freqs[s->num_bands - 1])
>  break;
>
> -s->bands = av_malloc((s->num_bands + 1) * sizeof(*s->bands));
> -if (!s->bands)
> -return AVERROR(ENOMEM);
> -
>  /* populate bands data */
>  s->bands[0] = 2;
>  for (i = 1; i < s->num_bands; i++)
> @@ -273,7 +269,6 @@ static int decode_block(BinkAudioContext *s, float
> **out, int use_dct)
>  static av_cold int decode_end(AVCodecContext *avctx)
>  {
>  BinkAudioContext * s = avctx->priv_data;
> -av_freep(&s->bands);
>  if (CONFIG_BINKAUDIO_RDFT_DECODER && avctx->codec->id ==
> AV_CODEC_ID_BINKAUDIO_RDFT)
>  ff_rdft_end(&s->trans.rdft);
>  else if (CONFIG_BINKAUDIO_DCT_DECODER)
> --
> 2.20.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@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/qsvdec: allow qsv decoders to use initialized device

2020-09-04 Thread Rogozhkin, Dmitry V
On Thu, 2020-09-03 at 01:02 +, Rogozhkin, Dmitry V wrote:
> > 
> > (If you do implement it then you can delete all of the ad-hoc
> > treatment in ffmpeg, like has been done for the other hardware
> > codecs.)
> 
> I like deleting code:). Ok, this sounds good. Let's try to understand
> what might be missing in the current implementation since I honestly
> don't see any gaps - it just works.

@Mark. We did internal review and believe that DEVICE_CTX path is
actually ready to be used and just needs to be activated. Can you,
please, let me know how you would like to proceed:
1. We can either consider review and apply the fix first (this patch)
then deal with ad_hoc in non-related patch series
2. Or we can go with the bigger patch series right away and address
both device_ctx + ad_hoc

2nd variant might require longer time to verify and review which would
hold the fix. What are your thoughts?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 3/6] avcodec/bink: Only keep what is used from HpelDSPContext

2020-09-04 Thread Paul B Mahol
On 9/4/20, Andreas Rheinhardt  wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/bink.c | 16 +---
>  1 file changed, 9 insertions(+), 7 deletions(-)
>

LGTM

> diff --git a/libavcodec/bink.c b/libavcodec/bink.c
> index 9fdfa37395..ec164d0165 100644
> --- a/libavcodec/bink.c
> +++ b/libavcodec/bink.c
> @@ -114,7 +114,7 @@ typedef struct Bundle {
>  typedef struct BinkContext {
>  AVCodecContext *avctx;
>  BlockDSPContext bdsp;
> -HpelDSPContext hdsp;
> +op_pixels_func put_pixels_tab;
>  BinkDSPContext binkdsp;
>  AVFrame*last;
>  intversion;  ///< internal Bink file version
> @@ -927,7 +927,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame
> *frame, GetBitContext *gb,
>  if (ref < ref_start || ref + 8*stride > ref_end) {
>  av_log(c->avctx, AV_LOG_WARNING, "Reference block is
> out of bounds\n");
>  } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
> -c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8);
> +c->put_pixels_tab(dst, ref, stride, 8);
>  } else {
>  put_pixels8x8_overlapped(dst, ref, stride);
>  }
> @@ -943,7 +943,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame
> *frame, GetBitContext *gb,
>  if (ref < ref_start || ref + 8 * stride > ref_end) {
>  av_log(c->avctx, AV_LOG_WARNING, "Reference block is
> out of bounds\n");
>  } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
> -c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8);
> +c->put_pixels_tab(dst, ref, stride, 8);
>  } else {
>  put_pixels8x8_overlapped(dst, ref, stride);
>  }
> @@ -975,7 +975,7 @@ static int binkb_decode_plane(BinkContext *c, AVFrame
> *frame, GetBitContext *gb,
>  if (ref < ref_start || ref + 8 * stride > ref_end) {
>  av_log(c->avctx, AV_LOG_WARNING, "Reference block is
> out of bounds\n");
>  } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
> -c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8);
> +c->put_pixels_tab(dst, ref, stride, 8);
>  } else {
>  put_pixels8x8_overlapped(dst, ref, stride);
>  }
> @@ -1010,7 +1010,7 @@ static int bink_put_pixels(BinkContext *c,
> xoff, yoff);
>  return AVERROR_INVALIDDATA;
>  }
> -c->hdsp.put_pixels_tab[1][0](dst, ref, stride, 8);
> +c->put_pixels_tab(dst, ref, stride, 8);
>
>  return 0;
>  }
> @@ -1093,7 +1093,7 @@ static int bink_decode_plane(BinkContext *c, AVFrame
> *frame, GetBitContext *gb,
>  }
>  switch (blk) {
>  case SKIP_BLOCK:
> -c->hdsp.put_pixels_tab[1][0](dst, prev, stride, 8);
> +c->put_pixels_tab(dst, prev, stride, 8);
>  break;
>  case SCALED_BLOCK:
>  blk = get_value(c, BINK_SRC_SUB_BLOCK_TYPES);
> @@ -1345,6 +1345,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
>  BinkContext * const c = avctx->priv_data;
>  static VLC_TYPE table[16 * 128][2];
>  static int binkb_initialised = 0;
> +HpelDSPContext hdsp;
>  int i, ret;
>  int flags;
>
> @@ -1379,7 +1380,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
>  avctx->color_range = c->version == 'k' ? AVCOL_RANGE_JPEG :
> AVCOL_RANGE_MPEG;
>
>  ff_blockdsp_init(&c->bdsp, avctx);
> -ff_hpeldsp_init(&c->hdsp, avctx->flags);
> +ff_hpeldsp_init(&hdsp, avctx->flags);
> +c->put_pixels_tab = hdsp.put_pixels_tab[1][0];
>  ff_binkdsp_init(&c->binkdsp);
>
>  if ((ret = init_bundles(c)) < 0)
> --
> 2.20.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@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/6] avcodec/bink: Combine allocations of arrays into one

2020-09-04 Thread Paul B Mahol
On 9/4/20, Andreas Rheinhardt  wrote:
> Saves allocations, checks for the allocations as well as frees.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/bink.c | 15 ---
>  1 file changed, 8 insertions(+), 7 deletions(-)
>

LGTM

> diff --git a/libavcodec/bink.c b/libavcodec/bink.c
> index c7ef333bd4..9fdfa37395 100644
> --- a/libavcodec/bink.c
> +++ b/libavcodec/bink.c
> @@ -178,17 +178,20 @@ static void init_lengths(BinkContext *c, int width,
> int bw)
>  static av_cold int init_bundles(BinkContext *c)
>  {
>  int bw, bh, blocks;
> +uint8_t *tmp;
>  int i;
>
>  bw = (c->avctx->width  + 7) >> 3;
>  bh = (c->avctx->height + 7) >> 3;
>  blocks = bw * bh;
>
> +tmp = av_calloc(blocks, 64 * BINKB_NB_SRC);
> +if (!tmp)
> +return AVERROR(ENOMEM);
>  for (i = 0; i < BINKB_NB_SRC; i++) {
> -c->bundle[i].data = av_mallocz(blocks * 64);
> -if (!c->bundle[i].data)
> -return AVERROR(ENOMEM);
> -c->bundle[i].data_end = c->bundle[i].data + blocks * 64;
> +c->bundle[i].data = tmp;
> +tmp  += blocks * 64;
> +c->bundle[i].data_end = tmp;
>  }
>
>  return 0;
> @@ -201,9 +204,7 @@ static av_cold int init_bundles(BinkContext *c)
>   */
>  static av_cold void free_bundles(BinkContext *c)
>  {
> -int i;
> -for (i = 0; i < BINKB_NB_SRC; i++)
> -av_freep(&c->bundle[i].data);
> +av_freep(&c->bundle[0].data);
>  }
>
>  /**
> --
> 2.20.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@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] fate: add wav chapters test

2020-09-04 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 tests/fate/lavf-audio.mak   |  5 +
 tests/ref/fate/wav-chapters | 45 +
 2 files changed, 50 insertions(+)
 create mode 100644 tests/ref/fate/wav-chapters

diff --git a/tests/fate/lavf-audio.mak b/tests/fate/lavf-audio.mak
index 0be7a3a050..a0600491a8 100644
--- a/tests/fate/lavf-audio.mak
+++ b/tests/fate/lavf-audio.mak
@@ -36,3 +36,8 @@ fate-lavf-peak_only.wav: CMD = lavf_audio "" "-write_peak 
only"
 
 FATE_AVCONV += $(FATE_LAVF_AUDIO)
 fate-lavf-audio fate-lavf: $(FATE_LAVF_AUDIO)
+
+FATE_WAV_FFPROBE-$(CONFIG_WAV_DEMUXER) += fate-wav-chapters
+fate-wav-chapters: CMD = probechapters $(TARGET_SAMPLES)/wav/200828-005.wav
+
+FATE_SAMPLES_FFPROBE += $(FATE_WAV_FFPROBE-yes)
diff --git a/tests/ref/fate/wav-chapters b/tests/ref/fate/wav-chapters
new file mode 100644
index 00..b47c560786
--- /dev/null
+++ b/tests/ref/fate/wav-chapters
@@ -0,0 +1,45 @@
+[CHAPTER]
+id=1
+time_base=1/48000
+start=148992
+start_time=3.104000
+end=226560
+end_time=4.72
+TAG:title=01
+[/CHAPTER]
+[CHAPTER]
+id=2
+time_base=1/48000
+start=226560
+start_time=4.72
+end=301728
+end_time=6.286000
+TAG:title=02
+[/CHAPTER]
+[CHAPTER]
+id=3
+time_base=1/48000
+start=301728
+start_time=6.286000
+end=314016
+end_time=6.542000
+TAG:title=03
+[/CHAPTER]
+[CHAPTER]
+id=4
+time_base=1/48000
+start=314016
+start_time=6.542000
+end=396528
+end_time=8.261000
+TAG:title=04
+[/CHAPTER]
+[CHAPTER]
+id=5
+time_base=1/48000
+start=396528
+start_time=8.261000
+end=614464
+end_time=12.801333
+TAG:title=05
+[/CHAPTER]
-- 
2.17.1

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

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

Re: [FFmpeg-devel] [PATCH 1/3] avcodec/dxtory: unbreak decoding after 6e1a167c556

2020-09-04 Thread Michael Niedermayer
On Fri, Sep 04, 2020 at 12:17:04PM +0200, Paul B Mahol wrote:
> get_unary() takes at minimum only 1 bit.
> 
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/dxtory.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)

should be ok

thanks

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

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato


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] avcodec/mobiclip: Fix mixed declarations and code

2020-09-04 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mobiclip.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c
index e2bda76978..d147eddbae 100644
--- a/libavcodec/mobiclip.c
+++ b/libavcodec/mobiclip.c
@@ -1333,13 +1333,15 @@ static int mobiclip_decode(AVCodecContext *avctx, void 
*data,
 setup_qtables(avctx, s->quantizer + get_se_golomb(gb));
 for (int y = 0; y < avctx->height; y += 16) {
 for (int x = 0; x < avctx->width; x += 16) {
+int idx;
+
 motion[0].x = mid_pred(motion[x / 16 + 1].x, motion[x / 16 + 
2].x, motion[x / 16 + 3].x);
 motion[0].y = mid_pred(motion[x / 16 + 1].y, motion[x / 16 + 
2].y, motion[x / 16 + 3].y);
 motion[x / 16 + 2].x = 0;
 motion[x / 16 + 2].y = 0;
 
-int idx = get_vlc2(gb, s->mv_vlc[s->moflex][0].table,
-   s->mv_vlc[s->moflex][0].bits, 1);
+idx = get_vlc2(gb, s->mv_vlc[s->moflex][0].table,
+   s->mv_vlc[s->moflex][0].bits, 1);
 if (idx < 0)
 return AVERROR_INVALIDDATA;
 
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 2/2] avcodec/photocd: Remove set-but-unused variables

2020-09-04 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/photocd.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/photocd.c b/libavcodec/photocd.c
index 6f8426b5d2..057c9d33d4 100644
--- a/libavcodec/photocd.c
+++ b/libavcodec/photocd.c
@@ -227,9 +227,9 @@ static av_noinline int decode_huff(AVCodecContext *avctx, 
AVFrame *frame,
 PhotoCDContext *s = avctx->priv_data;
 GetBitContext g;
 GetByteContext *gb = &s->gb;
-int ret, y = 0, type, height, y2;
+int ret, y = 0, type, height;
 int start = s->streampos;
-unsigned shiftreg, bit;
+unsigned shiftreg;
 const int scaling = target_res - curr_res;
 const uint8_t type2idx[] = { 0, 0xff, 1, 2 };
 
@@ -239,13 +239,11 @@ static av_noinline int decode_huff(AVCodecContext *avctx, 
AVFrame *frame,
 return ret;
 
 height = img_info[curr_res].height;
-y2 = avctx->height >> scaling;
 
 while (y < height) {
 uint8_t *data;
 int x2, idx;
 
-bit = 0;
 for (; get_bits_left(&g) > 0;) {
 if ((show_bits(&g, 24) & 0xfff000) == 0xfff000)
 break;
-- 
2.20.1

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

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

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/mobiclip: Fix mixed declarations and code

2020-09-04 Thread Paul B Mahol
On 9/4/20, Andreas Rheinhardt  wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/mobiclip.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
>

ok

> diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c
> index e2bda76978..d147eddbae 100644
> --- a/libavcodec/mobiclip.c
> +++ b/libavcodec/mobiclip.c
> @@ -1333,13 +1333,15 @@ static int mobiclip_decode(AVCodecContext *avctx,
> void *data,
>  setup_qtables(avctx, s->quantizer + get_se_golomb(gb));
>  for (int y = 0; y < avctx->height; y += 16) {
>  for (int x = 0; x < avctx->width; x += 16) {
> +int idx;
> +
>  motion[0].x = mid_pred(motion[x / 16 + 1].x, motion[x / 16
> + 2].x, motion[x / 16 + 3].x);
>  motion[0].y = mid_pred(motion[x / 16 + 1].y, motion[x / 16
> + 2].y, motion[x / 16 + 3].y);
>  motion[x / 16 + 2].x = 0;
>  motion[x / 16 + 2].y = 0;
>
> -int idx = get_vlc2(gb, s->mv_vlc[s->moflex][0].table,
> -   s->mv_vlc[s->moflex][0].bits, 1);
> +idx = get_vlc2(gb, s->mv_vlc[s->moflex][0].table,
> +   s->mv_vlc[s->moflex][0].bits, 1);
>  if (idx < 0)
>  return AVERROR_INVALIDDATA;
>
> --
> 2.20.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@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] avcodec/photocd: Remove set-but-unused variables

2020-09-04 Thread Paul B Mahol
On 9/4/20, Andreas Rheinhardt  wrote:
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/photocd.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
>

ok

> diff --git a/libavcodec/photocd.c b/libavcodec/photocd.c
> index 6f8426b5d2..057c9d33d4 100644
> --- a/libavcodec/photocd.c
> +++ b/libavcodec/photocd.c
> @@ -227,9 +227,9 @@ static av_noinline int decode_huff(AVCodecContext
> *avctx, AVFrame *frame,
>  PhotoCDContext *s = avctx->priv_data;
>  GetBitContext g;
>  GetByteContext *gb = &s->gb;
> -int ret, y = 0, type, height, y2;
> +int ret, y = 0, type, height;
>  int start = s->streampos;
> -unsigned shiftreg, bit;
> +unsigned shiftreg;
>  const int scaling = target_res - curr_res;
>  const uint8_t type2idx[] = { 0, 0xff, 1, 2 };
>
> @@ -239,13 +239,11 @@ static av_noinline int decode_huff(AVCodecContext
> *avctx, AVFrame *frame,
>  return ret;
>
>  height = img_info[curr_res].height;
> -y2 = avctx->height >> scaling;
>
>  while (y < height) {
>  uint8_t *data;
>  int x2, idx;
>
> -bit = 0;
>  for (; get_bits_left(&g) > 0;) {
>  if ((show_bits(&g, 24) & 0xfff000) == 0xfff000)
>  break;
> --
> 2.20.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@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/3] avcodec/dxtory: unbreak decoding after 6e1a167c556

2020-09-04 Thread Paul B Mahol
On 9/4/20, Michael Niedermayer  wrote:
> On Fri, Sep 04, 2020 at 12:17:04PM +0200, Paul B Mahol wrote:
>> get_unary() takes at minimum only 1 bit.
>>
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libavcodec/dxtory.c | 10 +-
>>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> should be ok

There is more correct approach in latest version of set in 2nd patch.
(It calculates bits more completely for 420 and 410 case)
I probably should merge 1st and 2nd patch of that set. What do you think?

>
> thanks
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> When the tyrant has disposed of foreign enemies by conquest or treaty, and
> there is nothing more to fear from them, then he is always stirring up
> some war or other, in order that the people may require a leader. -- Plato
>
___
ffmpeg-devel mailing list
ffmpeg-devel@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/dashdec: only limit DASH manifest size according to AVBprint limits

2020-09-04 Thread Jan Ekström
On Thu, Sep 3, 2020 at 8:29 PM Jan Ekström  wrote:
>
> Currently the API is internally limited to unsigned integers, so if we
> limit the file size as well as the amount to read to UINT_MAX - 1, we
> do not require additional limiting to be performed on the values.
>
> This change is based on the fact that initially the 8*1024 value added
> in 96d70694aea64616c68db8be306c159c73fb3980 was only for the case where
> the file size was not known. It was not a maximum file size limit.
>
> In 29121188983932f79aef8501652630d322a9974c this was reworked to be
> a maximum manifest file size limit, while its commit message appears
> to only note that it added support for larger manifest file sizes.
>
> This should enable various unfortunately large MPEG-DASH manifests,
> such as Youtube's multi-megabyte live stream archives to load up
> as well as bring back the original intent of the logic.
> ---

Got some reviews regarding the commit message on IRC, and have updated
it to the following:

avformat/dashdec: drop arbitrary DASH manifest size limit

Currently the utilized AVBPrint API is internally limited to unsigned
integers, so if we limit the file size as well as the amount to read
to UINT_MAX - 1, we do not require additional limiting to be performed
on the values.

This change is based on the fact that initially the 8*1024 value added
in 96d70694aea64616c68db8be306c159c73fb3980 was only for the case where
the file size was not known. It was not a maximum file size limit.

In 29121188983932f79aef8501652630d322a9974c this was reworked to be
a maximum manifest file size limit, while its commit message appears
to only note that it added support for larger manifest file sizes.

This should enable various unfortunately large MPEG-DASH manifests,
such as Youtube's multi-megabyte live stream archives to load up
as well as bring back the original intent of the logic.
---

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

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

Re: [FFmpeg-devel] [PATCH 3/9] avcodec/videotoolbox: h264 decoder on iOS is unable to decode interlaced video

2020-09-04 Thread Aman Gupta
On Tue, Sep 26, 2017 at 4:20 AM Carl Eugen Hoyos  wrote:

> 2017-09-26 2:36 GMT+02:00 Aman Gupta :
>
>
>
> > +   case kCMVideoCodecType_H264 : {
>
> > +  H264Context *h = avctx->priv_data;
>
> > +  if (TARGET_OS_IPHONE && h->ps.sps->frame_mbs_only_flag == 0) {
>
>
>
> I believe that for DVB 1080 transmissions the flag is
>
> never set even for progressive frames, so this has


Do you know where I could find a sample of such a transmission?

Aman


>
> to be conditional depending on a new user option.
>
> Imo, the default should be not to abort but others may
>
> disagree.
>
>
>
> Carl Eugen
>
> ___
>
> ffmpeg-devel mailing list
>
> ffmpeg-devel@ffmpeg.org
>
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@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/3] avcodec/dxtory: unbreak decoding after 6e1a167c556

2020-09-04 Thread Michael Niedermayer
On Fri, Sep 04, 2020 at 10:03:26PM +0200, Paul B Mahol wrote:
> On 9/4/20, Michael Niedermayer  wrote:
> > On Fri, Sep 04, 2020 at 12:17:04PM +0200, Paul B Mahol wrote:
> >> get_unary() takes at minimum only 1 bit.
> >>
> >> Signed-off-by: Paul B Mahol 
> >> ---
> >>  libavcodec/dxtory.c | 10 +-
> >>  1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > should be ok
> 
> There is more correct approach in latest version of set in 2nd patch.
> (It calculates bits more completely for 420 and 410 case)
> I probably should merge 1st and 2nd patch of that set. What do you think?

do what you prefer

thx

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

If you drop bombs on a foreign country and kill a hundred thousand
innocent people, expect your government to call the consequence
"unprovoked inhuman terrorist attacks" and use it to justify dropping
more bombs and killing more people. The technology changed, the idea is old.


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 v4 2/2] dnn_backend_native_layer_conv2d.c:Add mutithread function

2020-09-04 Thread Steven Liu
 于2020年9月4日周五 下午11:09写道:
>
> From: Xu Jun 
>
> Use pthread to multithread dnn_execute_layer_conv2d.
> Can be tested with command "./ffmpeg_g -i input.png -vf \
> format=yuvj420p,dnn_processing=dnn_backend=native:model= \
> espcn.model:input=x:output=y:options=conv2d_threads=23 \
>  -y sr_native.jpg -benchmark"
>
> before patch: utime=11.238s stime=0.005s rtime=11.248s
> after patch:  utime=20.817s stime=0.047s rtime=1.051s
> on my 3900X 12c24t @4.2GHz
>
> About the increase of utime, it's because that CPU HyperThreading
> technology makes logical cores twice of physical cores while cpu's
> counting performance improves less than double. And utime sums
> all cpu's logical cores' runtime. As a result, using threads num
> near cpu's logical core's number will double utime, while reduce
> rtime less than half for HyperThreading CPUs.
>
> Signed-off-by: Xu Jun 
> ---
> v2: add check for HAVE_PTHREAD_CANCEL and modify FATE test
> dnn-layer-conv2d-test.c
> v4: use extern to call dnn_native_class in dnn-layer-conv2d-test.c
>
>  .../dnn/dnn_backend_native_layer_conv2d.c | 107 --
>  tests/dnn/dnn-layer-conv2d-test.c |  14 ++-
>  2 files changed, 108 insertions(+), 13 deletions(-)
>
> diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c 
> b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> index d079795bf8..4068a13ab4 100644
> --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> @@ -19,10 +19,27 @@
>   */
>
>  #include "libavutil/avassert.h"
> +#include "libavutil/thread.h"
> +#include "libavutil/cpu.h"
>  #include "dnn_backend_native_layer_conv2d.h"
>
>  #define CLAMP_TO_EDGE(x, w) ((x) < 0 ? 0 : ((x) >= (w) ? (w - 1) : (x)))
>
> +//struct to pass parameters
> +typedef struct thread_common_param{
> +DnnOperand *operands;
> +const int32_t *input_operand_indexes;
> +int32_t output_operand_index;
> +const void *parameters;
> +NativeContext *ctx;
> +int thread_num;
> +} thread_common_param;
> +
> +typedef struct thread_param{
> +thread_common_param *thread_common_param;
> +int thread_index;
> +} thread_param;
> +
>  int dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int 
> file_size, int operands_num)
>  {
>  ConvolutionalParams *conv_params;
> @@ -88,17 +105,20 @@ int dnn_load_layer_conv2d(Layer *layer, AVIOContext 
> *model_file_context, int fil
>  return dnn_size;
>  }
>
> -int dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t 
> *input_operand_indexes,
> - int32_t output_operand_index, const void 
> *parameters, NativeContext *ctx)
> +static void * dnn_execute_layer_conv2d_thread(void *threadarg)
>  {
> +//pass parameters
> +thread_param *thread_param = (struct thread_param *)threadarg;
> +thread_common_param *thread_common_param = 
> thread_param->thread_common_param;
> +DnnOperand *operands = thread_common_param->operands;
>  float *output;
> -int32_t input_operand_index = input_operand_indexes[0];
> +int32_t input_operand_index = 
> thread_common_param->input_operand_indexes[0];
>  int number = operands[input_operand_index].dims[0];
>  int height = operands[input_operand_index].dims[1];
>  int width = operands[input_operand_index].dims[2];
>  int channel = operands[input_operand_index].dims[3];
>  const float *input = operands[input_operand_index].data;
> -const ConvolutionalParams *conv_params = (const ConvolutionalParams 
> *)parameters;
> +const ConvolutionalParams *conv_params = (const ConvolutionalParams 
> *)(thread_common_param->parameters);
>
>  int radius = conv_params->kernel_size >> 1;
>  int src_linesize = width * conv_params->input_num;
> @@ -106,7 +126,11 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, const 
> int32_t *input_operand_
>  int filter_size = conv_params->kernel_size * filter_linesize;
>  int pad_size = (conv_params->padding_method == VALID) ? 
> (conv_params->kernel_size - 1) / 2 * conv_params->dilation : 0;
>
> -DnnOperand *output_operand = &operands[output_operand_index];
> +int thread_stride = (height - pad_size * 2) / 
> thread_common_param->thread_num;
> +int thread_start = thread_stride * thread_param->thread_index + pad_size;
> +int thread_end = (thread_param->thread_index == 
> thread_common_param->thread_num - 1) ? (height - pad_size) : (thread_start + 
> thread_stride);
> +
> +DnnOperand *output_operand = 
> &operands[thread_common_param->output_operand_index];
>  output_operand->dims[0] = number;
>  output_operand->dims[1] = height - pad_size * 2;
>  output_operand->dims[2] = width - pad_size * 2;
> @@ -114,19 +138,21 @@ int dnn_execute_layer_conv2d(DnnOperand *operands, 
> const int32_t *input_operand_
>  output_operand->data_type = operands[input_operand_index].data_type;
>  output_operand->length = calculate_operand_data_length(output_operand);
> 

Re: [FFmpeg-devel] [PATCH] avformat/dashdec: only limit DASH manifest size according to AVBprint limits

2020-09-04 Thread Steven Liu
Jan Ekström  于2020年9月4日周五 上午2:33写道:
>
> Currently the API is internally limited to unsigned integers, so if we
> limit the file size as well as the amount to read to UINT_MAX - 1, we
> do not require additional limiting to be performed on the values.
>
> This change is based on the fact that initially the 8*1024 value added
> in 96d70694aea64616c68db8be306c159c73fb3980 was only for the case where
> the file size was not known. It was not a maximum file size limit.
>
> In 29121188983932f79aef8501652630d322a9974c this was reworked to be
> a maximum manifest file size limit, while its commit message appears
> to only note that it added support for larger manifest file sizes.
>
> This should enable various unfortunately large MPEG-DASH manifests,
> such as Youtube's multi-megabyte live stream archives to load up
> as well as bring back the original intent of the logic.
> ---
>  libavformat/dashdec.c | 10 ++
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index c5a5ff607b..1e9985f32c 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -29,7 +29,7 @@
>  #include "dash.h"
>
>  #define INITIAL_BUFFER_SIZE 32768
> -#define MAX_MANIFEST_SIZE 50 * 1024
> +#define MAX_BPRINT_READ_SIZE (UINT_MAX - 1)
>  #define DEFAULT_MANIFEST_SIZE 8 * 1024
>
>  struct fragment {
> @@ -1256,14 +1256,16 @@ static int parse_manifest(AVFormatContext *s, const 
> char *url, AVIOContext *in)
>  }
>
>  filesize = avio_size(in);
> -if (filesize > MAX_MANIFEST_SIZE) {
> +filesize = filesize > 0 ? filesize : DEFAULT_MANIFEST_SIZE;
> +
> +if (filesize > MAX_BPRINT_READ_SIZE) {
>  av_log(s, AV_LOG_ERROR, "Manifest too large: %"PRId64"\n", filesize);
>  return AVERROR_INVALIDDATA;
>  }
>
> -av_bprint_init(&buf, (filesize > 0) ? filesize + 1 : 
> DEFAULT_MANIFEST_SIZE, AV_BPRINT_SIZE_UNLIMITED);
> +av_bprint_init(&buf, filesize + 1, AV_BPRINT_SIZE_UNLIMITED);
>
> -if ((ret = avio_read_to_bprint(in, &buf, MAX_MANIFEST_SIZE)) < 0 ||
> +if ((ret = avio_read_to_bprint(in, &buf, MAX_BPRINT_READ_SIZE)) < 0 ||
>  !avio_feof(in) ||
>  (filesize = buf.len) == 0) {
>  av_log(s, AV_LOG_ERROR, "Unable to read to manifest '%s'\n", url);
> --
> 2.26.2
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Not proficient in English, but code looks ok. :D


Thanks jeeb


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 1/8] avcodec/jpeglsenc: Don't use put bits API for byte-aligned writes

2020-09-04 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
Is it actually guaranteed that the allocated packet size is
sufficient? If it is, one could use unchecked writes throughout; if it
isn't, should I add a check to properly error out in case the buffer is
too small? (And what would the return value be in this case?)

 libavcodec/jpeglsenc.c   | 80 +---
 libavcodec/mjpegenc.h|  6 ---
 libavcodec/mjpegenc_common.c |  6 +++
 3 files changed, 52 insertions(+), 40 deletions(-)

diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index 5ecd430db7..feea6fdde7 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -26,6 +26,7 @@
  */
 
 #include "avcodec.h"
+#include "bytestream.h"
 #include "get_bits.h"
 #include "put_bits.h"
 #include "golomb.h"
@@ -41,6 +42,18 @@ typedef struct JPEGLSContext {
 int pred;
 } JPEGLSContext;
 
+static inline void put_markeru(PutByteContext *pb, enum JpegMarker code)
+{
+bytestream2_put_byteu(pb, 0xff);
+bytestream2_put_byteu(pb, code);
+}
+
+static inline void put_marker(PutByteContext *pb, enum JpegMarker code)
+{
+bytestream2_put_byte(pb, 0xff);
+bytestream2_put_byte(pb, code);
+}
+
 /**
  * Encode error from regular symbol
  */
@@ -230,7 +243,7 @@ static inline void ls_encode_line(JLSState *state, 
PutBitContext *pb,
 }
 }
 
-static void ls_store_lse(JLSState *state, PutBitContext *pb)
+static void ls_store_lse(JLSState *state, PutByteContext *pb)
 {
 /* Test if we have default params and don't need to store LSE */
 JLSState state2 = { 0 };
@@ -243,14 +256,14 @@ static void ls_store_lse(JLSState *state, PutBitContext 
*pb)
 state->reset == state2.reset)
 return;
 /* store LSE type 1 */
-put_marker(pb, LSE);
-put_bits(pb, 16, 13);
-put_bits(pb, 8, 1);
-put_bits(pb, 16, state->maxval);
-put_bits(pb, 16, state->T1);
-put_bits(pb, 16, state->T2);
-put_bits(pb, 16, state->T3);
-put_bits(pb, 16, state->reset);
+put_markeru(pb, LSE);
+bytestream2_put_be16u(pb, 13);
+bytestream2_put_byteu(pb, 1);
+bytestream2_put_be16u(pb, state->maxval);
+bytestream2_put_be16u(pb, state->T1);
+bytestream2_put_be16u(pb, state->T2);
+bytestream2_put_be16u(pb, state->T3);
+bytestream2_put_be16u(pb, state->reset);
 }
 
 static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
@@ -258,7 +271,8 @@ static int encode_picture_ls(AVCodecContext *avctx, 
AVPacket *pkt,
 {
 JPEGLSContext *ctx = avctx->priv_data;
 const AVFrame *const p = pict;
-PutBitContext pb, pb2;
+PutByteContext pb;
+PutBitContext pb2;
 GetBitContext gb;
 uint8_t *buf2 = NULL;
 uint8_t *zero = NULL;
@@ -289,33 +303,33 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (!buf2)
 goto memfail;
 
-init_put_bits(&pb, pkt->data, pkt->size);
+bytestream2_init_writer(&pb, pkt->data, pkt->size);
 init_put_bits(&pb2, buf2, pkt->size);
 
 /* write our own JPEG header, can't use mjpeg_picture_header */
-put_marker(&pb, SOI);
-put_marker(&pb, SOF48);
-put_bits(&pb, 16, 8 + comps * 3); // header size depends on components
-put_bits(&pb, 8, (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8);  // bpp
-put_bits(&pb, 16, avctx->height);
-put_bits(&pb, 16, avctx->width);
-put_bits(&pb, 8, comps);  // components
+put_markeru(&pb, SOI);
+put_markeru(&pb, SOF48);
+bytestream2_put_be16u(&pb, 8 + comps * 3); // header size depends on 
components
+bytestream2_put_byteu(&pb, (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 
8);  // bpp
+bytestream2_put_be16u(&pb, avctx->height);
+bytestream2_put_be16u(&pb, avctx->width);
+bytestream2_put_byteu(&pb, comps);  // components
 for (i = 1; i <= comps; i++) {
-put_bits(&pb, 8, i); // component ID
-put_bits(&pb, 8, 0x11);  // subsampling: none
-put_bits(&pb, 8, 0); // Tiq, used by JPEG-LS ext
+bytestream2_put_byteu(&pb, i); // component ID
+bytestream2_put_byteu(&pb, 0x11);  // subsampling: none
+bytestream2_put_byteu(&pb, 0); // Tiq, used by JPEG-LS ext
 }
 
-put_marker(&pb, SOS);
-put_bits(&pb, 16, 6 + comps * 2);
-put_bits(&pb, 8, comps);
+put_markeru(&pb, SOS);
+bytestream2_put_be16u(&pb, 6 + comps * 2);
+bytestream2_put_byteu(&pb, comps);
 for (i = 1; i <= comps; i++) {
-put_bits(&pb, 8, i);   // component ID
-put_bits(&pb, 8, 0);   // mapping index: none
+bytestream2_put_byteu(&pb, i);   // component ID
+bytestream2_put_byteu(&pb, 0);   // mapping index: none
 }
-put_bits(&pb, 8, ctx->pred);
-put_bits(&pb, 8, (comps > 1) ? 1 : 0);  // interleaving: 0 - plane, 1 - 
line
-put_bits(&pb, 8, 0);  // point transform: none
+bytestream2_put_byteu(&pb, ctx->pred);
+bytestream2_put_byteu(&pb, (comps > 1) ? 1 : 0);  // interleaving: 0 - 
plane, 1 - line
+bytestream2_put_byteu(&pb, 0);  // 

[FFmpeg-devel] [PATCH 4/8] avcodec/jpeglsenc: Only use one line at a time as spare buffer

2020-09-04 Thread Andreas Rheinhardt
ls_encode_line() encodes one line of input from left to right and
to do so it uses the values of the left, upper left, upper and upper
right pixels for prediction (i.e. the values that a decoder gets when it
decodes the already encoded part of the picture). So a simple algorithm
would use a buffer that can hold two lines, namely the current line as
well as the last line and swap the pointers to the two lines after
decoding each line. Yet if one is currently encoding the pixel with
index k of a line, one doesn't need any pixel with index < k - 1 of the
last line at all and similarly, no pixels with index >= k have been
written yet. So the overlap in the effective lifetime is pretty limited
and since the last patch (which stopped reading the upper left pixel and
instead reused the value of the upper pixel from the last iteration of
the loop) it is inexistent. Ergo one only needs one line and doesn't
need to swap the lines out.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/jpeglsenc.c | 52 --
 1 file changed, 25 insertions(+), 27 deletions(-)

diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index b9c04e979c..d05fe4564b 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -141,19 +141,19 @@ static inline void ls_encode_run(JLSState *state, 
PutBitContext *pb, int run,
  * Encode one line of image
  */
 static inline void ls_encode_line(JLSState *state, PutBitContext *pb,
-  void *last, void *cur, const void *in, int 
last2, int w,
+  void *tmp, const void *in, int last2, int w,
   int stride, int comp, int bits)
 {
 int x = 0;
-int Ra = R(last, 0), Rb, Rc = last2, Rd;
+int Ra = R(tmp, 0), Rb, Rc = last2, Rd;
 int D0, D1, D2;
 
 while (x < w) {
 int err, pred, sign;
 
 /* compute gradients */
-Rb = R(last, x);
-Rd = (x >= w - stride) ? R(last, x) : R(last, x + stride);
+Rb = R(tmp, x);
+Rd = (x >= w - stride) ? R(tmp, x) : R(tmp, x + stride);
 D0 = Rd - Rb;
 D1 = Rb - Rc;
 D2 = Rc - Ra;
@@ -168,13 +168,13 @@ static inline void ls_encode_line(JLSState *state, 
PutBitContext *pb,
 RUNval = Ra;
 while (x < w && (FFABS(R(in, x) - RUNval) <= state->near)) {
 run++;
-W(cur, x, Ra);
+W(tmp, x, Ra);
 x += stride;
 }
 ls_encode_run(state, pb, run, comp, x < w);
 if (x >= w)
 return;
-Rb = R(last, x);
+Rb = R(tmp, x);
 RItype = FFABS(Ra - Rb) <= state->near;
 pred   = RItype ? Ra : Rb;
 err= R(in, x) - pred;
@@ -194,7 +194,7 @@ static inline void ls_encode_line(JLSState *state, 
PutBitContext *pb,
 Ra = av_clip(pred - err * state->twonear, 0, 
state->maxval);
 } else
 Ra = R(in, x);
-W(cur, x, Ra);
+W(tmp, x, Ra);
 
 if (err < 0)
 err += state->range;
@@ -236,7 +236,7 @@ static inline void ls_encode_line(JLSState *state, 
PutBitContext *pb,
 Ra = av_clip(pred - err * state->twonear, 0, 
state->maxval);
 } else
 Ra = R(in, x);
-W(cur, x, Ra);
+W(tmp, x, Ra);
 
 ls_encode_regular(state, pb, context, err);
 }
@@ -277,9 +277,8 @@ static int encode_picture_ls(AVCodecContext *avctx, 
AVPacket *pkt,
 PutBitContext pb2;
 GetBitContext gb;
 uint8_t *buf2 = NULL;
-uint8_t *zero = NULL;
 const uint8_t *in;
-uint8_t *last, *cur;
+uint8_t *last = NULL;
 JLSState *state = NULL;
 int i, size, ret;
 int comps;
@@ -345,28 +344,27 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 ls_store_lse(state, &pb);
 
-zero = last = av_calloc(FFABS(p->linesize[0]), 2);
-if (!zero)
+last = av_mallocz(FFABS(p->linesize[0]));
+if (!last)
 goto memfail;
-cur = zero + FFABS(p->linesize[0]);
 
 in = p->data[0];
 if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
 int t = 0;
 
 for (i = 0; i < avctx->height; i++) {
-ls_encode_line(state, &pb2, last, cur, in, t, avctx->width, 1, 0, 
8);
-t= last[0];
-FFSWAP(void *, last, cur);
+int last0 = last[0];
+ls_encode_line(state, &pb2, last, in, t, avctx->width, 1, 0, 8);
+t   = last0;
 in += p->linesize[0];
 }
 } else if (avctx->pix_fmt == AV_PIX_FMT_GRAY16) {
 int t = 0;
 
 for (i = 0; i < avctx->height; i++) {
-ls_encode_line(state, &pb2, last, cur, in, t, avctx->width, 1, 0, 
16);
-t= *((uint16_t *)last);
-FFSWAP(void *, last, cur);
+int last0 = *((uint16_t *)last);
+ls_encode_line(state, &pb2, last, in, t, av

[FFmpeg-devel] [PATCH 3/8] avcodec/jpeglsenc: Move check out of loop

2020-09-04 Thread Andreas Rheinhardt
ls_encode_line() encodes a line of input, going from left to right. In
order to calculate a predicted value it uses the left and upper-left
value of the output picture (that is, it uses how a decoder would see
the already encoded part of the picture), unless this is the very first
pixel of this line in which case one uses the first pixel of the last
(upper) line and the line before the last line. Therefore the loop
contained a check for whether this is the beginning of a new line. This
commit moves said check out of the loop by initializing these values
before the loop and by updating these values at the end of the loop
body; already read/calculated values are reused for this (the prediction
also needs the value of the upper pixel and this can be reused for the
upper left value of the next iteration of the loop).

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/jpeglsenc.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index 67897ce8ae..b9c04e979c 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -145,16 +145,14 @@ static inline void ls_encode_line(JLSState *state, 
PutBitContext *pb,
   int stride, int comp, int bits)
 {
 int x = 0;
-int Ra, Rb, Rc, Rd;
+int Ra = R(last, 0), Rb, Rc = last2, Rd;
 int D0, D1, D2;
 
 while (x < w) {
 int err, pred, sign;
 
 /* compute gradients */
-Ra = x ? R(cur, x - stride) : R(last, x);
 Rb = R(last, x);
-Rc = x ? R(last, x - stride) : last2;
 Rd = (x >= w - stride) ? R(last, x) : R(last, x + stride);
 D0 = Rd - Rb;
 D1 = Rb - Rc;
@@ -194,9 +192,9 @@ static inline void ls_encode_line(JLSState *state, 
PutBitContext *pb,
 Ra = av_clip(pred + err * state->twonear, 0, 
state->maxval);
 else
 Ra = av_clip(pred - err * state->twonear, 0, 
state->maxval);
-W(cur, x, Ra);
 } else
-W(cur, x, R(in, x));
+Ra = R(in, x);
+W(cur, x, Ra);
 
 if (err < 0)
 err += state->range;
@@ -236,12 +234,13 @@ static inline void ls_encode_line(JLSState *state, 
PutBitContext *pb,
 Ra = av_clip(pred + err * state->twonear, 0, 
state->maxval);
 else
 Ra = av_clip(pred - err * state->twonear, 0, 
state->maxval);
-W(cur, x, Ra);
 } else
-W(cur, x, R(in, x));
+Ra = R(in, x);
+W(cur, x, Ra);
 
 ls_encode_regular(state, pb, context, err);
 }
+Rc = Rb;
 x += stride;
 }
 }
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 2/8] avcodec/jpeglsenc: Don't modify frame we don't own

2020-09-04 Thread Andreas Rheinhardt
The jpegls encoder uses three buffers (as well as its state) to perform
its function: A copy of the last encoded line as a decoder would decode it,
the part of the current line that has been encoded (again, as a decoder
would decode it) and the part of the current line that is not yet encoded.

The encoder solves this by modifying the input frame as it encodes the
output (it also zero-allocates a line to serve as last line for the
first line where no preceding line exists); yet this is wrong as said
frame is not owned by the encoder, so it must not be modified (and it is
given to the encoder as const AVFrame *) without making it writable.

This patch solves this bug by allocating two lines, one for the last and
one for the currently encoded line of output (as a decoder would decode it).

Notice that the frame is only modified if the encoder is in the
non-default non-lossless mode.

Signed-off-by: Andreas Rheinhardt 
---
Example command line to trigger this behaviour:
ffmpeg -i fate-suite/png1/lena-rgb24.png -an -map 0 -map 0 -map 0 -c:v:0 jpegls 
-c:v:1 jpegls -pred:v:1 median -c:v:2 jpegls -f streamhash -
The output of the first and third stream differ with git master.

(For some reason "pred" is used to set how lossy the mode is.)

 libavcodec/jpeglsenc.c | 50 +++---
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index feea6fdde7..67897ce8ae 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -141,7 +141,7 @@ static inline void ls_encode_run(JLSState *state, 
PutBitContext *pb, int run,
  * Encode one line of image
  */
 static inline void ls_encode_line(JLSState *state, PutBitContext *pb,
-  void *last, void *cur, int last2, int w,
+  void *last, void *cur, const void *in, int 
last2, int w,
   int stride, int comp, int bits)
 {
 int x = 0;
@@ -168,7 +168,7 @@ static inline void ls_encode_line(JLSState *state, 
PutBitContext *pb,
 
 run= 0;
 RUNval = Ra;
-while (x < w && (FFABS(R(cur, x) - RUNval) <= state->near)) {
+while (x < w && (FFABS(R(in, x) - RUNval) <= state->near)) {
 run++;
 W(cur, x, Ra);
 x += stride;
@@ -179,7 +179,7 @@ static inline void ls_encode_line(JLSState *state, 
PutBitContext *pb,
 Rb = R(last, x);
 RItype = FFABS(Ra - Rb) <= state->near;
 pred   = RItype ? Ra : Rb;
-err= R(cur, x) - pred;
+err= R(in, x) - pred;
 
 if (!RItype && Ra > Rb)
 err = -err;
@@ -195,7 +195,9 @@ static inline void ls_encode_line(JLSState *state, 
PutBitContext *pb,
 else
 Ra = av_clip(pred - err * state->twonear, 0, 
state->maxval);
 W(cur, x, Ra);
-}
+} else
+W(cur, x, R(in, x));
+
 if (err < 0)
 err += state->range;
 if (err >= state->range + 1 >> 1)
@@ -218,11 +220,11 @@ static inline void ls_encode_line(JLSState *state, 
PutBitContext *pb,
 context = -context;
 sign= 1;
 pred= av_clip(pred - state->C[context], 0, state->maxval);
-err = pred - R(cur, x);
+err = pred - R(in, x);
 } else {
 sign = 0;
 pred = av_clip(pred + state->C[context], 0, state->maxval);
-err  = R(cur, x) - pred;
+err  = R(in, x) - pred;
 }
 
 if (state->near) {
@@ -235,7 +237,8 @@ static inline void ls_encode_line(JLSState *state, 
PutBitContext *pb,
 else
 Ra = av_clip(pred - err * state->twonear, 0, 
state->maxval);
 W(cur, x, Ra);
-}
+} else
+W(cur, x, R(in, x));
 
 ls_encode_regular(state, pb, context, err);
 }
@@ -276,8 +279,8 @@ static int encode_picture_ls(AVCodecContext *avctx, 
AVPacket *pkt,
 GetBitContext gb;
 uint8_t *buf2 = NULL;
 uint8_t *zero = NULL;
-uint8_t *cur  = NULL;
-uint8_t *last = NULL;
+const uint8_t *in;
+uint8_t *last, *cur;
 JLSState *state = NULL;
 int i, size, ret;
 int comps;
@@ -343,28 +346,29 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 ls_store_lse(state, &pb);
 
-zero = last = av_mallocz(FFABS(p->linesize[0]));
+zero = last = av_calloc(FFABS(p->linesize[0]), 2);
 if (!zero)
 goto memfail;
+cur = zero + FFABS(p->linesize[0]);
 
-cur  = p->data[0];
+in = p->data[0];
 if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
 int t = 0;
 
 for (i = 0; i < avctx->height; i++) {
-ls_encode_line(state, &pb2, last, cur, t, avctx->width, 1, 0, 8);
+ls_encode_line(state

[FFmpeg-devel] [PATCH 5/8] avcodec/jpeglsenc: Remove redundant av_packet_unref()

2020-09-04 Thread Andreas Rheinhardt
If encoding fails, the AVPacket that ought to contain the encoded packet
is already unreferenced generically.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/jpeglsenc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index d05fe4564b..b1e54431e9 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -431,7 +431,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 return 0;
 
 memfail:
-av_packet_unref(pkt);
 av_freep(&buf2);
 av_freep(&state);
 av_freep(&last);
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 8/8] avcodec/jpegls: Remove unused structure

2020-09-04 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/jpegls.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/libavcodec/jpegls.h b/libavcodec/jpegls.h
index 6b89b2afa3..16372bd39d 100644
--- a/libavcodec/jpegls.h
+++ b/libavcodec/jpegls.h
@@ -34,10 +34,6 @@
 
 #undef near /* This file uses struct member 'near' which in windows.h is 
defined as empty. */
 
-typedef struct JpeglsContext {
-AVCodecContext *avctx;
-} JpeglsContext;
-
 typedef struct JLSState {
 int T1, T2, T3;
 int A[367], B[367], C[365], N[367];
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 7/8] avcodec/jpeglsenc: Allocate buffers together

2020-09-04 Thread Andreas Rheinhardt
Having only one allocation that is not automatically freed in particular
means that one does not need to free the already allocated buffers
when allocating another one fails.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/jpeglsenc.c | 25 +++--
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index 7fd109f0cf..304b0806a7 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -276,7 +276,6 @@ static int encode_picture_ls(AVCodecContext *avctx, 
AVPacket *pkt,
 PutByteContext pb;
 PutBitContext pb2;
 GetBitContext gb;
-uint8_t *buf2 = NULL;
 const uint8_t *in;
 uint8_t *last = NULL;
 JLSState state = { 0 };
@@ -300,12 +299,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
 AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0)
 return ret;
 
-buf2 = av_malloc(pkt->size);
-if (!buf2)
-goto memfail;
+last = av_malloc((unsigned)pkt->size + FFABS(p->linesize[0]));
+if (!last)
+return AVERROR(ENOMEM);
+memset(last, 0, FFABS(p->linesize[0]));
 
 bytestream2_init_writer(&pb, pkt->data, pkt->size);
-init_put_bits(&pb2, buf2, pkt->size);
+init_put_bits(&pb2, last + FFABS(p->linesize[0]), pkt->size);
 
 /* write our own JPEG header, can't use mjpeg_picture_header */
 put_markeru(&pb, SOI);
@@ -340,10 +340,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 ls_store_lse(&state, &pb);
 
-last = av_mallocz(FFABS(p->linesize[0]));
-if (!last)
-goto memfail;
-
 in = p->data[0];
 if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
 int t = 0;
@@ -393,8 +389,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 }
 
-av_freep(&last);
-
 /* the specification says that after doing 0xff escaping unused bits in
  * the last byte must be set to 0, so just append 7 "optional" zero bits
  * to avoid special-casing. */
@@ -402,7 +396,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 size = put_bits_count(&pb2);
 flush_put_bits(&pb2);
 /* do escape coding */
-init_get_bits(&gb, buf2, size);
+init_get_bits(&gb, pb2.buf, size);
 size -= 7;
 while (get_bits_count(&gb) < size) {
 int v;
@@ -413,7 +407,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 bytestream2_put_byte(&pb, v);
 }
 }
-av_freep(&buf2);
+av_freep(&last);
 
 /* End of image */
 put_marker(&pb, EOI);
@@ -424,11 +418,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 pkt->flags |= AV_PKT_FLAG_KEY;
 *got_packet = 1;
 return 0;
-
-memfail:
-av_freep(&buf2);
-av_freep(&last);
-return AVERROR(ENOMEM);
 }
 
 static av_cold int encode_init_ls(AVCodecContext *ctx)
-- 
2.20.1

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

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

[FFmpeg-devel] [PATCH 6/8] avcodec/jpeglsenc: Avoid allocation of JLSState

2020-09-04 Thread Andreas Rheinhardt
This state is currently allocated and freed for every packet; but it can
just be moved to the stack instead.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/jpeglsenc.c | 26 ++
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index b1e54431e9..7fd109f0cf 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -279,7 +279,7 @@ static int encode_picture_ls(AVCodecContext *avctx, 
AVPacket *pkt,
 uint8_t *buf2 = NULL;
 const uint8_t *in;
 uint8_t *last = NULL;
-JLSState *state = NULL;
+JLSState state = { 0 };
 int i, size, ret;
 int comps;
 
@@ -332,17 +332,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
 bytestream2_put_byteu(&pb, (comps > 1) ? 1 : 0);  // interleaving: 0 - 
plane, 1 - line
 bytestream2_put_byteu(&pb, 0);  // point transform: none
 
-state = av_mallocz(sizeof(JLSState));
-if (!state)
-goto memfail;
-
 /* initialize JPEG-LS state from JPEG parameters */
-state->near = ctx->pred;
-state->bpp  = (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8;
-ff_jpegls_reset_coding_parameters(state, 0);
-ff_jpegls_init_state(state);
+state.near = ctx->pred;
+state.bpp  = (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8;
+ff_jpegls_reset_coding_parameters(&state, 0);
+ff_jpegls_init_state(&state);
 
-ls_store_lse(state, &pb);
+ls_store_lse(&state, &pb);
 
 last = av_mallocz(FFABS(p->linesize[0]));
 if (!last)
@@ -354,7 +350,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 for (i = 0; i < avctx->height; i++) {
 int last0 = last[0];
-ls_encode_line(state, &pb2, last, in, t, avctx->width, 1, 0, 8);
+ls_encode_line(&state, &pb2, last, in, t, avctx->width, 1, 0, 8);
 t   = last0;
 in += p->linesize[0];
 }
@@ -363,7 +359,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 for (i = 0; i < avctx->height; i++) {
 int last0 = *((uint16_t *)last);
-ls_encode_line(state, &pb2, last, in, t, avctx->width, 1, 0, 16);
+ls_encode_line(&state, &pb2, last, in, t, avctx->width, 1, 0, 16);
 t   = last0;
 in += p->linesize[0];
 }
@@ -375,7 +371,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 for (i = 0; i < avctx->height; i++) {
 for (j = 0; j < 3; j++) {
 int last0 = last[j];
-ls_encode_line(state, &pb2, last + j, in + j, Rc[j],
+ls_encode_line(&state, &pb2, last + j, in + j, Rc[j],
width, 3, j, 8);
 Rc[j] = last0;
 }
@@ -389,7 +385,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 for (i = 0; i < avctx->height; i++) {
 for (j = 2; j >= 0; j--) {
 int last0 = last[j];
-ls_encode_line(state, &pb2, last + j, in + j, Rc[j],
+ls_encode_line(&state, &pb2, last + j, in + j, Rc[j],
width, 3, j, 8);
 Rc[j] = last0;
 }
@@ -398,7 +394,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 
 av_freep(&last);
-av_freep(&state);
 
 /* the specification says that after doing 0xff escaping unused bits in
  * the last byte must be set to 0, so just append 7 "optional" zero bits
@@ -432,7 +427,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 memfail:
 av_freep(&buf2);
-av_freep(&state);
 av_freep(&last);
 return AVERROR(ENOMEM);
 }
-- 
2.20.1

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

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

Re: [FFmpeg-devel] [PATCH 3/5] avdevice/lavfi: Use av_packet_pack_dictionary() to pack dictionary

2020-09-04 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt 
> ---
> av_packet_pack_dictionary() returns NULL in case the dictionary's count
> is zero; but given that the dict API does not return such dicts at all,
> I have not added any check for this.
> 
>  libavdevice/lavfi.c | 25 -
>  1 file changed, 8 insertions(+), 17 deletions(-)
> 
> diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
> index 5e814eada8..bafc3275c9 100644
> --- a/libavdevice/lavfi.c
> +++ b/libavdevice/lavfi.c
> @@ -444,25 +444,16 @@ static int lavfi_read_packet(AVFormatContext *avctx, 
> AVPacket *pkt)
>  
>  frame_metadata = frame->metadata;
>  if (frame_metadata) {
> -uint8_t *metadata;
> -AVDictionaryEntry *e = NULL;
> -AVBPrint meta_buf;
> -
> -av_bprint_init(&meta_buf, 0, AV_BPRINT_SIZE_UNLIMITED);
> -while ((e = av_dict_get(frame_metadata, "", e, 
> AV_DICT_IGNORE_SUFFIX))) {
> -av_bprintf(&meta_buf, "%s", e->key);
> -av_bprint_chars(&meta_buf, '\0', 1);
> -av_bprintf(&meta_buf, "%s", e->value);
> -av_bprint_chars(&meta_buf, '\0', 1);
> -}
> -if (!av_bprint_is_complete(&meta_buf) ||
> -!(metadata = av_packet_new_side_data(pkt, 
> AV_PKT_DATA_STRINGS_METADATA,
> - meta_buf.len))) {
> -av_bprint_finalize(&meta_buf, NULL);
> +int size;
> +uint8_t *metadata = av_packet_pack_dictionary(frame_metadata, &size);
> +
> +if (!metadata)
>  return AVERROR(ENOMEM);
> +if ((ret = av_packet_add_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA,
> +   metadata, size)) < 0) {
> +av_freep(&metadata);
> +return ret;
>  }
> -memcpy(metadata, meta_buf.str, meta_buf.len);
> -av_bprint_finalize(&meta_buf, NULL);
>  }
>  
>  if ((ret = create_subcc_packet(avctx, frame, min_pts_sink_idx)) < 0) {
> 
Will apply the two outstanding patches (i.e. this and 4/5 [1]) of this
patchset tomorrow unless there are objections.

- Andreas

[1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2020-August/268930.html
___
ffmpeg-devel mailing list
ffmpeg-devel@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] qsv: question on CONFIG macros

2020-09-04 Thread js

> On Sep 4, 2020, at 23:58, Rogozhkin, Dmitry V  
> wrote:
> 
> Hi,
> 
> Can someone, please, help to clarify:
> 1. Where CONFIG_QSV and CONFIG_LIBMFX gets defined (I don't see that in
> the grep output - attached below)?

Defined at config.h during “./configuration xxx” step.

> 2. What's relationship between these 2? Which one should actually be
> used? /from the first glance they are about the same.../
> 
IMO related information in configuration scripts may helps.

- Linjie
> $ fgrep -rsn CONFIG_QSV
> doc/examples/Makefile:16:EXAMPLES-
> $(CONFIG_QSVDEC_EXAMPLE)+= qsvdec
> fftools/ffmpeg.h:621:#if CONFIG_QSV
> fftools/ffmpeg_opt.c:3772:#if CONFIG_QSV
> libavcodec/Makefile:137:OBJS-$(CONFIG_QSV) += qsv.o
> libavcodec/Makefile:138:OBJS-$(CONFIG_QSVDEC)  +=
> qsvdec.o
> libavcodec/Makefile:139:OBJS-$(CONFIG_QSVENC)  +=
> qsvenc.o
> libavcodec/Makefile:1184:SKIPHEADERS-$(CONFIG_QSV)  +=
> qsv.h qsv_internal.h
> libavcodec/Makefile:1185:SKIPHEADERS-$(CONFIG_QSVDEC)   +=
> qsvdec.h
> libavcodec/Makefile:1186:SKIPHEADERS-$(CONFIG_QSVENC)   +=
> qsvenc.h
> libavcodec/qsv_api.c:27:#if CONFIG_QSV
> libavfilter/Makefile:28:OBJS-$(CONFIG_QSVVPP)+= 
> qsvvpp.o
> libavfilter/Makefile:525:SKIPHEADERS-
> $(CONFIG_QSVVPP) += qsvvpp.h
> libavutil/Makefile:182:OBJS-$(CONFIG_QSV)  +=
> hwcontext_qsv.o
> libavutil/Makefile:198:SKIPHEADERS-$(CONFIG_QSV)  +=
> hwcontext_qsv.h
> libavutil/hwcontext.c:47:#if CONFIG_QSV
> 
> $ fgrep -rsn CONFIG_LIBMFX
> fftools/Makefile:13:OBJS-ffmpeg-$(CONFIG_LIBMFX)   +=
> fftools/ffmpeg_qsv.o
> fftools/ffmpeg_opt.c:138:#if CONFIG_LIBMFX
> libavutil/hwcontext_opencl.c:49:#if CONFIG_LIBMFX
> libavutil/hwcontext_opencl.c:2249:#if CONFIG_LIBMFX
> 
> Regards,
> Dmitry.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

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

[FFmpeg-devel] [PATCH 2/3] avcodec/mips: Refine get_cabac_inline_mips.

2020-09-04 Thread Shiyou Yin
1. Refined function get_cabac_inline_mips.
2. Optimize function get_cabac_bypass and get_cabac_bypass_sign.

Speed of decoding h264: 5.23x ==> 5.45x(tested on 3A4000).
---
 libavcodec/mips/cabac.h | 131 +---
 1 file changed, 102 insertions(+), 29 deletions(-)

diff --git a/libavcodec/mips/cabac.h b/libavcodec/mips/cabac.h
index 3d09e93..579d4ee 100644
--- a/libavcodec/mips/cabac.h
+++ b/libavcodec/mips/cabac.h
@@ -2,7 +2,8 @@
  * Loongson SIMD optimized h264chroma
  *
  * Copyright (c) 2018 Loongson Technology Corporation Limited
- * Copyright (c) 2018 Shiyou Yin 
+ * Contributed by Shiyou Yin 
+ *Gu Xiwei(guxiwei...@loongson.cn)
  *
  * This file is part of FFmpeg.
  *
@@ -25,18 +26,18 @@
 #define AVCODEC_MIPS_CABAC_H
 
 #include "libavcodec/cabac.h"
-#include "libavutil/mips/asmdefs.h"
+#include "libavutil/mips/mmiutils.h"
 #include "config.h"
 
 #define get_cabac_inline get_cabac_inline_mips
 static av_always_inline int get_cabac_inline_mips(CABACContext *c,
- uint8_t * const state){
+  uint8_t * const state){
 mips_reg tmp0, tmp1, tmp2, bit;
 
 __asm__ volatile (
 "lbu  %[bit],0(%[state])   \n\t"
 "and  %[tmp0],   %[c_range], 0xC0  \n\t"
-PTR_ADDU "%[tmp0],   %[tmp0],%[tmp0]   \n\t"
+PTR_SLL  "%[tmp0],   %[tmp0],0x01  \n\t"
 PTR_ADDU "%[tmp0],   %[tmp0],%[tables] \n\t"
 PTR_ADDU "%[tmp0],   %[tmp0],%[bit]\n\t"
 /* tmp1: RangeLPS */
@@ -44,18 +45,11 @@ static av_always_inline int 
get_cabac_inline_mips(CABACContext *c,
 
 PTR_SUBU "%[c_range],%[c_range], %[tmp1]   \n\t"
 PTR_SLL  "%[tmp0],   %[c_range], 0x11  \n\t"
-PTR_SUBU "%[tmp0],   %[tmp0],%[c_low]  \n\t"
-
-/* tmp2: lps_mask */
-PTR_SRA  "%[tmp2],   %[tmp0],0x1F  \n\t"
-/* If tmp0 < 0, lps_mask ==  0x*/
-/* If tmp0 >= 0, lps_mask ==  0x*/
+"slt  %[tmp2],   %[tmp0],%[c_low]  \n\t"
 "beqz %[tmp2],   1f\n\t"
-PTR_SLL  "%[tmp0],   %[c_range], 0x11  \n\t"
+"move %[c_range],%[tmp1]   \n\t"
+"not  %[bit],%[bit]\n\t"
 PTR_SUBU "%[c_low],  %[c_low],   %[tmp0]   \n\t"
-PTR_SUBU "%[tmp0],   %[tmp1],%[c_range]\n\t"
-PTR_ADDU "%[c_range],%[c_range], %[tmp0]   \n\t"
-"xor  %[bit],%[bit], %[tmp2]   \n\t"
 
 "1:\n\t"
 /* tmp1: *state */
@@ -70,23 +64,18 @@ static av_always_inline int 
get_cabac_inline_mips(CABACContext *c,
 PTR_SLL  "%[c_range],%[c_range], %[tmp2]   \n\t"
 PTR_SLL  "%[c_low],  %[c_low],   %[tmp2]   \n\t"
 
-"and  %[tmp0],   %[c_low],   %[cabac_mask] \n\t"
-"bnez %[tmp0],   1f\n\t"
-PTR_ADDIU"%[tmp0],   %[c_low],   -0x01 \n\t"
+"and  %[tmp1],   %[c_low],   %[cabac_mask] \n\t"
+"bnez %[tmp1],   1f\n\t"
+PTR_ADDIU"%[tmp0],   %[c_low],   -0X01 \n\t"
 "xor  %[tmp0],   %[c_low],   %[tmp0]   \n\t"
 PTR_SRA  "%[tmp0],   %[tmp0],0x0f  \n\t"
 PTR_ADDU "%[tmp0],   %[tmp0],%[tables] \n\t"
+/* tmp2: ff_h264_norm_shift[x >> (CABAC_BITS - 1)] */
 "lbu  %[tmp2],   %[norm_off](%[tmp0])  \n\t"
-#if CABAC_BITS == 16
-"lbu  %[tmp0],   0(%[c_bytestream])\n\t"
-"lbu  %[tmp1],   1(%[c_bytestream])\n\t"
-PTR_SLL  "%[tmp0],   %[tmp0],0x09  \n\t"
-PTR_SLL  "%[tmp1],   %[tmp1],0x01  \n\t"
-PTR_ADDU "%[tmp0],   %[tmp0],%[tmp1]   \n\t"
-#else
-"lbu  %[tmp0],   0(%[c_bytestream])\n\t"
+
+"lhu  %[tmp0],   0(%[c_bytestream])\n\t"
+"dsbh %[tmp0],   %[tmp0]   \n\t"
 PTR_SLL  "%[tmp0],   %[tmp0],0x01  \n\t"
-#endif
 PTR_SUBU "%[tmp0],   %[tmp0],%[cabac_mask] \n\t"
 
 "li   %[tmp1],   0x07  \n\t"
@@ -94,10 +83,13 @@ static av_always_inline int 
get_cabac_inline_mips(CABACContext *c,