[FFmpeg-devel] [PATCH 11/15] avcodec/celp_math: Disable unused function

2021-02-18 Thread Andreas Rheinhardt
The code using ff_exp2 (namely ff_acelp_decode_gain_code) use it only if
G729_BITEXACT is defined. So disable it if not.

Signed-off-by: Andreas Rheinhardt 
---
Alternatively one can also remove the G729_BITEXACT code altogether.

 libavcodec/celp_math.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/celp_math.c b/libavcodec/celp_math.c
index a96b1aed9e..920995a879 100644
--- a/libavcodec/celp_math.c
+++ b/libavcodec/celp_math.c
@@ -29,6 +29,7 @@
 #include "celp_math.h"
 #include "libavutil/common.h"
 
+#ifdef G729_BITEXACT
 static const uint16_t exp2a[]=
 {
  0,  1435,  2901,  4400,  5931,  7496,  9096, 10730,
@@ -54,6 +55,7 @@ int ff_exp2(uint16_t power)
 result= (result<<3) + ((result*exp2b[(power>>5)&31])>>17);
 return result + ((result*(power&31)*89)>>22);
 }
+#endif
 
 /**
  * Table used to compute log2(x)
-- 
2.27.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 10/15] avcodec/x86/diracdsp_init: Reuse macro

2021-02-18 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/x86/diracdsp_init.c | 38 ++
 1 file changed, 2 insertions(+), 36 deletions(-)

diff --git a/libavcodec/x86/diracdsp_init.c b/libavcodec/x86/diracdsp_init.c
index 8633c66743..8baacf3129 100644
--- a/libavcodec/x86/diracdsp_init.c
+++ b/libavcodec/x86/diracdsp_init.c
@@ -91,42 +91,8 @@ DIRAC_PIXOP(put, mmx)
 DIRAC_PIXOP(avg, mmx)
 DIRAC_PIXOP(avg, mmxext)
 
-static void put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5],
-int stride, int h)
-{
-if (h&3)
-ff_put_dirac_pixels16_c(dst, src, stride, h);
-else
-ff_put_pixels16_sse2(dst, src[0], stride, h);
-}
-static void avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5],
-int stride, int h)
-{
-if (h&3)
-ff_avg_dirac_pixels16_c(dst, src, stride, h);
-else
-ff_avg_pixels16_sse2(dst, src[0], stride, h);
-}
-static void put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5],
-int stride, int h)
-{
-if (h&3) {
-ff_put_dirac_pixels32_c(dst, src, stride, h);
-} else {
-ff_put_pixels16_sse2(dst   , src[0]   , stride, h);
-ff_put_pixels16_sse2(dst+16, src[0]+16, stride, h);
-}
-}
-static void avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5],
-int stride, int h)
-{
-if (h&3) {
-ff_avg_dirac_pixels32_c(dst, src, stride, h);
-} else {
-ff_avg_pixels16_sse2(dst   , src[0]   , stride, h);
-ff_avg_pixels16_sse2(dst+16, src[0]+16, stride, h);
-}
-}
+DIRAC_PIXOP(put, sse2)
+DIRAC_PIXOP(avg, sse2)
 
 #if !ARCH_X86_64
 HPEL_FILTER(8, mmx)
-- 
2.27.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 09/15] avcodec/x86/diracdsp_init: Simplify macro

2021-02-18 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/x86/diracdsp_init.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/libavcodec/x86/diracdsp_init.c b/libavcodec/x86/diracdsp_init.c
index cd663f2d23..8633c66743 100644
--- a/libavcodec/x86/diracdsp_init.c
+++ b/libavcodec/x86/diracdsp_init.c
@@ -67,29 +67,29 @@ void ff_dequant_subband_32_sse4(uint8_t *src, uint8_t *dst, 
ptrdiff_t stride, co
 c->PFX ## _dirac_pixels_tab[1][IDX] = PFX ## _dirac_pixels16_ ## EXT; \
 c->PFX ## _dirac_pixels_tab[2][IDX] = PFX ## _dirac_pixels32_ ## EXT
 
-#define DIRAC_PIXOP(OPNAME2, OPNAME, EXT)\
-static void OPNAME2 ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t 
*src[5], \
-   int stride, int h) \
+#define DIRAC_PIXOP(OPNAME, EXT)\
+static void OPNAME ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t 
*src[5], \
+  int stride, int h) \
 {\
 if (h&3)\
-ff_ ## OPNAME2 ## _dirac_pixels16_c(dst, src, stride, h);\
+ff_ ## OPNAME ## _dirac_pixels16_c(dst, src, stride, h);\
 else\
-OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\
+ff_ ## OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\
 }\
-static void OPNAME2 ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t 
*src[5], \
-   int stride, int h) \
+static void OPNAME ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t 
*src[5], \
+  int stride, int h) \
 {\
 if (h&3) {\
-ff_ ## OPNAME2 ## _dirac_pixels32_c(dst, src, stride, h);\
+ff_ ## OPNAME ## _dirac_pixels32_c(dst, src, stride, h);\
 } else {\
-OPNAME ## _pixels16_ ## EXT(dst   , src[0]   , stride, h);\
-OPNAME ## _pixels16_ ## EXT(dst+16, src[0]+16, stride, h);\
+ff_ ## OPNAME ## _pixels16_ ## EXT(dst   , src[0]   , stride, h);\
+ff_ ## OPNAME ## _pixels16_ ## EXT(dst+16, src[0]+16, stride, h);\
 }\
 }
 
-DIRAC_PIXOP(put, ff_put, mmx)
-DIRAC_PIXOP(avg, ff_avg, mmx)
-DIRAC_PIXOP(avg, ff_avg, mmxext)
+DIRAC_PIXOP(put, mmx)
+DIRAC_PIXOP(avg, mmx)
+DIRAC_PIXOP(avg, mmxext)
 
 static void put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5],
 int stride, int h)
-- 
2.27.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 08/15] avcodec/x86_diracdsp_init: Make functions only used here static

2021-02-18 Thread Andreas Rheinhardt
This allowed to remove forward declarations. Because compilers expect
declarations for all functions they encounter even when it is within
blocks disabled via "if (0 && foo)", one has to use a real #if in
ff_diracdsp_init_x86.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/x86/diracdsp_init.c | 55 ++
 1 file changed, 23 insertions(+), 32 deletions(-)

diff --git a/libavcodec/x86/diracdsp_init.c b/libavcodec/x86/diracdsp_init.c
index d570238d16..cd663f2d23 100644
--- a/libavcodec/x86/diracdsp_init.c
+++ b/libavcodec/x86/diracdsp_init.c
@@ -22,15 +22,6 @@
 #include "libavcodec/diracdsp.h"
 #include "fpel.h"
 
-DECL_DIRAC_PIXOP(put, mmx);
-DECL_DIRAC_PIXOP(avg, mmx);
-DECL_DIRAC_PIXOP(avg, mmxext);
-
-void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int 
stride, int h);
-void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int 
stride, int h);
-void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int 
stride, int h);
-void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int 
stride, int h);
-
 void ff_add_rect_clamped_mmx(uint8_t *, const uint16_t *, int, const int16_t 
*, int, int, int);
 void ff_add_rect_clamped_sse2(uint8_t *, const uint16_t *, int, const int16_t 
*, int, int, int);
 
@@ -72,19 +63,21 @@ void ff_dequant_subband_32_sse4(uint8_t *src, uint8_t *dst, 
ptrdiff_t stride, co
 }
 
 #define PIXFUNC(PFX, IDX, EXT) 
  \
-/*MMXDISABLEDc->PFX ## _dirac_pixels_tab[0][IDX] = ff_ ## PFX ## 
_dirac_pixels8_ ## EXT;*/  \
-c->PFX ## _dirac_pixels_tab[1][IDX] = ff_ ## PFX ## _dirac_pixels16_ ## 
EXT; \
-c->PFX ## _dirac_pixels_tab[2][IDX] = ff_ ## PFX ## _dirac_pixels32_ ## EXT
+/*MMXDISABLEDc->PFX ## _dirac_pixels_tab[0][IDX] = PFX ## _dirac_pixels8_ 
## EXT;*/  \
+c->PFX ## _dirac_pixels_tab[1][IDX] = PFX ## _dirac_pixels16_ ## EXT; \
+c->PFX ## _dirac_pixels_tab[2][IDX] = PFX ## _dirac_pixels32_ ## EXT
 
 #define DIRAC_PIXOP(OPNAME2, OPNAME, EXT)\
-void ff_ ## OPNAME2 ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t 
*src[5], int stride, int h)\
+static void OPNAME2 ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t 
*src[5], \
+   int stride, int h) \
 {\
 if (h&3)\
 ff_ ## OPNAME2 ## _dirac_pixels16_c(dst, src, stride, h);\
 else\
 OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\
 }\
-void ff_ ## OPNAME2 ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t 
*src[5], int stride, int h)\
+static void OPNAME2 ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t 
*src[5], \
+   int stride, int h) \
 {\
 if (h&3) {\
 ff_ ## OPNAME2 ## _dirac_pixels32_c(dst, src, stride, h);\
@@ -98,21 +91,24 @@ DIRAC_PIXOP(put, ff_put, mmx)
 DIRAC_PIXOP(avg, ff_avg, mmx)
 DIRAC_PIXOP(avg, ff_avg, mmxext)
 
-void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int 
stride, int h)
+static void put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5],
+int stride, int h)
 {
 if (h&3)
 ff_put_dirac_pixels16_c(dst, src, stride, h);
 else
 ff_put_pixels16_sse2(dst, src[0], stride, h);
 }
-void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int 
stride, int h)
+static void avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5],
+int stride, int h)
 {
 if (h&3)
 ff_avg_dirac_pixels16_c(dst, src, stride, h);
 else
 ff_avg_pixels16_sse2(dst, src[0], stride, h);
 }
-void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int 
stride, int h)
+static void put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5],
+int stride, int h)
 {
 if (h&3) {
 ff_put_dirac_pixels32_c(dst, src, stride, h);
@@ -121,7 +117,8 @@ void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t 
*src[5], int stride,
 ff_put_pixels16_sse2(dst+16, src[0]+16, stride, h);
 }
 }
-void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int 
stride, int h)
+static void avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5],
+int stride, int h)
 {
 if (h&3) {
 ff_avg_dirac_pixels32_c(dst, src, stride, h);
@@ -131,23 +128,16 @@ void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const 
uint8_t *src[5], int stride,
 }
 }
 
-#else // HAVE_X86ASM
-
-#define HPEL_FILTER(MMSIZE, EXT)   
  \
-void dirac_hpel_filter_ ## EXT(uint8_t *dsth, uint8_t *dstv, uint8_t 
*dstc,  \
-   const uint8_t *src, int stride, int width, 
int height);
-
-#define PIXFUNC(PFX, IDX, EXT) do {} while (0)
-
-#endif // HAVE_X86ASM
-
 #if !ARCH_X86_64
 HPEL_FILTER(8, mmx)
 #endif
 HPEL_FILTER(16, 

[FFmpeg-devel] [PATCH 15/15] avcodec/x86/constants: Remove unused ff_pw_17

2021-02-18 Thread Andreas Rheinhardt
Unused since 80944df720da98d6e5ee0e355db5814735914ec9.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/x86/constants.c| 1 -
 libavcodec/x86/h264_intrapred.asm | 4 
 2 files changed, 5 deletions(-)

diff --git a/libavcodec/x86/constants.c b/libavcodec/x86/constants.c
index f2d267e85d..bc7f2b17b8 100644
--- a/libavcodec/x86/constants.c
+++ b/libavcodec/x86/constants.c
@@ -34,7 +34,6 @@ DECLARE_ALIGNED(16, const xmm_reg,  ff_pw_8)= { 
0x0008000800080008ULL, 0x000
 DECLARE_ASM_ALIGNED(16, const xmm_reg,  ff_pw_9)= { 0x0009000900090009ULL, 
0x0009000900090009ULL };
 DECLARE_ALIGNED(8,  const uint64_t, ff_pw_15)   =   0x000F000F000F000FULL;
 DECLARE_ALIGNED(16, const xmm_reg,  ff_pw_16)   = { 0x0010001000100010ULL, 
0x0010001000100010ULL };
-DECLARE_ALIGNED(16, const xmm_reg,  ff_pw_17)   = { 0x0011001100110011ULL, 
0x0011001100110011ULL };
 DECLARE_ASM_ALIGNED(16, const xmm_reg,  ff_pw_18)   = { 0x0012001200120012ULL, 
0x0012001200120012ULL };
 DECLARE_ALIGNED(16, const xmm_reg,  ff_pw_20)   = { 0x0014001400140014ULL, 
0x0014001400140014ULL };
 DECLARE_ALIGNED(16, const xmm_reg,  ff_pw_32)   = { 0x0020002000200020ULL, 
0x0020002000200020ULL };
diff --git a/libavcodec/x86/h264_intrapred.asm 
b/libavcodec/x86/h264_intrapred.asm
index f3aa3172f0..b36c198fbb 100644
--- a/libavcodec/x86/h264_intrapred.asm
+++ b/libavcodec/x86/h264_intrapred.asm
@@ -42,11 +42,7 @@ SECTION .text
 cextern pb_1
 cextern pb_3
 cextern pw_4
-cextern pw_5
 cextern pw_8
-cextern pw_16
-cextern pw_17
-cextern pw_32
 
 ;-
 ; void ff_pred16x16_vertical_8(uint8_t *src, ptrdiff_t stride)
-- 
2.27.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 07/15] avcodec/x86/diracdsp_init: Remove unused MMX functions

2021-02-18 Thread Andreas Rheinhardt
Unused since a1f3b18bf55f106c974eacb1dc831be4d2bd5277, yet as nonstatic
functions the compiler can't detect this, so that these functions aren't
stripped and no warning is emitted.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/x86/diracdsp_init.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/libavcodec/x86/diracdsp_init.c b/libavcodec/x86/diracdsp_init.c
index 8cb84eb74c..d570238d16 100644
--- a/libavcodec/x86/diracdsp_init.c
+++ b/libavcodec/x86/diracdsp_init.c
@@ -77,13 +77,6 @@ void ff_dequant_subband_32_sse4(uint8_t *src, uint8_t *dst, 
ptrdiff_t stride, co
 c->PFX ## _dirac_pixels_tab[2][IDX] = ff_ ## PFX ## _dirac_pixels32_ ## EXT
 
 #define DIRAC_PIXOP(OPNAME2, OPNAME, EXT)\
-void ff_ ## OPNAME2 ## _dirac_pixels8_ ## EXT(uint8_t *dst, const uint8_t 
*src[5], int stride, int h)\
-{\
-if (h&3)\
-ff_ ## OPNAME2 ## _dirac_pixels8_c(dst, src, stride, h);\
-else\
-OPNAME ## _pixels8_ ## EXT(dst, src[0], stride, h);\
-}\
 void ff_ ## OPNAME2 ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t 
*src[5], int stride, int h)\
 {\
 if (h&3)\
-- 
2.27.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 14/15] swscale/x86/swscale: Remove unused ASM constants

2021-02-18 Thread Andreas Rheinhardt
The last user of g15Mask, r15Mask, g16Mask and r16Mask was disabled
in 77a416e8aab77058b542030870fd7178b62d2a62 and finally removed in
36e8de07ed62609df45d064b56501e3084d25723; b15Mask and b16Mask were
apparently always unused (except for in_asm_used_var_warning_killer,
a function that only existed to make the compiler not optimize ASM
constants away).
w10 is unused since d604bab901f6dfaaad672ef2164e42b1f350474c, w02
since ef423a661818f3c0d8206a2abbc65ff555cc0c67.

Signed-off-by: Andreas Rheinhardt 
---
 libswscale/x86/swscale.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index 1e865914cb..cc9e8b0155 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -44,15 +44,6 @@ const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
 
 DECLARE_ASM_CONST(8, uint64_t, bF8)=   0xF8F8F8F8F8F8F8F8LL;
 DECLARE_ASM_CONST(8, uint64_t, bFC)=   0xFCFCFCFCFCFCFCFCLL;
-DECLARE_ASM_CONST(8, uint64_t, w10)=   0x0010001000100010LL;
-DECLARE_ASM_CONST(8, uint64_t, w02)=   0x0002000200020002LL;
-
-DECLARE_ASM_CONST(8, uint64_t, b16Mask)=   0x001F001F001F001FLL;
-DECLARE_ASM_CONST(8, uint64_t, g16Mask)=   0x07E007E007E007E0LL;
-DECLARE_ASM_CONST(8, uint64_t, r16Mask)=   0xF800F800F800F800LL;
-DECLARE_ASM_CONST(8, uint64_t, b15Mask)=   0x001F001F001F001FLL;
-DECLARE_ASM_CONST(8, uint64_t, g15Mask)=   0x03E003E003E003E0LL;
-DECLARE_ASM_CONST(8, uint64_t, r15Mask)=   0x7C007C007C007C00LL;
 
 DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24A) = 0x00FFFFFFLL;
 DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24B) = 0xFFFFFF00LL;
-- 
2.27.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 06/15] avcodec/acelp_vectors: Remove unused ff_fc_2pulses_9bits_track1

2021-02-18 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/acelp_vectors.c | 11 ---
 libavcodec/acelp_vectors.h |  1 -
 2 files changed, 12 deletions(-)

diff --git a/libavcodec/acelp_vectors.c b/libavcodec/acelp_vectors.c
index 798217d73b..0d4de0e4c3 100644
--- a/libavcodec/acelp_vectors.c
+++ b/libavcodec/acelp_vectors.c
@@ -28,17 +28,6 @@
 #include "avcodec.h"
 #include "acelp_vectors.h"
 
-const uint8_t ff_fc_2pulses_9bits_track1[16] =
-{
-1,  3,
-6,  8,
-11, 13,
-16, 18,
-21, 23,
-26, 28,
-31, 33,
-36, 38
-};
 const uint8_t ff_fc_2pulses_9bits_track1_gray[16] =
 {
   1,  3,
diff --git a/libavcodec/acelp_vectors.h b/libavcodec/acelp_vectors.h
index fae834dac1..c2587c5f69 100644
--- a/libavcodec/acelp_vectors.h
+++ b/libavcodec/acelp_vectors.h
@@ -102,7 +102,6 @@ extern const uint8_t ff_fc_4pulses_8bits_track_4[32];
  *
  * Used in G.729 @@6.4k (with gray coding), AMR @@5.9k (without gray coding)
  */
-extern const uint8_t ff_fc_2pulses_9bits_track1[16];
 extern const uint8_t ff_fc_2pulses_9bits_track1_gray[16];
 
 /**
-- 
2.27.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 12/15] swscale/x86/yuv2rgb: Remove unused ASM constants

2021-02-18 Thread Andreas Rheinhardt
mmx_grnmask is unused since 531f97b0c32d1d421f3ac614e002c53951658115,
the other constants since e934194b6a4159b7960cabefb0dd8b998c1961e8.

Signed-off-by: Andreas Rheinhardt 
---
 libswscale/x86/yuv2rgb.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/libswscale/x86/yuv2rgb.c b/libswscale/x86/yuv2rgb.c
index 2143026a0d..47f45bd7c2 100644
--- a/libswscale/x86/yuv2rgb.c
+++ b/libswscale/x86/yuv2rgb.c
@@ -41,14 +41,6 @@
 
 #define DITHER1XBPP // only for MMX
 
-/* hope these constant values are cache line aligned */
-DECLARE_ASM_CONST(8, uint64_t, mmx_00ffw)   = 0x00ff00ff00ff00ffULL;
-DECLARE_ASM_CONST(8, uint64_t, mmx_redmask) = 0xf8f8f8f8f8f8f8f8ULL;
-DECLARE_ASM_CONST(8, uint64_t, mmx_grnmask) = 0xfcfcfcfcfcfcfcfcULL;
-DECLARE_ASM_CONST(8, uint64_t, pb_e0) = 0xe0e0e0e0e0e0e0e0ULL;
-DECLARE_ASM_CONST(8, uint64_t, pb_03) = 0x0303030303030303ULL;
-DECLARE_ASM_CONST(8, uint64_t, pb_07) = 0x0707070707070707ULL;
-
 //MMX versions
 #if HAVE_MMX
 #undef RENAME
-- 
2.27.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 13/15] swscale/x86/rgb2rgb: Remove unused ASM constants

2021-02-18 Thread Andreas Rheinhardt
mask24hh etc. are unused since f099fbf5f3ac1d6b3753fc8dfda6558572111fbd,
mask32b and mask32r since 296609f859a587575b91fe9e9691f2707d6e8136,
mask32g since b38d487466e68bd6baf2889017d2a751831560f0 and mask32 since
f8a138be5257f751ef7d3c6b7ab534c0434e90e7.

Signed-off-by: Andreas Rheinhardt 
---
 libswscale/x86/rgb2rgb.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/libswscale/x86/rgb2rgb.c b/libswscale/x86/rgb2rgb.c
index 4344b5f714..c38a953277 100644
--- a/libswscale/x86/rgb2rgb.c
+++ b/libswscale/x86/rgb2rgb.c
@@ -40,12 +40,7 @@
 
 DECLARE_ASM_CONST(8, uint64_t, mmx_ff)   = 0x00FFULL;
 DECLARE_ASM_CONST(8, uint64_t, mmx_null) = 0xULL;
-DECLARE_ASM_CONST(8, uint64_t, mmx_one)  = 0xULL;
-DECLARE_ASM_CONST(8, uint64_t, mask32b)  = 0x00FF00FFULL;
-DECLARE_ASM_CONST(8, uint64_t, mask32g)  = 0xFF00FF00ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask32r)  = 0x00FF00FFULL;
 DECLARE_ASM_CONST(8, uint64_t, mask32a)  = 0xFF00FF00ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask32)   = 0x00FF00FFULL;
 DECLARE_ASM_CONST(8, uint64_t, mask3216br)   = 0x00F800F800F800F8ULL;
 DECLARE_ASM_CONST(8, uint64_t, mask3216g)= 0xFC00FC00ULL;
 DECLARE_ASM_CONST(8, uint64_t, mask3215g)= 0xF800F800ULL;
@@ -56,9 +51,6 @@ DECLARE_ASM_CONST(8, uint64_t, mask24g)  = 
0xFFFFFF00ULL;
 DECLARE_ASM_CONST(8, uint64_t, mask24r)  = 0xFFFFULL;
 DECLARE_ASM_CONST(8, uint64_t, mask24l)  = 0x00FFULL;
 DECLARE_ASM_CONST(8, uint64_t, mask24h)  = 0xFF00ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask24hh) = 0xULL;
-DECLARE_ASM_CONST(8, uint64_t, mask24hhh)= 0xULL;
-DECLARE_ASM_CONST(8, uint64_t, mask24)   = 0xULL;
 DECLARE_ASM_CONST(8, uint64_t, mask15b)  = 0x001F001F001F001FULL; /* 
 0001  xxB */
 DECLARE_ASM_CONST(8, uint64_t, mask15rg) = 0x7FE07FE07FE07FE0ULL; /* 
0111 1110  RGx */
 DECLARE_ASM_CONST(8, uint64_t, mask15s)  = 0xFFE0FFE0FFE0FFE0ULL;
-- 
2.27.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 05/15] avcodec/acelp_pitch_delay: Inline small functions only used once

2021-02-18 Thread Andreas Rheinhardt
ff_acelp_decode_8bit_to_1st_delay3, ff_acelp_decode_4bit_to_2nd_delay3
and ff_acelp_decode_5_6_bit_to_2nd_delay3 are all only used once (by
g729dec) whereas ff_acelp_decode_9bit_to_1st_delay6 and
ff_acelp_decode_6bit_to_2nd_delay6 are completely unused; with the
possible exception of ff_acelp_decode_4bit_to_2nd_delay3, these
functions are so small that inlining them is appropriate; and as long as
ff_acelp_decode_4bit_to_2nd_delay3 is only called once, this is also
true for it.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/acelp_pitch_delay.c | 41 ---
 libavcodec/acelp_pitch_delay.h | 45 +-
 2 files changed, 34 insertions(+), 52 deletions(-)

diff --git a/libavcodec/acelp_pitch_delay.c b/libavcodec/acelp_pitch_delay.c
index a070d1b25d..1eca97ec69 100644
--- a/libavcodec/acelp_pitch_delay.c
+++ b/libavcodec/acelp_pitch_delay.c
@@ -29,47 +29,6 @@
 #include "celp_math.h"
 #include "audiodsp.h"
 
-int ff_acelp_decode_8bit_to_1st_delay3(int ac_index)
-{
-ac_index += 58;
-if(ac_index > 254)
-ac_index = 3 * ac_index - 510;
-return ac_index;
-}
-
-int ff_acelp_decode_4bit_to_2nd_delay3(
-int ac_index,
-int pitch_delay_min)
-{
-if(ac_index < 4)
-return 3 * (ac_index + pitch_delay_min);
-else if(ac_index < 12)
-return 3 * pitch_delay_min + ac_index + 6;
-else
-return 3 * (ac_index + pitch_delay_min) - 18;
-}
-
-int ff_acelp_decode_5_6_bit_to_2nd_delay3(
-int ac_index,
-int pitch_delay_min)
-{
-return 3 * pitch_delay_min + ac_index - 2;
-}
-
-int ff_acelp_decode_9bit_to_1st_delay6(int ac_index)
-{
-if(ac_index < 463)
-return ac_index + 105;
-else
-return 6 * (ac_index - 368);
-}
-int ff_acelp_decode_6bit_to_2nd_delay6(
-int ac_index,
-int pitch_delay_min)
-{
-return 6 * pitch_delay_min + ac_index - 3;
-}
-
 void ff_acelp_update_past_gain(
 int16_t* quant_energy,
 int gain_corr_factor,
diff --git a/libavcodec/acelp_pitch_delay.h b/libavcodec/acelp_pitch_delay.h
index 2aade2f226..73fa3c331a 100644
--- a/libavcodec/acelp_pitch_delay.h
+++ b/libavcodec/acelp_pitch_delay.h
@@ -41,7 +41,13 @@
  *with 1/3 resolution, 19  < pitch_delay <  85
  *integers only,   85 <= pitch_delay <= 143
  */
-int ff_acelp_decode_8bit_to_1st_delay3(int ac_index);
+static inline int ff_acelp_decode_8bit_to_1st_delay3(int ac_index)
+{
+ac_index += 58;
+if (ac_index > 254)
+ac_index = 3 * ac_index - 510;
+return ac_index;
+}
 
 /**
  * @brief Decode pitch delay of the second subframe encoded by 5 or 6 bits
@@ -58,9 +64,11 @@ int ff_acelp_decode_8bit_to_1st_delay3(int ac_index);
  * @remark The routine is used in G.729 @@8k, AMR @@10.2k, AMR @@7.95k,
  * AMR @@7.4k for the second subframe.
  */
-int ff_acelp_decode_5_6_bit_to_2nd_delay3(
-int ac_index,
-int pitch_delay_min);
+static inline int ff_acelp_decode_5_6_bit_to_2nd_delay3(int ac_index,
+int pitch_delay_min)
+{
+return 3 * pitch_delay_min + ac_index - 2;
+}
 
 /**
  * @brief Decode pitch delay with 1/3 precision.
@@ -78,9 +86,16 @@ int ff_acelp_decode_5_6_bit_to_2nd_delay3(
  * @remark The routine is used in G.729 @@6.4k, AMR @@6.7k, AMR @@5.9k,
  * AMR @@5.15k, AMR @@4.75k for the second subframe.
  */
-int ff_acelp_decode_4bit_to_2nd_delay3(
-int ac_index,
-int pitch_delay_min);
+static inline int ff_acelp_decode_4bit_to_2nd_delay3(int ac_index,
+ int pitch_delay_min)
+{
+if (ac_index < 4)
+return 3 * (ac_index + pitch_delay_min);
+else if (ac_index < 12)
+return 3 * pitch_delay_min + ac_index + 6;
+else
+return 3 * (ac_index + pitch_delay_min) - 18;
+}
 
 /**
  * @brief Decode pitch delay of the first subframe encoded by 9 bits
@@ -95,7 +110,13 @@ int ff_acelp_decode_4bit_to_2nd_delay3(
  *
  * @remark The routine is used in AMR @@12.2k for the first and third 
subframes.
  */
-int ff_acelp_decode_9bit_to_1st_delay6(int ac_index);
+static inline int ff_acelp_decode_9bit_to_1st_delay6(int ac_index)
+{
+if (ac_index < 463)
+return ac_index + 105;
+else
+return 6 * (ac_index - 368);
+}
 
 /**
  * @brief Decode pitch delay of the second subframe encoded by 6 bits
@@ -111,9 +132,11 @@ int ff_acelp_decode_9bit_to_1st_delay6(int ac_index);
  *
  * @remark The routine is used in AMR @@12.2k for the second and fourth 
subframes.
  */
-int ff_acelp_decode_6bit_to_2nd_delay6(
-int ac_index,
-int pitch_delay_min);
+static inline int ff_acelp_decode_6bit_to_2nd_delay6(int ac_index,
+ int pitch_delay_min)
+{
+return 6 * pitch_delay_min + ac_index - 3;
+}
 
 /**
  * @brief Update past quantized energies
-- 
2.27.0

___

[FFmpeg-devel] [PATCH 04/15] avcodec/rangecoder: Move ff_rac_check_termination to tests/rangecoder.c

2021-02-18 Thread Andreas Rheinhardt
It is only used there.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/rangecoder.c   | 19 ---
 libavcodec/rangecoder.h   |  9 -
 libavcodec/tests/rangecoder.c | 28 +++-
 3 files changed, 27 insertions(+), 29 deletions(-)

diff --git a/libavcodec/rangecoder.c b/libavcodec/rangecoder.c
index a6a3f082ef..fa7d5526d1 100644
--- a/libavcodec/rangecoder.c
+++ b/libavcodec/rangecoder.c
@@ -121,22 +121,3 @@ int ff_rac_terminate(RangeCoder *c, int version)
 
 return c->bytestream - c->bytestream_start;
 }
-
-int ff_rac_check_termination(RangeCoder *c, int version)
-{
-if (version == 1) {
-RangeCoder tmp = *c;
-get_rac(c, (uint8_t[]) { 129 });
-
-if (c->bytestream == tmp.bytestream && c->bytestream > 
c->bytestream_start)
-tmp.low -= *--tmp.bytestream;
-tmp.bytestream_end = tmp.bytestream;
-
-if (get_rac(, (uint8_t[]) { 129 }))
-return AVERROR_INVALIDDATA;
-} else {
-if (c->bytestream_end != c->bytestream)
-return AVERROR_INVALIDDATA;
-}
-return 0;
-}
diff --git a/libavcodec/rangecoder.h b/libavcodec/rangecoder.h
index 4d4ca4d526..4495f6df1a 100644
--- a/libavcodec/rangecoder.h
+++ b/libavcodec/rangecoder.h
@@ -57,15 +57,6 @@ void ff_init_range_decoder(RangeCoder *c, const uint8_t 
*buf, int buf_size);
  */
 int ff_rac_terminate(RangeCoder *c, int version);
 
-/**
- * Check if at the current position there is a valid looking termination
- * @param version version 0 requires the decoder to know the data size in bytes
- *version 1 needs about 1 bit more space but does not need to
- *  carry the size from encoder to decoder
- * @returns negative AVERROR code on error or non negative.
- */
-int ff_rac_check_termination(RangeCoder *c, int version);
-
 void ff_build_rac_states(RangeCoder *c, int factor, int max_p);
 
 static inline void renorm_encoder(RangeCoder *c)
diff --git a/libavcodec/tests/rangecoder.c b/libavcodec/tests/rangecoder.c
index d6cf9ec380..ca96e13c99 100644
--- a/libavcodec/tests/rangecoder.c
+++ b/libavcodec/tests/rangecoder.c
@@ -26,6 +26,32 @@
 
 #define SIZE 1240
 
+/**
+ * Check if at the current position there is a valid looking termination
+ * @param version version 0 requires the decoder to know the data size in bytes
+ *version 1 needs about 1 bit more space but does not need to
+ *  carry the size from encoder to decoder
+ * @returns negative AVERROR code on error or non negative.
+ */
+static int rac_check_termination(RangeCoder *c, int version)
+{
+if (version == 1) {
+RangeCoder tmp = *c;
+get_rac(c, (uint8_t[]) { 129 });
+
+if (c->bytestream == tmp.bytestream && c->bytestream > 
c->bytestream_start)
+tmp.low -= *--tmp.bytestream;
+tmp.bytestream_end = tmp.bytestream;
+
+if (get_rac(, (uint8_t[]) { 129 }))
+return AVERROR_INVALIDDATA;
+} else {
+if (c->bytestream_end != c->bytestream)
+return AVERROR_INVALIDDATA;
+}
+return 0;
+}
+
 int main(void)
 {
 RangeCoder c;
@@ -61,7 +87,7 @@ int main(void)
 return 1;
 }
 
-if (ff_rac_check_termination(, version) < 0) {
+if (rac_check_termination(, version) < 0) {
 av_log(NULL, AV_LOG_ERROR, "rac failure at termination pass %d 
version %d\n", p, version);
 return 1;
 }
-- 
2.27.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 03/15] avcodec/mqcenc: Remove unused ff_mqc_length

2021-02-18 Thread Andreas Rheinhardt
Unused since 4624656797b667eb6405186682eb04e74dfd90fd.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mqc.h| 3 ---
 libavcodec/mqcenc.c | 5 -
 2 files changed, 8 deletions(-)

diff --git a/libavcodec/mqc.h b/libavcodec/mqc.h
index 8bf7223d41..73604d5efe 100644
--- a/libavcodec/mqc.h
+++ b/libavcodec/mqc.h
@@ -54,9 +54,6 @@ void ff_mqc_initenc(MqcState *mqc, uint8_t *bp);
 /** code bit d with context cx */
 void ff_mqc_encode(MqcState *mqc, uint8_t *cxstate, int d);
 
-/** number of encoded bytes */
-int ff_mqc_length(MqcState *mqc);
-
 /** flush the encoder [returns number of bytes encoded] */
 int ff_mqc_flush(MqcState *mqc);
 int ff_mqc_flush_to(MqcState *mqc, uint8_t *dst, int *dst_len);
diff --git a/libavcodec/mqcenc.c b/libavcodec/mqcenc.c
index 7c9e1a0df9..c941f849d9 100644
--- a/libavcodec/mqcenc.c
+++ b/libavcodec/mqcenc.c
@@ -102,11 +102,6 @@ void ff_mqc_encode(MqcState *mqc, uint8_t *cxstate, int d)
 }
 }
 
-int ff_mqc_length(MqcState *mqc)
-{
-return mqc->bp - mqc->bpstart;
-}
-
 int ff_mqc_flush(MqcState *mqc)
 {
 setbits(mqc);
-- 
2.27.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 02/15] avcodec/ac3tab: Remove unused ff_eac3_default_chmap

2021-02-18 Thread Andreas Rheinhardt
Added in 0c79b1402a48a99f32435a0f5ad2364c58c6fcf3 to use it a function
that was never used and was itself removed in
676f1f533e2c2960d81784188592a066b9ff1c3d.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ac3tab.c | 13 -
 libavcodec/ac3tab.h |  1 -
 2 files changed, 14 deletions(-)

diff --git a/libavcodec/ac3tab.c b/libavcodec/ac3tab.c
index 99307218cc..1dcaa0e977 100644
--- a/libavcodec/ac3tab.c
+++ b/libavcodec/ac3tab.c
@@ -263,19 +263,6 @@ const uint16_t ff_ac3_fast_gain_tab[8]= {
 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400,
 };
 
-/**
- * Default channel map for a dependent substream defined by acmod
- */
-const uint16_t ff_eac3_default_chmap[8] = {
-AC3_CHMAP_L |   AC3_CHMAP_R, // FIXME Ch1+Ch2
-  AC3_CHMAP_C,
-AC3_CHMAP_L |   AC3_CHMAP_R,
-AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R,
-AC3_CHMAP_L |   AC3_CHMAP_R |   
AC3_CHMAP_C_SUR,
-AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R |   
AC3_CHMAP_C_SUR,
-AC3_CHMAP_L |   AC3_CHMAP_R | AC3_CHMAP_L_SUR |
  AC3_CHMAP_R_SUR,
-AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R | AC3_CHMAP_L_SUR |
  AC3_CHMAP_R_SUR
-};
 const uint64_t ff_eac3_custom_channel_map_locations[16][2] = {
 { 1, AV_CH_FRONT_LEFT },
 { 1, AV_CH_FRONT_CENTER },
diff --git a/libavcodec/ac3tab.h b/libavcodec/ac3tab.h
index a0036a301b..081a5906fb 100644
--- a/libavcodec/ac3tab.h
+++ b/libavcodec/ac3tab.h
@@ -46,7 +46,6 @@ extern const uint16_t ff_ac3_slow_gain_tab[4];
 extern const uint16_t ff_ac3_db_per_bit_tab[4];
 extern const int16_t  ff_ac3_floor_tab[8];
 extern const uint16_t ff_ac3_fast_gain_tab[8];
-extern const uint16_t ff_eac3_default_chmap[8];
 extern const uint8_t  ff_ac3_band_start_tab[AC3_CRITICAL_BANDS+1];
 extern const uint8_t  ff_ac3_bin_to_band_tab[253];
 extern const uint64_t ff_eac3_custom_channel_map_locations[16][2];
-- 
2.27.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 01/15] avformat/asf: Move ff_asf_audio_conceal_none to its only user

2021-02-18 Thread Andreas Rheinhardt
It is only used inside code guarded by #ifdef DEBUG, i.e. it is normally
unused.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/asf.c  | 6 --
 libavformat/asf.h  | 1 -
 libavformat/asfdec_f.c | 8 +++-
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/libavformat/asf.c b/libavformat/asf.c
index 719cae9da5..f1f171e6f6 100644
--- a/libavformat/asf.c
+++ b/libavformat/asf.c
@@ -40,12 +40,6 @@ const ff_asf_guid ff_asf_audio_stream = {
 0x40, 0x9E, 0x69, 0xF8, 0x4D, 0x5B, 0xCF, 0x11, 0xA8, 0xFD, 0x00, 0x80, 
0x5F, 0x5C, 0x44, 0x2B
 };
 
-const ff_asf_guid ff_asf_audio_conceal_none = {
-// 0x40, 0xa4, 0xf1, 0x49, 0x4ece, 0x11d0, 0xa3, 0xac, 0x00, 0xa0, 0xc9, 
0x03, 0x48, 0xf6
-// New value lifted from avifile
-0x00, 0x57, 0xfb, 0x20, 0x55, 0x5B, 0xCF, 0x11, 0xa8, 0xfd, 0x00, 0x80, 
0x5f, 0x5c, 0x44, 0x2b
-};
-
 const ff_asf_guid ff_asf_audio_conceal_spread = {
 0x50, 0xCD, 0xC3, 0xBF, 0x8F, 0x61, 0xCF, 0x11, 0x8B, 0xB2, 0x00, 0xAA, 
0x00, 0xB4, 0xE2, 0x20
 };
diff --git a/libavformat/asf.h b/libavformat/asf.h
index a30d3bb23b..bce820efae 100644
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -74,7 +74,6 @@ extern const ff_asf_guid ff_asf_file_header;
 extern const ff_asf_guid ff_asf_stream_header;
 extern const ff_asf_guid ff_asf_ext_stream_header;
 extern const ff_asf_guid ff_asf_audio_stream;
-extern const ff_asf_guid ff_asf_audio_conceal_none;
 extern const ff_asf_guid ff_asf_audio_conceal_spread;
 extern const ff_asf_guid ff_asf_video_stream;
 extern const ff_asf_guid ff_asf_jfif_media;
diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index b584f60195..1484b544d9 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -143,6 +143,12 @@ static const ff_asf_guid stream_bitrate_guid = { /* 
(http://get.to/sdp) */
 0xce, 0x75, 0xf8, 0x7b, 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 
0x97, 0xc9, 0xa2, 0xb2
 };
 
+static const ff_asf_guid asf_audio_conceal_none = {
+// 0x40, 0xa4, 0xf1, 0x49, 0x4ece, 0x11d0, 0xa3, 0xac, 0x00, 0xa0, 0xc9, 
0x03, 0x48, 0xf6
+// New value lifted from avifile
+0x00, 0x57, 0xfb, 0x20, 0x55, 0x5B, 0xCF, 0x11, 0xa8, 0xfd, 0x00, 0x80, 
0x5f, 0x5c, 0x44, 0x2b
+};
+
 #define PRINT_IF_GUID(g, cmp) \
 if (!ff_guidcmp(g, )) \
 av_log(NULL, AV_LOG_TRACE, "(GUID: %s) ", # cmp)
@@ -154,7 +160,7 @@ static void print_guid(ff_asf_guid *g)
 else PRINT_IF_GUID(g, ff_asf_file_header);
 else PRINT_IF_GUID(g, ff_asf_stream_header);
 else PRINT_IF_GUID(g, ff_asf_audio_stream);
-else PRINT_IF_GUID(g, ff_asf_audio_conceal_none);
+else PRINT_IF_GUID(g, asf_audio_conceal_none);
 else PRINT_IF_GUID(g, ff_asf_video_stream);
 else PRINT_IF_GUID(g, ff_asf_video_conceal_none);
 else PRINT_IF_GUID(g, ff_asf_command_stream);
-- 
2.27.0

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

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

[FFmpeg-devel] [PATCH 4/4] libavfilter: add filter dnn_detect for object detection

2021-02-18 Thread Guo, Yejun
Below are the example steps to do object detection:

1. download and install l_openvino_toolkit_p_2021.1.110.tgz from
https://software.intel.com/content/www/us/en/develop/tools/openvino-toolkit/download.html
  or, we can get source code (tag 2021.1), build and install.
2. export LD_LIBRARY_PATH with openvino settings, for example:
.../deployment_tools/inference_engine/lib/intel64/:.../deployment_tools/inference_engine/external/tbb/lib/
3. rebuild ffmpeg from source code with configure option:
--enable-libopenvino
--extra-cflags='-I.../deployment_tools/inference_engine/include/'
--extra-ldflags='-L.../deployment_tools/inference_engine/lib/intel64'
4. download model files and test image
wget 
https://github.com/guoyejun/ffmpeg_dnn/raw/main/models/openvino/2021.1/face-detection-adas-0001.bin
wget 
https://github.com/guoyejun/ffmpeg_dnn/raw/main/models/openvino/2021.1/face-detection-adas-0001.xml
wget
https://github.com/guoyejun/ffmpeg_dnn/raw/main/models/openvino/2021.1/face-detection-adas-0001.label
wget https://github.com/guoyejun/ffmpeg_dnn/raw/main/images/cici.jpg
5. run ffmpeg with:
./ffmpeg -i cici.jpg -vf 
dnn_detect=dnn_backend=openvino:model=face-detection-adas-0001.xml:input=data:output=detection_out:confidence=0.6:labels=face-detection-adas-0001.label,showinfo
 -f null -

We'll see the detect result as below:
[Parsed_showinfo_1 @ 0x55817e43ce40]   side data - bounding boxes:
[Parsed_showinfo_1 @ 0x55817e43ce40] source: face-detection-adas-0001.xml
[Parsed_showinfo_1 @ 0x55817e43ce40] index: 0, region: (1005, 813) -> (1086, 
905), label: face, confidence: 1/1.
[Parsed_showinfo_1 @ 0x55817e43ce40] index: 1, region: (888, 839) -> (967, 
926), label: face, confidence: 6917/1.

There are two faces detected with confidence 100% and 69.17%.

Signed-off-by: Guo, Yejun 
---
 configure  |   1 +
 doc/filters.texi   |  40 +++
 libavfilter/Makefile   |   1 +
 libavfilter/allfilters.c   |   1 +
 libavfilter/dnn/dnn_backend_openvino.c |  12 +
 libavfilter/dnn_filter_common.c|   7 +
 libavfilter/dnn_filter_common.h|   1 +
 libavfilter/dnn_interface.h|   6 +-
 libavfilter/vf_dnn_detect.c| 425 +
 9 files changed, 492 insertions(+), 2 deletions(-)
 create mode 100644 libavfilter/vf_dnn_detect.c

diff --git a/configure b/configure
index 336301cb40..cdac292c2f 100755
--- a/configure
+++ b/configure
@@ -3549,6 +3549,7 @@ derain_filter_select="dnn"
 deshake_filter_select="pixelutils"
 deshake_opencl_filter_deps="opencl"
 dilation_opencl_filter_deps="opencl"
+dnn_detect_filter_select="dnn"
 dnn_processing_filter_select="dnn"
 drawtext_filter_deps="libfreetype"
 drawtext_filter_suggest="libfontconfig libfribidi"
diff --git a/doc/filters.texi b/doc/filters.texi
index 426cb158da..55368c6f1b 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -10133,6 +10133,46 @@ ffmpeg -i INPUT -f lavfi -i 
nullsrc=hd720,geq='r=128+80*(sin(sqrt((X-W/2)*(X-W/2
 @end example
 @end itemize
 
+@section dnn_detect
+
+Do object detection with deep neural networks.
+
+The filter accepts the following options:
+
+@table @option
+@item dnn_backend
+Specify which DNN backend to use for model loading and execution. This option 
accepts
+only openvino now, tensorflow backends will be added.
+
+@item model
+Set path to model file specifying network architecture and its parameters.
+Note that different backends use different file formats.
+
+@item input
+Set the input name of the dnn network.
+
+@item output
+Set the output name of the dnn network.
+
+@item confidence
+Set the confidence threshold (default: 0.5).
+
+@item labels
+Set path to label file specifying the mapping between label id and name.
+Each label name is written in one line, tailing spaces and empty lines are 
skipped.
+The first line is the name of label id 0 (usually it is 'background'),
+and the second line is the name of label id 1, etc.
+The label id is considered as name if the label file is not provided.
+
+@item backend_configs
+Set the configs to be passed into backend
+
+@item async
+use DNN async execution if set (default: set),
+roll back to sync execution if the backend does not support async.
+
+@end table
+
 @anchor{dnn_processing}
 @section dnn_processing
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 359ea7f903..b14c0ecdb9 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -245,6 +245,7 @@ OBJS-$(CONFIG_DILATION_FILTER)   += 
vf_neighbor.o
 OBJS-$(CONFIG_DILATION_OPENCL_FILTER)+= vf_neighbor_opencl.o opencl.o \
 opencl/neighbor.o
 OBJS-$(CONFIG_DISPLACE_FILTER)   += vf_displace.o framesync.o
+OBJS-$(CONFIG_DNN_DETECT_FILTER) += vf_dnn_detect.o
 OBJS-$(CONFIG_DNN_PROCESSING_FILTER) += vf_dnn_processing.o
 OBJS-$(CONFIG_DOUBLEWEAVE_FILTER)+= vf_weave.o
 

[FFmpeg-devel] [PATCH 3/4] libavfilter: show side data of bounding box

2021-02-18 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
 libavfilter/f_sidedata.c  |  2 ++
 libavfilter/vf_showinfo.c | 38 ++
 2 files changed, 40 insertions(+)

diff --git a/libavfilter/f_sidedata.c b/libavfilter/f_sidedata.c
index 3757723375..912fb0d881 100644
--- a/libavfilter/f_sidedata.c
+++ b/libavfilter/f_sidedata.c
@@ -71,6 +71,7 @@ static const AVOption filt_name##_options[] = { \
 {   "S12M_TIMECOD",   "", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_S12M_TIMECODE  }, 0, 0, FLAGS, "type" }, \
 {   "DYNAMIC_HDR_PLUS",   "", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_DYNAMIC_HDR_PLUS   }, 0, 0, FLAGS, "type" }, \
 {   "REGIONS_OF_INTEREST","", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_REGIONS_OF_INTEREST}, 0, 0, FLAGS, "type" }, \
+{   "BOUNDING_BOXES", "", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_BOUNDING_BOXES }, 0, 0, FLAGS, "type" }, \
 {   "SEI_UNREGISTERED",   "", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_SEI_UNREGISTERED   }, 0, 0, FLAGS, "type" }, \
 { NULL } \
 }
@@ -100,6 +101,7 @@ static const AVOption filt_name##_options[] = { \
 {   "S12M_TIMECOD",   "", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_S12M_TIMECODE  }, 0, 0, FLAGS, "type" }, \
 {   "DYNAMIC_HDR_PLUS",   "", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_DYNAMIC_HDR_PLUS   }, 0, 0, FLAGS, "type" }, \
 {   "REGIONS_OF_INTEREST","", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_REGIONS_OF_INTEREST}, 0, 0, FLAGS, "type" }, \
+{   "BOUNDING_BOXES", "", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_BOUNDING_BOXES }, 0, 0, FLAGS, "type" }, \
 {   "SEI_UNREGISTERED",   "", 0, AV_OPT_TYPE_CONST,  
{.i64 = AV_FRAME_DATA_SEI_UNREGISTERED   }, 0, 0, FLAGS, "type" }, \
 { NULL } \
 }
diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 6208892005..f23518fdd5 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -38,6 +38,7 @@
 #include "libavutil/timecode.h"
 #include "libavutil/mastering_display_metadata.h"
 #include "libavutil/video_enc_params.h"
+#include "bbox.h"
 
 #include "avfilter.h"
 #include "internal.h"
@@ -153,6 +154,40 @@ static void dump_roi(AVFilterContext *ctx, const 
AVFrameSideData *sd)
 }
 }
 
+static void dump_boundingbox(AVFilterContext *ctx, const AVFrameSideData *sd)
+{
+int nb_bbox;
+const BoundingBoxHeader *header;
+const BoundingBox *bbox;
+uint32_t bbox_size, array_size;
+
+header = (const BoundingBoxHeader *)sd->data;
+bbox_size = header->bbox_size;
+array_size = sd->size - sizeof(*header);
+if (!bbox_size || array_size % bbox_size != 0 || bbox_size != 
sizeof(*bbox)) {
+av_log(ctx, AV_LOG_ERROR, "Invalid BoundingBoxHeader.bbox_size.\n");
+return;
+}
+
+nb_bbox = array_size / bbox_size;
+bbox = (const BoundingBox *)(header + 1);
+
+av_log(ctx, AV_LOG_INFO, "bounding boxes:\n");
+av_log(ctx, AV_LOG_INFO, "source: %s\n", header->source);
+for (int i = 0; i < nb_bbox; i++) {
+av_log(ctx, AV_LOG_INFO, "index: %d, region: (%d, %d) -> (%d, %d), 
label: %s, confidence: %d/%d.\n",
+ i, bbox->left, bbox->top, bbox->right, 
bbox->bottom,
+ bbox->detect_label, 
bbox->detect_confidence.num, bbox->detect_confidence.den);
+if (bbox->classify_count > 0) {
+for (int j = 0; j < bbox->classify_count; j++) {
+av_log(ctx, AV_LOG_INFO, "\t\tclassify:  label: %s, 
confidence: %d/%d.\n",
+   bbox->classify_labels[j], 
bbox->classify_confidences[j].num, bbox->classify_confidences[j].den);
+}
+}
+bbox++;
+}
+}
+
 static void dump_mastering_display(AVFilterContext *ctx, const AVFrameSideData 
*sd)
 {
 const AVMasteringDisplayMetadata *mastering_display;
@@ -494,6 +529,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 case AV_FRAME_DATA_REGIONS_OF_INTEREST:
 dump_roi(ctx, sd);
 break;
+case AV_FRAME_DATA_BOUNDING_BOXES:
+dump_boundingbox(ctx, sd);
+break;
 case AV_FRAME_DATA_MASTERING_DISPLAY_METADATA:
 dump_mastering_display(ctx, sd);
 break;
-- 
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/4] libavutil: add side data AV_FRAME_DATA_BOUNDING_BOXES

2021-02-18 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
 doc/APIchanges  | 2 ++
 libavutil/frame.c   | 1 +
 libavutil/frame.h   | 7 +++
 libavutil/version.h | 2 +-
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index c353d2d281..3c6e9e351e 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,8 @@ libavutil: 2017-10-21
 
 
 API changes, most recent first:
+2021-02-xx - xx - lavu 56.xx.100 - frame.h
+  Add AV_FRAME_DATA_BOUNDING_BOXES
 
 2021-02-14 - xx - lavd 58.12.100 - avdevice.h
   Deprecated avdevice_capabilities_create() and
diff --git a/libavutil/frame.c b/libavutil/frame.c
index eab51b6a32..53868a2410 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -852,6 +852,7 @@ const char *av_frame_side_data_name(enum 
AVFrameSideDataType type)
 case AV_FRAME_DATA_VIDEO_ENC_PARAMS:return "Video encoding 
parameters";
 case AV_FRAME_DATA_SEI_UNREGISTERED:return "H.26[45] User Data 
Unregistered SEI message";
 case AV_FRAME_DATA_FILM_GRAIN_PARAMS:   return "Film grain 
parameters";
+case AV_FRAME_DATA_BOUNDING_BOXES:  return "Bounding boxes";
 }
 return NULL;
 }
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 1aeafef6de..e213e0a646 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -198,6 +198,13 @@ enum AVFrameSideDataType {
  * Must be present for every frame which should have film grain applied.
  */
 AV_FRAME_DATA_FILM_GRAIN_PARAMS,
+
+/**
+ * Bounding boxes for object detection and classification, the data is a 
BoundingBoxHeader
+ * followed with an array of BoudingBox, the number of array element is 
implied by
+ * (AVFrameSideData.size - sizeof(BoundingBoxHeader)) / 
BoundingBoxHeader.bbox_size.
+ */
+AV_FRAME_DATA_BOUNDING_BOXES,
 };
 
 enum AVActiveFormatDescription {
diff --git a/libavutil/version.h b/libavutil/version.h
index b2165754f9..b7c5892a37 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  65
+#define LIBAVUTIL_VERSION_MINOR  66
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 1/4] libavfilter/bbox.h: add BoundingBoxHeader and BoundingBox

2021-02-18 Thread Guo, Yejun
They will be used for filters such as detect and classify.

Signed-off-by: Guo, Yejun 
---
 libavfilter/bbox.h | 45 +
 1 file changed, 45 insertions(+)

diff --git a/libavfilter/bbox.h b/libavfilter/bbox.h
index 116158d59e..7c63dfa727 100644
--- a/libavfilter/bbox.h
+++ b/libavfilter/bbox.h
@@ -22,6 +22,51 @@
 #define AVFILTER_BBOX_H
 
 #include 
+#include "libavutil/rational.h"
+
+typedef struct BoundingBoxHeader {
+/*
+ * Information about how the bounding box is generated.
+ * for example, the DNN model name.
+ */
+char source[128];
+
+/* Must be set to the size of BoundingBox (that is,
+ * sizeof(BoundingBox)).
+ */
+uint32_t bbox_size;
+} BoundingBoxHeader;
+
+typedef struct BoundingBox {
+/**
+ * Distance in pixels from the top edge of the frame to top
+ * and bottom, and from the left edge of the frame to left and
+ * right, defining the bounding box.
+ */
+int top;
+int left;
+int bottom;
+int right;
+
+#define BBOX_LABEL_NAME_MAX_LENGTH 32
+
+/**
+ * Detect result with confidence
+ */
+char detect_label[BBOX_LABEL_NAME_MAX_LENGTH+1];
+AVRational detect_confidence;
+
+/**
+ * At most 4 classifications based on the detected bounding box.
+ * For example, we can get max 4 different attributes with 4 different
+ * DNN models on one bounding box.
+ * classify_count is zero if no classification.
+ */
+#define AV_NUM_BBOX_CLASSIFY 4
+uint32_t classify_count;
+char classify_labels[AV_NUM_BBOX_CLASSIFY][BBOX_LABEL_NAME_MAX_LENGTH+1];
+AVRational classify_confidences[AV_NUM_BBOX_CLASSIFY];
+} BoundingBox;
 
 typedef struct FFBoundingBox {
 int x1, x2, y1, y2;
-- 
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 4/4] avutil/mips: Use $at as MMI macro temporary register

2021-02-18 Thread Jiaxun Yang
Some function had exceed 30 inline assembly register oprands limiation
when using LOONGSON2 version of MMI macros. We can avoid that by take
$at, which is register reserved for assembler, as temporary register.

As none of instructions used in these macros is pseudo, it is safe to
utilize $at here.

Signed-off-by: Jiaxun Yang 
---
 libavutil/mips/mmiutils.h | 115 +++---
 1 file changed, 69 insertions(+), 46 deletions(-)

diff --git a/libavutil/mips/mmiutils.h b/libavutil/mips/mmiutils.h
index 3994085057..7b7b405ddf 100644
--- a/libavutil/mips/mmiutils.h
+++ b/libavutil/mips/mmiutils.h
@@ -27,78 +27,107 @@
 #include "config.h"
 #include "libavutil/mips/asmdefs.h"
 
-#if HAVE_LOONGSON2
+/* 
+ * These were used to define temporary registers for MMI marcos
+ * however now we're using $at. They're theoretically unnecessary
+ * but just leave them here to avoid mess.
+ */
+#define DECLARE_VAR_LOW32
+#define RESTRICT_ASM_LOW32
+#define DECLARE_VAR_ALL64
+#define RESTRICT_ASM_ALL64
+#define DECLARE_VAR_ADDRT
+#define RESTRICT_ASM_ADDRT
 
-#define DECLARE_VAR_LOW32   int32_t low32
-#define RESTRICT_ASM_LOW32  [low32]"="(low32),
-#define DECLARE_VAR_ALL64   int64_t all64
-#define RESTRICT_ASM_ALL64  [all64]"="(all64),
-#define DECLARE_VAR_ADDRT   mips_reg addrt
-#define RESTRICT_ASM_ADDRT  [addrt]"="(addrt),
+#if HAVE_LOONGSON2
 
 #define MMI_LWX(reg, addr, stride, bias)\
-PTR_ADDU"%[addrt],  "#addr","#stride"   \n\t"   \
-"lw "#reg", "#bias"(%[addrt])   \n\t"
+".set noat \n\t"   \
+PTR_ADDU"$at,  "#addr","#stride"   \n\t"   \
+"lw "#reg", "#bias"($at)   \n\t"   \
+".set at   \n\t"
 
 #define MMI_SWX(reg, addr, stride, bias)\
-PTR_ADDU"%[addrt],  "#addr","#stride"   \n\t"   \
-"sw "#reg", "#bias"(%[addrt])   \n\t"
+".set noat \n\t"   \
+PTR_ADDU"$at,  "#addr","#stride"   \n\t"   \
+"sw "#reg", "#bias"($at)   \n\t"   \
+".set at   \n\t"
 
 #define MMI_LDX(reg, addr, stride, bias)\
-PTR_ADDU"%[addrt],  "#addr","#stride"   \n\t"   \
-"ld "#reg", "#bias"(%[addrt])   \n\t"
+".set noat \n\t"   \
+PTR_ADDU"$at,  "#addr","#stride"   \n\t"   \
+"ld "#reg", "#bias"($at)   \n\t"   \
+".set at   \n\t"
 
 #define MMI_SDX(reg, addr, stride, bias)\
-PTR_ADDU"%[addrt],  "#addr","#stride"   \n\t"   \
-"sd "#reg", "#bias"(%[addrt])   \n\t"
+".set noat \n\t"   \
+PTR_ADDU"$at,  "#addr","#stride"   \n\t"   \
+"sd "#reg", "#bias"($at)   \n\t"   \
+".set at   \n\t"
 
 #define MMI_LWC1(fp, addr, bias)\
 "lwc1   "#fp",  "#bias"("#addr")\n\t"
 
 #define MMI_LWLRC1(fp, addr, bias, off) \
-"lwl%[low32],   "#bias"+"#off"("#addr") \n\t"   \
-"lwr%[low32],   "#bias"("#addr")\n\t"   \
-"mtc1   %[low32],   "#fp"   \n\t"
+".set noat \n\t"   \
+"lwl$at,   "#bias"+"#off"("#addr") \n\t"   \
+"lwr$at,   "#bias"("#addr")\n\t"   \
+"mtc1   $at,   "#fp"   \n\t"   \
+".set at   \n\t"
 
 #define MMI_LWXC1(fp, addr, stride, bias)   \
-PTR_ADDU"%[addrt],  "#addr","#stride"   \n\t"   \
-MMI_LWC1(fp, %[addrt], bias)
+".set noat \n\t"   \
+PTR_ADDU"$at,  "#addr","#stride"   \n\t"   \
+MMI_LWC1(fp, $at, bias)\
+".set at   \n\t"
 
 #define MMI_SWC1(fp, addr, bias)\
 "swc1   "#fp",  "#bias"("#addr")\n\t"
 
 #define 

[FFmpeg-devel] [PATCH 3/4] avcodec/mips: Use MMI marcos to replace Loongson3 instructions

2021-02-18 Thread Jiaxun Yang
Loongson3's extention instructions (prefixed with gs) are widely used
in our MMI codebase. However, these instructions are not avilable on
Loongson-2E/F while MMI code should work on these processors.

Previously we introduced mmiutils marcos to provide backward compactbility
but newly commited code didn't follow that. In this patch I revewed the
codebase and converted all these instructions into MMI marcos to get
Loongson2 supproted again.

Signed-off-by: Jiaxun Yang 
---
 libavcodec/mips/h264chroma_mmi.c  |  26 +++-
 libavcodec/mips/h264dsp_mmi.c |   8 +-
 libavcodec/mips/hevcdsp_mmi.c | 251 --
 libavcodec/mips/hpeldsp_mmi.c |   1 +
 libavcodec/mips/simple_idct_mmi.c |  49 +++---
 libavcodec/mips/vp3dsp_idct_mmi.c |  11 +-
 libavcodec/mips/vp8dsp_mmi.c  | 100 +---
 libavcodec/mips/vp9_mc_mmi.c  | 128 ++-
 8 files changed, 245 insertions(+), 329 deletions(-)

diff --git a/libavcodec/mips/h264chroma_mmi.c b/libavcodec/mips/h264chroma_mmi.c
index 739dd7d4d6..b6ea1ba3b1 100644
--- a/libavcodec/mips/h264chroma_mmi.c
+++ b/libavcodec/mips/h264chroma_mmi.c
@@ -32,6 +32,7 @@ void ff_put_h264_chroma_mc8_mmi(uint8_t *dst, uint8_t *src, 
ptrdiff_t stride,
 int A = 64, B, C, D, E;
 double ftmp[12];
 uint64_t tmp[1];
+DECLARE_VAR_ALL64;
 
 if (!(x || y)) {
 /* x=0, y=0, A=64 */
@@ -57,7 +58,8 @@ void ff_put_h264_chroma_mc8_mmi(uint8_t *dst, uint8_t *src, 
ptrdiff_t stride,
 MMI_SDC1(%[ftmp3], %[dst], 0x00)
 PTR_ADDU   "%[dst], %[dst], %[stride]  \n\t"
 "bnez   %[h],   1b \n\t"
-: [ftmp0]"="(ftmp[0]),[ftmp1]"="(ftmp[1]),
+: RESTRICT_ASM_ALL64
+  [ftmp0]"="(ftmp[0]),[ftmp1]"="(ftmp[1]),
   [ftmp2]"="(ftmp[2]),[ftmp3]"="(ftmp[3]),
   [dst]"+"(dst),  [src]"+"(src),
   [h]"+"(h)
@@ -152,7 +154,8 @@ void ff_put_h264_chroma_mc8_mmi(uint8_t *dst, uint8_t *src, 
ptrdiff_t stride,
 MMI_SDC1(%[ftmp3], %[dst], 0x00)
 PTR_ADDU   "%[dst], %[dst], %[stride]  \n\t"
 "bnez   %[h],   1b \n\t"
-: [ftmp0]"="(ftmp[0]),[ftmp1]"="(ftmp[1]),
+: RESTRICT_ASM_ALL64
+  [ftmp0]"="(ftmp[0]),[ftmp1]"="(ftmp[1]),
   [ftmp2]"="(ftmp[2]),[ftmp3]"="(ftmp[3]),
   [ftmp4]"="(ftmp[4]),[ftmp5]"="(ftmp[5]),
   [ftmp6]"="(ftmp[6]),[ftmp7]"="(ftmp[7]),
@@ -203,7 +206,8 @@ void ff_put_h264_chroma_mc8_mmi(uint8_t *dst, uint8_t *src, 
ptrdiff_t stride,
 MMI_SDC1(%[ftmp1], %[dst], 0x00)
 PTR_ADDU   "%[dst], %[dst], %[stride]  \n\t"
 "bnez   %[h],   1b \n\t"
-: [ftmp0]"="(ftmp[0]),[ftmp1]"="(ftmp[1]),
+: RESTRICT_ASM_ALL64
+  [ftmp0]"="(ftmp[0]),[ftmp1]"="(ftmp[1]),
   [ftmp2]"="(ftmp[2]),[ftmp3]"="(ftmp[3]),
   [ftmp4]"="(ftmp[4]),[ftmp5]"="(ftmp[5]),
   [ftmp6]"="(ftmp[6]),[ftmp7]"="(ftmp[7]),
@@ -272,7 +276,8 @@ void ff_put_h264_chroma_mc8_mmi(uint8_t *dst, uint8_t *src, 
ptrdiff_t stride,
 MMI_SDC1(%[ftmp2], %[dst], 0x00)
 PTR_ADDU   "%[dst], %[dst], %[stride]  \n\t"
 "bnez   %[h],   1b \n\t"
-: [ftmp0]"="(ftmp[0]),[ftmp1]"="(ftmp[1]),
+: RESTRICT_ASM_ALL64
+  [ftmp0]"="(ftmp[0]),[ftmp1]"="(ftmp[1]),
   [ftmp2]"="(ftmp[2]),[ftmp3]"="(ftmp[3]),
   [ftmp4]"="(ftmp[4]),[ftmp5]"="(ftmp[5]),
   [ftmp6]"="(ftmp[6]),[ftmp7]"="(ftmp[7]),
@@ -293,6 +298,7 @@ void ff_avg_h264_chroma_mc8_mmi(uint8_t *dst, uint8_t *src, 
ptrdiff_t stride,
 int A = 64, B, C, D, E;
 double ftmp[10];
 uint64_t tmp[1];
+DECLARE_VAR_ALL64;
 
 if(!(x || y)){
 /* x=0, y=0, A=64 */
@@ -314,7 +320,8 @@ void ff_avg_h264_chroma_mc8_mmi(uint8_t *dst, uint8_t *src, 
ptrdiff_t stride,
 PTR_ADDU   "%[dst], %[dst], %[stride]   \n\t"
 "addi   %[h],   %[h],   -0x02   \n\t"
 "bnez   %[h],   1b  \n\t"
-: [ftmp0]"="(ftmp[0]),[ftmp1]"="(ftmp[1]),
+: RESTRICT_ASM_ALL64
+  [ftmp0]"="(ftmp[0]),[ftmp1]"="(ftmp[1]),
   [ftmp2]"="(ftmp[2]),[ftmp3]"="(ftmp[3]),
   [dst]"+"(dst),  [src]"+"(src),
   [h]"+"(h)
@@ -378,7 +385,8 @@ void ff_avg_h264_chroma_mc8_mmi(uint8_t *dst, uint8_t *src, 
ptrdiff_t stride,
 MMI_SDC1(%[ftmp1], %[dst], 0x00)

[FFmpeg-devel] [PATCH 2/4] avutil/mips: Extract load store with shift C1 pair marco

2021-02-18 Thread Jiaxun Yang
We're doing some fancy hacks with load store with shift C1
beside unaligned load store. Create a marco for l/r pair
to allow us use it in these places.

Signed-off-by: Jiaxun Yang 
---
 libavutil/mips/mmiutils.h | 49 ---
 1 file changed, 30 insertions(+), 19 deletions(-)

diff --git a/libavutil/mips/mmiutils.h b/libavutil/mips/mmiutils.h
index fb85a4dd1b..3994085057 100644
--- a/libavutil/mips/mmiutils.h
+++ b/libavutil/mips/mmiutils.h
@@ -55,8 +55,9 @@
 #define MMI_LWC1(fp, addr, bias)\
 "lwc1   "#fp",  "#bias"("#addr")\n\t"
 
-#define MMI_ULWC1(fp, addr, bias)   \
-"ulw%[low32],   "#bias"("#addr")\n\t"   \
+#define MMI_LWLRC1(fp, addr, bias, off) \
+"lwl%[low32],   "#bias"+"#off"("#addr") \n\t"   \
+"lwr%[low32],   "#bias"("#addr")\n\t"   \
 "mtc1   %[low32],   "#fp"   \n\t"
 
 #define MMI_LWXC1(fp, addr, stride, bias)   \
@@ -66,9 +67,10 @@
 #define MMI_SWC1(fp, addr, bias)\
 "swc1   "#fp",  "#bias"("#addr")\n\t"
 
-#define MMI_USWC1(fp, addr, bias)   \
+#define MMI_SWLRC1(fp, addr, bias, off)
   \
 "mfc1   %[low32],   "#fp"   \n\t"   \
-"usw%[low32],   "#bias"("#addr")\n\t"
+"swl%[low32],   "#bias"+"#off"("#addr") \n\t"   \
+"swr%[low32],   "#bias"("#addr")\n\t"
 
 #define MMI_SWXC1(fp, addr, stride, bias)   \
 PTR_ADDU"%[addrt],  "#addr","#stride"   \n\t"   \
@@ -77,8 +79,9 @@
 #define MMI_LDC1(fp, addr, bias)\
 "ldc1   "#fp",  "#bias"("#addr")\n\t"
 
-#define MMI_ULDC1(fp, addr, bias)   \
-"uld%[all64],   "#bias"("#addr")\n\t"   \
+#define MMI_LDLRC1(fp, addr, bias, off) \
+"ldl%[all64],   "#bias"+"#off"("#addr") \n\t"   \
+"ldr%[all64],   "#bias"("#addr")\n\t"   \
 "dmtc1  %[all64],   "#fp"   \n\t"
 
 #define MMI_LDXC1(fp, addr, stride, bias)   \
@@ -88,9 +91,10 @@
 #define MMI_SDC1(fp, addr, bias)\
 "sdc1   "#fp",  "#bias"("#addr")\n\t"
 
-#define MMI_USDC1(fp, addr, bias)   \
+#define MMI_SDLRC1(fp, addr, bias, off)
   \
 "dmfc1  %[all64],   "#fp"   \n\t"   \
-"usd%[all64],   "#bias"("#addr")\n\t"
+"sdl%[all64],   "#bias"+"#off"("#addr") \n\t"   \
+"sdr%[all64],   "#bias"("#addr")\n\t"
 
 #define MMI_SDXC1(fp, addr, stride, bias)   \
 PTR_ADDU"%[addrt],  "#addr","#stride"   \n\t"   \
@@ -139,17 +143,18 @@
 #define DECLARE_VAR_LOW32   int32_t low32
 #define RESTRICT_ASM_LOW32  [low32]"="(low32),
 
-#define MMI_ULWC1(fp, addr, bias)   \
-"ulw%[low32],   "#bias"("#addr")\n\t"   \
-"mtc1   %[low32],   "#fp"   \n\t"
+#define MMI_LWLRC1(fp, addr, bias, off) \
+"lwl%[low32],   "#bias"+"#off"("#addr") \n\t"   \
+"lwr%[low32],   "#bias"("#addr")\n\t"   \
+"mtc1   %[low32],   "#fp"  \n\t"
 
 #else /* _MIPS_SIM != _ABIO32 */
 
 #define DECLARE_VAR_LOW32
 #define RESTRICT_ASM_LOW32
 
-#define MMI_ULWC1(fp, addr, bias)   \
-"gslwlc1"#fp",3+"#bias"("#addr")\n\t"   \
+#define MMI_LWLRC1(fp, addr, bias, off) \
+"gslwlc1"#fp",  "#off"+"#bias"("#addr") \n\t"   \
 "gslwrc1"#fp",  "#bias"("#addr")\n\t"
 
 #endif /* _MIPS_SIM != _ABIO32 */
@@ -160,8 +165,8 @@
 #define MMI_SWC1(fp, addr, bias)\
 "swc1   "#fp",  "#bias"("#addr")\n\t"
 
-#define MMI_USWC1(fp, addr, bias)   \
-

[FFmpeg-devel] [PATCH 1/4] avutil/mips: Use MMI_{L, S}QC1 macro in {SAVE, RECOVER}_REG

2021-02-18 Thread Jiaxun Yang
{SAVE,RECOVER}_REG will be avilable for Loongson2 again,
also comment about the magic.

Signed-off-by: Jiaxun Yang 
---
 libavutil/mips/mmiutils.h | 32 +---
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/libavutil/mips/mmiutils.h b/libavutil/mips/mmiutils.h
index 8f692e86c5..fb85a4dd1b 100644
--- a/libavutil/mips/mmiutils.h
+++ b/libavutil/mips/mmiutils.h
@@ -202,25 +202,27 @@
 #endif /* HAVE_LOONGSON2 */
 
 /**
- * backup register
+ * Backup saved registers
+ * We're not using compiler's clobber list as it's not smart enough
+ * to take advantage of quad word load/store.
  */
 #define BACKUP_REG \
   LOCAL_ALIGNED_16(double, temp_backup_reg, [8]);   \
   if (_MIPS_SIM == _ABI64)  \
 __asm__ volatile (  \
-  "gssqc1   $f25,  $f24,   0x00(%[temp])  \n\t" \
-  "gssqc1   $f27,  $f26,   0x10(%[temp])  \n\t" \
-  "gssqc1   $f29,  $f28,   0x20(%[temp])  \n\t" \
-  "gssqc1   $f31,  $f30,   0x30(%[temp])  \n\t" \
+  MMI_SQC1($f25, $f24, %[temp], 0x00)   \
+  MMI_SQC1($f27, $f26, %[temp], 0x10)   \
+  MMI_SQC1($f29, $f28, %[temp], 0x20)   \
+  MMI_SQC1($f31, $f30, %[temp], 0x30)   \
   : \
   : [temp]"r"(temp_backup_reg)  \
   : "memory"\
 );  \
   else  \
 __asm__ volatile (  \
-  "gssqc1   $f22,  $f20,   0x00(%[temp])  \n\t" \
-  "gssqc1   $f26,  $f24,   0x10(%[temp])  \n\t" \
-  "gssqc1   $f30,  $f28,   0x20(%[temp])  \n\t" \
+  MMI_SQC1($f22, $f20, %[temp], 0x10)   \
+  MMI_SQC1($f26, $f24, %[temp], 0x10)   \
+  MMI_SQC1($f30, $f28, %[temp], 0x20)   \
   : \
   : [temp]"r"(temp_backup_reg)  \
   : "memory"\
@@ -232,19 +234,19 @@
 #define RECOVER_REG \
   if (_MIPS_SIM == _ABI64)  \
 __asm__ volatile (  \
-  "gslqc1   $f25,  $f24,   0x00(%[temp])  \n\t" \
-  "gslqc1   $f27,  $f26,   0x10(%[temp])  \n\t" \
-  "gslqc1   $f29,  $f28,   0x20(%[temp])  \n\t" \
-  "gslqc1   $f31,  $f30,   0x30(%[temp])  \n\t" \
+  MMI_LQC1($f25, $f24, %[temp], 0x00)   \
+  MMI_LQC1($f27, $f26, %[temp], 0x10)   \
+  MMI_LQC1($f29, $f28, %[temp], 0x20)   \
+  MMI_LQC1($f31, $f30, %[temp], 0x30)   \
   : \
   : [temp]"r"(temp_backup_reg)  \
   : "memory"\
 );  \
   else  \
 __asm__ volatile (  \
-  "gslqc1   $f22,  $f20,   0x00(%[temp])  \n\t" \
-  "gslqc1   $f26,  $f24,   0x10(%[temp])  \n\t" \
-  "gslqc1   $f30,  $f28,   0x20(%[temp])  \n\t" \
+  MMI_LQC1($f22, $f20, %[temp], 0x10)   \
+  MMI_LQC1($f26, $f24, %[temp], 0x10)   \
+  MMI_LQC1($f30, $f28, %[temp], 0x20)   \
   : \
   : [temp]"r"(temp_backup_reg)  \
   : "memory"\
-- 
2.30.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 0/4] avcodec Loongson-2 MMI fixes

2021-02-18 Thread Jiaxun Yang
Get MMI optimizations build for Loongson-2 again.
Tested on Loongson-2 and Loongson-3A.

Jiaxun Yang (4):
  avutil/mips: Use MMI_{L,S}QC1 macro in {SAVE,RECOVER}_REG
  avutil/mips: Extract load store with shift C1 pair marco
  avcodec/mips: Use MMI marcos to replace Loongson3 instructions
  avutil/mips: Use $at as MMI macro temporary register

 libavcodec/mips/h264chroma_mmi.c  |  26 +++-
 libavcodec/mips/h264dsp_mmi.c |   8 +-
 libavcodec/mips/hevcdsp_mmi.c | 251 --
 libavcodec/mips/hpeldsp_mmi.c |   1 +
 libavcodec/mips/simple_idct_mmi.c |  49 +++---
 libavcodec/mips/vp3dsp_idct_mmi.c |  11 +-
 libavcodec/mips/vp8dsp_mmi.c  | 100 +---
 libavcodec/mips/vp9_mc_mmi.c  | 128 ++-
 libavutil/mips/mmiutils.h | 174 +
 9 files changed, 350 insertions(+), 398 deletions(-)

-- 
2.30.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] libavcodec/qsvdec: skip non-key frame after "seek" function

2021-02-18 Thread wenbin . chen
From: "Chen,Wenbin" 

Fix #9095. Qsv decoder assume that after calling seek funcion, the first
frame should be key frame. However this is not true for some videos. If
the frame is not key frame after seek(), there will be error. Conditional
statements are added to skip these frame until reading a key frame.

Signed-off-by: Wenbin Chen 
---
 libavcodec/qsvdec.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index d10f90a0db..8133406085 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -616,6 +616,13 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext 
*q,
 }
 
 if (!q->initialized) {
+
+/*  skip non-key frame when decoder is reinitialized. 
+Adding before will skip all the non-key frames so add 
+it here */
+if (ret < 0)
+return ret;
+
 ret = qsv_decode_init_context(avctx, q, );
 if (ret < 0)
 goto reinit_fail;
-- 
2.25.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 v6 3/9] avformat: add vvc raw demux

2021-02-18 Thread Nuo Mi
>
>
>
> > All h266 conformance test clips will not detect as other formats. But if
> > you have a well-designed clip, it may be. This is normal case for a raw
> > bytestream detector.
>
> I'm mainly asking because the H.264 probe function does check some PS IDs
> to have a bit more confidence that it is looking at an H.264 stream.
>
> If the collision cases are rare such that they will never overlap except
> with crafted streams then this is probably fine.
>
H.264 and H.265's seq_parameter_set_id are ue(v). So you can check the max
value.
But for H.266, the sps_seq_parameter_set_id is u(4). and the range is 0 to
15. It's no way to check it's valid or not.
We can check sps_pic_width_max_in_luma_samples
and sps_pic_height_max_in_luma_samples, but it's not so meanful.


> - Mark
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@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 4/4] avcodec/x86: add cfhdenc SIMD

2021-02-18 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/cfhdencdsp.c  |   3 +
 libavcodec/x86/Makefile  |   2 +
 libavcodec/x86/cfhdencdsp.asm| 426 +++
 libavcodec/x86/cfhdencdsp_init.c |  46 
 4 files changed, 477 insertions(+)
 create mode 100644 libavcodec/x86/cfhdencdsp.asm
 create mode 100644 libavcodec/x86/cfhdencdsp_init.c

diff --git a/libavcodec/cfhdencdsp.c b/libavcodec/cfhdencdsp.c
index 0becb76d1d..b979e9e09a 100644
--- a/libavcodec/cfhdencdsp.c
+++ b/libavcodec/cfhdencdsp.c
@@ -73,4 +73,7 @@ av_cold void ff_cfhdencdsp_init(CFHDEncDSPContext *c)
 {
 c->horiz_filter = horiz_filter;
 c->vert_filter = vert_filter;
+
+if (ARCH_X86)
+ff_cfhdencdsp_init_x86(c);
 }
diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
index 884dc0c759..6361161180 100644
--- a/libavcodec/x86/Makefile
+++ b/libavcodec/x86/Makefile
@@ -51,6 +51,7 @@ OBJS-$(CONFIG_ALAC_DECODER)+= x86/alacdsp_init.o
 OBJS-$(CONFIG_APNG_DECODER)+= x86/pngdsp_init.o
 OBJS-$(CONFIG_CAVS_DECODER)+= x86/cavsdsp.o
 OBJS-$(CONFIG_CFHD_DECODER)+= x86/cfhddsp_init.o
+OBJS-$(CONFIG_CFHD_ENCODER)+= x86/cfhdencdsp_init.o
 OBJS-$(CONFIG_DCA_DECODER) += x86/dcadsp_init.o 
x86/synth_filter_init.o
 OBJS-$(CONFIG_DNXHD_ENCODER)   += x86/dnxhdenc_init.o
 OBJS-$(CONFIG_EXR_DECODER) += x86/exrdsp_init.o
@@ -154,6 +155,7 @@ X86ASM-OBJS-$(CONFIG_ADPCM_G722_ENCODER) += x86/g722dsp.o
 X86ASM-OBJS-$(CONFIG_ALAC_DECODER) += x86/alacdsp.o
 X86ASM-OBJS-$(CONFIG_APNG_DECODER) += x86/pngdsp.o
 X86ASM-OBJS-$(CONFIG_CAVS_DECODER) += x86/cavsidct.o
+X86ASM-OBJS-$(CONFIG_CFHD_ENCODER) += x86/cfhdencdsp.o
 X86ASM-OBJS-$(CONFIG_CFHD_DECODER) += x86/cfhddsp.o
 X86ASM-OBJS-$(CONFIG_DCA_DECODER)  += x86/dcadsp.o x86/synth_filter.o
 X86ASM-OBJS-$(CONFIG_DIRAC_DECODER)+= x86/diracdsp.o\
diff --git a/libavcodec/x86/cfhdencdsp.asm b/libavcodec/x86/cfhdencdsp.asm
new file mode 100644
index 00..2fb4744345
--- /dev/null
+++ b/libavcodec/x86/cfhdencdsp.asm
@@ -0,0 +1,426 @@
+;**
+;* x86-optimized functions for the CFHD encoder
+;* Copyright (c) 2021 Paul B Mahol
+;*
+;* 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 "libavutil/x86/x86util.asm"
+
+SECTION_RODATA
+
+pw_p1_n1:  dw  1, -1, 1, -1, 1, -1, 1, -1
+pw_n1_p1:  dw  -1, 1, -1, 1, -1, 1, -1, 1
+pw_p5_n11: dw  5, -11, 5, -11, 5, -11, 5, -11
+pw_n5_p11: dw -5, 11, -5, 11, -5, 11, -5, 11
+pw_p11_n5: dw 11, -5, 11, -5, 11, -5, 11, -5
+pw_n11_p5: dw -11, 5, -11, 5, -11, 5, -11, 5
+pd_4:  times 4 dd  4
+pw_p4: times 8 dw  4
+pw_n4: times 8 dw -4
+pw_p1: times 8 dw  1
+pw_n1: times 8 dw -1
+
+SECTION .text
+
+INIT_XMM sse2
+%if ARCH_X86_64
+cglobal cfhdenc_horiz_filter, 8, 11, 12, input, low, high, istride, lwidth, 
hwidth, width, height, x, y, temp
+movyd, heightd
+shl  istrided, 1
+shl   lwidthd, 1
+shl   hwidthd, 1
+negyq
+%else
+cglobal cfhdenc_horiz_filter, 7, 7, 8, input, x, low, y, high, temp, width, 
height
+TODO
+%endif
+.looph:
+movsx  xq, word [inputq]
+
+movsx   tempq, word [inputq + 2]
+add tempq, xq
+
+movd  xm0, tempd
+packssdw   m0, m0
+pextrw  tempd, xm0, 0
+mov   word [lowq], tempw
+
+movsx  xq, word [inputq]
+imul   xq, 5
+movsx   tempq, word [inputq + 2]
+imultempq, -11
+add tempq, xq
+
+movsx  xq, word [inputq + 4]
+imul   xq, 4
+add tempq, xq
+
+movsx  xq, word [inputq + 6]
+imul   xq, 4
+add tempq, xq
+
+movsx  xq, word [inputq + 8]
+imul   xq, -1
+add tempq, xq
+
+movsx  xq, word [inputq + 10]
+imul   xq, -1
+add tempq, xq
+
+add tempq, 4
+sar tempq, 3
+
+movd  xm0, tempd
+packssdw   m0, m0
+pextrw  tempd, xm0, 0
+mov  word [highq], tempw
+
+movxq, 2
+
+.loopw:
+

Re: [FFmpeg-devel] [RFC] Event loop

2021-02-18 Thread Lynne
Feb 18, 2021, 16:43 by geo...@nsup.org:

> Lynne (12021-02-17):
>
>> It's more actively developed by a large margin, and I generally
>>
>
> This is an interesting argument.
>
>> prefer its API and how it works internally.
>>
>
> Can you give more details? Which differences make you prefer it?
>
> One of the things that I like about libev is that it makes effort to be
> efficient and simple in terms of allocating data structures. No such
> thing as always dynamically allocating stuff like the Gnome projects, so
> much that it looks more like Java than C. We can have the libev
> structures directly in our own data structures.
>
> Is libuv similar in that respect?
>
> The fact that it is designed to run the interpreter of a language with a
> garbage collector worries me.
>

I found this document useful:
https://gist.github.com/andreybolonin/2413da76f088e2c5ab04df53f07659ea

Although it's main user was node.js, it's now used in dozens upon dozens
of different non-language projects, some of which get featured here:
https://github.com/libuv/libuv/wiki/Projects-that-use-libuv

It also has plenty of bindings, so projects don't have to invent their
own C bindings.
Most high-level users have long since moved to asynchronous event
processing on threads, so having a synchronous single-threaded
implementation seems like somewhat behind with the times.

___
ffmpeg-devel mailing list
ffmpeg-devel@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/4] avcodec/cfhdenc: do not try to encode junk

2021-02-18 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/cfhdenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/cfhdenc.c b/libavcodec/cfhdenc.c
index 9c8ba3700c..b2993cf2a9 100644
--- a/libavcodec/cfhdenc.c
+++ b/libavcodec/cfhdenc.c
@@ -742,7 +742,7 @@ static int cfhd_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 
 for (int m = 0; m < height; m++) {
 for (int j = 0; j < stride; j++) {
-int16_t index = FFSIGN(data[j]) * lut[FFABS(data[j])];
+int16_t index = j >= width ? 0 : FFSIGN(data[j]) * 
lut[FFABS(data[j])];
 
 if (index < 0)
 index += 512;
-- 
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/4] avcodec/cfhdenc: add padding to each decomposition

2021-02-18 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/cfhdenc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/cfhdenc.c b/libavcodec/cfhdenc.c
index 1e89ffc41c..9c8ba3700c 100644
--- a/libavcodec/cfhdenc.c
+++ b/libavcodec/cfhdenc.c
@@ -270,10 +270,10 @@ static av_cold int cfhd_encode_init(AVCodecContext *avctx)
 int width  = i ? avctx->width >> s->chroma_h_shift : avctx->width;
 int height = i ? FFALIGN(avctx->height >> s->chroma_v_shift, 8) :
  FFALIGN(avctx->height >> s->chroma_v_shift, 8);
-ptrdiff_t stride = FFALIGN(width / 8, 8) * 8;
+ptrdiff_t stride = (FFALIGN(width / 8, 8) + 64) * 8;
 
-w8 = FFALIGN(width / 8, 8);
-h8 = height / 8;
+w8 = FFALIGN(width / 8, 8) + 64;
+h8 = FFALIGN(height, 8) / 8;
 w4 = w8 * 2;
 h4 = h8 * 2;
 w2 = w4 * 2;
-- 
2.17.1

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

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

[FFmpeg-devel] [PATCH 1/4] avcodec/cfhdenc: refactor DSP code for CFHD encoder

2021-02-18 Thread Paul B Mahol
This is needed to implement x86 SIMD.

Signed-off-by: Paul B Mahol 
---
 libavcodec/Makefile |   2 +-
 libavcodec/cfhdenc.c| 123 +++-
 libavcodec/cfhdencdsp.c |  76 +
 libavcodec/cfhdencdsp.h |  41 ++
 4 files changed, 151 insertions(+), 91 deletions(-)
 create mode 100644 libavcodec/cfhdencdsp.c
 create mode 100644 libavcodec/cfhdencdsp.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 53d164e83e..6a57ddf2b1 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -259,7 +259,7 @@ OBJS-$(CONFIG_CDGRAPHICS_DECODER)  += cdgraphics.o
 OBJS-$(CONFIG_CDTOONS_DECODER) += cdtoons.o
 OBJS-$(CONFIG_CDXL_DECODER)+= cdxl.o
 OBJS-$(CONFIG_CFHD_DECODER)+= cfhd.o cfhddata.o cfhddsp.o
-OBJS-$(CONFIG_CFHD_ENCODER)+= cfhdenc.o cfhddata.o
+OBJS-$(CONFIG_CFHD_ENCODER)+= cfhdenc.o cfhddata.o cfhdencdsp.o
 OBJS-$(CONFIG_CINEPAK_DECODER) += cinepak.o
 OBJS-$(CONFIG_CINEPAK_ENCODER) += cinepakenc.o elbg.o
 OBJS-$(CONFIG_CLEARVIDEO_DECODER)  += clearvideo.o
diff --git a/libavcodec/cfhdenc.c b/libavcodec/cfhdenc.c
index 5554baefa3..1e89ffc41c 100644
--- a/libavcodec/cfhdenc.c
+++ b/libavcodec/cfhdenc.c
@@ -33,6 +33,7 @@
 #include "avcodec.h"
 #include "bytestream.h"
 #include "cfhd.h"
+#include "cfhdencdsp.h"
 #include "put_bits.h"
 #include "internal.h"
 #include "thread.h"
@@ -239,6 +240,8 @@ typedef struct CFHDEncContext {
 Runbook  rb[321];
 Codebook cb[513];
 int16_t *alpha;
+
+CFHDEncDSPContext dsp;
 } CFHDEncContext;
 
 static av_cold int cfhd_encode_init(AVCodecContext *avctx)
@@ -359,6 +362,8 @@ static av_cold int cfhd_encode_init(AVCodecContext *avctx)
 s->lut[i] = last;
 }
 
+ff_cfhdencdsp_init(>dsp);
+
 if (s->planes != 4)
 return 0;
 
@@ -369,42 +374,6 @@ static av_cold int cfhd_encode_init(AVCodecContext *avctx)
 return 0;
 }
 
-static av_always_inline void filter(int16_t *input, ptrdiff_t in_stride,
-  int16_t *low, ptrdiff_t low_stride,
-  int16_t *high, ptrdiff_t high_stride,
-  int len)
-{
-low[(0>>1) * low_stride]   = av_clip_int16(input[0*in_stride] + 
input[1*in_stride]);
-high[(0>>1) * high_stride] = av_clip_int16((5 * input[0*in_stride] - 11 * 
input[1*in_stride] +
-4 * input[2*in_stride] +  4 * 
input[3*in_stride] -
-1 * input[4*in_stride] -  1 * 
input[5*in_stride] + 4) >> 3);
-
-for (int i = 2; i < len - 2; i += 2) {
-low[(i>>1) * low_stride]   = av_clip_int16(input[i*in_stride] + 
input[(i+1)*in_stride]);
-high[(i>>1) * high_stride] = av_clip_int16(((-input[(i-2)*in_stride] - 
input[(i-1)*in_stride] +
-  input[(i+2)*in_stride] + 
input[(i+3)*in_stride] + 4) >> 3) +
-  input[(i+0)*in_stride] - 
input[(i+1)*in_stride]);
-}
-
-low[((len-2)>>1) * low_stride]   = 
av_clip_int16(input[((len-2)+0)*in_stride] + input[((len-2)+1)*in_stride]);
-high[((len-2)>>1) * high_stride] = av_clip_int16((11* 
input[((len-2)+0)*in_stride] - 5 * input[((len-2)+1)*in_stride] -
-  4 * 
input[((len-2)-1)*in_stride] - 4 * input[((len-2)-2)*in_stride] +
-  1 * 
input[((len-2)-3)*in_stride] + 1 * input[((len-2)-4)*in_stride] + 4) >> 3);
-}
-
-static void horiz_filter(int16_t *input, int16_t *low, int16_t *high,
- int width)
-{
-filter(input, 1, low, 1, high, 1, width);
-}
-
-static void vert_filter(int16_t *input, ptrdiff_t in_stride,
-int16_t *low, ptrdiff_t low_stride,
-int16_t *high, ptrdiff_t high_stride, int len)
-{
-filter(input, in_stride, low, low_stride, high, high_stride, len);
-}
-
 static void quantize_band(int16_t *input, int width, int a_width,
   int height, unsigned quantization)
 {
@@ -454,6 +423,7 @@ static int cfhd_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
  const AVFrame *frame, int *got_packet)
 {
 CFHDEncContext *s = avctx->priv_data;
+CFHDEncDSPContext *dsp = >dsp;
 PutByteContext *pby = >pby;
 PutBitContext *pb = >pb;
 const Codebook *const cb = s->cb;
@@ -480,12 +450,9 @@ static int cfhd_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 in_stride = avctx->width;
 }
 
-for (int i = 0; i < height * 2; i++) {
-horiz_filter(input, low, high, width * 2);
-input += in_stride;
-low += a_width;
-high += a_width;
-}
+dsp->horiz_filter(input, low, high,
+  in_stride, a_width, a_width,
+ 

Re: [FFmpeg-devel] [PATCH] avcodec/videotoolboxenc: ignore encoded h264 SEI nalu by default

2021-02-18 Thread sharpbai
To Andreas Rheinhardt,

You are right. The last byte 0x80 is rbsp_trailing_bits.
Before macOS 11 there is no problem of the generated SEI.

To Rick Kern,

After macOS 11, the encoded SEI nalu length changes from 20
to 25, the following code should help you to confirm it.

Place these code to copy_replace_length_codes function,
after CMBlockBufferCopyDataBytes calling copy nalu data. 

```
if (nal_type == 6) {
char buf[1024] = {0};
int index = 0;
for(int i = 0; i < box_len; i++) {
index += sprintf(buf + index, "%.2x ", dst_box[i]);
}
av_log(avctx, AV_LOG_DEBUG, "Found sei nalu length: %zu value: 
%s\n", box_len, buf);
} else {
av_log(avctx, AV_LOG_DEBUG, "Found type %d nalu length: %zu\n", 
nal_type, box_len);
}
```

For example run this ffmpeg command

$ ffmpeg -f lavfi -i testsrc=d=5:s=1920x1080:r=24,format=yuv420p \
-ignore_internal_sei 0 -vcodec h264_videotoolbox -b:v 40m -y bar.h264

got a output like this

[h264_videotoolbox @ 0x7fa30d00ca00] Found sei nalu length: 25 value: 06 05 10 
b9 ed b9 30 5d 21 4b 71 83 71 2c 10 a3 14 bb 29 80 00 00 03 00 01
[h264_videotoolbox @ 0x7fa30d00ca00] Found type 5 nalu length: 135751

This proves that the last 5 bytes are added by videotoolboxenc.  


February 16, 2021 12:23 AM, "Rick Kern"  写到:

> On Mon, Feb 15, 2021 at 7:51 AM Andreas Rheinhardt <
> andreas.rheinha...@gmail.com> wrote:
> 
>> sharpbai:
>> Before macOS 11, the encoded h264 sample contains fixed SEI before
>> IDR frame, which the content is below
>> 
>> 06 05 10 b9 ed b9 30 5d 21 4b 71 83 71 2c 10 a3
>> 14 bb 29 80
>> 
>> The length of the encoded SEI nalu is 20 byte. According to
>> the ITU-T H.264 Recommendation section 7.3.2.3.1, the last byte
>> 0x80 means type. Then there is no length byte, which make the
>> SEI nonstandard.
>> 
>> Wrong:
>> 06: forbidden_zero_bit + nal_ref_idc + nal_unit_type (6 for SEI)
>> 05: payload type 5 (user data unregistered) SEI message
>> 10: length of this SEI message is 16
>> b9-29: the payload of this SEI message (the first 12 byte are an uuid,
>> the last are user_data_payload_byte)
>> 80: rbsp_trailing_bits: the first bit is rbsp_stop_one_bit (equal to
>> one), the remaining bits are padding (with value zero)
>> 
>> You can use trace_headers to inspect this.
>> 
>> (Notice that one needs to know the length of the NAL unit in advance
>> before one can start parsing it; how one gets it depends upon the
>> framing. There are two common methods for this: Annex B and mp4. The
>> former works by using start codes 0x00 00 01 to mark the beginning of a
>> new NAL, the latter prefixes the length of the NAL units to the units.)
>> 
>> On macOS 11, the encoded h264 sample still contains fixed SEI before
>> IDR frame, which length is 5 bytes longer than before.
>> 
>> 06 05 10 b9 ed b9 30 5d 21 4b 71 83 71 2c 10 a3
>> 14 bb 29 80 00 00 03 00 01
>> ^^ ^^ ^^ ^^ ^^
>> 
>> That looks as if there were a 00 00 00 01 startcode after the SEI that
>> some tool has tried to 0x03 escape. That is a bug. Can you share samples
>> containing these NAL units?
> 
> This file is inserting the emulation prevention byte 0x03. I can take a
> look later today.
> 
>> This time type the content of the SEI has type 0 payload but
>> invalid length payload data, which violates recommendation
>> appendix D.
>> 
>> Whether it is a bug or not, these SEI nalus should be erased to keep
>> the output bytestream not violating the standard. But we may
>> not come across the situration we do need these encoded SEI
>> nalu, so we just reserve a switch and set not to output by default.
>> 
>> Signed-off-by: sharpbai 
>> ---
>> libavcodec/videotoolboxenc.c | 51 +---
>> 1 file changed, 30 insertions(+), 21 deletions(-)
>> 
>> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
>> index cc08cf6a50..c240090f10 100644
>> --- a/libavcodec/videotoolboxenc.c
>> +++ b/libavcodec/videotoolboxenc.c
>> @@ -221,6 +221,7 @@ typedef struct VTEncContext {
>> 
>> int64_t allow_sw;
>> int64_t require_sw;
>> + int64_t ignore_internal_sei;
>> 
>> bool flushing;
>> bool has_b_frames;
>> @@ -1690,7 +1691,8 @@ static int copy_replace_length_codes(
>> CMSampleBufferRef sample_buffer,
>> ExtraSEI *sei,
>> uint8_t *dst_data,
>> - size_t dst_size)
>> + size_t dst_size,
>> + int ignore_internal_sei)
>> {
>> size_t src_size = CMSampleBufferGetTotalSampleSize(sample_buffer);
>> size_t remaining_src_size = src_size;
>> @@ -1707,8 +1709,8 @@ static int copy_replace_length_codes(
>> }
>> 
>> while (remaining_src_size > 0) {
>> - size_t curr_src_len;
>> - size_t curr_dst_len;
>> + size_t curr_src_len = 0;
>> + size_t curr_dst_len = 0;
>> size_t box_len = 0;
>> size_t i;
>> 
>> @@ -1740,7 +1742,8 @@ static int copy_replace_length_codes(
>> box_len |= size_buf[i];
>> }
>> 
>> - if (sei && !wrote_sei && is_post_sei_nal_type(nal_type)) {
>> + if 

Re: [FFmpeg-devel] [PATCH] Moves yuv2yuvX_sse3 to yasm, unrolls main loop and other small optimizations for ~20% speedup.

2021-02-18 Thread James Almer

On 2/17/2021 5:24 PM, Paul B Mahol wrote:

On Tue, Feb 16, 2021 at 6:31 PM Alan Kelly <
alankelly-at-google@ffmpeg.org> wrote:


Looks like there are no comments, is this OK to be applied? Thanks



Applied, thanks for pinging.


Valgrind complains about this change. The checkasm test specifically.

http://fate.ffmpeg.org/report.cgi?time=20210218014903=x86_64-archlinux-gcc-valgrind

I also noticed it has a bunch of unchecked av_mallocs().
___
ffmpeg-devel mailing list
ffmpeg-devel@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] [RFC] Event loop

2021-02-18 Thread Nicolas George
Mark Thompson (12021-02-18):
> I wrote the last packet a second ago and got a callback for
> writeability from the loop, but didn't have anything to write back
> then so I did nothing.
> 
> Now I have a packet to write, but the event loop is sitting idle in its 
> poll() call.
> 
> You've said I'm not allowed to interact with the loop from another
> thread, so how do I make the loop generate a callback so I can write
> something on the thread which is allowed to write?

Where does your packet come from? If it comes from inside the loop, then
there is no problem.

If it comes from another thread, that means your application either
requires a libavutil with a thread-capable event loop backend or must
provide one.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH v6 3/9] avformat: add vvc raw demux

2021-02-18 Thread Mark Thompson

On 18/02/2021 08:47, Nuo Mi wrote:

On Thu, Feb 18, 2021 at 6:52 AM Mark Thompson  wrote:

On 17/02/2021 01:51, Nuo Mi wrote:


+for (i = 0; i < p->buf_size - 1; i++) {
+code = (code << 8) + p->buf[i];
+if ((code & 0xff00) == 0x100) {
+uint8_t nal2 = p->buf[i + 1];
+int type = (nal2 & 0xF8) >> 3;
+
+if (code & 0xc0) // forbidden_zero_bit and

nuh_reserved_zero_bit

+return 0;
+
+if ((nal2 & 0x7) == 0) // nuh_temporal_id_plus1
+return 0;
+
+switch (type) {
+case VVC_SPS_NUT:   sps++;  break;
+case VVC_PPS_NUT:   pps++;  break;
+case VVC_IDR_N_LP:
+case VVC_IDR_W_RADL:
+case VVC_CRA_NUT:
+case VVC_GDR_NUT:   irap++; break;
+}
+}
+}
+
+if (sps && pps && irap)
+return AVPROBE_SCORE_EXTENSION + 1; // 1 more than .mpg


How well does this test fully distinguish from previous standards using
the same start code style?

(Can I have an H.264 or H.265 raw stream which passes this test?  Can an
H.266 stream ever pass the test for those codecs, implying we need to
update them?)


The nal_unit_type located in a different byte. When a H.265 bitstream
has nuh_layer_ids equal to  VVC_SPS_NUT,  VVC_PPS_NUT and  VVC_IDR_N_LP,
can pass the test. Vice versa
All h266 conformance test clips will not detect as other formats. But if
you have a well-designed clip, it may be. This is normal case for a raw
bytestream detector.


I'm mainly asking because the H.264 probe function does check some PS IDs to 
have a bit more confidence that it is looking at an H.264 stream.

If the collision cases are rare such that they will never overlap except with 
crafted streams then this is probably fine.

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@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] [RFC] Event loop

2021-02-18 Thread Mark Thompson

On 18/02/2021 21:44, Nicolas George wrote:

Mark Thompson (12021-02-18):

When is the callback for an output stream called?  What if it doesn't
have a packet available to write right now, but will do later?


It will be called when data has been written, of course. If there is no
data to write, the stream is just idle.


I wrote the last packet a second ago and got a callback for writeability from 
the loop, but didn't have anything to write back then so I did nothing.

Now I have a packet to write, but the event loop is sitting idle in its poll() 
call.

You've said I'm not allowed to interact with the loop from another thread, so 
how do I make the loop generate a callback so I can write something on the 
thread which is allowed to write?

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@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 v6 4/9] avcodec: add cbs for h266/vvc

2021-02-18 Thread Mark Thompson

On 18/02/2021 15:20, Nuo Mi wrote:



+return AVERROR(ENOMEM);
+}
+h266->ph = (H266RawPH*)h266->ph_ref->data;
+memcpy(h266->ph, >sh_picture_header,

sizeof(H266RawPH));

This memcpy() is naughty - if that was a ref to a previous picture header
then you've just overwritten the reference while the other unit still holds
it.

If the slice is unit->content then unit->content_ref is a reference to a
superstructure of the picture header, avoiding the copy, but I'm not sure
it's the right way to do it.

Is it right that the two possible options here are:
* Store a ref, which might be to a newly-allocated buffer or might be to
a previous unit.


* Store the whole structure in the private context.



?


If the structure isn't too large, then the second option feels much
simpler.

If it is large such that holding references and avoiding copies is
beneficial (which is quite large, every ref entails a malloc/free
call-pair), then we probably want that ref to always be to the unit?


If we store the whole structure, it's hard to detect the picture header
missing case.


Also, if we use this as start point of the native decoder, the native
decoder may need ref the picture header for multi-thread decoding.


I think it would be reffing all of the units of the picture, which would 
include the picture header.

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@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 v6 4/9] avcodec: add cbs for h266/vvc

2021-02-18 Thread Mark Thompson

On 18/02/2021 15:14, Nuo Mi wrote:

On Thu, Feb 18, 2021 at 8:04 AM Mark Thompson  wrote:


On 17/02/2021 01:51, Nuo Mi wrote:

---
   configure |2 +
   libavcodec/Makefile   |1 +
   libavcodec/cbs.c  |6 +
   libavcodec/cbs_h2645.c|  541 -
   libavcodec/cbs_h266.h |  817 +++
   libavcodec/cbs_h266_syntax_template.c | 3006 +
   libavcodec/cbs_internal.h |3 +-
   libavcodec/cbs_sei.c  |   29 +
   8 files changed, 4397 insertions(+), 8 deletions(-)
   create mode 100644 libavcodec/cbs_h266.h
   create mode 100644 libavcodec/cbs_h266_syntax_template.c

...
@@ -1327,7 +1717,7 @@ static int

cbs_h2645_assemble_fragment(CodedBitstreamContext *ctx,

   {
   uint8_t *data;
   size_t max_size, dp, sp;
-int err, i, zero_run;
+int err, i, zero_run, h266_au_start = 0;

   for (i = 0; i < frag->nb_units; i++) {
   // Data should already all have been written when we get here.
@@ -1343,7 +1733,10 @@ static int

cbs_h2645_assemble_fragment(CodedBitstreamContext *ctx,

   data = av_realloc(NULL, max_size + AV_INPUT_BUFFER_PADDING_SIZE);
   if (!data)
   return AVERROR(ENOMEM);
-
+if (ctx->codec->codec_id == AV_CODEC_ID_VVC) {
+CodedBitstreamH266Context *h266 = ctx->priv_data;
+h266_au_start = h266_is_au_start(h266, frag, ctx->log_ctx) > 0;
+}


It is unclear to me why this wants a special case.

The current logic is that we are writing an AU, so the first NAL unit in
it is necessarily an AU start and subsequent NAL units are not?


H.266 AU contains one or more PU(3.105). One PU contains one coded picture.
Only the first NAL unit of an AU needs the zero_byte(B.2.2)
H.265 has no PU, each AU has one coded picture(3.1)
H.266's PU is the H.265's AU. In vvc_parser, we split bitstream to PU.


Er, I don't think this is right: an AVPacket should contain all of the pictures 
for a single timestamp - a decoder can then output at most one picture from it, 
for the selected spatial layer.

Though I don't know how the container formats are defined here, for other 
codecs having multiple packets with the same timestamps causes ugly problems in 
muxing/demuxing which we avoid by saying you aren't allowed to do that.

(See AV1, which has the same features.)


   dp = 0;
   for (i = 0; i < frag->nb_units; i++) {
   CodedBitstreamUnit *unit = >units[i];
@@ -1356,7 +1749,7 @@ static int

cbs_h2645_assemble_fragment(CodedBitstreamContext *ctx,

   frag->data_bit_padding = unit->data_bit_padding;
   }

-if (cbs_h2645_unit_requires_zero_byte(ctx->codec->codec_id,

unit->type, i)) {

+if (cbs_h2645_unit_requires_zero_byte(ctx->codec->codec_id,

unit->type, i, h266_au_start)) {

   // zero_byte
   data[dp++] = 0;
   }
@@ -1470,6 +1863,37 @@ static void cbs_h265_close(CodedBitstreamContext

*ctx)

   av_buffer_unref(>pps_ref[i]);
   }

...
+static int FUNC(ph)(CodedBitstreamContext *ctx, RWContext *rw,

H266RawPH *current)

+{
+int err;
+
+HEADER("Picture Header");
+
+CHECK(FUNC(nal_unit_header)(ctx, rw, >nal_unit_header,

VVC_PH_NUT));

+CHECK(FUNC(picture_header)(ctx, rw, current));
+CHECK(FUNC(rbsp_trailing_bits)(ctx, rw));
+return 0;
+}
+
+static int FUNC(slice_header)(CodedBitstreamContext *ctx, RWContext *rw,
+  H266RawSliceHeader *current)
+{
+CodedBitstreamH266Context *h266 = ctx->priv_data;
+const H266RawSPS *sps;
+const H266RawPPS *pps;
+const H266RawPH  *ph;
+const H266RefPicLists *ref_pic_lists;
+int  err, i;
+uint8_t  nal_unit_type, qp_bd_offset;
+uint16_t curr_subpic_idx;
+uint16_t num_slices_in_subpic;
+
+HEADER("Slice Header");
+
+CHECK(FUNC(nal_unit_header)(ctx, rw, >nal_unit_header,

-1));

+
+flag(sh_picture_header_in_slice_header_flag);
+if (current->sh_picture_header_in_slice_header_flag){
+CHECK(FUNC(picture_header)(ctx, rw,

>sh_picture_header));

+if (!h266->ph_ref) {
+h266->ph_ref = av_buffer_allocz(sizeof(H266RawPH));
+if (!h266->ph_ref)
+return AVERROR(ENOMEM);
+}
+h266->ph = (H266RawPH*)h266->ph_ref->data;
+memcpy(h266->ph, >sh_picture_header,

sizeof(H266RawPH));

This memcpy() is naughty - if that was a ref to a previous picture header
then you've just overwritten the reference while the other unit still holds
it.

If the slice is unit->content then unit->content_ref is a reference to a
superstructure of the picture header, avoiding the copy, but I'm not sure
it's the right way to do it.

Is it right that the two possible options here are:
* Store a ref, which might be to a newly-allocated buffer or might be to a
previous unit.


* Store the whole structure in the private context.



?


If the 

Re: [FFmpeg-devel] [PATCH v5] avcodec/libvpxenc: optimize parsing vpx_svc_ref_frame_config

2021-02-18 Thread Wonkap Jang
On Thu, Feb 18, 2021 at 1:26 PM James Zern 
wrote:

> On Thu, Feb 18, 2021 at 11:01 AM Wonkap Jang
>  wrote:
> >
> > Getting rid of unnecessary use of AVDictionary object in parsing
> > vpx_svc_ref_frame_config.
> > ---
> >  libavcodec/libvpxenc.c | 73 +++---
> >  1 file changed, 55 insertions(+), 18 deletions(-)
> >
>
> lgtm, just a couple of cosmetics I addressed locally. I'll submit this
> soon. Thanks for the suggestions Nicolas.
>
> > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> > index 284cb9a108..dfa0763fff 100644
> > --- a/libavcodec/libvpxenc.c
> > +++ b/libavcodec/libvpxenc.c
> > @@ -42,6 +42,7 @@
> >  #include "libavutil/mathematics.h"
> >  #include "libavutil/opt.h"
> >  #include "libavutil/pixdesc.h"
> > +#include "libavutil/avstring.h"
> >
>
> This is already included, in general the includes can be sorted.
> Deleted locally.
>
> > [...]
> > -av_log(avctx, AV_LOG_WARNING,
> > -   "Error parsing option '%s = %s'.\n",
> > -   en2->key, en2->value);
> > +int ret;
> > +ret =
> vpx_parse_ref_frame_config(>ref_frame_config,
> > +
>  enccfg->ss_number_layers, en->value);
>
> I joined these two lines locally.
>
> > +if (ret < 0) {
> > +av_log(avctx, AV_LOG_WARNING,
> > +   "Error parsing ref_frame_config option
> %s.\n", en->value);
> > +return ret;
> >  }
> >
> >  codecctl_intp(avctx, VP9E_SET_SVC_REF_FRAME_CONFIG,
> (int *)>ref_frame_config);
> >  } else {
> >  av_log(avctx, AV_LOG_WARNING,
> > -   "Error using option ref-frame-config for a
> non-VP9 codec\n");
> > +   "Using option ref-frame-config for a non-VP9
> codec\n");
>
> I changed 'Using' to 'Ignoring' locally.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Thank you all.

Wonkap

>
___
ffmpeg-devel mailing list
ffmpeg-devel@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] [RFC] Event loop

2021-02-18 Thread Nicolas George
Mark Thompson (12021-02-18):
> When is the callback for an output stream called?  What if it doesn't
> have a packet available to write right now, but will do later?

It will be called when data has been written, of course. If there is no
data to write, the stream is just idle.

> I think this means that integration with most external libraries (and
> non-network things) will not be possible, then.

I am sure this is entirely the opposite.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH v5] avcodec/libvpxenc: optimize parsing vpx_svc_ref_frame_config

2021-02-18 Thread James Zern
On Thu, Feb 18, 2021 at 11:01 AM Wonkap Jang
 wrote:
>
> Getting rid of unnecessary use of AVDictionary object in parsing
> vpx_svc_ref_frame_config.
> ---
>  libavcodec/libvpxenc.c | 73 +++---
>  1 file changed, 55 insertions(+), 18 deletions(-)
>

lgtm, just a couple of cosmetics I addressed locally. I'll submit this
soon. Thanks for the suggestions Nicolas.

> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> index 284cb9a108..dfa0763fff 100644
> --- a/libavcodec/libvpxenc.c
> +++ b/libavcodec/libvpxenc.c
> @@ -42,6 +42,7 @@
>  #include "libavutil/mathematics.h"
>  #include "libavutil/opt.h"
>  #include "libavutil/pixdesc.h"
> +#include "libavutil/avstring.h"
>

This is already included, in general the includes can be sorted.
Deleted locally.

> [...]
> -av_log(avctx, AV_LOG_WARNING,
> -   "Error parsing option '%s = %s'.\n",
> -   en2->key, en2->value);
> +int ret;
> +ret = vpx_parse_ref_frame_config(>ref_frame_config,
> +   enccfg->ss_number_layers, 
> en->value);

I joined these two lines locally.

> +if (ret < 0) {
> +av_log(avctx, AV_LOG_WARNING,
> +   "Error parsing ref_frame_config option 
> %s.\n", en->value);
> +return ret;
>  }
>
>  codecctl_intp(avctx, VP9E_SET_SVC_REF_FRAME_CONFIG, (int 
> *)>ref_frame_config);
>  } else {
>  av_log(avctx, AV_LOG_WARNING,
> -   "Error using option ref-frame-config for a 
> non-VP9 codec\n");
> +   "Using option ref-frame-config for a non-VP9 
> codec\n");

I changed 'Using' to 'Ignoring' locally.
___
ffmpeg-devel mailing list
ffmpeg-devel@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] [RFC] Event loop

2021-02-18 Thread Mark Thompson

On 18/02/2021 20:55, Nicolas George wrote:

Mark Thompson (12021-02-18):

If the existing remote-socket-only poll is sufficent (so no local
events), then I think I have misunderstood your original definition of
the event loop because I was expecting that other threads would be
able to interact with it.


Threading is one of the goals, but not the main one. If it is available
on Unix only until somebody writes a little Windows code or unless one
use the external library, that is not an issue.


Would it be possible to add an example what you intend API use to
actually look like to your design summary?  (In loose pseudocode.)


loop = create_event_loop()
vid_st = create_rtp_stream(...)
aud_st = create_rtp_stream(...)
attach_to_loop(loop, vid_st)
attach_to_loop(loop, aud_st)
connect_callback(vid_st, video_callback)
connect_callback(aud_st, video_callback)
run_loop(loop)


The callback for an input stream is called when you receive something, sure.

When is the callback for an output stream called?  What if it doesn't have a 
packet available to write right now, but will do later?


libev does not implement enough Windows support to be used generally,
though it is sufficient if you know the event loop will never want to
interact with anything which is not a socket (it hacks up self-pipes
by connecting TCP sockets to random ports on localhost).


If it works...


I believe that libuv and libevent both implement it properly


That would be an argument for it. I am waiting for Lynne answer to my
request for details.


(Note in particular that this means essentially everything dealing
with sockets has to be delegated to the event library so that it can
deal with asynchronous calls internally, especially send()/recv()
calls.)


Using non-standard IO code and tying to the library is completely out of
the question.

I think this means that integration with most external libraries (and 
non-network things) will not be possible, then.

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@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] [RFC] Event loop

2021-02-18 Thread Nicolas George
Mark Thompson (12021-02-18):
> If the existing remote-socket-only poll is sufficent (so no local
> events), then I think I have misunderstood your original definition of
> the event loop because I was expecting that other threads would be
> able to interact with it.

Threading is one of the goals, but not the main one. If it is available
on Unix only until somebody writes a little Windows code or unless one
use the external library, that is not an issue.

> Would it be possible to add an example what you intend API use to
> actually look like to your design summary?  (In loose pseudocode.)

loop = create_event_loop()
vid_st = create_rtp_stream(...)
aud_st = create_rtp_stream(...)
attach_to_loop(loop, vid_st)
attach_to_loop(loop, aud_st)
connect_callback(vid_st, video_callback)
connect_callback(aud_st, video_callback)
run_loop(loop)

> libev does not implement enough Windows support to be used generally,
> though it is sufficient if you know the event loop will never want to
> interact with anything which is not a socket (it hacks up self-pipes
> by connecting TCP sockets to random ports on localhost).

If it works...

> I believe that libuv and libevent both implement it properly

That would be an argument for it. I am waiting for Lynne answer to my
request for details.

> (Note in particular that this means essentially everything dealing
> with sockets has to be delegated to the event library so that it can
> deal with asynchronous calls internally, especially send()/recv()
> calls.)

Using non-standard IO code and tying to the library is completely out of
the question.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [RFC] Event loop

2021-02-18 Thread Mark Thompson

On 18/02/2021 15:39, Nicolas George wrote:

Mark Thompson (12021-02-17):

I'm not sure you can avoid writing Windows code for this to work at
all, because I don't think poll() as we have now is sufficient to get
the functionality you want.


I'm sure I can avoid writing Windows code, because, as I have already
pointed, our current implementation already work using poll(). If it
currently works, I have no intention of breaking it, just reorganizing
it to make it work better and make easier to extend.


If the existing remote-socket-only poll is sufficent (so no local events), then 
I think I have misunderstood your original definition of the event loop because 
I was expecting that other threads would be able to interact with it.

Would it be possible to add an example what you intend API use to actually look 
like to your design summary?  (In loose pseudocode.)


I also worry that codifying something in this form is going to exclude
the possibility of getting a better result on Windows later, because
that wouldn't involve file descriptors or internals calling default
BSD send()/recv().


You have got it backwards: it will make the possibility of getting a
better result on Windows later easier, because it will make everything
modular.

In fact, libev and libuv already implement code specific to Windows, so
we get them for free as soon as we implement support for one of these
libraries.


libev does not implement enough Windows support to be used generally, though it 
is sufficient if you know the event loop will never want to interact with 
anything which is not a socket (it hacks up self-pipes by connecting TCP 
sockets to random ports on localhost).

I believe that libuv and libevent both implement it properly (I have no 
experience with libuv, but Lynne seems to be advocating for it), so I would 
strongly recommend starting your implementation using one of them in order to 
ensure that you don't end up tied to the Unix model in an unhelpful way.  (Note 
in particular that this means essentially everything dealing with sockets has 
to be delegated to the event library so that it can deal with asynchronous 
calls internally, especially send()/recv() calls.)

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@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] swscale/x86/swscale: fix mix of inline and external function definitions

2021-02-18 Thread James Almer

On 2/18/2021 11:41 AM, James Almer wrote:

This includes removing pointless static function forward declarations.

Signed-off-by: James Almer 
---
  libswscale/x86/swscale.c  | 40 ++-
  libswscale/x86/swscale_template.c |  1 -
  2 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index 316a824e87..12e7799d0f 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -63,16 +63,6 @@ DECLARE_ASM_ALIGNED(8, const uint64_t, ff_bgr2UVOffset) = 
0x8080808080808080ULL;
  DECLARE_ASM_ALIGNED(8, const uint64_t, ff_w)= 
0x0001000100010001ULL;
  
  
-#define YUV2YUVX_FUNC_DECL(opt)  \

-static void yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, const 
int16_t **src, \
-   uint8_t *dest, int dstW, \
-   const uint8_t *dither, int offset); \
-
-YUV2YUVX_FUNC_DECL(mmx)
-YUV2YUVX_FUNC_DECL(mmxext)
-YUV2YUVX_FUNC_DECL(sse3)
-YUV2YUVX_FUNC_DECL(avx2)
-
  //MMX versions
  #if HAVE_MMX_INLINE
  #undef RENAME
@@ -206,8 +196,8 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY)
  }
  }
  }
+#endif /* HAVE_INLINE_ASM */
  
-#if HAVE_MMXEXT

  #define YUV2YUVX_FUNC_MMX(opt, step)  \
  void ff_yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, int srcOffset, 
\
 uint8_t *dest, int dstW,  \
@@ -241,17 +231,19 @@ static void yuv2yuvX_ ##opt(const int16_t *filter, int 
filterSize, \
  return; \
  }
  
+#if HAVE_MMX_EXTERNAL

  YUV2YUVX_FUNC_MMX(mmx, 16)
+#endif
+#if HAVE_MMXEXT_EXTERNAL
  YUV2YUVX_FUNC_MMX(mmxext, 16)
+#endif
+#if HAVE_SSE3_EXTERNAL
  YUV2YUVX_FUNC(sse3, 32)
+#endif
  #if HAVE_AVX2_EXTERNAL
  YUV2YUVX_FUNC(avx2, 64)
  #endif
  
-#endif

-
-#endif /* HAVE_INLINE_ASM */
-
  #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
  void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
  SwsContext *c, int16_t *data, 
\
@@ -379,8 +371,22 @@ av_cold void ff_sws_init_swscale_x86(SwsContext *c)
  if (INLINE_MMXEXT(cpu_flags))
  sws_init_swscale_mmxext(c);
  #endif
-#if HAVE_SSSE3_EXTERNAL
-if (EXTERNAL_SSSE3(cpu_flags)) {
+#if HAVE_MMX_EXTERNAL
+if (EXTERNAL_MMX(cpu_flags)) {
+if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND)){
+c->yuv2planeX = yuv2yuvX_mmx;
+}
+}
+#endif
+#if HAVE_MMXEXT_EXTERNAL
+if (EXTERNAL_MMXEXT(cpu_flags)) {
+if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND)){
+c->yuv2planeX = yuv2yuvX_mmxext;
+}
+}
+#endif
+#if HAVE_SSE3_EXTERNAL
+if (EXTERNAL_SSE3(cpu_flags)) {
  if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND)){
  c->yuv2planeX = yuv2yuvX_sse3;
  }
diff --git a/libswscale/x86/swscale_template.c 
b/libswscale/x86/swscale_template.c
index cb33af97e4..97d8cae613 100644
--- a/libswscale/x86/swscale_template.c
+++ b/libswscale/x86/swscale_template.c
@@ -1435,7 +1435,6 @@ static av_cold void RENAME(sws_init_swscale)(SwsContext 
*c)
  }
  } else {
  c->use_mmx_vfilter= 1;
-c->yuv2planeX = RENAME(yuv2yuvX);
  if (!(c->flags & SWS_FULL_CHR_H_INT)) {
  switch (c->dstFormat) {
  case AV_PIX_FMT_RGB32:   c->yuv2packedX = 
RENAME(yuv2rgb32_X);   break;


Will apply soon as this fixes compilation with MSVC, where inline asm is 
not available.

___
ffmpeg-devel mailing list
ffmpeg-devel@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] avcodec/libvpxenc: optimize parsing vpx_svc_ref_frame_config

2021-02-18 Thread Nicolas George
Wonkap Jang (12021-02-18):
> Getting rid of unnecessary use of AVDictionary object in parsing
> vpx_svc_ref_frame_config.
> ---
>  libavcodec/libvpxenc.c | 73 +++---
>  1 file changed, 55 insertions(+), 18 deletions(-)

No more remarks from me. Thanks.

Regards,

-- 
  Nicolas George


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

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

[FFmpeg-devel] [PATCH v5] avcodec/libvpxenc: optimize parsing vpx_svc_ref_frame_config

2021-02-18 Thread Wonkap Jang
Getting rid of unnecessary use of AVDictionary object in parsing
vpx_svc_ref_frame_config.
---
 libavcodec/libvpxenc.c | 73 +++---
 1 file changed, 55 insertions(+), 18 deletions(-)

diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 284cb9a108..dfa0763fff 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -42,6 +42,7 @@
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/avstring.h"
 
 /**
  * Portion of struct vpx_codec_cx_pkt from vpx_encoder.h.
@@ -127,7 +128,6 @@ typedef struct VPxEncoderContext {
 int roi_warned;
 #if CONFIG_LIBVPX_VP9_ENCODER && 
defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
 vpx_svc_ref_frame_config_t ref_frame_config;
-AVDictionary *vpx_ref_frame_config;
 #endif
 } VPxContext;
 
@@ -561,18 +561,13 @@ static int vpx_ts_param_parse(VPxContext *ctx, struct 
vpx_codec_enc_cfg *enccfg,
 }
 
 #if CONFIG_LIBVPX_VP9_ENCODER && 
defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
-static int vpx_ref_frame_config_parse(VPxContext *ctx, const struct 
vpx_codec_enc_cfg *enccfg,
-  char *key, char *value, enum AVCodecID 
codec_id)
+static int vpx_ref_frame_config_set_value(vpx_svc_ref_frame_config_t 
*ref_frame_config,
+  int ss_number_layers, char *key, 
char *value)
 {
 size_t value_len = strlen(value);
-int ss_number_layers = enccfg->ss_number_layers;
-vpx_svc_ref_frame_config_t *ref_frame_config = >ref_frame_config;
 
 if (!value_len)
-return -1;
-
-if (codec_id != AV_CODEC_ID_VP9)
-return -1;
+return AVERROR(EINVAL);
 
 if (!strcmp(key, "rfc_update_buffer_slot")) {
 vp8_ts_parse_int_array(ref_frame_config->update_buffer_slot, value, 
value_len, ss_number_layers);
@@ -600,6 +595,49 @@ static int vpx_ref_frame_config_parse(VPxContext *ctx, 
const struct vpx_codec_en
 
 return 0;
 }
+
+static int vpx_parse_ref_frame_config_element(vpx_svc_ref_frame_config_t 
*ref_frame_config,
+  int ss_number_layers, const char 
**buf)
+{
+const char key_val_sep[] = "=";
+const char pairs_sep[] = ":";
+char *key = av_get_token(buf, key_val_sep);
+char *val = NULL;
+int ret;
+
+if (key && *key && strspn(*buf, key_val_sep)) {
+(*buf)++;
+val = av_get_token(buf, pairs_sep);
+}
+
+if (key && *key && val && *val)
+ret = vpx_ref_frame_config_set_value(ref_frame_config, 
ss_number_layers, key, val);
+else
+ret = AVERROR(EINVAL);
+
+av_freep();
+av_freep();
+
+return ret;
+}
+
+static int vpx_parse_ref_frame_config(vpx_svc_ref_frame_config_t 
*ref_frame_config,
+  int ss_number_layers, const char *str)
+{
+int ret = 0;
+
+while (*str) {
+ret =
+vpx_parse_ref_frame_config_element(ref_frame_config, 
ss_number_layers, );
+if (ret < 0)
+return ret;
+
+if (*str)
+str++;
+}
+
+return ret;
+}
 #endif
 
 #if CONFIG_LIBVPX_VP9_ENCODER
@@ -1594,20 +1632,19 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket 
*pkt,
 
 if (en) {
 if (avctx->codec_id == AV_CODEC_ID_VP9) {
-AVDictionaryEntry* en2 = NULL;
-av_dict_parse_string(>vpx_ref_frame_config, 
en->value, "=", ":", 0);
-
-while ((en2 = av_dict_get(ctx->vpx_ref_frame_config, "", 
en2, AV_DICT_IGNORE_SUFFIX))) {
-if (vpx_ref_frame_config_parse(ctx, enccfg, en2->key, 
en2->value, avctx->codec_id) < 0)
-av_log(avctx, AV_LOG_WARNING,
-   "Error parsing option '%s = %s'.\n",
-   en2->key, en2->value);
+int ret;
+ret = vpx_parse_ref_frame_config(>ref_frame_config,
+   enccfg->ss_number_layers, 
en->value);
+if (ret < 0) {
+av_log(avctx, AV_LOG_WARNING,
+   "Error parsing ref_frame_config option %s.\n", 
en->value);
+return ret;
 }
 
 codecctl_intp(avctx, VP9E_SET_SVC_REF_FRAME_CONFIG, (int 
*)>ref_frame_config);
 } else {
 av_log(avctx, AV_LOG_WARNING,
-   "Error using option ref-frame-config for a non-VP9 
codec\n");
+   "Using option ref-frame-config for a non-VP9 
codec\n");
 }
 }
 #endif
-- 
2.30.0.617.g56c4b15f3c-goog

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

To unsubscribe, visit link above, or email

Re: [FFmpeg-devel] [PATCH v4] avcodec/libvpxenc: optimize parsing vpx_svc_ref_frame_config parameters

2021-02-18 Thread Nicolas George
Wonkap Jang (12021-02-17):
> Getting rid of unnecessary use of AVDictionary object in parsing
> vpx_svc_ref_frame_config.
> ---
>  libavcodec/libvpxenc.c | 76 --
>  1 file changed, 58 insertions(+), 18 deletions(-)

Thanks for the updated patch. It looks much better now. There are a few
minor enhancement still.

> 
> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> index 284cb9a108..abfd0032c1 100644
> --- a/libavcodec/libvpxenc.c
> +++ b/libavcodec/libvpxenc.c
> @@ -42,6 +42,7 @@
>  #include "libavutil/mathematics.h"
>  #include "libavutil/opt.h"
>  #include "libavutil/pixdesc.h"
> +#include "libavutil/avstring.h"
>  
>  /**
>   * Portion of struct vpx_codec_cx_pkt from vpx_encoder.h.
> @@ -127,7 +128,6 @@ typedef struct VPxEncoderContext {
>  int roi_warned;
>  #if CONFIG_LIBVPX_VP9_ENCODER && 
> defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
>  vpx_svc_ref_frame_config_t ref_frame_config;
> -AVDictionary *vpx_ref_frame_config;
>  #endif
>  } VPxContext;
>  
> @@ -561,18 +561,13 @@ static int vpx_ts_param_parse(VPxContext *ctx, struct 
> vpx_codec_enc_cfg *enccfg,
>  }
>  
>  #if CONFIG_LIBVPX_VP9_ENCODER && 
> defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
> -static int vpx_ref_frame_config_parse(VPxContext *ctx, const struct 
> vpx_codec_enc_cfg *enccfg,
> -  char *key, char *value, enum AVCodecID 
> codec_id)
> +static int vpx_ref_frame_config_set_value(vpx_svc_ref_frame_config_t 
> *ref_frame_config,
> +  int ss_number_layers, char *key, 
> char *value)
>  {
>  size_t value_len = strlen(value);
> -int ss_number_layers = enccfg->ss_number_layers;
> -vpx_svc_ref_frame_config_t *ref_frame_config = >ref_frame_config;
>  
>  if (!value_len)
> -return -1;
> -
> -if (codec_id != AV_CODEC_ID_VP9)
> -return -1;
> +return AVERROR(EINVAL);
>  
>  if (!strcmp(key, "rfc_update_buffer_slot")) {
>  vp8_ts_parse_int_array(ref_frame_config->update_buffer_slot, value, 
> value_len, ss_number_layers);
> @@ -600,6 +595,52 @@ static int vpx_ref_frame_config_parse(VPxContext *ctx, 
> const struct vpx_codec_en
>  
>  return 0;
>  }
> +

> +static int vpx_parse_ref_frame_config_element(vpx_svc_ref_frame_config_t 
> *ref_frame_config, int ss_number_layers,
> +  const char **buf, const char 
> *key_val_sep, const char *pairs_sep)

You do not need to carry the key_val_sep and pairs_sep around, just
hard-code them when they are used instead of hard-coding them in the
initial call.

> +{
> +char *key = av_get_token(buf, key_val_sep);
> +char *val = NULL;
> +int ret;
> +
> +if (key && *key && strspn(*buf, key_val_sep)) {
> +(*buf)++;
> +val = av_get_token(buf, pairs_sep);
> +}
> +
> +if (key && *key && val && *val)
> +ret = vpx_ref_frame_config_set_value(ref_frame_config, 
> ss_number_layers, key, val);
> +else
> +ret = AVERROR(EINVAL);
> +
> +av_freep();
> +av_freep();
> +
> +return ret;
> +}
> +
> +static int vpx_parse_ref_frame_config(vpx_svc_ref_frame_config_t 
> *ref_frame_config, int ss_number_layers,
> +  const char *str, const char 
> *key_val_sep, const char *pairs_sep)
> +{
> +int ret = 0;
> +

> +if (!ref_frame_config)
> +return AVERROR(EINVAL);
> +
> +if (!str)
> +return AVERROR(EINVAL);

Dictionaries entries cannot be NULL, and ref_frame_config can defintely
not be NULL here, so these tests are redundant, and misleading about the
proper use of this function.

> +
> +while (*str) {

> +if ((ret = vpx_parse_ref_frame_config_element(ref_frame_config, 
> ss_number_layers,
> +  , key_val_sep, 
> pairs_sep)) !=0)

Please do not merge assignment and comparison when it does not make the
code more readable.

And the usual idiom is "if (ret < 0)".

> +return ret;
> +
> +if (*str)
> +str++;
> +}
> +
> +return ret;
> +}
>  #endif
>  
>  #if CONFIG_LIBVPX_VP9_ENCODER
> @@ -1594,20 +1635,19 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket 
> *pkt,
>  
>  if (en) {
>  if (avctx->codec_id == AV_CODEC_ID_VP9) {
> -AVDictionaryEntry* en2 = NULL;
> -av_dict_parse_string(>vpx_ref_frame_config, 
> en->value, "=", ":", 0);
> -
> -while ((en2 = av_dict_get(ctx->vpx_ref_frame_config, "", 
> en2, AV_DICT_IGNORE_SUFFIX))) {
> -if (vpx_ref_frame_config_parse(ctx, enccfg, 
> en2->key, en2->value, avctx->codec_id) < 0)
> -av_log(avctx, AV_LOG_WARNING,
> -   "Error parsing option '%s = %s'.\n",
> -   en2->key, en2->value);
> +int ret;
> 

Re: [FFmpeg-devel] [PATCH 1/1] avcodec/libopusdec: Enable FEC/PLC

2021-02-18 Thread Philip-Dylan Gleonec
Here is the reworked patch properly attached.
Sorry about the duplicate mail, I just noticed I had a mishap with my
mail client and the previous patch was scrubbed.

Signed-off-by: Philip-Dylan Gleonec 
Co-developed-by: Steinar H. Gunderson 
---
 libavcodec/libopusdec.c | 107 +++-
 1 file changed, 96 insertions(+), 11 deletions(-)

diff --git a/libavcodec/libopusdec.c b/libavcodec/libopusdec.c
index 082a431c6c..3de784dfbd 100644
--- a/libavcodec/libopusdec.c
+++ b/libavcodec/libopusdec.c
@@ -43,10 +43,15 @@ struct libopus_context {
 #ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST
 int apply_phase_inv;
 #endif
+int decode_fec;
+int64_t expected_next_pts;
 };
 
 #define OPUS_HEAD_SIZE 19
 
+// Sample rate is constant as libopus always output at 48kHz
+const AVRational opus_timebase = { 1, 48000 };
+
 static av_cold int libopus_decode_init(AVCodecContext *avc)
 {
 struct libopus_context *opus = avc->priv_data;
@@ -134,6 +139,8 @@ static av_cold int libopus_decode_init(AVCodecContext *avc)
 /* Decoder delay (in samples) at 48kHz */
 avc->delay = avc->internal->skip_samples = opus->pre_skip;
 
+opus->expected_next_pts = AV_NOPTS_VALUE;
+
 return 0;
 }
 
@@ -155,25 +162,102 @@ static int libopus_decode(AVCodecContext *avc, void 
*data,
 {
 struct libopus_context *opus = avc->priv_data;
 AVFrame *frame   = data;
-int ret, nb_samples;
+uint8_t *outptr;
+int ret, nb_samples = 0, nb_lost_samples = 0, nb_samples_left;
+
+// If FEC is enabled, calculate number of lost samples
+if (opus->decode_fec &&
+opus->expected_next_pts != AV_NOPTS_VALUE &&
+pkt->pts != AV_NOPTS_VALUE &&
+pkt->pts != opus->expected_next_pts) {
+// Cap at recovering 120 ms of lost audio.
+nb_lost_samples = pkt->pts - opus->expected_next_pts;
+nb_lost_samples = FFMIN(nb_lost_samples, MAX_FRAME_SIZE);
+// pts is expressed in ms for some containers (e.g. mkv)
+// FEC only works for SILK frames (> 10ms)
+// Detect if nb_lost_samples is in ms, and convert in samples if it is
+if (nb_lost_samples > 0) {
+if (avc->pkt_timebase.den != 48000) {
+nb_lost_samples = av_rescale_q(nb_lost_samples, 
avc->pkt_timebase, opus_timebase);
+}
+// For FEC/PLC, frame_size has to be to have a multiple of 2.5 ms
+if (nb_lost_samples % (int)(2.5 / 1000 * opus_timebase.den)) {
+nb_lost_samples -= nb_lost_samples % (int)(2.5 / 1000 * 
opus_timebase.den);
+}
+}
+}
 
-frame->nb_samples = MAX_FRAME_SIZE;
+frame->nb_samples = MAX_FRAME_SIZE + nb_lost_samples;
 if ((ret = ff_get_buffer(avc, frame, 0)) < 0)
 return ret;
 
+outptr = frame->data[0];
+nb_samples_left = frame->nb_samples;
+
+if (opus->decode_fec && nb_lost_samples > 0) {
+// Try to recover the lost samples with FEC data from this one.
+// If there's no FEC data, the decoder will do loss concealment 
instead.
+if (avc->sample_fmt == AV_SAMPLE_FMT_S16)
+ret = opus_multistream_decode(opus->dec, pkt->data, pkt->size,
+  (opus_int16 *)outptr,
+  nb_lost_samples, 1);
+else
+ret = opus_multistream_decode_float(opus->dec, pkt->data, 
pkt->size,
+   (float *)outptr,
+   nb_lost_samples, 1);
+
+if (ret < 0) {
+if (opus->decode_fec) opus->expected_next_pts = pkt->pts + 
pkt->duration;
+av_log(avc, AV_LOG_ERROR, "Decoding error: %s\n",
+   opus_strerror(ret));
+return ff_opus_error_to_averror(ret);
+}
+
+av_log(avc, AV_LOG_WARNING, "Recovered %d samples with FEC/PLC\n",
+   ret);
+
+outptr += ret * avc->channels * 
av_get_bytes_per_sample(avc->sample_fmt);
+nb_samples_left -= ret;
+nb_samples += ret;
+if (pkt->pts != AV_NOPTS_VALUE) {
+frame->pts = pkt->pts - ret;
+}
+}
+
+// Decode the actual, non-lost data.
 if (avc->sample_fmt == AV_SAMPLE_FMT_S16)
-nb_samples = opus_multistream_decode(opus->dec, pkt->data, pkt->size,
- (opus_int16 *)frame->data[0],
- frame->nb_samples, 0);
+ret = opus_multistream_decode(opus->dec, pkt->data, pkt->size,
+  (opus_int16 *)outptr,
+  nb_samples_left, 0);
 else
-nb_samples = opus_multistream_decode_float(opus->dec, pkt->data, 
pkt->size,
-   (float *)frame->data[0],
-   frame->nb_samples, 0);
+  

Re: [FFmpeg-devel] [PATCH v4] avcodec/libvpxenc: optimize parsing vpx_svc_ref_frame_config parameters

2021-02-18 Thread Wonkap Jang
On Wed, Feb 17, 2021 at 4:41 PM Wonkap Jang  wrote:

> Getting rid of unnecessary use of AVDictionary object in parsing
> vpx_svc_ref_frame_config.
> ---
>  libavcodec/libvpxenc.c | 76 --
>  1 file changed, 58 insertions(+), 18 deletions(-)
>
> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> index 284cb9a108..abfd0032c1 100644
> --- a/libavcodec/libvpxenc.c
> +++ b/libavcodec/libvpxenc.c
> @@ -42,6 +42,7 @@
>  #include "libavutil/mathematics.h"
>  #include "libavutil/opt.h"
>  #include "libavutil/pixdesc.h"
> +#include "libavutil/avstring.h"
>
>  /**
>   * Portion of struct vpx_codec_cx_pkt from vpx_encoder.h.
> @@ -127,7 +128,6 @@ typedef struct VPxEncoderContext {
>  int roi_warned;
>  #if CONFIG_LIBVPX_VP9_ENCODER &&
> defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
>  vpx_svc_ref_frame_config_t ref_frame_config;
> -AVDictionary *vpx_ref_frame_config;
>  #endif
>  } VPxContext;
>
> @@ -561,18 +561,13 @@ static int vpx_ts_param_parse(VPxContext *ctx,
> struct vpx_codec_enc_cfg *enccfg,
>  }
>
>  #if CONFIG_LIBVPX_VP9_ENCODER &&
> defined(VPX_CTRL_VP9E_SET_MAX_INTER_BITRATE_PCT)
> -static int vpx_ref_frame_config_parse(VPxContext *ctx, const struct
> vpx_codec_enc_cfg *enccfg,
> -  char *key, char *value, enum
> AVCodecID codec_id)
> +static int vpx_ref_frame_config_set_value(vpx_svc_ref_frame_config_t
> *ref_frame_config,
> +  int ss_number_layers, char
> *key, char *value)
>  {
>  size_t value_len = strlen(value);
> -int ss_number_layers = enccfg->ss_number_layers;
> -vpx_svc_ref_frame_config_t *ref_frame_config = >ref_frame_config;
>
>  if (!value_len)
> -return -1;
> -
> -if (codec_id != AV_CODEC_ID_VP9)
> -return -1;
> +return AVERROR(EINVAL);
>
>  if (!strcmp(key, "rfc_update_buffer_slot")) {
>  vp8_ts_parse_int_array(ref_frame_config->update_buffer_slot,
> value, value_len, ss_number_layers);
> @@ -600,6 +595,52 @@ static int vpx_ref_frame_config_parse(VPxContext
> *ctx, const struct vpx_codec_en
>
>  return 0;
>  }
> +
> +static int vpx_parse_ref_frame_config_element(vpx_svc_ref_frame_config_t
> *ref_frame_config, int ss_number_layers,
> +  const char **buf, const
> char *key_val_sep, const char *pairs_sep)
> +{
> +char *key = av_get_token(buf, key_val_sep);
> +char *val = NULL;
> +int ret;
> +
> +if (key && *key && strspn(*buf, key_val_sep)) {
> +(*buf)++;
> +val = av_get_token(buf, pairs_sep);
> +}
> +
> +if (key && *key && val && *val)
> +ret = vpx_ref_frame_config_set_value(ref_frame_config,
> ss_number_layers, key, val);
> +else
> +ret = AVERROR(EINVAL);
> +
> +av_freep();
> +av_freep();
> +
> +return ret;
> +}
> +
> +static int vpx_parse_ref_frame_config(vpx_svc_ref_frame_config_t
> *ref_frame_config, int ss_number_layers,
> +  const char *str, const char
> *key_val_sep, const char *pairs_sep)
> +{
> +int ret = 0;
> +
> +if (!ref_frame_config)
> +return AVERROR(EINVAL);
> +
> +if (!str)
> +return AVERROR(EINVAL);
> +
> +while (*str) {
> +if ((ret = vpx_parse_ref_frame_config_element(ref_frame_config,
> ss_number_layers,
> +  , key_val_sep,
> pairs_sep)) !=0)
> +return ret;
> +
> +if (*str)
> +str++;
> +}
> +
> +return ret;
> +}
>  #endif
>
>  #if CONFIG_LIBVPX_VP9_ENCODER
> @@ -1594,20 +1635,19 @@ static int vpx_encode(AVCodecContext *avctx,
> AVPacket *pkt,
>
>  if (en) {
>  if (avctx->codec_id == AV_CODEC_ID_VP9) {
> -AVDictionaryEntry* en2 = NULL;
> -av_dict_parse_string(>vpx_ref_frame_config,
> en->value, "=", ":", 0);
> -
> -while ((en2 = av_dict_get(ctx->vpx_ref_frame_config,
> "", en2, AV_DICT_IGNORE_SUFFIX))) {
> -if (vpx_ref_frame_config_parse(ctx, enccfg,
> en2->key, en2->value, avctx->codec_id) < 0)
> -av_log(avctx, AV_LOG_WARNING,
> -   "Error parsing option '%s = %s'.\n",
> -   en2->key, en2->value);
> +int ret;
> +ret =
> vpx_parse_ref_frame_config(>ref_frame_config,
> +
>  enccfg->ss_number_layers, en->value,  "=", ":");
> +if (ret != 0) {
> +av_log(avctx, AV_LOG_WARNING,
> +   "Error parsing ref_frame_config option
> %s.\n", en->value);
> +return ret;
>  }
>
>  codecctl_intp(avctx, VP9E_SET_SVC_REF_FRAME_CONFIG,
> (int *)>ref_frame_config);
>  } else {
>  av_log(avctx, AV_LOG_WARNING,
> - 

Re: [FFmpeg-devel] [RFC] Event loop

2021-02-18 Thread Nicolas George
Lynne (12021-02-17):
> It's more actively developed by a large margin, and I generally

This is an interesting argument.

> prefer its API and how it works internally.

Can you give more details? Which differences make you prefer it?

One of the things that I like about libev is that it makes effort to be
efficient and simple in terms of allocating data structures. No such
thing as always dynamically allocating stuff like the Gnome projects, so
much that it looks more like Java than C. We can have the libev
structures directly in our own data structures.

Is libuv similar in that respect?

The fact that it is designed to run the interpreter of a language with a
garbage collector worries me.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [RFC] Event loop

2021-02-18 Thread Nicolas George
Mark Thompson (12021-02-17):
> I'm not sure you can avoid writing Windows code for this to work at
> all, because I don't think poll() as we have now is sufficient to get
> the functionality you want.

I'm sure I can avoid writing Windows code, because, as I have already
pointed, our current implementation already work using poll(). If it
currently works, I have no intention of breaking it, just reorganizing
it to make it work better and make easier to extend.

> I also worry that codifying something in this form is going to exclude
> the possibility of getting a better result on Windows later, because
> that wouldn't involve file descriptors or internals calling default
> BSD send()/recv().

You have got it backwards: it will make the possibility of getting a
better result on Windows later easier, because it will make everything
modular.

In fact, libev and libuv already implement code specific to Windows, so
we get them for free as soon as we implement support for one of these
libraries.

> How are you going to implement altering/removing an event or stopping
> the loop?
> 
> On Unix you of course have an eventfd/self-pipe sitting in the poll()
> set on the event loop to interrupt it.  On Windows you can't, because
> those things are not file descriptors.

These are needed for stopping the loop from the outside, from another
thread. They are not needed to stop the loop from the inside.

It is possible that our threading capabilities for this will be more
limited on Windows than on Unix until specific code is implemented (not
by me) and unless the external library is used. Just as our threading
capabilities are currently more limited on Windows.

I insist: it is the opposite as what you are saying, this project makes
it possible to have code that works on Windows, unlike now. It just will
not be me who write specific code.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH v6 4/9] avcodec: add cbs for h266/vvc

2021-02-18 Thread Nuo Mi
>
>> > +return AVERROR(ENOMEM);
>> > +}
>> > +h266->ph = (H266RawPH*)h266->ph_ref->data;
>> > +memcpy(h266->ph, >sh_picture_header,
>> sizeof(H266RawPH));
>>
>> This memcpy() is naughty - if that was a ref to a previous picture header
>> then you've just overwritten the reference while the other unit still holds
>> it.
>>
>> If the slice is unit->content then unit->content_ref is a reference to a
>> superstructure of the picture header, avoiding the copy, but I'm not sure
>> it's the right way to do it.
>>
>> Is it right that the two possible options here are:
>> * Store a ref, which might be to a newly-allocated buffer or might be to
>> a previous unit.
>>
> * Store the whole structure in the private context.
>>
> ?
>>
>> If the structure isn't too large, then the second option feels much
>> simpler.
>>
>> If it is large such that holding references and avoiding copies is
>> beneficial (which is quite large, every ref entails a malloc/free
>> call-pair), then we probably want that ref to always be to the unit?
>>
> If we store the whole structure, it's hard to detect the picture header
> missing case.
>
Also, if we use this as start point of the native decoder, the native
decoder may need ref the picture header for multi-thread decoding.

>
>> > +}
>> > +
>> > +ph = h266->ph;
>> > +if (!ph) {
>> > +av_log(ctx->log_ctx, AV_LOG_ERROR, "Picture header not
>> available.\n");
>> > +return AVERROR_INVALIDDATA;
>> > +}
>> > ...
>> > diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
>> > index a392880036..118b1052d4 100644
>> > --- a/libavcodec/cbs_internal.h
>> > +++ b/libavcodec/cbs_internal.h
>> > @@ -40,7 +40,7 @@ enum CBSContentType {
>> >   enum {
>> > // Maximum number of unit types described by the same unit type
>> > // descriptor.
>> > -  CBS_MAX_UNIT_TYPES  = 3,
>> > +  CBS_MAX_UNIT_TYPES  = 4,
>>
>> Heh, fair :)
>>
>> > // Maximum number of reference buffer offsets in any one unit.
>> > CBS_MAX_REF_OFFSETS = 2,
>> > // Special value used in a unit type descriptor to indicate
>> that it
>> > @@ -204,6 +204,7 @@ int ff_cbs_write_signed(CodedBitstreamContext *ctx,
>> PutBitContext *pbc,
>> >   extern const CodedBitstreamType ff_cbs_type_av1;
>> >   extern const CodedBitstreamType ff_cbs_type_h264;
>> >   extern const CodedBitstreamType ff_cbs_type_h265;
>> > +extern const CodedBitstreamType ff_cbs_type_h266;
>> >   extern const CodedBitstreamType ff_cbs_type_jpeg;
>> >   extern const CodedBitstreamType ff_cbs_type_mpeg2;
>> >   extern const CodedBitstreamType ff_cbs_type_vp9;
>> > diff --git a/libavcodec/cbs_sei.c b/libavcodec/cbs_sei.c
>> > index c49830ad77..96c60259ce 100644
>> > --- a/libavcodec/cbs_sei.c
>> > +++ b/libavcodec/cbs_sei.c
>> > @@ -20,6 +20,7 @@
>> >   #include "cbs_internal.h"
>> >   #include "cbs_h264.h"
>> >   #include "cbs_h265.h"
>> > +#include "cbs_h266.h"
>> >   #include "cbs_sei.h"
>> >
>> >   static void cbs_free_user_data_registered(void *opaque, uint8_t *data)
>> > @@ -132,6 +133,13 @@ static int cbs_sei_get_unit(CodedBitstreamContext
>> *ctx,
>> >   else
>> >   sei_type = HEVC_NAL_SEI_SUFFIX;
>> >   break;
>> > +case AV_CODEC_ID_H266:
>> > +highest_vcl_type = VVC_RSV_IRAP_11;
>> > +if (prefix)
>> > +sei_type = VVC_PREFIX_SEI_NUT;
>> > +else
>> > +sei_type = VVC_SUFFIX_SEI_NUT;
>> > +break;
>> >   default:
>> >   return AVERROR(EINVAL);
>> >   }
>> > @@ -207,6 +215,18 @@ static int cbs_sei_get_unit(CodedBitstreamContext
>> *ctx,
>> >   memcpy(unit->content, , sizeof(sei));
>> >   }
>> >   break;
>> > +case AV_CODEC_ID_H266:
>> > +{
>> > +H266RawSEI sei = {
>> > +.nal_unit_header = {
>> > +.nal_unit_type = sei_type,
>> > +.nuh_layer_id  = 0,
>> > +.nuh_temporal_id_plus1 = 1,
>> > +},
>> > +};
>> > +memcpy(unit->content, , sizeof(sei));
>> > +}
>> > +break;
>> >   default:
>> >   av_assert0(0);
>> >   }
>> > @@ -237,6 +257,15 @@ static int
>> cbs_sei_get_message_list(CodedBitstreamContext *ctx,
>> >   *list = >message_list;
>> >   }
>> >   break;
>> > +case AV_CODEC_ID_H266:
>> > +{
>> > +H266RawSEI *sei = unit->content;
>> > +if (unit->type != VVC_PREFIX_SEI_NUT &&
>> > +unit->type != VVC_SUFFIX_SEI_NUT)
>> > +return AVERROR(EINVAL);
>> > +*list = >message_list;
>> > +}
>> > +break;
>>
>> Yay, I'm glad the SEI stuff fitted in nicely with no extra weird cases.
>>
> Yes. It's a good solution to remove duplicate things

>
>> >   default:
>> >   return AVERROR(EINVAL);
>> >   }
>> >
>> Thanks,

Re: [FFmpeg-devel] [PATCH v6 4/9] avcodec: add cbs for h266/vvc

2021-02-18 Thread Nuo Mi
On Thu, Feb 18, 2021 at 8:04 AM Mark Thompson  wrote:

> On 17/02/2021 01:51, Nuo Mi wrote:
> > ---
> >   configure |2 +
> >   libavcodec/Makefile   |1 +
> >   libavcodec/cbs.c  |6 +
> >   libavcodec/cbs_h2645.c|  541 -
> >   libavcodec/cbs_h266.h |  817 +++
> >   libavcodec/cbs_h266_syntax_template.c | 3006 +
> >   libavcodec/cbs_internal.h |3 +-
> >   libavcodec/cbs_sei.c  |   29 +
> >   8 files changed, 4397 insertions(+), 8 deletions(-)
> >   create mode 100644 libavcodec/cbs_h266.h
> >   create mode 100644 libavcodec/cbs_h266_syntax_template.c
> >
> > diff --git a/configure b/configure
> > index a76c2ec4ae..11df59a229 100755
> > --- a/configure
> > +++ b/configure
> > @@ -2355,6 +2355,7 @@ CONFIG_EXTRA="
> >   cbs_av1
> >   cbs_h264
> >   cbs_h265
> > +cbs_h266
> >   cbs_jpeg
> >   cbs_mpeg2
> >   cbs_vp9
> > @@ -2623,6 +2624,7 @@ threads_if_any="$THREADS_LIST"
> >   cbs_av1_select="cbs"
> >   cbs_h264_select="cbs"
> >   cbs_h265_select="cbs"
> > +cbs_h266_select="cbs"
> >   cbs_jpeg_select="cbs"
> >   cbs_mpeg2_select="cbs"
> >   cbs_vp9_select="cbs"
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > index 3341801b97..23553e68e9 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -73,6 +73,7 @@ OBJS-$(CONFIG_CBS) += cbs.o
> cbs_bsf.o
> >   OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o
> >   OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_sei.o
> h2645_parse.o
> >   OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_sei.o
> h2645_parse.o
> > +OBJS-$(CONFIG_CBS_H266)+= cbs_h2645.o cbs_sei.o
> h2645_parse.o
> >   OBJS-$(CONFIG_CBS_JPEG)+= cbs_jpeg.o
> >   OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
> >   OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
> > diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
> > index ecf22b3fdb..6baf21d62b 100644
> > --- a/libavcodec/cbs.c
> > +++ b/libavcodec/cbs.c
> > @@ -39,6 +39,9 @@ static const CodedBitstreamType *const
> cbs_type_table[] = {
> >   #if CONFIG_CBS_H265
> >   _cbs_type_h265,
> >   #endif
> > +#if CONFIG_CBS_H266
> > +_cbs_type_h266,
> > +#endif
> >   #if CONFIG_CBS_JPEG
> >   _cbs_type_jpeg,
> >   #endif
> > @@ -60,6 +63,9 @@ const enum AVCodecID ff_cbs_all_codec_ids[] = {
> >   #if CONFIG_CBS_H265
> >   AV_CODEC_ID_H265,
> >   #endif
> > +#if CONFIG_CBS_H266
> > +AV_CODEC_ID_H266,
> > +#endif
> >   #if CONFIG_CBS_JPEG
> >   AV_CODEC_ID_MJPEG,
> >   #endif
> > diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> > index 57c419aa05..d39464ba49 100644
> > --- a/libavcodec/cbs_h2645.c
> > +++ b/libavcodec/cbs_h2645.c
> > @@ -24,12 +24,129 @@
> >   #include "cbs_internal.h"
> >   #include "cbs_h264.h"
> >   #include "cbs_h265.h"
> > +#include "cbs_h266.h"
> >   #include "h264.h"
> >   #include "h264_sei.h"
> >   #include "h2645_parse.h"
> >   #include "hevc.h"
> >   #include "hevc_sei.h"
> > +#include "vvc.h"
> >
> > +#define H266_IS_SLICE(nut) (nut <= VVC_RASL_NUT || (nut >=
> VVC_IDR_W_RADL && nut <= VVC_GDR_NUT))
> > +#define H266_IS_IDR(nut) (nut == VVC_IDR_W_RADL || nut == VVC_IDR_N_LP)
> > +
> > +static void h266_au_detector_init(H266AuDetector* d)
> > +{
> > +if (!d->inited) {
> > +d->prev_layer_id = UINT8_MAX;
> > +d->prev_poc = INT_MAX;
> > +d->prev_tid0_poc = INT_MAX;
> > +d->inited = 1;
> > +}
> > +}
> > +
> > +//8.3.1 Decoding process for picture order count.
> > +//VTM did not follow the spec, and it's much simpler than spec.
> > +//We follow the VTM.
>
> To clarify, does that mean that the VTM is wrong or that the spec defines
> it in an equivalent way which is overly complicated?
>
Yes, It equals, Spec is over complicated. Spec defined many constrain for
encoder, decoder does not need  care about it.

>
> > +static int h266_get_slice_poc(CodedBitstreamH266Context *h266, void*
> log_ctx,
> > +  const H266RawPH *ph, const
> H266RawSliceHeader *slice,
> > +  int *poc)
> > +{
> > +int poc_msb, max_poc_lsb, poc_lsb;
> > +H266AuDetector* d = >priv.au_detector;
> > +const H266RawSPS* sps;
> > +const H266RawPPS* pps;
>
> Please keep the '*'s as part of the declarator, not the
> declaration-specifiers (in lots of places in these functions).
>
Used a regex to search and replace. should be done now

>
> > +
> > +pps = h266->pps[ph->ph_pic_parameter_set_id];
> > +if (!pps) {
> > +av_log(log_ctx, AV_LOG_ERROR, "PPS id %d is not avaliable.\n",
> > +   ph->ph_pic_parameter_set_id);
> > +return AVERROR_INVALIDDATA;
> > +}
> > +
> > +sps = h266->sps[pps->pps_seq_parameter_set_id];
> > +if (!sps) {
> > +av_log(log_ctx, AV_LOG_ERROR, "SPS id %d 

[FFmpeg-devel] [PATCH] swscale/x86/swscale: fix mix of inline and external function definitions

2021-02-18 Thread James Almer
This includes removing pointless static function forward declarations.

Signed-off-by: James Almer 
---
 libswscale/x86/swscale.c  | 40 ++-
 libswscale/x86/swscale_template.c |  1 -
 2 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index 316a824e87..12e7799d0f 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -63,16 +63,6 @@ DECLARE_ASM_ALIGNED(8, const uint64_t, ff_bgr2UVOffset) = 
0x8080808080808080ULL;
 DECLARE_ASM_ALIGNED(8, const uint64_t, ff_w)= 
0x0001000100010001ULL;
 
 
-#define YUV2YUVX_FUNC_DECL(opt)  \
-static void yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, const 
int16_t **src, \
-   uint8_t *dest, int dstW, \
-   const uint8_t *dither, int offset); \
-
-YUV2YUVX_FUNC_DECL(mmx)
-YUV2YUVX_FUNC_DECL(mmxext)
-YUV2YUVX_FUNC_DECL(sse3)
-YUV2YUVX_FUNC_DECL(avx2)
-
 //MMX versions
 #if HAVE_MMX_INLINE
 #undef RENAME
@@ -206,8 +196,8 @@ void ff_updateMMXDitherTables(SwsContext *c, int dstY)
 }
 }
 }
+#endif /* HAVE_INLINE_ASM */
 
-#if HAVE_MMXEXT
 #define YUV2YUVX_FUNC_MMX(opt, step)  \
 void ff_yuv2yuvX_ ##opt(const int16_t *filter, int filterSize, int srcOffset, \
uint8_t *dest, int dstW,  \
@@ -241,17 +231,19 @@ static void yuv2yuvX_ ##opt(const int16_t *filter, int 
filterSize, \
 return; \
 }
 
+#if HAVE_MMX_EXTERNAL
 YUV2YUVX_FUNC_MMX(mmx, 16)
+#endif
+#if HAVE_MMXEXT_EXTERNAL
 YUV2YUVX_FUNC_MMX(mmxext, 16)
+#endif
+#if HAVE_SSE3_EXTERNAL
 YUV2YUVX_FUNC(sse3, 32)
+#endif
 #if HAVE_AVX2_EXTERNAL
 YUV2YUVX_FUNC(avx2, 64)
 #endif
 
-#endif
-
-#endif /* HAVE_INLINE_ASM */
-
 #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
 void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
 SwsContext *c, int16_t *data, \
@@ -379,8 +371,22 @@ av_cold void ff_sws_init_swscale_x86(SwsContext *c)
 if (INLINE_MMXEXT(cpu_flags))
 sws_init_swscale_mmxext(c);
 #endif
-#if HAVE_SSSE3_EXTERNAL
-if (EXTERNAL_SSSE3(cpu_flags)) {
+#if HAVE_MMX_EXTERNAL
+if (EXTERNAL_MMX(cpu_flags)) {
+if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND)){
+c->yuv2planeX = yuv2yuvX_mmx;
+}
+}
+#endif
+#if HAVE_MMXEXT_EXTERNAL
+if (EXTERNAL_MMXEXT(cpu_flags)) {
+if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND)){
+c->yuv2planeX = yuv2yuvX_mmxext;
+}
+}
+#endif
+#if HAVE_SSE3_EXTERNAL
+if (EXTERNAL_SSE3(cpu_flags)) {
 if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND)){
 c->yuv2planeX = yuv2yuvX_sse3;
 }
diff --git a/libswscale/x86/swscale_template.c 
b/libswscale/x86/swscale_template.c
index cb33af97e4..97d8cae613 100644
--- a/libswscale/x86/swscale_template.c
+++ b/libswscale/x86/swscale_template.c
@@ -1435,7 +1435,6 @@ static av_cold void RENAME(sws_init_swscale)(SwsContext 
*c)
 }
 } else {
 c->use_mmx_vfilter= 1;
-c->yuv2planeX = RENAME(yuv2yuvX);
 if (!(c->flags & SWS_FULL_CHR_H_INT)) {
 switch (c->dstFormat) {
 case AV_PIX_FMT_RGB32:   c->yuv2packedX = 
RENAME(yuv2rgb32_X);   break;
-- 
2.30.0

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

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

Re: [FFmpeg-devel] [PATCH 1/1] avcodec/libopusdec: Enable FEC/PLC

2021-02-18 Thread Philip-Dylan Gleonec

Andreas Rheinhardt:

>>> Could you elaborate?
>>> I would have expected that the normal use case is not have a
>>> lossy input and that the new feature is always useful if data
>>> was lost.
>>
>> The use-case for FEC is typically RTP stream where audio is compressed
>> with opus. In that case, depending on the network conditions, packets
>> can be lost. From the decoder side, this can be observed as a packet
>> with a pts that is incremented more than we would expect.
>>
>> With this patch, if no discontinuity is detected, the packet is decoded
>> as usual. If a discontinuity is detected, its duration is checked to
>> deduct how many samples should be reconstructed. One limitation of opus
>> FEC is that packets can be reconstructed with a granularity of 2.5ms
>> (120 samples), so libopus can not jsut reconstruct an arbitrary number
>> of samples. This patch manages this by "rounding" the number of lost
>> samples to the closest number of samples that libopsu can reconstruct.
>>
>>> Or is there no way to distinguish between a stream with
>>> unusual timestamps and a stream with packet loss?
>>
>> From my understanding, the only information at the decoder side are the
>> metadata associated with the packet to decode, notably the pts, dts and
>> packet duration. It does not have information about how the packet has
>> been received (RTP, SDP, other...). Packet loss can typically be
>> detected at higher layers (RTCP packets for RTP) but not at the decoder
>> layer.
>>
>> From observation it seemed that a pts different from the last pts +
>> packet duration would indicate that some samples were lost. The decoder
>> than tries to restore as much sample as it can.
>>
>> Note that packet duration seem to change units depending on how the file
>> is encapsulated: the same file had a packet->duration of 20 (ms) in a
>> .mkv container but 960 (samples) in a .opus container. Since the decoder
>> is not aware of which container is used, it has to "guess" which unit is
>> used. As FEC is ony used with SILK frames, which have a 10ms (480
>> samples) minimal duration, and an opus packet has a max duration of
>> 120ms, a threshold can find how the pts is expressed.
>
>There is AVCodecContext.pkt_timebase.

Thanks for the feedback, I had missed that property.
I've attached a reworked version of the patch which makes use of it. It
is indeed more clean and precise. I've left a fallback when computing
the expected_next_pts in case it has not been set after creating the
AVCodecContext and left at the {0, 1} value.
>From 098076ac2acdf531fc44b594dee10ceb9b42270e Mon Sep 17 00:00:00 2001
From: Philip-Dylan Gleonec 
Date: Thu, 11 Feb 2021 12:22:03 +0100
Subject: [PATCH] avcodec/libopusdec: Enable FEC/PLC

Adds FEC/PLC support to libopus. The lost packets are detected as a
discontinuity in the audio stream. When a discontinuity is used, this
patch tries to decode the FEC data. If FEC data is present in the
packet, it is decoded, otherwise audio is re-created through PLC.

This patch is based on Steinar H. Gunderson contribution, and corrects
the pts computation: all pts are expressed in samples instead of time.
This patch also adds an option "decode_fec" which enables or disables
FEC decoding. This option is disabled by default to keep consistent
behaviour with former versions.

A number of checks are made to ensure compatibility with different
containers. Indeed, video containers seem to have a pts expressed in ms
while it is expressed in samples for audio containers. It also manages
the cases where pkt->duration is 0, in some RTP streams. This patch
ignores data it can not reconstruct, i.e. packets received twice and
packets with a length that is not a multiple of 2.5ms.

Signed-off-by: Philip-Dylan Gleonec 
Co-developed-by: Steinar H. Gunderson 
---
 libavcodec/libopusdec.c | 107 +++-
 1 file changed, 96 insertions(+), 11 deletions(-)

diff --git a/libavcodec/libopusdec.c b/libavcodec/libopusdec.c
index 082a431c6c..3de784dfbd 100644
--- a/libavcodec/libopusdec.c
+++ b/libavcodec/libopusdec.c
@@ -43,10 +43,15 @@ struct libopus_context {
 #ifdef OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST
 int apply_phase_inv;
 #endif
+int decode_fec;
+int64_t expected_next_pts;
 };
 
 #define OPUS_HEAD_SIZE 19
 
+// Sample rate is constant as libopus always output at 48kHz
+const AVRational opus_timebase = { 1, 48000 };
+
 static av_cold int libopus_decode_init(AVCodecContext *avc)
 {
 struct libopus_context *opus = avc->priv_data;
@@ -134,6 +139,8 @@ static av_cold int libopus_decode_init(AVCodecContext *avc)
 /* Decoder delay (in samples) at 48kHz */
 avc->delay = avc->internal->skip_samples = opus->pre_skip;
 
+opus->expected_next_pts = AV_NOPTS_VALUE;
+
 return 0;
 }
 
@@ -155,25 +162,102 @@ static int libopus_decode(AVCodecContext *avc, void *data,
 {
 struct libopus_context *opus = avc->priv_data;
 AVFrame *frame   = data;
-int ret, nb_samples;
+

Re: [FFmpeg-devel] [PATCH v2 0/4] avcodec/aarch64/hevcdsp

2021-02-18 Thread Josh Dekker

Set pushed with all Martin's changes implemented. More NEON & updates soon.

--
Josh

On 2021-02-04 12:32, Josh Dekker wrote:

Hi,

Rebases the unpushed part of my patches on top of Reimar's set.  Also
implements Martin's suggestions except 'unrolling the loop' for SAO band
function, will update the band function when I fix non 8x8 cases.


___
ffmpeg-devel mailing list
ffmpeg-devel@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/4] avformat/mpegenc: Ensure packet queue stays valid

2021-02-18 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> The MPEG-PS muxer uses a custom queue of custom packets. To keep track
> of it, it has a pointer (named predecode_packet) to the head of the
> queue and a pointer to where the next packet is to be added (it points
> to the next-pointer of the last element of the queue); furthermore,
> there is also a pointer that points into the queue (called premux_packet).
> 
> The exact behaviour was as follows: If premux_packet was NULL when a
> packet is received, it is taken to mean that the old queue is empty and
> a new queue is started. premux_packet will point to the head of said
> queue and the next_packet-pointer points to its next pointer. If
> predecode_packet is NULL, it will also made to point to the newly
> allocated element.
> 
> But if premux_packet is NULL and predecode_packet is not, then there
> will be two queues with head elements premux_packet and
> predecode_packet. Yet only elements reachable from predecode_packet are
> ever freed, so the premux_packet queue leaks.
> Worse yet, when the predecode_packet queue will be eventually exhausted,
> predecode_packet will be made to point into the other queue and when
> predecode_packet will be freed, the next pointer of the preceding
> element of the queue will still point to the element just freed. This
> element might very well be still reachable from premux_packet which
> leads to use-after-frees lateron. This happened in the tickets mentioned
> below.
> 
> Fix this by never creating two queues in the first place by checking for
> predecode_packet to know whether the queue is empty. If premux_packet is
> NULL, then it is set to the newly allocated element of the queue.
> 
> Fixes tickets #6887, #8188 and #8266.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> Disclaimer: I don't know MPEG program streams very well; it might very
> well be that the mere fact that premux_packet can be NULL while
> predecode_packet isn't is indicative of a deeper bug. All I know is that
> this patch only changes behaviour in case the old behaviour was broken
> (i.e. led to leaks or use-after-frees).
> 
>  libavformat/mpegenc.c | 19 +++
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
> index 9bd0a555d4..810dd717ca 100644
> --- a/libavformat/mpegenc.c
> +++ b/libavformat/mpegenc.c
> @@ -48,9 +48,9 @@ typedef struct StreamInfo {
>  uint8_t id;
>  int max_buffer_size; /* in bytes */
>  int buffer_index;
> -PacketDesc *predecode_packet;
> +PacketDesc *predecode_packet; /* start of packet queue */
> +PacketDesc *last_packet;  /* end of packet queue */
>  PacketDesc *premux_packet;
> -PacketDesc **next_packet;
>  int packet_number;
>  uint8_t lpcm_header[3];
>  int lpcm_align;
> @@ -986,6 +986,8 @@ static int remove_decoded_packets(AVFormatContext *ctx, 
> int64_t scr)
>  }
>  stream->buffer_index-= pkt_desc->size;
>  stream->predecode_packet = pkt_desc->next;
> +if (!stream->predecode_packet)
> +stream->last_packet = NULL;
>  av_freep(_desc);
>  }
>  }
> @@ -1177,12 +1179,16 @@ static int mpeg_mux_write_packet(AVFormatContext 
> *ctx, AVPacket *pkt)
>  av_log(ctx, AV_LOG_TRACE, "dts:%f pts:%f flags:%d stream:%d nopts:%d\n",
>  dts / 9.0, pts / 9.0, pkt->flags,
>  pkt->stream_index, pts != AV_NOPTS_VALUE);
> -if (!stream->premux_packet)
> -stream->next_packet = >premux_packet;
> -*stream->next_packet =
>  pkt_desc = av_mallocz(sizeof(PacketDesc));
>  if (!pkt_desc)
>  return AVERROR(ENOMEM);
> +if (!stream->predecode_packet) {
> +stream->predecode_packet  = pkt_desc;
> +} else
> +stream->last_packet->next = pkt_desc;
> +stream->last_packet = pkt_desc;
> +if (!stream->premux_packet)
> +stream->premux_packet = pkt_desc;
>  pkt_desc->pts= pts;
>  pkt_desc->dts= dts;
>  
> @@ -1200,9 +1206,6 @@ static int mpeg_mux_write_packet(AVFormatContext *ctx, 
> AVPacket *pkt)
>  
>  pkt_desc->unwritten_size =
>  pkt_desc->size   = size;
> -if (!stream->predecode_packet)
> -stream->predecode_packet = pkt_desc;
> -stream->next_packet = _desc->next;
>  
>  if (av_fifo_realloc2(stream->fifo, av_fifo_size(stream->fifo) + size) < 
> 0)
>  return -1;
> 
Will apply this patchset tomorrow unless there are objections.

- 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 1/2] avutil/video_enc_params: Combine overflow checks

2021-02-18 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> This patch also fixes a -Wtautological-constant-out-of-range-compare
> warning from Clang and a -Wtype-limits warning from GCC on systems
> where size_t is 64bits and unsigned 32bits. The reason for this seems
> to be that variable (whose value derives from sizeof() and can therefore
> be known at compile-time) is used instead of using sizeof() directly in
> the comparison.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> Using (UINT_MAX > SIZE_MAX / sizeof(AVVideoBlockParams) && nb_blocks >
> SIZE_MAX / sizeof(AVVideoBlockParams)) would have fixed the warning with
> Clang, but not GCC.
> 
>  libavutil/video_enc_params.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavutil/video_enc_params.c b/libavutil/video_enc_params.c
> index c46c0f1dc6..b9cdafddbb 100644
> --- a/libavutil/video_enc_params.c
> +++ b/libavutil/video_enc_params.c
> @@ -33,8 +33,7 @@ AVVideoEncParams *av_video_enc_params_alloc(enum 
> AVVideoEncParamsType type,
>  size_t size;
>  
>  size = sizeof(*par);
> -if (nb_blocks > SIZE_MAX / sizeof(AVVideoBlockParams) ||
> -nb_blocks * sizeof(AVVideoBlockParams) > SIZE_MAX - size)
> +if (nb_blocks > (SIZE_MAX - size) / sizeof(AVVideoBlockParams))
>  return NULL;
>  size += sizeof(AVVideoBlockParams) * nb_blocks;
>  
> 
Will apply this patchset tomorrow unless there are objections.

- 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 4/6] Revert "avcodec/pngdec: fix possible race condition with APNG decoding"

2021-02-18 Thread Anton Khirnov
Quoting Paul B Mahol (2021-02-18 13:27:26)
> On Thu, Feb 18, 2021 at 1:15 PM Anton Khirnov  wrote:
> 
> > Quoting Paul B Mahol (2021-02-17 14:33:25)
> > > On Wed, Feb 17, 2021 at 12:31 PM Anton Khirnov 
> > wrote:
> > >
> > > Is helgrind report clean with your patch set?
> >
> > Helgrind is not clean before your patch, after your patch, or after my
> > set. The reason is because helgrind does not understand atomics, so its
> > reports are bogus.
> >
> 
> I only can accept this patch if you squash it with next one.

sure

-- 
Anton Khirnov
___
ffmpeg-devel mailing list
ffmpeg-devel@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] Revert "avcodec/pngdec: fix possible race condition with APNG decoding"

2021-02-18 Thread Paul B Mahol
On Thu, Feb 18, 2021 at 1:15 PM Anton Khirnov  wrote:

> Quoting Paul B Mahol (2021-02-17 14:33:25)
> > On Wed, Feb 17, 2021 at 12:31 PM Anton Khirnov 
> wrote:
> >
> > Is helgrind report clean with your patch set?
>
> Helgrind is not clean before your patch, after your patch, or after my
> set. The reason is because helgrind does not understand atomics, so its
> reports are bogus.
>

I only can accept this patch if you squash it with next one.



>
> --
> Anton Khirnov
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@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] pngdec: fix and simplify apng reference handling

2021-02-18 Thread Anton Khirnov
Quoting Paul B Mahol (2021-02-17 14:34:18)
> On Wed, Feb 17, 2021 at 12:33 PM Anton Khirnov  wrote:
> 
> > Quoting Paul B Mahol (2021-02-17 11:52:31)
> > > On Tue, Feb 16, 2021 at 9:26 PM Anton Khirnov  wrote:
> > > > @@ -1088,23 +1084,23 @@ static int handle_p_frame_apng(AVCodecContext
> > > > *avctx, PNGDecContext *s,
> > > >  if (!buffer)
> > > >  return AVERROR(ENOMEM);
> > > >
> > > > +ff_thread_await_progress(>last_picture, INT_MAX, 0);
> > > >
> > > > -// Do the disposal operation specified by the last frame on the
> > frame
> > > > -if (s->last_dispose_op != APNG_DISPOSE_OP_PREVIOUS) {
> > > > -ff_thread_await_progress(>last_picture, INT_MAX, 0);
> > > > -memcpy(buffer, s->last_picture.f->data[0], s->image_linesize *
> > > > s->height);
> > > > -
> > > > -if (s->last_dispose_op == APNG_DISPOSE_OP_BACKGROUND)
> > > > -for (y = s->last_y_offset; y < s->last_y_offset +
> > s->last_h;
> > > > ++y)
> > > > -memset(buffer + s->image_linesize * y + s->bpp *
> > > > s->last_x_offset, 0, s->bpp * s->last_w);
> > > > +// need to reset a rectangle to background:
> > > > +// create a new writable copy
> > > > +if (s->last_dispose_op == APNG_DISPOSE_OP_BACKGROUND) {
> > > > +int ret = av_frame_make_writable(s->last_picture.f);
> > > > +if (ret < 0)
> > > > +return ret;
> > > >
> > > > -memcpy(s->previous_picture.f->data[0], buffer,
> > s->image_linesize
> > > > * s->height);
> > > > -ff_thread_report_progress(>previous_picture, INT_MAX, 0);
> > > > -} else {
> > > > -ff_thread_await_progress(>previous_picture, INT_MAX, 0);
> > > > -memcpy(buffer, s->previous_picture.f->data[0],
> > s->image_linesize
> > > > * s->height);
> > > > +for (y = s->last_y_offset; y < s->last_y_offset + s->last_h;
> > y++)
> > > > {
> > > > +memset(s->last_picture.f->data[0] + s->image_linesize * y
> > +
> > > > +   s->bpp * s->last_x_offset, 0, s->bpp * s->last_w);
> > > > +}
> > > >  }
> > > >
> > > > +memcpy(buffer, s->last_picture.f->data[0], s->image_linesize *
> > > > s->height);
> > > > +
> > > >  // Perform blending
> > > >  if (s->blend_op == APNG_BLEND_OP_SOURCE) {
> > > >  for (y = s->y_offset; y < s->y_offset + s->cur_h; ++y) {
> > > > @@ -1448,22 +1444,17 @@ exit_loop:
> > > >  if (CONFIG_PNG_DECODER && avctx->codec_id !=
> > AV_CODEC_ID_APNG)
> > > >  handle_p_frame_png(s, p);
> > > >  else if (CONFIG_APNG_DECODER &&
> > > > - s->previous_picture.f->width == p->width  &&
> > > > - s->previous_picture.f->height== p->height &&
> > > > - s->previous_picture.f->format== p->format &&
> > > >
> > >
> > > No explanation provided why those line are removed.
> > >
> >
> > They are removed because previous_picture is removed. As is actually
> > explained in the commit message.
> >
> >
> But you just replaced previous with last?

The same check is already done for last_picture a few lines above.

-- 
Anton Khirnov
___
ffmpeg-devel mailing list
ffmpeg-devel@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] Revert "avcodec/pngdec: fix possible race condition with APNG decoding"

2021-02-18 Thread Anton Khirnov
Quoting Paul B Mahol (2021-02-17 14:33:25)
> On Wed, Feb 17, 2021 at 12:31 PM Anton Khirnov  wrote:
> 
> Is helgrind report clean with your patch set?

Helgrind is not clean before your patch, after your patch, or after my
set. The reason is because helgrind does not understand atomics, so its
reports are bogus.

-- 
Anton Khirnov
___
ffmpeg-devel mailing list
ffmpeg-devel@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 v6 3/9] avformat: add vvc raw demux

2021-02-18 Thread Nuo Mi
On Thu, Feb 18, 2021 at 6:52 AM Mark Thompson  wrote:

> On 17/02/2021 01:51, Nuo Mi wrote:
>
> > +for (i = 0; i < p->buf_size - 1; i++) {
> > +code = (code << 8) + p->buf[i];
> > +if ((code & 0xff00) == 0x100) {
> > +uint8_t nal2 = p->buf[i + 1];
> > +int type = (nal2 & 0xF8) >> 3;
> > +
> > +if (code & 0xc0) // forbidden_zero_bit and
> nuh_reserved_zero_bit
> > +return 0;
> > +
> > +if ((nal2 & 0x7) == 0) // nuh_temporal_id_plus1
> > +return 0;
> > +
> > +switch (type) {
> > +case VVC_SPS_NUT:   sps++;  break;
> > +case VVC_PPS_NUT:   pps++;  break;
> > +case VVC_IDR_N_LP:
> > +case VVC_IDR_W_RADL:
> > +case VVC_CRA_NUT:
> > +case VVC_GDR_NUT:   irap++; break;
> > +}
> > +}
> > +}
> > +
> > +if (sps && pps && irap)
> > +return AVPROBE_SCORE_EXTENSION + 1; // 1 more than .mpg
>
> How well does this test fully distinguish from previous standards using
> the same start code style?
>
> (Can I have an H.264 or H.265 raw stream which passes this test?  Can an
> H.266 stream ever pass the test for those codecs, implying we need to
> update them?)
>
The nal_unit_type located in a different byte. When a H.265 bitstream
has nuh_layer_ids equal to  VVC_SPS_NUT,  VVC_PPS_NUT and  VVC_IDR_N_LP,
can pass the test. Vice versa
All h266 conformance test clips will not detect as other formats. But if
you have a well-designed clip, it may be. This is normal case for a raw
bytestream detector.

>
> > +return 0;
> > +}
> > +
> > +FF_DEF_RAWVIDEO_DEMUXER(vvc, "raw VVC video", vvc_probe,
> "h266,266,vvc", AV_CODEC_ID_VVC)
> >
>
> - Mark
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@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 v6 2/9] avcodec/vvc: add shared header for vvc

2021-02-18 Thread Nuo Mi
>
>
>
> > +enum {
> > +//6.2 we can have 3 sample arrays
> > +MAX_SAMPLE_ARRAYS = 3,
>
> Needs the "VVC_" prefix.
>
fixed

>
> > +
> > +//7.4.3.3 vps_max_layers_minus1 is u(6)
> > +VVC_MAX_LAYERS = 64,
> > +
> > +//7.4.3.3 The value of vps_max_sublayers_minus1 shall be in the
> range of 0 to 6, inclusive
> > +VVC_MAX_SUBLAYERS = 7,
> > +
> > +//7.4.3.3 vps_num_ptls_minus1 is u(8)
> > +VVC_MAX_PTLS = 256,
> > +
> > +//7.4.3.3 vps_num_output_layer_sets_minus2 is u(8)
> > +VVC_MAX_TOTAL_NUM_OLSS = 257,
> > +
> > +// 7.3.2.3: vps_video_parameter_set_id is u(4).
> > +VVC_MAX_VPS_COUNT = 16,
> > +// 7.3.2.4: sps_seq_parameter_set_id is u(4)
> > +VVC_MAX_SPS_COUNT = 16,
> > +// 7.3.2.5: pps_pic_parameter_set_id is u(6)
> > +VVC_MAX_PPS_COUNT = 64,
> > +
> > +// 7.4.4.1: ptl_num_sub_profiles is u(8)
> > +VVC_MAX_SUB_PROFILES = 256,
> > +
> > +// A.4.2: according to (1577), MaxDpbSize is bounded above by 2 *
> maxDpbPicBuf(8)
> > +VVC_MAX_DPB_SIZE = 16,
> > +
> > +//7.4.3.4 sps_num_ref_pic_lists in range [0, 64]
> > +VVC_MAX_REF_PIC_LISTS = 64,
> > +
> > +//7.4.11 num_ref_entries in range [0, MaxDpbSize + 13]
> > +VVC_MAX_REF_ENTRIES = VVC_MAX_DPB_SIZE + 13,
> > +
> > +//7.4.3.3 sps_num_points_in_qp_table_minus1[i] in range [0, 36 −
> sps_qp_table_start_minus26[i]],
> > +//sps_qp_table_start_minus26[i] in range
> [sps_qp_table_start_minus26[i] −26 − QpBdOffset, 36]
> > +//for 10 bitsQpBdOffset is 12, so
> sps_num_points_in_qp_table_minus1[i] in range [0, 74]
> > +VVC_MAX_POINTS_IN_QP_TABLE = 75,
> > +
> > +// 7.4.6.1: hrd_cpb_cnt_minus1 is in [0, 31].
> > +VVC_MAX_CPB_CNT = 32,
> > +
> > +// A.4.1: the highest level allows a MaxLumaPs of 35 651 584.
> > +VVC_MAX_LUMA_PS = 35651584,
> > +
> > +// A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples
> are
> > +// constrained to be not greater than sqrt(MaxLumaPs * 8).  Hence
> height/
> > +// width are bounded above by sqrt(8 * 35651584) = 16888.2 samples.
> > +VVC_MAX_WIDTH  = 16888,
> > +VVC_MAX_HEIGHT = 16888,
> > +
> > +// A.4.1: table A.1 allows at most 440 tiles per au for any level.
> > +VVC_MAX_TILES_PER_AU = 440,
> > +// A.4.1: table A.1 did not define max tile rows.
> > +// in worest a case, we can have 1x440 tiles picture.
> > +VVC_MAX_TILE_ROWS= VVC_MAX_TILES_PER_AU,
> > +// A.4.1: table A.1 allows at most 20 tile columns for any level.
> > +VVC_MAX_TILE_COLUMNS = 20,
> > +
> > +// A.4.1 table A.1 allows at most 600 slice for any level.
> > +VVC_MAX_SLICES = 600,
> > +
> > +// 7.4.8: in the worst case (tiles_enabled_flag and
> > +// entropy_coding_sync_enabled_flag are both set), entry points can
> be
> > +// placed at the beginning of every Ctb row in every tile, giving an
> > +// upper bound of (num_tile_columns_minus1 + 1) * PicHeightInCtbsY
> - 1.
> > +// Only a stream with very high resolution and perverse parameters
> could
> > +// get near that, though, so set a lower limit here with the maximum
> > +// possible value for 8K video (at most 135 32x32 Ctb rows).
> Not all of the variable names from H.265 mentioned here exist in H.266
> (e.g. there is no tiles_enabled_flag).  It should be updated to use the
> correct names for H.266.
>
Fixed

>
> > +VVC_MAX_ENTRY_POINTS = VVC_MAX_TILE_COLUMNS * 135,
> > +};
> > +
> > +#endif /* AVCODEC_VVC_H */
> >
>
> - Mark
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v2 2/6] avformat/mxfenc: Use user-specified version even when bitexact

2021-02-18 Thread Tomas Härdin
mån 2021-02-15 klockan 17:55 +0100 skrev Andreas Rheinhardt:
> Doing so is still bitexact.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/mxfenc.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index 509cae8442..3bfe2a5c1a 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -762,16 +762,15 @@ static void mxf_write_identification(AVFormatContext *s)
>  AVDictionaryEntry *version_entry = av_dict_get(s->metadata, 
> "product_version", NULL, 0);
>  const char *company = com_entry ? com_entry->value : "FFmpeg";
>  const char *product = product_entry ? product_entry->value : s->oformat 
> != _mxf_opatom_muxer ? "OP1a Muxer" : "OPAtom Muxer";
> -const char *product_version = version_entry ? version_entry->value : 
> AV_STRINGIFY(LIBAVFORMAT_VERSION);
>  const char *platform = s->flags & AVFMT_FLAG_BITEXACT ? "Lavf" : 
> PLATFROM_IDENT;
> -const char *version;
> +const char *version = version_entry ? version_entry->value :
> +  s->flags & AVFMT_FLAG_BITEXACT ? "0.0.0" :
> +  AV_STRINGIFY(LIBAVFORMAT_VERSION);

Looks OK

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