diff --git a/media/ffvpx/compat/atomics/win32/stdatomic.h b/media/ffvpx/compat/atomics/win32/stdatomic.h index bb8e6e7e15a5..28a627bfd3d9 100644 --- a/media/ffvpx/compat/atomics/win32/stdatomic.h +++ b/media/ffvpx/compat/atomics/win32/stdatomic.h @@ -96,7 +96,7 @@ do { \ atomic_load(object) #define atomic_exchange(object, desired) \ - InterlockedExchangePointer(object, desired); + InterlockedExchangePointer((PVOID volatile *)object, (PVOID)desired) #define atomic_exchange_explicit(object, desired, order) \ atomic_exchange(object, desired) diff --git a/media/ffvpx/compat/w32pthreads.h b/media/ffvpx/compat/w32pthreads.h index 21acfd2ba1a9..b7a65b233b7b 100644 --- a/media/ffvpx/compat/w32pthreads.h +++ b/media/ffvpx/compat/w32pthreads.h @@ -38,11 +38,13 @@ #define WIN32_LEAN_AND_MEAN #include #include +#include #include "libavutil/attributes.h" #include "libavutil/common.h" #include "libavutil/internal.h" #include "libavutil/mem.h" +#include "libavutil/fftime.h" typedef struct pthread_t { void *handle; @@ -61,6 +63,9 @@ typedef CONDITION_VARIABLE pthread_cond_t; #define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0) #define WaitForSingleObject(a, b) WaitForSingleObjectEx(a, b, FALSE) +#define PTHREAD_CANCEL_ENABLE 1 +#define PTHREAD_CANCEL_DISABLE 0 + static av_unused unsigned __stdcall attribute_align_arg win32thread_worker(void *arg) { pthread_t *h = (pthread_t*)arg; @@ -156,10 +161,31 @@ static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex return 0; } +static inline int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, + const struct timespec *abstime) +{ + int64_t abs_milli = abstime->tv_sec * 1000LL + abstime->tv_nsec / 1000000; + DWORD t = av_clip64(abs_milli - av_gettime() / 1000, 0, UINT32_MAX); + + if (!SleepConditionVariableSRW(cond, mutex, t, 0)) { + DWORD err = GetLastError(); + if (err == ERROR_TIMEOUT) + return ETIMEDOUT; + else + return EINVAL; + } + return 0; +} + static inline int pthread_cond_signal(pthread_cond_t *cond) { WakeConditionVariable(cond); return 0; } +static inline int pthread_setcancelstate(int state, int *oldstate) +{ + return 0; +} + #endif /* COMPAT_W32PTHREADS_H */ diff --git a/media/ffvpx/libavcodec/aarch64/fft_neon.S b/media/ffvpx/libavcodec/aarch64/fft_neon.S index 862039f97dd9..9ff3f9c52627 100644 --- a/media/ffvpx/libavcodec/aarch64/fft_neon.S +++ b/media/ffvpx/libavcodec/aarch64/fft_neon.S @@ -36,6 +36,7 @@ function fft4_neon + AARCH64_VALID_JUMP_TARGET ld1 {v0.2s,v1.2s,v2.2s,v3.2s}, [x0] fadd v4.2s, v0.2s, v1.2s // r0+r1,i0+i1 @@ -58,6 +59,7 @@ function fft4_neon endfunc function fft8_neon + AARCH64_VALID_JUMP_TARGET mov x1, x0 ld1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x0], #32 ld1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0] @@ -108,6 +110,7 @@ function fft8_neon endfunc function fft16_neon + AARCH64_VALID_JUMP_TARGET mov x1, x0 ld1 {v0.2s, v1.2s, v2.2s, v3.2s}, [x0], #32 ld1 {v16.2s,v17.2s,v18.2s,v19.2s}, [x0], #32 @@ -337,6 +340,8 @@ endfunc .macro def_fft n, n2, n4 function fft\n\()_neon, align=6 + AARCH64_VALID_JUMP_TARGET + AARCH64_SIGN_LINK_REGISTER sub sp, sp, #16 stp x28, x30, [sp] add x28, x0, #\n4*2*8 @@ -347,6 +352,7 @@ function fft\n\()_neon, align=6 bl fft\n4\()_neon sub x0, x28, #\n4*2*8 ldp x28, x30, [sp], #16 + AARCH64_VALIDATE_LINK_REGISTER movrel x4, X(ff_cos_\n) mov x2, #\n4>>1 b fft_pass_neon diff --git a/media/ffvpx/libavcodec/aarch64/h264cmc_neon.S b/media/ffvpx/libavcodec/aarch64/h264cmc_neon.S index 8be757800117..f8e94078546d 100644 --- a/media/ffvpx/libavcodec/aarch64/h264cmc_neon.S +++ b/media/ffvpx/libavcodec/aarch64/h264cmc_neon.S @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config_components.h" + #include "libavutil/aarch64/asm.S" /* chroma_mc8(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h, int x, int y) */ diff --git a/media/ffvpx/libavcodec/aarch64/h264dsp_init_aarch64.c b/media/ffvpx/libavcodec/aarch64/h264dsp_init_aarch64.c index d5baccf2355e..6bf3ecb8a1e1 100644 --- a/media/ffvpx/libavcodec/aarch64/h264dsp_init_aarch64.c +++ b/media/ffvpx/libavcodec/aarch64/h264dsp_init_aarch64.c @@ -69,19 +69,42 @@ void ff_h264_idct_add_neon(uint8_t *dst, int16_t *block, int stride); void ff_h264_idct_dc_add_neon(uint8_t *dst, int16_t *block, int stride); void ff_h264_idct_add16_neon(uint8_t *dst, const int *block_offset, int16_t *block, int stride, - const uint8_t nnzc[6*8]); + const uint8_t nnzc[5 * 8]); void ff_h264_idct_add16intra_neon(uint8_t *dst, const int *block_offset, int16_t *block, int stride, - const uint8_t nnzc[6*8]); + const uint8_t nnzc[5 * 8]); void ff_h264_idct_add8_neon(uint8_t **dest, const int *block_offset, int16_t *block, int stride, - const uint8_t nnzc[6*8]); + const uint8_t nnzc[15 * 8]); void ff_h264_idct8_add_neon(uint8_t *dst, int16_t *block, int stride); void ff_h264_idct8_dc_add_neon(uint8_t *dst, int16_t *block, int stride); void ff_h264_idct8_add4_neon(uint8_t *dst, const int *block_offset, int16_t *block, int stride, - const uint8_t nnzc[6*8]); + const uint8_t nnzc[5 * 8]); + +void ff_h264_v_loop_filter_luma_neon_10(uint8_t *pix, ptrdiff_t stride, int alpha, + int beta, int8_t *tc0); +void ff_h264_h_loop_filter_luma_neon_10(uint8_t *pix, ptrdiff_t stride, int alpha, + int beta, int8_t *tc0); +void ff_h264_v_loop_filter_luma_intra_neon_10(uint8_t *pix, ptrdiff_t stride, int alpha, + int beta); +void ff_h264_h_loop_filter_luma_intra_neon_10(uint8_t *pix, ptrdiff_t stride, int alpha, + int beta); +void ff_h264_v_loop_filter_chroma_neon_10(uint8_t *pix, ptrdiff_t stride, int alpha, + int beta, int8_t *tc0); +void ff_h264_h_loop_filter_chroma_neon_10(uint8_t *pix, ptrdiff_t stride, int alpha, + int beta, int8_t *tc0); +void ff_h264_h_loop_filter_chroma422_neon_10(uint8_t *pix, ptrdiff_t stride, int alpha, + int beta, int8_t *tc0); +void ff_h264_v_loop_filter_chroma_intra_neon_10(uint8_t *pix, ptrdiff_t stride, + int alpha, int beta); +void ff_h264_h_loop_filter_chroma_intra_neon_10(uint8_t *pix, ptrdiff_t stride, + int alpha, int beta); +void ff_h264_h_loop_filter_chroma422_intra_neon_10(uint8_t *pix, ptrdiff_t stride, + int alpha, int beta); +void ff_h264_h_loop_filter_chroma_mbaff_intra_neon_10(uint8_t *pix, ptrdiff_t stride, + int alpha, int beta); av_cold void ff_h264dsp_init_aarch64(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) @@ -125,5 +148,19 @@ av_cold void ff_h264dsp_init_aarch64(H264DSPContext *c, const int bit_depth, c->h264_idct8_add = ff_h264_idct8_add_neon; c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon; c->h264_idct8_add4 = ff_h264_idct8_add4_neon; + } else if (have_neon(cpu_flags) && bit_depth == 10) { + c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon_10; + c->h264_v_loop_filter_chroma_intra = ff_h264_v_loop_filter_chroma_intra_neon_10; + + if (chroma_format_idc <= 1) { + c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma_neon_10; + c->h264_h_loop_filter_chroma_intra = ff_h264_h_loop_filter_chroma_intra_neon_10; + c->h264_h_loop_filter_chroma_mbaff_intra = ff_h264_h_loop_filter_chroma_mbaff_intra_neon_10; + } else { + c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma422_neon_10; + c->h264_h_loop_filter_chroma_mbaff = ff_h264_h_loop_filter_chroma_neon_10; + c->h264_h_loop_filter_chroma_intra = ff_h264_h_loop_filter_chroma422_intra_neon_10; + c->h264_h_loop_filter_chroma_mbaff_intra = ff_h264_h_loop_filter_chroma_intra_neon_10; + } } } diff --git a/media/ffvpx/libavcodec/aarch64/h264dsp_neon.S b/media/ffvpx/libavcodec/aarch64/h264dsp_neon.S index fbb8ecc463b2..ea221e6862e0 100644 --- a/media/ffvpx/libavcodec/aarch64/h264dsp_neon.S +++ b/media/ffvpx/libavcodec/aarch64/h264dsp_neon.S @@ -110,7 +110,6 @@ function ff_h264_v_loop_filter_luma_neon, export=1 h264_loop_filter_start - sxtw x1, w1 ld1 {v0.16B}, [x0], x1 ld1 {v2.16B}, [x0], x1 @@ -134,7 +133,6 @@ endfunc function ff_h264_h_loop_filter_luma_neon, export=1 h264_loop_filter_start - sxtw x1, w1 sub x0, x0, #4 ld1 {v6.8B}, [x0], x1 @@ -184,199 +182,198 @@ endfunc .macro h264_loop_filter_start_intra - orr w4, w2, w3 - cbnz w4, 1f - ret + orr w4, w2, w3 + cbnz w4, 1f + ret 1: - sxtw x1, w1 - dup v30.16b, w2 // alpha - dup v31.16b, w3 // beta + dup v30.16b, w2 // alpha + dup v31.16b, w3 // beta .endm .macro h264_loop_filter_luma_intra - uabd v16.16b, v7.16b, v0.16b // abs(p0 - q0) - uabd v17.16b, v6.16b, v7.16b // abs(p1 - p0) - uabd v18.16b, v1.16b, v0.16b // abs(q1 - q0) - cmhi v19.16b, v30.16b, v16.16b // < alpha - cmhi v17.16b, v31.16b, v17.16b // < beta - cmhi v18.16b, v31.16b, v18.16b // < beta + uabd v16.16b, v7.16b, v0.16b // abs(p0 - q0) + uabd v17.16b, v6.16b, v7.16b // abs(p1 - p0) + uabd v18.16b, v1.16b, v0.16b // abs(q1 - q0) + cmhi v19.16b, v30.16b, v16.16b // < alpha + cmhi v17.16b, v31.16b, v17.16b // < beta + cmhi v18.16b, v31.16b, v18.16b // < beta - movi v29.16b, #2 - ushr v30.16b, v30.16b, #2 // alpha >> 2 - add v30.16b, v30.16b, v29.16b // (alpha >> 2) + 2 - cmhi v16.16b, v30.16b, v16.16b // < (alpha >> 2) + 2 + movi v29.16b, #2 + ushr v30.16b, v30.16b, #2 // alpha >> 2 + add v30.16b, v30.16b, v29.16b // (alpha >> 2) + 2 + cmhi v16.16b, v30.16b, v16.16b // < (alpha >> 2) + 2 - and v19.16b, v19.16b, v17.16b - and v19.16b, v19.16b, v18.16b - shrn v20.8b, v19.8h, #4 - mov x4, v20.d[0] - cbz x4, 9f + and v19.16b, v19.16b, v17.16b + and v19.16b, v19.16b, v18.16b + shrn v20.8b, v19.8h, #4 + mov x4, v20.d[0] + cbz x4, 9f - ushll v20.8h, v6.8b, #1 - ushll v22.8h, v1.8b, #1 - ushll2 v21.8h, v6.16b, #1 - ushll2 v23.8h, v1.16b, #1 - uaddw v20.8h, v20.8h, v7.8b - uaddw v22.8h, v22.8h, v0.8b - uaddw2 v21.8h, v21.8h, v7.16b - uaddw2 v23.8h, v23.8h, v0.16b - uaddw v20.8h, v20.8h, v1.8b - uaddw v22.8h, v22.8h, v6.8b - uaddw2 v21.8h, v21.8h, v1.16b - uaddw2 v23.8h, v23.8h, v6.16b + ushll v20.8h, v6.8b, #1 + ushll v22.8h, v1.8b, #1 + ushll2 v21.8h, v6.16b, #1 + ushll2 v23.8h, v1.16b, #1 + uaddw v20.8h, v20.8h, v7.8b + uaddw v22.8h, v22.8h, v0.8b + uaddw2 v21.8h, v21.8h, v7.16b + uaddw2 v23.8h, v23.8h, v0.16b + uaddw v20.8h, v20.8h, v1.8b + uaddw v22.8h, v22.8h, v6.8b + uaddw2 v21.8h, v21.8h, v1.16b + uaddw2 v23.8h, v23.8h, v6.16b - rshrn v24.8b, v20.8h, #2 // p0'_1 - rshrn v25.8b, v22.8h, #2 // q0'_1 - rshrn2 v24.16b, v21.8h, #2 // p0'_1 - rshrn2 v25.16b, v23.8h, #2 // q0'_1 + rshrn v24.8b, v20.8h, #2 // p0'_1 + rshrn v25.8b, v22.8h, #2 // q0'_1 + rshrn2 v24.16b, v21.8h, #2 // p0'_1 + rshrn2 v25.16b, v23.8h, #2 // q0'_1 - uabd v17.16b, v5.16b, v7.16b // abs(p2 - p0) - uabd v18.16b, v2.16b, v0.16b // abs(q2 - q0) - cmhi v17.16b, v31.16b, v17.16b // < beta - cmhi v18.16b, v31.16b, v18.16b // < beta + uabd v17.16b, v5.16b, v7.16b // abs(p2 - p0) + uabd v18.16b, v2.16b, v0.16b // abs(q2 - q0) + cmhi v17.16b, v31.16b, v17.16b // < beta + cmhi v18.16b, v31.16b, v18.16b // < beta - and v17.16b, v16.16b, v17.16b // if_2 && if_3 - and v18.16b, v16.16b, v18.16b // if_2 && if_4 + and v17.16b, v16.16b, v17.16b // if_2 && if_3 + and v18.16b, v16.16b, v18.16b // if_2 && if_4 - not v30.16b, v17.16b - not v31.16b, v18.16b + not v30.16b, v17.16b + not v31.16b, v18.16b - and v30.16b, v30.16b, v19.16b // if_1 && !(if_2 && if_3) - and v31.16b, v31.16b, v19.16b // if_1 && !(if_2 && if_4) + and v30.16b, v30.16b, v19.16b // if_1 && !(if_2 && if_3) + and v31.16b, v31.16b, v19.16b // if_1 && !(if_2 && if_4) - and v17.16b, v19.16b, v17.16b // if_1 && if_2 && if_3 - and v18.16b, v19.16b, v18.16b // if_1 && if_2 && if_4 + and v17.16b, v19.16b, v17.16b // if_1 && if_2 && if_3 + and v18.16b, v19.16b, v18.16b // if_1 && if_2 && if_4 - //calc p, v7, v6, v5, v4, v17, v7, v6, v5, v4 - uaddl v26.8h, v5.8b, v7.8b - uaddl2 v27.8h, v5.16b, v7.16b - uaddw v26.8h, v26.8h, v0.8b - uaddw2 v27.8h, v27.8h, v0.16b - add v20.8h, v20.8h, v26.8h - add v21.8h, v21.8h, v27.8h - uaddw v20.8h, v20.8h, v0.8b - uaddw2 v21.8h, v21.8h, v0.16b - rshrn v20.8b, v20.8h, #3 // p0'_2 - rshrn2 v20.16b, v21.8h, #3 // p0'_2 - uaddw v26.8h, v26.8h, v6.8b - uaddw2 v27.8h, v27.8h, v6.16b - rshrn v21.8b, v26.8h, #2 // p1'_2 - rshrn2 v21.16b, v27.8h, #2 // p1'_2 - uaddl v28.8h, v4.8b, v5.8b - uaddl2 v29.8h, v4.16b, v5.16b - shl v28.8h, v28.8h, #1 - shl v29.8h, v29.8h, #1 - add v28.8h, v28.8h, v26.8h - add v29.8h, v29.8h, v27.8h - rshrn v19.8b, v28.8h, #3 // p2'_2 - rshrn2 v19.16b, v29.8h, #3 // p2'_2 + //calc p, v7, v6, v5, v4, v17, v7, v6, v5, v4 + uaddl v26.8h, v5.8b, v7.8b + uaddl2 v27.8h, v5.16b, v7.16b + uaddw v26.8h, v26.8h, v0.8b + uaddw2 v27.8h, v27.8h, v0.16b + add v20.8h, v20.8h, v26.8h + add v21.8h, v21.8h, v27.8h + uaddw v20.8h, v20.8h, v0.8b + uaddw2 v21.8h, v21.8h, v0.16b + rshrn v20.8b, v20.8h, #3 // p0'_2 + rshrn2 v20.16b, v21.8h, #3 // p0'_2 + uaddw v26.8h, v26.8h, v6.8b + uaddw2 v27.8h, v27.8h, v6.16b + rshrn v21.8b, v26.8h, #2 // p1'_2 + rshrn2 v21.16b, v27.8h, #2 // p1'_2 + uaddl v28.8h, v4.8b, v5.8b + uaddl2 v29.8h, v4.16b, v5.16b + shl v28.8h, v28.8h, #1 + shl v29.8h, v29.8h, #1 + add v28.8h, v28.8h, v26.8h + add v29.8h, v29.8h, v27.8h + rshrn v19.8b, v28.8h, #3 // p2'_2 + rshrn2 v19.16b, v29.8h, #3 // p2'_2 - //calc q, v0, v1, v2, v3, v18, v0, v1, v2, v3 - uaddl v26.8h, v2.8b, v0.8b - uaddl2 v27.8h, v2.16b, v0.16b - uaddw v26.8h, v26.8h, v7.8b - uaddw2 v27.8h, v27.8h, v7.16b - add v22.8h, v22.8h, v26.8h - add v23.8h, v23.8h, v27.8h - uaddw v22.8h, v22.8h, v7.8b - uaddw2 v23.8h, v23.8h, v7.16b - rshrn v22.8b, v22.8h, #3 // q0'_2 - rshrn2 v22.16b, v23.8h, #3 // q0'_2 - uaddw v26.8h, v26.8h, v1.8b - uaddw2 v27.8h, v27.8h, v1.16b - rshrn v23.8b, v26.8h, #2 // q1'_2 - rshrn2 v23.16b, v27.8h, #2 // q1'_2 - uaddl v28.8h, v2.8b, v3.8b - uaddl2 v29.8h, v2.16b, v3.16b - shl v28.8h, v28.8h, #1 - shl v29.8h, v29.8h, #1 - add v28.8h, v28.8h, v26.8h - add v29.8h, v29.8h, v27.8h - rshrn v26.8b, v28.8h, #3 // q2'_2 - rshrn2 v26.16b, v29.8h, #3 // q2'_2 + //calc q, v0, v1, v2, v3, v18, v0, v1, v2, v3 + uaddl v26.8h, v2.8b, v0.8b + uaddl2 v27.8h, v2.16b, v0.16b + uaddw v26.8h, v26.8h, v7.8b + uaddw2 v27.8h, v27.8h, v7.16b + add v22.8h, v22.8h, v26.8h + add v23.8h, v23.8h, v27.8h + uaddw v22.8h, v22.8h, v7.8b + uaddw2 v23.8h, v23.8h, v7.16b + rshrn v22.8b, v22.8h, #3 // q0'_2 + rshrn2 v22.16b, v23.8h, #3 // q0'_2 + uaddw v26.8h, v26.8h, v1.8b + uaddw2 v27.8h, v27.8h, v1.16b + rshrn v23.8b, v26.8h, #2 // q1'_2 + rshrn2 v23.16b, v27.8h, #2 // q1'_2 + uaddl v28.8h, v2.8b, v3.8b + uaddl2 v29.8h, v2.16b, v3.16b + shl v28.8h, v28.8h, #1 + shl v29.8h, v29.8h, #1 + add v28.8h, v28.8h, v26.8h + add v29.8h, v29.8h, v27.8h + rshrn v26.8b, v28.8h, #3 // q2'_2 + rshrn2 v26.16b, v29.8h, #3 // q2'_2 - bit v7.16b, v24.16b, v30.16b // p0'_1 - bit v0.16b, v25.16b, v31.16b // q0'_1 - bit v7.16b, v20.16b, v17.16b // p0'_2 - bit v6.16b, v21.16b, v17.16b // p1'_2 - bit v5.16b, v19.16b, v17.16b // p2'_2 - bit v0.16b, v22.16b, v18.16b // q0'_2 - bit v1.16b, v23.16b, v18.16b // q1'_2 - bit v2.16b, v26.16b, v18.16b // q2'_2 + bit v7.16b, v24.16b, v30.16b // p0'_1 + bit v0.16b, v25.16b, v31.16b // q0'_1 + bit v7.16b, v20.16b, v17.16b // p0'_2 + bit v6.16b, v21.16b, v17.16b // p1'_2 + bit v5.16b, v19.16b, v17.16b // p2'_2 + bit v0.16b, v22.16b, v18.16b // q0'_2 + bit v1.16b, v23.16b, v18.16b // q1'_2 + bit v2.16b, v26.16b, v18.16b // q2'_2 .endm function ff_h264_v_loop_filter_luma_intra_neon, export=1 - h264_loop_filter_start_intra + h264_loop_filter_start_intra - ld1 {v0.16b}, [x0], x1 // q0 - ld1 {v1.16b}, [x0], x1 // q1 - ld1 {v2.16b}, [x0], x1 // q2 - ld1 {v3.16b}, [x0], x1 // q3 - sub x0, x0, x1, lsl #3 - ld1 {v4.16b}, [x0], x1 // p3 - ld1 {v5.16b}, [x0], x1 // p2 - ld1 {v6.16b}, [x0], x1 // p1 - ld1 {v7.16b}, [x0] // p0 + ld1 {v0.16b}, [x0], x1 // q0 + ld1 {v1.16b}, [x0], x1 // q1 + ld1 {v2.16b}, [x0], x1 // q2 + ld1 {v3.16b}, [x0], x1 // q3 + sub x0, x0, x1, lsl #3 + ld1 {v4.16b}, [x0], x1 // p3 + ld1 {v5.16b}, [x0], x1 // p2 + ld1 {v6.16b}, [x0], x1 // p1 + ld1 {v7.16b}, [x0] // p0 - h264_loop_filter_luma_intra + h264_loop_filter_luma_intra - sub x0, x0, x1, lsl #1 - st1 {v5.16b}, [x0], x1 // p2 - st1 {v6.16b}, [x0], x1 // p1 - st1 {v7.16b}, [x0], x1 // p0 - st1 {v0.16b}, [x0], x1 // q0 - st1 {v1.16b}, [x0], x1 // q1 - st1 {v2.16b}, [x0] // q2 + sub x0, x0, x1, lsl #1 + st1 {v5.16b}, [x0], x1 // p2 + st1 {v6.16b}, [x0], x1 // p1 + st1 {v7.16b}, [x0], x1 // p0 + st1 {v0.16b}, [x0], x1 // q0 + st1 {v1.16b}, [x0], x1 // q1 + st1 {v2.16b}, [x0] // q2 9: - ret + ret endfunc function ff_h264_h_loop_filter_luma_intra_neon, export=1 - h264_loop_filter_start_intra + h264_loop_filter_start_intra - sub x0, x0, #4 - ld1 {v4.8b}, [x0], x1 - ld1 {v5.8b}, [x0], x1 - ld1 {v6.8b}, [x0], x1 - ld1 {v7.8b}, [x0], x1 - ld1 {v0.8b}, [x0], x1 - ld1 {v1.8b}, [x0], x1 - ld1 {v2.8b}, [x0], x1 - ld1 {v3.8b}, [x0], x1 - ld1 {v4.d}[1], [x0], x1 - ld1 {v5.d}[1], [x0], x1 - ld1 {v6.d}[1], [x0], x1 - ld1 {v7.d}[1], [x0], x1 - ld1 {v0.d}[1], [x0], x1 - ld1 {v1.d}[1], [x0], x1 - ld1 {v2.d}[1], [x0], x1 - ld1 {v3.d}[1], [x0], x1 + sub x0, x0, #4 + ld1 {v4.8b}, [x0], x1 + ld1 {v5.8b}, [x0], x1 + ld1 {v6.8b}, [x0], x1 + ld1 {v7.8b}, [x0], x1 + ld1 {v0.8b}, [x0], x1 + ld1 {v1.8b}, [x0], x1 + ld1 {v2.8b}, [x0], x1 + ld1 {v3.8b}, [x0], x1 + ld1 {v4.d}[1], [x0], x1 + ld1 {v5.d}[1], [x0], x1 + ld1 {v6.d}[1], [x0], x1 + ld1 {v7.d}[1], [x0], x1 + ld1 {v0.d}[1], [x0], x1 + ld1 {v1.d}[1], [x0], x1 + ld1 {v2.d}[1], [x0], x1 + ld1 {v3.d}[1], [x0], x1 - transpose_8x16B v4, v5, v6, v7, v0, v1, v2, v3, v21, v23 + transpose_8x16B v4, v5, v6, v7, v0, v1, v2, v3, v21, v23 - h264_loop_filter_luma_intra + h264_loop_filter_luma_intra - transpose_8x16B v4, v5, v6, v7, v0, v1, v2, v3, v21, v23 + transpose_8x16B v4, v5, v6, v7, v0, v1, v2, v3, v21, v23 - sub x0, x0, x1, lsl #4 - st1 {v4.8b}, [x0], x1 - st1 {v5.8b}, [x0], x1 - st1 {v6.8b}, [x0], x1 - st1 {v7.8b}, [x0], x1 - st1 {v0.8b}, [x0], x1 - st1 {v1.8b}, [x0], x1 - st1 {v2.8b}, [x0], x1 - st1 {v3.8b}, [x0], x1 - st1 {v4.d}[1], [x0], x1 - st1 {v5.d}[1], [x0], x1 - st1 {v6.d}[1], [x0], x1 - st1 {v7.d}[1], [x0], x1 - st1 {v0.d}[1], [x0], x1 - st1 {v1.d}[1], [x0], x1 - st1 {v2.d}[1], [x0], x1 - st1 {v3.d}[1], [x0], x1 + sub x0, x0, x1, lsl #4 + st1 {v4.8b}, [x0], x1 + st1 {v5.8b}, [x0], x1 + st1 {v6.8b}, [x0], x1 + st1 {v7.8b}, [x0], x1 + st1 {v0.8b}, [x0], x1 + st1 {v1.8b}, [x0], x1 + st1 {v2.8b}, [x0], x1 + st1 {v3.8b}, [x0], x1 + st1 {v4.d}[1], [x0], x1 + st1 {v5.d}[1], [x0], x1 + st1 {v6.d}[1], [x0], x1 + st1 {v7.d}[1], [x0], x1 + st1 {v0.d}[1], [x0], x1 + st1 {v1.d}[1], [x0], x1 + st1 {v2.d}[1], [x0], x1 + st1 {v3.d}[1], [x0], x1 9: - ret + ret endfunc .macro h264_loop_filter_chroma @@ -414,7 +411,6 @@ endfunc function ff_h264_v_loop_filter_chroma_neon, export=1 h264_loop_filter_start - sxtw x1, w1 sub x0, x0, x1, lsl #1 ld1 {v18.8B}, [x0], x1 @@ -433,7 +429,6 @@ endfunc function ff_h264_h_loop_filter_chroma_neon, export=1 h264_loop_filter_start - sxtw x1, w1 sub x0, x0, #2 h_loop_filter_chroma420: @@ -466,7 +461,6 @@ h_loop_filter_chroma420: endfunc function ff_h264_h_loop_filter_chroma422_neon, export=1 - sxtw x1, w1 h264_loop_filter_start add x5, x0, x1 sub x0, x0, #2 @@ -480,113 +474,113 @@ function ff_h264_h_loop_filter_chroma422_neon, export=1 endfunc .macro h264_loop_filter_chroma_intra - uabd v26.8b, v16.8b, v17.8b // abs(p0 - q0) - uabd v27.8b, v18.8b, v16.8b // abs(p1 - p0) - uabd v28.8b, v19.8b, v17.8b // abs(q1 - q0) - cmhi v26.8b, v30.8b, v26.8b // < alpha - cmhi v27.8b, v31.8b, v27.8b // < beta - cmhi v28.8b, v31.8b, v28.8b // < beta - and v26.8b, v26.8b, v27.8b - and v26.8b, v26.8b, v28.8b - mov x2, v26.d[0] + uabd v26.8b, v16.8b, v17.8b // abs(p0 - q0) + uabd v27.8b, v18.8b, v16.8b // abs(p1 - p0) + uabd v28.8b, v19.8b, v17.8b // abs(q1 - q0) + cmhi v26.8b, v30.8b, v26.8b // < alpha + cmhi v27.8b, v31.8b, v27.8b // < beta + cmhi v28.8b, v31.8b, v28.8b // < beta + and v26.8b, v26.8b, v27.8b + and v26.8b, v26.8b, v28.8b + mov x2, v26.d[0] - ushll v4.8h, v18.8b, #1 - ushll v6.8h, v19.8b, #1 - cbz x2, 9f - uaddl v20.8h, v16.8b, v19.8b - uaddl v22.8h, v17.8b, v18.8b - add v20.8h, v20.8h, v4.8h - add v22.8h, v22.8h, v6.8h - uqrshrn v24.8b, v20.8h, #2 - uqrshrn v25.8b, v22.8h, #2 - bit v16.8b, v24.8b, v26.8b - bit v17.8b, v25.8b, v26.8b + ushll v4.8h, v18.8b, #1 + ushll v6.8h, v19.8b, #1 + cbz x2, 9f + uaddl v20.8h, v16.8b, v19.8b + uaddl v22.8h, v17.8b, v18.8b + add v20.8h, v20.8h, v4.8h + add v22.8h, v22.8h, v6.8h + uqrshrn v24.8b, v20.8h, #2 + uqrshrn v25.8b, v22.8h, #2 + bit v16.8b, v24.8b, v26.8b + bit v17.8b, v25.8b, v26.8b .endm function ff_h264_v_loop_filter_chroma_intra_neon, export=1 - h264_loop_filter_start_intra + h264_loop_filter_start_intra - sub x0, x0, x1, lsl #1 - ld1 {v18.8b}, [x0], x1 - ld1 {v16.8b}, [x0], x1 - ld1 {v17.8b}, [x0], x1 - ld1 {v19.8b}, [x0] + sub x0, x0, x1, lsl #1 + ld1 {v18.8b}, [x0], x1 + ld1 {v16.8b}, [x0], x1 + ld1 {v17.8b}, [x0], x1 + ld1 {v19.8b}, [x0] - h264_loop_filter_chroma_intra + h264_loop_filter_chroma_intra - sub x0, x0, x1, lsl #1 - st1 {v16.8b}, [x0], x1 - st1 {v17.8b}, [x0], x1 + sub x0, x0, x1, lsl #1 + st1 {v16.8b}, [x0], x1 + st1 {v17.8b}, [x0], x1 9: - ret + ret endfunc function ff_h264_h_loop_filter_chroma_mbaff_intra_neon, export=1 - h264_loop_filter_start_intra + h264_loop_filter_start_intra - sub x4, x0, #2 - sub x0, x0, #1 - ld1 {v18.8b}, [x4], x1 - ld1 {v16.8b}, [x4], x1 - ld1 {v17.8b}, [x4], x1 - ld1 {v19.8b}, [x4], x1 + sub x4, x0, #2 + sub x0, x0, #1 + ld1 {v18.8b}, [x4], x1 + ld1 {v16.8b}, [x4], x1 + ld1 {v17.8b}, [x4], x1 + ld1 {v19.8b}, [x4], x1 - transpose_4x8B v18, v16, v17, v19, v26, v27, v28, v29 + transpose_4x8B v18, v16, v17, v19, v26, v27, v28, v29 - h264_loop_filter_chroma_intra + h264_loop_filter_chroma_intra - st2 {v16.b,v17.b}[0], [x0], x1 - st2 {v16.b,v17.b}[1], [x0], x1 - st2 {v16.b,v17.b}[2], [x0], x1 - st2 {v16.b,v17.b}[3], [x0], x1 + st2 {v16.b,v17.b}[0], [x0], x1 + st2 {v16.b,v17.b}[1], [x0], x1 + st2 {v16.b,v17.b}[2], [x0], x1 + st2 {v16.b,v17.b}[3], [x0], x1 9: - ret + ret endfunc function ff_h264_h_loop_filter_chroma_intra_neon, export=1 - h264_loop_filter_start_intra + h264_loop_filter_start_intra - sub x4, x0, #2 - sub x0, x0, #1 + sub x4, x0, #2 + sub x0, x0, #1 h_loop_filter_chroma420_intra: - ld1 {v18.8b}, [x4], x1 - ld1 {v16.8b}, [x4], x1 - ld1 {v17.8b}, [x4], x1 - ld1 {v19.8b}, [x4], x1 - ld1 {v18.s}[1], [x4], x1 - ld1 {v16.s}[1], [x4], x1 - ld1 {v17.s}[1], [x4], x1 - ld1 {v19.s}[1], [x4], x1 + ld1 {v18.8b}, [x4], x1 + ld1 {v16.8b}, [x4], x1 + ld1 {v17.8b}, [x4], x1 + ld1 {v19.8b}, [x4], x1 + ld1 {v18.s}[1], [x4], x1 + ld1 {v16.s}[1], [x4], x1 + ld1 {v17.s}[1], [x4], x1 + ld1 {v19.s}[1], [x4], x1 - transpose_4x8B v18, v16, v17, v19, v26, v27, v28, v29 + transpose_4x8B v18, v16, v17, v19, v26, v27, v28, v29 - h264_loop_filter_chroma_intra + h264_loop_filter_chroma_intra - st2 {v16.b,v17.b}[0], [x0], x1 - st2 {v16.b,v17.b}[1], [x0], x1 - st2 {v16.b,v17.b}[2], [x0], x1 - st2 {v16.b,v17.b}[3], [x0], x1 - st2 {v16.b,v17.b}[4], [x0], x1 - st2 {v16.b,v17.b}[5], [x0], x1 - st2 {v16.b,v17.b}[6], [x0], x1 - st2 {v16.b,v17.b}[7], [x0], x1 + st2 {v16.b,v17.b}[0], [x0], x1 + st2 {v16.b,v17.b}[1], [x0], x1 + st2 {v16.b,v17.b}[2], [x0], x1 + st2 {v16.b,v17.b}[3], [x0], x1 + st2 {v16.b,v17.b}[4], [x0], x1 + st2 {v16.b,v17.b}[5], [x0], x1 + st2 {v16.b,v17.b}[6], [x0], x1 + st2 {v16.b,v17.b}[7], [x0], x1 9: - ret + ret endfunc function ff_h264_h_loop_filter_chroma422_intra_neon, export=1 - h264_loop_filter_start_intra - sub x4, x0, #2 - add x5, x0, x1, lsl #3 - sub x0, x0, #1 - mov x7, x30 - bl h_loop_filter_chroma420_intra - sub x0, x5, #1 - mov x30, x7 - b h_loop_filter_chroma420_intra + h264_loop_filter_start_intra + sub x4, x0, #2 + add x5, x0, x1, lsl #3 + sub x0, x0, #1 + mov x7, x30 + bl h_loop_filter_chroma420_intra + sub x0, x5, #1 + mov x30, x7 + b h_loop_filter_chroma420_intra endfunc .macro biweight_16 macs, macd @@ -691,7 +685,6 @@ endfunc .macro biweight_func w function ff_biweight_h264_pixels_\w\()_neon, export=1 - sxtw x2, w2 lsr w8, w5, #31 add w7, w7, #1 eor w8, w8, w6, lsr #30 @@ -800,7 +793,6 @@ endfunc .macro weight_func w function ff_weight_h264_pixels_\w\()_neon, export=1 - sxtw x1, w1 cmp w3, #1 mov w6, #1 lsl w5, w5, w3 @@ -827,3 +819,258 @@ endfunc weight_func 16 weight_func 8 weight_func 4 + +.macro h264_loop_filter_start_10 + cmp w2, #0 + ldr w6, [x4] + ccmp w3, #0, #0, ne + lsl w2, w2, #2 + mov v24.S[0], w6 + lsl w3, w3, #2 + and w8, w6, w6, lsl #16 + b.eq 1f + ands w8, w8, w8, lsl #8 + b.ge 2f +1: + ret +2: +.endm + +.macro h264_loop_filter_start_intra_10 + orr w4, w2, w3 + cbnz w4, 1f + ret +1: + lsl w2, w2, #2 + lsl w3, w3, #2 + dup v30.8h, w2 // alpha + dup v31.8h, w3 // beta +.endm + +.macro h264_loop_filter_chroma_10 + dup v22.8h, w2 // alpha + dup v23.8h, w3 // beta + uxtl v24.8h, v24.8b // tc0 + + uabd v26.8h, v16.8h, v0.8h // abs(p0 - q0) + uabd v28.8h, v18.8h, v16.8h // abs(p1 - p0) + uabd v30.8h, v2.8h, v0.8h // abs(q1 - q0) + cmhi v26.8h, v22.8h, v26.8h // < alpha + cmhi v28.8h, v23.8h, v28.8h // < beta + cmhi v30.8h, v23.8h, v30.8h // < beta + + and v26.16b, v26.16b, v28.16b + mov v4.16b, v0.16b + sub v4.8h, v4.8h, v16.8h + and v26.16b, v26.16b, v30.16b + shl v4.8h, v4.8h, #2 + mov x8, v26.d[0] + mov x9, v26.d[1] + sli v24.8h, v24.8h, #8 + uxtl v24.8h, v24.8b + add v4.8h, v4.8h, v18.8h + adds x8, x8, x9 + shl v24.8h, v24.8h, #2 + + b.eq 9f + + movi v31.8h, #3 // (tc0 - 1) << (BIT_DEPTH - 8)) + 1 + uqsub v24.8h, v24.8h, v31.8h + sub v4.8h, v4.8h, v2.8h + srshr v4.8h, v4.8h, #3 + smin v4.8h, v4.8h, v24.8h + neg v25.8h, v24.8h + smax v4.8h, v4.8h, v25.8h + and v4.16b, v4.16b, v26.16b + add v16.8h, v16.8h, v4.8h + sub v0.8h, v0.8h, v4.8h + + mvni v4.8h, #0xFC, lsl #8 // 1023 for clipping + movi v5.8h, #0 + smin v0.8h, v0.8h, v4.8h + smin v16.8h, v16.8h, v4.8h + smax v0.8h, v0.8h, v5.8h + smax v16.8h, v16.8h, v5.8h +.endm + +function ff_h264_v_loop_filter_chroma_neon_10, export=1 + h264_loop_filter_start_10 + + mov x10, x0 + sub x0, x0, x1, lsl #1 + ld1 {v18.8h}, [x0 ], x1 + ld1 {v0.8h}, [x10], x1 + ld1 {v16.8h}, [x0 ], x1 + ld1 {v2.8h}, [x10] + + h264_loop_filter_chroma_10 + + sub x0, x10, x1, lsl #1 + st1 {v16.8h}, [x0], x1 + st1 {v0.8h}, [x0], x1 +9: + ret +endfunc + +function ff_h264_h_loop_filter_chroma_neon_10, export=1 + h264_loop_filter_start_10 + + sub x0, x0, #4 // access the 2nd left pixel +h_loop_filter_chroma420_10: + add x10, x0, x1, lsl #2 + ld1 {v18.d}[0], [x0 ], x1 + ld1 {v18.d}[1], [x10], x1 + ld1 {v16.d}[0], [x0 ], x1 + ld1 {v16.d}[1], [x10], x1 + ld1 {v0.d}[0], [x0 ], x1 + ld1 {v0.d}[1], [x10], x1 + ld1 {v2.d}[0], [x0 ], x1 + ld1 {v2.d}[1], [x10], x1 + + transpose_4x8H v18, v16, v0, v2, v28, v29, v30, v31 + + h264_loop_filter_chroma_10 + + transpose_4x8H v18, v16, v0, v2, v28, v29, v30, v31 + + sub x0, x10, x1, lsl #3 + st1 {v18.d}[0], [x0], x1 + st1 {v16.d}[0], [x0], x1 + st1 {v0.d}[0], [x0], x1 + st1 {v2.d}[0], [x0], x1 + st1 {v18.d}[1], [x0], x1 + st1 {v16.d}[1], [x0], x1 + st1 {v0.d}[1], [x0], x1 + st1 {v2.d}[1], [x0], x1 +9: + ret +endfunc + +function ff_h264_h_loop_filter_chroma422_neon_10, export=1 + h264_loop_filter_start_10 + add x5, x0, x1 + sub x0, x0, #4 + add x1, x1, x1 + mov x7, x30 + bl h_loop_filter_chroma420_10 + mov x30, x7 + sub x0, x5, #4 + mov v24.s[0], w6 + b h_loop_filter_chroma420_10 +endfunc + +.macro h264_loop_filter_chroma_intra_10 + uabd v26.8h, v16.8h, v17.8h // abs(p0 - q0) + uabd v27.8h, v18.8h, v16.8h // abs(p1 - p0) + uabd v28.8h, v19.8h, v17.8h // abs(q1 - q0) + cmhi v26.8h, v30.8h, v26.8h // < alpha + cmhi v27.8h, v31.8h, v27.8h // < beta + cmhi v28.8h, v31.8h, v28.8h // < beta + and v26.16b, v26.16b, v27.16b + and v26.16b, v26.16b, v28.16b + mov x2, v26.d[0] + mov x3, v26.d[1] + + shl v4.8h, v18.8h, #1 + shl v6.8h, v19.8h, #1 + + adds x2, x2, x3 + b.eq 9f + + add v20.8h, v16.8h, v19.8h + add v22.8h, v17.8h, v18.8h + add v20.8h, v20.8h, v4.8h + add v22.8h, v22.8h, v6.8h + urshr v24.8h, v20.8h, #2 + urshr v25.8h, v22.8h, #2 + bit v16.16b, v24.16b, v26.16b + bit v17.16b, v25.16b, v26.16b +.endm + +function ff_h264_v_loop_filter_chroma_intra_neon_10, export=1 + h264_loop_filter_start_intra_10 + mov x9, x0 + sub x0, x0, x1, lsl #1 + ld1 {v18.8h}, [x0], x1 + ld1 {v17.8h}, [x9], x1 + ld1 {v16.8h}, [x0], x1 + ld1 {v19.8h}, [x9] + + h264_loop_filter_chroma_intra_10 + + sub x0, x9, x1, lsl #1 + st1 {v16.8h}, [x0], x1 + st1 {v17.8h}, [x0], x1 + +9: + ret +endfunc + +function ff_h264_h_loop_filter_chroma_mbaff_intra_neon_10, export=1 + h264_loop_filter_start_intra_10 + + sub x4, x0, #4 + sub x0, x0, #2 + add x9, x4, x1, lsl #1 + ld1 {v18.8h}, [x4], x1 + ld1 {v17.8h}, [x9], x1 + ld1 {v16.8h}, [x4], x1 + ld1 {v19.8h}, [x9], x1 + + transpose_4x8H v18, v16, v17, v19, v26, v27, v28, v29 + + h264_loop_filter_chroma_intra_10 + + st2 {v16.h,v17.h}[0], [x0], x1 + st2 {v16.h,v17.h}[1], [x0], x1 + st2 {v16.h,v17.h}[2], [x0], x1 + st2 {v16.h,v17.h}[3], [x0], x1 + +9: + ret +endfunc + +function ff_h264_h_loop_filter_chroma_intra_neon_10, export=1 + h264_loop_filter_start_intra_10 + sub x4, x0, #4 + sub x0, x0, #2 +h_loop_filter_chroma420_intra_10: + add x9, x4, x1, lsl #2 + ld1 {v18.4h}, [x4], x1 + ld1 {v18.d}[1], [x9], x1 + ld1 {v16.4h}, [x4], x1 + ld1 {v16.d}[1], [x9], x1 + ld1 {v17.4h}, [x4], x1 + ld1 {v17.d}[1], [x9], x1 + ld1 {v19.4h}, [x4], x1 + ld1 {v19.d}[1], [x9], x1 + + transpose_4x8H v18, v16, v17, v19, v26, v27, v28, v29 + + h264_loop_filter_chroma_intra_10 + + st2 {v16.h,v17.h}[0], [x0], x1 + st2 {v16.h,v17.h}[1], [x0], x1 + st2 {v16.h,v17.h}[2], [x0], x1 + st2 {v16.h,v17.h}[3], [x0], x1 + st2 {v16.h,v17.h}[4], [x0], x1 + st2 {v16.h,v17.h}[5], [x0], x1 + st2 {v16.h,v17.h}[6], [x0], x1 + st2 {v16.h,v17.h}[7], [x0], x1 + +9: + ret +endfunc + +function ff_h264_h_loop_filter_chroma422_intra_neon_10, export=1 + h264_loop_filter_start_intra_10 + sub x4, x0, #4 + add x5, x0, x1, lsl #3 + sub x0, x0, #2 + mov x7, x30 + bl h_loop_filter_chroma420_intra_10 + mov x4, x9 + sub x0, x5, #2 + mov x30, x7 + b h_loop_filter_chroma420_intra_10 +endfunc diff --git a/media/ffvpx/libavcodec/aarch64/h264idct_neon.S b/media/ffvpx/libavcodec/aarch64/h264idct_neon.S index 7de44205d39a..7d2879b0ce70 100644 --- a/media/ffvpx/libavcodec/aarch64/h264idct_neon.S +++ b/media/ffvpx/libavcodec/aarch64/h264idct_neon.S @@ -24,6 +24,7 @@ function ff_h264_idct_add_neon, export=1 .L_ff_h264_idct_add_neon: + AARCH64_VALID_CALL_TARGET ld1 {v0.4H, v1.4H, v2.4H, v3.4H}, [x1] sxtw x2, w2 movi v30.8H, #0 @@ -79,6 +80,7 @@ endfunc function ff_h264_idct_dc_add_neon, export=1 .L_ff_h264_idct_dc_add_neon: + AARCH64_VALID_CALL_TARGET sxtw x2, w2 mov w3, #0 ld1r {v2.8H}, [x1] @@ -266,6 +268,7 @@ endfunc function ff_h264_idct8_add_neon, export=1 .L_ff_h264_idct8_add_neon: + AARCH64_VALID_CALL_TARGET movi v19.8H, #0 sxtw x2, w2 ld1 {v24.8H, v25.8H}, [x1] @@ -330,6 +333,7 @@ endfunc function ff_h264_idct8_dc_add_neon, export=1 .L_ff_h264_idct8_dc_add_neon: + AARCH64_VALID_CALL_TARGET mov w3, #0 sxtw x2, w2 ld1r {v31.8H}, [x1] diff --git a/media/ffvpx/libavcodec/aarch64/h264pred_init.c b/media/ffvpx/libavcodec/aarch64/h264pred_init.c index b144376f9002..0ae8f70d2390 100644 --- a/media/ffvpx/libavcodec/aarch64/h264pred_init.c +++ b/media/ffvpx/libavcodec/aarch64/h264pred_init.c @@ -45,42 +45,84 @@ void ff_pred8x8_0lt_dc_neon(uint8_t *src, ptrdiff_t stride); void ff_pred8x8_l00_dc_neon(uint8_t *src, ptrdiff_t stride); void ff_pred8x8_0l0_dc_neon(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_vert_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_hor_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_plane_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_dc_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred16x16_top_dc_neon_10(uint8_t *src, ptrdiff_t stride); + +void ff_pred8x8_vert_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_hor_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_plane_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_dc_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_128_dc_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_left_dc_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_top_dc_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_l0t_dc_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_0lt_dc_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_l00_dc_neon_10(uint8_t *src, ptrdiff_t stride); +void ff_pred8x8_0l0_dc_neon_10(uint8_t *src, ptrdiff_t stride); + static av_cold void h264_pred_init_neon(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc) { - const int high_depth = bit_depth > 8; - - if (high_depth) - return; - - if (chroma_format_idc <= 1) { - h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vert_neon; - h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_hor_neon; - if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) - h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_neon; - h->pred8x8[DC_128_PRED8x8 ] = ff_pred8x8_128_dc_neon; - if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 && - codec_id != AV_CODEC_ID_VP8) { - h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_neon; - h->pred8x8[LEFT_DC_PRED8x8] = ff_pred8x8_left_dc_neon; - h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_neon; - h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] = ff_pred8x8_l0t_dc_neon; - h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] = ff_pred8x8_0lt_dc_neon; - h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] = ff_pred8x8_l00_dc_neon; - h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] = ff_pred8x8_0l0_dc_neon; + if (bit_depth == 8) { + if (chroma_format_idc <= 1) { + h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vert_neon; + h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_hor_neon; + if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) + h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_neon; + h->pred8x8[DC_128_PRED8x8 ] = ff_pred8x8_128_dc_neon; + if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 && + codec_id != AV_CODEC_ID_VP8) { + h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_neon; + h->pred8x8[LEFT_DC_PRED8x8] = ff_pred8x8_left_dc_neon; + h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_neon; + h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] = ff_pred8x8_l0t_dc_neon; + h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] = ff_pred8x8_0lt_dc_neon; + h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] = ff_pred8x8_l00_dc_neon; + h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] = ff_pred8x8_0l0_dc_neon; + } } - } - h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_neon; - h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vert_neon; - h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_hor_neon; - h->pred16x16[LEFT_DC_PRED8x8] = ff_pred16x16_left_dc_neon; - h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_neon; - h->pred16x16[DC_128_PRED8x8 ] = ff_pred16x16_128_dc_neon; - if (codec_id != AV_CODEC_ID_SVQ3 && codec_id != AV_CODEC_ID_RV40 && - codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) - h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon; + h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_neon; + h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vert_neon; + h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_hor_neon; + h->pred16x16[LEFT_DC_PRED8x8] = ff_pred16x16_left_dc_neon; + h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_neon; + h->pred16x16[DC_128_PRED8x8 ] = ff_pred16x16_128_dc_neon; + if (codec_id != AV_CODEC_ID_SVQ3 && codec_id != AV_CODEC_ID_RV40 && + codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) + h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon; + } + if (bit_depth == 10) { + if (chroma_format_idc <= 1) { + h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vert_neon_10; + h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_hor_neon_10; + if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) + h->pred8x8[PLANE_PRED8x8] = ff_pred8x8_plane_neon_10; + h->pred8x8[DC_128_PRED8x8 ] = ff_pred8x8_128_dc_neon_10; + if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 && + codec_id != AV_CODEC_ID_VP8) { + h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_neon_10; + h->pred8x8[LEFT_DC_PRED8x8] = ff_pred8x8_left_dc_neon_10; + h->pred8x8[TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_neon_10; + h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8] = ff_pred8x8_l0t_dc_neon_10; + h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8] = ff_pred8x8_0lt_dc_neon_10; + h->pred8x8[ALZHEIMER_DC_L00_PRED8x8] = ff_pred8x8_l00_dc_neon_10; + h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8] = ff_pred8x8_0l0_dc_neon_10; + } + } + + h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_neon_10; + h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vert_neon_10; + h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_hor_neon_10; + h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_neon_10; + if (codec_id != AV_CODEC_ID_SVQ3 && codec_id != AV_CODEC_ID_RV40 && + codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) + h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_neon_10; + } } av_cold void ff_h264_pred_init_aarch64(H264PredContext *h, int codec_id, diff --git a/media/ffvpx/libavcodec/aarch64/h264pred_neon.S b/media/ffvpx/libavcodec/aarch64/h264pred_neon.S index 213b40b3e7d4..ea37689f34c0 100644 --- a/media/ffvpx/libavcodec/aarch64/h264pred_neon.S +++ b/media/ffvpx/libavcodec/aarch64/h264pred_neon.S @@ -81,8 +81,8 @@ function ff_pred16x16_dc_neon, export=1 .L_pred16x16_dc_end: mov w3, #8 6: st1 {v0.16b}, [x0], x1 - st1 {v0.16b}, [x0], x1 subs w3, w3, #1 + st1 {v0.16b}, [x0], x1 b.ne 6b ret endfunc @@ -91,8 +91,8 @@ function ff_pred16x16_hor_neon, export=1 sub x2, x0, #1 mov w3, #16 1: ld1r {v0.16b}, [x2], x1 - st1 {v0.16b}, [x0], x1 subs w3, w3, #1 + st1 {v0.16b}, [x0], x1 b.ne 1b ret endfunc @@ -102,9 +102,9 @@ function ff_pred16x16_vert_neon, export=1 add x1, x1, x1 ld1 {v0.16b}, [x2], x1 mov w3, #8 -1: st1 {v0.16b}, [x0], x1 +1: subs w3, w3, #1 + st1 {v0.16b}, [x0], x1 st1 {v0.16b}, [x2], x1 - subs w3, w3, #1 b.ne 1b ret endfunc @@ -158,8 +158,8 @@ function ff_pred16x16_plane_neon, export=1 add v1.8h, v1.8h, v2.8h sqshrun2 v0.16b, v1.8h, #5 add v1.8h, v1.8h, v3.8h - st1 {v0.16b}, [x0], x1 subs w3, w3, #1 + st1 {v0.16b}, [x0], x1 b.ne 1b ret endfunc @@ -175,8 +175,8 @@ function ff_pred8x8_hor_neon, export=1 sub x2, x0, #1 mov w3, #8 1: ld1r {v0.8b}, [x2], x1 - st1 {v0.8b}, [x0], x1 subs w3, w3, #1 + st1 {v0.8b}, [x0], x1 b.ne 1b ret endfunc @@ -186,9 +186,9 @@ function ff_pred8x8_vert_neon, export=1 lsl x1, x1, #1 ld1 {v0.8b}, [x2], x1 mov w3, #4 -1: st1 {v0.8b}, [x0], x1 +1: subs w3, w3, #1 + st1 {v0.8b}, [x0], x1 st1 {v0.8b}, [x2], x1 - subs w3, w3, #1 b.ne 1b ret endfunc @@ -232,9 +232,9 @@ function ff_pred8x8_plane_neon, export=1 mov w3, #8 1: sqshrun v0.8b, v1.8h, #5 + subs w3, w3, #1 add v1.8h, v1.8h, v2.8h st1 {v0.8b}, [x0], x1 - subs w3, w3, #1 b.ne 1b ret endfunc @@ -290,9 +290,9 @@ function ff_pred8x8_dc_neon, export=1 .L_pred8x8_dc_end: mov w3, #4 add x2, x0, x1, lsl #2 -6: st1 {v0.8b}, [x0], x1 +6: subs w3, w3, #1 + st1 {v0.8b}, [x0], x1 st1 {v1.8b}, [x2], x1 - subs w3, w3, #1 b.ne 6b ret endfunc @@ -359,3 +359,407 @@ function ff_pred8x8_0l0_dc_neon, export=1 dup v1.8b, v1.b[0] b .L_pred8x8_dc_end endfunc + +.macro ldcol.16 rd, rs, rt, n=4, hi=0 +.if \n >= 4 && \hi == 0 + ld1 {\rd\().h}[0], [\rs], \rt + ld1 {\rd\().h}[1], [\rs], \rt + ld1 {\rd\().h}[2], [\rs], \rt + ld1 {\rd\().h}[3], [\rs], \rt +.endif +.if \n == 8 || \hi == 1 + ld1 {\rd\().h}[4], [\rs], \rt + ld1 {\rd\().h}[5], [\rs], \rt + ld1 {\rd\().h}[6], [\rs], \rt + ld1 {\rd\().h}[7], [\rs], \rt +.endif +.endm + +// slower than C +/* +function ff_pred16x16_128_dc_neon_10, export=1 + movi v0.8h, #2, lsl #8 // 512, 1 << (bit_depth - 1) + + b .L_pred16x16_dc_10_end +endfunc +*/ + +function ff_pred16x16_top_dc_neon_10, export=1 + sub x2, x0, x1 + + ld1 {v0.8h, v1.8h}, [x2] + + add v0.8h, v0.8h, v1.8h + addv h0, v0.8h + + urshr v0.4h, v0.4h, #4 + dup v0.8h, v0.h[0] + b .L_pred16x16_dc_10_end +endfunc + +// slower than C +/* +function ff_pred16x16_left_dc_neon_10, export=1 + sub x2, x0, #2 // access to the "left" column + ldcol.16 v0, x2, x1, 8 + ldcol.16 v1, x2, x1, 8 // load "left" column + + add v0.8h, v0.8h, v1.8h + addv h0, v0.8h + + urshr v0.4h, v0.4h, #4 + dup v0.8h, v0.h[0] + b .L_pred16x16_dc_10_end +endfunc +*/ + +function ff_pred16x16_dc_neon_10, export=1 + sub x2, x0, x1 // access to the "top" row + sub x3, x0, #2 // access to the "left" column + + ld1 {v0.8h, v1.8h}, [x2] + ldcol.16 v2, x3, x1, 8 + ldcol.16 v3, x3, x1, 8 // load pixels in "top" row and "left" col + + add v0.8h, v0.8h, v1.8h + add v2.8h, v2.8h, v3.8h + add v0.8h, v0.8h, v2.8h + addv h0, v0.8h + + urshr v0.4h, v0.4h, #5 + dup v0.8h, v0.h[0] +.L_pred16x16_dc_10_end: + mov v1.16b, v0.16b + mov w3, #8 +6: st1 {v0.8h, v1.8h}, [x0], x1 + subs w3, w3, #1 + st1 {v0.8h, v1.8h}, [x0], x1 + b.ne 6b + ret +endfunc + +function ff_pred16x16_hor_neon_10, export=1 + sub x2, x0, #2 + add x3, x0, #16 + + mov w4, #16 +1: ld1r {v0.8h}, [x2], x1 + subs w4, w4, #1 + st1 {v0.8h}, [x0], x1 + st1 {v0.8h}, [x3], x1 + b.ne 1b + ret +endfunc + +function ff_pred16x16_vert_neon_10, export=1 + sub x2, x0, x1 + add x1, x1, x1 + + ld1 {v0.8h, v1.8h}, [x2], x1 + + mov w3, #8 +1: subs w3, w3, #1 + st1 {v0.8h, v1.8h}, [x0], x1 + st1 {v0.8h, v1.8h}, [x2], x1 + + b.ne 1b + ret +endfunc + +function ff_pred16x16_plane_neon_10, export=1 + sub x3, x0, x1 + movrel x4, p16weight + add x2, x3, #16 + sub x3, x3, #2 + ld1 {v0.8h}, [x3] + ld1 {v2.8h}, [x2], x1 + ldcol.16 v1, x3, x1, 8 + add x3, x3, x1 + ldcol.16 v3, x3, x1, 8 + + rev64 v16.8h, v0.8h + rev64 v17.8h, v1.8h + ext v0.16b, v16.16b, v16.16b, #8 + ext v1.16b, v17.16b, v17.16b, #8 + + add v7.8h, v2.8h, v3.8h + sub v2.8h, v2.8h, v0.8h + sub v3.8h, v3.8h, v1.8h + ld1 {v0.8h}, [x4] + mul v2.8h, v2.8h, v0.8h + mul v3.8h, v3.8h, v0.8h + addp v2.8h, v2.8h, v3.8h + addp v2.8h, v2.8h, v2.8h + addp v2.4h, v2.4h, v2.4h + sshll v3.4s, v2.4h, #2 + saddw v2.4s, v3.4s, v2.4h + rshrn v4.4h, v2.4s, #6 + trn2 v5.4h, v4.4h, v4.4h + add v2.4h, v4.4h, v5.4h + shl v3.4h, v2.4h, #3 + ext v7.16b, v7.16b, v7.16b, #14 + sub v3.4h, v3.4h, v2.4h // 7 * (b + c) + add v7.4h, v7.4h, v0.4h + shl v2.4h, v7.4h, #4 + ssubl v2.4s, v2.4h, v3.4h + shl v3.4h, v4.4h, #4 + ext v0.16b, v0.16b, v0.16b, #14 + ssubl v6.4s, v5.4h, v3.4h + + mov v0.h[0], wzr + mul v0.8h, v0.8h, v4.h[0] + dup v16.4s, v2.s[0] + dup v17.4s, v2.s[0] + dup v2.8h, v4.h[0] + dup v3.4s, v6.s[0] + shl v2.8h, v2.8h, #3 + saddw v16.4s, v16.4s, v0.4h + saddw2 v17.4s, v17.4s, v0.8h + saddw v3.4s, v3.4s, v2.4h + + mov w3, #16 + mvni v4.8h, #0xFC, lsl #8 // 1023 for clipping +1: + sqshrun v0.4h, v16.4s, #5 + sqshrun2 v0.8h, v17.4s, #5 + saddw v16.4s, v16.4s, v2.4h + saddw v17.4s, v17.4s, v2.4h + sqshrun v1.4h, v16.4s, #5 + sqshrun2 v1.8h, v17.4s, #5 + add v16.4s, v16.4s, v3.4s + add v17.4s, v17.4s, v3.4s + + subs w3, w3, #1 + + smin v0.8h, v0.8h, v4.8h + smin v1.8h, v1.8h, v4.8h + + st1 {v0.8h, v1.8h}, [x0], x1 + b.ne 1b + ret +endfunc + +function ff_pred8x8_hor_neon_10, export=1 + sub x2, x0, #2 + mov w3, #8 + +1: ld1r {v0.8h}, [x2], x1 + subs w3, w3, #1 + st1 {v0.8h}, [x0], x1 + b.ne 1b + ret +endfunc + +function ff_pred8x8_vert_neon_10, export=1 + sub x2, x0, x1 + lsl x1, x1, #1 + + ld1 {v0.8h}, [x2], x1 + mov w3, #4 +1: subs w3, w3, #1 + st1 {v0.8h}, [x0], x1 + st1 {v0.8h}, [x2], x1 + b.ne 1b + ret +endfunc + +function ff_pred8x8_plane_neon_10, export=1 + sub x3, x0, x1 + movrel x4, p8weight + movrel x5, p16weight + add x2, x3, #8 + sub x3, x3, #2 + ld1 {v0.d}[0], [x3] + ld1 {v2.d}[0], [x2], x1 + ldcol.16 v0, x3, x1, hi=1 + add x3, x3, x1 + ldcol.16 v3, x3, x1, 4 + add v7.8h, v2.8h, v3.8h + rev64 v0.8h, v0.8h + trn1 v2.2d, v2.2d, v3.2d + sub v2.8h, v2.8h, v0.8h + ld1 {v6.8h}, [x4] + mul v2.8h, v2.8h, v6.8h + ld1 {v0.8h}, [x5] + saddlp v2.4s, v2.8h + addp v2.4s, v2.4s, v2.4s + shl v3.4s, v2.4s, #4 + add v2.4s, v3.4s, v2.4s + rshrn v5.4h, v2.4s, #5 + addp v2.4h, v5.4h, v5.4h + shl v3.4h, v2.4h, #1 + add v3.4h, v3.4h, v2.4h + rev64 v7.4h, v7.4h + add v7.4h, v7.4h, v0.4h + shl v2.4h, v7.4h, #4 + ssubl v2.4s, v2.4h, v3.4h + ext v0.16b, v0.16b, v0.16b, #14 + mov v0.h[0], wzr + mul v0.8h, v0.8h, v5.h[0] + dup v1.4s, v2.s[0] + dup v2.4s, v2.s[0] + dup v3.8h, v5.h[1] + saddw v1.4s, v1.4s, v0.4h + saddw2 v2.4s, v2.4s, v0.8h + mov w3, #8 + mvni v4.8h, #0xFC, lsl #8 // 1023 for clipping +1: + sqshrun v0.4h, v1.4s, #5 + sqshrun2 v0.8h, v2.4s, #5 + + saddw v1.4s, v1.4s, v3.4h + saddw v2.4s, v2.4s, v3.4h + + subs w3, w3, #1 + + smin v0.8h, v0.8h, v4.8h + + st1 {v0.8h}, [x0], x1 + b.ne 1b + ret +endfunc + +function ff_pred8x8_128_dc_neon_10, export=1 + movi v0.8h, #2, lsl #8 // 512, 1 << (bit_depth - 1) + movi v1.8h, #2, lsl #8 + b .L_pred8x8_dc_10_end +endfunc + +function ff_pred8x8_top_dc_neon_10, export=1 + sub x2, x0, x1 + ld1 {v0.8h}, [x2] + + addp v0.8h, v0.8h, v0.8h + addp v0.4h, v0.4h, v0.4h + zip1 v0.4h, v0.4h, v0.4h + urshr v2.4h, v0.4h, #2 + zip1 v0.8h, v2.8h, v2.8h + zip1 v1.8h, v2.8h, v2.8h + b .L_pred8x8_dc_10_end +endfunc + +function ff_pred8x8_left_dc_neon_10, export=1 + sub x2, x0, #2 + ldcol.16 v0, x2, x1, 8 + + addp v0.8h, v0.8h, v0.8h + addp v0.4h, v0.4h, v0.4h + urshr v2.4h, v0.4h, #2 + dup v1.8h, v2.h[1] + dup v0.8h, v2.h[0] + b .L_pred8x8_dc_10_end +endfunc + +function ff_pred8x8_dc_neon_10, export=1 + sub x2, x0, x1 + sub x3, x0, #2 + + ld1 {v0.8h}, [x2] + ldcol.16 v1, x3, x1, 8 + + addp v0.8h, v0.8h, v0.8h + addp v1.8h, v1.8h, v1.8h + trn1 v2.2s, v0.2s, v1.2s + trn2 v3.2s, v0.2s, v1.2s + addp v4.4h, v2.4h, v3.4h + addp v5.4h, v4.4h, v4.4h + urshr v6.4h, v5.4h, #3 + urshr v7.4h, v4.4h, #2 + dup v0.8h, v6.h[0] + dup v2.8h, v7.h[2] + dup v1.8h, v7.h[3] + dup v3.8h, v6.h[1] + zip1 v0.2d, v0.2d, v2.2d + zip1 v1.2d, v1.2d, v3.2d +.L_pred8x8_dc_10_end: + mov w3, #4 + add x2, x0, x1, lsl #2 + +6: st1 {v0.8h}, [x0], x1 + subs w3, w3, #1 + st1 {v1.8h}, [x2], x1 + b.ne 6b + ret +endfunc + +function ff_pred8x8_l0t_dc_neon_10, export=1 + sub x2, x0, x1 + sub x3, x0, #2 + + ld1 {v0.8h}, [x2] + ldcol.16 v1, x3, x1, 4 + + addp v0.8h, v0.8h, v0.8h + addp v1.4h, v1.4h, v1.4h + addp v0.4h, v0.4h, v0.4h + addp v1.4h, v1.4h, v1.4h + add v1.4h, v1.4h, v0.4h + + urshr v2.4h, v0.4h, #2 + urshr v3.4h, v1.4h, #3 // the pred4x4 part + + dup v4.4h, v3.h[0] + dup v5.4h, v2.h[0] + dup v6.4h, v2.h[1] + + zip1 v0.2d, v4.2d, v6.2d + zip1 v1.2d, v5.2d, v6.2d + b .L_pred8x8_dc_10_end +endfunc + +function ff_pred8x8_l00_dc_neon_10, export=1 + sub x2, x0, #2 + + ldcol.16 v0, x2, x1, 4 + + addp v0.4h, v0.4h, v0.4h + addp v0.4h, v0.4h, v0.4h + urshr v0.4h, v0.4h, #2 + + movi v1.8h, #2, lsl #8 // 512 + dup v0.8h, v0.h[0] + b .L_pred8x8_dc_10_end +endfunc + +function ff_pred8x8_0lt_dc_neon_10, export=1 + add x3, x0, x1, lsl #2 + sub x2, x0, x1 + sub x3, x3, #2 + + ld1 {v0.8h}, [x2] + ldcol.16 v1, x3, x1, hi=1 + + addp v0.8h, v0.8h, v0.8h + addp v1.8h, v1.8h, v1.8h + addp v0.4h, v0.4h, v0.4h + addp v1.4h, v1.4h, v1.4h + zip1 v0.2s, v0.2s, v1.2s + add v1.4h, v0.4h, v1.4h + + urshr v2.4h, v0.4h, #2 + urshr v3.4h, v1.4h, #3 + + dup v4.4h, v2.h[0] + dup v5.4h, v2.h[3] + dup v6.4h, v2.h[1] + dup v7.4h, v3.h[1] + + zip1 v0.2d, v4.2d, v6.2d + zip1 v1.2d, v5.2d, v7.2d + b .L_pred8x8_dc_10_end +endfunc + +function ff_pred8x8_0l0_dc_neon_10, export=1 + add x2, x0, x1, lsl #2 + sub x2, x2, #2 + + ldcol.16 v1, x2, x1, 4 + + addp v2.8h, v1.8h, v1.8h + addp v2.4h, v2.4h, v2.4h + urshr v1.4h, v2.4h, #2 + + movi v0.8h, #2, lsl #8 // 512 + dup v1.8h, v1.h[0] + b .L_pred8x8_dc_10_end +endfunc diff --git a/media/ffvpx/libavcodec/aarch64/idct.h b/media/ffvpx/libavcodec/aarch64/idct.h index 5c49046148b7..97ee0a64af34 100644 --- a/media/ffvpx/libavcodec/aarch64/idct.h +++ b/media/ffvpx/libavcodec/aarch64/idct.h @@ -19,6 +19,7 @@ #ifndef AVCODEC_AARCH64_IDCT_H #define AVCODEC_AARCH64_IDCT_H +#include #include void ff_simple_idct_neon(int16_t *data); diff --git a/media/ffvpx/libavcodec/aarch64/idctdsp_init_aarch64.c b/media/ffvpx/libavcodec/aarch64/idctdsp_init_aarch64.c index 742a3372e3a6..eec21aa5a2ea 100644 --- a/media/ffvpx/libavcodec/aarch64/idctdsp_init_aarch64.c +++ b/media/ffvpx/libavcodec/aarch64/idctdsp_init_aarch64.c @@ -27,19 +27,29 @@ #include "libavcodec/idctdsp.h" #include "idct.h" +void ff_put_pixels_clamped_neon(const int16_t *, uint8_t *, ptrdiff_t); +void ff_put_signed_pixels_clamped_neon(const int16_t *, uint8_t *, ptrdiff_t); +void ff_add_pixels_clamped_neon(const int16_t *, uint8_t *, ptrdiff_t); + av_cold void ff_idctdsp_init_aarch64(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth) { int cpu_flags = av_get_cpu_flags(); - if (have_neon(cpu_flags) && !avctx->lowres && !high_bit_depth) { - if (avctx->idct_algo == FF_IDCT_AUTO || - avctx->idct_algo == FF_IDCT_SIMPLEAUTO || - avctx->idct_algo == FF_IDCT_SIMPLENEON) { - c->idct_put = ff_simple_idct_put_neon; - c->idct_add = ff_simple_idct_add_neon; - c->idct = ff_simple_idct_neon; - c->perm_type = FF_IDCT_PERM_PARTTRANS; + if (have_neon(cpu_flags)) { + if (!avctx->lowres && !high_bit_depth) { + if (avctx->idct_algo == FF_IDCT_AUTO || + avctx->idct_algo == FF_IDCT_SIMPLEAUTO || + avctx->idct_algo == FF_IDCT_SIMPLENEON) { + c->idct_put = ff_simple_idct_put_neon; + c->idct_add = ff_simple_idct_add_neon; + c->idct = ff_simple_idct_neon; + c->perm_type = FF_IDCT_PERM_PARTTRANS; + } } + + c->add_pixels_clamped = ff_add_pixels_clamped_neon; + c->put_pixels_clamped = ff_put_pixels_clamped_neon; + c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_neon; } } diff --git a/media/ffvpx/libavcodec/aarch64/idctdsp_neon.S b/media/ffvpx/libavcodec/aarch64/idctdsp_neon.S new file mode 100644 index 000000000000..7f4761120677 --- /dev/null +++ b/media/ffvpx/libavcodec/aarch64/idctdsp_neon.S @@ -0,0 +1,130 @@ +/* + * IDCT AArch64 NEON optimisations + * + * Copyright (c) 2022 Ben Avison + * + * 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/aarch64/asm.S" + +// Clamp 16-bit signed block coefficients to unsigned 8-bit +// On entry: +// x0 -> array of 64x 16-bit coefficients +// x1 -> 8-bit results +// x2 = row stride for results, bytes +function ff_put_pixels_clamped_neon, export=1 + ld1 {v0.16b, v1.16b, v2.16b, v3.16b}, [x0], #64 + ld1 {v4.16b, v5.16b, v6.16b, v7.16b}, [x0] + sqxtun v0.8b, v0.8h + sqxtun v1.8b, v1.8h + sqxtun v2.8b, v2.8h + sqxtun v3.8b, v3.8h + sqxtun v4.8b, v4.8h + st1 {v0.8b}, [x1], x2 + sqxtun v0.8b, v5.8h + st1 {v1.8b}, [x1], x2 + sqxtun v1.8b, v6.8h + st1 {v2.8b}, [x1], x2 + sqxtun v2.8b, v7.8h + st1 {v3.8b}, [x1], x2 + st1 {v4.8b}, [x1], x2 + st1 {v0.8b}, [x1], x2 + st1 {v1.8b}, [x1], x2 + st1 {v2.8b}, [x1] + ret +endfunc + +// Clamp 16-bit signed block coefficients to signed 8-bit (biased by 128) +// On entry: +// x0 -> array of 64x 16-bit coefficients +// x1 -> 8-bit results +// x2 = row stride for results, bytes +function ff_put_signed_pixels_clamped_neon, export=1 + ld1 {v0.16b, v1.16b, v2.16b, v3.16b}, [x0], #64 + movi v4.8b, #128 + ld1 {v16.16b, v17.16b, v18.16b, v19.16b}, [x0] + sqxtn v0.8b, v0.8h + sqxtn v1.8b, v1.8h + sqxtn v2.8b, v2.8h + sqxtn v3.8b, v3.8h + sqxtn v5.8b, v16.8h + add v0.8b, v0.8b, v4.8b + sqxtn v6.8b, v17.8h + add v1.8b, v1.8b, v4.8b + sqxtn v7.8b, v18.8h + add v2.8b, v2.8b, v4.8b + sqxtn v16.8b, v19.8h + add v3.8b, v3.8b, v4.8b + st1 {v0.8b}, [x1], x2 + add v0.8b, v5.8b, v4.8b + st1 {v1.8b}, [x1], x2 + add v1.8b, v6.8b, v4.8b + st1 {v2.8b}, [x1], x2 + add v2.8b, v7.8b, v4.8b + st1 {v3.8b}, [x1], x2 + add v3.8b, v16.8b, v4.8b + st1 {v0.8b}, [x1], x2 + st1 {v1.8b}, [x1], x2 + st1 {v2.8b}, [x1], x2 + st1 {v3.8b}, [x1] + ret +endfunc + +// Add 16-bit signed block coefficients to unsigned 8-bit +// On entry: +// x0 -> array of 64x 16-bit coefficients +// x1 -> 8-bit input and results +// x2 = row stride for 8-bit input and results, bytes +function ff_add_pixels_clamped_neon, export=1 + ld1 {v0.16b, v1.16b, v2.16b, v3.16b}, [x0], #64 + mov x3, x1 + ld1 {v4.8b}, [x1], x2 + ld1 {v5.8b}, [x1], x2 + ld1 {v6.8b}, [x1], x2 + ld1 {v7.8b}, [x1], x2 + ld1 {v16.16b, v17.16b, v18.16b, v19.16b}, [x0] + uaddw v0.8h, v0.8h, v4.8b + uaddw v1.8h, v1.8h, v5.8b + uaddw v2.8h, v2.8h, v6.8b + ld1 {v4.8b}, [x1], x2 + uaddw v3.8h, v3.8h, v7.8b + ld1 {v5.8b}, [x1], x2 + sqxtun v0.8b, v0.8h + ld1 {v6.8b}, [x1], x2 + sqxtun v1.8b, v1.8h + ld1 {v7.8b}, [x1] + sqxtun v2.8b, v2.8h + sqxtun v3.8b, v3.8h + uaddw v4.8h, v16.8h, v4.8b + st1 {v0.8b}, [x3], x2 + uaddw v0.8h, v17.8h, v5.8b + st1 {v1.8b}, [x3], x2 + uaddw v1.8h, v18.8h, v6.8b + st1 {v2.8b}, [x3], x2 + uaddw v2.8h, v19.8h, v7.8b + sqxtun v4.8b, v4.8h + sqxtun v0.8b, v0.8h + st1 {v3.8b}, [x3], x2 + sqxtun v1.8b, v1.8h + sqxtun v2.8b, v2.8h + st1 {v4.8b}, [x3], x2 + st1 {v0.8b}, [x3], x2 + st1 {v1.8b}, [x3], x2 + st1 {v2.8b}, [x3] + ret +endfunc diff --git a/media/ffvpx/libavcodec/aarch64/mdct_neon.S b/media/ffvpx/libavcodec/aarch64/mdct_neon.S index 1fd199c972e8..6091e72022f5 100644 --- a/media/ffvpx/libavcodec/aarch64/mdct_neon.S +++ b/media/ffvpx/libavcodec/aarch64/mdct_neon.S @@ -25,6 +25,7 @@ function ff_imdct_half_neon, export=1 sub sp, sp, #32 stp x19, x20, [sp] + AARCH64_SIGN_LINK_REGISTER str x30, [sp, #16] mov x12, #1 ldr w14, [x0, #28] // mdct_bits @@ -121,6 +122,7 @@ function ff_imdct_half_neon, export=1 ldp x19, x20, [sp] ldr x30, [sp, #16] + AARCH64_VALIDATE_LINK_REGISTER add sp, sp, #32 ret @@ -129,6 +131,7 @@ endfunc function ff_imdct_calc_neon, export=1 sub sp, sp, #32 stp x19, x20, [sp] + AARCH64_SIGN_LINK_REGISTER str x30, [sp, #16] ldr w3, [x0, #28] // mdct_bits mov x19, #1 @@ -160,8 +163,10 @@ function ff_imdct_calc_neon, export=1 subs x19, x19, #16 b.gt 1b - ldp x19, x20, [sp], #16 - ldr x30, [sp], #16 + ldp x19, x20, [sp] + ldr x30, [sp, #16] + AARCH64_VALIDATE_LINK_REGISTER + add sp, sp, #32 ret endfunc @@ -170,6 +175,7 @@ endfunc function ff_mdct_calc_neon, export=1 sub sp, sp, #32 stp x19, x20, [sp] + AARCH64_SIGN_LINK_REGISTER str x30, [sp, #16] mov x12, #1 @@ -317,7 +323,10 @@ function ff_mdct_calc_neon, export=1 st2 {v4.2s,v5.2s}, [x0] st2 {v6.2s,v7.2s}, [x8] - ldp x19, x20, [sp], #16 - ldr x30, [sp], #16 + ldp x19, x20, [sp] + ldr x30, [sp, #16] + AARCH64_VALIDATE_LINK_REGISTER + add sp, sp, #32 + ret endfunc diff --git a/media/ffvpx/libavcodec/aarch64/moz.build b/media/ffvpx/libavcodec/aarch64/moz.build index 3f3e88fc1db2..1b973ef5034e 100644 --- a/media/ffvpx/libavcodec/aarch64/moz.build +++ b/media/ffvpx/libavcodec/aarch64/moz.build @@ -4,48 +4,55 @@ ## License, v. 2.0. If a copy of the MPL was not distributed with this ## file, You can obtain one at http://mozilla.org/MPL/2.0/. -SOURCES += [ - 'h264chroma_init_aarch64.c', - 'h264cmc_neon.S', - 'h264dsp_init_aarch64.c', - 'h264dsp_neon.S', - 'h264idct_neon.S', - 'h264pred_init.c', - 'h264pred_neon.S', - 'hpeldsp_init_aarch64.c', - 'hpeldsp_neon.S', - 'idctdsp_init_aarch64.c', - 'mdct_neon.S', - 'mpegaudiodsp_init.c', - 'mpegaudiodsp_neon.S', - 'neon.S', - 'simple_idct_neon.S', - 'videodsp.S', - 'videodsp_init.c', - 'vp8dsp_init_aarch64.c', - 'vp8dsp_neon.S', - 'vp9dsp_init_10bpp_aarch64.c', - 'vp9dsp_init_12bpp_aarch64.c', - 'vp9dsp_init_aarch64.c', - 'vp9itxfm_16bpp_neon.S', - 'vp9itxfm_neon.S', - 'vp9lpf_16bpp_neon.S', - 'vp9lpf_neon.S', - 'vp9mc_16bpp_neon.S', - 'vp9mc_aarch64.S', - 'vp9mc_neon.S', -] +if not CONFIG['MOZ_FFVPX_AUDIOONLY']: + SOURCES += [ + 'fft_init_aarch64.c', + 'fft_neon.S', + 'h264chroma_init_aarch64.c', + 'h264cmc_neon.S', + 'h264dsp_init_aarch64.c', + 'h264dsp_neon.S', + 'h264idct_neon.S', + 'h264pred_init.c', + 'h264pred_neon.S', + 'hpeldsp_init_aarch64.c', + 'hpeldsp_neon.S', + 'idctdsp_init_aarch64.c', + 'mdct_neon.S', + 'mpegaudiodsp_init.c', + 'mpegaudiodsp_neon.S', + 'neon.S', + 'simple_idct_neon.S', + 'videodsp.S', + 'videodsp_init.c', + 'vp8dsp_init_aarch64.c', + 'vp8dsp_neon.S', + 'vp9dsp_init_10bpp_aarch64.c', + 'vp9dsp_init_12bpp_aarch64.c', + 'vp9dsp_init_aarch64.c', + 'vp9itxfm_16bpp_neon.S', + 'vp9itxfm_neon.S', + 'vp9lpf_16bpp_neon.S', + 'vp9lpf_neon.S', + 'vp9mc_16bpp_neon.S', + 'vp9mc_aarch64.S', + 'vp9mc_neon.S', + ] +else: + SOURCES += [ + 'fft_init_aarch64.c', + 'fft_neon.S', + 'idctdsp_init_aarch64.c', + 'idctdsp_neon.S', + 'mpegaudiodsp_init.c', + 'mpegaudiodsp_neon.S', + 'simple_idct_neon.S', + ] if CONFIG['OS_ARCH'] == 'WINNT': USE_INTEGRATED_CLANGCL_AS = True DEFINES['EXTERN_ASM'] = '' -if CONFIG['MOZ_LIBAV_FFT']: - SOURCES += [ - 'fft_init_aarch64.c', - 'fft_neon.S', - ] - FINAL_LIBRARY = 'mozavcodec' include('/media/ffvpx/ffvpxcommon.mozbuild') diff --git a/media/ffvpx/libavcodec/aarch64/neon.S b/media/ffvpx/libavcodec/aarch64/neon.S index 0fddbecae30c..1ad32c359d41 100644 --- a/media/ffvpx/libavcodec/aarch64/neon.S +++ b/media/ffvpx/libavcodec/aarch64/neon.S @@ -109,12 +109,25 @@ trn2 \r5\().4H, \r0\().4H, \r1\().4H trn1 \r6\().4H, \r2\().4H, \r3\().4H trn2 \r7\().4H, \r2\().4H, \r3\().4H + trn1 \r0\().2S, \r4\().2S, \r6\().2S trn2 \r2\().2S, \r4\().2S, \r6\().2S trn1 \r1\().2S, \r5\().2S, \r7\().2S trn2 \r3\().2S, \r5\().2S, \r7\().2S .endm +.macro transpose_4x8H r0, r1, r2, r3, t4, t5, t6, t7 + trn1 \t4\().8H, \r0\().8H, \r1\().8H + trn2 \t5\().8H, \r0\().8H, \r1\().8H + trn1 \t6\().8H, \r2\().8H, \r3\().8H + trn2 \t7\().8H, \r2\().8H, \r3\().8H + + trn1 \r0\().4S, \t4\().4S, \t6\().4S + trn2 \r2\().4S, \t4\().4S, \t6\().4S + trn1 \r1\().4S, \t5\().4S, \t7\().4S + trn2 \r3\().4S, \t5\().4S, \t7\().4S +.endm + .macro transpose_8x8H r0, r1, r2, r3, r4, r5, r6, r7, r8, r9 trn1 \r8\().8H, \r0\().8H, \r1\().8H trn2 \r9\().8H, \r0\().8H, \r1\().8H diff --git a/media/ffvpx/libavcodec/aarch64/simple_idct_neon.S b/media/ffvpx/libavcodec/aarch64/simple_idct_neon.S index 5e4d021a9766..210182ff2108 100644 --- a/media/ffvpx/libavcodec/aarch64/simple_idct_neon.S +++ b/media/ffvpx/libavcodec/aarch64/simple_idct_neon.S @@ -58,7 +58,7 @@ endconst .endm .macro idct_end - br x10 + ret x10 .endm .macro smull1 a, b, c diff --git a/media/ffvpx/libavcodec/aarch64/vc1dsp_init_aarch64.c b/media/ffvpx/libavcodec/aarch64/vc1dsp_init_aarch64.c index 13dfd74940ab..a7976fd59685 100644 --- a/media/ffvpx/libavcodec/aarch64/vc1dsp_init_aarch64.c +++ b/media/ffvpx/libavcodec/aarch64/vc1dsp_init_aarch64.c @@ -21,10 +21,28 @@ #include "libavutil/attributes.h" #include "libavutil/cpu.h" #include "libavutil/aarch64/cpu.h" +#include "libavutil/intreadwrite.h" #include "libavcodec/vc1dsp.h" #include "config.h" +void ff_vc1_inv_trans_8x8_neon(int16_t *block); +void ff_vc1_inv_trans_8x4_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block); +void ff_vc1_inv_trans_4x8_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block); +void ff_vc1_inv_trans_4x4_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block); + +void ff_vc1_inv_trans_8x8_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block); +void ff_vc1_inv_trans_8x4_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block); +void ff_vc1_inv_trans_4x8_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block); +void ff_vc1_inv_trans_4x4_dc_neon(uint8_t *dest, ptrdiff_t stride, int16_t *block); + +void ff_vc1_v_loop_filter4_neon(uint8_t *src, ptrdiff_t stride, int pq); +void ff_vc1_h_loop_filter4_neon(uint8_t *src, ptrdiff_t stride, int pq); +void ff_vc1_v_loop_filter8_neon(uint8_t *src, ptrdiff_t stride, int pq); +void ff_vc1_h_loop_filter8_neon(uint8_t *src, ptrdiff_t stride, int pq); +void ff_vc1_v_loop_filter16_neon(uint8_t *src, ptrdiff_t stride, int pq); +void ff_vc1_h_loop_filter16_neon(uint8_t *src, ptrdiff_t stride, int pq); + void ff_put_vc1_chroma_mc8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h, int x, int y); void ff_avg_vc1_chroma_mc8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride, @@ -34,14 +52,90 @@ void ff_put_vc1_chroma_mc4_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride, void ff_avg_vc1_chroma_mc4_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h, int x, int y); +int ff_vc1_unescape_buffer_helper_neon(const uint8_t *src, int size, uint8_t *dst); + +static int vc1_unescape_buffer_neon(const uint8_t *src, int size, uint8_t *dst) +{ + /* Dealing with starting and stopping, and removing escape bytes, are + * comparatively less time-sensitive, so are more clearly expressed using + * a C wrapper around the assembly inner loop. Note that we assume a + * little-endian machine that supports unaligned loads. */ + int dsize = 0; + while (size >= 4) + { + int found = 0; + while (!found && (((uintptr_t) dst) & 7) && size >= 4) + { + found = (AV_RL32(src) &~ 0x03000000) == 0x00030000; + if (!found) + { + *dst++ = *src++; + --size; + ++dsize; + } + } + if (!found) + { + int skip = size - ff_vc1_unescape_buffer_helper_neon(src, size, dst); + dst += skip; + src += skip; + size -= skip; + dsize += skip; + while (!found && size >= 4) + { + found = (AV_RL32(src) &~ 0x03000000) == 0x00030000; + if (!found) + { + *dst++ = *src++; + --size; + ++dsize; + } + } + } + if (found) + { + *dst++ = *src++; + *dst++ = *src++; + ++src; + size -= 3; + dsize += 2; + } + } + while (size > 0) + { + *dst++ = *src++; + --size; + ++dsize; + } + return dsize; +} + av_cold void ff_vc1dsp_init_aarch64(VC1DSPContext *dsp) { int cpu_flags = av_get_cpu_flags(); if (have_neon(cpu_flags)) { + dsp->vc1_inv_trans_8x8 = ff_vc1_inv_trans_8x8_neon; + dsp->vc1_inv_trans_8x4 = ff_vc1_inv_trans_8x4_neon; + dsp->vc1_inv_trans_4x8 = ff_vc1_inv_trans_4x8_neon; + dsp->vc1_inv_trans_4x4 = ff_vc1_inv_trans_4x4_neon; + dsp->vc1_inv_trans_8x8_dc = ff_vc1_inv_trans_8x8_dc_neon; + dsp->vc1_inv_trans_8x4_dc = ff_vc1_inv_trans_8x4_dc_neon; + dsp->vc1_inv_trans_4x8_dc = ff_vc1_inv_trans_4x8_dc_neon; + dsp->vc1_inv_trans_4x4_dc = ff_vc1_inv_trans_4x4_dc_neon; + + dsp->vc1_v_loop_filter4 = ff_vc1_v_loop_filter4_neon; + dsp->vc1_h_loop_filter4 = ff_vc1_h_loop_filter4_neon; + dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_neon; + dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_neon; + dsp->vc1_v_loop_filter16 = ff_vc1_v_loop_filter16_neon; + dsp->vc1_h_loop_filter16 = ff_vc1_h_loop_filter16_neon; + dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_neon; dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_neon; dsp->put_no_rnd_vc1_chroma_pixels_tab[1] = ff_put_vc1_chroma_mc4_neon; dsp->avg_no_rnd_vc1_chroma_pixels_tab[1] = ff_avg_vc1_chroma_mc4_neon; + + dsp->vc1_unescape_buffer = vc1_unescape_buffer_neon; } } diff --git a/media/ffvpx/libavcodec/aarch64/videodsp.S b/media/ffvpx/libavcodec/aarch64/videodsp.S index 24067cc2af52..fe2da0658eef 100644 --- a/media/ffvpx/libavcodec/aarch64/videodsp.S +++ b/media/ffvpx/libavcodec/aarch64/videodsp.S @@ -19,10 +19,11 @@ #include "libavutil/aarch64/asm.S" function ff_prefetch_aarch64, export=1 +1: subs w2, w2, #2 prfm pldl1strm, [x0] prfm pldl1strm, [x0, x1] add x0, x0, x1, lsl #1 - b.gt X(ff_prefetch_aarch64) + b.gt 1b ret endfunc diff --git a/media/ffvpx/libavcodec/aarch64/vp9itxfm_16bpp_neon.S b/media/ffvpx/libavcodec/aarch64/vp9itxfm_16bpp_neon.S index 68296d9c40c0..c5f43d36a329 100644 --- a/media/ffvpx/libavcodec/aarch64/vp9itxfm_16bpp_neon.S +++ b/media/ffvpx/libavcodec/aarch64/vp9itxfm_16bpp_neon.S @@ -1040,7 +1040,7 @@ function \txfm\()16_1d_4x16_pass1_neon .irp i, 16, 20, 24, 28, 17, 21, 25, 29, 18, 22, 26, 30, 19, 23, 27, 31 store \i, x0, #16 .endr - br x14 + ret x14 1: // Special case: For the last input column (x1 == 12), // which would be stored as the last row in the temp buffer, @@ -1068,7 +1068,7 @@ function \txfm\()16_1d_4x16_pass1_neon mov v29.16b, v17.16b mov v30.16b, v18.16b mov v31.16b, v19.16b - br x14 + ret x14 endfunc // Read a vertical 4x16 slice out of a 16x16 matrix, do a transform on it, @@ -1098,7 +1098,7 @@ function \txfm\()16_1d_4x16_pass2_neon load_add_store v16.4s, v17.4s, v18.4s, v19.4s, v20.4s, v21.4s, v22.4s, v23.4s load_add_store v24.4s, v25.4s, v26.4s, v27.4s, v28.4s, v29.4s, v30.4s, v31.4s - br x14 + ret x14 endfunc .endm @@ -1208,7 +1208,7 @@ function vp9_\txfm1\()_\txfm2\()_16x16_add_16_neon ldp d12, d13, [sp], 0x10 ldp d14, d15, [sp], 0x10 .endif - br x15 + ret x15 endfunc function ff_vp9_\txfm1\()_\txfm2\()_16x16_add_10_neon, export=1 @@ -1264,7 +1264,7 @@ function idct16_1d_4x16_pass1_quarter_neon st1 {v23.4s}, [x0], #16 st1 {v27.4s}, [x0], #16 st1 {v31.4s}, [x0], #16 - br x14 + ret x14 endfunc function idct16_1d_4x16_pass2_quarter_neon @@ -1286,7 +1286,7 @@ function idct16_1d_4x16_pass2_quarter_neon load_add_store v16.4s, v17.4s, v18.4s, v19.4s, v20.4s, v21.4s, v22.4s, v23.4s load_add_store v24.4s, v25.4s, v26.4s, v27.4s, v28.4s, v29.4s, v30.4s, v31.4s - br x14 + ret x14 endfunc function idct16_1d_4x16_pass1_half_neon @@ -1313,7 +1313,7 @@ function idct16_1d_4x16_pass1_half_neon .irp i, 16, 20, 24, 28, 17, 21, 25, 29, 18, 22, 26, 30, 19, 23, 27, 31 store \i, x0, #16 .endr - br x14 + ret x14 1: // Special case: For the second input column (r1 == 4), // which would be stored as the second row in the temp buffer, @@ -1341,7 +1341,7 @@ function idct16_1d_4x16_pass1_half_neon mov v21.16b, v17.16b mov v22.16b, v18.16b mov v23.16b, v19.16b - br x14 + ret x14 endfunc function idct16_1d_4x16_pass2_half_neon @@ -1364,7 +1364,7 @@ function idct16_1d_4x16_pass2_half_neon load_add_store v16.4s, v17.4s, v18.4s, v19.4s, v20.4s, v21.4s, v22.4s, v23.4s load_add_store v24.4s, v25.4s, v26.4s, v27.4s, v28.4s, v29.4s, v30.4s, v31.4s - br x14 + ret x14 endfunc .macro idct16_partial size @@ -1390,7 +1390,7 @@ function idct16x16_\size\()_add_16_neon add sp, sp, #1024 ldp d8, d9, [sp], 0x10 - br x15 + ret x15 endfunc .endm @@ -1729,7 +1729,7 @@ function idct32_1d_4x32_pass1\suffix\()_neon store_rev v29.4s, v25.4s, v21.4s, v17.4s, v29.16b, v25.16b store_rev v28.4s, v24.4s, v20.4s, v16.4s, v28.16b, v24.16b .purgem store_rev - br x14 + ret x14 endfunc // This is mostly the same as 4x32_pass1, but without the transpose, @@ -1849,7 +1849,7 @@ function idct32_1d_4x32_pass2\suffix\()_neon load_acc_store v24.4s, v25.4s, v26.4s, v27.4s, 1 load_acc_store v28.4s, v29.4s, v30.4s, v31.4s, 1 .purgem load_acc_store - br x14 + ret x14 endfunc .endm @@ -1943,7 +1943,7 @@ function vp9_idct_idct_32x32_add_16_neon ldp d10, d11, [sp], 0x10 ldp d8, d9, [sp], 0x10 - br x15 + ret x15 endfunc function ff_vp9_idct_idct_32x32_add_10_neon, export=1 @@ -2009,7 +2009,7 @@ function idct32x32_\size\()_add_16_neon ldp d10, d11, [sp], 0x10 ldp d8, d9, [sp], 0x10 - br x15 + ret x15 endfunc .endm diff --git a/media/ffvpx/libavcodec/aarch64/vp9itxfm_neon.S b/media/ffvpx/libavcodec/aarch64/vp9itxfm_neon.S index 99413b0f707e..03272eae82fa 100644 --- a/media/ffvpx/libavcodec/aarch64/vp9itxfm_neon.S +++ b/media/ffvpx/libavcodec/aarch64/vp9itxfm_neon.S @@ -787,7 +787,7 @@ function \txfm\()16_1d_8x16_pass1_neon .irp i, 16, 24, 17, 25, 18, 26, 19, 27, 20, 28, 21, 29, 22, 30, 23, 31 store \i, x0, #16 .endr - br x14 + ret x14 1: // Special case: For the last input column (x1 == 8), // which would be stored as the last row in the temp buffer, @@ -806,7 +806,7 @@ function \txfm\()16_1d_8x16_pass1_neon mov v29.16b, v21.16b mov v30.16b, v22.16b mov v31.16b, v23.16b - br x14 + ret x14 endfunc // Read a vertical 8x16 slice out of a 16x16 matrix, do a transform on it, @@ -834,7 +834,7 @@ function \txfm\()16_1d_8x16_pass2_neon load_add_store v16.8h, v17.8h, v18.8h, v19.8h, v20.8h, v21.8h, v22.8h, v23.8h, v16.8b, v17.8b load_add_store v24.8h, v25.8h, v26.8h, v27.8h, v28.8h, v29.8h, v30.8h, v31.8h, v16.8b, v17.8b - br x14 + ret x14 endfunc .endm @@ -925,7 +925,7 @@ function ff_vp9_\txfm1\()_\txfm2\()_16x16_add_neon, export=1 ldp d12, d13, [sp], 0x10 ldp d14, d15, [sp], 0x10 .endif - br x15 + ret x15 endfunc .endm @@ -960,7 +960,7 @@ function idct16_1d_8x16_pass1_quarter_neon .irp i, 24, 25, 26, 27 store \i, x0, x9 .endr - br x14 + ret x14 endfunc function idct16_1d_8x16_pass2_quarter_neon @@ -978,7 +978,7 @@ function idct16_1d_8x16_pass2_quarter_neon load_add_store v16.8h, v17.8h, v18.8h, v19.8h, v20.8h, v21.8h, v22.8h, v23.8h, v16.8b, v17.8b load_add_store v24.8h, v25.8h, v26.8h, v27.8h, v28.8h, v29.8h, v30.8h, v31.8h, v16.8b, v17.8b - br x14 + ret x14 endfunc function idct16_1d_8x16_pass1_half_neon @@ -1003,7 +1003,7 @@ function idct16_1d_8x16_pass1_half_neon .irp i, 24, 25, 26, 27, 28, 29, 30, 31 store \i, x0, x9 .endr - br x14 + ret x14 endfunc function idct16_1d_8x16_pass2_half_neon @@ -1021,7 +1021,7 @@ function idct16_1d_8x16_pass2_half_neon load_add_store v16.8h, v17.8h, v18.8h, v19.8h, v20.8h, v21.8h, v22.8h, v23.8h, v16.8b, v17.8b load_add_store v24.8h, v25.8h, v26.8h, v27.8h, v28.8h, v29.8h, v30.8h, v31.8h, v16.8b, v17.8b - br x14 + ret x14 endfunc .macro idct16_partial size @@ -1038,7 +1038,7 @@ function idct16x16_\size\()_add_neon .endr add sp, sp, #512 - br x15 + ret x15 endfunc .endm @@ -1349,7 +1349,7 @@ function idct32_1d_8x32_pass1\suffix\()_neon store_rev v25.8h, v17.8h store_rev v24.8h, v16.8h .purgem store_rev - br x14 + ret x14 endfunc // This is mostly the same as 8x32_pass1, but without the transpose, @@ -1466,7 +1466,7 @@ function idct32_1d_8x32_pass2\suffix\()_neon load_acc_store v24.8h, v25.8h, v26.8h, v27.8h, 1 load_acc_store v28.8h, v29.8h, v30.8h, v31.8h, 1 .purgem load_acc_store - br x14 + ret x14 endfunc .endm @@ -1547,7 +1547,7 @@ function ff_vp9_idct_idct_32x32_add_neon, export=1 ldp d8, d9, [sp], 0x10 ldp d10, d11, [sp], 0x10 - br x15 + ret x15 endfunc .macro idct32_partial size @@ -1572,7 +1572,7 @@ function idct32x32_\size\()_add_neon ldp d8, d9, [sp], 0x10 ldp d10, d11, [sp], 0x10 - br x15 + ret x15 endfunc .endm diff --git a/media/ffvpx/libavcodec/aarch64/vp9lpf_16bpp_neon.S b/media/ffvpx/libavcodec/aarch64/vp9lpf_16bpp_neon.S index 9075f3d40619..a092617b9264 100644 --- a/media/ffvpx/libavcodec/aarch64/vp9lpf_16bpp_neon.S +++ b/media/ffvpx/libavcodec/aarch64/vp9lpf_16bpp_neon.S @@ -22,18 +22,6 @@ #include "neon.S" -.macro transpose_4x8H r0, r1, r2, r3, t4, t5, t6, t7 - trn1 \t4\().8h, \r0\().8h, \r1\().8h - trn2 \t5\().8h, \r0\().8h, \r1\().8h - trn1 \t6\().8h, \r2\().8h, \r3\().8h - trn2 \t7\().8h, \r2\().8h, \r3\().8h - - trn1 \r0\().4s, \t4\().4s, \t6\().4s - trn2 \r2\().4s, \t4\().4s, \t6\().4s - trn1 \r1\().4s, \t5\().4s, \t7\().4s - trn2 \r3\().4s, \t5\().4s, \t7\().4s -.endm - // The input to and output from this macro is in the registers v16-v31, // and v0-v7 are used as scratch registers. // p7 = v16 .. p3 = v20, p0 = v23, q0 = v24, q3 = v27, q7 = v31 @@ -69,7 +57,7 @@ mov x12, v4.d[1] adds x11, x11, x12 b.ne 1f - br x10 + ret x10 1: .if \wd >= 8 @@ -205,7 +193,7 @@ b.eq 6f .else b.ne 1f - br x13 + ret x13 1: .endif @@ -264,7 +252,7 @@ b.ne 1f // If no pixels needed flat8in nor flat8out, jump to a // writeout of the inner 4 pixels - br x14 + ret x14 1: mov x11, v7.d[0] @@ -272,7 +260,7 @@ adds x11, x11, x12 b.ne 1f // If no pixels need flat8out, jump to a writeout of the inner 6 pixels - br x15 + ret x15 1: // flat8out @@ -446,7 +434,7 @@ function ff_\func\()_\bpp\()_neon, export=1 ldp d10, d11, [sp], 0x10 ldp d12, d13, [sp], 0x10 ldp d14, d15, [sp], 0x10 - br x16 + ret x16 .else b \func\()_16_neon .endif @@ -486,7 +474,7 @@ function ff_\func\()_\suffix\()_\bpp\()_neon, export=1 ldp d12, d13, [sp], 0x10 ldp d14, d15, [sp], 0x10 .endif - br x16 + ret x16 endfunc .endm @@ -520,7 +508,7 @@ function ff_vp9_loop_filter_\dir\()_\wd1\()\wd2\()_16_\bpp\()_neon, export=1 lsl w3, w14, #\bpp - 8 lsl w4, w15, #\bpp - 8 bl vp9_loop_filter_\dir\()_\wd2\()_8_16_neon - br x16 + ret x16 endfunc .endm @@ -553,7 +541,7 @@ function vp9_loop_filter_v_4_8_16_neon st1 {v25.8h}, [x0], x1 sub x0, x0, x1, lsl #1 - br x10 + ret x10 endfunc bpp_frontends vp9_loop_filter_v_4_8 @@ -601,7 +589,7 @@ function vp9_loop_filter_h_4_8_16_neon sub x0, x0, x1, lsl #3 add x0, x0, #4 - br x10 + ret x10 endfunc bpp_frontends vp9_loop_filter_h_4_8 @@ -632,7 +620,7 @@ function vp9_loop_filter_v_8_8_16_neon sub x0, x0, x1, lsl #1 sub x0, x0, x1 - br x10 + ret x10 6: sub x9, x0, x1, lsl #1 st1 {v22.8h}, [x9], x1 @@ -640,7 +628,7 @@ function vp9_loop_filter_v_8_8_16_neon st1 {v23.8h}, [x9], x1 st1 {v25.8h}, [x0], x1 sub x0, x0, x1, lsl #1 - br x10 + ret x10 endfunc bpp_frontends vp9_loop_filter_v_8_8 @@ -683,7 +671,7 @@ function vp9_loop_filter_h_8_8_16_neon sub x0, x0, x1, lsl #3 add x0, x0, #8 - br x10 + ret x10 6: // If we didn't need to do the flat8in part, we use the same writeback // as in loop_filter_h_4_8. @@ -700,7 +688,7 @@ function vp9_loop_filter_h_8_8_16_neon st1 {v25.d}[1], [x0], x1 sub x0, x0, x1, lsl #3 add x0, x0, #4 - br x10 + ret x10 endfunc bpp_frontends vp9_loop_filter_h_8_8 @@ -755,7 +743,7 @@ function vp9_loop_filter_v_16_8_16_neon sub x0, x0, x1, lsl #3 add x0, x0, x1 - br x10 + ret x10 8: add x9, x9, x1, lsl #2 // If we didn't do the flat8out part, the output is left in the @@ -768,7 +756,7 @@ function vp9_loop_filter_v_16_8_16_neon st1 {v26.8h}, [x0], x1 sub x0, x0, x1, lsl #1 sub x0, x0, x1 - br x10 + ret x10 7: sub x9, x0, x1, lsl #1 st1 {v22.8h}, [x9], x1 @@ -776,7 +764,7 @@ function vp9_loop_filter_v_16_8_16_neon st1 {v23.8h}, [x9], x1 st1 {v25.8h}, [x0], x1 sub x0, x0, x1, lsl #1 - br x10 + ret x10 endfunc bpp_frontends vp9_loop_filter_v_16_8, push=1 @@ -833,7 +821,7 @@ function vp9_loop_filter_h_16_8_16_neon st1 {v31.8h}, [x0], x1 sub x0, x0, x1, lsl #3 - br x10 + ret x10 8: // The same writeback as in loop_filter_h_8_8 sub x9, x0, #8 @@ -850,7 +838,7 @@ function vp9_loop_filter_h_16_8_16_neon st1 {v27.8h}, [x0], x1 sub x0, x0, x1, lsl #3 add x0, x0, #8 - br x10 + ret x10 7: // The same writeback as in loop_filter_h_4_8 sub x9, x0, #4 @@ -866,7 +854,7 @@ function vp9_loop_filter_h_16_8_16_neon st1 {v25.d}[1], [x0], x1 sub x0, x0, x1, lsl #3 add x0, x0, #4 - br x10 + ret x10 endfunc bpp_frontends vp9_loop_filter_h_16_8, push=1 diff --git a/media/ffvpx/libavcodec/aarch64/vp9lpf_neon.S b/media/ffvpx/libavcodec/aarch64/vp9lpf_neon.S index 0878763020a5..694ff8956fc2 100644 --- a/media/ffvpx/libavcodec/aarch64/vp9lpf_neon.S +++ b/media/ffvpx/libavcodec/aarch64/vp9lpf_neon.S @@ -399,7 +399,7 @@ .endif // If no pixels needed flat8in nor flat8out, jump to a // writeout of the inner 4 pixels - br x14 + ret x14 1: mov x5, v7.d[0] @@ -411,7 +411,7 @@ cbnz x5, 1f .endif // If no pixels need flat8out, jump to a writeout of the inner 6 pixels - br x15 + ret x15 1: // flat8out @@ -532,32 +532,32 @@ function vp9_loop_filter_4 loop_filter 4, .8b, 0, v16, v17, v18, v19, v28, v29, v30, v31 ret 9: - br x10 + ret x10 endfunc function vp9_loop_filter_4_16b_mix_44 loop_filter 4, .16b, 44, v16, v17, v18, v19, v28, v29, v30, v31 ret 9: - br x10 + ret x10 endfunc function vp9_loop_filter_8 loop_filter 8, .8b, 0, v16, v17, v18, v19, v28, v29, v30, v31 ret 6: - br x13 + ret x13 9: - br x10 + ret x10 endfunc function vp9_loop_filter_8_16b_mix loop_filter 8, .16b, 88, v16, v17, v18, v19, v28, v29, v30, v31 ret 6: - br x13 + ret x13 9: - br x10 + ret x10 endfunc function vp9_loop_filter_16 @@ -568,7 +568,7 @@ function vp9_loop_filter_16 ldp d10, d11, [sp], 0x10 ldp d12, d13, [sp], 0x10 ldp d14, d15, [sp], 0x10 - br x10 + ret x10 endfunc function vp9_loop_filter_16_16b @@ -579,7 +579,7 @@ function vp9_loop_filter_16_16b ldp d10, d11, [sp], 0x10 ldp d12, d13, [sp], 0x10 ldp d14, d15, [sp], 0x10 - br x10 + ret x10 endfunc .macro loop_filter_4 @@ -648,7 +648,7 @@ function ff_vp9_loop_filter_v_4_8_neon, export=1 st1 {v23.8b}, [x9], x1 st1 {v25.8b}, [x0], x1 - br x10 + ret x10 endfunc function ff_vp9_loop_filter_v_44_16_neon, export=1 @@ -672,7 +672,7 @@ function ff_vp9_loop_filter_v_44_16_neon, export=1 st1 {v23.16b}, [x9], x1 st1 {v25.16b}, [x0], x1 - br x10 + ret x10 endfunc function ff_vp9_loop_filter_h_4_8_neon, export=1 @@ -714,7 +714,7 @@ function ff_vp9_loop_filter_h_4_8_neon, export=1 st1 {v25.s}[0], [x9], x1 st1 {v25.s}[1], [x0], x1 - br x10 + ret x10 endfunc function ff_vp9_loop_filter_h_44_16_neon, export=1 @@ -766,7 +766,7 @@ function ff_vp9_loop_filter_h_44_16_neon, export=1 st1 {v25.s}[1], [x9], x1 st1 {v25.s}[3], [x0], x1 - br x10 + ret x10 endfunc function ff_vp9_loop_filter_v_8_8_neon, export=1 @@ -793,14 +793,14 @@ function ff_vp9_loop_filter_v_8_8_neon, export=1 st1 {v23.8b}, [x9], x1 st1 {v26.8b}, [x0], x1 - br x10 + ret x10 6: sub x9, x0, x1, lsl #1 st1 {v22.8b}, [x9], x1 st1 {v24.8b}, [x0], x1 st1 {v23.8b}, [x9], x1 st1 {v25.8b}, [x0], x1 - br x10 + ret x10 endfunc .macro mix_v_16 mix @@ -828,14 +828,14 @@ function ff_vp9_loop_filter_v_\mix\()_16_neon, export=1 st1 {v23.16b}, [x9], x1 st1 {v26.16b}, [x0], x1 - br x10 + ret x10 6: sub x9, x0, x1, lsl #1 st1 {v22.16b}, [x9], x1 st1 {v24.16b}, [x0], x1 st1 {v23.16b}, [x9], x1 st1 {v25.16b}, [x0], x1 - br x10 + ret x10 endfunc .endm @@ -876,7 +876,7 @@ function ff_vp9_loop_filter_h_8_8_neon, export=1 st1 {v23.8b}, [x9], x1 st1 {v27.8b}, [x0], x1 - br x10 + ret x10 6: // If we didn't need to do the flat8in part, we use the same writeback // as in loop_filter_h_4_8. @@ -891,7 +891,7 @@ function ff_vp9_loop_filter_h_8_8_neon, export=1 st1 {v24.s}[1], [x0], x1 st1 {v25.s}[0], [x9], x1 st1 {v25.s}[1], [x0], x1 - br x10 + ret x10 endfunc .macro mix_h_16 mix @@ -942,7 +942,7 @@ function ff_vp9_loop_filter_h_\mix\()_16_neon, export=1 st1 {v27.8b}, [x9], x1 st1 {v27.d}[1], [x0], x1 - br x10 + ret x10 6: add x9, x9, #2 add x0, x0, #2 @@ -963,7 +963,7 @@ function ff_vp9_loop_filter_h_\mix\()_16_neon, export=1 st1 {v24.s}[3], [x0], x1 st1 {v25.s}[1], [x9], x1 st1 {v25.s}[3], [x0], x1 - br x10 + ret x10 endfunc .endm @@ -1022,7 +1022,7 @@ function ff_vp9_loop_filter_v_16_8_neon, export=1 ldp d10, d11, [sp], 0x10 ldp d12, d13, [sp], 0x10 ldp d14, d15, [sp], 0x10 - br x10 + ret x10 8: add x9, x9, x1, lsl #2 // If we didn't do the flat8out part, the output is left in the @@ -1091,7 +1091,7 @@ function ff_vp9_loop_filter_v_16_16_neon, export=1 ldp d10, d11, [sp], 0x10 ldp d12, d13, [sp], 0x10 ldp d14, d15, [sp], 0x10 - br x10 + ret x10 8: add x9, x9, x1, lsl #2 st1 {v21.16b}, [x9], x1 @@ -1168,7 +1168,7 @@ function ff_vp9_loop_filter_h_16_8_neon, export=1 ldp d10, d11, [sp], 0x10 ldp d12, d13, [sp], 0x10 ldp d14, d15, [sp], 0x10 - br x10 + ret x10 8: // The same writeback as in loop_filter_h_8_8 sub x9, x0, #4 @@ -1287,7 +1287,7 @@ function ff_vp9_loop_filter_h_16_16_neon, export=1 ldp d10, d11, [sp], 0x10 ldp d12, d13, [sp], 0x10 ldp d14, d15, [sp], 0x10 - br x10 + ret x10 8: sub x9, x0, #4 add x0, x9, x1, lsl #3 diff --git a/media/ffvpx/libavcodec/allcodecs.c b/media/ffvpx/libavcodec/allcodecs.c index 2e9a3581dea2..f0b01051b00b 100644 --- a/media/ffvpx/libavcodec/allcodecs.c +++ b/media/ffvpx/libavcodec/allcodecs.c @@ -24,821 +24,846 @@ * Provide registration of all codecs, parsers and bitstream filters for libavcodec. */ -#include "config.h" -#include "libavutil/thread.h" -#include "avcodec.h" -#include "version.h" +#include +#include -extern AVCodec ff_a64multi_encoder; -extern AVCodec ff_a64multi5_encoder; -extern AVCodec ff_aasc_decoder; -extern AVCodec ff_aic_decoder; -extern AVCodec ff_alias_pix_encoder; -extern AVCodec ff_alias_pix_decoder; -extern AVCodec ff_agm_decoder; -extern AVCodec ff_amv_encoder; -extern AVCodec ff_amv_decoder; -extern AVCodec ff_anm_decoder; -extern AVCodec ff_ansi_decoder; -extern AVCodec ff_apng_encoder; -extern AVCodec ff_apng_decoder; -extern AVCodec ff_arbc_decoder; -extern AVCodec ff_argo_decoder; -extern AVCodec ff_asv1_encoder; -extern AVCodec ff_asv1_decoder; -extern AVCodec ff_asv2_encoder; -extern AVCodec ff_asv2_decoder; -extern AVCodec ff_aura_decoder; -extern AVCodec ff_aura2_decoder; -extern AVCodec ff_avrp_encoder; -extern AVCodec ff_avrp_decoder; -extern AVCodec ff_avrn_decoder; -extern AVCodec ff_avs_decoder; -extern AVCodec ff_avui_encoder; -extern AVCodec ff_avui_decoder; -extern AVCodec ff_ayuv_encoder; -extern AVCodec ff_ayuv_decoder; -extern AVCodec ff_bethsoftvid_decoder; -extern AVCodec ff_bfi_decoder; -extern AVCodec ff_bink_decoder; -extern AVCodec ff_bitpacked_decoder; -extern AVCodec ff_bmp_encoder; -extern AVCodec ff_bmp_decoder; -extern AVCodec ff_bmv_video_decoder; -extern AVCodec ff_brender_pix_decoder; -extern AVCodec ff_c93_decoder; -extern AVCodec ff_cavs_decoder; -extern AVCodec ff_cdgraphics_decoder; -extern AVCodec ff_cdtoons_decoder; -extern AVCodec ff_cdxl_decoder; -extern AVCodec ff_cfhd_encoder; -extern AVCodec ff_cfhd_decoder; -extern AVCodec ff_cinepak_encoder; -extern AVCodec ff_cinepak_decoder; -extern AVCodec ff_clearvideo_decoder; -extern AVCodec ff_cljr_encoder; -extern AVCodec ff_cljr_decoder; -extern AVCodec ff_cllc_decoder; -extern AVCodec ff_comfortnoise_encoder; -extern AVCodec ff_comfortnoise_decoder; -extern AVCodec ff_cpia_decoder; -extern AVCodec ff_cri_decoder; -extern AVCodec ff_cscd_decoder; -extern AVCodec ff_cyuv_decoder; -extern AVCodec ff_dds_decoder; -extern AVCodec ff_dfa_decoder; -extern AVCodec ff_dirac_decoder; -extern AVCodec ff_dnxhd_encoder; -extern AVCodec ff_dnxhd_decoder; -extern AVCodec ff_dpx_encoder; -extern AVCodec ff_dpx_decoder; -extern AVCodec ff_dsicinvideo_decoder; -extern AVCodec ff_dvaudio_decoder; -extern AVCodec ff_dvvideo_encoder; -extern AVCodec ff_dvvideo_decoder; -extern AVCodec ff_dxa_decoder; -extern AVCodec ff_dxtory_decoder; -extern AVCodec ff_dxv_decoder; -extern AVCodec ff_eacmv_decoder; -extern AVCodec ff_eamad_decoder; -extern AVCodec ff_eatgq_decoder; -extern AVCodec ff_eatgv_decoder; -extern AVCodec ff_eatqi_decoder; -extern AVCodec ff_eightbps_decoder; -extern AVCodec ff_eightsvx_exp_decoder; -extern AVCodec ff_eightsvx_fib_decoder; -extern AVCodec ff_escape124_decoder; -extern AVCodec ff_escape130_decoder; -extern AVCodec ff_exr_encoder; -extern AVCodec ff_exr_decoder; -extern AVCodec ff_ffv1_encoder; -extern AVCodec ff_ffv1_decoder; -extern AVCodec ff_ffvhuff_encoder; -extern AVCodec ff_ffvhuff_decoder; -extern AVCodec ff_fic_decoder; -extern AVCodec ff_fits_encoder; -extern AVCodec ff_fits_decoder; -extern AVCodec ff_flashsv_encoder; -extern AVCodec ff_flashsv_decoder; -extern AVCodec ff_flashsv2_encoder; -extern AVCodec ff_flashsv2_decoder; -extern AVCodec ff_flic_decoder; -extern AVCodec ff_flv_encoder; -extern AVCodec ff_flv_decoder; -extern AVCodec ff_fmvc_decoder; -extern AVCodec ff_fourxm_decoder; -extern AVCodec ff_fraps_decoder; -extern AVCodec ff_frwu_decoder; -extern AVCodec ff_g2m_decoder; -extern AVCodec ff_gdv_decoder; -extern AVCodec ff_gif_encoder; -extern AVCodec ff_gif_decoder; -extern AVCodec ff_h261_encoder; -extern AVCodec ff_h261_decoder; -extern AVCodec ff_h263_encoder; -extern AVCodec ff_h263_decoder; -extern AVCodec ff_h263i_decoder; -extern AVCodec ff_h263p_encoder; -extern AVCodec ff_h263p_decoder; -extern AVCodec ff_h263_v4l2m2m_decoder; -extern AVCodec ff_h264_decoder; -extern AVCodec ff_h264_crystalhd_decoder; -extern AVCodec ff_h264_v4l2m2m_decoder; -extern AVCodec ff_h264_mediacodec_decoder; -extern AVCodec ff_h264_mmal_decoder; -extern AVCodec ff_h264_qsv_decoder; -extern AVCodec ff_h264_rkmpp_decoder; -extern AVCodec ff_hap_encoder; -extern AVCodec ff_hap_decoder; -extern AVCodec ff_hevc_decoder; -extern AVCodec ff_hevc_qsv_decoder; -extern AVCodec ff_hevc_rkmpp_decoder; -extern AVCodec ff_hevc_v4l2m2m_decoder; -extern AVCodec ff_hnm4_video_decoder; -extern AVCodec ff_hq_hqa_decoder; -extern AVCodec ff_hqx_decoder; -extern AVCodec ff_huffyuv_encoder; -extern AVCodec ff_huffyuv_decoder; -extern AVCodec ff_hymt_decoder; -extern AVCodec ff_idcin_decoder; -extern AVCodec ff_iff_ilbm_decoder; -extern AVCodec ff_imm4_decoder; -extern AVCodec ff_imm5_decoder; -extern AVCodec ff_indeo2_decoder; -extern AVCodec ff_indeo3_decoder; -extern AVCodec ff_indeo4_decoder; -extern AVCodec ff_indeo5_decoder; -extern AVCodec ff_interplay_video_decoder; -extern AVCodec ff_ipu_decoder; -extern AVCodec ff_jpeg2000_encoder; -extern AVCodec ff_jpeg2000_decoder; -extern AVCodec ff_jpegls_encoder; -extern AVCodec ff_jpegls_decoder; -extern AVCodec ff_jv_decoder; -extern AVCodec ff_kgv1_decoder; -extern AVCodec ff_kmvc_decoder; -extern AVCodec ff_lagarith_decoder; -extern AVCodec ff_ljpeg_encoder; -extern AVCodec ff_loco_decoder; -extern AVCodec ff_lscr_decoder; -extern AVCodec ff_m101_decoder; -extern AVCodec ff_magicyuv_encoder; -extern AVCodec ff_magicyuv_decoder; -extern AVCodec ff_mdec_decoder; -extern AVCodec ff_mimic_decoder; -extern AVCodec ff_mjpeg_encoder; -extern AVCodec ff_mjpeg_decoder; -extern AVCodec ff_mjpegb_decoder; -extern AVCodec ff_mmvideo_decoder; -extern AVCodec ff_mobiclip_decoder; -extern AVCodec ff_motionpixels_decoder; -extern AVCodec ff_mpeg1video_encoder; -extern AVCodec ff_mpeg1video_decoder; -extern AVCodec ff_mpeg2video_encoder; -extern AVCodec ff_mpeg2video_decoder; -extern AVCodec ff_mpeg4_encoder; -extern AVCodec ff_mpeg4_decoder; -extern AVCodec ff_mpeg4_crystalhd_decoder; -extern AVCodec ff_mpeg4_v4l2m2m_decoder; -extern AVCodec ff_mpeg4_mmal_decoder; -extern AVCodec ff_mpegvideo_decoder; -extern AVCodec ff_mpeg1_v4l2m2m_decoder; -extern AVCodec ff_mpeg2_mmal_decoder; -extern AVCodec ff_mpeg2_crystalhd_decoder; -extern AVCodec ff_mpeg2_v4l2m2m_decoder; -extern AVCodec ff_mpeg2_qsv_decoder; -extern AVCodec ff_mpeg2_mediacodec_decoder; -extern AVCodec ff_msa1_decoder; -extern AVCodec ff_mscc_decoder; -extern AVCodec ff_msmpeg4v1_decoder; -extern AVCodec ff_msmpeg4v2_encoder; -extern AVCodec ff_msmpeg4v2_decoder; -extern AVCodec ff_msmpeg4v3_encoder; -extern AVCodec ff_msmpeg4v3_decoder; -extern AVCodec ff_msmpeg4_crystalhd_decoder; -extern AVCodec ff_msp2_decoder; -extern AVCodec ff_msrle_decoder; -extern AVCodec ff_mss1_decoder; -extern AVCodec ff_mss2_decoder; -extern AVCodec ff_msvideo1_encoder; -extern AVCodec ff_msvideo1_decoder; -extern AVCodec ff_mszh_decoder; -extern AVCodec ff_mts2_decoder; -extern AVCodec ff_mv30_decoder; -extern AVCodec ff_mvc1_decoder; -extern AVCodec ff_mvc2_decoder; -extern AVCodec ff_mvdv_decoder; -extern AVCodec ff_mvha_decoder; -extern AVCodec ff_mwsc_decoder; -extern AVCodec ff_mxpeg_decoder; -extern AVCodec ff_notchlc_decoder; -extern AVCodec ff_nuv_decoder; -extern AVCodec ff_paf_video_decoder; -extern AVCodec ff_pam_encoder; -extern AVCodec ff_pam_decoder; -extern AVCodec ff_pbm_encoder; -extern AVCodec ff_pbm_decoder; -extern AVCodec ff_pcx_encoder; -extern AVCodec ff_pcx_decoder; -extern AVCodec ff_pfm_encoder; -extern AVCodec ff_pfm_decoder; -extern AVCodec ff_pgm_encoder; -extern AVCodec ff_pgm_decoder; -extern AVCodec ff_pgmyuv_encoder; -extern AVCodec ff_pgmyuv_decoder; -extern AVCodec ff_pgx_decoder; -extern AVCodec ff_photocd_decoder; -extern AVCodec ff_pictor_decoder; -extern AVCodec ff_pixlet_decoder; -extern AVCodec ff_png_encoder; -extern AVCodec ff_png_decoder; -extern AVCodec ff_ppm_encoder; -extern AVCodec ff_ppm_decoder; -extern AVCodec ff_prores_encoder; -extern AVCodec ff_prores_decoder; -extern AVCodec ff_prores_aw_encoder; -extern AVCodec ff_prores_ks_encoder; -extern AVCodec ff_prosumer_decoder; -extern AVCodec ff_psd_decoder; -extern AVCodec ff_ptx_decoder; -extern AVCodec ff_qdraw_decoder; -extern AVCodec ff_qpeg_decoder; -extern AVCodec ff_qtrle_encoder; -extern AVCodec ff_qtrle_decoder; -extern AVCodec ff_r10k_encoder; -extern AVCodec ff_r10k_decoder; -extern AVCodec ff_r210_encoder; -extern AVCodec ff_r210_decoder; -extern AVCodec ff_rasc_decoder; -extern AVCodec ff_rawvideo_encoder; -extern AVCodec ff_rawvideo_decoder; -extern AVCodec ff_rl2_decoder; -extern AVCodec ff_roq_encoder; -extern AVCodec ff_roq_decoder; -extern AVCodec ff_rpza_encoder; -extern AVCodec ff_rpza_decoder; -extern AVCodec ff_rscc_decoder; -extern AVCodec ff_rv10_encoder; -extern AVCodec ff_rv10_decoder; -extern AVCodec ff_rv20_encoder; -extern AVCodec ff_rv20_decoder; -extern AVCodec ff_rv30_decoder; -extern AVCodec ff_rv40_decoder; -extern AVCodec ff_s302m_encoder; -extern AVCodec ff_s302m_decoder; -extern AVCodec ff_sanm_decoder; -extern AVCodec ff_scpr_decoder; -extern AVCodec ff_screenpresso_decoder; -extern AVCodec ff_sga_decoder; -extern AVCodec ff_sgi_encoder; -extern AVCodec ff_sgi_decoder; -extern AVCodec ff_sgirle_decoder; -extern AVCodec ff_sheervideo_decoder; -extern AVCodec ff_simbiosis_imx_decoder; -extern AVCodec ff_smacker_decoder; -extern AVCodec ff_smc_decoder; -extern AVCodec ff_smvjpeg_decoder; -extern AVCodec ff_snow_encoder; -extern AVCodec ff_snow_decoder; -extern AVCodec ff_sp5x_decoder; -extern AVCodec ff_speedhq_decoder; -extern AVCodec ff_speedhq_encoder; -extern AVCodec ff_srgc_decoder; -extern AVCodec ff_sunrast_encoder; -extern AVCodec ff_sunrast_decoder; -extern AVCodec ff_svq1_encoder; -extern AVCodec ff_svq1_decoder; -extern AVCodec ff_svq3_decoder; -extern AVCodec ff_targa_encoder; -extern AVCodec ff_targa_decoder; -extern AVCodec ff_targa_y216_decoder; -extern AVCodec ff_tdsc_decoder; -extern AVCodec ff_theora_decoder; -extern AVCodec ff_thp_decoder; -extern AVCodec ff_tiertexseqvideo_decoder; -extern AVCodec ff_tiff_encoder; -extern AVCodec ff_tiff_decoder; -extern AVCodec ff_tmv_decoder; -extern AVCodec ff_truemotion1_decoder; -extern AVCodec ff_truemotion2_decoder; -extern AVCodec ff_truemotion2rt_decoder; -extern AVCodec ff_tscc_decoder; -extern AVCodec ff_tscc2_decoder; -extern AVCodec ff_txd_decoder; -extern AVCodec ff_ulti_decoder; -extern AVCodec ff_utvideo_encoder; -extern AVCodec ff_utvideo_decoder; -extern AVCodec ff_v210_encoder; -extern AVCodec ff_v210_decoder; -extern AVCodec ff_v210x_decoder; -extern AVCodec ff_v308_encoder; -extern AVCodec ff_v308_decoder; -extern AVCodec ff_v408_encoder; -extern AVCodec ff_v408_decoder; -extern AVCodec ff_v410_encoder; -extern AVCodec ff_v410_decoder; -extern AVCodec ff_vb_decoder; -extern AVCodec ff_vble_decoder; -extern AVCodec ff_vc1_decoder; -extern AVCodec ff_vc1_crystalhd_decoder; -extern AVCodec ff_vc1image_decoder; -extern AVCodec ff_vc1_mmal_decoder; -extern AVCodec ff_vc1_qsv_decoder; -extern AVCodec ff_vc1_v4l2m2m_decoder; -extern AVCodec ff_vc2_encoder; -extern AVCodec ff_vcr1_decoder; -extern AVCodec ff_vmdvideo_decoder; -extern AVCodec ff_vmnc_decoder; -extern AVCodec ff_vp3_decoder; -extern AVCodec ff_vp4_decoder; -extern AVCodec ff_vp5_decoder; -extern AVCodec ff_vp6_decoder; -extern AVCodec ff_vp6a_decoder; -extern AVCodec ff_vp6f_decoder; -extern AVCodec ff_vp7_decoder; -extern AVCodec ff_vp8_decoder; -extern AVCodec ff_vp8_rkmpp_decoder; -extern AVCodec ff_vp8_v4l2m2m_decoder; -extern AVCodec ff_vp9_decoder; -extern AVCodec ff_vp9_rkmpp_decoder; -extern AVCodec ff_vp9_v4l2m2m_decoder; -extern AVCodec ff_vqa_decoder; -extern AVCodec ff_webp_decoder; -extern AVCodec ff_wcmv_decoder; -extern AVCodec ff_wrapped_avframe_encoder; -extern AVCodec ff_wrapped_avframe_decoder; -extern AVCodec ff_wmv1_encoder; -extern AVCodec ff_wmv1_decoder; -extern AVCodec ff_wmv2_encoder; -extern AVCodec ff_wmv2_decoder; -extern AVCodec ff_wmv3_decoder; -extern AVCodec ff_wmv3_crystalhd_decoder; -extern AVCodec ff_wmv3image_decoder; -extern AVCodec ff_wnv1_decoder; -extern AVCodec ff_xan_wc3_decoder; -extern AVCodec ff_xan_wc4_decoder; -extern AVCodec ff_xbm_encoder; -extern AVCodec ff_xbm_decoder; -extern AVCodec ff_xface_encoder; -extern AVCodec ff_xface_decoder; -extern AVCodec ff_xl_decoder; -extern AVCodec ff_xpm_decoder; -extern AVCodec ff_xwd_encoder; -extern AVCodec ff_xwd_decoder; -extern AVCodec ff_y41p_encoder; -extern AVCodec ff_y41p_decoder; -extern AVCodec ff_ylc_decoder; -extern AVCodec ff_yop_decoder; -extern AVCodec ff_yuv4_encoder; -extern AVCodec ff_yuv4_decoder; -extern AVCodec ff_zero12v_decoder; -extern AVCodec ff_zerocodec_decoder; -extern AVCodec ff_zlib_encoder; -extern AVCodec ff_zlib_decoder; -extern AVCodec ff_zmbv_encoder; -extern AVCodec ff_zmbv_decoder; +#include "config.h" +#include "config_components.h" +#include "libavutil/thread.h" +#include "codec.h" +#include "codec_id.h" +#include "codec_internal.h" + +extern const FFCodec ff_a64multi_encoder; +extern const FFCodec ff_a64multi5_encoder; +extern const FFCodec ff_aasc_decoder; +extern const FFCodec ff_aic_decoder; +extern const FFCodec ff_alias_pix_encoder; +extern const FFCodec ff_alias_pix_decoder; +extern const FFCodec ff_agm_decoder; +extern const FFCodec ff_amv_encoder; +extern const FFCodec ff_amv_decoder; +extern const FFCodec ff_anm_decoder; +extern const FFCodec ff_ansi_decoder; +extern const FFCodec ff_apng_encoder; +extern const FFCodec ff_apng_decoder; +extern const FFCodec ff_arbc_decoder; +extern const FFCodec ff_argo_decoder; +extern const FFCodec ff_asv1_encoder; +extern const FFCodec ff_asv1_decoder; +extern const FFCodec ff_asv2_encoder; +extern const FFCodec ff_asv2_decoder; +extern const FFCodec ff_aura_decoder; +extern const FFCodec ff_aura2_decoder; +extern const FFCodec ff_avrp_encoder; +extern const FFCodec ff_avrp_decoder; +extern const FFCodec ff_avrn_decoder; +extern const FFCodec ff_avs_decoder; +extern const FFCodec ff_avui_encoder; +extern const FFCodec ff_avui_decoder; +extern const FFCodec ff_ayuv_encoder; +extern const FFCodec ff_ayuv_decoder; +extern const FFCodec ff_bethsoftvid_decoder; +extern const FFCodec ff_bfi_decoder; +extern const FFCodec ff_bink_decoder; +extern const FFCodec ff_bitpacked_decoder; +extern const FFCodec ff_bitpacked_encoder; +extern const FFCodec ff_bmp_encoder; +extern const FFCodec ff_bmp_decoder; +extern const FFCodec ff_bmv_video_decoder; +extern const FFCodec ff_brender_pix_decoder; +extern const FFCodec ff_c93_decoder; +extern const FFCodec ff_cavs_decoder; +extern const FFCodec ff_cdgraphics_decoder; +extern const FFCodec ff_cdtoons_decoder; +extern const FFCodec ff_cdxl_decoder; +extern const FFCodec ff_cfhd_encoder; +extern const FFCodec ff_cfhd_decoder; +extern const FFCodec ff_cinepak_encoder; +extern const FFCodec ff_cinepak_decoder; +extern const FFCodec ff_clearvideo_decoder; +extern const FFCodec ff_cljr_encoder; +extern const FFCodec ff_cljr_decoder; +extern const FFCodec ff_cllc_decoder; +extern const FFCodec ff_comfortnoise_encoder; +extern const FFCodec ff_comfortnoise_decoder; +extern const FFCodec ff_cpia_decoder; +extern const FFCodec ff_cri_decoder; +extern const FFCodec ff_cscd_decoder; +extern const FFCodec ff_cyuv_decoder; +extern const FFCodec ff_dds_decoder; +extern const FFCodec ff_dfa_decoder; +extern const FFCodec ff_dirac_decoder; +extern const FFCodec ff_dnxhd_encoder; +extern const FFCodec ff_dnxhd_decoder; +extern const FFCodec ff_dpx_encoder; +extern const FFCodec ff_dpx_decoder; +extern const FFCodec ff_dsicinvideo_decoder; +extern const FFCodec ff_dvaudio_decoder; +extern const FFCodec ff_dvvideo_encoder; +extern const FFCodec ff_dvvideo_decoder; +extern const FFCodec ff_dxa_decoder; +extern const FFCodec ff_dxtory_decoder; +extern const FFCodec ff_dxv_decoder; +extern const FFCodec ff_eacmv_decoder; +extern const FFCodec ff_eamad_decoder; +extern const FFCodec ff_eatgq_decoder; +extern const FFCodec ff_eatgv_decoder; +extern const FFCodec ff_eatqi_decoder; +extern const FFCodec ff_eightbps_decoder; +extern const FFCodec ff_eightsvx_exp_decoder; +extern const FFCodec ff_eightsvx_fib_decoder; +extern const FFCodec ff_escape124_decoder; +extern const FFCodec ff_escape130_decoder; +extern const FFCodec ff_exr_encoder; +extern const FFCodec ff_exr_decoder; +extern const FFCodec ff_ffv1_encoder; +extern const FFCodec ff_ffv1_decoder; +extern const FFCodec ff_ffvhuff_encoder; +extern const FFCodec ff_ffvhuff_decoder; +extern const FFCodec ff_fic_decoder; +extern const FFCodec ff_fits_encoder; +extern const FFCodec ff_fits_decoder; +extern const FFCodec ff_flashsv_encoder; +extern const FFCodec ff_flashsv_decoder; +extern const FFCodec ff_flashsv2_encoder; +extern const FFCodec ff_flashsv2_decoder; +extern const FFCodec ff_flic_decoder; +extern const FFCodec ff_flv_encoder; +extern const FFCodec ff_flv_decoder; +extern const FFCodec ff_fmvc_decoder; +extern const FFCodec ff_fourxm_decoder; +extern const FFCodec ff_fraps_decoder; +extern const FFCodec ff_frwu_decoder; +extern const FFCodec ff_g2m_decoder; +extern const FFCodec ff_gdv_decoder; +extern const FFCodec ff_gem_decoder; +extern const FFCodec ff_gif_encoder; +extern const FFCodec ff_gif_decoder; +extern const FFCodec ff_h261_encoder; +extern const FFCodec ff_h261_decoder; +extern const FFCodec ff_h263_encoder; +extern const FFCodec ff_h263_decoder; +extern const FFCodec ff_h263i_decoder; +extern const FFCodec ff_h263p_encoder; +extern const FFCodec ff_h263p_decoder; +extern const FFCodec ff_h263_v4l2m2m_decoder; +extern const FFCodec ff_h264_decoder; +extern const FFCodec ff_h264_crystalhd_decoder; +extern const FFCodec ff_h264_v4l2m2m_decoder; +extern const FFCodec ff_h264_mediacodec_decoder; +extern const FFCodec ff_h264_mmal_decoder; +extern const FFCodec ff_h264_qsv_decoder; +extern const FFCodec ff_h264_rkmpp_decoder; +extern const FFCodec ff_hap_encoder; +extern const FFCodec ff_hap_decoder; +extern const FFCodec ff_hevc_decoder; +extern const FFCodec ff_hevc_qsv_decoder; +extern const FFCodec ff_hevc_rkmpp_decoder; +extern const FFCodec ff_hevc_v4l2m2m_decoder; +extern const FFCodec ff_hnm4_video_decoder; +extern const FFCodec ff_hq_hqa_decoder; +extern const FFCodec ff_hqx_decoder; +extern const FFCodec ff_huffyuv_encoder; +extern const FFCodec ff_huffyuv_decoder; +extern const FFCodec ff_hymt_decoder; +extern const FFCodec ff_idcin_decoder; +extern const FFCodec ff_iff_ilbm_decoder; +extern const FFCodec ff_imm4_decoder; +extern const FFCodec ff_imm5_decoder; +extern const FFCodec ff_indeo2_decoder; +extern const FFCodec ff_indeo3_decoder; +extern const FFCodec ff_indeo4_decoder; +extern const FFCodec ff_indeo5_decoder; +extern const FFCodec ff_interplay_video_decoder; +extern const FFCodec ff_ipu_decoder; +extern const FFCodec ff_jpeg2000_encoder; +extern const FFCodec ff_jpeg2000_decoder; +extern const FFCodec ff_jpegls_encoder; +extern const FFCodec ff_jpegls_decoder; +extern const FFCodec ff_jv_decoder; +extern const FFCodec ff_kgv1_decoder; +extern const FFCodec ff_kmvc_decoder; +extern const FFCodec ff_lagarith_decoder; +extern const FFCodec ff_ljpeg_encoder; +extern const FFCodec ff_loco_decoder; +extern const FFCodec ff_lscr_decoder; +extern const FFCodec ff_m101_decoder; +extern const FFCodec ff_magicyuv_encoder; +extern const FFCodec ff_magicyuv_decoder; +extern const FFCodec ff_mdec_decoder; +extern const FFCodec ff_mimic_decoder; +extern const FFCodec ff_mjpeg_encoder; +extern const FFCodec ff_mjpeg_decoder; +extern const FFCodec ff_mjpegb_decoder; +extern const FFCodec ff_mmvideo_decoder; +extern const FFCodec ff_mobiclip_decoder; +extern const FFCodec ff_motionpixels_decoder; +extern const FFCodec ff_mpeg1video_encoder; +extern const FFCodec ff_mpeg1video_decoder; +extern const FFCodec ff_mpeg2video_encoder; +extern const FFCodec ff_mpeg2video_decoder; +extern const FFCodec ff_mpeg4_encoder; +extern const FFCodec ff_mpeg4_decoder; +extern const FFCodec ff_mpeg4_crystalhd_decoder; +extern const FFCodec ff_mpeg4_v4l2m2m_decoder; +extern const FFCodec ff_mpeg4_mmal_decoder; +extern const FFCodec ff_mpegvideo_decoder; +extern const FFCodec ff_mpeg1_v4l2m2m_decoder; +extern const FFCodec ff_mpeg2_mmal_decoder; +extern const FFCodec ff_mpeg2_crystalhd_decoder; +extern const FFCodec ff_mpeg2_v4l2m2m_decoder; +extern const FFCodec ff_mpeg2_qsv_decoder; +extern const FFCodec ff_mpeg2_mediacodec_decoder; +extern const FFCodec ff_msa1_decoder; +extern const FFCodec ff_mscc_decoder; +extern const FFCodec ff_msmpeg4v1_decoder; +extern const FFCodec ff_msmpeg4v2_encoder; +extern const FFCodec ff_msmpeg4v2_decoder; +extern const FFCodec ff_msmpeg4v3_encoder; +extern const FFCodec ff_msmpeg4v3_decoder; +extern const FFCodec ff_msmpeg4_crystalhd_decoder; +extern const FFCodec ff_msp2_decoder; +extern const FFCodec ff_msrle_decoder; +extern const FFCodec ff_mss1_decoder; +extern const FFCodec ff_mss2_decoder; +extern const FFCodec ff_msvideo1_encoder; +extern const FFCodec ff_msvideo1_decoder; +extern const FFCodec ff_mszh_decoder; +extern const FFCodec ff_mts2_decoder; +extern const FFCodec ff_mv30_decoder; +extern const FFCodec ff_mvc1_decoder; +extern const FFCodec ff_mvc2_decoder; +extern const FFCodec ff_mvdv_decoder; +extern const FFCodec ff_mvha_decoder; +extern const FFCodec ff_mwsc_decoder; +extern const FFCodec ff_mxpeg_decoder; +extern const FFCodec ff_notchlc_decoder; +extern const FFCodec ff_nuv_decoder; +extern const FFCodec ff_paf_video_decoder; +extern const FFCodec ff_pam_encoder; +extern const FFCodec ff_pam_decoder; +extern const FFCodec ff_pbm_encoder; +extern const FFCodec ff_pbm_decoder; +extern const FFCodec ff_pcx_encoder; +extern const FFCodec ff_pcx_decoder; +extern const FFCodec ff_pfm_encoder; +extern const FFCodec ff_pfm_decoder; +extern const FFCodec ff_pgm_encoder; +extern const FFCodec ff_pgm_decoder; +extern const FFCodec ff_pgmyuv_encoder; +extern const FFCodec ff_pgmyuv_decoder; +extern const FFCodec ff_pgx_decoder; +extern const FFCodec ff_photocd_decoder; +extern const FFCodec ff_pictor_decoder; +extern const FFCodec ff_pixlet_decoder; +extern const FFCodec ff_png_encoder; +extern const FFCodec ff_png_decoder; +extern const FFCodec ff_ppm_encoder; +extern const FFCodec ff_ppm_decoder; +extern const FFCodec ff_prores_encoder; +extern const FFCodec ff_prores_decoder; +extern const FFCodec ff_prores_aw_encoder; +extern const FFCodec ff_prores_ks_encoder; +extern const FFCodec ff_prosumer_decoder; +extern const FFCodec ff_psd_decoder; +extern const FFCodec ff_ptx_decoder; +extern const FFCodec ff_qdraw_decoder; +extern const FFCodec ff_qoi_encoder; +extern const FFCodec ff_qoi_decoder; +extern const FFCodec ff_qpeg_decoder; +extern const FFCodec ff_qtrle_encoder; +extern const FFCodec ff_qtrle_decoder; +extern const FFCodec ff_r10k_encoder; +extern const FFCodec ff_r10k_decoder; +extern const FFCodec ff_r210_encoder; +extern const FFCodec ff_r210_decoder; +extern const FFCodec ff_rasc_decoder; +extern const FFCodec ff_rawvideo_encoder; +extern const FFCodec ff_rawvideo_decoder; +extern const FFCodec ff_rl2_decoder; +extern const FFCodec ff_roq_encoder; +extern const FFCodec ff_roq_decoder; +extern const FFCodec ff_rpza_encoder; +extern const FFCodec ff_rpza_decoder; +extern const FFCodec ff_rscc_decoder; +extern const FFCodec ff_rv10_encoder; +extern const FFCodec ff_rv10_decoder; +extern const FFCodec ff_rv20_encoder; +extern const FFCodec ff_rv20_decoder; +extern const FFCodec ff_rv30_decoder; +extern const FFCodec ff_rv40_decoder; +extern const FFCodec ff_s302m_encoder; +extern const FFCodec ff_s302m_decoder; +extern const FFCodec ff_sanm_decoder; +extern const FFCodec ff_scpr_decoder; +extern const FFCodec ff_screenpresso_decoder; +extern const FFCodec ff_sga_decoder; +extern const FFCodec ff_sgi_encoder; +extern const FFCodec ff_sgi_decoder; +extern const FFCodec ff_sgirle_decoder; +extern const FFCodec ff_sheervideo_decoder; +extern const FFCodec ff_simbiosis_imx_decoder; +extern const FFCodec ff_smacker_decoder; +extern const FFCodec ff_smc_encoder; +extern const FFCodec ff_smc_decoder; +extern const FFCodec ff_smvjpeg_decoder; +extern const FFCodec ff_snow_encoder; +extern const FFCodec ff_snow_decoder; +extern const FFCodec ff_sp5x_decoder; +extern const FFCodec ff_speedhq_decoder; +extern const FFCodec ff_speedhq_encoder; +extern const FFCodec ff_speex_decoder; +extern const FFCodec ff_srgc_decoder; +extern const FFCodec ff_sunrast_encoder; +extern const FFCodec ff_sunrast_decoder; +extern const FFCodec ff_svq1_encoder; +extern const FFCodec ff_svq1_decoder; +extern const FFCodec ff_svq3_decoder; +extern const FFCodec ff_targa_encoder; +extern const FFCodec ff_targa_decoder; +extern const FFCodec ff_targa_y216_decoder; +extern const FFCodec ff_tdsc_decoder; +extern const FFCodec ff_theora_decoder; +extern const FFCodec ff_thp_decoder; +extern const FFCodec ff_tiertexseqvideo_decoder; +extern const FFCodec ff_tiff_encoder; +extern const FFCodec ff_tiff_decoder; +extern const FFCodec ff_tmv_decoder; +extern const FFCodec ff_truemotion1_decoder; +extern const FFCodec ff_truemotion2_decoder; +extern const FFCodec ff_truemotion2rt_decoder; +extern const FFCodec ff_tscc_decoder; +extern const FFCodec ff_tscc2_decoder; +extern const FFCodec ff_txd_decoder; +extern const FFCodec ff_ulti_decoder; +extern const FFCodec ff_utvideo_encoder; +extern const FFCodec ff_utvideo_decoder; +extern const FFCodec ff_v210_encoder; +extern const FFCodec ff_v210_decoder; +extern const FFCodec ff_v210x_decoder; +extern const FFCodec ff_v308_encoder; +extern const FFCodec ff_v308_decoder; +extern const FFCodec ff_v408_encoder; +extern const FFCodec ff_v408_decoder; +extern const FFCodec ff_v410_encoder; +extern const FFCodec ff_v410_decoder; +extern const FFCodec ff_vb_decoder; +extern const FFCodec ff_vbn_encoder; +extern const FFCodec ff_vbn_decoder; +extern const FFCodec ff_vble_decoder; +extern const FFCodec ff_vc1_decoder; +extern const FFCodec ff_vc1_crystalhd_decoder; +extern const FFCodec ff_vc1image_decoder; +extern const FFCodec ff_vc1_mmal_decoder; +extern const FFCodec ff_vc1_qsv_decoder; +extern const FFCodec ff_vc1_v4l2m2m_decoder; +extern const FFCodec ff_vc2_encoder; +extern const FFCodec ff_vcr1_decoder; +extern const FFCodec ff_vmdvideo_decoder; +extern const FFCodec ff_vmnc_decoder; +extern const FFCodec ff_vp3_decoder; +extern const FFCodec ff_vp4_decoder; +extern const FFCodec ff_vp5_decoder; +extern const FFCodec ff_vp6_decoder; +extern const FFCodec ff_vp6a_decoder; +extern const FFCodec ff_vp6f_decoder; +extern const FFCodec ff_vp7_decoder; +extern const FFCodec ff_vp8_decoder; +extern const FFCodec ff_vp8_rkmpp_decoder; +extern const FFCodec ff_vp8_v4l2m2m_decoder; +extern const FFCodec ff_vp9_decoder; +extern const FFCodec ff_vp9_rkmpp_decoder; +extern const FFCodec ff_vp9_v4l2m2m_decoder; +extern const FFCodec ff_vqa_decoder; +extern const FFCodec ff_webp_decoder; +extern const FFCodec ff_wcmv_decoder; +extern const FFCodec ff_wrapped_avframe_encoder; +extern const FFCodec ff_wrapped_avframe_decoder; +extern const FFCodec ff_wmv1_encoder; +extern const FFCodec ff_wmv1_decoder; +extern const FFCodec ff_wmv2_encoder; +extern const FFCodec ff_wmv2_decoder; +extern const FFCodec ff_wmv3_decoder; +extern const FFCodec ff_wmv3_crystalhd_decoder; +extern const FFCodec ff_wmv3image_decoder; +extern const FFCodec ff_wnv1_decoder; +extern const FFCodec ff_xan_wc3_decoder; +extern const FFCodec ff_xan_wc4_decoder; +extern const FFCodec ff_xbm_encoder; +extern const FFCodec ff_xbm_decoder; +extern const FFCodec ff_xface_encoder; +extern const FFCodec ff_xface_decoder; +extern const FFCodec ff_xl_decoder; +extern const FFCodec ff_xpm_decoder; +extern const FFCodec ff_xwd_encoder; +extern const FFCodec ff_xwd_decoder; +extern const FFCodec ff_y41p_encoder; +extern const FFCodec ff_y41p_decoder; +extern const FFCodec ff_ylc_decoder; +extern const FFCodec ff_yop_decoder; +extern const FFCodec ff_yuv4_encoder; +extern const FFCodec ff_yuv4_decoder; +extern const FFCodec ff_zero12v_decoder; +extern const FFCodec ff_zerocodec_decoder; +extern const FFCodec ff_zlib_encoder; +extern const FFCodec ff_zlib_decoder; +extern const FFCodec ff_zmbv_encoder; +extern const FFCodec ff_zmbv_decoder; /* audio codecs */ -extern AVCodec ff_aac_encoder; -extern AVCodec ff_aac_decoder; -extern AVCodec ff_aac_fixed_decoder; -extern AVCodec ff_aac_latm_decoder; -extern AVCodec ff_ac3_encoder; -extern AVCodec ff_ac3_decoder; -extern AVCodec ff_ac3_fixed_encoder; -extern AVCodec ff_ac3_fixed_decoder; -extern AVCodec ff_acelp_kelvin_decoder; -extern AVCodec ff_alac_encoder; -extern AVCodec ff_alac_decoder; -extern AVCodec ff_als_decoder; -extern AVCodec ff_amrnb_decoder; -extern AVCodec ff_amrwb_decoder; -extern AVCodec ff_ape_decoder; -extern AVCodec ff_aptx_encoder; -extern AVCodec ff_aptx_decoder; -extern AVCodec ff_aptx_hd_encoder; -extern AVCodec ff_aptx_hd_decoder; -extern AVCodec ff_atrac1_decoder; -extern AVCodec ff_atrac3_decoder; -extern AVCodec ff_atrac3al_decoder; -extern AVCodec ff_atrac3p_decoder; -extern AVCodec ff_atrac3pal_decoder; -extern AVCodec ff_atrac9_decoder; -extern AVCodec ff_binkaudio_dct_decoder; -extern AVCodec ff_binkaudio_rdft_decoder; -extern AVCodec ff_bmv_audio_decoder; -extern AVCodec ff_cook_decoder; -extern AVCodec ff_dca_encoder; -extern AVCodec ff_dca_decoder; -extern AVCodec ff_dolby_e_decoder; -extern AVCodec ff_dsd_lsbf_decoder; -extern AVCodec ff_dsd_msbf_decoder; -extern AVCodec ff_dsd_lsbf_planar_decoder; -extern AVCodec ff_dsd_msbf_planar_decoder; -extern AVCodec ff_dsicinaudio_decoder; -extern AVCodec ff_dss_sp_decoder; -extern AVCodec ff_dst_decoder; -extern AVCodec ff_eac3_encoder; -extern AVCodec ff_eac3_decoder; -extern AVCodec ff_evrc_decoder; -extern AVCodec ff_fastaudio_decoder; -extern AVCodec ff_ffwavesynth_decoder; -extern AVCodec ff_flac_encoder; -extern AVCodec ff_flac_decoder; -extern AVCodec ff_g723_1_encoder; -extern AVCodec ff_g723_1_decoder; -extern AVCodec ff_g729_decoder; -extern AVCodec ff_gsm_decoder; -extern AVCodec ff_gsm_ms_decoder; -extern AVCodec ff_hca_decoder; -extern AVCodec ff_hcom_decoder; -extern AVCodec ff_iac_decoder; -extern AVCodec ff_ilbc_decoder; -extern AVCodec ff_imc_decoder; -extern AVCodec ff_interplay_acm_decoder; -extern AVCodec ff_mace3_decoder; -extern AVCodec ff_mace6_decoder; -extern AVCodec ff_metasound_decoder; -extern AVCodec ff_mlp_encoder; -extern AVCodec ff_mlp_decoder; -extern AVCodec ff_mp1_decoder; -extern AVCodec ff_mp1float_decoder; -extern AVCodec ff_mp2_encoder; -extern AVCodec ff_mp2_decoder; -extern AVCodec ff_mp2float_decoder; -extern AVCodec ff_mp2fixed_encoder; -extern AVCodec ff_mp3float_decoder; -extern AVCodec ff_mp3_decoder; -extern AVCodec ff_mp3adufloat_decoder; -extern AVCodec ff_mp3adu_decoder; -extern AVCodec ff_mp3on4float_decoder; -extern AVCodec ff_mp3on4_decoder; -extern AVCodec ff_mpc7_decoder; -extern AVCodec ff_mpc8_decoder; -extern AVCodec ff_nellymoser_encoder; -extern AVCodec ff_nellymoser_decoder; -extern AVCodec ff_on2avc_decoder; -extern AVCodec ff_opus_encoder; -extern AVCodec ff_opus_decoder; -extern AVCodec ff_paf_audio_decoder; -extern AVCodec ff_qcelp_decoder; -extern AVCodec ff_qdm2_decoder; -extern AVCodec ff_qdmc_decoder; -extern AVCodec ff_ra_144_encoder; -extern AVCodec ff_ra_144_decoder; -extern AVCodec ff_ra_288_decoder; -extern AVCodec ff_ralf_decoder; -extern AVCodec ff_sbc_encoder; -extern AVCodec ff_sbc_decoder; -extern AVCodec ff_shorten_decoder; -extern AVCodec ff_sipr_decoder; -extern AVCodec ff_siren_decoder; -extern AVCodec ff_smackaud_decoder; -extern AVCodec ff_sonic_encoder; -extern AVCodec ff_sonic_decoder; -extern AVCodec ff_sonic_ls_encoder; -extern AVCodec ff_tak_decoder; -extern AVCodec ff_truehd_encoder; -extern AVCodec ff_truehd_decoder; -extern AVCodec ff_truespeech_decoder; -extern AVCodec ff_tta_encoder; -extern AVCodec ff_tta_decoder; -extern AVCodec ff_twinvq_decoder; -extern AVCodec ff_vmdaudio_decoder; -extern AVCodec ff_vorbis_encoder; -extern AVCodec ff_vorbis_decoder; -extern AVCodec ff_wavpack_encoder; -extern AVCodec ff_wavpack_decoder; -extern AVCodec ff_wmalossless_decoder; -extern AVCodec ff_wmapro_decoder; -extern AVCodec ff_wmav1_encoder; -extern AVCodec ff_wmav1_decoder; -extern AVCodec ff_wmav2_encoder; -extern AVCodec ff_wmav2_decoder; -extern AVCodec ff_wmavoice_decoder; -extern AVCodec ff_ws_snd1_decoder; -extern AVCodec ff_xma1_decoder; -extern AVCodec ff_xma2_decoder; +extern const FFCodec ff_aac_encoder; +extern const FFCodec ff_aac_decoder; +extern const FFCodec ff_aac_fixed_decoder; +extern const FFCodec ff_aac_latm_decoder; +extern const FFCodec ff_ac3_encoder; +extern const FFCodec ff_ac3_decoder; +extern const FFCodec ff_ac3_fixed_encoder; +extern const FFCodec ff_ac3_fixed_decoder; +extern const FFCodec ff_acelp_kelvin_decoder; +extern const FFCodec ff_alac_encoder; +extern const FFCodec ff_alac_decoder; +extern const FFCodec ff_als_decoder; +extern const FFCodec ff_amrnb_decoder; +extern const FFCodec ff_amrwb_decoder; +extern const FFCodec ff_ape_decoder; +extern const FFCodec ff_aptx_encoder; +extern const FFCodec ff_aptx_decoder; +extern const FFCodec ff_aptx_hd_encoder; +extern const FFCodec ff_aptx_hd_decoder; +extern const FFCodec ff_atrac1_decoder; +extern const FFCodec ff_atrac3_decoder; +extern const FFCodec ff_atrac3al_decoder; +extern const FFCodec ff_atrac3p_decoder; +extern const FFCodec ff_atrac3pal_decoder; +extern const FFCodec ff_atrac9_decoder; +extern const FFCodec ff_binkaudio_dct_decoder; +extern const FFCodec ff_binkaudio_rdft_decoder; +extern const FFCodec ff_bmv_audio_decoder; +extern const FFCodec ff_cook_decoder; +extern const FFCodec ff_dca_encoder; +extern const FFCodec ff_dca_decoder; +extern const FFCodec ff_dfpwm_encoder; +extern const FFCodec ff_dfpwm_decoder; +extern const FFCodec ff_dolby_e_decoder; +extern const FFCodec ff_dsd_lsbf_decoder; +extern const FFCodec ff_dsd_msbf_decoder; +extern const FFCodec ff_dsd_lsbf_planar_decoder; +extern const FFCodec ff_dsd_msbf_planar_decoder; +extern const FFCodec ff_dsicinaudio_decoder; +extern const FFCodec ff_dss_sp_decoder; +extern const FFCodec ff_dst_decoder; +extern const FFCodec ff_eac3_encoder; +extern const FFCodec ff_eac3_decoder; +extern const FFCodec ff_evrc_decoder; +extern const FFCodec ff_fastaudio_decoder; +extern const FFCodec ff_ffwavesynth_decoder; +extern const FFCodec ff_flac_encoder; +extern const FFCodec ff_flac_decoder; +extern const FFCodec ff_g723_1_encoder; +extern const FFCodec ff_g723_1_decoder; +extern const FFCodec ff_g729_decoder; +extern const FFCodec ff_gsm_decoder; +extern const FFCodec ff_gsm_ms_decoder; +extern const FFCodec ff_hca_decoder; +extern const FFCodec ff_hcom_decoder; +extern const FFCodec ff_iac_decoder; +extern const FFCodec ff_ilbc_decoder; +extern const FFCodec ff_imc_decoder; +extern const FFCodec ff_interplay_acm_decoder; +extern const FFCodec ff_mace3_decoder; +extern const FFCodec ff_mace6_decoder; +extern const FFCodec ff_metasound_decoder; +extern const FFCodec ff_mlp_encoder; +extern const FFCodec ff_mlp_decoder; +extern const FFCodec ff_mp1_decoder; +extern const FFCodec ff_mp1float_decoder; +extern const FFCodec ff_mp2_encoder; +extern const FFCodec ff_mp2_decoder; +extern const FFCodec ff_mp2float_decoder; +extern const FFCodec ff_mp2fixed_encoder; +extern const FFCodec ff_mp3float_decoder; +extern const FFCodec ff_mp3_decoder; +extern const FFCodec ff_mp3adufloat_decoder; +extern const FFCodec ff_mp3adu_decoder; +extern const FFCodec ff_mp3on4float_decoder; +extern const FFCodec ff_mp3on4_decoder; +extern const FFCodec ff_mpc7_decoder; +extern const FFCodec ff_mpc8_decoder; +extern const FFCodec ff_msnsiren_decoder; +extern const FFCodec ff_nellymoser_encoder; +extern const FFCodec ff_nellymoser_decoder; +extern const FFCodec ff_on2avc_decoder; +extern const FFCodec ff_opus_encoder; +extern const FFCodec ff_opus_decoder; +extern const FFCodec ff_paf_audio_decoder; +extern const FFCodec ff_qcelp_decoder; +extern const FFCodec ff_qdm2_decoder; +extern const FFCodec ff_qdmc_decoder; +extern const FFCodec ff_ra_144_encoder; +extern const FFCodec ff_ra_144_decoder; +extern const FFCodec ff_ra_288_decoder; +extern const FFCodec ff_ralf_decoder; +extern const FFCodec ff_sbc_encoder; +extern const FFCodec ff_sbc_decoder; +extern const FFCodec ff_shorten_decoder; +extern const FFCodec ff_sipr_decoder; +extern const FFCodec ff_siren_decoder; +extern const FFCodec ff_smackaud_decoder; +extern const FFCodec ff_sonic_encoder; +extern const FFCodec ff_sonic_decoder; +extern const FFCodec ff_sonic_ls_encoder; +extern const FFCodec ff_tak_decoder; +extern const FFCodec ff_truehd_encoder; +extern const FFCodec ff_truehd_decoder; +extern const FFCodec ff_truespeech_decoder; +extern const FFCodec ff_tta_encoder; +extern const FFCodec ff_tta_decoder; +extern const FFCodec ff_twinvq_decoder; +extern const FFCodec ff_vmdaudio_decoder; +extern const FFCodec ff_vorbis_encoder; +extern const FFCodec ff_vorbis_decoder; +extern const FFCodec ff_wavpack_encoder; +extern const FFCodec ff_wavpack_decoder; +extern const FFCodec ff_wmalossless_decoder; +extern const FFCodec ff_wmapro_decoder; +extern const FFCodec ff_wmav1_encoder; +extern const FFCodec ff_wmav1_decoder; +extern const FFCodec ff_wmav2_encoder; +extern const FFCodec ff_wmav2_decoder; +extern const FFCodec ff_wmavoice_decoder; +extern const FFCodec ff_ws_snd1_decoder; +extern const FFCodec ff_xma1_decoder; +extern const FFCodec ff_xma2_decoder; /* PCM codecs */ -extern AVCodec ff_pcm_alaw_encoder; -extern AVCodec ff_pcm_alaw_decoder; -extern AVCodec ff_pcm_bluray_decoder; -extern AVCodec ff_pcm_dvd_encoder; -extern AVCodec ff_pcm_dvd_decoder; -extern AVCodec ff_pcm_f16le_decoder; -extern AVCodec ff_pcm_f24le_decoder; -extern AVCodec ff_pcm_f32be_encoder; -extern AVCodec ff_pcm_f32be_decoder; -extern AVCodec ff_pcm_f32le_encoder; -extern AVCodec ff_pcm_f32le_decoder; -extern AVCodec ff_pcm_f64be_encoder; -extern AVCodec ff_pcm_f64be_decoder; -extern AVCodec ff_pcm_f64le_encoder; -extern AVCodec ff_pcm_f64le_decoder; -extern AVCodec ff_pcm_lxf_decoder; -extern AVCodec ff_pcm_mulaw_encoder; -extern AVCodec ff_pcm_mulaw_decoder; -extern AVCodec ff_pcm_s8_encoder; -extern AVCodec ff_pcm_s8_decoder; -extern AVCodec ff_pcm_s8_planar_encoder; -extern AVCodec ff_pcm_s8_planar_decoder; -extern AVCodec ff_pcm_s16be_encoder; -extern AVCodec ff_pcm_s16be_decoder; -extern AVCodec ff_pcm_s16be_planar_encoder; -extern AVCodec ff_pcm_s16be_planar_decoder; -extern AVCodec ff_pcm_s16le_encoder; -extern AVCodec ff_pcm_s16le_decoder; -extern AVCodec ff_pcm_s16le_planar_encoder; -extern AVCodec ff_pcm_s16le_planar_decoder; -extern AVCodec ff_pcm_s24be_encoder; -extern AVCodec ff_pcm_s24be_decoder; -extern AVCodec ff_pcm_s24daud_encoder; -extern AVCodec ff_pcm_s24daud_decoder; -extern AVCodec ff_pcm_s24le_encoder; -extern AVCodec ff_pcm_s24le_decoder; -extern AVCodec ff_pcm_s24le_planar_encoder; -extern AVCodec ff_pcm_s24le_planar_decoder; -extern AVCodec ff_pcm_s32be_encoder; -extern AVCodec ff_pcm_s32be_decoder; -extern AVCodec ff_pcm_s32le_encoder; -extern AVCodec ff_pcm_s32le_decoder; -extern AVCodec ff_pcm_s32le_planar_encoder; -extern AVCodec ff_pcm_s32le_planar_decoder; -extern AVCodec ff_pcm_s64be_encoder; -extern AVCodec ff_pcm_s64be_decoder; -extern AVCodec ff_pcm_s64le_encoder; -extern AVCodec ff_pcm_s64le_decoder; -extern AVCodec ff_pcm_sga_decoder; -extern AVCodec ff_pcm_u8_encoder; -extern AVCodec ff_pcm_u8_decoder; -extern AVCodec ff_pcm_u16be_encoder; -extern AVCodec ff_pcm_u16be_decoder; -extern AVCodec ff_pcm_u16le_encoder; -extern AVCodec ff_pcm_u16le_decoder; -extern AVCodec ff_pcm_u24be_encoder; -extern AVCodec ff_pcm_u24be_decoder; -extern AVCodec ff_pcm_u24le_encoder; -extern AVCodec ff_pcm_u24le_decoder; -extern AVCodec ff_pcm_u32be_encoder; -extern AVCodec ff_pcm_u32be_decoder; -extern AVCodec ff_pcm_u32le_encoder; -extern AVCodec ff_pcm_u32le_decoder; -extern AVCodec ff_pcm_vidc_encoder; -extern AVCodec ff_pcm_vidc_decoder; +extern const FFCodec ff_pcm_alaw_encoder; +extern const FFCodec ff_pcm_alaw_decoder; +extern const FFCodec ff_pcm_bluray_encoder; +extern const FFCodec ff_pcm_bluray_decoder; +extern const FFCodec ff_pcm_dvd_encoder; +extern const FFCodec ff_pcm_dvd_decoder; +extern const FFCodec ff_pcm_f16le_decoder; +extern const FFCodec ff_pcm_f24le_decoder; +extern const FFCodec ff_pcm_f32be_encoder; +extern const FFCodec ff_pcm_f32be_decoder; +extern const FFCodec ff_pcm_f32le_encoder; +extern const FFCodec ff_pcm_f32le_decoder; +extern const FFCodec ff_pcm_f64be_encoder; +extern const FFCodec ff_pcm_f64be_decoder; +extern const FFCodec ff_pcm_f64le_encoder; +extern const FFCodec ff_pcm_f64le_decoder; +extern const FFCodec ff_pcm_lxf_decoder; +extern const FFCodec ff_pcm_mulaw_encoder; +extern const FFCodec ff_pcm_mulaw_decoder; +extern const FFCodec ff_pcm_s8_encoder; +extern const FFCodec ff_pcm_s8_decoder; +extern const FFCodec ff_pcm_s8_planar_encoder; +extern const FFCodec ff_pcm_s8_planar_decoder; +extern const FFCodec ff_pcm_s16be_encoder; +extern const FFCodec ff_pcm_s16be_decoder; +extern const FFCodec ff_pcm_s16be_planar_encoder; +extern const FFCodec ff_pcm_s16be_planar_decoder; +extern const FFCodec ff_pcm_s16le_encoder; +extern const FFCodec ff_pcm_s16le_decoder; +extern const FFCodec ff_pcm_s16le_planar_encoder; +extern const FFCodec ff_pcm_s16le_planar_decoder; +extern const FFCodec ff_pcm_s24be_encoder; +extern const FFCodec ff_pcm_s24be_decoder; +extern const FFCodec ff_pcm_s24daud_encoder; +extern const FFCodec ff_pcm_s24daud_decoder; +extern const FFCodec ff_pcm_s24le_encoder; +extern const FFCodec ff_pcm_s24le_decoder; +extern const FFCodec ff_pcm_s24le_planar_encoder; +extern const FFCodec ff_pcm_s24le_planar_decoder; +extern const FFCodec ff_pcm_s32be_encoder; +extern const FFCodec ff_pcm_s32be_decoder; +extern const FFCodec ff_pcm_s32le_encoder; +extern const FFCodec ff_pcm_s32le_decoder; +extern const FFCodec ff_pcm_s32le_planar_encoder; +extern const FFCodec ff_pcm_s32le_planar_decoder; +extern const FFCodec ff_pcm_s64be_encoder; +extern const FFCodec ff_pcm_s64be_decoder; +extern const FFCodec ff_pcm_s64le_encoder; +extern const FFCodec ff_pcm_s64le_decoder; +extern const FFCodec ff_pcm_sga_decoder; +extern const FFCodec ff_pcm_u8_encoder; +extern const FFCodec ff_pcm_u8_decoder; +extern const FFCodec ff_pcm_u16be_encoder; +extern const FFCodec ff_pcm_u16be_decoder; +extern const FFCodec ff_pcm_u16le_encoder; +extern const FFCodec ff_pcm_u16le_decoder; +extern const FFCodec ff_pcm_u24be_encoder; +extern const FFCodec ff_pcm_u24be_decoder; +extern const FFCodec ff_pcm_u24le_encoder; +extern const FFCodec ff_pcm_u24le_decoder; +extern const FFCodec ff_pcm_u32be_encoder; +extern const FFCodec ff_pcm_u32be_decoder; +extern const FFCodec ff_pcm_u32le_encoder; +extern const FFCodec ff_pcm_u32le_decoder; +extern const FFCodec ff_pcm_vidc_encoder; +extern const FFCodec ff_pcm_vidc_decoder; /* DPCM codecs */ -extern AVCodec ff_derf_dpcm_decoder; -extern AVCodec ff_gremlin_dpcm_decoder; -extern AVCodec ff_interplay_dpcm_decoder; -extern AVCodec ff_roq_dpcm_encoder; -extern AVCodec ff_roq_dpcm_decoder; -extern AVCodec ff_sdx2_dpcm_decoder; -extern AVCodec ff_sol_dpcm_decoder; -extern AVCodec ff_xan_dpcm_decoder; +extern const FFCodec ff_derf_dpcm_decoder; +extern const FFCodec ff_gremlin_dpcm_decoder; +extern const FFCodec ff_interplay_dpcm_decoder; +extern const FFCodec ff_roq_dpcm_encoder; +extern const FFCodec ff_roq_dpcm_decoder; +extern const FFCodec ff_sdx2_dpcm_decoder; +extern const FFCodec ff_sol_dpcm_decoder; +extern const FFCodec ff_xan_dpcm_decoder; /* ADPCM codecs */ -extern AVCodec ff_adpcm_4xm_decoder; -extern AVCodec ff_adpcm_adx_encoder; -extern AVCodec ff_adpcm_adx_decoder; -extern AVCodec ff_adpcm_afc_decoder; -extern AVCodec ff_adpcm_agm_decoder; -extern AVCodec ff_adpcm_aica_decoder; -extern AVCodec ff_adpcm_argo_decoder; -extern AVCodec ff_adpcm_argo_encoder; -extern AVCodec ff_adpcm_ct_decoder; -extern AVCodec ff_adpcm_dtk_decoder; -extern AVCodec ff_adpcm_ea_decoder; -extern AVCodec ff_adpcm_ea_maxis_xa_decoder; -extern AVCodec ff_adpcm_ea_r1_decoder; -extern AVCodec ff_adpcm_ea_r2_decoder; -extern AVCodec ff_adpcm_ea_r3_decoder; -extern AVCodec ff_adpcm_ea_xas_decoder; -extern AVCodec ff_adpcm_g722_encoder; -extern AVCodec ff_adpcm_g722_decoder; -extern AVCodec ff_adpcm_g726_encoder; -extern AVCodec ff_adpcm_g726_decoder; -extern AVCodec ff_adpcm_g726le_encoder; -extern AVCodec ff_adpcm_g726le_decoder; -extern AVCodec ff_adpcm_ima_amv_decoder; -extern AVCodec ff_adpcm_ima_amv_encoder; -extern AVCodec ff_adpcm_ima_alp_decoder; -extern AVCodec ff_adpcm_ima_alp_encoder; -extern AVCodec ff_adpcm_ima_apc_decoder; -extern AVCodec ff_adpcm_ima_apm_decoder; -extern AVCodec ff_adpcm_ima_apm_encoder; -extern AVCodec ff_adpcm_ima_cunning_decoder; -extern AVCodec ff_adpcm_ima_dat4_decoder; -extern AVCodec ff_adpcm_ima_dk3_decoder; -extern AVCodec ff_adpcm_ima_dk4_decoder; -extern AVCodec ff_adpcm_ima_ea_eacs_decoder; -extern AVCodec ff_adpcm_ima_ea_sead_decoder; -extern AVCodec ff_adpcm_ima_iss_decoder; -extern AVCodec ff_adpcm_ima_moflex_decoder; -extern AVCodec ff_adpcm_ima_mtf_decoder; -extern AVCodec ff_adpcm_ima_oki_decoder; -extern AVCodec ff_adpcm_ima_qt_encoder; -extern AVCodec ff_adpcm_ima_qt_decoder; -extern AVCodec ff_adpcm_ima_rad_decoder; -extern AVCodec ff_adpcm_ima_ssi_decoder; -extern AVCodec ff_adpcm_ima_ssi_encoder; -extern AVCodec ff_adpcm_ima_smjpeg_decoder; -extern AVCodec ff_adpcm_ima_wav_encoder; -extern AVCodec ff_adpcm_ima_wav_decoder; -extern AVCodec ff_adpcm_ima_ws_decoder; -extern AVCodec ff_adpcm_ms_encoder; -extern AVCodec ff_adpcm_ms_decoder; -extern AVCodec ff_adpcm_mtaf_decoder; -extern AVCodec ff_adpcm_psx_decoder; -extern AVCodec ff_adpcm_sbpro_2_decoder; -extern AVCodec ff_adpcm_sbpro_3_decoder; -extern AVCodec ff_adpcm_sbpro_4_decoder; -extern AVCodec ff_adpcm_swf_encoder; -extern AVCodec ff_adpcm_swf_decoder; -extern AVCodec ff_adpcm_thp_decoder; -extern AVCodec ff_adpcm_thp_le_decoder; -extern AVCodec ff_adpcm_vima_decoder; -extern AVCodec ff_adpcm_xa_decoder; -extern AVCodec ff_adpcm_yamaha_encoder; -extern AVCodec ff_adpcm_yamaha_decoder; -extern AVCodec ff_adpcm_zork_decoder; +extern const FFCodec ff_adpcm_4xm_decoder; +extern const FFCodec ff_adpcm_adx_encoder; +extern const FFCodec ff_adpcm_adx_decoder; +extern const FFCodec ff_adpcm_afc_decoder; +extern const FFCodec ff_adpcm_agm_decoder; +extern const FFCodec ff_adpcm_aica_decoder; +extern const FFCodec ff_adpcm_argo_decoder; +extern const FFCodec ff_adpcm_argo_encoder; +extern const FFCodec ff_adpcm_ct_decoder; +extern const FFCodec ff_adpcm_dtk_decoder; +extern const FFCodec ff_adpcm_ea_decoder; +extern const FFCodec ff_adpcm_ea_maxis_xa_decoder; +extern const FFCodec ff_adpcm_ea_r1_decoder; +extern const FFCodec ff_adpcm_ea_r2_decoder; +extern const FFCodec ff_adpcm_ea_r3_decoder; +extern const FFCodec ff_adpcm_ea_xas_decoder; +extern const FFCodec ff_adpcm_g722_encoder; +extern const FFCodec ff_adpcm_g722_decoder; +extern const FFCodec ff_adpcm_g726_encoder; +extern const FFCodec ff_adpcm_g726_decoder; +extern const FFCodec ff_adpcm_g726le_encoder; +extern const FFCodec ff_adpcm_g726le_decoder; +extern const FFCodec ff_adpcm_ima_acorn_decoder; +extern const FFCodec ff_adpcm_ima_amv_decoder; +extern const FFCodec ff_adpcm_ima_amv_encoder; +extern const FFCodec ff_adpcm_ima_alp_decoder; +extern const FFCodec ff_adpcm_ima_alp_encoder; +extern const FFCodec ff_adpcm_ima_apc_decoder; +extern const FFCodec ff_adpcm_ima_apm_decoder; +extern const FFCodec ff_adpcm_ima_apm_encoder; +extern const FFCodec ff_adpcm_ima_cunning_decoder; +extern const FFCodec ff_adpcm_ima_dat4_decoder; +extern const FFCodec ff_adpcm_ima_dk3_decoder; +extern const FFCodec ff_adpcm_ima_dk4_decoder; +extern const FFCodec ff_adpcm_ima_ea_eacs_decoder; +extern const FFCodec ff_adpcm_ima_ea_sead_decoder; +extern const FFCodec ff_adpcm_ima_iss_decoder; +extern const FFCodec ff_adpcm_ima_moflex_decoder; +extern const FFCodec ff_adpcm_ima_mtf_decoder; +extern const FFCodec ff_adpcm_ima_oki_decoder; +extern const FFCodec ff_adpcm_ima_qt_encoder; +extern const FFCodec ff_adpcm_ima_qt_decoder; +extern const FFCodec ff_adpcm_ima_rad_decoder; +extern const FFCodec ff_adpcm_ima_ssi_decoder; +extern const FFCodec ff_adpcm_ima_ssi_encoder; +extern const FFCodec ff_adpcm_ima_smjpeg_decoder; +extern const FFCodec ff_adpcm_ima_wav_encoder; +extern const FFCodec ff_adpcm_ima_wav_decoder; +extern const FFCodec ff_adpcm_ima_ws_encoder; +extern const FFCodec ff_adpcm_ima_ws_decoder; +extern const FFCodec ff_adpcm_ms_encoder; +extern const FFCodec ff_adpcm_ms_decoder; +extern const FFCodec ff_adpcm_mtaf_decoder; +extern const FFCodec ff_adpcm_psx_decoder; +extern const FFCodec ff_adpcm_sbpro_2_decoder; +extern const FFCodec ff_adpcm_sbpro_3_decoder; +extern const FFCodec ff_adpcm_sbpro_4_decoder; +extern const FFCodec ff_adpcm_swf_encoder; +extern const FFCodec ff_adpcm_swf_decoder; +extern const FFCodec ff_adpcm_thp_decoder; +extern const FFCodec ff_adpcm_thp_le_decoder; +extern const FFCodec ff_adpcm_vima_decoder; +extern const FFCodec ff_adpcm_xa_decoder; +extern const FFCodec ff_adpcm_yamaha_encoder; +extern const FFCodec ff_adpcm_yamaha_decoder; +extern const FFCodec ff_adpcm_zork_decoder; /* subtitles */ -extern AVCodec ff_ssa_encoder; -extern AVCodec ff_ssa_decoder; -extern AVCodec ff_ass_encoder; -extern AVCodec ff_ass_decoder; -extern AVCodec ff_ccaption_decoder; -extern AVCodec ff_dvbsub_encoder; -extern AVCodec ff_dvbsub_decoder; -extern AVCodec ff_dvdsub_encoder; -extern AVCodec ff_dvdsub_decoder; -extern AVCodec ff_jacosub_decoder; -extern AVCodec ff_microdvd_decoder; -extern AVCodec ff_movtext_encoder; -extern AVCodec ff_movtext_decoder; -extern AVCodec ff_mpl2_decoder; -extern AVCodec ff_pgssub_decoder; -extern AVCodec ff_pjs_decoder; -extern AVCodec ff_realtext_decoder; -extern AVCodec ff_sami_decoder; -extern AVCodec ff_srt_encoder; -extern AVCodec ff_srt_decoder; -extern AVCodec ff_stl_decoder; -extern AVCodec ff_subrip_encoder; -extern AVCodec ff_subrip_decoder; -extern AVCodec ff_subviewer_decoder; -extern AVCodec ff_subviewer1_decoder; -extern AVCodec ff_text_encoder; -extern AVCodec ff_text_decoder; -extern AVCodec ff_ttml_encoder; -extern AVCodec ff_vplayer_decoder; -extern AVCodec ff_webvtt_encoder; -extern AVCodec ff_webvtt_decoder; -extern AVCodec ff_xsub_encoder; -extern AVCodec ff_xsub_decoder; +extern const FFCodec ff_ssa_encoder; +extern const FFCodec ff_ssa_decoder; +extern const FFCodec ff_ass_encoder; +extern const FFCodec ff_ass_decoder; +extern const FFCodec ff_ccaption_decoder; +extern const FFCodec ff_dvbsub_encoder; +extern const FFCodec ff_dvbsub_decoder; +extern const FFCodec ff_dvdsub_encoder; +extern const FFCodec ff_dvdsub_decoder; +extern const FFCodec ff_jacosub_decoder; +extern const FFCodec ff_microdvd_decoder; +extern const FFCodec ff_movtext_encoder; +extern const FFCodec ff_movtext_decoder; +extern const FFCodec ff_mpl2_decoder; +extern const FFCodec ff_pgssub_decoder; +extern const FFCodec ff_pjs_decoder; +extern const FFCodec ff_realtext_decoder; +extern const FFCodec ff_sami_decoder; +extern const FFCodec ff_srt_encoder; +extern const FFCodec ff_srt_decoder; +extern const FFCodec ff_stl_decoder; +extern const FFCodec ff_subrip_encoder; +extern const FFCodec ff_subrip_decoder; +extern const FFCodec ff_subviewer_decoder; +extern const FFCodec ff_subviewer1_decoder; +extern const FFCodec ff_text_encoder; +extern const FFCodec ff_text_decoder; +extern const FFCodec ff_ttml_encoder; +extern const FFCodec ff_vplayer_decoder; +extern const FFCodec ff_webvtt_encoder; +extern const FFCodec ff_webvtt_decoder; +extern const FFCodec ff_xsub_encoder; +extern const FFCodec ff_xsub_decoder; /* external libraries */ -extern AVCodec ff_aac_at_encoder; -extern AVCodec ff_aac_at_decoder; -extern AVCodec ff_ac3_at_decoder; -extern AVCodec ff_adpcm_ima_qt_at_decoder; -extern AVCodec ff_alac_at_encoder; -extern AVCodec ff_alac_at_decoder; -extern AVCodec ff_amr_nb_at_decoder; -extern AVCodec ff_eac3_at_decoder; -extern AVCodec ff_gsm_ms_at_decoder; -extern AVCodec ff_ilbc_at_encoder; -extern AVCodec ff_ilbc_at_decoder; -extern AVCodec ff_mp1_at_decoder; -extern AVCodec ff_mp2_at_decoder; -extern AVCodec ff_mp3_at_decoder; -extern AVCodec ff_pcm_alaw_at_encoder; -extern AVCodec ff_pcm_alaw_at_decoder; -extern AVCodec ff_pcm_mulaw_at_encoder; -extern AVCodec ff_pcm_mulaw_at_decoder; -extern AVCodec ff_qdmc_at_decoder; -extern AVCodec ff_qdm2_at_decoder; -extern AVCodec ff_libaom_av1_encoder; -extern AVCodec ff_libaribb24_decoder; -extern AVCodec ff_libcelt_decoder; -extern AVCodec ff_libcodec2_encoder; -extern AVCodec ff_libcodec2_decoder; -extern AVCodec ff_libdav1d_decoder; -extern AVCodec ff_libdavs2_decoder; -extern AVCodec ff_libfdk_aac_encoder; -extern AVCodec ff_libfdk_aac_decoder; -extern AVCodec ff_libgsm_encoder; -extern AVCodec ff_libgsm_decoder; -extern AVCodec ff_libgsm_ms_encoder; -extern AVCodec ff_libgsm_ms_decoder; -extern AVCodec ff_libilbc_encoder; -extern AVCodec ff_libilbc_decoder; -extern AVCodec ff_libmp3lame_encoder; -extern AVCodec ff_libopencore_amrnb_encoder; -extern AVCodec ff_libopencore_amrnb_decoder; -extern AVCodec ff_libopencore_amrwb_decoder; -extern AVCodec ff_libopenjpeg_encoder; -extern AVCodec ff_libopenjpeg_decoder; -extern AVCodec ff_libopus_encoder; -extern AVCodec ff_libopus_decoder; -extern AVCodec ff_librav1e_encoder; -extern AVCodec ff_librsvg_decoder; -extern AVCodec ff_libshine_encoder; -extern AVCodec ff_libspeex_encoder; -extern AVCodec ff_libspeex_decoder; -extern AVCodec ff_libsvtav1_encoder; -extern AVCodec ff_libtheora_encoder; -extern AVCodec ff_libtwolame_encoder; -extern AVCodec ff_libuavs3d_decoder; -extern AVCodec ff_libvo_amrwbenc_encoder; -extern AVCodec ff_libvorbis_encoder; -extern AVCodec ff_libvorbis_decoder; -extern AVCodec ff_libvpx_vp8_encoder; -extern AVCodec ff_libvpx_vp8_decoder; -extern AVCodec ff_libvpx_vp9_encoder; -extern AVCodec ff_libvpx_vp9_decoder; +extern const FFCodec ff_aac_at_encoder; +extern const FFCodec ff_aac_at_decoder; +extern const FFCodec ff_ac3_at_decoder; +extern const FFCodec ff_adpcm_ima_qt_at_decoder; +extern const FFCodec ff_alac_at_encoder; +extern const FFCodec ff_alac_at_decoder; +extern const FFCodec ff_amr_nb_at_decoder; +extern const FFCodec ff_eac3_at_decoder; +extern const FFCodec ff_gsm_ms_at_decoder; +extern const FFCodec ff_ilbc_at_encoder; +extern const FFCodec ff_ilbc_at_decoder; +extern const FFCodec ff_mp1_at_decoder; +extern const FFCodec ff_mp2_at_decoder; +extern const FFCodec ff_mp3_at_decoder; +extern const FFCodec ff_pcm_alaw_at_encoder; +extern const FFCodec ff_pcm_alaw_at_decoder; +extern const FFCodec ff_pcm_mulaw_at_encoder; +extern const FFCodec ff_pcm_mulaw_at_decoder; +extern const FFCodec ff_qdmc_at_decoder; +extern const FFCodec ff_qdm2_at_decoder; +extern FFCodec ff_libaom_av1_encoder; +extern const FFCodec ff_libaribb24_decoder; +extern const FFCodec ff_libcelt_decoder; +extern const FFCodec ff_libcodec2_encoder; +extern const FFCodec ff_libcodec2_decoder; +extern const FFCodec ff_libdav1d_decoder; +extern const FFCodec ff_libdavs2_decoder; +extern const FFCodec ff_libfdk_aac_encoder; +extern const FFCodec ff_libfdk_aac_decoder; +extern const FFCodec ff_libgsm_encoder; +extern const FFCodec ff_libgsm_decoder; +extern const FFCodec ff_libgsm_ms_encoder; +extern const FFCodec ff_libgsm_ms_decoder; +extern const FFCodec ff_libilbc_encoder; +extern const FFCodec ff_libilbc_decoder; +extern const FFCodec ff_libjxl_decoder; +extern const FFCodec ff_libjxl_encoder; +extern const FFCodec ff_libmp3lame_encoder; +extern const FFCodec ff_libopencore_amrnb_encoder; +extern const FFCodec ff_libopencore_amrnb_decoder; +extern const FFCodec ff_libopencore_amrwb_decoder; +extern const FFCodec ff_libopenjpeg_encoder; +extern const FFCodec ff_libopenjpeg_decoder; +extern const FFCodec ff_libopus_encoder; +extern const FFCodec ff_libopus_decoder; +extern const FFCodec ff_librav1e_encoder; +extern const FFCodec ff_librsvg_decoder; +extern const FFCodec ff_libshine_encoder; +extern const FFCodec ff_libspeex_encoder; +extern const FFCodec ff_libspeex_decoder; +extern const FFCodec ff_libsvtav1_encoder; +extern const FFCodec ff_libtheora_encoder; +extern const FFCodec ff_libtwolame_encoder; +extern const FFCodec ff_libuavs3d_decoder; +extern const FFCodec ff_libvo_amrwbenc_encoder; +extern const FFCodec ff_libvorbis_encoder; +extern const FFCodec ff_libvorbis_decoder; +extern const FFCodec ff_libvpx_vp8_encoder; +extern const FFCodec ff_libvpx_vp8_decoder; +extern FFCodec ff_libvpx_vp9_encoder; +extern FFCodec ff_libvpx_vp9_decoder; /* preferred over libwebp */ -extern AVCodec ff_libwebp_anim_encoder; -extern AVCodec ff_libwebp_encoder; -extern AVCodec ff_libx262_encoder; -extern AVCodec ff_libx264_encoder; -extern AVCodec ff_libx264rgb_encoder; -extern AVCodec ff_libx265_encoder; -extern AVCodec ff_libxavs_encoder; -extern AVCodec ff_libxavs2_encoder; -extern AVCodec ff_libxvid_encoder; -extern AVCodec ff_libzvbi_teletext_decoder; +extern const FFCodec ff_libwebp_anim_encoder; +extern const FFCodec ff_libwebp_encoder; +extern const FFCodec ff_libx262_encoder; +#if CONFIG_LIBX264_ENCODER +#include +#if X264_BUILD < 153 +#define LIBX264_CONST +#else +#define LIBX264_CONST const +#endif +extern LIBX264_CONST FFCodec ff_libx264_encoder; +#endif +extern const FFCodec ff_libx264rgb_encoder; +extern FFCodec ff_libx265_encoder; +extern const FFCodec ff_libxavs_encoder; +extern const FFCodec ff_libxavs2_encoder; +extern const FFCodec ff_libxvid_encoder; +extern const FFCodec ff_libzvbi_teletext_decoder; /* text */ -extern AVCodec ff_bintext_decoder; -extern AVCodec ff_xbin_decoder; -extern AVCodec ff_idf_decoder; +extern const FFCodec ff_bintext_decoder; +extern const FFCodec ff_xbin_decoder; +extern const FFCodec ff_idf_decoder; /* external libraries, that shouldn't be used by default if one of the * above is available */ -extern AVCodec ff_aac_mf_encoder; -extern AVCodec ff_ac3_mf_encoder; -extern AVCodec ff_h263_v4l2m2m_encoder; -extern AVCodec ff_libaom_av1_decoder; +extern const FFCodec ff_aac_mf_encoder; +extern const FFCodec ff_ac3_mf_encoder; +extern const FFCodec ff_h263_v4l2m2m_encoder; +extern const FFCodec ff_libaom_av1_decoder; /* hwaccel hooks only, so prefer external decoders */ -extern AVCodec ff_av1_decoder; -extern AVCodec ff_av1_cuvid_decoder; -extern AVCodec ff_av1_qsv_decoder; -extern AVCodec ff_libopenh264_encoder; -extern AVCodec ff_libopenh264_decoder; -extern AVCodec ff_h264_amf_encoder; -extern AVCodec ff_h264_cuvid_decoder; -extern AVCodec ff_h264_mf_encoder; -extern AVCodec ff_h264_nvenc_encoder; -extern AVCodec ff_h264_omx_encoder; -extern AVCodec ff_h264_qsv_encoder; -extern AVCodec ff_h264_v4l2m2m_encoder; -extern AVCodec ff_h264_vaapi_encoder; -extern AVCodec ff_h264_videotoolbox_encoder; -#if FF_API_NVENC_OLD_NAME -extern AVCodec ff_nvenc_encoder; -extern AVCodec ff_nvenc_h264_encoder; -extern AVCodec ff_nvenc_hevc_encoder; -#endif -extern AVCodec ff_hevc_amf_encoder; -extern AVCodec ff_hevc_cuvid_decoder; -extern AVCodec ff_hevc_mediacodec_decoder; -extern AVCodec ff_hevc_mf_encoder; -extern AVCodec ff_hevc_nvenc_encoder; -extern AVCodec ff_hevc_qsv_encoder; -extern AVCodec ff_hevc_v4l2m2m_encoder; -extern AVCodec ff_hevc_vaapi_encoder; -extern AVCodec ff_hevc_videotoolbox_encoder; -extern AVCodec ff_libkvazaar_encoder; -extern AVCodec ff_mjpeg_cuvid_decoder; -extern AVCodec ff_mjpeg_qsv_encoder; -extern AVCodec ff_mjpeg_qsv_decoder; -extern AVCodec ff_mjpeg_vaapi_encoder; -extern AVCodec ff_mp3_mf_encoder; -extern AVCodec ff_mpeg1_cuvid_decoder; -extern AVCodec ff_mpeg2_cuvid_decoder; -extern AVCodec ff_mpeg2_qsv_encoder; -extern AVCodec ff_mpeg2_vaapi_encoder; -extern AVCodec ff_mpeg4_cuvid_decoder; -extern AVCodec ff_mpeg4_mediacodec_decoder; -extern AVCodec ff_mpeg4_omx_encoder; -extern AVCodec ff_mpeg4_v4l2m2m_encoder; -extern AVCodec ff_vc1_cuvid_decoder; -extern AVCodec ff_vp8_cuvid_decoder; -extern AVCodec ff_vp8_mediacodec_decoder; -extern AVCodec ff_vp8_qsv_decoder; -extern AVCodec ff_vp8_v4l2m2m_encoder; -extern AVCodec ff_vp8_vaapi_encoder; -extern AVCodec ff_vp9_cuvid_decoder; -extern AVCodec ff_vp9_mediacodec_decoder; -extern AVCodec ff_vp9_qsv_decoder; -extern AVCodec ff_vp9_vaapi_encoder; -extern AVCodec ff_vp9_qsv_encoder; +extern const FFCodec ff_av1_decoder; +extern const FFCodec ff_av1_cuvid_decoder; +extern const FFCodec ff_av1_qsv_decoder; +extern const FFCodec ff_libopenh264_encoder; +extern const FFCodec ff_libopenh264_decoder; +extern const FFCodec ff_h264_amf_encoder; +extern const FFCodec ff_h264_cuvid_decoder; +extern const FFCodec ff_h264_mf_encoder; +extern const FFCodec ff_h264_nvenc_encoder; +extern const FFCodec ff_h264_omx_encoder; +extern const FFCodec ff_h264_qsv_encoder; +extern const FFCodec ff_h264_v4l2m2m_encoder; +extern const FFCodec ff_h264_vaapi_encoder; +extern const FFCodec ff_h264_videotoolbox_encoder; +extern const FFCodec ff_hevc_amf_encoder; +extern const FFCodec ff_hevc_cuvid_decoder; +extern const FFCodec ff_hevc_mediacodec_decoder; +extern const FFCodec ff_hevc_mf_encoder; +extern const FFCodec ff_hevc_nvenc_encoder; +extern const FFCodec ff_hevc_qsv_encoder; +extern const FFCodec ff_hevc_v4l2m2m_encoder; +extern const FFCodec ff_hevc_vaapi_encoder; +extern const FFCodec ff_hevc_videotoolbox_encoder; +extern const FFCodec ff_libkvazaar_encoder; +extern const FFCodec ff_mjpeg_cuvid_decoder; +extern const FFCodec ff_mjpeg_qsv_encoder; +extern const FFCodec ff_mjpeg_qsv_decoder; +extern const FFCodec ff_mjpeg_vaapi_encoder; +extern const FFCodec ff_mp3_mf_encoder; +extern const FFCodec ff_mpeg1_cuvid_decoder; +extern const FFCodec ff_mpeg2_cuvid_decoder; +extern const FFCodec ff_mpeg2_qsv_encoder; +extern const FFCodec ff_mpeg2_vaapi_encoder; +extern const FFCodec ff_mpeg4_cuvid_decoder; +extern const FFCodec ff_mpeg4_mediacodec_decoder; +extern const FFCodec ff_mpeg4_omx_encoder; +extern const FFCodec ff_mpeg4_v4l2m2m_encoder; +extern const FFCodec ff_prores_videotoolbox_encoder; +extern const FFCodec ff_vc1_cuvid_decoder; +extern const FFCodec ff_vp8_cuvid_decoder; +extern const FFCodec ff_vp8_mediacodec_decoder; +extern const FFCodec ff_vp8_qsv_decoder; +extern const FFCodec ff_vp8_v4l2m2m_encoder; +extern const FFCodec ff_vp8_vaapi_encoder; +extern const FFCodec ff_vp9_cuvid_decoder; +extern const FFCodec ff_vp9_mediacodec_decoder; +extern const FFCodec ff_vp9_qsv_decoder; +extern const FFCodec ff_vp9_vaapi_encoder; +extern const FFCodec ff_vp9_qsv_encoder; // The iterate API is not usable with ossfuzz due to the excessive size of binaries created #if CONFIG_OSSFUZZ -AVCodec * codec_list[] = { +const FFCodec * codec_list[] = { NULL, NULL, NULL @@ -852,62 +877,24 @@ static void av_codec_init_static(void) { for (int i = 0; codec_list[i]; i++) { if (codec_list[i]->init_static_data) - codec_list[i]->init_static_data((AVCodec*)codec_list[i]); + codec_list[i]->init_static_data((FFCodec*)codec_list[i]); } } const AVCodec *av_codec_iterate(void **opaque) { uintptr_t i = (uintptr_t)*opaque; - const AVCodec *c = codec_list[i]; + const FFCodec *c = codec_list[i]; ff_thread_once(&av_codec_static_init, av_codec_init_static); - if (c) + if (c) { *opaque = (void*)(i + 1); - - return c; -} - -#if FF_API_NEXT -FF_DISABLE_DEPRECATION_WARNINGS -static AVOnce av_codec_next_init = AV_ONCE_INIT; - -static void av_codec_init_next(void) -{ - AVCodec *prev = NULL, *p; - void *i = 0; - while ((p = (AVCodec*)av_codec_iterate(&i))) { - if (prev) - prev->next = p; - prev = p; + return &c->p; } + return NULL; } - - -av_cold void avcodec_register(AVCodec *codec) -{ - ff_thread_once(&av_codec_next_init, av_codec_init_next); -} - -AVCodec *av_codec_next(const AVCodec *c) -{ - ff_thread_once(&av_codec_next_init, av_codec_init_next); - - if (c) - return c->next; - else - return (AVCodec*)codec_list[0]; -} - -void avcodec_register_all(void) -{ - ff_thread_once(&av_codec_next_init, av_codec_init_next); -} -FF_ENABLE_DEPRECATION_WARNINGS -#endif - static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id) { switch(id){ @@ -917,7 +904,7 @@ static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id) } } -static AVCodec *find_codec(enum AVCodecID id, int (*x)(const AVCodec *)) +static const AVCodec *find_codec(enum AVCodecID id, int (*x)(const AVCodec *)) { const AVCodec *p, *experimental = NULL; void *i = 0; @@ -931,24 +918,24 @@ static AVCodec *find_codec(enum AVCodecID id, int (*x)(const AVCodec *)) if (p->capabilities & AV_CODEC_CAP_EXPERIMENTAL && !experimental) { experimental = p; } else - return (AVCodec*)p; + return p; } } - return (AVCodec*)experimental; + return experimental; } -AVCodec *avcodec_find_encoder(enum AVCodecID id) +const AVCodec *avcodec_find_encoder(enum AVCodecID id) { return find_codec(id, av_codec_is_encoder); } -AVCodec *avcodec_find_decoder(enum AVCodecID id) +const AVCodec *avcodec_find_decoder(enum AVCodecID id) { return find_codec(id, av_codec_is_decoder); } -static AVCodec *find_codec_by_name(const char *name, int (*x)(const AVCodec *)) +static const AVCodec *find_codec_by_name(const char *name, int (*x)(const AVCodec *)) { void *i = 0; const AVCodec *p; @@ -960,18 +947,18 @@ static AVCodec *find_codec_by_name(const char *name, int (*x)(const AVCodec *)) if (!x(p)) continue; if (strcmp(name, p->name) == 0) - return (AVCodec*)p; + return p; } return NULL; } -AVCodec *avcodec_find_encoder_by_name(const char *name) +const AVCodec *avcodec_find_encoder_by_name(const char *name) { return find_codec_by_name(name, av_codec_is_encoder); } -AVCodec *avcodec_find_decoder_by_name(const char *name) +const AVCodec *avcodec_find_decoder_by_name(const char *name) { return find_codec_by_name(name, av_codec_is_decoder); } diff --git a/media/ffvpx/libavcodec/arm/flacdsp_init_arm.c b/media/ffvpx/libavcodec/arm/flacdsp_init_arm.c index 564e3dc79b2a..bac9ff19592d 100644 --- a/media/ffvpx/libavcodec/arm/flacdsp_init_arm.c +++ b/media/ffvpx/libavcodec/arm/flacdsp_init_arm.c @@ -18,8 +18,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/attributes.h" #include "libavcodec/flacdsp.h" #include "config.h" +#include "config_components.h" void ff_flac_lpc_16_arm(int32_t *samples, const int coeffs[32], int order, int qlevel, int len); diff --git a/media/ffvpx/libavcodec/atsc_a53.c b/media/ffvpx/libavcodec/atsc_a53.c index 2d89ef50b94c..29ec71bc5f73 100644 --- a/media/ffvpx/libavcodec/atsc_a53.c +++ b/media/ffvpx/libavcodec/atsc_a53.c @@ -73,7 +73,7 @@ int ff_parse_a53_cc(AVBufferRef **pbuf, const uint8_t *data, int size) int ret, cc_count; if (size < 3) - return AVERROR(EINVAL); + return AVERROR_INVALIDDATA; ret = init_get_bits8(&gb, data, size); if (ret < 0) @@ -95,12 +95,12 @@ int ff_parse_a53_cc(AVBufferRef **pbuf, const uint8_t *data, int size) /* 3 bytes per CC plus one byte marker_bits at the end */ if (cc_count * 3 >= (get_bits_left(&gb) >> 3)) - return AVERROR(EINVAL); + return AVERROR_INVALIDDATA; new_size = (old_size + cc_count * 3); if (new_size > INT_MAX) - return AVERROR(EINVAL); + return AVERROR_INVALIDDATA; /* Allow merging of the cc data from two fields. */ ret = av_buffer_realloc(pbuf, new_size); diff --git a/media/ffvpx/libavcodec/av1.h b/media/ffvpx/libavcodec/av1.h index 0f99ae4829d9..951a18ecb260 100644 --- a/media/ffvpx/libavcodec/av1.h +++ b/media/ffvpx/libavcodec/av1.h @@ -114,6 +114,13 @@ enum { AV1_WARP_MODEL_TRANSLATION = 1, AV1_WARP_MODEL_ROTZOOM = 2, AV1_WARP_MODEL_AFFINE = 3, + AV1_WARP_PARAM_REDUCE_BITS = 6, + + AV1_DIV_LUT_BITS = 8, + AV1_DIV_LUT_PREC_BITS = 14, + AV1_DIV_LUT_NUM = 257, + + AV1_MAX_LOOP_FILTER = 63, }; diff --git a/media/ffvpx/libavcodec/av1_parse.h b/media/ffvpx/libavcodec/av1_parse.h index ae0ebb5a1850..f4a5d2830ec0 100644 --- a/media/ffvpx/libavcodec/av1_parse.h +++ b/media/ffvpx/libavcodec/av1_parse.h @@ -21,10 +21,14 @@ #ifndef AVCODEC_AV1_PARSE_H #define AVCODEC_AV1_PARSE_H +#include #include +#include "libavutil/error.h" +#include "libavutil/intmath.h" +#include "libavutil/macros.h" + #include "av1.h" -#include "avcodec.h" #include "get_bits.h" // OBU header fields + max leb128 length diff --git a/media/ffvpx/libavcodec/av1_parser.c b/media/ffvpx/libavcodec/av1_parser.c index 6a76ffb7bc35..4cbd7408a026 100644 --- a/media/ffvpx/libavcodec/av1_parser.c +++ b/media/ffvpx/libavcodec/av1_parser.c @@ -20,10 +20,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "av1_parse.h" +#include "libavutil/avassert.h" #include "cbs.h" #include "cbs_av1.h" -#include "internal.h" #include "parser.h" typedef struct AV1ParseContext { @@ -56,9 +55,9 @@ static int av1_parser_parse(AVCodecParserContext *ctx, { AV1ParseContext *s = ctx->priv_data; CodedBitstreamFragment *td = &s->temporal_unit; - CodedBitstreamAV1Context *av1 = s->cbc->priv_data; - AV1RawSequenceHeader *seq; - AV1RawColorConfig *color; + const CodedBitstreamAV1Context *av1 = s->cbc->priv_data; + const AV1RawSequenceHeader *seq; + const AV1RawColorConfig *color; int ret; *out_data = data; @@ -96,9 +95,9 @@ static int av1_parser_parse(AVCodecParserContext *ctx, color = &seq->color_config; for (int i = 0; i < td->nb_units; i++) { - CodedBitstreamUnit *unit = &td->units[i]; - AV1RawOBU *obu = unit->content; - AV1RawFrameHeader *frame; + const CodedBitstreamUnit *unit = &td->units[i]; + const AV1RawOBU *obu = unit->content; + const AV1RawFrameHeader *frame; if (unit->type == AV1_OBU_FRAME) frame = &obu->obu.frame.header; @@ -205,33 +204,10 @@ static void av1_parser_close(AVCodecParserContext *ctx) ff_cbs_close(&s->cbc); } -static int av1_parser_split(AVCodecContext *avctx, - const uint8_t *buf, int buf_size) -{ - AV1OBU obu; - const uint8_t *ptr = buf, *end = buf + buf_size; - - while (ptr < end) { - int len = ff_av1_extract_obu(&obu, ptr, buf_size, avctx); - if (len < 0) - break; - - if (obu.type == AV1_OBU_FRAME_HEADER || - obu.type == AV1_OBU_FRAME) { - return ptr - buf; - } - ptr += len; - buf_size -= len; - } - - return 0; -} - -AVCodecParser ff_av1_parser = { +const AVCodecParser ff_av1_parser = { .codec_ids = { AV_CODEC_ID_AV1 }, .priv_data_size = sizeof(AV1ParseContext), .parser_init = av1_parser_init, .parser_close = av1_parser_close, .parser_parse = av1_parser_parse, - .split = av1_parser_split, }; diff --git a/media/ffvpx/libavcodec/av1dec.c b/media/ffvpx/libavcodec/av1dec.c index a75d6744d315..1c09b1d6d606 100644 --- a/media/ffvpx/libavcodec/av1dec.c +++ b/media/ffvpx/libavcodec/av1dec.c @@ -18,15 +18,47 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config_components.h" + #include "libavutil/film_grain_params.h" #include "libavutil/pixdesc.h" #include "libavutil/opt.h" #include "avcodec.h" #include "av1dec.h" #include "bytestream.h" +#include "codec_internal.h" #include "hwconfig.h" #include "internal.h" #include "profiles.h" +#include "thread.h" + +/**< same with Div_Lut defined in spec 7.11.3.7 */ +static const uint16_t div_lut[AV1_DIV_LUT_NUM] = { + 16384, 16320, 16257, 16194, 16132, 16070, 16009, 15948, 15888, 15828, 15768, + 15709, 15650, 15592, 15534, 15477, 15420, 15364, 15308, 15252, 15197, 15142, + 15087, 15033, 14980, 14926, 14873, 14821, 14769, 14717, 14665, 14614, 14564, + 14513, 14463, 14413, 14364, 14315, 14266, 14218, 14170, 14122, 14075, 14028, + 13981, 13935, 13888, 13843, 13797, 13752, 13707, 13662, 13618, 13574, 13530, + 13487, 13443, 13400, 13358, 13315, 13273, 13231, 13190, 13148, 13107, 13066, + 13026, 12985, 12945, 12906, 12866, 12827, 12788, 12749, 12710, 12672, 12633, + 12596, 12558, 12520, 12483, 12446, 12409, 12373, 12336, 12300, 12264, 12228, + 12193, 12157, 12122, 12087, 12053, 12018, 11984, 11950, 11916, 11882, 11848, + 11815, 11782, 11749, 11716, 11683, 11651, 11619, 11586, 11555, 11523, 11491, + 11460, 11429, 11398, 11367, 11336, 11305, 11275, 11245, 11215, 11185, 11155, + 11125, 11096, 11067, 11038, 11009, 10980, 10951, 10923, 10894, 10866, 10838, + 10810, 10782, 10755, 10727, 10700, 10673, 10645, 10618, 10592, 10565, 10538, + 10512, 10486, 10460, 10434, 10408, 10382, 10356, 10331, 10305, 10280, 10255, + 10230, 10205, 10180, 10156, 10131, 10107, 10082, 10058, 10034, 10010, 9986, + 9963, 9939, 9916, 9892, 9869, 9846, 9823, 9800, 9777, 9754, 9732, + 9709, 9687, 9664, 9642, 9620, 9598, 9576, 9554, 9533, 9511, 9489, + 9468, 9447, 9425, 9404, 9383, 9362, 9341, 9321, 9300, 9279, 9259, + 9239, 9218, 9198, 9178, 9158, 9138, 9118, 9098, 9079, 9059, 9039, + 9020, 9001, 8981, 8962, 8943, 8924, 8905, 8886, 8867, 8849, 8830, + 8812, 8793, 8775, 8756, 8738, 8720, 8702, 8684, 8666, 8648, 8630, + 8613, 8595, 8577, 8560, 8542, 8525, 8508, 8490, 8473, 8456, 8439, + 8422, 8405, 8389, 8372, 8355, 8339, 8322, 8306, 8289, 8273, 8257, + 8240, 8224, 8208, 8192 +}; static uint32_t inverse_recenter(int r, uint32_t v) { @@ -97,6 +129,70 @@ static void read_global_param(AV1DecContext *s, int type, int ref, int idx) -mx, mx + 1, r) << prec_diff) + round; } +static uint64_t round_two(uint64_t x, uint16_t n) +{ + if (n == 0) + return x; + return ((x + ((uint64_t)1 << (n - 1))) >> n); +} + +static int64_t round_two_signed(int64_t x, uint16_t n) +{ + return ((x<0) ? -((int64_t)round_two(-x, n)) : (int64_t)round_two(x, n)); +} + +/** + * Resolve divisor process. + * see spec 7.11.3.7 + */ +static int16_t resolve_divisor(uint32_t d, uint16_t *shift) +{ + int32_t e, f; + + *shift = av_log2(d); + e = d - (1 << (*shift)); + if (*shift > AV1_DIV_LUT_BITS) + f = round_two(e, *shift - AV1_DIV_LUT_BITS); + else + f = e << (AV1_DIV_LUT_BITS - (*shift)); + + *shift += AV1_DIV_LUT_PREC_BITS; + + return div_lut[f]; +} + +/** + * check if global motion params is valid. + * see spec 7.11.3.6 + */ +static uint8_t get_shear_params_valid(AV1DecContext *s, int idx) +{ + int16_t alpha, beta, gamma, delta, divf, divs; + int64_t v, w; + int32_t *param = &s->cur_frame.gm_params[idx][0]; + if (param[2] < 0) + return 0; + + alpha = av_clip_int16(param[2] - (1 << AV1_WARPEDMODEL_PREC_BITS)); + beta = av_clip_int16(param[3]); + divf = resolve_divisor(abs(param[2]), &divs); + v = (int64_t)param[4] * (1 << AV1_WARPEDMODEL_PREC_BITS); + w = (int64_t)param[3] * param[4]; + gamma = av_clip_int16((int)round_two_signed((v * divf), divs)); + delta = av_clip_int16(param[5] - (int)round_two_signed((w * divf), divs) - (1 << AV1_WARPEDMODEL_PREC_BITS)); + + alpha = round_two_signed(alpha, AV1_WARP_PARAM_REDUCE_BITS) << AV1_WARP_PARAM_REDUCE_BITS; + beta = round_two_signed(beta, AV1_WARP_PARAM_REDUCE_BITS) << AV1_WARP_PARAM_REDUCE_BITS; + gamma = round_two_signed(gamma, AV1_WARP_PARAM_REDUCE_BITS) << AV1_WARP_PARAM_REDUCE_BITS; + delta = round_two_signed(delta, AV1_WARP_PARAM_REDUCE_BITS) << AV1_WARP_PARAM_REDUCE_BITS; + + if ((4 * abs(alpha) + 7 * abs(beta)) >= (1 << AV1_WARPEDMODEL_PREC_BITS) || + (4 * abs(gamma) + 4 * abs(delta)) >= (1 << AV1_WARPEDMODEL_PREC_BITS)) + return 0; + + return 1; +} + /** * update gm type/params, since cbs already implemented part of this funcation, * so we don't need to full implement spec. @@ -144,6 +240,9 @@ static void global_motion_params(AV1DecContext *s) read_global_param(s, type, ref, 0); read_global_param(s, type, ref, 1); } + if (type <= AV1_WARP_MODEL_AFFINE) { + s->cur_frame.gm_invalid[ref] = !get_shear_params_valid(s, ref); + } } } @@ -404,9 +503,8 @@ static int get_pixel_format(AVCodecContext *avctx) if (pix_fmt == AV_PIX_FMT_NONE) return -1; - s->pix_fmt = pix_fmt; - switch (s->pix_fmt) { + switch (pix_fmt) { case AV_PIX_FMT_YUV420P: #if CONFIG_AV1_DXVA2_HWACCEL *fmtp++ = AV_PIX_FMT_DXVA2_VLD; @@ -449,7 +547,7 @@ static int get_pixel_format(AVCodecContext *avctx) break; } - *fmtp++ = s->pix_fmt; + *fmtp++ = pix_fmt; *fmtp = AV_PIX_FMT_NONE; ret = ff_thread_get_format(avctx, pix_fmts); @@ -467,6 +565,7 @@ static int get_pixel_format(AVCodecContext *avctx) return AVERROR(ENOSYS); } + s->pix_fmt = pix_fmt; avctx->pix_fmt = ret; return 0; @@ -474,7 +573,7 @@ static int get_pixel_format(AVCodecContext *avctx) static void av1_frame_unref(AVCodecContext *avctx, AV1Frame *f) { - ff_thread_release_buffer(avctx, &f->tf); + ff_thread_release_buffer(avctx, f->f); av_buffer_unref(&f->hwaccel_priv_buf); f->hwaccel_picture_private = NULL; av_buffer_unref(&f->header_ref); @@ -490,16 +589,19 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *s { int ret; - ret = ff_thread_ref_frame(&dst->tf, &src->tf); + ret = av_buffer_replace(&dst->header_ref, src->header_ref); if (ret < 0) return ret; - dst->header_ref = av_buffer_ref(src->header_ref); - if (!dst->header_ref) - goto fail; - dst->raw_frame_header = src->raw_frame_header; + if (!src->f->buf[0]) + return 0; + + ret = av_frame_ref(dst->f, src->f); + if (ret < 0) + goto fail; + if (src->hwaccel_picture_private) { dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf); if (!dst->hwaccel_priv_buf) @@ -509,6 +611,9 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *s dst->spatial_id = src->spatial_id; dst->temporal_id = src->temporal_id; + memcpy(dst->gm_invalid, + src->gm_invalid, + AV1_NUM_REF_FRAMES * sizeof(uint8_t)); memcpy(dst->gm_type, src->gm_type, AV1_NUM_REF_FRAMES * sizeof(uint8_t)); @@ -536,10 +641,10 @@ static av_cold int av1_decode_free(AVCodecContext *avctx) for (int i = 0; i < FF_ARRAY_ELEMS(s->ref); i++) { av1_frame_unref(avctx, &s->ref[i]); - av_frame_free(&s->ref[i].tf.f); + av_frame_free(&s->ref[i].f); } av1_frame_unref(avctx, &s->cur_frame); - av_frame_free(&s->cur_frame.tf.f); + av_frame_free(&s->cur_frame.f); av_buffer_unref(&s->seq_ref); av_buffer_unref(&s->header_ref); @@ -575,6 +680,11 @@ static int set_context_with_sequence(AVCodecContext *avctx, break; } + if (seq->film_grain_params_present) + avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN; + else + avctx->properties &= ~FF_CODEC_PROPERTY_FILM_GRAIN; + if (avctx->width != width || avctx->height != height) { int ret = ff_set_dimensions(avctx, width, height); if (ret < 0) @@ -635,16 +745,16 @@ static av_cold int av1_decode_init(AVCodecContext *avctx) s->pix_fmt = AV_PIX_FMT_NONE; for (int i = 0; i < FF_ARRAY_ELEMS(s->ref); i++) { - s->ref[i].tf.f = av_frame_alloc(); - if (!s->ref[i].tf.f) { + s->ref[i].f = av_frame_alloc(); + if (!s->ref[i].f) { av_log(avctx, AV_LOG_ERROR, "Failed to allocate reference frame buffer %d.\n", i); return AVERROR(ENOMEM); } } - s->cur_frame.tf.f = av_frame_alloc(); - if (!s->cur_frame.tf.f) { + s->cur_frame.f = av_frame_alloc(); + if (!s->cur_frame.f) { av_log(avctx, AV_LOG_ERROR, "Failed to allocate current frame buffer.\n"); return AVERROR(ENOMEM); @@ -697,16 +807,10 @@ static int av1_frame_alloc(AVCodecContext *avctx, AV1Frame *f) return ret; } - f->header_ref = av_buffer_ref(s->header_ref); - if (!f->header_ref) - return AVERROR(ENOMEM); - - f->raw_frame_header = s->raw_frame_header; - - if ((ret = ff_thread_get_buffer(avctx, &f->tf, AV_GET_BUFFER_FLAG_REF)) < 0) + if ((ret = ff_thread_get_buffer(avctx, f->f, AV_GET_BUFFER_FLAG_REF)) < 0) goto fail; - frame = f->tf.f; + frame = f->f; frame->key_frame = header->frame_type == AV1_FRAME_KEY; switch (header->frame_type) { @@ -805,7 +909,7 @@ static int set_output_frame(AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt, int *got_frame) { AV1DecContext *s = avctx->priv_data; - const AVFrame *srcframe = s->cur_frame.tf.f; + const AVFrame *srcframe = s->cur_frame.f; int ret; // TODO: all layers @@ -842,8 +946,7 @@ static int update_reference_list(AVCodecContext *avctx) for (int i = 0; i < AV1_NUM_REF_FRAMES; i++) { if (header->refresh_frame_flags & (1 << i)) { - if (s->ref[i].tf.f->buf[0]) - av1_frame_unref(avctx, &s->ref[i]); + av1_frame_unref(avctx, &s->ref[i]); if ((ret = av1_frame_ref(avctx, &s->ref[i], &s->cur_frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to update frame %d in reference list\n", i); @@ -859,8 +962,27 @@ static int get_current_frame(AVCodecContext *avctx) AV1DecContext *s = avctx->priv_data; int ret; - if (s->cur_frame.tf.f->buf[0]) - av1_frame_unref(avctx, &s->cur_frame); + av1_frame_unref(avctx, &s->cur_frame); + + s->cur_frame.header_ref = av_buffer_ref(s->header_ref); + if (!s->cur_frame.header_ref) + return AVERROR(ENOMEM); + + s->cur_frame.raw_frame_header = s->raw_frame_header; + + ret = init_tile_data(s); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Failed to init tile data.\n"); + return ret; + } + + if ((avctx->skip_frame >= AVDISCARD_NONINTRA && + (s->raw_frame_header->frame_type != AV1_FRAME_KEY && + s->raw_frame_header->frame_type != AV1_FRAME_INTRA_ONLY)) || + (avctx->skip_frame >= AVDISCARD_NONKEY && + s->raw_frame_header->frame_type != AV1_FRAME_KEY) || + avctx->skip_frame >= AVDISCARD_ALL) + return 0; ret = av1_frame_alloc(avctx, &s->cur_frame); if (ret < 0) { @@ -869,12 +991,6 @@ static int get_current_frame(AVCodecContext *avctx) return ret; } - ret = init_tile_data(s); - if (ret < 0) { - av_log(avctx, AV_LOG_ERROR, "Failed to init tile data.\n"); - return ret; - } - global_motion_params(s); skip_mode_params(s); coded_lossless_param(s); @@ -883,7 +999,7 @@ static int get_current_frame(AVCodecContext *avctx) return ret; } -static int av1_decode_frame(AVCodecContext *avctx, void *frame, +static int av1_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt) { AV1DecContext *s = avctx->priv_data; @@ -974,8 +1090,7 @@ static int av1_decode_frame(AVCodecContext *avctx, void *frame, s->raw_frame_header = &obu->obu.frame_header; if (s->raw_frame_header->show_existing_frame) { - if (s->cur_frame.tf.f->buf[0]) - av1_frame_unref(avctx, &s->cur_frame); + av1_frame_unref(avctx, &s->cur_frame); ret = av1_frame_ref(avctx, &s->cur_frame, &s->ref[s->raw_frame_header->frame_to_show_map_idx]); @@ -990,9 +1105,11 @@ static int av1_decode_frame(AVCodecContext *avctx, void *frame, goto end; } - ret = set_output_frame(avctx, frame, pkt, got_frame); - if (ret < 0) - av_log(avctx, AV_LOG_ERROR, "Set output frame error.\n"); + if (s->cur_frame.f->buf[0]) { + ret = set_output_frame(avctx, frame, pkt, got_frame); + if (ret < 0) + av_log(avctx, AV_LOG_ERROR, "Set output frame error.\n"); + } s->raw_frame_header = NULL; @@ -1008,7 +1125,7 @@ static int av1_decode_frame(AVCodecContext *avctx, void *frame, s->cur_frame.spatial_id = header->spatial_id; s->cur_frame.temporal_id = header->temporal_id; - if (avctx->hwaccel) { + if (avctx->hwaccel && s->cur_frame.f->buf[0]) { ret = avctx->hwaccel->start_frame(avctx, unit->data, unit->data_size); if (ret < 0) { @@ -1035,7 +1152,7 @@ static int av1_decode_frame(AVCodecContext *avctx, void *frame, if (ret < 0) goto end; - if (avctx->hwaccel) { + if (avctx->hwaccel && s->cur_frame.f->buf[0]) { ret = avctx->hwaccel->decode_slice(avctx, raw_tile_group->tile_data.data, raw_tile_group->tile_data.data_size); @@ -1058,7 +1175,7 @@ static int av1_decode_frame(AVCodecContext *avctx, void *frame, } if (raw_tile_group && (s->tile_num == raw_tile_group->tg_end + 1)) { - if (avctx->hwaccel) { + if (avctx->hwaccel && s->cur_frame.f->buf[0]) { ret = avctx->hwaccel->end_frame(avctx); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "HW accel end frame fail.\n"); @@ -1072,7 +1189,7 @@ static int av1_decode_frame(AVCodecContext *avctx, void *frame, goto end; } - if (s->raw_frame_header->show_frame) { + if (s->raw_frame_header->show_frame && s->cur_frame.f->buf[0]) { ret = set_output_frame(avctx, frame, pkt, got_frame); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Set output frame error\n"); @@ -1121,22 +1238,23 @@ static const AVClass av1_class = { .version = LIBAVUTIL_VERSION_INT, }; -AVCodec ff_av1_decoder = { - .name = "av1", - .long_name = NULL_IF_CONFIG_SMALL("Alliance for Open Media AV1"), - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_AV1, +const FFCodec ff_av1_decoder = { + .p.name = "av1", + .p.long_name = NULL_IF_CONFIG_SMALL("Alliance for Open Media AV1"), + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_AV1, .priv_data_size = sizeof(AV1DecContext), .init = av1_decode_init, .close = av1_decode_free, - .decode = av1_decode_frame, - .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING, + FF_CODEC_DECODE_CB(av1_decode_frame), + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_SETS_PKT_DTS, .flush = av1_decode_flush, - .profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles), - .priv_class = &av1_class, + .p.profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles), + .p.priv_class = &av1_class, + .bsfs = "av1_frame_split", .hw_configs = (const AVCodecHWConfigInternal *const []) { #if CONFIG_AV1_DXVA2_HWACCEL HWACCEL_DXVA2(av1), diff --git a/media/ffvpx/libavcodec/av1dec.h b/media/ffvpx/libavcodec/av1dec.h index 248a68750f54..82c7084e99fb 100644 --- a/media/ffvpx/libavcodec/av1dec.h +++ b/media/ffvpx/libavcodec/av1dec.h @@ -24,14 +24,14 @@ #include #include "libavutil/buffer.h" +#include "libavutil/frame.h" #include "libavutil/pixfmt.h" #include "avcodec.h" #include "cbs.h" #include "cbs_av1.h" -#include "thread.h" typedef struct AV1Frame { - ThreadFrame tf; + AVFrame *f; AVBufferRef *hwaccel_priv_buf; void *hwaccel_picture_private; @@ -42,6 +42,7 @@ typedef struct AV1Frame { int temporal_id; int spatial_id; + uint8_t gm_invalid[AV1_NUM_REF_FRAMES]; uint8_t gm_type[AV1_NUM_REF_FRAMES]; int32_t gm_params[AV1_NUM_REF_FRAMES][6]; diff --git a/media/ffvpx/libavcodec/avcodec.c b/media/ffvpx/libavcodec/avcodec.c index e572e9533ddc..5f6e71a39e7b 100644 --- a/media/ffvpx/libavcodec/avcodec.c +++ b/media/ffvpx/libavcodec/avcodec.c @@ -26,43 +26,21 @@ #include "config.h" #include "libavutil/avassert.h" #include "libavutil/avstring.h" +#include "libavutil/bprint.h" +#include "libavutil/channel_layout.h" +#include "libavutil/fifo.h" #include "libavutil/imgutils.h" #include "libavutil/mem.h" #include "libavutil/opt.h" #include "libavutil/thread.h" #include "avcodec.h" +#include "bsf.h" +#include "codec_internal.h" #include "decode.h" #include "encode.h" #include "frame_thread_encoder.h" #include "internal.h" #include "thread.h" -#if CONFIG_ICONV -# include -#endif - -#include "libavutil/ffversion.h" -const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION; - -unsigned avcodec_version(void) -{ - av_assert0(AV_CODEC_ID_PCM_S8_PLANAR==65563); - av_assert0(AV_CODEC_ID_ADPCM_G722==69660); - av_assert0(AV_CODEC_ID_SRT==94216); - av_assert0(LIBAVCODEC_VERSION_MICRO >= 100); - - return LIBAVCODEC_VERSION_INT; -} - -const char *avcodec_configuration(void) -{ - return FFMPEG_CONFIGURATION; -} - -const char *avcodec_license(void) -{ -#define LICENSE_PREFIX "libavcodec license: " - return &LICENSE_PREFIX FFMPEG_LICENSE[sizeof(LICENSE_PREFIX) - 1]; -} int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size) { @@ -92,25 +70,18 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, static AVMutex codec_mutex = AV_MUTEX_INITIALIZER; -static void lock_avcodec(const AVCodec *codec) +static void lock_avcodec(const FFCodec *codec) { if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE) && codec->init) ff_mutex_lock(&codec_mutex); } -static void unlock_avcodec(const AVCodec *codec) +static void unlock_avcodec(const FFCodec *codec) { if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE) && codec->init) ff_mutex_unlock(&codec_mutex); } -#if FF_API_LOCKMGR -int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) -{ - return 0; -} -#endif - static int64_t get_bit_rate(AVCodecContext *ctx) { int64_t bit_rate; @@ -126,7 +97,7 @@ static int64_t get_bit_rate(AVCodecContext *ctx) case AVMEDIA_TYPE_AUDIO: bits_per_sample = av_get_bits_per_sample(ctx->codec_id); if (bits_per_sample) { - bit_rate = ctx->sample_rate * (int64_t)ctx->channels; + bit_rate = ctx->sample_rate * (int64_t)ctx->ch_layout.nb_channels; if (bit_rate > INT64_MAX / bits_per_sample) { bit_rate = 0; } else @@ -144,9 +115,8 @@ static int64_t get_bit_rate(AVCodecContext *ctx) int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options) { int ret = 0; - int codec_init_ok = 0; - AVDictionary *tmp = NULL; AVCodecInternal *avci; + const FFCodec *codec2; if (avcodec_is_open(avctx)) return 0; @@ -162,15 +132,21 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code } if (!codec) codec = avctx->codec; + codec2 = ffcodec(codec); + + if ((avctx->codec_type != AVMEDIA_TYPE_UNKNOWN && avctx->codec_type != codec->type) || + (avctx->codec_id != AV_CODEC_ID_NONE && avctx->codec_id != codec->id)) { + av_log(avctx, AV_LOG_ERROR, "Codec type or id mismatches\n"); + return AVERROR(EINVAL); + } + + avctx->codec_type = codec->type; + avctx->codec_id = codec->id; + avctx->codec = codec; if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE) return AVERROR(EINVAL); - if (options) - av_dict_copy(&tmp, *options, 0); - - lock_avcodec(codec); - avci = av_mallocz(sizeof(*avci)); if (!avci) { ret = AVERROR(ENOMEM); @@ -178,33 +154,18 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code } avctx->internal = avci; -#if FF_API_OLD_ENCDEC - avci->to_free = av_frame_alloc(); - avci->compat_decode_frame = av_frame_alloc(); - avci->compat_encode_packet = av_packet_alloc(); - if (!avci->to_free || !avci->compat_decode_frame || !avci->compat_encode_packet) { - ret = AVERROR(ENOMEM); - goto free_and_end; - } -#endif avci->buffer_frame = av_frame_alloc(); avci->buffer_pkt = av_packet_alloc(); - avci->es.in_frame = av_frame_alloc(); - avci->ds.in_pkt = av_packet_alloc(); - avci->last_pkt_props = av_packet_alloc(); - avci->pkt_props = av_fifo_alloc(sizeof(*avci->last_pkt_props)); - if (!avci->buffer_frame || !avci->buffer_pkt || - !avci->es.in_frame || !avci->ds.in_pkt || - !avci->last_pkt_props || !avci->pkt_props) { + if (!avci->buffer_frame || !avci->buffer_pkt) { ret = AVERROR(ENOMEM); goto free_and_end; } avci->skip_samples_multiplier = 1; - if (codec->priv_data_size > 0) { + if (codec2->priv_data_size > 0) { if (!avctx->priv_data) { - avctx->priv_data = av_mallocz(codec->priv_data_size); + avctx->priv_data = av_mallocz(codec2->priv_data_size); if (!avctx->priv_data) { ret = AVERROR(ENOMEM); goto free_and_end; @@ -214,12 +175,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code av_opt_set_defaults(avctx->priv_data); } } - if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, &tmp)) < 0) + if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, options)) < 0) goto free_and_end; } else { avctx->priv_data = NULL; } - if ((ret = av_opt_set_dict(avctx, &tmp)) < 0) + if ((ret = av_opt_set_dict(avctx, options)) < 0) goto free_and_end; if (avctx->codec_whitelist && av_match_list(codec->name, avctx->codec_whitelist, ',') <= 0) { @@ -256,20 +217,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code } } - if (avctx->channels > FF_SANE_NB_CHANNELS || avctx->channels < 0) { - av_log(avctx, AV_LOG_ERROR, "Too many or invalid channels: %d\n", avctx->channels); - ret = AVERROR(EINVAL); - goto free_and_end; - } - if (av_codec_is_decoder(codec) && - codec->type == AVMEDIA_TYPE_AUDIO && - !(codec->capabilities & AV_CODEC_CAP_CHANNEL_CONF) && - avctx->channels == 0) { - av_log(avctx, AV_LOG_ERROR, "Decoder requires channel count but channels not set\n"); - ret = AVERROR(EINVAL); - goto free_and_end; - } - if (avctx->sample_rate < 0) { av_log(avctx, AV_LOG_ERROR, "Invalid sample rate: %d\n", avctx->sample_rate); ret = AVERROR(EINVAL); @@ -281,18 +228,31 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code goto free_and_end; } - avctx->codec = codec; - if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == codec->type) && - avctx->codec_id == AV_CODEC_ID_NONE) { - avctx->codec_type = codec->type; - avctx->codec_id = codec->id; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + /* compat wrapper for old-style callers */ + if (avctx->channel_layout && !avctx->channels) + avctx->channels = av_popcount64(avctx->channel_layout); + + if ((avctx->channels > 0 && avctx->ch_layout.nb_channels != avctx->channels) || + (avctx->channel_layout && (avctx->ch_layout.order != AV_CHANNEL_ORDER_NATIVE || + avctx->ch_layout.u.mask != avctx->channel_layout))) { + if (avctx->channel_layout) { + av_channel_layout_from_mask(&avctx->ch_layout, avctx->channel_layout); + } else { + avctx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + avctx->ch_layout.nb_channels = avctx->channels; + } } - if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type - && avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT)) { - av_log(avctx, AV_LOG_ERROR, "Codec type or id mismatches\n"); +FF_ENABLE_DEPRECATION_WARNINGS +#endif + + if (avctx->ch_layout.nb_channels > FF_SANE_NB_CHANNELS) { + av_log(avctx, AV_LOG_ERROR, "Too many channels: %d\n", avctx->ch_layout.nb_channels); ret = AVERROR(EINVAL); goto free_and_end; } + avctx->frame_number = 0; avctx->codec_descriptor = avcodec_descriptor_get(avctx->codec_id); @@ -325,35 +285,37 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code if (ret < 0) goto free_and_end; - if (!HAVE_THREADS) - av_log(avctx, AV_LOG_WARNING, "Warning: not compiled with thread support, using thread emulation\n"); - if (CONFIG_FRAME_THREAD_ENCODER && av_codec_is_encoder(avctx->codec)) { - unlock_avcodec(codec); //we will instantiate a few encoders thus kick the counter to prevent false detection of a problem - ret = ff_frame_thread_encoder_init(avctx, options ? *options : NULL); - lock_avcodec(codec); + ret = ff_frame_thread_encoder_init(avctx); if (ret < 0) goto free_and_end; } if (HAVE_THREADS && !(avci->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))) { + /* Frame-threaded decoders call FFCodec.init for their child contexts. */ + lock_avcodec(codec2); ret = ff_thread_init(avctx); + unlock_avcodec(codec2); if (ret < 0) { goto free_and_end; } } - if (!HAVE_THREADS && !(codec->caps_internal & FF_CODEC_CAP_AUTO_THREADS)) + if (!HAVE_THREADS && !(codec2->caps_internal & FF_CODEC_CAP_AUTO_THREADS)) avctx->thread_count = 1; - if ( avctx->codec->init && (!(avctx->active_thread_type&FF_THREAD_FRAME) - || avci->frame_thread_encoder)) { - ret = avctx->codec->init(avctx); - if (ret < 0) { - codec_init_ok = -1; - goto free_and_end; + if (!(avctx->active_thread_type & FF_THREAD_FRAME) || + avci->frame_thread_encoder) { + if (codec2->init) { + lock_avcodec(codec2); + ret = codec2->init(avctx); + unlock_avcodec(codec2); + if (ret < 0) { + avci->needs_close = codec2->caps_internal & FF_CODEC_CAP_INIT_CLEANUP; + goto free_and_end; + } } - codec_init_ok = 1; + avci->needs_close = 1; } ret=0; @@ -361,6 +323,14 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code if (av_codec_is_decoder(avctx->codec)) { if (!avctx->bit_rate) avctx->bit_rate = get_bit_rate(avctx); + +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + /* update the deprecated fields for old-style callers */ + avctx->channels = avctx->ch_layout.nb_channels; + avctx->channel_layout = avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ? + avctx->ch_layout.u.mask : 0; + /* validate channel layout from the decoder */ if (avctx->channel_layout) { int channels = av_get_channel_layout_nb_channels(avctx->channel_layout); @@ -385,106 +355,22 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code ret = AVERROR(EINVAL); goto free_and_end; } - if (avctx->sub_charenc) { - if (avctx->codec_type != AVMEDIA_TYPE_SUBTITLE) { - av_log(avctx, AV_LOG_ERROR, "Character encoding is only " - "supported with subtitles codecs\n"); - ret = AVERROR(EINVAL); - goto free_and_end; - } else if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) { - av_log(avctx, AV_LOG_WARNING, "Codec '%s' is bitmap-based, " - "subtitles character encoding will be ignored\n", - avctx->codec_descriptor->name); - avctx->sub_charenc_mode = FF_SUB_CHARENC_MODE_DO_NOTHING; - } else { - /* input character encoding is set for a text based subtitle - * codec at this point */ - if (avctx->sub_charenc_mode == FF_SUB_CHARENC_MODE_AUTOMATIC) - avctx->sub_charenc_mode = FF_SUB_CHARENC_MODE_PRE_DECODER; - - if (avctx->sub_charenc_mode == FF_SUB_CHARENC_MODE_PRE_DECODER) { -#if CONFIG_ICONV - iconv_t cd = iconv_open("UTF-8", avctx->sub_charenc); - if (cd == (iconv_t)-1) { - ret = AVERROR(errno); - av_log(avctx, AV_LOG_ERROR, "Unable to open iconv context " - "with input character encoding \"%s\"\n", avctx->sub_charenc); - goto free_and_end; - } - iconv_close(cd); -#else - av_log(avctx, AV_LOG_ERROR, "Character encoding subtitles " - "conversion needs a libavcodec built with iconv support " - "for this codec\n"); - ret = AVERROR(ENOSYS); - goto free_and_end; +FF_ENABLE_DEPRECATION_WARNINGS #endif - } - } - } #if FF_API_AVCTX_TIMEBASE if (avctx->framerate.num > 0 && avctx->framerate.den > 0) avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1})); #endif } - if (codec->priv_data_size > 0 && avctx->priv_data && codec->priv_class) { + if (codec->priv_class) av_assert0(*(const AVClass **)avctx->priv_data == codec->priv_class); - } end: - unlock_avcodec(codec); - if (options) { - av_dict_free(options); - *options = tmp; - } return ret; free_and_end: - if (avctx->codec && avctx->codec->close && - (codec_init_ok > 0 || (codec_init_ok < 0 && - avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP))) - avctx->codec->close(avctx); - - if (HAVE_THREADS && avci->thread_ctx) - ff_thread_free(avctx); - - if (codec->priv_class && avctx->priv_data) - av_opt_free(avctx->priv_data); - av_opt_free(avctx); - - if (av_codec_is_encoder(avctx->codec)) { -#if FF_API_CODED_FRAME -FF_DISABLE_DEPRECATION_WARNINGS - av_frame_free(&avctx->coded_frame); -FF_ENABLE_DEPRECATION_WARNINGS -#endif - av_freep(&avctx->extradata); - avctx->extradata_size = 0; - } - - av_dict_free(&tmp); - av_freep(&avctx->priv_data); - av_freep(&avctx->subtitle_header); - -#if FF_API_OLD_ENCDEC - av_frame_free(&avci->to_free); - av_frame_free(&avci->compat_decode_frame); - av_packet_free(&avci->compat_encode_packet); -#endif - av_frame_free(&avci->buffer_frame); - av_packet_free(&avci->buffer_pkt); - av_packet_free(&avci->last_pkt_props); - av_fifo_freep(&avci->pkt_props); - - av_packet_free(&avci->ds.in_pkt); - av_frame_free(&avci->es.in_frame); - av_bsf_free(&avci->bsf); - - av_buffer_unref(&avci->pool); - av_freep(&avci); - avctx->internal = NULL; - avctx->codec = NULL; + avcodec_close(avctx); goto end; } @@ -502,50 +388,31 @@ void avcodec_flush_buffers(AVCodecContext *avctx) "that doesn't support it\n"); return; } + if (avci->in_frame) + av_frame_unref(avci->in_frame); + } else { + av_packet_unref(avci->last_pkt_props); + while (av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1) >= 0) + av_packet_unref(avci->last_pkt_props); - // We haven't implemented flushing for frame-threaded encoders. - av_assert0(!(caps & AV_CODEC_CAP_FRAME_THREADS)); + av_packet_unref(avci->in_pkt); + + avctx->pts_correction_last_pts = + avctx->pts_correction_last_dts = INT64_MIN; + + av_bsf_flush(avci->bsf); } avci->draining = 0; avci->draining_done = 0; avci->nb_draining_errors = 0; av_frame_unref(avci->buffer_frame); -#if FF_API_OLD_ENCDEC - av_frame_unref(avci->compat_decode_frame); - av_packet_unref(avci->compat_encode_packet); -#endif av_packet_unref(avci->buffer_pkt); - av_packet_unref(avci->last_pkt_props); - while (av_fifo_size(avci->pkt_props) >= sizeof(*avci->last_pkt_props)) { - av_fifo_generic_read(avci->pkt_props, - avci->last_pkt_props, sizeof(*avci->last_pkt_props), - NULL); - av_packet_unref(avci->last_pkt_props); - } - av_fifo_reset(avci->pkt_props); - - av_frame_unref(avci->es.in_frame); - av_packet_unref(avci->ds.in_pkt); - if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) ff_thread_flush(avctx); - else if (avctx->codec->flush) - avctx->codec->flush(avctx); - - avctx->pts_correction_last_pts = - avctx->pts_correction_last_dts = INT64_MIN; - - if (av_codec_is_decoder(avctx->codec)) - av_bsf_flush(avci->bsf); - -#if FF_API_OLD_ENCDEC -FF_DISABLE_DEPRECATION_WARNINGS - if (!avctx->refcounted_frames) - av_frame_unref(avci->to_free); -FF_ENABLE_DEPRECATION_WARNINGS -#endif + else if (ffcodec(avctx->codec)->flush) + ffcodec(avctx->codec)->flush(avctx); } void avsubtitle_free(AVSubtitle *sub) @@ -553,12 +420,15 @@ void avsubtitle_free(AVSubtitle *sub) int i; for (i = 0; i < sub->num_rects; i++) { - av_freep(&sub->rects[i]->data[0]); - av_freep(&sub->rects[i]->data[1]); - av_freep(&sub->rects[i]->data[2]); - av_freep(&sub->rects[i]->data[3]); - av_freep(&sub->rects[i]->text); - av_freep(&sub->rects[i]->ass); + AVSubtitleRect *const rect = sub->rects[i]; + + av_freep(&rect->data[0]); + av_freep(&rect->data[1]); + av_freep(&rect->data[2]); + av_freep(&rect->data[3]); + av_freep(&rect->text); + av_freep(&rect->ass); + av_freep(&sub->rects[i]); } @@ -575,45 +445,41 @@ av_cold int avcodec_close(AVCodecContext *avctx) return 0; if (avcodec_is_open(avctx)) { + AVCodecInternal *avci = avctx->internal; + if (CONFIG_FRAME_THREAD_ENCODER && - avctx->internal->frame_thread_encoder && avctx->thread_count > 1) { + avci->frame_thread_encoder && avctx->thread_count > 1) { ff_frame_thread_encoder_free(avctx); } - if (HAVE_THREADS && avctx->internal->thread_ctx) + if (HAVE_THREADS && avci->thread_ctx) ff_thread_free(avctx); - if (avctx->codec && avctx->codec->close) - avctx->codec->close(avctx); - avctx->internal->byte_buffer_size = 0; - av_freep(&avctx->internal->byte_buffer); -#if FF_API_OLD_ENCDEC - av_frame_free(&avctx->internal->to_free); - av_frame_free(&avctx->internal->compat_decode_frame); - av_packet_free(&avctx->internal->compat_encode_packet); -#endif - av_frame_free(&avctx->internal->buffer_frame); - av_packet_free(&avctx->internal->buffer_pkt); - av_packet_unref(avctx->internal->last_pkt_props); - while (av_fifo_size(avctx->internal->pkt_props) >= - sizeof(*avctx->internal->last_pkt_props)) { - av_fifo_generic_read(avctx->internal->pkt_props, - avctx->internal->last_pkt_props, - sizeof(*avctx->internal->last_pkt_props), - NULL); - av_packet_unref(avctx->internal->last_pkt_props); + if (avci->needs_close && ffcodec(avctx->codec)->close) + ffcodec(avctx->codec)->close(avctx); + avci->byte_buffer_size = 0; + av_freep(&avci->byte_buffer); + av_frame_free(&avci->buffer_frame); + av_packet_free(&avci->buffer_pkt); + if (avci->pkt_props) { + while (av_fifo_can_read(avci->pkt_props)) { + av_packet_unref(avci->last_pkt_props); + av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1); + } + av_fifo_freep2(&avci->pkt_props); } - av_packet_free(&avctx->internal->last_pkt_props); - av_fifo_freep(&avctx->internal->pkt_props); + av_packet_free(&avci->last_pkt_props); - av_packet_free(&avctx->internal->ds.in_pkt); - av_frame_free(&avctx->internal->es.in_frame); + av_packet_free(&avci->in_pkt); + av_frame_free(&avci->in_frame); - av_buffer_unref(&avctx->internal->pool); + av_buffer_unref(&avci->pool); if (avctx->hwaccel && avctx->hwaccel->uninit) avctx->hwaccel->uninit(avctx); - av_freep(&avctx->internal->hwaccel_priv_data); + av_freep(&avci->hwaccel_priv_data); - av_bsf_free(&avctx->internal->bsf); + av_bsf_free(&avci->bsf); + + av_channel_layout_uninit(&avci->initial_ch_layout); av_freep(&avctx->internal); } @@ -632,12 +498,10 @@ av_cold int avcodec_close(AVCodecContext *avctx) av_freep(&avctx->priv_data); if (av_codec_is_encoder(avctx->codec)) { av_freep(&avctx->extradata); -#if FF_API_CODED_FRAME -FF_DISABLE_DEPRECATION_WARNINGS - av_frame_free(&avctx->coded_frame); -FF_ENABLE_DEPRECATION_WARNINGS -#endif - } + avctx->extradata_size = 0; + } else if (av_codec_is_decoder(avctx->codec)) + av_freep(&avctx->subtitle_header); + avctx->codec = NULL; avctx->active_thread_type = 0; @@ -654,6 +518,7 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) const char *codec_type; const char *codec_name; const char *profile = NULL; + AVBPrint bprint; int64_t bitrate; int new_line = 0; AVRational display_aspect_ratio; @@ -662,46 +527,54 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) if (!buf || buf_size <= 0) return; + av_bprint_init_for_buffer(&bprint, buf, buf_size); codec_type = av_get_media_type_string(enc->codec_type); codec_name = avcodec_get_name(enc->codec_id); profile = avcodec_profile_name(enc->codec_id, enc->profile); - snprintf(buf, buf_size, "%s: %s", codec_type ? codec_type : "unknown", - codec_name); + av_bprintf(&bprint, "%s: %s", codec_type ? codec_type : "unknown", + codec_name); buf[0] ^= 'a' ^ 'A'; /* first letter in uppercase */ if (enc->codec && strcmp(enc->codec->name, codec_name)) - snprintf(buf + strlen(buf), buf_size - strlen(buf), " (%s)", enc->codec->name); + av_bprintf(&bprint, " (%s)", enc->codec->name); if (profile) - snprintf(buf + strlen(buf), buf_size - strlen(buf), " (%s)", profile); + av_bprintf(&bprint, " (%s)", profile); if ( enc->codec_type == AVMEDIA_TYPE_VIDEO && av_log_get_level() >= AV_LOG_VERBOSE && enc->refs) - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", %d reference frame%s", - enc->refs, enc->refs > 1 ? "s" : ""); + av_bprintf(&bprint, ", %d reference frame%s", + enc->refs, enc->refs > 1 ? "s" : ""); if (enc->codec_tag) - snprintf(buf + strlen(buf), buf_size - strlen(buf), " (%s / 0x%04X)", - av_fourcc2str(enc->codec_tag), enc->codec_tag); + av_bprintf(&bprint, " (%s / 0x%04X)", + av_fourcc2str(enc->codec_tag), enc->codec_tag); switch (enc->codec_type) { case AVMEDIA_TYPE_VIDEO: { - char detail[256] = "("; + unsigned len; - av_strlcat(buf, separator, buf_size); + av_bprintf(&bprint, "%s%s", separator, + enc->pix_fmt == AV_PIX_FMT_NONE ? "none" : + unknown_if_null(av_get_pix_fmt_name(enc->pix_fmt))); + + av_bprint_chars(&bprint, '(', 1); + len = bprint.len; + + /* The following check ensures that '(' has been written + * and therefore allows us to erase it if it turns out + * to be unnecessary. */ + if (!av_bprint_is_complete(&bprint)) + return; - snprintf(buf + strlen(buf), buf_size - strlen(buf), - "%s", enc->pix_fmt == AV_PIX_FMT_NONE ? "none" : - unknown_if_null(av_get_pix_fmt_name(enc->pix_fmt))); if (enc->bits_per_raw_sample && enc->pix_fmt != AV_PIX_FMT_NONE && enc->bits_per_raw_sample < av_pix_fmt_desc_get(enc->pix_fmt)->comp[0].depth) - av_strlcatf(detail, sizeof(detail), "%d bpc, ", enc->bits_per_raw_sample); + av_bprintf(&bprint, "%d bpc, ", enc->bits_per_raw_sample); if (enc->color_range != AVCOL_RANGE_UNSPECIFIED && (str = av_color_range_name(enc->color_range))) - av_strlcatf(detail, sizeof(detail), "%s, ", str); + av_bprintf(&bprint, "%s, ", str); if (enc->colorspace != AVCOL_SPC_UNSPECIFIED || enc->color_primaries != AVCOL_PRI_UNSPECIFIED || @@ -711,10 +584,9 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) const char *trc = unknown_if_null(av_color_transfer_name(enc->color_trc)); if (strcmp(col, pri) || strcmp(col, trc)) { new_line = 1; - av_strlcatf(detail, sizeof(detail), "%s/%s/%s, ", - col, pri, trc); + av_bprintf(&bprint, "%s/%s/%s, ", col, pri, trc); } else - av_strlcatf(detail, sizeof(detail), "%s, ", col); + av_bprintf(&bprint, "%s, ", col); } if (enc->field_order != AV_FIELD_UNKNOWN) { @@ -728,120 +600,115 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) else if (enc->field_order == AV_FIELD_BT) field_order = "bottom coded first (swapped)"; - av_strlcatf(detail, sizeof(detail), "%s, ", field_order); + av_bprintf(&bprint, "%s, ", field_order); } if (av_log_get_level() >= AV_LOG_VERBOSE && enc->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED && (str = av_chroma_location_name(enc->chroma_sample_location))) - av_strlcatf(detail, sizeof(detail), "%s, ", str); + av_bprintf(&bprint, "%s, ", str); - if (strlen(detail) > 1) { - detail[strlen(detail) - 2] = 0; - av_strlcatf(buf, buf_size, "%s)", detail); + if (len == bprint.len) { + bprint.str[len - 1] = '\0'; + bprint.len--; + } else { + if (bprint.len - 2 < bprint.size) { + /* Erase the last ", " */ + bprint.len -= 2; + bprint.str[bprint.len] = '\0'; + } + av_bprint_chars(&bprint, ')', 1); } } if (enc->width) { - av_strlcat(buf, new_line ? separator : ", ", buf_size); - - snprintf(buf + strlen(buf), buf_size - strlen(buf), - "%dx%d", - enc->width, enc->height); + av_bprintf(&bprint, "%s%dx%d", new_line ? separator : ", ", + enc->width, enc->height); if (av_log_get_level() >= AV_LOG_VERBOSE && (enc->width != enc->coded_width || enc->height != enc->coded_height)) - snprintf(buf + strlen(buf), buf_size - strlen(buf), - " (%dx%d)", enc->coded_width, enc->coded_height); + av_bprintf(&bprint, " (%dx%d)", + enc->coded_width, enc->coded_height); if (enc->sample_aspect_ratio.num) { av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, enc->width * (int64_t)enc->sample_aspect_ratio.num, enc->height * (int64_t)enc->sample_aspect_ratio.den, 1024 * 1024); - snprintf(buf + strlen(buf), buf_size - strlen(buf), - " [SAR %d:%d DAR %d:%d]", + av_bprintf(&bprint, " [SAR %d:%d DAR %d:%d]", enc->sample_aspect_ratio.num, enc->sample_aspect_ratio.den, display_aspect_ratio.num, display_aspect_ratio.den); } if (av_log_get_level() >= AV_LOG_DEBUG) { int g = av_gcd(enc->time_base.num, enc->time_base.den); - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", %d/%d", - enc->time_base.num / g, enc->time_base.den / g); + av_bprintf(&bprint, ", %d/%d", + enc->time_base.num / g, enc->time_base.den / g); } } if (encode) { - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", q=%d-%d", enc->qmin, enc->qmax); + av_bprintf(&bprint, ", q=%d-%d", enc->qmin, enc->qmax); } else { if (enc->properties & FF_CODEC_PROPERTY_CLOSED_CAPTIONS) - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", Closed Captions"); + av_bprintf(&bprint, ", Closed Captions"); + if (enc->properties & FF_CODEC_PROPERTY_FILM_GRAIN) + av_bprintf(&bprint, ", Film Grain"); if (enc->properties & FF_CODEC_PROPERTY_LOSSLESS) - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", lossless"); + av_bprintf(&bprint, ", lossless"); } break; case AVMEDIA_TYPE_AUDIO: - av_strlcat(buf, separator, buf_size); + av_bprintf(&bprint, "%s", separator); if (enc->sample_rate) { - snprintf(buf + strlen(buf), buf_size - strlen(buf), - "%d Hz, ", enc->sample_rate); + av_bprintf(&bprint, "%d Hz, ", enc->sample_rate); + } + { + char buf[512]; + int ret = av_channel_layout_describe(&enc->ch_layout, buf, sizeof(buf)); + if (ret >= 0) + av_bprintf(&bprint, "%s", buf); } - av_get_channel_layout_string(buf + strlen(buf), buf_size - strlen(buf), enc->channels, enc->channel_layout); if (enc->sample_fmt != AV_SAMPLE_FMT_NONE && (str = av_get_sample_fmt_name(enc->sample_fmt))) { - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", %s", str); + av_bprintf(&bprint, ", %s", str); } if ( enc->bits_per_raw_sample > 0 && enc->bits_per_raw_sample != av_get_bytes_per_sample(enc->sample_fmt) * 8) - snprintf(buf + strlen(buf), buf_size - strlen(buf), - " (%d bit)", enc->bits_per_raw_sample); + av_bprintf(&bprint, " (%d bit)", enc->bits_per_raw_sample); if (av_log_get_level() >= AV_LOG_VERBOSE) { if (enc->initial_padding) - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", delay %d", enc->initial_padding); + av_bprintf(&bprint, ", delay %d", enc->initial_padding); if (enc->trailing_padding) - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", padding %d", enc->trailing_padding); + av_bprintf(&bprint, ", padding %d", enc->trailing_padding); } break; case AVMEDIA_TYPE_DATA: if (av_log_get_level() >= AV_LOG_DEBUG) { int g = av_gcd(enc->time_base.num, enc->time_base.den); if (g) - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", %d/%d", - enc->time_base.num / g, enc->time_base.den / g); + av_bprintf(&bprint, ", %d/%d", + enc->time_base.num / g, enc->time_base.den / g); } break; case AVMEDIA_TYPE_SUBTITLE: if (enc->width) - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", %dx%d", enc->width, enc->height); + av_bprintf(&bprint, ", %dx%d", enc->width, enc->height); break; default: return; } if (encode) { if (enc->flags & AV_CODEC_FLAG_PASS1) - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", pass 1"); + av_bprintf(&bprint, ", pass 1"); if (enc->flags & AV_CODEC_FLAG_PASS2) - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", pass 2"); + av_bprintf(&bprint, ", pass 2"); } bitrate = get_bit_rate(enc); if (bitrate != 0) { - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", %"PRId64" kb/s", bitrate / 1000); + av_bprintf(&bprint, ", %"PRId64" kb/s", bitrate / 1000); } else if (enc->rc_max_rate > 0) { - snprintf(buf + strlen(buf), buf_size - strlen(buf), - ", max. %"PRId64" kb/s", enc->rc_max_rate / 1000); + av_bprintf(&bprint, ", max. %"PRId64" kb/s", enc->rc_max_rate / 1000); } } diff --git a/media/ffvpx/libavcodec/avcodec.h b/media/ffvpx/libavcodec/avcodec.h index 8a71c042308e..4dae23d06ec6 100644 --- a/media/ffvpx/libavcodec/avcodec.h +++ b/media/ffvpx/libavcodec/avcodec.h @@ -27,27 +27,29 @@ * Libavcodec external API header */ -#include #include "libavutil/samplefmt.h" #include "libavutil/attributes.h" #include "libavutil/avutil.h" #include "libavutil/buffer.h" -#include "libavutil/cpu.h" -#include "libavutil/channel_layout.h" #include "libavutil/dict.h" #include "libavutil/frame.h" -#include "libavutil/hwcontext.h" #include "libavutil/log.h" #include "libavutil/pixfmt.h" #include "libavutil/rational.h" -#include "bsf.h" #include "codec.h" #include "codec_desc.h" #include "codec_par.h" #include "codec_id.h" +#include "defs.h" #include "packet.h" +#include "version_major.h" +#ifndef HAVE_AV_CONFIG_H +/* When included as part of the ffmpeg build, only include the major version + * to avoid unnecessary rebuilds. When included externally, keep including + * the full version information. */ #include "version.h" +#endif /** * @defgroup libavc libavcodec @@ -155,29 +157,6 @@ * at least will not fail with AVERROR(EAGAIN). In general, no codec will * permit unlimited buffering of input or output. * - * This API replaces the following legacy functions: - * - avcodec_decode_video2() and avcodec_decode_audio4(): - * Use avcodec_send_packet() to feed input to the decoder, then use - * avcodec_receive_frame() to receive decoded frames after each packet. - * Unlike with the old video decoding API, multiple frames might result from - * a packet. For audio, splitting the input packet into frames by partially - * decoding packets becomes transparent to the API user. You never need to - * feed an AVPacket to the API twice (unless it is rejected with AVERROR(EAGAIN) - then - * no data was read from the packet). - * Additionally, sending a flush/draining packet is required only once. - * - avcodec_encode_video2()/avcodec_encode_audio2(): - * Use avcodec_send_frame() to feed input to the encoder, then use - * avcodec_receive_packet() to receive encoded packets. - * Providing user-allocated buffers for avcodec_receive_packet() is not - * possible. - * - The new API does not handle subtitles yet. - * - * Mixing new and old function calls on the same AVCodecContext is not allowed, - * and will result in undefined behavior. - * - * Some codecs might require using the new API; using the old API will return - * an error when calling it. All codecs support the new API. - * * A codec is not allowed to return AVERROR(EAGAIN) for both sending and receiving. This * would be an invalid state, which could put the codec user into an endless * loop. The API has no concept of time either: it cannot happen that trying to @@ -204,16 +183,6 @@ * @{ */ -/** - * @ingroup lavc_decoding - * Required number of additionally allocated bytes at the end of the input bitstream for decoding. - * This is mainly needed because some optimized bitstream readers read - * 32 or 64 bit at once and could read over the end.
- * Note: If the first 23 bits of the additional bytes are not 0, then damaged - * MPEG bitstreams could cause overread and segfault. - */ -#define AV_INPUT_BUFFER_PADDING_SIZE 64 - /** * @ingroup lavc_encoding * minimum encoding buffer size @@ -221,34 +190,6 @@ */ #define AV_INPUT_BUFFER_MIN_SIZE 16384 -/** - * @ingroup lavc_decoding - */ -enum AVDiscard{ - /* We leave some space between them for extensions (drop some - * keyframes for intra-only or drop just some bidir frames). */ - AVDISCARD_NONE =-16, ///< discard nothing - AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi - AVDISCARD_NONREF = 8, ///< discard all non reference - AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames - AVDISCARD_NONINTRA= 24, ///< discard all non intra frames - AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes - AVDISCARD_ALL = 48, ///< discard all -}; - -enum AVAudioServiceType { - AV_AUDIO_SERVICE_TYPE_MAIN = 0, - AV_AUDIO_SERVICE_TYPE_EFFECTS = 1, - AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2, - AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3, - AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4, - AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5, - AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6, - AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7, - AV_AUDIO_SERVICE_TYPE_KARAOKE = 8, - AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI -}; - /** * @ingroup lavc_encoding */ @@ -310,11 +251,15 @@ typedef struct RcOverride{ * error[?] variables will be set during encoding. */ #define AV_CODEC_FLAG_PSNR (1 << 15) +#if FF_API_FLAG_TRUNCATED /** * Input bitstream might be truncated at a random location * instead of only at frame boundaries. + * + * @deprecated use codec parsers for packetizing input */ #define AV_CODEC_FLAG_TRUNCATED (1 << 16) +#endif /** * Use interlaced DCT. */ @@ -416,98 +361,6 @@ typedef struct RcOverride{ */ #define AV_CODEC_EXPORT_DATA_FILM_GRAIN (1 << 3) -/** - * Pan Scan area. - * This specifies the area which should be displayed. - * Note there may be multiple such areas for one frame. - */ -typedef struct AVPanScan { - /** - * id - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - int id; - - /** - * width and height in 1/16 pel - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - int width; - int height; - - /** - * position of the top left corner in 1/16 pel for up to 3 fields/frames - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - int16_t position[3][2]; -} AVPanScan; - -/** - * This structure describes the bitrate properties of an encoded bitstream. It - * roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD - * parameters for H.264/HEVC. - */ -typedef struct AVCPBProperties { - /** - * Maximum bitrate of the stream, in bits per second. - * Zero if unknown or unspecified. - */ -#if FF_API_UNSANITIZED_BITRATES - int max_bitrate; -#else - int64_t max_bitrate; -#endif - /** - * Minimum bitrate of the stream, in bits per second. - * Zero if unknown or unspecified. - */ -#if FF_API_UNSANITIZED_BITRATES - int min_bitrate; -#else - int64_t min_bitrate; -#endif - /** - * Average bitrate of the stream, in bits per second. - * Zero if unknown or unspecified. - */ -#if FF_API_UNSANITIZED_BITRATES - int avg_bitrate; -#else - int64_t avg_bitrate; -#endif - - /** - * The size of the buffer to which the ratecontrol is applied, in bits. - * Zero if unknown or unspecified. - */ - int buffer_size; - - /** - * The delay between the time the packet this structure is associated with - * is received and the time when it should be decoded, in periods of a 27MHz - * clock. - * - * UINT64_MAX when unknown or unspecified. - */ - uint64_t vbv_delay; -} AVCPBProperties; - -/** - * This structure supplies correlation between a packet timestamp and a wall clock - * production time. The definition follows the Producer Reference Time ('prft') - * as defined in ISO/IEC 14496-12 - */ -typedef struct AVProducerReferenceTime { - /** - * A UTC timestamp, in microseconds, since Unix epoch (e.g, av_gettime()). - */ - int64_t wallclock; - int flags; -} AVProducerReferenceTime; - /** * The decoder will keep a reference to the frame and may reuse it later. */ @@ -697,7 +550,7 @@ typedef struct AVCodecContext { * picture width / height. * * @note Those fields may not match the values of the last - * AVFrame output by avcodec_decode_video2 due frame + * AVFrame output by avcodec_receive_frame() due frame * reordering. * * - encoding: MUST be set by user. @@ -773,17 +626,29 @@ typedef struct AVCodecContext { int y, int type, int height); /** - * callback to negotiate the pixelFormat - * @param fmt is the list of formats which are supported by the codec, - * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality. - * The first is always the native one. - * @note The callback may be called again immediately if initialization for - * the selected (hardware-accelerated) pixel format failed. - * @warning Behavior is undefined if the callback returns a value not - * in the fmt list of formats. - * @return the chosen format - * - encoding: unused - * - decoding: Set by user, if not set the native format will be chosen. + * Callback to negotiate the pixel format. Decoding only, may be set by the + * caller before avcodec_open2(). + * + * Called by some decoders to select the pixel format that will be used for + * the output frames. This is mainly used to set up hardware acceleration, + * then the provided format list contains the corresponding hwaccel pixel + * formats alongside the "software" one. The software pixel format may also + * be retrieved from \ref sw_pix_fmt. + * + * This callback will be called when the coded frame properties (such as + * resolution, pixel format, etc.) change and more than one output format is + * supported for those new properties. If a hardware pixel format is chosen + * and initialization for it fails, the callback may be called again + * immediately. + * + * This callback may be called from different threads if the decoder is + * multi-threaded, but not from more than one thread simultaneously. + * + * @param fmt list of formats which may be used in the current + * configuration, terminated by AV_PIX_FMT_NONE. + * @warning Behavior is undefined if the callback returns a value other + * than one of the formats in fmt or AV_PIX_FMT_NONE. + * @return the chosen format or AV_PIX_FMT_NONE */ enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt); @@ -804,12 +669,6 @@ typedef struct AVCodecContext { */ float b_quant_factor; -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int b_frame_strategy; -#endif - /** * qscale offset between IP and B-frames * - encoding: Set by user. @@ -825,12 +684,6 @@ typedef struct AVCodecContext { */ int has_b_frames; -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int mpeg_quant; -#endif - /** * qscale factor between P- and I-frames * If > 0 then the last P-frame quantizer will be used (q = lastp_q * factor + offset). @@ -889,15 +742,6 @@ typedef struct AVCodecContext { */ int slice_count; -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int prediction_method; -#define FF_PRED_LEFT 0 -#define FF_PRED_PLANE 1 -#define FF_PRED_MEDIAN 2 -#endif - /** * slice offsets in the frame in bytes * - encoding: Set/allocated by libavcodec. @@ -970,12 +814,6 @@ typedef struct AVCodecContext { */ int last_predictor_count; -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int pre_me; -#endif - /** * motion estimation prepass comparison function * - encoding: Set by user. @@ -1044,16 +882,6 @@ typedef struct AVCodecContext { */ uint16_t *inter_matrix; -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int scenechange_threshold; - - /** @deprecated use encoder private options instead */ - attribute_deprecated - int noise_reduction; -#endif - /** * precision of the intra DC coefficient - 8 * - encoding: Set by user. @@ -1089,26 +917,12 @@ typedef struct AVCodecContext { */ int mb_lmax; -#if FF_API_PRIVATE_OPT - /** - * @deprecated use encoder private options instead - */ - attribute_deprecated - int me_penalty_compensation; -#endif - /** * - encoding: Set by user. * - decoding: unused */ int bidir_refine; -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int brd_scale; -#endif - /** * minimum GOP size * - encoding: Set by user. @@ -1123,12 +937,6 @@ typedef struct AVCodecContext { */ int refs; -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int chromaoffset; -#endif - /** * Note: Value depends upon the compare function used for fullpel ME. * - encoding: Set by user. @@ -1136,12 +944,6 @@ typedef struct AVCodecContext { */ int mv0_threshold; -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int b_sensitivity; -#endif - /** * Chromaticity coordinates of the source primaries. * - encoding: Set by user @@ -1194,7 +996,15 @@ typedef struct AVCodecContext { /* audio only */ int sample_rate; ///< samples per second - int channels; ///< number of audio channels + +#if FF_API_OLD_CHANNEL_LAYOUT + /** + * number of audio channels + * @deprecated use ch_layout.nb_channels + */ + attribute_deprecated + int channels; +#endif /** * audio sample format @@ -1239,19 +1049,25 @@ typedef struct AVCodecContext { */ int cutoff; +#if FF_API_OLD_CHANNEL_LAYOUT /** * Audio channel layout. * - encoding: set by user. * - decoding: set by user, may be overwritten by libavcodec. + * @deprecated use ch_layout */ + attribute_deprecated uint64_t channel_layout; /** * Request decoder to use this channel layout if it can (0 for default) * - encoding: unused * - decoding: Set by user. + * @deprecated use "downmix" codec private option */ + attribute_deprecated uint64_t request_channel_layout; +#endif /** * Type of service that the audio stream conveys. @@ -1350,24 +1166,6 @@ typedef struct AVCodecContext { */ int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags); -#if FF_API_OLD_ENCDEC - /** - * If non-zero, the decoded audio and video frames returned from - * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted - * and are valid indefinitely. The caller must free them with - * av_frame_unref() when they are not needed anymore. - * Otherwise, the decoded frames must not be freed by the caller and are - * only valid until the next decode call. - * - * This is always automatically enabled if avcodec_receive_frame() is used. - * - * - encoding: unused - * - decoding: set by the caller before avcodec_open2(). - */ - attribute_deprecated - int refcounted_frames; -#endif - /* - encoding parameters */ float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0) float qblur; ///< amount of qscale smoothing over time (0.0-1.0) @@ -1443,42 +1241,6 @@ typedef struct AVCodecContext { */ int rc_initial_buffer_occupancy; -#if FF_API_CODER_TYPE -#define FF_CODER_TYPE_VLC 0 -#define FF_CODER_TYPE_AC 1 -#define FF_CODER_TYPE_RAW 2 -#define FF_CODER_TYPE_RLE 3 - /** - * @deprecated use encoder private options instead - */ - attribute_deprecated - int coder_type; -#endif /* FF_API_CODER_TYPE */ - -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int context_model; -#endif - -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int frame_skip_threshold; - - /** @deprecated use encoder private options instead */ - attribute_deprecated - int frame_skip_factor; - - /** @deprecated use encoder private options instead */ - attribute_deprecated - int frame_skip_exp; - - /** @deprecated use encoder private options instead */ - attribute_deprecated - int frame_skip_cmp; -#endif /* FF_API_PRIVATE_OPT */ - /** * trellis RD quantization * - encoding: Set by user. @@ -1486,69 +1248,6 @@ typedef struct AVCodecContext { */ int trellis; -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int min_prediction_order; - - /** @deprecated use encoder private options instead */ - attribute_deprecated - int max_prediction_order; - - /** @deprecated use encoder private options instead */ - attribute_deprecated - int64_t timecode_frame_start; -#endif - -#if FF_API_RTP_CALLBACK - /** - * @deprecated unused - */ - /* The RTP callback: This function is called */ - /* every time the encoder has a packet to send. */ - /* It depends on the encoder if the data starts */ - /* with a Start Code (it should). H.263 does. */ - /* mb_nb contains the number of macroblocks */ - /* encoded in the RTP payload. */ - attribute_deprecated - void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb); -#endif - -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int rtp_payload_size; /* The size of the RTP payload: the coder will */ - /* do its best to deliver a chunk with size */ - /* below rtp_payload_size, the chunk will start */ - /* with a start code on some codecs like H.263. */ - /* This doesn't take account of any particular */ - /* headers inside the transmitted RTP payload. */ -#endif - -#if FF_API_STAT_BITS - /* statistics, used for 2-pass encoding */ - attribute_deprecated - int mv_bits; - attribute_deprecated - int header_bits; - attribute_deprecated - int i_tex_bits; - attribute_deprecated - int p_tex_bits; - attribute_deprecated - int i_count; - attribute_deprecated - int p_count; - attribute_deprecated - int skip_count; - attribute_deprecated - int misc_bits; - - /** @deprecated this field is unused */ - attribute_deprecated - int frame_bits; -#endif - /** * pass1 encoding statistics output buffer * - encoding: Set by libavcodec. @@ -1684,8 +1383,7 @@ typedef struct AVCodecContext { * For some hardware accelerators, a global context needs to be * provided by the user. In that case, this holds display-dependent * data FFmpeg cannot instantiate itself. Please refer to the - * FFmpeg HW accelerator documentation to know how to fill this - * is. e.g. for VA API, this is a struct vaapi_context. + * FFmpeg HW accelerator documentation to know how to fill this. * - encoding: unused * - decoding: Set by user */ @@ -1729,7 +1427,10 @@ typedef struct AVCodecContext { #define FF_IDCT_SIMPLEARMV6 17 #define FF_IDCT_FAAN 20 #define FF_IDCT_SIMPLENEON 22 -#define FF_IDCT_NONE 24 /* Used by XvMC to extract IDCT coefficients with FF_IDCT_PERM_NONE */ +#if FF_API_IDCT_NONE +// formerly used by xvmc +#define FF_IDCT_NONE 24 +#endif #define FF_IDCT_SIMPLEAUTO 128 /** @@ -1753,17 +1454,6 @@ typedef struct AVCodecContext { */ int lowres; -#if FF_API_CODED_FRAME - /** - * the picture in the bitstream - * - encoding: Set by libavcodec. - * - decoding: unused - * - * @deprecated use the quality factor packet side data instead - */ - attribute_deprecated AVFrame *coded_frame; -#endif - /** * thread count * is used to decide how many independent tasks should be passed to execute() @@ -2016,34 +1706,6 @@ typedef struct AVCodecContext { uint8_t *subtitle_header; int subtitle_header_size; -#if FF_API_VBV_DELAY - /** - * VBV delay coded in the last frame (in periods of a 27 MHz clock). - * Used for compliant TS muxing. - * - encoding: Set by libavcodec. - * - decoding: unused. - * @deprecated this value is now exported as a part of - * AV_PKT_DATA_CPB_PROPERTIES packet side data - */ - attribute_deprecated - uint64_t vbv_delay; -#endif - -#if FF_API_SIDEDATA_ONLY_PKT - /** - * Encoding only and set by default. Allow encoders to output packets - * that do not contain any encoded data, only side data. - * - * Some encoders need to output such packets, e.g. to update some stream - * parameters at the end of encoding. - * - * @deprecated this field disables the default behaviour and - * it is kept only for compatibility. - */ - attribute_deprecated - int side_data_only_packets; -#endif - /** * Audio only. The number of "priming" samples (padding) inserted by the * encoder at the beginning of the audio. I.e. this number of leading @@ -2183,6 +1845,7 @@ typedef struct AVCodecContext { unsigned properties; #define FF_CODEC_PROPERTY_LOSSLESS 0x00000001 #define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x00000002 +#define FF_CODEC_PROPERTY_FILM_GRAIN 0x00000004 /** * Additional data associated with the entire coded stream. @@ -2217,15 +1880,13 @@ typedef struct AVCodecContext { */ AVBufferRef *hw_frames_ctx; +#if FF_API_SUB_TEXT_FORMAT /** - * Control the form of AVSubtitle.rects[N]->ass - * - decoding: set by user - * - encoding: unused + * @deprecated unused */ + attribute_deprecated int sub_text_format; #define FF_SUB_TEXT_FMT_ASS 0 -#if FF_API_ASS_TIMING -#define FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS 1 #endif /** @@ -2355,6 +2016,10 @@ typedef struct AVCodecContext { * This callback must use the above value to calculate the required buffer size, * which must padded by at least AV_INPUT_BUFFER_PADDING_SIZE bytes. * + * In some specific cases, the encoder may not use the entire buffer allocated by this + * callback. This will be reflected in the size value in the packet once returned by + * avcodec_receive_packet(). + * * This callback must fill the following fields in the packet: * - data: alignment requirements for AVPacket apply, if any. Some architectures and * encoders may benefit from having aligned data. @@ -2382,51 +2047,16 @@ typedef struct AVCodecContext { * - decoding: unused */ int (*get_encode_buffer)(struct AVCodecContext *s, AVPacket *pkt, int flags); + + /** + * Audio channel layout. + * - encoding: must be set by the caller, to one of AVCodec.ch_layouts. + * - decoding: may be set by the caller if known e.g. from the container. + * The decoder can then override during decoding as needed. + */ + AVChannelLayout ch_layout; } AVCodecContext; -#if FF_API_CODEC_GET_SET -/** - * Accessors for some AVCodecContext fields. These used to be provided for ABI - * compatibility, and do not need to be used anymore. - */ -attribute_deprecated -AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx); -attribute_deprecated -void av_codec_set_pkt_timebase (AVCodecContext *avctx, AVRational val); - -attribute_deprecated -const AVCodecDescriptor *av_codec_get_codec_descriptor(const AVCodecContext *avctx); -attribute_deprecated -void av_codec_set_codec_descriptor(AVCodecContext *avctx, const AVCodecDescriptor *desc); - -attribute_deprecated -unsigned av_codec_get_codec_properties(const AVCodecContext *avctx); - -attribute_deprecated -int av_codec_get_lowres(const AVCodecContext *avctx); -attribute_deprecated -void av_codec_set_lowres(AVCodecContext *avctx, int val); - -attribute_deprecated -int av_codec_get_seek_preroll(const AVCodecContext *avctx); -attribute_deprecated -void av_codec_set_seek_preroll(AVCodecContext *avctx, int val); - -attribute_deprecated -uint16_t *av_codec_get_chroma_intra_matrix(const AVCodecContext *avctx); -attribute_deprecated -void av_codec_set_chroma_intra_matrix(AVCodecContext *avctx, uint16_t *val); -#endif - -struct AVSubtitle; - -#if FF_API_CODEC_GET_SET -attribute_deprecated -int av_codec_get_max_lowres(const AVCodec *codec); -#endif - -struct MpegEncContext; - /** * @defgroup lavc_hwaccel AVHWAccel * @@ -2518,7 +2148,6 @@ typedef struct AVHWAccel { * * Meaningful slice information (codec specific) is guaranteed to * be parsed at this point. This function is mandatory. - * The only exception is XvMC, that works on MB level. * * @param avctx the codec context * @param buf the slice data buffer base @@ -2547,17 +2176,6 @@ typedef struct AVHWAccel { */ int frame_priv_data_size; - /** - * Called for every Macroblock in a slice. - * - * XvMC uses it to replace the ff_mpv_reconstruct_mb(). - * Instead of decoding to raw picture, MB parameters are - * stored in an array provided by the video driver. - * - * @param s the mpeg context - */ - void (*decode_mb)(struct MpegEncContext *s); - /** * Initialize the hwaccel private data. * @@ -2637,33 +2255,6 @@ typedef struct AVHWAccel { * @} */ -#if FF_API_AVPICTURE -/** - * @defgroup lavc_picture AVPicture - * - * Functions for working with AVPicture - * @{ - */ - -/** - * Picture data structure. - * - * Up to four components can be stored into it, the last component is - * alpha. - * @deprecated use AVFrame or imgutils functions instead - */ -typedef struct AVPicture { - attribute_deprecated - uint8_t *data[AV_NUM_DATA_POINTERS]; ///< pointers to the image data planes - attribute_deprecated - int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line -} AVPicture; - -/** - * @} - */ -#endif - enum AVSubtitleType { SUBTITLE_NONE, @@ -2691,13 +2282,6 @@ typedef struct AVSubtitleRect { int h; ///< height of pict, undefined when pict is not set int nb_colors; ///< number of colors in pict, undefined when pict is not set -#if FF_API_AVPICTURE - /** - * @deprecated unused - */ - attribute_deprecated - AVPicture pict; -#endif /** * data+linesize for the bitmap of this subtitle. * Can be set for text/ass as well once they are rendered. @@ -2728,16 +2312,6 @@ typedef struct AVSubtitle { int64_t pts; ///< Same as packet pts, in AV_TIME_BASE } AVSubtitle; -#if FF_API_NEXT -/** - * If c is NULL, returns the first registered codec, - * if c is non-NULL, returns the next registered codec after c, - * or NULL if c is the last one. - */ -attribute_deprecated -AVCodec *av_codec_next(const AVCodec *c); -#endif - /** * Return the LIBAVCODEC_VERSION_INT constant. */ @@ -2753,20 +2327,6 @@ const char *avcodec_configuration(void); */ const char *avcodec_license(void); -#if FF_API_NEXT -/** - * @deprecated Calling this function is unnecessary. - */ -attribute_deprecated -void avcodec_register(AVCodec *codec); - -/** - * @deprecated Calling this function is unnecessary. - */ -attribute_deprecated -void avcodec_register_all(void); -#endif - /** * Allocate an AVCodecContext and set its fields to default values. The * resulting struct should be freed with avcodec_free_context(). @@ -2788,15 +2348,6 @@ AVCodecContext *avcodec_alloc_context3(const AVCodec *codec); */ void avcodec_free_context(AVCodecContext **avctx); -#if FF_API_GET_CONTEXT_DEFAULTS -/** - * @deprecated This function should not be used, as closing and opening a codec - * context multiple time is not supported. A new codec context should be - * allocated for each new use. - */ -int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec); -#endif - /** * Get the AVClass for AVCodecContext. It can be used in combination with * AV_OPT_SEARCH_FAKE_OBJ for examining options. @@ -2821,28 +2372,6 @@ const AVClass *avcodec_get_frame_class(void); */ const AVClass *avcodec_get_subtitle_rect_class(void); -#if FF_API_COPY_CONTEXT -/** - * Copy the settings of the source AVCodecContext into the destination - * AVCodecContext. The resulting destination codec context will be - * unopened, i.e. you are required to call avcodec_open2() before you - * can use this AVCodecContext to decode/encode video/audio data. - * - * @param dest target codec context, should be initialized with - * avcodec_alloc_context3(NULL), but otherwise uninitialized - * @param src source codec context - * @return AVERROR() on error (e.g. memory allocation error), 0 on success - * - * @deprecated The semantics of this function are ill-defined and it should not - * be used. If you need to transfer the stream parameters from one codec context - * to another, use an intermediate AVCodecParameters instance and the - * avcodec_parameters_from_context() / avcodec_parameters_to_context() - * functions. - */ -attribute_deprecated -int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); -#endif - /** * Fill the parameters struct based on the values from the supplied codec * context. Any allocated fields in par are freed and replaced with duplicates @@ -2872,8 +2401,6 @@ int avcodec_parameters_to_context(AVCodecContext *codec, * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for * retrieving a codec. * - * @warning This function is not thread safe! - * * @note Always call this function before using decoding routines (such as * @ref avcodec_receive_frame()). * @@ -2989,115 +2516,6 @@ int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos); */ enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos); -#if FF_API_OLD_ENCDEC -/** - * Decode the audio frame of size avpkt->size from avpkt->data into frame. - * - * Some decoders may support multiple frames in a single AVPacket. Such - * decoders would then just decode the first frame and the return value would be - * less than the packet size. In this case, avcodec_decode_audio4 has to be - * called again with an AVPacket containing the remaining data in order to - * decode the second frame, etc... Even if no frames are returned, the packet - * needs to be fed to the decoder with remaining data until it is completely - * consumed or an error occurs. - * - * Some decoders (those marked with AV_CODEC_CAP_DELAY) have a delay between input - * and output. This means that for some packets they will not immediately - * produce decoded output and need to be flushed at the end of decoding to get - * all the decoded data. Flushing is done by calling this function with packets - * with avpkt->data set to NULL and avpkt->size set to 0 until it stops - * returning samples. It is safe to flush even those decoders that are not - * marked with AV_CODEC_CAP_DELAY, then no samples will be returned. - * - * @warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE - * larger than the actual read bytes because some optimized bitstream - * readers read 32 or 64 bits at once and could read over the end. - * - * @note The AVCodecContext MUST have been opened with @ref avcodec_open2() - * before packets may be fed to the decoder. - * - * @param avctx the codec context - * @param[out] frame The AVFrame in which to store decoded audio samples. - * The decoder will allocate a buffer for the decoded frame by - * calling the AVCodecContext.get_buffer2() callback. - * When AVCodecContext.refcounted_frames is set to 1, the frame is - * reference counted and the returned reference belongs to the - * caller. The caller must release the frame using av_frame_unref() - * when the frame is no longer needed. The caller may safely write - * to the frame if av_frame_is_writable() returns 1. - * When AVCodecContext.refcounted_frames is set to 0, the returned - * reference belongs to the decoder and is valid only until the - * next call to this function or until closing or flushing the - * decoder. The caller may not write to it. - * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is - * non-zero. Note that this field being set to zero - * does not mean that an error has occurred. For - * decoders with AV_CODEC_CAP_DELAY set, no given decode - * call is guaranteed to produce a frame. - * @param[in] avpkt The input AVPacket containing the input buffer. - * At least avpkt->data and avpkt->size should be set. Some - * decoders might also require additional fields to be set. - * @return A negative error code is returned if an error occurred during - * decoding, otherwise the number of bytes consumed from the input - * AVPacket is returned. - * -* @deprecated Use avcodec_send_packet() and avcodec_receive_frame(). - */ -attribute_deprecated -int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, - int *got_frame_ptr, const AVPacket *avpkt); - -/** - * Decode the video frame of size avpkt->size from avpkt->data into picture. - * Some decoders may support multiple frames in a single AVPacket, such - * decoders would then just decode the first frame. - * - * @warning The input buffer must be AV_INPUT_BUFFER_PADDING_SIZE larger than - * the actual read bytes because some optimized bitstream readers read 32 or 64 - * bits at once and could read over the end. - * - * @warning The end of the input buffer buf should be set to 0 to ensure that - * no overreading happens for damaged MPEG streams. - * - * @note Codecs which have the AV_CODEC_CAP_DELAY capability set have a delay - * between input and output, these need to be fed with avpkt->data=NULL, - * avpkt->size=0 at the end to return the remaining frames. - * - * @note The AVCodecContext MUST have been opened with @ref avcodec_open2() - * before packets may be fed to the decoder. - * - * @param avctx the codec context - * @param[out] picture The AVFrame in which the decoded video frame will be stored. - * Use av_frame_alloc() to get an AVFrame. The codec will - * allocate memory for the actual bitmap by calling the - * AVCodecContext.get_buffer2() callback. - * When AVCodecContext.refcounted_frames is set to 1, the frame is - * reference counted and the returned reference belongs to the - * caller. The caller must release the frame using av_frame_unref() - * when the frame is no longer needed. The caller may safely write - * to the frame if av_frame_is_writable() returns 1. - * When AVCodecContext.refcounted_frames is set to 0, the returned - * reference belongs to the decoder and is valid only until the - * next call to this function or until closing or flushing the - * decoder. The caller may not write to it. - * - * @param[in] avpkt The input AVPacket containing the input buffer. - * You can create such packet with av_init_packet() and by then setting - * data and size, some decoders might in addition need other fields like - * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least - * fields possible. - * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. - * @return On error a negative value is returned, otherwise the number of bytes - * used or zero if no frame could be decompressed. - * - * @deprecated Use avcodec_send_packet() and avcodec_receive_frame(). - */ -attribute_deprecated -int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, - int *got_picture_ptr, - const AVPacket *avpkt); -#endif - /** * Decode a subtitle message. * Return a negative value on error, otherwise return the number of bytes used. @@ -3141,10 +2559,6 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, * larger than the actual read bytes because some optimized bitstream * readers read 32 or 64 bits at once and could read over the end. * - * @warning Do not mix this API with the legacy API (like avcodec_decode_video2()) - * on the same AVCodecContext. It will return unexpected results now - * or in future libavcodec versions. - * * @note The AVCodecContext MUST have been opened with @ref avcodec_open2() * before packets may be fed to the decoder. * @@ -3234,8 +2648,7 @@ int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame); * the call will not fail with EAGAIN). * AVERROR_EOF: the encoder has been flushed, and no new frames can * be sent to it - * AVERROR(EINVAL): codec not opened, refcounted_frames not set, it is a - * decoder, or requires flush + * AVERROR(EINVAL): codec not opened, it is a decoder, or requires flush * AVERROR(ENOMEM): failed to add packet to internal queue, or similar * other errors: legitimate encoding errors */ @@ -3376,7 +2789,7 @@ enum AVPictureStructure { typedef struct AVCodecParserContext { void *priv_data; - struct AVCodecParser *parser; + const struct AVCodecParser *parser; int64_t frame_offset; /* offset of the current frame */ int64_t cur_offset; /* current offset (incremented by each av_parser_parse()) */ @@ -3425,14 +2838,6 @@ typedef struct AVCodecParserContext { */ int key_frame; -#if FF_API_CONVERGENCE_DURATION - /** - * @deprecated unused - */ - attribute_deprecated - int64_t convergence_duration; -#endif - // Timestamp generation support: /** * Synchronization point for start of timestamp generation. @@ -3542,7 +2947,7 @@ typedef struct AVCodecParserContext { } AVCodecParserContext; typedef struct AVCodecParser { - int codec_ids[5]; /* several codec IDs are permitted */ + int codec_ids[7]; /* several codec IDs are permitted */ int priv_data_size; int (*parser_init)(AVCodecParserContext *s); /* This callback never returns an error, a negative value means that @@ -3553,10 +2958,6 @@ typedef struct AVCodecParser { const uint8_t *buf, int buf_size); void (*parser_close)(AVCodecParserContext *s); int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size); -#if FF_API_NEXT - attribute_deprecated - struct AVCodecParser *next; -#endif } AVCodecParser; /** @@ -3570,13 +2971,6 @@ typedef struct AVCodecParser { */ const AVCodecParser *av_parser_iterate(void **opaque); -#if FF_API_NEXT -attribute_deprecated -AVCodecParser *av_parser_next(const AVCodecParser *c); - -attribute_deprecated -void av_register_codec_parser(AVCodecParser *parser); -#endif AVCodecParserContext *av_parser_init(int codec_id); /** @@ -3617,18 +3011,6 @@ int av_parser_parse2(AVCodecParserContext *s, int64_t pts, int64_t dts, int64_t pos); -#if FF_API_PARSER_CHANGE -/** - * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed - * @deprecated Use dump_extradata, remove_extra or extract_extradata - * bitstream filters instead. - */ -attribute_deprecated -int av_parser_change(AVCodecParserContext *s, - AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, int keyframe); -#endif void av_parser_close(AVCodecParserContext *s); /** @@ -3641,95 +3023,6 @@ void av_parser_close(AVCodecParserContext *s); * @{ */ -#if FF_API_OLD_ENCDEC -/** - * Encode a frame of audio. - * - * Takes input samples from frame and writes the next output packet, if - * available, to avpkt. The output packet does not necessarily contain data for - * the most recent frame, as encoders can delay, split, and combine input frames - * internally as needed. - * - * @param avctx codec context - * @param avpkt output AVPacket. - * The user can supply an output buffer by setting - * avpkt->data and avpkt->size prior to calling the - * function, but if the size of the user-provided data is not - * large enough, encoding will fail. If avpkt->data and - * avpkt->size are set, avpkt->destruct must also be set. All - * other AVPacket fields will be reset by the encoder using - * av_init_packet(). If avpkt->data is NULL, the encoder will - * allocate it. The encoder will set avpkt->size to the size - * of the output packet. - * - * If this function fails or produces no output, avpkt will be - * freed using av_packet_unref(). - * @param[in] frame AVFrame containing the raw audio data to be encoded. - * May be NULL when flushing an encoder that has the - * AV_CODEC_CAP_DELAY capability set. - * If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame - * can have any number of samples. - * If it is not set, frame->nb_samples must be equal to - * avctx->frame_size for all frames except the last. - * The final frame may be smaller than avctx->frame_size. - * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the - * output packet is non-empty, and to 0 if it is - * empty. If the function returns an error, the - * packet can be assumed to be invalid, and the - * value of got_packet_ptr is undefined and should - * not be used. - * @return 0 on success, negative error code on failure - * - * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead. - * If allowed and required, set AVCodecContext.get_encode_buffer to - * a custom function to pass user supplied output buffers. - */ -attribute_deprecated -int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, - const AVFrame *frame, int *got_packet_ptr); - -/** - * Encode a frame of video. - * - * Takes input raw video data from frame and writes the next output packet, if - * available, to avpkt. The output packet does not necessarily contain data for - * the most recent frame, as encoders can delay and reorder input frames - * internally as needed. - * - * @param avctx codec context - * @param avpkt output AVPacket. - * The user can supply an output buffer by setting - * avpkt->data and avpkt->size prior to calling the - * function, but if the size of the user-provided data is not - * large enough, encoding will fail. All other AVPacket fields - * will be reset by the encoder using av_init_packet(). If - * avpkt->data is NULL, the encoder will allocate it. - * The encoder will set avpkt->size to the size of the - * output packet. The returned data (if any) belongs to the - * caller, he is responsible for freeing it. - * - * If this function fails or produces no output, avpkt will be - * freed using av_packet_unref(). - * @param[in] frame AVFrame containing the raw video data to be encoded. - * May be NULL when flushing an encoder that has the - * AV_CODEC_CAP_DELAY capability set. - * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the - * output packet is non-empty, and to 0 if it is - * empty. If the function returns an error, the - * packet can be assumed to be invalid, and the - * value of got_packet_ptr is undefined and should - * not be used. - * @return 0 on success, negative error code on failure - * - * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead. - * If allowed and required, set AVCodecContext.get_encode_buffer to - * a custom function to pass user supplied output buffers. - */ -attribute_deprecated -int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, - const AVFrame *frame, int *got_packet_ptr); -#endif - int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVSubtitle *sub); @@ -3738,71 +3031,6 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, * @} */ -#if FF_API_AVPICTURE -/** - * @addtogroup lavc_picture - * @{ - */ - -/** - * @deprecated unused - */ -attribute_deprecated -int avpicture_alloc(AVPicture *picture, enum AVPixelFormat pix_fmt, int width, int height); - -/** - * @deprecated unused - */ -attribute_deprecated -void avpicture_free(AVPicture *picture); - -/** - * @deprecated use av_image_fill_arrays() instead. - */ -attribute_deprecated -int avpicture_fill(AVPicture *picture, const uint8_t *ptr, - enum AVPixelFormat pix_fmt, int width, int height); - -/** - * @deprecated use av_image_copy_to_buffer() instead. - */ -attribute_deprecated -int avpicture_layout(const AVPicture *src, enum AVPixelFormat pix_fmt, - int width, int height, - unsigned char *dest, int dest_size); - -/** - * @deprecated use av_image_get_buffer_size() instead. - */ -attribute_deprecated -int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height); - -/** - * @deprecated av_image_copy() instead. - */ -attribute_deprecated -void av_picture_copy(AVPicture *dst, const AVPicture *src, - enum AVPixelFormat pix_fmt, int width, int height); - -/** - * @deprecated unused - */ -attribute_deprecated -int av_picture_crop(AVPicture *dst, const AVPicture *src, - enum AVPixelFormat pix_fmt, int top_band, int left_band); - -/** - * @deprecated unused - */ -attribute_deprecated -int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum AVPixelFormat pix_fmt, - int padtop, int padbottom, int padleft, int padright, int *color); - -/** - * @} - */ -#endif - /** * @defgroup lavc_misc Utility functions * @ingroup libavc @@ -3819,15 +3047,6 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, * @{ */ -#if FF_API_GETCHROMA -/** - * @deprecated Use av_pix_fmt_get_chroma_sub_sample - */ - -attribute_deprecated -void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift); -#endif - /** * Return a value representing the fourCC code associated to the * pixel format pix_fmt, or 0 if no associated fourCC code can be @@ -3856,71 +3075,14 @@ enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *p enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr); -#if FF_API_AVCODEC_PIX_FMT -/** - * @deprecated see av_get_pix_fmt_loss() - */ -attribute_deprecated -int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt, - int has_alpha); -/** - * @deprecated see av_find_best_pix_fmt_of_2() - */ -attribute_deprecated -enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, - enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr); - -attribute_deprecated -enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, - enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr); -#endif - enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat * fmt); /** * @} */ -#if FF_API_TAG_STRING -/** - * Put a string representing the codec tag codec_tag in buf. - * - * @param buf buffer to place codec tag in - * @param buf_size size in bytes of buf - * @param codec_tag codec tag to assign - * @return the length of the string that would have been generated if - * enough space had been available, excluding the trailing null - * - * @deprecated see av_fourcc_make_string() and av_fourcc2str(). - */ -attribute_deprecated -size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag); -#endif - void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode); -/** - * Return a name for the specified profile, if available. - * - * @param codec the codec that is searched for the given profile - * @param profile the profile value for which a name is requested - * @return A name for the profile if found, NULL otherwise. - */ -const char *av_get_profile_name(const AVCodec *codec, int profile); - -/** - * Return a name for the specified profile, if available. - * - * @param codec_id the ID of the codec to which the requested profile belongs - * @param profile the profile value for which a name is requested - * @return A name for the profile if found, NULL otherwise. - * - * @note unlike av_get_profile_name(), which searches a list of profiles - * supported by a specific decoder or encoder implementation, this - * function searches the list of profiles from the AVCodecDescriptor - */ -const char *avcodec_profile_name(enum AVCodecID codec_id, int profile); - int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size); int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count); //FIXME func typedef @@ -3956,11 +3118,8 @@ int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, * Reset the internal codec state / flush internal buffers. Should be called * e.g. when seeking or when switching to a different stream. * - * @note for decoders, when refcounted frames are not used - * (i.e. avctx->refcounted_frames is 0), this invalidates the frames previously - * returned from the decoder. When refcounted frames are used, the decoder just - * releases any references it might keep internally, but the caller's reference - * remains valid. + * @note for decoders, this function just releases any references the decoder + * might keep internally, but the caller's references remain valid. * * @note for encoders, this function will only do something if the encoder * declares support for AV_CODEC_CAP_ENCODER_FLUSH. When called, the encoder @@ -3971,32 +3130,6 @@ int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, */ void avcodec_flush_buffers(AVCodecContext *avctx); -/** - * Return codec bits per sample. - * - * @param[in] codec_id the codec - * @return Number of bits per sample or zero if unknown for the given codec. - */ -int av_get_bits_per_sample(enum AVCodecID codec_id); - -/** - * Return the PCM codec associated with a sample format. - * @param be endianness, 0 for little, 1 for big, - * -1 (or anything else) for native - * @return AV_CODEC_ID_PCM_* or AV_CODEC_ID_NONE - */ -enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be); - -/** - * Return codec bits per sample. - * Only return non-zero if the bits per sample is exactly correct, not an - * approximation. - * - * @param[in] codec_id the codec - * @return Number of bits per sample or zero if unknown for the given codec. - */ -int av_get_exact_bits_per_sample(enum AVCodecID codec_id); - /** * Return audio frame duration. * @@ -4007,69 +3140,6 @@ int av_get_exact_bits_per_sample(enum AVCodecID codec_id); */ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes); -/** - * This function is the same as av_get_audio_frame_duration(), except it works - * with AVCodecParameters instead of an AVCodecContext. - */ -int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes); - -#if FF_API_OLD_BSF -typedef struct AVBitStreamFilterContext { - void *priv_data; - const struct AVBitStreamFilter *filter; - AVCodecParserContext *parser; - struct AVBitStreamFilterContext *next; - /** - * Internal default arguments, used if NULL is passed to av_bitstream_filter_filter(). - * Not for access by library users. - */ - char *args; -} AVBitStreamFilterContext; - -/** - * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext) - * is deprecated. Use the new bitstream filtering API (using AVBSFContext). - */ -attribute_deprecated -void av_register_bitstream_filter(AVBitStreamFilter *bsf); -/** - * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext) - * is deprecated. Use av_bsf_get_by_name(), av_bsf_alloc(), and av_bsf_init() - * from the new bitstream filtering API (using AVBSFContext). - */ -attribute_deprecated -AVBitStreamFilterContext *av_bitstream_filter_init(const char *name); -/** - * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext) - * is deprecated. Use av_bsf_send_packet() and av_bsf_receive_packet() from the - * new bitstream filtering API (using AVBSFContext). - */ -attribute_deprecated -int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, - AVCodecContext *avctx, const char *args, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, int keyframe); -/** - * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext) - * is deprecated. Use av_bsf_free() from the new bitstream filtering API (using - * AVBSFContext). - */ -attribute_deprecated -void av_bitstream_filter_close(AVBitStreamFilterContext *bsf); -/** - * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext) - * is deprecated. Use av_bsf_iterate() from the new bitstream filtering API (using - * AVBSFContext). - */ -attribute_deprecated -const AVBitStreamFilter *av_bitstream_filter_next(const AVBitStreamFilter *f); -#endif - -#if FF_API_NEXT -attribute_deprecated -const AVBitStreamFilter *av_bsf_next(void **opaque); -#endif - /* memory */ /** @@ -4087,96 +3157,12 @@ void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size); */ void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size); -/** - * Encode extradata length to a buffer. Used by xiph codecs. - * - * @param s buffer to write to; must be at least (v/255+1) bytes long - * @param v size of extradata in bytes - * @return number of bytes written to the buffer. - */ -unsigned int av_xiphlacing(unsigned char *s, unsigned int v); - -#if FF_API_USER_VISIBLE_AVHWACCEL -/** - * Register the hardware accelerator hwaccel. - * - * @deprecated This function doesn't do anything. - */ -attribute_deprecated -void av_register_hwaccel(AVHWAccel *hwaccel); - -/** - * If hwaccel is NULL, returns the first registered hardware accelerator, - * if hwaccel is non-NULL, returns the next registered hardware accelerator - * after hwaccel, or NULL if hwaccel is the last one. - * - * @deprecated AVHWaccel structures contain no user-serviceable parts, so - * this function should not be used. - */ -attribute_deprecated -AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel); -#endif - -#if FF_API_LOCKMGR -/** - * Lock operation used by lockmgr - * - * @deprecated Deprecated together with av_lockmgr_register(). - */ -enum AVLockOp { - AV_LOCK_CREATE, ///< Create a mutex - AV_LOCK_OBTAIN, ///< Lock the mutex - AV_LOCK_RELEASE, ///< Unlock the mutex - AV_LOCK_DESTROY, ///< Free mutex resources -}; - -/** - * Register a user provided lock manager supporting the operations - * specified by AVLockOp. The "mutex" argument to the function points - * to a (void *) where the lockmgr should store/get a pointer to a user - * allocated mutex. It is NULL upon AV_LOCK_CREATE and equal to the - * value left by the last call for all other ops. If the lock manager is - * unable to perform the op then it should leave the mutex in the same - * state as when it was called and return a non-zero value. However, - * when called with AV_LOCK_DESTROY the mutex will always be assumed to - * have been successfully destroyed. If av_lockmgr_register succeeds - * it will return a non-negative value, if it fails it will return a - * negative value and destroy all mutex and unregister all callbacks. - * av_lockmgr_register is not thread-safe, it must be called from a - * single thread before any calls which make use of locking are used. - * - * @param cb User defined callback. av_lockmgr_register invokes calls - * to this callback and the previously registered callback. - * The callback will be used to create more than one mutex - * each of which must be backed by its own underlying locking - * mechanism (i.e. do not use a single static object to - * implement your lock manager). If cb is set to NULL the - * lockmgr will be unregistered. - * - * @deprecated This function does nothing, and always returns 0. Be sure to - * build with thread support to get basic thread safety. - */ -attribute_deprecated -int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)); -#endif - /** * @return a positive value if s is open (i.e. avcodec_open2() was called on it * with no corresponding avcodec_close()), 0 otherwise. */ int avcodec_is_open(AVCodecContext *s); -/** - * Allocate a CPB properties structure and initialize its fields to default - * values. - * - * @param size if non-NULL, the size of the allocated struct will be written - * here. This is useful for embedding it in side data. - * - * @return the newly allocated struct or NULL on failure - */ -AVCPBProperties *av_cpb_properties_alloc(size_t *size); - /** * @} */ diff --git a/media/ffvpx/libavcodec/avcodec.symbols b/media/ffvpx/libavcodec/avcodec.symbols index 2c37f0df573e..e42dd5ab7f64 100644 --- a/media/ffvpx/libavcodec/avcodec.symbols +++ b/media/ffvpx/libavcodec/avcodec.symbols @@ -1,47 +1,26 @@ av_codec_ffversion -av_codec_get_chroma_intra_matrix -av_codec_get_codec_descriptor -av_codec_get_codec_properties -av_codec_get_lowres -av_codec_get_max_lowres -av_codec_get_pkt_timebase -av_codec_get_seek_preroll av_codec_is_decoder av_codec_is_encoder av_codec_iterate -av_codec_next -av_codec_set_chroma_intra_matrix -av_codec_set_codec_descriptor -av_codec_set_lowres -av_codec_set_pkt_timebase -av_codec_set_seek_preroll -av_copy_packet -av_copy_packet_side_data -av_dup_packet av_fast_padded_malloc av_fast_padded_mallocz -av_free_packet av_get_audio_frame_duration av_get_bits_per_sample -av_get_codec_tag_string av_get_exact_bits_per_sample av_get_pcm_codec av_get_profile_name av_grow_packet -av_hwaccel_next av_hwdevice_ctx_init av_hwdevice_ctx_alloc av_hwdevice_ctx_create_derived av_hwframe_transfer_get_formats av_hwframe_ctx_alloc av_init_packet -av_lockmgr_register av_new_packet av_packet_copy_props av_packet_free_side_data av_packet_from_data av_packet_get_side_data -av_packet_merge_side_data av_packet_move_ref av_packet_new_side_data av_packet_pack_dictionary @@ -49,21 +28,16 @@ av_packet_ref av_packet_rescale_ts av_packet_shrink_side_data av_packet_side_data_name -av_packet_split_side_data av_packet_unpack_dictionary av_packet_unref -av_parser_change av_parser_close av_parser_init -av_parser_next av_parser_parse2 #ifdef MOZ_LIBAV_FFT av_rdft_calc av_rdft_end av_rdft_init #endif -av_register_codec_parser -av_register_hwaccel av_shrink_packet av_vorbis_parse_frame av_vorbis_parse_frame_flags @@ -77,10 +51,7 @@ avcodec_alloc_context3 avcodec_chroma_pos_to_enum avcodec_close avcodec_configuration -avcodec_copy_context -avcodec_decode_audio4 avcodec_decode_subtitle2 -avcodec_decode_video2 avcodec_default_execute avcodec_default_execute2 avcodec_default_get_buffer2 @@ -97,7 +68,6 @@ avcodec_find_encoder_by_name avcodec_flush_buffers avcodec_free_context avcodec_get_class -avcodec_get_context_defaults3 avcodec_get_frame_class avcodec_get_hw_config avcodec_get_name @@ -106,10 +76,12 @@ avcodec_get_type avcodec_is_open avcodec_license avcodec_open2 -avcodec_register -avcodec_register_all avcodec_string avcodec_version avsubtitle_free avcodec_send_packet avcodec_receive_frame +ff_init_vlc_from_lengths +ff_init_vlc_sparse +ff_mpa_freq_tab +ff_mpa_bitrate_tab diff --git a/media/ffvpx/libavcodec/avpacket.c b/media/ffvpx/libavcodec/avpacket.c index b5bac5c5f282..bcbc4166cb40 100644 --- a/media/ffvpx/libavcodec/avpacket.c +++ b/media/ffvpx/libavcodec/avpacket.c @@ -22,13 +22,12 @@ #include #include "libavutil/avassert.h" -#include "libavutil/common.h" -#include "libavutil/internal.h" +#include "libavutil/intreadwrite.h" #include "libavutil/mathematics.h" #include "libavutil/mem.h" +#include "libavutil/rational.h" -#include "bytestream.h" -#include "internal.h" +#include "defs.h" #include "packet.h" #include "packet_internal.h" @@ -39,16 +38,14 @@ void av_init_packet(AVPacket *pkt) pkt->dts = AV_NOPTS_VALUE; pkt->pos = -1; pkt->duration = 0; -#if FF_API_CONVERGENCE_DURATION -FF_DISABLE_DEPRECATION_WARNINGS - pkt->convergence_duration = 0; -FF_ENABLE_DEPRECATION_WARNINGS -#endif pkt->flags = 0; pkt->stream_index = 0; pkt->buf = NULL; pkt->side_data = NULL; pkt->side_data_elems = 0; + pkt->opaque = NULL; + pkt->opaque_ref = NULL; + pkt->time_base = av_make_q(0, 1); } #endif @@ -59,11 +56,12 @@ static void get_packet_defaults(AVPacket *pkt) pkt->pts = AV_NOPTS_VALUE; pkt->dts = AV_NOPTS_VALUE; pkt->pos = -1; + pkt->time_base = av_make_q(0, 1); } AVPacket *av_packet_alloc(void) { - AVPacket *pkt = av_mallocz(sizeof(AVPacket)); + AVPacket *pkt = av_malloc(sizeof(AVPacket)); if (!pkt) return pkt; @@ -142,7 +140,14 @@ int av_grow_packet(AVPacket *pkt, int grow_by) if (new_size + data_offset > pkt->buf->size || !av_buffer_is_writable(pkt->buf)) { - int ret = av_buffer_realloc(&pkt->buf, new_size + data_offset); + int ret; + + // allocate slightly more than requested to avoid excessive + // reallocations + if (new_size + data_offset < INT_MAX - new_size/16) + new_size += new_size/16; + + ret = av_buffer_realloc(&pkt->buf, new_size + data_offset); if (ret < 0) { pkt->data = old_data; return ret; @@ -179,108 +184,6 @@ int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size) return 0; } -#if FF_API_AVPACKET_OLD_API -FF_DISABLE_DEPRECATION_WARNINGS -#define ALLOC_MALLOC(data, size) data = av_malloc(size) -#define ALLOC_BUF(data, size) \ -do { \ - av_buffer_realloc(&pkt->buf, size); \ - data = pkt->buf ? pkt->buf->data : NULL; \ -} while (0) - -#define DUP_DATA(dst, src, size, padding, ALLOC) \ - do { \ - void *data; \ - if (padding) { \ - if ((unsigned)(size) > \ - (unsigned)(size) + AV_INPUT_BUFFER_PADDING_SIZE) \ - goto failed_alloc; \ - ALLOC(data, size + AV_INPUT_BUFFER_PADDING_SIZE); \ - } else { \ - ALLOC(data, size); \ - } \ - if (!data) \ - goto failed_alloc; \ - memcpy(data, src, size); \ - if (padding) \ - memset((uint8_t *)data + size, 0, \ - AV_INPUT_BUFFER_PADDING_SIZE); \ - dst = data; \ - } while (0) - -/* Makes duplicates of data, side_data, but does not copy any other fields */ -static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup) -{ - pkt->data = NULL; - pkt->side_data = NULL; - pkt->side_data_elems = 0; - if (pkt->buf) { - AVBufferRef *ref = av_buffer_ref(src->buf); - if (!ref) - return AVERROR(ENOMEM); - pkt->buf = ref; - pkt->data = ref->data; - } else { - DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF); - } - if (src->side_data_elems && dup) { - pkt->side_data = src->side_data; - pkt->side_data_elems = src->side_data_elems; - } - if (src->side_data_elems && !dup) { - return av_copy_packet_side_data(pkt, src); - } - return 0; - -failed_alloc: - av_packet_unref(pkt); - return AVERROR(ENOMEM); -} - -int av_copy_packet_side_data(AVPacket *pkt, const AVPacket *src) -{ - if (src->side_data_elems) { - int i; - DUP_DATA(pkt->side_data, src->side_data, - src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC); - if (src != pkt) { - memset(pkt->side_data, 0, - src->side_data_elems * sizeof(*src->side_data)); - } - for (i = 0; i < src->side_data_elems; i++) { - DUP_DATA(pkt->side_data[i].data, src->side_data[i].data, - src->side_data[i].size, 1, ALLOC_MALLOC); - pkt->side_data[i].size = src->side_data[i].size; - pkt->side_data[i].type = src->side_data[i].type; - } - } - pkt->side_data_elems = src->side_data_elems; - return 0; - -failed_alloc: - av_packet_unref(pkt); - return AVERROR(ENOMEM); -} - -int av_dup_packet(AVPacket *pkt) -{ - AVPacket tmp_pkt; - - if (!pkt->buf && pkt->data) { - tmp_pkt = *pkt; - return copy_packet_data(pkt, &tmp_pkt, 1); - } - return 0; -} - -int av_copy_packet(AVPacket *dst, const AVPacket *src) -{ - *dst = *src; - return copy_packet_data(dst, src, 0); -} -FF_ENABLE_DEPRECATION_WARNINGS -#endif - void av_packet_free_side_data(AVPacket *pkt) { int i; @@ -290,22 +193,6 @@ void av_packet_free_side_data(AVPacket *pkt) pkt->side_data_elems = 0; } -#if FF_API_AVPACKET_OLD_API -FF_DISABLE_DEPRECATION_WARNINGS -void av_free_packet(AVPacket *pkt) -{ - if (pkt) { - if (pkt->buf) - av_buffer_unref(&pkt->buf); - pkt->data = NULL; - pkt->size = 0; - - av_packet_free_side_data(pkt); - } -} -FF_ENABLE_DEPRECATION_WARNINGS -#endif - int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, uint8_t *data, size_t size) { @@ -341,16 +228,12 @@ int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, - buffer_size_t size) + size_t size) { int ret; uint8_t *data; -#if FF_API_BUFFER_SIZE_T - if ((unsigned)size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) -#else if (size > SIZE_MAX - AV_INPUT_BUFFER_PADDING_SIZE) -#endif return NULL; data = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE); if (!data) @@ -366,7 +249,7 @@ uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, } uint8_t *av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, - buffer_size_t *size) + size_t *size) { int i; @@ -416,102 +299,12 @@ const char *av_packet_side_data_name(enum AVPacketSideDataType type) case AV_PKT_DATA_ICC_PROFILE: return "ICC Profile"; case AV_PKT_DATA_DOVI_CONF: return "DOVI configuration record"; case AV_PKT_DATA_S12M_TIMECODE: return "SMPTE ST 12-1:2014 timecode"; + case AV_PKT_DATA_DYNAMIC_HDR10_PLUS: return "HDR10+ Dynamic Metadata (SMPTE 2094-40)"; } return NULL; } -#if FF_API_MERGE_SD_API - -#define FF_MERGE_MARKER 0x8c4d9d108e25e9feULL - -int av_packet_merge_side_data(AVPacket *pkt){ - if(pkt->side_data_elems){ - AVBufferRef *buf; - int i; - uint8_t *p; - uint64_t size= pkt->size + 8LL + AV_INPUT_BUFFER_PADDING_SIZE; - AVPacket old= *pkt; - for (i=0; i INT_MAX) - return AVERROR(EINVAL); - buf = av_buffer_alloc(size); - if (!buf) - return AVERROR(ENOMEM); - pkt->buf = buf; - pkt->data = p = buf->data; - pkt->size = size - AV_INPUT_BUFFER_PADDING_SIZE; - bytestream_put_buffer(&p, old.data, old.size); - for (i=old.side_data_elems-1; i>=0; i--) { - bytestream_put_buffer(&p, old.side_data[i].data, old.side_data[i].size); - bytestream_put_be32(&p, old.side_data[i].size); - *p++ = old.side_data[i].type | ((i==old.side_data_elems-1)*128); - } - bytestream_put_be64(&p, FF_MERGE_MARKER); - av_assert0(p-pkt->data == pkt->size); - memset(p, 0, AV_INPUT_BUFFER_PADDING_SIZE); - av_packet_unref(&old); - pkt->side_data_elems = 0; - pkt->side_data = NULL; - return 1; - } - return 0; -} - -int av_packet_split_side_data(AVPacket *pkt){ - if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == FF_MERGE_MARKER){ - int i; - unsigned int size; - uint8_t *p; - - p = pkt->data + pkt->size - 8 - 5; - for (i=1; ; i++){ - size = AV_RB32(p); - if (size>INT_MAX - 5 || p - pkt->data < size) - return 0; - if (p[4]&128) - break; - if (p - pkt->data < size + 5) - return 0; - p-= size+5; - } - - if (i > AV_PKT_DATA_NB) - return AVERROR(ERANGE); - - pkt->side_data = av_malloc_array(i, sizeof(*pkt->side_data)); - if (!pkt->side_data) - return AVERROR(ENOMEM); - - p= pkt->data + pkt->size - 8 - 5; - for (i=0; ; i++){ - size= AV_RB32(p); - av_assert0(size<=INT_MAX - 5 && p - pkt->data >= size); - pkt->side_data[i].data = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE); - pkt->side_data[i].size = size; - pkt->side_data[i].type = p[4]&127; - if (!pkt->side_data[i].data) - return AVERROR(ENOMEM); - memcpy(pkt->side_data[i].data, p-size, size); - pkt->size -= size + 5; - if(p[4]&128) - break; - p-= size+5; - } - pkt->size -= 8; - pkt->side_data_elems = i+1; - return 1; - } - return 0; -} -#endif - -#if FF_API_BUFFER_SIZE_T -uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size) -#else uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size) -#endif { uint8_t *data = NULL; *size = 0; @@ -530,11 +323,7 @@ uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size) if (pass) memcpy(data + total_length, str, len); -#if FF_API_BUFFER_SIZE_T - else if (len > INT_MAX - total_length) -#else else if (len > SIZE_MAX - total_length) -#endif return NULL; total_length += len; } @@ -550,12 +339,8 @@ uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size) return data; } -#if FF_API_BUFFER_SIZE_T -int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict) -#else int av_packet_unpack_dictionary(const uint8_t *data, size_t size, AVDictionary **dict) -#endif { const uint8_t *end; int ret; @@ -582,7 +367,7 @@ int av_packet_unpack_dictionary(const uint8_t *data, size_t size, } int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, - buffer_size_t size) + size_t size) { int i; @@ -599,29 +384,32 @@ int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int av_packet_copy_props(AVPacket *dst, const AVPacket *src) { - int i; + int i, ret; dst->pts = src->pts; dst->dts = src->dts; dst->pos = src->pos; dst->duration = src->duration; -#if FF_API_CONVERGENCE_DURATION -FF_DISABLE_DEPRECATION_WARNINGS - dst->convergence_duration = src->convergence_duration; -FF_ENABLE_DEPRECATION_WARNINGS -#endif dst->flags = src->flags; dst->stream_index = src->stream_index; - + dst->opaque = src->opaque; + dst->time_base = src->time_base; + dst->opaque_ref = NULL; dst->side_data = NULL; dst->side_data_elems = 0; + + ret = av_buffer_replace(&dst->opaque_ref, src->opaque_ref); + if (ret < 0) + return ret; + for (i = 0; i < src->side_data_elems; i++) { enum AVPacketSideDataType type = src->side_data[i].type; - buffer_size_t size = src->side_data[i].size; + size_t size = src->side_data[i].size; uint8_t *src_data = src->side_data[i].data; uint8_t *dst_data = av_packet_new_side_data(dst, type, size); if (!dst_data) { + av_buffer_unref(&dst->opaque_ref); av_packet_free_side_data(dst); return AVERROR(ENOMEM); } @@ -634,6 +422,7 @@ FF_ENABLE_DEPRECATION_WARNINGS void av_packet_unref(AVPacket *pkt) { av_packet_free_side_data(pkt); + av_buffer_unref(&pkt->opaque_ref); av_buffer_unref(&pkt->buf); get_packet_defaults(pkt); } @@ -742,27 +531,21 @@ void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb) pkt->dts = av_rescale_q(pkt->dts, src_tb, dst_tb); if (pkt->duration > 0) pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb); -#if FF_API_CONVERGENCE_DURATION -FF_DISABLE_DEPRECATION_WARNINGS - if (pkt->convergence_duration > 0) - pkt->convergence_duration = av_rescale_q(pkt->convergence_duration, src_tb, dst_tb); -FF_ENABLE_DEPRECATION_WARNINGS -#endif } -int avpriv_packet_list_put(PacketList **packet_buffer, - PacketList **plast_pktl, +int avpriv_packet_list_put(PacketList *packet_buffer, AVPacket *pkt, int (*copy)(AVPacket *dst, const AVPacket *src), int flags) { - PacketList *pktl = av_mallocz(sizeof(PacketList)); + PacketListEntry *pktl = av_malloc(sizeof(*pktl)); int ret; if (!pktl) return AVERROR(ENOMEM); if (copy) { + get_packet_defaults(&pktl->pkt); ret = copy(&pktl->pkt, pkt); if (ret < 0) { av_free(pktl); @@ -777,50 +560,49 @@ int avpriv_packet_list_put(PacketList **packet_buffer, av_packet_move_ref(&pktl->pkt, pkt); } - if (*packet_buffer) - (*plast_pktl)->next = pktl; + pktl->next = NULL; + + if (packet_buffer->head) + packet_buffer->tail->next = pktl; else - *packet_buffer = pktl; + packet_buffer->head = pktl; /* Add the packet in the buffered packet list. */ - *plast_pktl = pktl; + packet_buffer->tail = pktl; return 0; } -int avpriv_packet_list_get(PacketList **pkt_buffer, - PacketList **pkt_buffer_end, +int avpriv_packet_list_get(PacketList *pkt_buffer, AVPacket *pkt) { - PacketList *pktl; - if (!*pkt_buffer) + PacketListEntry *pktl = pkt_buffer->head; + if (!pktl) return AVERROR(EAGAIN); - pktl = *pkt_buffer; *pkt = pktl->pkt; - *pkt_buffer = pktl->next; - if (!pktl->next) - *pkt_buffer_end = NULL; + pkt_buffer->head = pktl->next; + if (!pkt_buffer->head) + pkt_buffer->tail = NULL; av_freep(&pktl); return 0; } -void avpriv_packet_list_free(PacketList **pkt_buf, PacketList **pkt_buf_end) +void avpriv_packet_list_free(PacketList *pkt_buf) { - PacketList *tmp = *pkt_buf; + PacketListEntry *tmp = pkt_buf->head; while (tmp) { - PacketList *pktl = tmp; + PacketListEntry *pktl = tmp; tmp = pktl->next; av_packet_unref(&pktl->pkt); av_freep(&pktl); } - *pkt_buf = NULL; - *pkt_buf_end = NULL; + pkt_buf->head = pkt_buf->tail = NULL; } int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type) { uint8_t *side_data; - buffer_size_t side_data_size; + size_t side_data_size; int i; side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &side_data_size); @@ -846,7 +628,7 @@ int ff_side_data_set_prft(AVPacket *pkt, int64_t timestamp) { AVProducerReferenceTime *prft; uint8_t *side_data; - buffer_size_t side_data_size; + size_t side_data_size; side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_PRFT, &side_data_size); if (!side_data) { diff --git a/media/ffvpx/libavcodec/bitstream.c b/media/ffvpx/libavcodec/bitstream.c index e425ffdc9647..36065750559e 100644 --- a/media/ffvpx/libavcodec/bitstream.c +++ b/media/ffvpx/libavcodec/bitstream.c @@ -28,33 +28,13 @@ * bitstream api. */ +#include +#include + +#include "config.h" #include "libavutil/avassert.h" -#include "libavutil/qsort.h" -#include "avcodec.h" -#include "internal.h" -#include "mathops.h" +#include "libavutil/intreadwrite.h" #include "put_bits.h" -#include "vlc.h" - -const uint8_t ff_log2_run[41]={ - 0, 0, 0, 0, 1, 1, 1, 1, - 2, 2, 2, 2, 3, 3, 3, 3, - 4, 4, 5, 5, 6, 6, 7, 7, - 8, 9,10,11,12,13,14,15, -16,17,18,19,20,21,22,23, -24, -}; - -#if FF_API_AVPRIV_PUT_BITS -void avpriv_align_put_bits(PutBitContext *s) -{ - align_put_bits(s); -} -void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length) -{ - ff_copy_bits(pb, src, length); -} -#endif void ff_put_string(PutBitContext *pb, const char *string, int terminate_string) { @@ -90,345 +70,3 @@ void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length) put_bits(pb, bits, AV_RB16(src + 2 * words) >> (16 - bits)); } - -/* VLC decoding */ - -#define GET_DATA(v, table, i, wrap, size) \ -{ \ - const uint8_t *ptr = (const uint8_t *)table + i * wrap; \ - switch(size) { \ - case 1: \ - v = *(const uint8_t *)ptr; \ - break; \ - case 2: \ - v = *(const uint16_t *)ptr; \ - break; \ - case 4: \ - default: \ - av_assert1(size == 4); \ - v = *(const uint32_t *)ptr; \ - break; \ - } \ -} - - -static int alloc_table(VLC *vlc, int size, int use_static) -{ - int index = vlc->table_size; - - vlc->table_size += size; - if (vlc->table_size > vlc->table_allocated) { - if (use_static) - abort(); // cannot do anything, init_vlc() is used with too little memory - vlc->table_allocated += (1 << vlc->bits); - vlc->table = av_realloc_f(vlc->table, vlc->table_allocated, sizeof(VLC_TYPE) * 2); - if (!vlc->table) { - vlc->table_allocated = 0; - vlc->table_size = 0; - return AVERROR(ENOMEM); - } - memset(vlc->table + vlc->table_allocated - (1 << vlc->bits), 0, sizeof(VLC_TYPE) * 2 << vlc->bits); - } - return index; -} - -#define LOCALBUF_ELEMS 1500 // the maximum currently needed is 1296 by rv34 - -typedef struct VLCcode { - uint8_t bits; - VLC_TYPE symbol; - /** codeword, with the first bit-to-be-read in the msb - * (even if intended for a little-endian bitstream reader) */ - uint32_t code; -} VLCcode; - -static int vlc_common_init(VLC *vlc_arg, int nb_bits, int nb_codes, - VLC **vlc, VLC *localvlc, VLCcode **buf, - int flags) -{ - *vlc = vlc_arg; - (*vlc)->bits = nb_bits; - if (flags & INIT_VLC_USE_NEW_STATIC) { - av_assert0(nb_codes <= LOCALBUF_ELEMS); - *localvlc = *vlc_arg; - *vlc = localvlc; - (*vlc)->table_size = 0; - } else { - (*vlc)->table = NULL; - (*vlc)->table_allocated = 0; - (*vlc)->table_size = 0; - } - if (nb_codes > LOCALBUF_ELEMS) { - *buf = av_malloc_array(nb_codes, sizeof(VLCcode)); - if (!*buf) - return AVERROR(ENOMEM); - } - - return 0; -} - -static int compare_vlcspec(const void *a, const void *b) -{ - const VLCcode *sa = a, *sb = b; - return (sa->code >> 1) - (sb->code >> 1); -} -/** - * Build VLC decoding tables suitable for use with get_vlc(). - * - * @param vlc the context to be initialized - * - * @param table_nb_bits max length of vlc codes to store directly in this table - * (Longer codes are delegated to subtables.) - * - * @param nb_codes number of elements in codes[] - * - * @param codes descriptions of the vlc codes - * These must be ordered such that codes going into the same subtable are contiguous. - * Sorting by VLCcode.code is sufficient, though not necessary. - */ -static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, - VLCcode *codes, int flags) -{ - int table_size, table_index, index, code_prefix, symbol, subtable_bits; - int i, j, k, n, nb, inc; - uint32_t code; - volatile VLC_TYPE (* volatile table)[2]; // the double volatile is needed to prevent an internal compiler error in gcc 4.2 - - if (table_nb_bits > 30) - return AVERROR(EINVAL); - table_size = 1 << table_nb_bits; - table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); - ff_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size); - if (table_index < 0) - return table_index; - table = (volatile VLC_TYPE (*)[2])&vlc->table[table_index]; - - /* first pass: map codes and compute auxiliary table sizes */ - for (i = 0; i < nb_codes; i++) { - n = codes[i].bits; - code = codes[i].code; - symbol = codes[i].symbol; - ff_dlog(NULL, "i=%d n=%d code=0x%"PRIx32"\n", i, n, code); - if (n <= table_nb_bits) { - /* no need to add another table */ - j = code >> (32 - table_nb_bits); - nb = 1 << (table_nb_bits - n); - inc = 1; - if (flags & INIT_VLC_OUTPUT_LE) { - j = bitswap_32(code); - inc = 1 << n; - } - for (k = 0; k < nb; k++) { - int bits = table[j][1]; - int oldsym = table[j][0]; - ff_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n); - if ((bits || oldsym) && (bits != n || oldsym != symbol)) { - av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); - return AVERROR_INVALIDDATA; - } - table[j][1] = n; //bits - table[j][0] = symbol; - j += inc; - } - } else { - /* fill auxiliary table recursively */ - n -= table_nb_bits; - code_prefix = code >> (32 - table_nb_bits); - subtable_bits = n; - codes[i].bits = n; - codes[i].code = code << table_nb_bits; - for (k = i+1; k < nb_codes; k++) { - n = codes[k].bits - table_nb_bits; - if (n <= 0) - break; - code = codes[k].code; - if (code >> (32 - table_nb_bits) != code_prefix) - break; - codes[k].bits = n; - codes[k].code = code << table_nb_bits; - subtable_bits = FFMAX(subtable_bits, n); - } - subtable_bits = FFMIN(subtable_bits, table_nb_bits); - j = (flags & INIT_VLC_OUTPUT_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix; - table[j][1] = -subtable_bits; - ff_dlog(NULL, "%4x: n=%d (subtable)\n", - j, codes[i].bits + table_nb_bits); - index = build_table(vlc, subtable_bits, k-i, codes+i, flags); - if (index < 0) - return index; - /* note: realloc has been done, so reload tables */ - table = (volatile VLC_TYPE (*)[2])&vlc->table[table_index]; - table[j][0] = index; //code - if (table[j][0] != index) { - avpriv_request_sample(NULL, "strange codes"); - return AVERROR_PATCHWELCOME; - } - i = k-1; - } - } - - for (i = 0; i < table_size; i++) { - if (table[i][1] == 0) //bits - table[i][0] = -1; //codes - } - - return table_index; -} - -static int vlc_common_end(VLC *vlc, int nb_bits, int nb_codes, VLCcode *codes, - int flags, VLC *vlc_arg, VLCcode localbuf[LOCALBUF_ELEMS]) -{ - int ret = build_table(vlc, nb_bits, nb_codes, codes, flags); - - if (flags & INIT_VLC_USE_NEW_STATIC) { - if (vlc->table_size != vlc->table_allocated && - !(flags & (INIT_VLC_STATIC_OVERLONG & ~INIT_VLC_USE_NEW_STATIC))) - av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", vlc->table_size, vlc->table_allocated); - av_assert0(ret >= 0); - *vlc_arg = *vlc; - } else { - if (codes != localbuf) - av_free(codes); - if (ret < 0) { - av_freep(&vlc->table); - return ret; - } - } - return 0; -} - -/* Build VLC decoding tables suitable for use with get_vlc(). - - 'nb_bits' sets the decoding table size (2^nb_bits) entries. The - bigger it is, the faster is the decoding. But it should not be too - big to save memory and L1 cache. '9' is a good compromise. - - 'nb_codes' : number of vlcs codes - - 'bits' : table which gives the size (in bits) of each vlc code. - - 'codes' : table which gives the bit pattern of of each vlc code. - - 'symbols' : table which gives the values to be returned from get_vlc(). - - 'xxx_wrap' : give the number of bytes between each entry of the - 'bits' or 'codes' tables. - - 'xxx_size' : gives the number of bytes of each entry of the 'bits' - or 'codes' tables. Currently 1,2 and 4 are supported. - - 'wrap' and 'size' make it possible to use any memory configuration and types - (byte/word/long) to store the 'bits', 'codes', and 'symbols' tables. -*/ -int ff_init_vlc_sparse(VLC *vlc_arg, int nb_bits, int nb_codes, - const void *bits, int bits_wrap, int bits_size, - const void *codes, int codes_wrap, int codes_size, - const void *symbols, int symbols_wrap, int symbols_size, - int flags) -{ - VLCcode localbuf[LOCALBUF_ELEMS], *buf = localbuf; - int i, j, ret; - VLC localvlc, *vlc; - - ret = vlc_common_init(vlc_arg, nb_bits, nb_codes, &vlc, &localvlc, - &buf, flags); - if (ret < 0) - return ret; - - av_assert0(symbols_size <= 2 || !symbols); - j = 0; -#define COPY(condition)\ - for (i = 0; i < nb_codes; i++) { \ - unsigned len; \ - GET_DATA(len, bits, i, bits_wrap, bits_size); \ - if (!(condition)) \ - continue; \ - if (len > 3*nb_bits || len > 32) { \ - av_log(NULL, AV_LOG_ERROR, "Too long VLC (%u) in init_vlc\n", len);\ - if (buf != localbuf) \ - av_free(buf); \ - return AVERROR(EINVAL); \ - } \ - buf[j].bits = len; \ - GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size); \ - if (buf[j].code >= (1LL< nb_bits); - // qsort is the slowest part of init_vlc, and could probably be improved or avoided - AV_QSORT(buf, j, struct VLCcode, compare_vlcspec); - COPY(len && len <= nb_bits); - nb_codes = j; - - return vlc_common_end(vlc, nb_bits, nb_codes, buf, - flags, vlc_arg, localbuf); -} - -int ff_init_vlc_from_lengths(VLC *vlc_arg, int nb_bits, int nb_codes, - const int8_t *lens, int lens_wrap, - const void *symbols, int symbols_wrap, int symbols_size, - int offset, int flags, void *logctx) -{ - VLCcode localbuf[LOCALBUF_ELEMS], *buf = localbuf; - VLC localvlc, *vlc; - uint64_t code; - int ret, j, len_max = FFMIN(32, 3 * nb_bits); - - ret = vlc_common_init(vlc_arg, nb_bits, nb_codes, &vlc, &localvlc, - &buf, flags); - if (ret < 0) - return ret; - - j = code = 0; - for (int i = 0; i < nb_codes; i++, lens += lens_wrap) { - int len = *lens; - if (len > 0) { - unsigned sym; - - buf[j].bits = len; - if (symbols) - GET_DATA(sym, symbols, i, symbols_wrap, symbols_size) - else - sym = i; - buf[j].symbol = sym + offset; - buf[j++].code = code; - } else if (len < 0) { - len = -len; - } else - continue; - if (len > len_max || code & ((1U << (32 - len)) - 1)) { - av_log(logctx, AV_LOG_ERROR, "Invalid VLC (length %u)\n", len); - goto fail; - } - code += 1U << (32 - len); - if (code > UINT32_MAX + 1ULL) { - av_log(logctx, AV_LOG_ERROR, "Overdetermined VLC tree\n"); - goto fail; - } - } - return vlc_common_end(vlc, nb_bits, j, buf, - flags, vlc_arg, localbuf); -fail: - if (buf != localbuf) - av_free(buf); - return AVERROR_INVALIDDATA; -} - -void ff_free_vlc(VLC *vlc) -{ - av_freep(&vlc->table); -} diff --git a/media/ffvpx/libavcodec/bitstream_filter.c b/media/ffvpx/libavcodec/bitstream_filter.c deleted file mode 100644 index ca11ed371e37..000000000000 --- a/media/ffvpx/libavcodec/bitstream_filter.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * 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 - -#include "avcodec.h" -#include "libavutil/internal.h" -#include "libavutil/mem.h" -#include "libavutil/opt.h" - -#if FF_API_OLD_BSF -FF_DISABLE_DEPRECATION_WARNINGS - -const AVBitStreamFilter *av_bitstream_filter_next(const AVBitStreamFilter *f) -{ - const AVBitStreamFilter *filter = NULL; - void *opaque = NULL; - - while (filter != f) - filter = av_bsf_iterate(&opaque); - - return av_bsf_iterate(&opaque); -} - -void av_register_bitstream_filter(AVBitStreamFilter *bsf) -{ -} - -typedef struct BSFCompatContext { - AVBSFContext *ctx; - int extradata_updated; -} BSFCompatContext; - -AVBitStreamFilterContext *av_bitstream_filter_init(const char *name) -{ - AVBitStreamFilterContext *ctx = NULL; - BSFCompatContext *priv = NULL; - const AVBitStreamFilter *bsf; - - bsf = av_bsf_get_by_name(name); - if (!bsf) - return NULL; - - ctx = av_mallocz(sizeof(*ctx)); - if (!ctx) - return NULL; - - priv = av_mallocz(sizeof(*priv)); - if (!priv) - goto fail; - - - ctx->filter = bsf; - ctx->priv_data = priv; - - return ctx; - -fail: - if (priv) - av_bsf_free(&priv->ctx); - av_freep(&priv); - av_freep(&ctx); - return NULL; -} - -void av_bitstream_filter_close(AVBitStreamFilterContext *bsfc) -{ - BSFCompatContext *priv; - - if (!bsfc) - return; - - priv = bsfc->priv_data; - - av_bsf_free(&priv->ctx); - av_freep(&bsfc->priv_data); - av_free(bsfc); -} - -int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, - AVCodecContext *avctx, const char *args, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, int keyframe) -{ - BSFCompatContext *priv = bsfc->priv_data; - AVPacket pkt = { 0 }; - int ret; - - if (!priv->ctx) { - ret = av_bsf_alloc(bsfc->filter, &priv->ctx); - if (ret < 0) - return ret; - - ret = avcodec_parameters_from_context(priv->ctx->par_in, avctx); - if (ret < 0) - return ret; - - priv->ctx->time_base_in = avctx->time_base; - - if (bsfc->args && bsfc->filter->priv_class) { - const AVOption *opt = av_opt_next(priv->ctx->priv_data, NULL); - const char * shorthand[2] = {NULL}; - - if (opt) - shorthand[0] = opt->name; - - ret = av_opt_set_from_string(priv->ctx->priv_data, bsfc->args, shorthand, "=", ":"); - if (ret < 0) - return ret; - } - - ret = av_bsf_init(priv->ctx); - if (ret < 0) - return ret; - } - - pkt.data = (uint8_t *)buf; - pkt.size = buf_size; - - ret = av_bsf_send_packet(priv->ctx, &pkt); - if (ret < 0) - return ret; - - *poutbuf = NULL; - *poutbuf_size = 0; - - ret = av_bsf_receive_packet(priv->ctx, &pkt); - if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) - return 0; - else if (ret < 0) - return ret; - - *poutbuf = av_malloc(pkt.size + AV_INPUT_BUFFER_PADDING_SIZE); - if (!*poutbuf) { - av_packet_unref(&pkt); - return AVERROR(ENOMEM); - } - - *poutbuf_size = pkt.size; - memcpy(*poutbuf, pkt.data, pkt.size); - - av_packet_unref(&pkt); - - /* drain all the remaining packets we cannot return */ - while (ret >= 0) { - ret = av_bsf_receive_packet(priv->ctx, &pkt); - av_packet_unref(&pkt); - } - - if (!priv->extradata_updated) { - /* update extradata in avctx from the output codec parameters */ - if (priv->ctx->par_out->extradata_size && (!args || !strstr(args, "private_spspps_buf"))) { - av_freep(&avctx->extradata); - avctx->extradata_size = 0; - avctx->extradata = av_mallocz(priv->ctx->par_out->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); - if (!avctx->extradata) - return AVERROR(ENOMEM); - memcpy(avctx->extradata, priv->ctx->par_out->extradata, priv->ctx->par_out->extradata_size); - avctx->extradata_size = priv->ctx->par_out->extradata_size; - } - - priv->extradata_updated = 1; - } - - return 1; -} -FF_ENABLE_DEPRECATION_WARNINGS -#endif diff --git a/media/ffvpx/libavcodec/bitstream_filters.c b/media/ffvpx/libavcodec/bitstream_filters.c index 02d33abb18b3..444423ae93c5 100644 --- a/media/ffvpx/libavcodec/bitstream_filters.c +++ b/media/ffvpx/libavcodec/bitstream_filters.c @@ -16,71 +16,68 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "config.h" +#include +#include -#include "libavutil/common.h" #include "libavutil/log.h" -#include "avcodec.h" +#include "bsf.h" #include "bsf_internal.h" -extern const AVBitStreamFilter ff_aac_adtstoasc_bsf; -extern const AVBitStreamFilter ff_av1_frame_merge_bsf; -extern const AVBitStreamFilter ff_av1_frame_split_bsf; -extern const AVBitStreamFilter ff_av1_metadata_bsf; -extern const AVBitStreamFilter ff_chomp_bsf; -extern const AVBitStreamFilter ff_dump_extradata_bsf; -extern const AVBitStreamFilter ff_dca_core_bsf; -extern const AVBitStreamFilter ff_eac3_core_bsf; -extern const AVBitStreamFilter ff_extract_extradata_bsf; -extern const AVBitStreamFilter ff_filter_units_bsf; -extern const AVBitStreamFilter ff_h264_metadata_bsf; -extern const AVBitStreamFilter ff_h264_mp4toannexb_bsf; -extern const AVBitStreamFilter ff_h264_redundant_pps_bsf; -extern const AVBitStreamFilter ff_hapqa_extract_bsf; -extern const AVBitStreamFilter ff_hevc_metadata_bsf; -extern const AVBitStreamFilter ff_hevc_mp4toannexb_bsf; -extern const AVBitStreamFilter ff_imx_dump_header_bsf; -extern const AVBitStreamFilter ff_mjpeg2jpeg_bsf; -extern const AVBitStreamFilter ff_mjpega_dump_header_bsf; -extern const AVBitStreamFilter ff_mp3_header_decompress_bsf; -extern const AVBitStreamFilter ff_mpeg2_metadata_bsf; -extern const AVBitStreamFilter ff_mpeg4_unpack_bframes_bsf; -extern const AVBitStreamFilter ff_mov2textsub_bsf; -extern const AVBitStreamFilter ff_noise_bsf; -extern const AVBitStreamFilter ff_null_bsf; -extern const AVBitStreamFilter ff_opus_metadata_bsf; -extern const AVBitStreamFilter ff_pcm_rechunk_bsf; -extern const AVBitStreamFilter ff_prores_metadata_bsf; -extern const AVBitStreamFilter ff_remove_extradata_bsf; -extern const AVBitStreamFilter ff_setts_bsf; -extern const AVBitStreamFilter ff_text2movsub_bsf; -extern const AVBitStreamFilter ff_trace_headers_bsf; -extern const AVBitStreamFilter ff_truehd_core_bsf; -extern const AVBitStreamFilter ff_vp9_metadata_bsf; -extern const AVBitStreamFilter ff_vp9_raw_reorder_bsf; -extern const AVBitStreamFilter ff_vp9_superframe_bsf; -extern const AVBitStreamFilter ff_vp9_superframe_split_bsf; +extern const FFBitStreamFilter ff_aac_adtstoasc_bsf; +extern const FFBitStreamFilter ff_av1_frame_merge_bsf; +extern const FFBitStreamFilter ff_av1_frame_split_bsf; +extern const FFBitStreamFilter ff_av1_metadata_bsf; +extern const FFBitStreamFilter ff_chomp_bsf; +extern const FFBitStreamFilter ff_dump_extradata_bsf; +extern const FFBitStreamFilter ff_dca_core_bsf; +extern const FFBitStreamFilter ff_dv_error_marker_bsf; +extern const FFBitStreamFilter ff_eac3_core_bsf; +extern const FFBitStreamFilter ff_extract_extradata_bsf; +extern const FFBitStreamFilter ff_filter_units_bsf; +extern const FFBitStreamFilter ff_h264_metadata_bsf; +extern const FFBitStreamFilter ff_h264_mp4toannexb_bsf; +extern const FFBitStreamFilter ff_h264_redundant_pps_bsf; +extern const FFBitStreamFilter ff_hapqa_extract_bsf; +extern const FFBitStreamFilter ff_hevc_metadata_bsf; +extern const FFBitStreamFilter ff_hevc_mp4toannexb_bsf; +extern const FFBitStreamFilter ff_imx_dump_header_bsf; +extern const FFBitStreamFilter ff_mjpeg2jpeg_bsf; +extern const FFBitStreamFilter ff_mjpega_dump_header_bsf; +extern const FFBitStreamFilter ff_mp3_header_decompress_bsf; +extern const FFBitStreamFilter ff_mpeg2_metadata_bsf; +extern const FFBitStreamFilter ff_mpeg4_unpack_bframes_bsf; +extern const FFBitStreamFilter ff_mov2textsub_bsf; +extern const FFBitStreamFilter ff_noise_bsf; +extern const FFBitStreamFilter ff_null_bsf; +extern const FFBitStreamFilter ff_opus_metadata_bsf; +extern const FFBitStreamFilter ff_pcm_rechunk_bsf; +extern const FFBitStreamFilter ff_pgs_frame_merge_bsf; +extern const FFBitStreamFilter ff_prores_metadata_bsf; +extern const FFBitStreamFilter ff_remove_extradata_bsf; +extern const FFBitStreamFilter ff_setts_bsf; +extern const FFBitStreamFilter ff_text2movsub_bsf; +extern const FFBitStreamFilter ff_trace_headers_bsf; +extern const FFBitStreamFilter ff_truehd_core_bsf; +extern const FFBitStreamFilter ff_vp9_metadata_bsf; +extern const FFBitStreamFilter ff_vp9_raw_reorder_bsf; +extern const FFBitStreamFilter ff_vp9_superframe_bsf; +extern const FFBitStreamFilter ff_vp9_superframe_split_bsf; #include "libavcodec/bsf_list.c" const AVBitStreamFilter *av_bsf_iterate(void **opaque) { uintptr_t i = (uintptr_t)*opaque; - const AVBitStreamFilter *f = bitstream_filters[i]; + const FFBitStreamFilter *f = bitstream_filters[i]; - if (f) + if (f) { *opaque = (void*)(i + 1); - - return f; + return &f->p; + } + return NULL; } -#if FF_API_NEXT -const AVBitStreamFilter *av_bsf_next(void **opaque) { - return av_bsf_iterate(opaque); -} -#endif - const AVBitStreamFilter *av_bsf_get_by_name(const char *name) { const AVBitStreamFilter *f = NULL; @@ -97,28 +94,6 @@ const AVBitStreamFilter *av_bsf_get_by_name(const char *name) return NULL; } -#if FF_API_CHILD_CLASS_NEXT -const AVClass *ff_bsf_child_class_next(const AVClass *prev) -{ - const AVBitStreamFilter *f = NULL; - void *i = 0; - - /* find the filter that corresponds to prev */ - while (prev && (f = av_bsf_iterate(&i))) { - if (f->priv_class == prev) { - break; - } - } - - /* find next filter with priv options */ - while ((f = av_bsf_iterate(&i))) { - if (f->priv_class) - return f->priv_class; - } - return NULL; -} -#endif - const AVClass *ff_bsf_child_class_iterate(void **opaque) { const AVBitStreamFilter *f; diff --git a/media/ffvpx/libavcodec/blockdsp.h b/media/ffvpx/libavcodec/blockdsp.h index 26fc2ea13b6a..58eecffb0733 100644 --- a/media/ffvpx/libavcodec/blockdsp.h +++ b/media/ffvpx/libavcodec/blockdsp.h @@ -23,7 +23,6 @@ #include #include "avcodec.h" -#include "version.h" /* add and put pixel (decoding) * Block sizes for op_pixels_func are 8x4,8x8 16x8 16x16. diff --git a/media/ffvpx/libavcodec/bsf.c b/media/ffvpx/libavcodec/bsf.c index 157984bd9a24..42cc1b5ab0c6 100644 --- a/media/ffvpx/libavcodec/bsf.c +++ b/media/ffvpx/libavcodec/bsf.c @@ -18,6 +18,8 @@ #include +#include "config_components.h" + #include "libavutil/avassert.h" #include "libavutil/log.h" #include "libavutil/mem.h" @@ -32,29 +34,40 @@ #define IS_EMPTY(pkt) (!(pkt)->data && !(pkt)->side_data_elems) -struct AVBSFInternal { +static av_always_inline const FFBitStreamFilter *ff_bsf(const AVBitStreamFilter *bsf) +{ + return (const FFBitStreamFilter*)bsf; +} + +typedef struct FFBSFContext { + AVBSFContext pub; AVPacket *buffer_pkt; int eof; -}; +} FFBSFContext; + +static av_always_inline FFBSFContext *ffbsfcontext(AVBSFContext *ctx) +{ + return (FFBSFContext *)ctx; +} void av_bsf_free(AVBSFContext **pctx) { AVBSFContext *ctx; + FFBSFContext *bsfi; if (!pctx || !*pctx) return; - ctx = *pctx; + ctx = *pctx; + bsfi = ffbsfcontext(ctx); - if (ctx->internal) { - if (ctx->filter->close) - ctx->filter->close(ctx); - av_packet_free(&ctx->internal->buffer_pkt); - av_freep(&ctx->internal); + if (ctx->priv_data) { + if (ff_bsf(ctx->filter)->close) + ff_bsf(ctx->filter)->close(ctx); + if (ctx->filter->priv_class) + av_opt_free(ctx->priv_data); + av_freep(&ctx->priv_data); } - if (ctx->filter->priv_class && ctx->priv_data) - av_opt_free(ctx->priv_data); - - av_freep(&ctx->priv_data); + av_packet_free(&bsfi->buffer_pkt); avcodec_parameters_free(&ctx->par_in); avcodec_parameters_free(&ctx->par_out); @@ -80,9 +93,6 @@ static const AVClass bsf_class = { .item_name = bsf_to_name, .version = LIBAVUTIL_VERSION_INT, .child_next = bsf_child_next, -#if FF_API_CHILD_CLASS_NEXT - .child_class_next = ff_bsf_child_class_next, -#endif .child_class_iterate = ff_bsf_child_class_iterate, .category = AV_CLASS_CATEGORY_BITSTREAM_FILTER, }; @@ -95,12 +105,13 @@ const AVClass *av_bsf_get_class(void) int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx) { AVBSFContext *ctx; - AVBSFInternal *bsfi; + FFBSFContext *bsfi; int ret; - ctx = av_mallocz(sizeof(*ctx)); - if (!ctx) + bsfi = av_mallocz(sizeof(*bsfi)); + if (!bsfi) return AVERROR(ENOMEM); + ctx = &bsfi->pub; ctx->av_class = &bsf_class; ctx->filter = filter; @@ -112,8 +123,8 @@ int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx) goto fail; } /* allocate priv data and init private options */ - if (filter->priv_data_size) { - ctx->priv_data = av_mallocz(filter->priv_data_size); + if (ff_bsf(filter)->priv_data_size) { + ctx->priv_data = av_mallocz(ff_bsf(filter)->priv_data_size); if (!ctx->priv_data) { ret = AVERROR(ENOMEM); goto fail; @@ -123,15 +134,6 @@ int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx) av_opt_set_defaults(ctx->priv_data); } } - /* Allocate AVBSFInternal; must happen after priv_data has been allocated - * so that a filter->close needing priv_data is never called without. */ - bsfi = av_mallocz(sizeof(*bsfi)); - if (!bsfi) { - ret = AVERROR(ENOMEM); - goto fail; - } - ctx->internal = bsfi; - bsfi->buffer_pkt = av_packet_alloc(); if (!bsfi->buffer_pkt) { ret = AVERROR(ENOMEM); @@ -160,9 +162,9 @@ int av_bsf_init(AVBSFContext *ctx) "bitstream filter '%s'. Supported codecs are: ", desc ? desc->name : "unknown", ctx->par_in->codec_id, ctx->filter->name); for (i = 0; ctx->filter->codec_ids[i] != AV_CODEC_ID_NONE; i++) { - desc = avcodec_descriptor_get(ctx->filter->codec_ids[i]); + enum AVCodecID codec_id = ctx->filter->codec_ids[i]; av_log(ctx, AV_LOG_ERROR, "%s (%d) ", - desc ? desc->name : "unknown", ctx->filter->codec_ids[i]); + avcodec_get_name(codec_id), codec_id); } av_log(ctx, AV_LOG_ERROR, "\n"); return AVERROR(EINVAL); @@ -177,8 +179,8 @@ int av_bsf_init(AVBSFContext *ctx) ctx->time_base_out = ctx->time_base_in; - if (ctx->filter->init) { - ret = ctx->filter->init(ctx); + if (ff_bsf(ctx->filter)->init) { + ret = ff_bsf(ctx->filter)->init(ctx); if (ret < 0) return ret; } @@ -188,22 +190,24 @@ int av_bsf_init(AVBSFContext *ctx) void av_bsf_flush(AVBSFContext *ctx) { - AVBSFInternal *bsfi = ctx->internal; + FFBSFContext *const bsfi = ffbsfcontext(ctx); bsfi->eof = 0; av_packet_unref(bsfi->buffer_pkt); - if (ctx->filter->flush) - ctx->filter->flush(ctx); + if (ff_bsf(ctx->filter)->flush) + ff_bsf(ctx->filter)->flush(ctx); } int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt) { - AVBSFInternal *bsfi = ctx->internal; + FFBSFContext *const bsfi = ffbsfcontext(ctx); int ret; if (!pkt || IS_EMPTY(pkt)) { + if (pkt) + av_packet_unref(pkt); bsfi->eof = 1; return 0; } @@ -226,12 +230,12 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt) int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt) { - return ctx->filter->filter(ctx, pkt); + return ff_bsf(ctx->filter)->filter(ctx, pkt); } int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt) { - AVBSFInternal *bsfi = ctx->internal; + FFBSFContext *const bsfi = ffbsfcontext(ctx); AVPacket *tmp_pkt; if (bsfi->eof) @@ -252,7 +256,7 @@ int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt) int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt) { - AVBSFInternal *bsfi = ctx->internal; + FFBSFContext *const bsfi = ffbsfcontext(ctx); if (bsfi->eof) return AVERROR_EOF; @@ -399,10 +403,10 @@ static const AVClass bsf_list_class = { .version = LIBAVUTIL_VERSION_INT, }; -const AVBitStreamFilter ff_list_bsf = { - .name = "bsf_list", +static const FFBitStreamFilter list_bsf = { + .p.name = "bsf_list", + .p.priv_class = &bsf_list_class, .priv_data_size = sizeof(BSFListContext), - .priv_class = &bsf_list_class, .init = bsf_list_init, .filter = bsf_list_filter, .flush = bsf_list_flush, @@ -495,7 +499,7 @@ int av_bsf_list_finalize(AVBSFList **lst, AVBSFContext **bsf) goto end; } - ret = av_bsf_alloc(&ff_list_bsf, bsf); + ret = av_bsf_alloc(&list_bsf.p, bsf); if (ret < 0) return ret; @@ -523,7 +527,6 @@ static int bsf_parse_single(char *str, AVBSFList *bsf_lst) int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst) { AVBSFList *lst; - char *bsf_str, *buf, *dup, *saveptr; int ret; if (!str) @@ -533,28 +536,27 @@ int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst) if (!lst) return AVERROR(ENOMEM); - if (!(dup = buf = av_strdup(str))) { - ret = AVERROR(ENOMEM); - goto end; - } - - while (bsf_str = av_strtok(buf, ",", &saveptr)) { + do { + char *bsf_str = av_get_token(&str, ","); ret = bsf_parse_single(bsf_str, lst); + av_free(bsf_str); if (ret < 0) goto end; - - buf = NULL; - } + } while (*str && *++str); ret = av_bsf_list_finalize(&lst, bsf_lst); end: if (ret < 0) av_bsf_list_free(&lst); - av_free(dup); return ret; } int av_bsf_get_null_filter(AVBSFContext **bsf) { - return av_bsf_alloc(&ff_list_bsf, bsf); +#if CONFIG_NULL_BSF + extern const FFBitStreamFilter ff_null_bsf; + return av_bsf_alloc(&ff_null_bsf.p, bsf); +#else + return av_bsf_alloc(&list_bsf.p, bsf); +#endif } diff --git a/media/ffvpx/libavcodec/bsf.h b/media/ffvpx/libavcodec/bsf.h index 3b5faa85cb51..69d91a16abf8 100644 --- a/media/ffvpx/libavcodec/bsf.h +++ b/media/ffvpx/libavcodec/bsf.h @@ -30,12 +30,31 @@ #include "packet.h" /** - * @addtogroup lavc_core + * @defgroup lavc_bsf Bitstream filters + * @ingroup libavc + * + * Bitstream filters transform encoded media data without decoding it. This + * allows e.g. manipulating various header values. Bitstream filters operate on + * @ref AVPacket "AVPackets". + * + * The bitstream filtering API is centered around two structures: + * AVBitStreamFilter and AVBSFContext. The former represents a bitstream filter + * in abstract, the latter a specific filtering process. Obtain an + * AVBitStreamFilter using av_bsf_get_by_name() or av_bsf_iterate(), then pass + * it to av_bsf_alloc() to create an AVBSFContext. Fill in the user-settable + * AVBSFContext fields, as described in its documentation, then call + * av_bsf_init() to prepare the filter context for use. + * + * Submit packets for filtering using av_bsf_send_packet(), obtain filtered + * results with av_bsf_receive_packet(). When no more input packets will be + * sent, submit a NULL AVPacket to signal the end of the stream to the filter. + * av_bsf_receive_packet() will then return trailing packets, if any are + * produced by the filter. + * + * Finally, free the filter context with av_bsf_free(). * @{ */ -typedef struct AVBSFInternal AVBSFInternal; - /** * The bitstream filter state. * @@ -57,12 +76,6 @@ typedef struct AVBSFContext { */ const struct AVBitStreamFilter *filter; - /** - * Opaque libavcodec internal data. Must not be touched by the caller in any - * way. - */ - AVBSFInternal *internal; - /** * Opaque filter-specific private data. If filter->priv_class is non-NULL, * this is an AVOptions-enabled struct. @@ -115,20 +128,6 @@ typedef struct AVBitStreamFilter { * code to this class. */ const AVClass *priv_class; - - /***************************************************************** - * No fields below this line are part of the public API. They - * may not be used outside of libavcodec and can be changed and - * removed at will. - * New public fields should be added right above. - ***************************************************************** - */ - - int priv_data_size; - int (*init)(AVBSFContext *ctx); - int (*filter)(AVBSFContext *ctx, AVPacket *pkt); - void (*close)(AVBSFContext *ctx); - void (*flush)(AVBSFContext *ctx); } AVBitStreamFilter; /** @@ -154,9 +153,9 @@ const AVBitStreamFilter *av_bsf_iterate(void **opaque); * av_bsf_init() before sending any data to the filter. * * @param filter the filter for which to allocate an instance. - * @param ctx a pointer into which the pointer to the newly-allocated context - * will be written. It must be freed with av_bsf_free() after the - * filtering is done. + * @param[out] ctx a pointer into which the pointer to the newly-allocated context + * will be written. It must be freed with av_bsf_free() after the + * filtering is done. * * @return 0 on success, a negative AVERROR code on failure */ @@ -182,9 +181,11 @@ int av_bsf_init(AVBSFContext *ctx); * sending more empty packets does nothing) and will cause the filter to output * any packets it may have buffered internally. * - * @return 0 on success. AVERROR(EAGAIN) if packets need to be retrieved from the - * filter (using av_bsf_receive_packet()) before new input can be consumed. Another - * negative AVERROR value if an error occurs. + * @return + * - 0 on success. + * - AVERROR(EAGAIN) if packets need to be retrieved from the filter (using + * av_bsf_receive_packet()) before new input can be consumed. + * - Another negative AVERROR value if an error occurs. */ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt); @@ -201,10 +202,12 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt); * overwritten by the returned data. On failure, pkt is not * touched. * - * @return 0 on success. AVERROR(EAGAIN) if more packets need to be sent to the - * filter (using av_bsf_send_packet()) to get more output. AVERROR_EOF if there - * will be no further output from the filter. Another negative AVERROR value if - * an error occurs. + * @return + * - 0 on success. + * - AVERROR(EAGAIN) if more packets need to be sent to the filter (using + * av_bsf_send_packet()) to get more output. + * - AVERROR_EOF if there will be no further output from the filter. + * - Another negative AVERROR value if an error occurs. * * @note one input packet may result in several output packets, so after sending * a packet with av_bsf_send_packet(), this function needs to be called diff --git a/media/ffvpx/libavcodec/bsf_internal.h b/media/ffvpx/libavcodec/bsf_internal.h index b78c134bdda6..922b03c01be0 100644 --- a/media/ffvpx/libavcodec/bsf_internal.h +++ b/media/ffvpx/libavcodec/bsf_internal.h @@ -24,6 +24,19 @@ #include "bsf.h" #include "packet.h" +typedef struct FFBitStreamFilter { + /** + * The public AVBitStreamFilter. See bsf.h for it. + */ + AVBitStreamFilter p; + + int priv_data_size; + int (*init)(AVBSFContext *ctx); + int (*filter)(AVBSFContext *ctx, AVPacket *pkt); + void (*close)(AVBSFContext *ctx); + void (*flush)(AVBSFContext *ctx); +} FFBitStreamFilter; + /** * Called by the bitstream filters to get the next packet for filtering. * The filter is responsible for either freeing the packet or passing it to the @@ -42,10 +55,6 @@ int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt); */ int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt); -#if FF_API_CHILD_CLASS_NEXT -const AVClass *ff_bsf_child_class_next(const AVClass *prev); -#endif - const AVClass *ff_bsf_child_class_iterate(void **opaque); #endif /* AVCODEC_BSF_INTERNAL_H */ diff --git a/media/ffvpx/libavcodec/bsf_list.c b/media/ffvpx/libavcodec/bsf_list.c index 92d9948b2952..21ab5ccb5702 100644 --- a/media/ffvpx/libavcodec/bsf_list.c +++ b/media/ffvpx/libavcodec/bsf_list.c @@ -1,6 +1,3 @@ -static const AVBitStreamFilter * const bitstream_filters[] = { - &ff_null_bsf, -#if CONFIG_VP9_SUPERFRAME_SPLIT_BSF +static const FFBitStreamFilter * const bitstream_filters[] = { &ff_vp9_superframe_split_bsf, -#endif NULL }; diff --git a/media/ffvpx/libavcodec/cbs.c b/media/ffvpx/libavcodec/cbs.c index c7f69845fb27..e829caa0a0f9 100644 --- a/media/ffvpx/libavcodec/cbs.c +++ b/media/ffvpx/libavcodec/cbs.c @@ -25,6 +25,7 @@ #include "libavutil/common.h" #include "libavutil/opt.h" +#include "avcodec.h" #include "cbs.h" #include "cbs_internal.h" @@ -293,6 +294,19 @@ int ff_cbs_read_packet(CodedBitstreamContext *ctx, pkt->data, pkt->size, 0); } +int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + const AVPacket *pkt) +{ + size_t side_data_size; + const uint8_t *side_data = + av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, + &side_data_size); + + return cbs_read_data(ctx, frag, NULL, + side_data, side_data_size, 1); +} + int ff_cbs_read(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const uint8_t *data, size_t size) @@ -301,6 +315,28 @@ int ff_cbs_read(CodedBitstreamContext *ctx, data, size, 0); } +/** + * Allocate a new internal data buffer of the given size in the unit. + * + * The data buffer will have input padding. + */ +static int cbs_alloc_unit_data(CodedBitstreamUnit *unit, + size_t size) +{ + av_assert0(!unit->data && !unit->data_ref); + + unit->data_ref = av_buffer_alloc(size + AV_INPUT_BUFFER_PADDING_SIZE); + if (!unit->data_ref) + return AVERROR(ENOMEM); + + unit->data = unit->data_ref->data; + unit->data_size = size; + + memset(unit->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE); + + return 0; +} + static int cbs_write_unit_data(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit) { @@ -346,7 +382,7 @@ static int cbs_write_unit_data(CodedBitstreamContext *ctx, flush_put_bits(&pbc); - ret = ff_cbs_alloc_unit_data(unit, put_bits_count(&pbc) / 8); + ret = cbs_alloc_unit_data(unit, put_bytes_output(&pbc)); if (ret < 0) return ret; @@ -679,23 +715,6 @@ int ff_cbs_alloc_unit_content(CodedBitstreamUnit *unit, return 0; } -int ff_cbs_alloc_unit_data(CodedBitstreamUnit *unit, - size_t size) -{ - av_assert0(!unit->data && !unit->data_ref); - - unit->data_ref = av_buffer_alloc(size + AV_INPUT_BUFFER_PADDING_SIZE); - if (!unit->data_ref) - return AVERROR(ENOMEM); - - unit->data = unit->data_ref->data; - unit->data_size = size; - - memset(unit->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE); - - return 0; -} - static int cbs_insert_unit(CodedBitstreamFragment *frag, int position) { @@ -770,18 +789,16 @@ int ff_cbs_insert_unit_content(CodedBitstreamFragment *frag, return 0; } -int ff_cbs_insert_unit_data(CodedBitstreamFragment *frag, - int position, - CodedBitstreamUnitType type, - uint8_t *data, size_t data_size, - AVBufferRef *data_buf) +static int cbs_insert_unit_data(CodedBitstreamFragment *frag, + CodedBitstreamUnitType type, + uint8_t *data, size_t data_size, + AVBufferRef *data_buf, + int position) { CodedBitstreamUnit *unit; AVBufferRef *data_ref; int err; - if (position == -1) - position = frag->nb_units; av_assert0(position >= 0 && position <= frag->nb_units); if (data_buf) @@ -809,6 +826,16 @@ int ff_cbs_insert_unit_data(CodedBitstreamFragment *frag, return 0; } +int ff_cbs_append_unit_data(CodedBitstreamFragment *frag, + CodedBitstreamUnitType type, + uint8_t *data, size_t data_size, + AVBufferRef *data_buf) +{ + return cbs_insert_unit_data(frag, type, + data, data_size, data_buf, + frag->nb_units); +} + void ff_cbs_delete_unit(CodedBitstreamFragment *frag, int position) { diff --git a/media/ffvpx/libavcodec/cbs.h b/media/ffvpx/libavcodec/cbs.h index f022282b75b1..5583063b5e93 100644 --- a/media/ffvpx/libavcodec/cbs.h +++ b/media/ffvpx/libavcodec/cbs.h @@ -24,7 +24,9 @@ #include "libavutil/buffer.h" -#include "avcodec.h" +#include "codec_id.h" +#include "codec_par.h" +#include "packet.h" /* @@ -40,6 +42,7 @@ * bitstream. */ +struct AVCodecContext; struct CodedBitstreamType; /** @@ -271,7 +274,11 @@ int ff_cbs_read_extradata(CodedBitstreamContext *ctx, */ int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, - const AVCodecContext *avctx); + const struct AVCodecContext *avctx); + +int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + const AVPacket *pkt); /** * Read the data bitstream from a packet into a fragment, then @@ -373,15 +380,6 @@ int ff_cbs_alloc_unit_content(CodedBitstreamUnit *unit, int ff_cbs_alloc_unit_content2(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit); - -/** - * Allocate a new internal data buffer of the given size in the unit. - * - * The data buffer will have input padding. - */ -int ff_cbs_alloc_unit_data(CodedBitstreamUnit *unit, - size_t size); - /** * Insert a new unit into a fragment with the given content. * @@ -395,14 +393,13 @@ int ff_cbs_insert_unit_content(CodedBitstreamFragment *frag, AVBufferRef *content_buf); /** - * Insert a new unit into a fragment with the given data bitstream. + * Add a new unit to a fragment with the given data bitstream. * * If data_buf is not supplied then data must have been allocated with * av_malloc() and will on success become owned by the unit after this * call or freed on error. */ -int ff_cbs_insert_unit_data(CodedBitstreamFragment *frag, - int position, +int ff_cbs_append_unit_data(CodedBitstreamFragment *frag, CodedBitstreamUnitType type, uint8_t *data, size_t data_size, AVBufferRef *data_buf); diff --git a/media/ffvpx/libavcodec/cbs_av1.c b/media/ffvpx/libavcodec/cbs_av1.c index 302e1f38f500..1229480567a9 100644 --- a/media/ffvpx/libavcodec/cbs_av1.c +++ b/media/ffvpx/libavcodec/cbs_av1.c @@ -20,10 +20,10 @@ #include "libavutil/opt.h" #include "libavutil/pixfmt.h" +#include "avcodec.h" #include "cbs.h" #include "cbs_internal.h" #include "cbs_av1.h" -#include "internal.h" static int cbs_av1_read_uvlc(CodedBitstreamContext *ctx, GetBitContext *gbc, @@ -828,7 +828,7 @@ static int cbs_av1_split_fragment(CodedBitstreamContext *ctx, goto fail; } - err = ff_cbs_insert_unit_data(frag, -1, header.obu_type, + err = ff_cbs_append_unit_data(frag, header.obu_type, data, obu_length, frag->data_ref); if (err < 0) goto fail; diff --git a/media/ffvpx/libavcodec/cbs_av1_syntax_template.c b/media/ffvpx/libavcodec/cbs_av1_syntax_template.c index 6fe6e9a4f356..d98d3d42dea3 100644 --- a/media/ffvpx/libavcodec/cbs_av1_syntax_template.c +++ b/media/ffvpx/libavcodec/cbs_av1_syntax_template.c @@ -355,7 +355,7 @@ static int FUNC(set_frame_refs)(CodedBitstreamContext *ctx, RWContext *rw, AV1_REF_FRAME_ALTREF2, AV1_REF_FRAME_ALTREF }; int8_t ref_frame_idx[AV1_REFS_PER_FRAME], used_frame[AV1_NUM_REF_FRAMES]; - int8_t shifted_order_hints[AV1_NUM_REF_FRAMES]; + int16_t shifted_order_hints[AV1_NUM_REF_FRAMES]; int cur_frame_hint, latest_order_hint, earliest_order_hint, ref; int i, j; diff --git a/media/ffvpx/libavcodec/cbs_internal.h b/media/ffvpx/libavcodec/cbs_internal.h index a392880036ed..f853086fa305 100644 --- a/media/ffvpx/libavcodec/cbs_internal.h +++ b/media/ffvpx/libavcodec/cbs_internal.h @@ -19,8 +19,13 @@ #ifndef AVCODEC_CBS_INTERNAL_H #define AVCODEC_CBS_INTERNAL_H -#include "avcodec.h" +#include + +#include "libavutil/buffer.h" +#include "libavutil/log.h" + #include "cbs.h" +#include "codec_id.h" #include "get_bits.h" #include "put_bits.h" diff --git a/media/ffvpx/libavcodec/codec.h b/media/ffvpx/libavcodec/codec.h index 50a22f6e3cb0..03e8be90a2fe 100644 --- a/media/ffvpx/libavcodec/codec.h +++ b/media/ffvpx/libavcodec/codec.h @@ -31,7 +31,7 @@ #include "libavutil/samplefmt.h" #include "libavcodec/codec_id.h" -#include "libavcodec/version.h" +#include "libavcodec/version_major.h" /** * @addtogroup lavc_core @@ -50,7 +50,12 @@ * avcodec_default_get_buffer2 or avcodec_default_get_encode_buffer. */ #define AV_CODEC_CAP_DR1 (1 << 1) +#if FF_API_FLAG_TRUNCATED +/** + * @deprecated Use parsers to always send proper frames. + */ #define AV_CODEC_CAP_TRUNCATED (1 << 3) +#endif /** * Encoder or decoder requires flushing with NULL input at the end in order to * give the complete and correct output. @@ -185,12 +190,6 @@ typedef struct AVProfile { const char *name; ///< short name for the profile } AVProfile; -typedef struct AVCodecDefault AVCodecDefault; - -struct AVCodecContext; -struct AVSubtitle; -struct AVPacket; - /** * AVCodec. */ @@ -214,12 +213,18 @@ typedef struct AVCodec { * see AV_CODEC_CAP_* */ int capabilities; + uint8_t max_lowres; ///< maximum value for lowres supported by the decoder const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0} const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1 const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 +#if FF_API_OLD_CHANNEL_LAYOUT + /** + * @deprecated use ch_layouts instead + */ + attribute_deprecated const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 - uint8_t max_lowres; ///< maximum value for lowres supported by the decoder +#endif const AVClass *priv_class; ///< AVClass for the private context const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} @@ -235,117 +240,10 @@ typedef struct AVCodec { */ const char *wrapper_name; - /***************************************************************** - * No fields below this line are part of the public API. They - * may not be used outside of libavcodec and can be changed and - * removed at will. - * New public fields should be added right above. - ***************************************************************** - */ - int priv_data_size; -#if FF_API_NEXT - struct AVCodec *next; -#endif /** - * @name Frame-level threading support functions - * @{ + * Array of supported channel layouts, terminated with a zeroed layout. */ - /** - * Copy necessary context variables from a previous thread context to the current one. - * If not defined, the next thread will start automatically; otherwise, the codec - * must call ff_thread_finish_setup(). - * - * dst and src will (rarely) point to the same context, in which case memcpy should be skipped. - */ - int (*update_thread_context)(struct AVCodecContext *dst, const struct AVCodecContext *src); - /** @} */ - - /** - * Private codec-specific defaults. - */ - const AVCodecDefault *defaults; - - /** - * Initialize codec static data, called from av_codec_iterate(). - * - * This is not intended for time consuming operations as it is - * run for every codec regardless of that codec being used. - */ - void (*init_static_data)(struct AVCodec *codec); - - int (*init)(struct AVCodecContext *); - int (*encode_sub)(struct AVCodecContext *, uint8_t *buf, int buf_size, - const struct AVSubtitle *sub); - /** - * Encode data to an AVPacket. - * - * @param avctx codec context - * @param avpkt output AVPacket - * @param[in] frame AVFrame containing the raw data to be encoded - * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a - * non-empty packet was returned in avpkt. - * @return 0 on success, negative error code on failure - */ - int (*encode2)(struct AVCodecContext *avctx, struct AVPacket *avpkt, - const struct AVFrame *frame, int *got_packet_ptr); - /** - * Decode picture or subtitle data. - * - * @param avctx codec context - * @param outdata codec type dependent output struct - * @param[out] got_frame_ptr decoder sets to 0 or 1 to indicate that a - * non-empty frame or subtitle was returned in - * outdata. - * @param[in] avpkt AVPacket containing the data to be decoded - * @return amount of bytes read from the packet on success, negative error - * code on failure - */ - int (*decode)(struct AVCodecContext *avctx, void *outdata, - int *got_frame_ptr, struct AVPacket *avpkt); - int (*close)(struct AVCodecContext *); - /** - * Encode API with decoupled frame/packet dataflow. This function is called - * to get one output packet. It should call ff_encode_get_frame() to obtain - * input data. - */ - int (*receive_packet)(struct AVCodecContext *avctx, struct AVPacket *avpkt); - - /** - * Decode API with decoupled packet/frame dataflow. This function is called - * to get one output frame. It should call ff_decode_get_packet() to obtain - * input data. - */ - int (*receive_frame)(struct AVCodecContext *avctx, struct AVFrame *frame); - /** - * Flush buffers. - * Will be called when seeking - */ - void (*flush)(struct AVCodecContext *); - /** - * Internal codec capabilities. - * See FF_CODEC_CAP_* in internal.h - */ - int caps_internal; - - /** - * Decoding only, a comma-separated list of bitstream filters to apply to - * packets before decoding. - */ - const char *bsfs; - - /** - * Array of pointers to hardware configurations supported by the codec, - * or NULL if no hardware supported. The array is terminated by a NULL - * pointer. - * - * The user can only access this field via avcodec_get_hw_config(). - */ - const struct AVCodecHWConfigInternal *const *hw_configs; - - /** - * List of supported codec_tags, terminated by FF_CODEC_TAGS_END. - */ - const uint32_t *codec_tags; + const AVChannelLayout *ch_layouts; } AVCodec; /** @@ -365,7 +263,7 @@ const AVCodec *av_codec_iterate(void **opaque); * @param id AVCodecID of the requested decoder * @return A decoder if one was found, NULL otherwise. */ -AVCodec *avcodec_find_decoder(enum AVCodecID id); +const AVCodec *avcodec_find_decoder(enum AVCodecID id); /** * Find a registered decoder with the specified name. @@ -373,7 +271,7 @@ AVCodec *avcodec_find_decoder(enum AVCodecID id); * @param name name of the requested decoder * @return A decoder if one was found, NULL otherwise. */ -AVCodec *avcodec_find_decoder_by_name(const char *name); +const AVCodec *avcodec_find_decoder_by_name(const char *name); /** * Find a registered encoder with a matching codec ID. @@ -381,7 +279,7 @@ AVCodec *avcodec_find_decoder_by_name(const char *name); * @param id AVCodecID of the requested encoder * @return An encoder if one was found, NULL otherwise. */ -AVCodec *avcodec_find_encoder(enum AVCodecID id); +const AVCodec *avcodec_find_encoder(enum AVCodecID id); /** * Find a registered encoder with the specified name. @@ -389,7 +287,7 @@ AVCodec *avcodec_find_encoder(enum AVCodecID id); * @param name name of the requested encoder * @return An encoder if one was found, NULL otherwise. */ -AVCodec *avcodec_find_encoder_by_name(const char *name); +const AVCodec *avcodec_find_encoder_by_name(const char *name); /** * @return a non-zero number if codec is an encoder, zero otherwise */ @@ -400,6 +298,15 @@ int av_codec_is_encoder(const AVCodec *codec); */ int av_codec_is_decoder(const AVCodec *codec); +/** + * Return a name for the specified profile, if available. + * + * @param codec the codec that is searched for the given profile + * @param profile the profile value for which a name is requested + * @return A name for the profile if found, NULL otherwise. + */ +const char *av_get_profile_name(const AVCodec *codec, int profile); + enum { /** * The codec supports this format via the hw_device_ctx interface. diff --git a/media/ffvpx/libavcodec/codec_desc.c b/media/ffvpx/libavcodec/codec_desc.c index 17f8a140446e..e2c1c67f5e5e 100644 --- a/media/ffvpx/libavcodec/codec_desc.c +++ b/media/ffvpx/libavcodec/codec_desc.c @@ -19,15 +19,15 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include -#include "libavutil/common.h" #include "libavutil/internal.h" +#include "libavutil/macros.h" #include "codec_id.h" #include "codec_desc.h" #include "profiles.h" -#include "version.h" #define MT(...) (const char *const[]){ __VA_ARGS__, NULL } @@ -1856,6 +1856,36 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Digital Pictures SGA Video"), .props = AV_CODEC_PROP_LOSSY, }, + { + .id = AV_CODEC_ID_GEM, + .type = AVMEDIA_TYPE_VIDEO, + .name = "gem", + .long_name = NULL_IF_CONFIG_SMALL("GEM Raster image"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_VBN, + .type = AVMEDIA_TYPE_VIDEO, + .name = "vbn", + .long_name = NULL_IF_CONFIG_SMALL("Vizrt Binary Image"), + .props = AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_JPEGXL, + .type = AVMEDIA_TYPE_VIDEO, + .name = "jpegxl", + .long_name = NULL_IF_CONFIG_SMALL("JPEG XL"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY | + AV_CODEC_PROP_LOSSLESS, + .mime_types= MT("image/jxl"), + }, + { + .id = AV_CODEC_ID_QOI, + .type = AVMEDIA_TYPE_VIDEO, + .name = "qoi", + .long_name = NULL_IF_CONFIG_SMALL("QOI (Quite OK Image)"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, + }, /* various PCM "codecs" */ { @@ -2462,6 +2492,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA MobiClip MOFLEX"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, }, + { + .id = AV_CODEC_ID_ADPCM_IMA_ACORN, + .type = AVMEDIA_TYPE_AUDIO, + .name = "adpcm_ima_acorn", + .long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA Acorn Replay"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, + }, /* AMR */ { @@ -2758,7 +2795,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .type = AVMEDIA_TYPE_AUDIO, .name = "mlp", .long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)"), - .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, + .props = AV_CODEC_PROP_LOSSLESS, }, { .id = AV_CODEC_ID_GSM_MS, @@ -3216,6 +3253,20 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("MobiClip FastAudio"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, }, + { + .id = AV_CODEC_ID_MSNSIREN, + .type = AVMEDIA_TYPE_AUDIO, + .name = "msnsiren", + .long_name = NULL_IF_CONFIG_SMALL("MSN Siren"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, + }, + { + .id = AV_CODEC_ID_DFPWM, + .type = AVMEDIA_TYPE_AUDIO, + .name = "dfpwm", + .long_name = NULL_IF_CONFIG_SMALL("DFPWM (Dynamic Filter Pulse Width Modulation)"), + .props = AV_CODEC_PROP_LOSSY, + }, /* subtitle codecs */ { diff --git a/media/ffvpx/libavcodec/codec_id.h b/media/ffvpx/libavcodec/codec_id.h index ab265ec58433..93856a16f2d0 100644 --- a/media/ffvpx/libavcodec/codec_id.h +++ b/media/ffvpx/libavcodec/codec_id.h @@ -308,6 +308,9 @@ enum AVCodecID { AV_CODEC_ID_SIMBIOSIS_IMX, AV_CODEC_ID_SGA_VIDEO, AV_CODEC_ID_GEM, + AV_CODEC_ID_VBN, + AV_CODEC_ID_JPEGXL, + AV_CODEC_ID_QOI, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs @@ -516,6 +519,7 @@ enum AVCodecID { AV_CODEC_ID_HCA, AV_CODEC_ID_FASTAUDIO, AV_CODEC_ID_MSNSIREN, + AV_CODEC_ID_DFPWM, /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. diff --git a/media/ffvpx/libavcodec/codec_internal.h b/media/ffvpx/libavcodec/codec_internal.h new file mode 100644 index 000000000000..5df286ce52d3 --- /dev/null +++ b/media/ffvpx/libavcodec/codec_internal.h @@ -0,0 +1,278 @@ +/* + * 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 + */ + +#ifndef AVCODEC_CODEC_INTERNAL_H +#define AVCODEC_CODEC_INTERNAL_H + +#include + +#include "libavutil/attributes.h" +#include "codec.h" + +/** + * The codec does not modify any global variables in the init function, + * allowing to call the init function without locking any global mutexes. + */ +#define FF_CODEC_CAP_INIT_THREADSAFE (1 << 0) +/** + * The codec allows calling the close function for deallocation even if + * the init function returned a failure. Without this capability flag, a + * codec does such cleanup internally when returning failures from the + * init function and does not expect the close function to be called at + * all. + */ +#define FF_CODEC_CAP_INIT_CLEANUP (1 << 1) +/** + * Decoders marked with FF_CODEC_CAP_SETS_PKT_DTS want to set + * AVFrame.pkt_dts manually. If the flag is set, decode.c won't overwrite + * this field. If it's unset, decode.c tries to guess the pkt_dts field + * from the input AVPacket. + */ +#define FF_CODEC_CAP_SETS_PKT_DTS (1 << 2) +/** + * The decoder extracts and fills its parameters even if the frame is + * skipped due to the skip_frame setting. + */ +#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM (1 << 3) +/** + * The decoder sets the cropping fields in the output frames manually. + * If this cap is set, the generic code will initialize output frame + * dimensions to coded rather than display values. + */ +#define FF_CODEC_CAP_EXPORTS_CROPPING (1 << 4) +/** + * Codec initializes slice-based threading with a main function + */ +#define FF_CODEC_CAP_SLICE_THREAD_HAS_MF (1 << 5) +/* + * The codec supports frame threading and has inter-frame dependencies, so it + * uses ff_thread_report/await_progress(). + */ +#define FF_CODEC_CAP_ALLOCATE_PROGRESS (1 << 6) +/** + * Codec handles avctx->thread_count == 0 (auto) internally. + */ +#define FF_CODEC_CAP_AUTO_THREADS (1 << 7) +/** + * Codec handles output frame properties internally instead of letting the + * internal logic derive them from AVCodecInternal.last_pkt_props. + */ +#define FF_CODEC_CAP_SETS_FRAME_PROPS (1 << 8) + +/** + * FFCodec.codec_tags termination value + */ +#define FF_CODEC_TAGS_END -1 + +typedef struct FFCodecDefault { + const char *key; + const char *value; +} FFCodecDefault; + +struct AVCodecContext; +struct AVSubtitle; +struct AVPacket; + +enum FFCodecType { + /* The codec is a decoder using the decode callback; + * audio and video codecs only. */ + FF_CODEC_CB_TYPE_DECODE, + /* The codec is a decoder using the decode_sub callback; + * subtitle codecs only. */ + FF_CODEC_CB_TYPE_DECODE_SUB, + /* The codec is a decoder using the receive_frame callback; + * audio and video codecs only. */ + FF_CODEC_CB_TYPE_RECEIVE_FRAME, + /* The codec is an encoder using the encode callback; + * audio and video codecs only. */ + FF_CODEC_CB_TYPE_ENCODE, + /* The codec is an encoder using the encode_sub callback; + * subtitle codecs only. */ + FF_CODEC_CB_TYPE_ENCODE_SUB, + /* The codec is an encoder using the receive_packet callback; + * audio and video codecs only. */ + FF_CODEC_CB_TYPE_RECEIVE_PACKET, +}; + +typedef struct FFCodec { + /** + * The public AVCodec. See codec.h for it. + */ + AVCodec p; + + /** + * Internal codec capabilities FF_CODEC_CAP_*. + */ + unsigned caps_internal:29; + + /** + * This field determines the type of the codec (decoder/encoder) + * and also the exact callback cb implemented by the codec. + * cb_type uses enum FFCodecType values. + */ + unsigned cb_type:3; + + int priv_data_size; + /** + * @name Frame-level threading support functions + * @{ + */ + /** + * Copy necessary context variables from a previous thread context to the current one. + * If not defined, the next thread will start automatically; otherwise, the codec + * must call ff_thread_finish_setup(). + * + * dst and src will (rarely) point to the same context, in which case memcpy should be skipped. + */ + int (*update_thread_context)(struct AVCodecContext *dst, const struct AVCodecContext *src); + + /** + * Copy variables back to the user-facing context + */ + int (*update_thread_context_for_user)(struct AVCodecContext *dst, const struct AVCodecContext *src); + /** @} */ + + /** + * Private codec-specific defaults. + */ + const FFCodecDefault *defaults; + + /** + * Initialize codec static data, called from av_codec_iterate(). + * + * This is not intended for time consuming operations as it is + * run for every codec regardless of that codec being used. + */ + void (*init_static_data)(struct FFCodec *codec); + + int (*init)(struct AVCodecContext *); + + union { + /** + * Decode to an AVFrame. + * cb is in this state if cb_type is FF_CODEC_CB_TYPE_DECODE. + * + * @param avctx codec context + * @param[out] frame AVFrame for output + * @param[out] got_frame_ptr decoder sets to 0 or 1 to indicate that + * a non-empty frame was returned in frame. + * @param[in] avpkt AVPacket containing the data to be decoded + * @return amount of bytes read from the packet on success, + * negative error code on failure + */ + int (*decode)(struct AVCodecContext *avctx, struct AVFrame *frame, + int *got_frame_ptr, struct AVPacket *avpkt); + /** + * Decode subtitle data to an AVSubtitle. + * cb is in this state if cb_type is FF_CODEC_CB_TYPE_DECODE_SUB. + * + * Apart from that this is like the decode callback. + */ + int (*decode_sub)(struct AVCodecContext *avctx, struct AVSubtitle *sub, + int *got_frame_ptr, const struct AVPacket *avpkt); + /** + * Decode API with decoupled packet/frame dataflow. + * cb is in this state if cb_type is FF_CODEC_CB_TYPE_RECEIVE_FRAME. + * + * This function is called to get one output frame. It should call + * ff_decode_get_packet() to obtain input data. + */ + int (*receive_frame)(struct AVCodecContext *avctx, struct AVFrame *frame); + /** + * Encode data to an AVPacket. + * cb is in this state if cb_type is FF_CODEC_CB_TYPE_ENCODE + * + * @param avctx codec context + * @param[out] avpkt output AVPacket + * @param[in] frame AVFrame containing the input to be encoded + * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a + * non-empty packet was returned in avpkt. + * @return 0 on success, negative error code on failure + */ + int (*encode)(struct AVCodecContext *avctx, struct AVPacket *avpkt, + const struct AVFrame *frame, int *got_packet_ptr); + /** + * Encode subtitles to a raw buffer. + * cb is in this state if cb_type is FF_CODEC_CB_TYPE_ENCODE_SUB. + */ + int (*encode_sub)(struct AVCodecContext *avctx, uint8_t *buf, + int buf_size, const struct AVSubtitle *sub); + /** + * Encode API with decoupled frame/packet dataflow. + * cb is in this state if cb_type is FF_CODEC_CB_TYPE_RECEIVE_PACKET. + * + * This function is called to get one output packet. + * It should call ff_encode_get_frame() to obtain input data. + */ + int (*receive_packet)(struct AVCodecContext *avctx, struct AVPacket *avpkt); + } cb; + + int (*close)(struct AVCodecContext *); + + /** + * Flush buffers. + * Will be called when seeking + */ + void (*flush)(struct AVCodecContext *); + + /** + * Decoding only, a comma-separated list of bitstream filters to apply to + * packets before decoding. + */ + const char *bsfs; + + /** + * Array of pointers to hardware configurations supported by the codec, + * or NULL if no hardware supported. The array is terminated by a NULL + * pointer. + * + * The user can only access this field via avcodec_get_hw_config(). + */ + const struct AVCodecHWConfigInternal *const *hw_configs; + + /** + * List of supported codec_tags, terminated by FF_CODEC_TAGS_END. + */ + const uint32_t *codec_tags; +} FFCodec; + +#define FF_CODEC_DECODE_CB(func) \ + .cb_type = FF_CODEC_CB_TYPE_DECODE, \ + .cb.decode = (func) +#define FF_CODEC_DECODE_SUB_CB(func) \ + .cb_type = FF_CODEC_CB_TYPE_DECODE_SUB, \ + .cb.decode_sub = (func) +#define FF_CODEC_RECEIVE_FRAME_CB(func) \ + .cb_type = FF_CODEC_CB_TYPE_RECEIVE_FRAME, \ + .cb.receive_frame = (func) +#define FF_CODEC_ENCODE_CB(func) \ + .cb_type = FF_CODEC_CB_TYPE_ENCODE, \ + .cb.encode = (func) +#define FF_CODEC_ENCODE_SUB_CB(func) \ + .cb_type = FF_CODEC_CB_TYPE_ENCODE_SUB, \ + .cb.encode_sub = (func) +#define FF_CODEC_RECEIVE_PACKET_CB(func) \ + .cb_type = FF_CODEC_CB_TYPE_RECEIVE_PACKET, \ + .cb.receive_packet = (func) + +static av_always_inline const FFCodec *ffcodec(const AVCodec *codec) +{ + return (const FFCodec*)codec; +} + +#endif /* AVCODEC_CODEC_INTERNAL_H */ diff --git a/media/ffvpx/libavcodec/codec_list.c b/media/ffvpx/libavcodec/codec_list.c index d437748f8e04..21ffe0f1e78d 100644 --- a/media/ffvpx/libavcodec/codec_list.c +++ b/media/ffvpx/libavcodec/codec_list.c @@ -1,20 +1,6 @@ -static const AVCodec * const codec_list[] = { -#if CONFIG_VP8_DECODER +static const FFCodec * const codec_list[] = { &ff_vp8_decoder, -#endif -#if CONFIG_VP9_DECODER &ff_vp9_decoder, -#endif -#if CONFIG_FLAC_DECODER &ff_flac_decoder, -#endif -#if CONFIG_MP3_DECODER &ff_mp3_decoder, -#endif -#if CONFIG_LIBDAV1D - &ff_libdav1d_decoder, -#endif -#if CONFIG_AV1_DECODER - &ff_av1_decoder, -#endif NULL }; diff --git a/media/ffvpx/libavcodec/codec_par.c b/media/ffvpx/libavcodec/codec_par.c index 1a5168a04b8d..abda649aa884 100644 --- a/media/ffvpx/libavcodec/codec_par.c +++ b/media/ffvpx/libavcodec/codec_par.c @@ -31,12 +31,14 @@ static void codec_parameters_reset(AVCodecParameters *par) { av_freep(&par->extradata); + av_channel_layout_uninit(&par->ch_layout); memset(par, 0, sizeof(*par)); par->codec_type = AVMEDIA_TYPE_UNKNOWN; par->codec_id = AV_CODEC_ID_NONE; par->format = -1; + par->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; par->field_order = AV_FIELD_UNKNOWN; par->color_range = AVCOL_RANGE_UNSPECIFIED; par->color_primaries = AVCOL_PRI_UNSPECIFIED; @@ -71,9 +73,12 @@ void avcodec_parameters_free(AVCodecParameters **ppar) int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src) { + int ret; + codec_parameters_reset(dst); memcpy(dst, src, sizeof(*dst)); + dst->ch_layout = (AVChannelLayout){0}; dst->extradata = NULL; dst->extradata_size = 0; if (src->extradata) { @@ -84,12 +89,18 @@ int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src dst->extradata_size = src->extradata_size; } + ret = av_channel_layout_copy(&dst->ch_layout, &src->ch_layout); + if (ret < 0) + return ret; + return 0; } int avcodec_parameters_from_context(AVCodecParameters *par, const AVCodecContext *codec) { + int ret; + codec_parameters_reset(par); par->codec_type = codec->codec_type; @@ -118,8 +129,32 @@ int avcodec_parameters_from_context(AVCodecParameters *par, break; case AVMEDIA_TYPE_AUDIO: par->format = codec->sample_fmt; - par->channel_layout = codec->channel_layout; - par->channels = codec->channels; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + // if the old/new fields are set inconsistently, prefer the old ones + if ((codec->channels && codec->channels != codec->ch_layout.nb_channels) || + (codec->channel_layout && (codec->ch_layout.order != AV_CHANNEL_ORDER_NATIVE || + codec->ch_layout.u.mask != codec->channel_layout))) { + if (codec->channel_layout) + av_channel_layout_from_mask(&par->ch_layout, codec->channel_layout); + else { + par->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + par->ch_layout.nb_channels = codec->channels; + } +FF_ENABLE_DEPRECATION_WARNINGS + } else { +#endif + ret = av_channel_layout_copy(&par->ch_layout, &codec->ch_layout); + if (ret < 0) + return ret; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + } + par->channel_layout = par->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ? + par->ch_layout.u.mask : 0; + par->channels = par->ch_layout.nb_channels; +FF_ENABLE_DEPRECATION_WARNINGS +#endif par->sample_rate = codec->sample_rate; par->block_align = codec->block_align; par->frame_size = codec->frame_size; @@ -147,6 +182,8 @@ int avcodec_parameters_from_context(AVCodecParameters *par, int avcodec_parameters_to_context(AVCodecContext *codec, const AVCodecParameters *par) { + int ret; + codec->codec_type = par->codec_type; codec->codec_id = par->codec_id; codec->codec_tag = par->codec_tag; @@ -173,8 +210,32 @@ int avcodec_parameters_to_context(AVCodecContext *codec, break; case AVMEDIA_TYPE_AUDIO: codec->sample_fmt = par->format; - codec->channel_layout = par->channel_layout; - codec->channels = par->channels; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + // if the old/new fields are set inconsistently, prefer the old ones + if ((par->channels && par->channels != par->ch_layout.nb_channels) || + (par->channel_layout && (par->ch_layout.order != AV_CHANNEL_ORDER_NATIVE || + par->ch_layout.u.mask != par->channel_layout))) { + if (par->channel_layout) + av_channel_layout_from_mask(&codec->ch_layout, par->channel_layout); + else { + codec->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + codec->ch_layout.nb_channels = par->channels; + } +FF_ENABLE_DEPRECATION_WARNINGS + } else { +#endif + ret = av_channel_layout_copy(&codec->ch_layout, &par->ch_layout); + if (ret < 0) + return ret; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + } + codec->channel_layout = codec->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ? + codec->ch_layout.u.mask : 0; + codec->channels = codec->ch_layout.nb_channels; +FF_ENABLE_DEPRECATION_WARNINGS +#endif codec->sample_rate = par->sample_rate; codec->block_align = par->block_align; codec->frame_size = par->frame_size; diff --git a/media/ffvpx/libavcodec/codec_par.h b/media/ffvpx/libavcodec/codec_par.h index 10cf79dff104..7660791a12e2 100644 --- a/media/ffvpx/libavcodec/codec_par.h +++ b/media/ffvpx/libavcodec/codec_par.h @@ -24,6 +24,7 @@ #include #include "libavutil/avutil.h" +#include "libavutil/channel_layout.h" #include "libavutil/rational.h" #include "libavutil/pixfmt.h" @@ -154,16 +155,22 @@ typedef struct AVCodecParameters { */ int video_delay; +#if FF_API_OLD_CHANNEL_LAYOUT /** * Audio only. The channel layout bitmask. May be 0 if the channel layout is * unknown or unspecified, otherwise the number of bits set must be equal to * the channels field. + * @deprecated use ch_layout */ + attribute_deprecated uint64_t channel_layout; /** * Audio only. The number of audio channels. + * @deprecated use ch_layout.nb_channels */ + attribute_deprecated int channels; +#endif /** * Audio only. The number of audio samples per second. */ @@ -198,6 +205,11 @@ typedef struct AVCodecParameters { * Audio only. Number of samples to skip after a discontinuity. */ int seek_preroll; + + /** + * Audio only. The channel layout and number of channels. + */ + AVChannelLayout ch_layout; } AVCodecParameters; /** diff --git a/media/ffvpx/libavcodec/dct.c b/media/ffvpx/libavcodec/dct.c index 52f082d0623d..eeb4d154e08f 100644 --- a/media/ffvpx/libavcodec/dct.c +++ b/media/ffvpx/libavcodec/dct.c @@ -30,7 +30,9 @@ #include #include +#include "libavutil/error.h" #include "libavutil/mathematics.h" +#include "libavutil/mem.h" #include "dct.h" #include "dct32.h" @@ -212,8 +214,9 @@ av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse) } s->dct32 = ff_dct32_float; - if (ARCH_X86) - ff_dct_init_x86(s); +#if ARCH_X86 + ff_dct_init_x86(s); +#endif return 0; } diff --git a/media/ffvpx/libavcodec/decode.c b/media/ffvpx/libavcodec/decode.c index 936e5d63da8d..1893caa6a67b 100644 --- a/media/ffvpx/libavcodec/decode.c +++ b/media/ffvpx/libavcodec/decode.c @@ -30,7 +30,9 @@ #include "libavutil/avassert.h" #include "libavutil/avstring.h" #include "libavutil/bprint.h" +#include "libavutil/channel_layout.h" #include "libavutil/common.h" +#include "libavutil/fifo.h" #include "libavutil/frame.h" #include "libavutil/hwcontext.h" #include "libavutil/imgutils.h" @@ -40,34 +42,17 @@ #include "avcodec.h" #include "bytestream.h" +#include "bsf.h" +#include "codec_internal.h" #include "decode.h" #include "hwconfig.h" #include "internal.h" #include "thread.h" -typedef struct FramePool { - /** - * Pools for each data plane. For audio all the planes have the same size, - * so only pools[0] is used. - */ - AVBufferPool *pools[4]; - - /* - * Pool parameters - */ - int format; - int width, height; - int stride_align[AV_NUM_DATA_POINTERS]; - int linesize[4]; - int planes; - int channels; - int samples; -} FramePool; - static int apply_param_change(AVCodecContext *avctx, const AVPacket *avpkt) { int ret; - buffer_size_t size; + size_t size; const uint8_t *data; uint32_t flags; int64_t val; @@ -89,6 +74,8 @@ static int apply_param_change(AVCodecContext *avctx, const AVPacket *avpkt) flags = bytestream_get_le32(&data); size -= 4; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) { if (size < 4) goto fail; @@ -107,6 +94,8 @@ static int apply_param_change(AVCodecContext *avctx, const AVPacket *avpkt) avctx->channel_layout = bytestream_get_le64(&data); size -= 8; } +FF_ENABLE_DEPRECATION_WARNINGS +#endif if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) { if (size < 4) goto fail; @@ -163,39 +152,33 @@ static int extract_packet_props(AVCodecInternal *avci, const AVPacket *pkt) int ret = 0; if (IS_EMPTY(avci->last_pkt_props)) { - if (av_fifo_size(avci->pkt_props) >= sizeof(*pkt)) { - av_fifo_generic_read(avci->pkt_props, avci->last_pkt_props, - sizeof(*avci->last_pkt_props), NULL); - } else + if (av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1) < 0) return copy_packet_props(avci->last_pkt_props, pkt); } - if (av_fifo_space(avci->pkt_props) < sizeof(*pkt)) { - ret = av_fifo_grow(avci->pkt_props, sizeof(*pkt)); - if (ret < 0) - return ret; - } - ret = copy_packet_props(&tmp, pkt); if (ret < 0) return ret; - av_fifo_generic_write(avci->pkt_props, &tmp, sizeof(tmp), NULL); + ret = av_fifo_write(avci->pkt_props, &tmp, 1); + if (ret < 0) + av_packet_unref(&tmp); - return 0; + return ret; } static int decode_bsfs_init(AVCodecContext *avctx) { AVCodecInternal *avci = avctx->internal; + const FFCodec *const codec = ffcodec(avctx->codec); int ret; if (avci->bsf) return 0; - ret = av_bsf_list_parse_str(avctx->codec->bsfs, &avci->bsf); + ret = av_bsf_list_parse_str(codec->bsfs, &avci->bsf); if (ret < 0) { - av_log(avctx, AV_LOG_ERROR, "Error parsing decoder bitstream filters '%s': %s\n", avctx->codec->bsfs, av_err2str(ret)); + av_log(avctx, AV_LOG_ERROR, "Error parsing decoder bitstream filters '%s': %s\n", codec->bsfs, av_err2str(ret)); if (ret != AVERROR(ENOMEM)) ret = AVERROR_BUG; goto fail; @@ -233,7 +216,7 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt) if (ret < 0) return ret; - if (!(avctx->codec->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS)) { + if (!(ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS)) { ret = extract_packet_props(avctx->internal, pkt); if (ret < 0) goto finish; @@ -243,11 +226,6 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt) if (ret < 0) goto finish; -#if FF_API_OLD_ENCDEC - if (avctx->codec->receive_frame) - avci->compat_decode_consumed += pkt->size; -#endif - return 0; finish: av_packet_unref(pkt); @@ -299,8 +277,8 @@ static int64_t guess_correct_pts(AVCodecContext *ctx, static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame, int64_t *discarded_samples) { AVCodecInternal *avci = avctx->internal; - DecodeSimpleContext *ds = &avci->ds; - AVPacket *pkt = ds->in_pkt; + AVPacket *const pkt = avci->in_pkt; + const FFCodec *const codec = ffcodec(avctx->codec); int got_frame, actual_got_frame; int ret; @@ -326,9 +304,9 @@ static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame, if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) { ret = ff_thread_decode_frame(avctx, frame, &got_frame, pkt); } else { - ret = avctx->codec->decode(avctx, frame, &got_frame, pkt); + ret = codec->cb.decode(avctx, frame, &got_frame, pkt); - if (!(avctx->codec->caps_internal & FF_CODEC_CAP_SETS_PKT_DTS)) + if (!(codec->caps_internal & FF_CODEC_CAP_SETS_PKT_DTS)) frame->pkt_dts = pkt->dts; if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) { if(!avctx->has_b_frames) @@ -351,7 +329,7 @@ static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame, got_frame = 0; } else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) { uint8_t *side; - buffer_size_t side_size; + size_t side_size; uint32_t discard_padding = 0; uint8_t skip_reason = 0; uint8_t discard_reason = 0; @@ -359,10 +337,22 @@ static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame, if (ret >= 0 && got_frame) { if (frame->format == AV_SAMPLE_FMT_NONE) frame->format = avctx->sample_fmt; + if (!frame->ch_layout.nb_channels) { + int ret2 = av_channel_layout_copy(&frame->ch_layout, &avctx->ch_layout); + if (ret2 < 0) { + ret = ret2; + got_frame = 0; + } + } +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS if (!frame->channel_layout) - frame->channel_layout = avctx->channel_layout; + frame->channel_layout = avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ? + avctx->ch_layout.u.mask : 0; if (!frame->channels) - frame->channels = avctx->channels; + frame->channels = avctx->ch_layout.nb_channels; +FF_ENABLE_DEPRECATION_WARNINGS +#endif if (!frame->sample_rate) frame->sample_rate = avctx->sample_rate; } @@ -370,6 +360,7 @@ static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame, side= av_packet_get_side_data(avci->last_pkt_props, AV_PKT_DATA_SKIP_SAMPLES, &side_size); if(side && side_size>=10) { avci->skip_samples = AV_RL32(side) * avci->skip_samples_multiplier; + avci->skip_samples = FFMAX(0, avci->skip_samples); discard_padding = AV_RL32(side + 4); av_log(avctx, AV_LOG_DEBUG, "skip %d / discard %d samples due to side data\n", avci->skip_samples, (int)discard_padding); @@ -394,19 +385,13 @@ static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame, avci->skip_samples); } else { av_samples_copy(frame->extended_data, frame->extended_data, 0, avci->skip_samples, - frame->nb_samples - avci->skip_samples, avctx->channels, frame->format); + frame->nb_samples - avci->skip_samples, avctx->ch_layout.nb_channels, frame->format); if(avctx->pkt_timebase.num && avctx->sample_rate) { int64_t diff_ts = av_rescale_q(avci->skip_samples, (AVRational){1, avctx->sample_rate}, avctx->pkt_timebase); if(frame->pts!=AV_NOPTS_VALUE) frame->pts += diff_ts; -#if FF_API_PKT_PTS -FF_DISABLE_DEPRECATION_WARNINGS - if(frame->pkt_pts!=AV_NOPTS_VALUE) - frame->pkt_pts += diff_ts; -FF_ENABLE_DEPRECATION_WARNINGS -#endif if(frame->pkt_dts!=AV_NOPTS_VALUE) frame->pkt_dts += diff_ts; if (frame->pkt_duration >= diff_ts) @@ -464,7 +449,11 @@ FF_ENABLE_DEPRECATION_WARNINGS if (!got_frame) av_frame_unref(frame); +#if FF_API_FLAG_TRUNCATED if (ret >= 0 && avctx->codec->type == AVMEDIA_TYPE_VIDEO && !(avctx->flags & AV_CODEC_FLAG_TRUNCATED)) +#else + if (ret >= 0 && avctx->codec->type == AVMEDIA_TYPE_VIDEO) +#endif ret = pkt->size; #if FF_API_AVCTX_TIMEBASE @@ -492,10 +481,6 @@ FF_ENABLE_DEPRECATION_WARNINGS } } -#if FF_API_OLD_ENCDEC - avci->compat_decode_consumed += ret; -#endif - if (ret >= pkt->size || ret < 0) { av_packet_unref(pkt); av_packet_unref(avci->last_pkt_props); @@ -506,7 +491,7 @@ FF_ENABLE_DEPRECATION_WARNINGS pkt->size -= consumed; pkt->pts = AV_NOPTS_VALUE; pkt->dts = AV_NOPTS_VALUE; - if (!(avctx->codec->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS)) { + if (!(codec->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS)) { avci->last_pkt_props->size -= consumed; // See extract_packet_props() comment. avci->last_pkt_props->pts = AV_NOPTS_VALUE; avci->last_pkt_props->dts = AV_NOPTS_VALUE; @@ -538,12 +523,13 @@ static int decode_simple_receive_frame(AVCodecContext *avctx, AVFrame *frame) static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) { AVCodecInternal *avci = avctx->internal; + const FFCodec *const codec = ffcodec(avctx->codec); int ret; av_assert0(!frame->buf[0]); - if (avctx->codec->receive_frame) { - ret = avctx->codec->receive_frame(avctx, frame); + if (codec->cb_type == FF_CODEC_CB_TYPE_RECEIVE_FRAME) { + ret = codec->cb.receive_frame(avctx, frame); if (ret != AVERROR(EAGAIN)) av_packet_unref(avci->last_pkt_props); } else @@ -552,10 +538,11 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) if (ret == AVERROR_EOF) avci->draining_done = 1; - if (!(avctx->codec->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS) && - IS_EMPTY(avci->last_pkt_props) && av_fifo_size(avci->pkt_props) >= sizeof(*avci->last_pkt_props)) - av_fifo_generic_read(avci->pkt_props, - avci->last_pkt_props, sizeof(*avci->last_pkt_props), NULL); + if (!(codec->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS) && + IS_EMPTY(avci->last_pkt_props)) { + // May fail if the FIFO is empty. + av_fifo_read(avci->pkt_props, avci->last_pkt_props, 1); + } if (!ret) { frame->best_effort_timestamp = guess_correct_pts(avctx, @@ -689,8 +676,17 @@ int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr case AVMEDIA_TYPE_AUDIO: avci->initial_sample_rate = frame->sample_rate ? frame->sample_rate : avctx->sample_rate; - avci->initial_channels = frame->channels; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + avci->initial_channels = frame->ch_layout.nb_channels; avci->initial_channel_layout = frame->channel_layout; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + ret = av_channel_layout_copy(&avci->initial_ch_layout, &frame->ch_layout); + if (ret < 0) { + av_frame_unref(frame); + return ret; + } break; } } @@ -704,10 +700,15 @@ int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr avci->initial_height != frame->height; break; case AVMEDIA_TYPE_AUDIO: +FF_DISABLE_DEPRECATION_WARNINGS changed |= avci->initial_sample_rate != frame->sample_rate || avci->initial_sample_rate != avctx->sample_rate || +#if FF_API_OLD_CHANNEL_LAYOUT avci->initial_channels != frame->channels || - avci->initial_channel_layout != frame->channel_layout; + avci->initial_channel_layout != frame->channel_layout || +#endif + av_channel_layout_compare(&avci->initial_ch_layout, &frame->ch_layout); +FF_ENABLE_DEPRECATION_WARNINGS break; } @@ -725,152 +726,6 @@ int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr return 0; } -#if FF_API_OLD_ENCDEC -FF_DISABLE_DEPRECATION_WARNINGS -static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame) -{ - int ret; - - /* move the original frame to our backup */ - av_frame_unref(avci->to_free); - av_frame_move_ref(avci->to_free, frame); - - /* now copy everything except the AVBufferRefs back - * note that we make a COPY of the side data, so calling av_frame_free() on - * the caller's frame will work properly */ - ret = av_frame_copy_props(frame, avci->to_free); - if (ret < 0) - return ret; - - memcpy(frame->data, avci->to_free->data, sizeof(frame->data)); - memcpy(frame->linesize, avci->to_free->linesize, sizeof(frame->linesize)); - if (avci->to_free->extended_data != avci->to_free->data) { - int planes = avci->to_free->channels; - int size = planes * sizeof(*frame->extended_data); - - if (!size) { - av_frame_unref(frame); - return AVERROR_BUG; - } - - frame->extended_data = av_malloc(size); - if (!frame->extended_data) { - av_frame_unref(frame); - return AVERROR(ENOMEM); - } - memcpy(frame->extended_data, avci->to_free->extended_data, - size); - } else - frame->extended_data = frame->data; - - frame->format = avci->to_free->format; - frame->width = avci->to_free->width; - frame->height = avci->to_free->height; - frame->channel_layout = avci->to_free->channel_layout; - frame->nb_samples = avci->to_free->nb_samples; - frame->channels = avci->to_free->channels; - - return 0; -} - -static int compat_decode(AVCodecContext *avctx, AVFrame *frame, - int *got_frame, const AVPacket *pkt) -{ - AVCodecInternal *avci = avctx->internal; - int ret = 0; - - av_assert0(avci->compat_decode_consumed == 0); - - if (avci->draining_done && pkt && pkt->size != 0) { - av_log(avctx, AV_LOG_WARNING, "Got unexpected packet after EOF\n"); - avcodec_flush_buffers(avctx); - } - - *got_frame = 0; - - if (avci->compat_decode_partial_size > 0 && - avci->compat_decode_partial_size != pkt->size) { - av_log(avctx, AV_LOG_ERROR, - "Got unexpected packet size after a partial decode\n"); - ret = AVERROR(EINVAL); - goto finish; - } - - if (!avci->compat_decode_partial_size) { - ret = avcodec_send_packet(avctx, pkt); - if (ret == AVERROR_EOF) - ret = 0; - else if (ret == AVERROR(EAGAIN)) { - /* we fully drain all the output in each decode call, so this should not - * ever happen */ - ret = AVERROR_BUG; - goto finish; - } else if (ret < 0) - goto finish; - } - - while (ret >= 0) { - ret = avcodec_receive_frame(avctx, frame); - if (ret < 0) { - if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) - ret = 0; - goto finish; - } - - if (frame != avci->compat_decode_frame) { - if (!avctx->refcounted_frames) { - ret = unrefcount_frame(avci, frame); - if (ret < 0) - goto finish; - } - - *got_frame = 1; - frame = avci->compat_decode_frame; - } else { - if (!avci->compat_decode_warned) { - av_log(avctx, AV_LOG_WARNING, "The deprecated avcodec_decode_* " - "API cannot return all the frames for this decoder. " - "Some frames will be dropped. Update your code to the " - "new decoding API to fix this.\n"); - avci->compat_decode_warned = 1; - } - } - - if (avci->draining || (!avctx->codec->bsfs && avci->compat_decode_consumed < pkt->size)) - break; - } - -finish: - if (ret == 0) { - /* if there are any bsfs then assume full packet is always consumed */ - if (avctx->codec->bsfs) - ret = pkt->size; - else - ret = FFMIN(avci->compat_decode_consumed, pkt->size); - } - avci->compat_decode_consumed = 0; - avci->compat_decode_partial_size = (ret >= 0) ? pkt->size - ret : 0; - - return ret; -} - -int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, - int *got_picture_ptr, - const AVPacket *avpkt) -{ - return compat_decode(avctx, picture, got_picture_ptr, avpkt); -} - -int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, - AVFrame *frame, - int *got_frame_ptr, - const AVPacket *avpkt) -{ - return compat_decode(avctx, frame, got_frame_ptr, avpkt); -} -FF_ENABLE_DEPRECATION_WARNINGS -#endif - static void get_subtitle_defaults(AVSubtitle *sub) { memset(sub, 0, sizeof(*sub)); @@ -958,79 +813,6 @@ static int utf8_check(const uint8_t *str) return 1; } -#if FF_API_ASS_TIMING -static void insert_ts(AVBPrint *buf, int ts) -{ - if (ts == -1) { - av_bprintf(buf, "9:59:59.99,"); - } else { - int h, m, s; - - h = ts/360000; ts -= 360000*h; - m = ts/ 6000; ts -= 6000*m; - s = ts/ 100; ts -= 100*s; - av_bprintf(buf, "%d:%02d:%02d.%02d,", h, m, s, ts); - } -} - -static int convert_sub_to_old_ass_form(AVSubtitle *sub, const AVPacket *pkt, AVRational tb) -{ - int i; - AVBPrint buf; - - av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED); - - for (i = 0; i < sub->num_rects; i++) { - char *final_dialog; - const char *dialog; - AVSubtitleRect *rect = sub->rects[i]; - int ts_start, ts_duration = -1; - long int layer; - - if (rect->type != SUBTITLE_ASS || !strncmp(rect->ass, "Dialogue: ", 10)) - continue; - - av_bprint_clear(&buf); - - /* skip ReadOrder */ - dialog = strchr(rect->ass, ','); - if (!dialog) - continue; - dialog++; - - /* extract Layer or Marked */ - layer = strtol(dialog, (char**)&dialog, 10); - if (*dialog != ',') - continue; - dialog++; - - /* rescale timing to ASS time base (ms) */ - ts_start = av_rescale_q(pkt->pts, tb, av_make_q(1, 100)); - if (pkt->duration != -1) - ts_duration = av_rescale_q(pkt->duration, tb, av_make_q(1, 100)); - sub->end_display_time = FFMAX(sub->end_display_time, 10 * ts_duration); - - /* construct ASS (standalone file form with timestamps) string */ - av_bprintf(&buf, "Dialogue: %ld,", layer); - insert_ts(&buf, ts_start); - insert_ts(&buf, ts_duration == -1 ? -1 : ts_start + ts_duration); - av_bprintf(&buf, "%s\r\n", dialog); - - final_dialog = av_strdup(buf.str); - if (!av_bprint_is_complete(&buf) || !final_dialog) { - av_freep(&final_dialog); - av_bprint_finalize(&buf, NULL); - return AVERROR(ENOMEM); - } - av_freep(&rect->ass); - rect->ass = final_dialog; - } - - av_bprint_finalize(&buf, NULL); - return 0; -} -#endif - int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt) @@ -1062,20 +844,15 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, if (avctx->pkt_timebase.num && avpkt->pts != AV_NOPTS_VALUE) sub->pts = av_rescale_q(avpkt->pts, avctx->pkt_timebase, AV_TIME_BASE_Q); - ret = avctx->codec->decode(avctx, sub, got_sub_ptr, pkt); - av_assert1((ret >= 0) >= !!*got_sub_ptr && - !!*got_sub_ptr >= !!sub->num_rects); - -#if FF_API_ASS_TIMING - if (avctx->sub_text_format == FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS - && *got_sub_ptr && sub->num_rects) { - const AVRational tb = avctx->pkt_timebase.num ? avctx->pkt_timebase - : avctx->time_base; - int err = convert_sub_to_old_ass_form(sub, avpkt, tb); - if (err < 0) - ret = err; + ret = ffcodec(avctx->codec)->cb.decode_sub(avctx, sub, got_sub_ptr, pkt); + if (pkt == avci->buffer_pkt) // did we recode? + av_packet_unref(avci->buffer_pkt); + if (ret < 0) { + *got_sub_ptr = 0; + avsubtitle_free(sub); + return ret; } -#endif + av_assert1(!sub->num_rects || *got_sub_ptr); if (sub->num_rects && !sub->end_display_time && avpkt->duration && avctx->pkt_timebase.num) { @@ -1096,16 +873,13 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, "Invalid UTF-8 in decoded subtitles text; " "maybe missing -sub_charenc option\n"); avsubtitle_free(sub); - ret = AVERROR_INVALIDDATA; - break; + *got_sub_ptr = 0; + return AVERROR_INVALIDDATA; } } if (*got_sub_ptr) avctx->frame_number++; - - if (pkt == avci->buffer_pkt) // did we recode? - av_packet_unref(avci->buffer_pkt); } return ret; @@ -1120,11 +894,11 @@ enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *avctx, // If a device was supplied when the codec was opened, assume that the // user wants to use it. - if (avctx->hw_device_ctx && avctx->codec->hw_configs) { + if (avctx->hw_device_ctx && ffcodec(avctx->codec)->hw_configs) { AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)avctx->hw_device_ctx->data; for (i = 0;; i++) { - config = &avctx->codec->hw_configs[i]->public; + config = &ffcodec(avctx->codec)->hw_configs[i]->public; if (!config) break; if (!(config->methods & @@ -1236,7 +1010,7 @@ int avcodec_get_hw_frames_parameters(AVCodecContext *avctx, int i, ret; for (i = 0;; i++) { - hw_config = avctx->codec->hw_configs[i]; + hw_config = ffcodec(avctx->codec)->hw_configs[i]; if (!hw_config) return AVERROR(ENOENT); if (hw_config->public.pix_fmt == hw_pix_fmt) @@ -1344,12 +1118,10 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt) avctx->sw_pix_fmt = fmt[n - 1]; } - choices = av_malloc_array(n + 1, sizeof(*choices)); + choices = av_memdup(fmt, (n + 1) * sizeof(*choices)); if (!choices) return AV_PIX_FMT_NONE; - memcpy(choices, fmt, (n + 1) * sizeof(*choices)); - for (;;) { // Remove the previous hwaccel, if there was one. hwaccel_uninit(avctx); @@ -1382,9 +1154,9 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt) break; } - if (avctx->codec->hw_configs) { + if (ffcodec(avctx->codec)->hw_configs) { for (i = 0;; i++) { - hw_config = avctx->codec->hw_configs[i]; + hw_config = ffcodec(avctx->codec)->hw_configs[i]; if (!hw_config) break; if (hw_config->public.pix_fmt == user_choice) @@ -1460,265 +1232,9 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt) return ret; } -static void frame_pool_free(void *opaque, uint8_t *data) -{ - FramePool *pool = (FramePool*)data; - int i; - - for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++) - av_buffer_pool_uninit(&pool->pools[i]); - - av_freep(&data); -} - -static AVBufferRef *frame_pool_alloc(void) -{ - FramePool *pool = av_mallocz(sizeof(*pool)); - AVBufferRef *buf; - - if (!pool) - return NULL; - - buf = av_buffer_create((uint8_t*)pool, sizeof(*pool), - frame_pool_free, NULL, 0); - if (!buf) { - av_freep(&pool); - return NULL; - } - - return buf; -} - -static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame) -{ - FramePool *pool = avctx->internal->pool ? - (FramePool*)avctx->internal->pool->data : NULL; - AVBufferRef *pool_buf; - int i, ret, ch, planes; - - if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) { - int planar = av_sample_fmt_is_planar(frame->format); - ch = frame->channels; - planes = planar ? ch : 1; - } - - if (pool && pool->format == frame->format) { - if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && - pool->width == frame->width && pool->height == frame->height) - return 0; - if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && pool->planes == planes && - pool->channels == ch && frame->nb_samples == pool->samples) - return 0; - } - - pool_buf = frame_pool_alloc(); - if (!pool_buf) - return AVERROR(ENOMEM); - pool = (FramePool*)pool_buf->data; - - switch (avctx->codec_type) { - case AVMEDIA_TYPE_VIDEO: { - int linesize[4]; - int w = frame->width; - int h = frame->height; - int unaligned; - ptrdiff_t linesize1[4]; - size_t size[4]; - - avcodec_align_dimensions2(avctx, &w, &h, pool->stride_align); - - do { - // NOTE: do not align linesizes individually, this breaks e.g. assumptions - // that linesize[0] == 2*linesize[1] in the MPEG-encoder for 4:2:2 - ret = av_image_fill_linesizes(linesize, avctx->pix_fmt, w); - if (ret < 0) - goto fail; - // increase alignment of w for next try (rhs gives the lowest bit set in w) - w += w & ~(w - 1); - - unaligned = 0; - for (i = 0; i < 4; i++) - unaligned |= linesize[i] % pool->stride_align[i]; - } while (unaligned); - - for (i = 0; i < 4; i++) - linesize1[i] = linesize[i]; - ret = av_image_fill_plane_sizes(size, avctx->pix_fmt, h, linesize1); - if (ret < 0) - goto fail; - - for (i = 0; i < 4; i++) { - pool->linesize[i] = linesize[i]; - if (size[i]) { - if (size[i] > INT_MAX - (16 + STRIDE_ALIGN - 1)) { - ret = AVERROR(EINVAL); - goto fail; - } - pool->pools[i] = av_buffer_pool_init(size[i] + 16 + STRIDE_ALIGN - 1, - CONFIG_MEMORY_POISONING ? - NULL : - av_buffer_allocz); - if (!pool->pools[i]) { - ret = AVERROR(ENOMEM); - goto fail; - } - } - } - pool->format = frame->format; - pool->width = frame->width; - pool->height = frame->height; - - break; - } - case AVMEDIA_TYPE_AUDIO: { - ret = av_samples_get_buffer_size(&pool->linesize[0], ch, - frame->nb_samples, frame->format, 0); - if (ret < 0) - goto fail; - - pool->pools[0] = av_buffer_pool_init(pool->linesize[0], NULL); - if (!pool->pools[0]) { - ret = AVERROR(ENOMEM); - goto fail; - } - - pool->format = frame->format; - pool->planes = planes; - pool->channels = ch; - pool->samples = frame->nb_samples; - break; - } - default: av_assert0(0); - } - - av_buffer_unref(&avctx->internal->pool); - avctx->internal->pool = pool_buf; - - return 0; -fail: - av_buffer_unref(&pool_buf); - return ret; -} - -static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame) -{ - FramePool *pool = (FramePool*)avctx->internal->pool->data; - int planes = pool->planes; - int i; - - frame->linesize[0] = pool->linesize[0]; - - if (planes > AV_NUM_DATA_POINTERS) { - frame->extended_data = av_mallocz_array(planes, sizeof(*frame->extended_data)); - frame->nb_extended_buf = planes - AV_NUM_DATA_POINTERS; - frame->extended_buf = av_mallocz_array(frame->nb_extended_buf, - sizeof(*frame->extended_buf)); - if (!frame->extended_data || !frame->extended_buf) { - av_freep(&frame->extended_data); - av_freep(&frame->extended_buf); - return AVERROR(ENOMEM); - } - } else { - frame->extended_data = frame->data; - av_assert0(frame->nb_extended_buf == 0); - } - - for (i = 0; i < FFMIN(planes, AV_NUM_DATA_POINTERS); i++) { - frame->buf[i] = av_buffer_pool_get(pool->pools[0]); - if (!frame->buf[i]) - goto fail; - frame->extended_data[i] = frame->data[i] = frame->buf[i]->data; - } - for (i = 0; i < frame->nb_extended_buf; i++) { - frame->extended_buf[i] = av_buffer_pool_get(pool->pools[0]); - if (!frame->extended_buf[i]) - goto fail; - frame->extended_data[i + AV_NUM_DATA_POINTERS] = frame->extended_buf[i]->data; - } - - if (avctx->debug & FF_DEBUG_BUFFERS) - av_log(avctx, AV_LOG_DEBUG, "default_get_buffer called on frame %p", frame); - - return 0; -fail: - av_frame_unref(frame); - return AVERROR(ENOMEM); -} - -static int video_get_buffer(AVCodecContext *s, AVFrame *pic) -{ - FramePool *pool = (FramePool*)s->internal->pool->data; - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pic->format); - int i; - - if (pic->data[0] || pic->data[1] || pic->data[2] || pic->data[3]) { - av_log(s, AV_LOG_ERROR, "pic->data[*]!=NULL in avcodec_default_get_buffer\n"); - return -1; - } - - if (!desc) { - av_log(s, AV_LOG_ERROR, - "Unable to get pixel format descriptor for format %s\n", - av_get_pix_fmt_name(pic->format)); - return AVERROR(EINVAL); - } - - memset(pic->data, 0, sizeof(pic->data)); - pic->extended_data = pic->data; - - for (i = 0; i < 4 && pool->pools[i]; i++) { - pic->linesize[i] = pool->linesize[i]; - - pic->buf[i] = av_buffer_pool_get(pool->pools[i]); - if (!pic->buf[i]) - goto fail; - - pic->data[i] = pic->buf[i]->data; - } - for (; i < AV_NUM_DATA_POINTERS; i++) { - pic->data[i] = NULL; - pic->linesize[i] = 0; - } - if (desc->flags & AV_PIX_FMT_FLAG_PAL || - ((desc->flags & FF_PSEUDOPAL) && pic->data[1])) - avpriv_set_systematic_pal2((uint32_t *)pic->data[1], pic->format); - - if (s->debug & FF_DEBUG_BUFFERS) - av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p\n", pic); - - return 0; -fail: - av_frame_unref(pic); - return AVERROR(ENOMEM); -} - -int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags) -{ - int ret; - - if (avctx->hw_frames_ctx) { - ret = av_hwframe_get_buffer(avctx->hw_frames_ctx, frame, 0); - frame->width = avctx->coded_width; - frame->height = avctx->coded_height; - return ret; - } - - if ((ret = update_frame_pool(avctx, frame)) < 0) - return ret; - - switch (avctx->codec_type) { - case AVMEDIA_TYPE_VIDEO: - return video_get_buffer(avctx, frame); - case AVMEDIA_TYPE_AUDIO: - return audio_get_buffer(avctx, frame); - default: - return -1; - } -} - static int add_metadata_from_side_data(const AVPacket *avpkt, AVFrame *frame) { - buffer_size_t size; + size_t size; const uint8_t *side_metadata; AVDictionary **frame_md = &frame->metadata; @@ -1745,21 +1261,17 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) { AV_PKT_DATA_A53_CC, AV_FRAME_DATA_A53_CC }, { AV_PKT_DATA_ICC_PROFILE, AV_FRAME_DATA_ICC_PROFILE }, { AV_PKT_DATA_S12M_TIMECODE, AV_FRAME_DATA_S12M_TIMECODE }, + { AV_PKT_DATA_DYNAMIC_HDR10_PLUS, AV_FRAME_DATA_DYNAMIC_HDR_PLUS }, }; - if (!(avctx->codec->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS)) { + if (!(ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS)) { frame->pts = pkt->pts; -#if FF_API_PKT_PTS -FF_DISABLE_DEPRECATION_WARNINGS - frame->pkt_pts = pkt->pts; -FF_ENABLE_DEPRECATION_WARNINGS -#endif frame->pkt_pos = pkt->pos; frame->pkt_duration = pkt->duration; frame->pkt_size = pkt->size; for (int i = 0; i < FF_ARRAY_ELEMS(sd); i++) { - buffer_size_t size; + size_t size; uint8_t *packet_sd = av_packet_get_side_data(pkt, sd[i].packet, &size); if (packet_sd) { AVFrameSideData *frame_sd = av_frame_new_side_data(frame, @@ -1813,25 +1325,18 @@ FF_ENABLE_DEPRECATION_WARNINGS frame->sample_rate = avctx->sample_rate; if (frame->format < 0) frame->format = avctx->sample_fmt; - if (!frame->channel_layout) { - if (avctx->channel_layout) { - if (av_get_channel_layout_nb_channels(avctx->channel_layout) != - avctx->channels) { - av_log(avctx, AV_LOG_ERROR, "Inconsistent channel " - "configuration.\n"); - return AVERROR(EINVAL); - } - - frame->channel_layout = avctx->channel_layout; - } else { - if (avctx->channels > FF_SANE_NB_CHANNELS) { - av_log(avctx, AV_LOG_ERROR, "Too many channels: %d.\n", - avctx->channels); - return AVERROR(ENOSYS); - } - } + if (!frame->ch_layout.nb_channels) { + int ret = av_channel_layout_copy(&frame->ch_layout, &avctx->ch_layout); + if (ret < 0) + return ret; } - frame->channels = avctx->channels; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + frame->channels = frame->ch_layout.nb_channels; + frame->channel_layout = frame->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ? + frame->ch_layout.u.mask : 0; +FF_ENABLE_DEPRECATION_WARNINGS +#endif break; } return 0; @@ -1846,8 +1351,6 @@ static void validate_avframe_allocation(AVCodecContext *avctx, AVFrame *frame) int flags = desc ? desc->flags : 0; if (num_planes == 1 && (flags & AV_PIX_FMT_FLAG_PAL)) num_planes = 2; - if ((flags & FF_PSEUDOPAL) && frame->data[1]) - num_planes = 2; for (i = 0; i < num_planes; i++) { av_assert0(frame->data[i]); } @@ -1903,6 +1406,8 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) int override_dimensions = 1; int ret; + av_assert0(av_codec_is_decoder(avctx->codec)); + if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) { if ((unsigned)avctx->width > INT_MAX - STRIDE_ALIGN || (ret = av_image_check_size2(FFALIGN(avctx->width, STRIDE_ALIGN), avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) < 0 || avctx->pix_fmt<0) { @@ -1923,7 +1428,16 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) goto fail; } } else if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) { - if (frame->nb_samples * (int64_t)avctx->channels > avctx->max_samples) { +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + /* compat layer for old-style get_buffer() implementations */ + avctx->channels = avctx->ch_layout.nb_channels; + avctx->channel_layout = (avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE) ? + avctx->ch_layout.u.mask : 0; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + + if (frame->nb_samples * (int64_t)avctx->ch_layout.nb_channels > avctx->max_samples) { av_log(avctx, AV_LOG_ERROR, "samples per frame %d, exceeds max_samples %"PRId64"\n", frame->nb_samples, avctx->max_samples); ret = AVERROR(EINVAL); goto fail; @@ -1953,7 +1467,7 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) end: if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions && - !(avctx->codec->caps_internal & FF_CODEC_CAP_EXPORTS_CROPPING)) { + !(ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_EXPORTS_CROPPING)) { frame->width = avctx->width; frame->height = avctx->height; } @@ -2014,6 +1528,7 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) int ff_decode_preinit(AVCodecContext *avctx) { + AVCodecInternal *avci = avctx->internal; int ret = 0; /* if the decoder init function was already called previously, @@ -2033,11 +1548,51 @@ FF_DISABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS #endif + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && avctx->ch_layout.nb_channels == 0 && + !(avctx->codec->capabilities & AV_CODEC_CAP_CHANNEL_CONF)) { + av_log(avctx, AV_LOG_ERROR, "Decoder requires channel count but channels not set\n"); + return AVERROR(EINVAL); + } if (avctx->codec->max_lowres < avctx->lowres || avctx->lowres < 0) { av_log(avctx, AV_LOG_WARNING, "The maximum value for lowres supported by the decoder is %d\n", avctx->codec->max_lowres); avctx->lowres = avctx->codec->max_lowres; } + if (avctx->sub_charenc) { + if (avctx->codec_type != AVMEDIA_TYPE_SUBTITLE) { + av_log(avctx, AV_LOG_ERROR, "Character encoding is only " + "supported with subtitles codecs\n"); + return AVERROR(EINVAL); + } else if (avctx->codec_descriptor->props & AV_CODEC_PROP_BITMAP_SUB) { + av_log(avctx, AV_LOG_WARNING, "Codec '%s' is bitmap-based, " + "subtitles character encoding will be ignored\n", + avctx->codec_descriptor->name); + avctx->sub_charenc_mode = FF_SUB_CHARENC_MODE_DO_NOTHING; + } else { + /* input character encoding is set for a text based subtitle + * codec at this point */ + if (avctx->sub_charenc_mode == FF_SUB_CHARENC_MODE_AUTOMATIC) + avctx->sub_charenc_mode = FF_SUB_CHARENC_MODE_PRE_DECODER; + + if (avctx->sub_charenc_mode == FF_SUB_CHARENC_MODE_PRE_DECODER) { +#if CONFIG_ICONV + iconv_t cd = iconv_open("UTF-8", avctx->sub_charenc); + if (cd == (iconv_t)-1) { + ret = AVERROR(errno); + av_log(avctx, AV_LOG_ERROR, "Unable to open iconv context " + "with input character encoding \"%s\"\n", avctx->sub_charenc); + return ret; + } + iconv_close(cd); +#else + av_log(avctx, AV_LOG_ERROR, "Character encoding subtitles " + "conversion needs a libavcodec built with iconv support " + "for this codec\n"); + return AVERROR(ENOSYS); +#endif + } + } + } avctx->pts_correction_num_faulty_pts = avctx->pts_correction_num_faulty_dts = 0; @@ -2052,9 +1607,31 @@ FF_ENABLE_DEPRECATION_WARNINGS avctx->export_side_data |= AV_CODEC_EXPORT_DATA_MVS; } + avci->in_pkt = av_packet_alloc(); + avci->last_pkt_props = av_packet_alloc(); + avci->pkt_props = av_fifo_alloc2(1, sizeof(*avci->last_pkt_props), + AV_FIFO_FLAG_AUTO_GROW); + if (!avci->in_pkt || !avci->last_pkt_props || !avci->pkt_props) + return AVERROR(ENOMEM); + ret = decode_bsfs_init(avctx); if (ret < 0) return ret; return 0; } + +int ff_copy_palette(void *dst, const AVPacket *src, void *logctx) +{ + size_t size; + const void *pal = av_packet_get_side_data(src, AV_PKT_DATA_PALETTE, &size); + + if (pal && size == AVPALETTE_SIZE) { + memcpy(dst, pal, AVPALETTE_SIZE); + return 1; + } else if (pal) { + av_log(logctx, AV_LOG_ERROR, + "Palette size %"SIZE_SPECIFIER" is wrong\n", size); + } + return 0; +} diff --git a/media/ffvpx/libavcodec/decode.h b/media/ffvpx/libavcodec/decode.h index 1467b1eb3378..1b40f714e12e 100644 --- a/media/ffvpx/libavcodec/decode.h +++ b/media/ffvpx/libavcodec/decode.h @@ -79,9 +79,18 @@ int ff_decode_get_hw_frames_ctx(AVCodecContext *avctx, int ff_attach_decode_data(AVFrame *frame); +/** + * Check whether the side-data of src contains a palette of + * size AVPALETTE_SIZE; if so, copy it to dst and return 1; + * else return 0. + * Also emit an error message upon encountering a palette + * with invalid size. + */ +int ff_copy_palette(void *dst, const AVPacket *src, void *logctx); + /** * Perform decoder initialization and validation. - * Called when opening the decoder, before the AVCodec.init() call. + * Called when opening the decoder, before the FFCodec.init() call. */ int ff_decode_preinit(AVCodecContext *avctx); diff --git a/media/ffvpx/libavcodec/defs.h b/media/ffvpx/libavcodec/defs.h new file mode 100644 index 000000000000..420a042b8ff4 --- /dev/null +++ b/media/ffvpx/libavcodec/defs.h @@ -0,0 +1,170 @@ +/* + * + * 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 + */ + +#ifndef AVCODEC_DEFS_H +#define AVCODEC_DEFS_H + +/** + * @file + * @ingroup libavc + * Misc types and constants that do not belong anywhere else. + */ + +#include +#include + +/** + * @ingroup lavc_decoding + * Required number of additionally allocated bytes at the end of the input bitstream for decoding. + * This is mainly needed because some optimized bitstream readers read + * 32 or 64 bit at once and could read over the end.
+ * Note: If the first 23 bits of the additional bytes are not 0, then damaged + * MPEG bitstreams could cause overread and segfault. + */ +#define AV_INPUT_BUFFER_PADDING_SIZE 64 + +/** + * @ingroup lavc_decoding + */ +enum AVDiscard{ + /* We leave some space between them for extensions (drop some + * keyframes for intra-only or drop just some bidir frames). */ + AVDISCARD_NONE =-16, ///< discard nothing + AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi + AVDISCARD_NONREF = 8, ///< discard all non reference + AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames + AVDISCARD_NONINTRA= 24, ///< discard all non intra frames + AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes + AVDISCARD_ALL = 48, ///< discard all +}; + +enum AVAudioServiceType { + AV_AUDIO_SERVICE_TYPE_MAIN = 0, + AV_AUDIO_SERVICE_TYPE_EFFECTS = 1, + AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2, + AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3, + AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4, + AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5, + AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6, + AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7, + AV_AUDIO_SERVICE_TYPE_KARAOKE = 8, + AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI +}; + +/** + * Pan Scan area. + * This specifies the area which should be displayed. + * Note there may be multiple such areas for one frame. + */ +typedef struct AVPanScan { + /** + * id + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int id; + + /** + * width and height in 1/16 pel + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int width; + int height; + + /** + * position of the top left corner in 1/16 pel for up to 3 fields/frames + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int16_t position[3][2]; +} AVPanScan; + +/** + * This structure describes the bitrate properties of an encoded bitstream. It + * roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD + * parameters for H.264/HEVC. + */ +typedef struct AVCPBProperties { + /** + * Maximum bitrate of the stream, in bits per second. + * Zero if unknown or unspecified. + */ + int64_t max_bitrate; + /** + * Minimum bitrate of the stream, in bits per second. + * Zero if unknown or unspecified. + */ + int64_t min_bitrate; + /** + * Average bitrate of the stream, in bits per second. + * Zero if unknown or unspecified. + */ + int64_t avg_bitrate; + + /** + * The size of the buffer to which the ratecontrol is applied, in bits. + * Zero if unknown or unspecified. + */ + int64_t buffer_size; + + /** + * The delay between the time the packet this structure is associated with + * is received and the time when it should be decoded, in periods of a 27MHz + * clock. + * + * UINT64_MAX when unknown or unspecified. + */ + uint64_t vbv_delay; +} AVCPBProperties; + +/** + * Allocate a CPB properties structure and initialize its fields to default + * values. + * + * @param size if non-NULL, the size of the allocated struct will be written + * here. This is useful for embedding it in side data. + * + * @return the newly allocated struct or NULL on failure + */ +AVCPBProperties *av_cpb_properties_alloc(size_t *size); + +/** + * This structure supplies correlation between a packet timestamp and a wall clock + * production time. The definition follows the Producer Reference Time ('prft') + * as defined in ISO/IEC 14496-12 + */ +typedef struct AVProducerReferenceTime { + /** + * A UTC timestamp, in microseconds, since Unix epoch (e.g, av_gettime()). + */ + int64_t wallclock; + int flags; +} AVProducerReferenceTime; + +/** + * Encode extradata length to a buffer. Used by xiph codecs. + * + * @param s buffer to write to; must be at least (v/255+1) bytes long + * @param v size of extradata in bytes + * @return number of bytes written to the buffer. + */ +unsigned int av_xiphlacing(unsigned char *s, unsigned int v); + +#endif // AVCODEC_DEFS_H diff --git a/media/ffvpx/libavcodec/encode.c b/media/ffvpx/libavcodec/encode.c index 89df5235dafd..b68bf1e184a9 100644 --- a/media/ffvpx/libavcodec/encode.c +++ b/media/ffvpx/libavcodec/encode.c @@ -20,17 +20,19 @@ #include "libavutil/attributes.h" #include "libavutil/avassert.h" +#include "libavutil/channel_layout.h" #include "libavutil/frame.h" #include "libavutil/imgutils.h" #include "libavutil/internal.h" #include "libavutil/samplefmt.h" #include "avcodec.h" +#include "codec_internal.h" #include "encode.h" #include "frame_thread_encoder.h" #include "internal.h" -int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size) +int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size) { if (size < 0 || size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) { av_log(avctx, AV_LOG_ERROR, "Invalid minimum required packet size %"PRId64" (max allowed is %d)\n", @@ -40,18 +42,14 @@ int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64 av_assert0(!avpkt->data); - if (avctx && 2*min_size < size) { // FIXME The factor needs to be finetuned - av_fast_padded_malloc(&avctx->internal->byte_buffer, &avctx->internal->byte_buffer_size, size); - avpkt->data = avctx->internal->byte_buffer; - avpkt->size = size; - } - + av_fast_padded_malloc(&avctx->internal->byte_buffer, + &avctx->internal->byte_buffer_size, size); + avpkt->data = avctx->internal->byte_buffer; if (!avpkt->data) { - int ret = av_new_packet(avpkt, size); - if (ret < 0) - av_log(avctx, AV_LOG_ERROR, "Failed to allocate packet of size %"PRId64"\n", size); - return ret; + av_log(avctx, AV_LOG_ERROR, "Failed to allocate packet of size %"PRId64"\n", size); + return AVERROR(ENOMEM); } + avpkt->size = size; return 0; } @@ -74,7 +72,6 @@ int avcodec_default_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, in return ret; } avpkt->data = avpkt->buf->data; - memset(avpkt->data + avpkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE); return 0; } @@ -98,6 +95,7 @@ int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, i ret = AVERROR(EINVAL); goto fail; } + memset(avpkt->data + avpkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE); ret = 0; fail: @@ -117,9 +115,10 @@ static int pad_last_frame(AVCodecContext *s, AVFrame *frame, const AVFrame *src) int ret; frame->format = src->format; - frame->channel_layout = src->channel_layout; - frame->channels = src->channels; frame->nb_samples = s->frame_size; + ret = av_channel_layout_copy(&frame->ch_layout, &s->ch_layout); + if (ret < 0) + goto fail; ret = av_frame_get_buffer(frame, 0); if (ret < 0) goto fail; @@ -129,11 +128,12 @@ static int pad_last_frame(AVCodecContext *s, AVFrame *frame, const AVFrame *src) goto fail; if ((ret = av_samples_copy(frame->extended_data, src->extended_data, 0, 0, - src->nb_samples, s->channels, s->sample_fmt)) < 0) + src->nb_samples, s->ch_layout.nb_channels, + s->sample_fmt)) < 0) goto fail; if ((ret = av_samples_set_silence(frame->extended_data, src->nb_samples, frame->nb_samples - src->nb_samples, - s->channels, s->sample_fmt)) < 0) + s->ch_layout.nb_channels, s->sample_fmt)) < 0) goto fail; return 0; @@ -152,7 +152,7 @@ int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, return -1; } - ret = avctx->codec->encode_sub(avctx, buf, buf_size, sub); + ret = ffcodec(avctx->codec)->cb.encode_sub(avctx, buf, buf_size, sub); avctx->frame_number++; return ret; } @@ -175,8 +175,8 @@ int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame) static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt) { AVCodecInternal *avci = avctx->internal; - EncodeSimpleContext *es = &avci->es; - AVFrame *frame = es->in_frame; + AVFrame *frame = avci->in_frame; + const FFCodec *const codec = ffcodec(avctx->codec); int got_packet; int ret; @@ -201,7 +201,7 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt) got_packet = 0; - av_assert0(avctx->codec->encode2); + av_assert0(codec->cb_type == FF_CODEC_CB_TYPE_ENCODE); if (CONFIG_FRAME_THREAD_ENCODER && avci->frame_thread_encoder && (avctx->active_thread_type & FF_THREAD_FRAME)) @@ -211,7 +211,7 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt) * no sense to use the properties of the current frame anyway). */ ret = ff_thread_video_encode_frame(avctx, avpkt, frame, &got_packet); else { - ret = avctx->codec->encode2(avctx, avpkt, frame, &got_packet); + ret = codec->cb.encode(avctx, avpkt, frame, &got_packet); if (avctx->codec->type == AVMEDIA_TYPE_VIDEO && !ret && got_packet && !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY)) avpkt->pts = avpkt->dts = frame->pts; @@ -238,12 +238,9 @@ static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt) } } if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) { - /* NOTE: if we add any audio encoders which output non-keyframe packets, - * this needs to be moved to the encoders, but for now we can do it - * here to simplify things */ - avpkt->flags |= AV_PKT_FLAG_KEY; avpkt->dts = avpkt->pts; } + avpkt->flags |= avci->intra_only_flag; } if (avci->draining && !got_packet) @@ -253,11 +250,8 @@ end: if (ret < 0 || !got_packet) av_packet_unref(avpkt); - if (frame) { - if (!ret) - avctx->frame_number++; + if (frame) av_frame_unref(frame); - } if (got_packet) // Encoders must always return ref-counted buffers. @@ -297,8 +291,8 @@ static int encode_receive_packet_internal(AVCodecContext *avctx, AVPacket *avpkt return AVERROR(EINVAL); } - if (avctx->codec->receive_packet) { - ret = avctx->codec->receive_packet(avctx, avpkt); + if (ffcodec(avctx->codec)->cb_type == FF_CODEC_CB_TYPE_RECEIVE_PACKET) { + ret = ffcodec(avctx->codec)->cb.receive_packet(avctx, avpkt); if (ret < 0) av_packet_unref(avpkt); else @@ -372,7 +366,7 @@ int attribute_align_arg avcodec_send_frame(AVCodecContext *avctx, const AVFrame if (avci->draining) return AVERROR_EOF; - if (avci->buffer_frame->data[0]) + if (avci->buffer_frame->buf[0]) return AVERROR(EAGAIN); if (!frame) { @@ -389,6 +383,8 @@ int attribute_align_arg avcodec_send_frame(AVCodecContext *avctx, const AVFrame return ret; } + avctx->frame_number++; + return 0; } @@ -413,160 +409,16 @@ int attribute_align_arg avcodec_receive_packet(AVCodecContext *avctx, AVPacket * return 0; } -#if FF_API_OLD_ENCDEC -static int compat_encode(AVCodecContext *avctx, AVPacket *avpkt, - int *got_packet, const AVFrame *frame) -{ - AVCodecInternal *avci = avctx->internal; - AVPacket user_pkt; - int ret; - - *got_packet = 0; - - if (frame && avctx->codec->type == AVMEDIA_TYPE_VIDEO) { - if (frame->format == AV_PIX_FMT_NONE) - av_log(avctx, AV_LOG_WARNING, "AVFrame.format is not set\n"); - if (frame->width == 0 || frame->height == 0) - av_log(avctx, AV_LOG_WARNING, "AVFrame.width or height is not set\n"); - } - - if (avctx->codec->capabilities & AV_CODEC_CAP_DR1) { - av_log(avctx, AV_LOG_WARNING, "The deprecated avcodec_encode_* API does not support " - "AV_CODEC_CAP_DR1 encoders\n"); - return AVERROR(ENOSYS); - } - - ret = avcodec_send_frame(avctx, frame); - if (ret == AVERROR_EOF) - ret = 0; - else if (ret == AVERROR(EAGAIN)) { - /* we fully drain all the output in each encode call, so this should not - * ever happen */ - return AVERROR_BUG; - } else if (ret < 0) - return ret; - - av_packet_move_ref(&user_pkt, avpkt); - while (ret >= 0) { - ret = avcodec_receive_packet(avctx, avpkt); - if (ret < 0) { - if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) - ret = 0; - goto finish; - } - - if (avpkt != avci->compat_encode_packet) { - if (avpkt->data && user_pkt.data) { - if (user_pkt.size >= avpkt->size) { - memcpy(user_pkt.data, avpkt->data, avpkt->size); - av_buffer_unref(&avpkt->buf); - avpkt->buf = user_pkt.buf; - avpkt->data = user_pkt.data; -FF_DISABLE_DEPRECATION_WARNINGS - av_init_packet(&user_pkt); -FF_ENABLE_DEPRECATION_WARNINGS - } else { - av_log(avctx, AV_LOG_ERROR, "Provided packet is too small, needs to be %d\n", avpkt->size); - av_packet_unref(avpkt); - ret = AVERROR(EINVAL); - goto finish; - } - } - - *got_packet = 1; - avpkt = avci->compat_encode_packet; - } else { - if (!avci->compat_decode_warned) { - av_log(avctx, AV_LOG_WARNING, "The deprecated avcodec_encode_* " - "API cannot return all the packets for this encoder. " - "Some packets will be dropped. Update your code to the " - "new encoding API to fix this.\n"); - avci->compat_decode_warned = 1; - av_packet_unref(avpkt); - } - } - - if (avci->draining) - break; - } - -finish: - if (ret < 0) - av_packet_unref(&user_pkt); - - return ret; -} - -int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, - AVPacket *avpkt, - const AVFrame *frame, - int *got_packet_ptr) -{ - int ret = compat_encode(avctx, avpkt, got_packet_ptr, frame); - - if (ret < 0) - av_packet_unref(avpkt); - - return ret; -} - -int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, - AVPacket *avpkt, - const AVFrame *frame, - int *got_packet_ptr) -{ - int ret = compat_encode(avctx, avpkt, got_packet_ptr, frame); - - if (ret < 0) - av_packet_unref(avpkt); - - return ret; -} -#endif - -int ff_encode_preinit(AVCodecContext *avctx) +static int encode_preinit_video(AVCodecContext *avctx) { + const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(avctx->pix_fmt); int i; -#if FF_API_CODED_FRAME -FF_DISABLE_DEPRECATION_WARNINGS - avctx->coded_frame = av_frame_alloc(); - if (!avctx->coded_frame) { - return AVERROR(ENOMEM); - } -FF_ENABLE_DEPRECATION_WARNINGS -#endif - if (avctx->time_base.num <= 0 || avctx->time_base.den <= 0) { - av_log(avctx, AV_LOG_ERROR, "The encoder timebase is not set.\n"); - return AVERROR(EINVAL); - } - - if (avctx->codec->sample_fmts) { - for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) { - if (avctx->sample_fmt == avctx->codec->sample_fmts[i]) - break; - if (avctx->channels == 1 && - av_get_planar_sample_fmt(avctx->sample_fmt) == - av_get_planar_sample_fmt(avctx->codec->sample_fmts[i])) { - avctx->sample_fmt = avctx->codec->sample_fmts[i]; - break; - } - } - if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) { - char buf[128]; - snprintf(buf, sizeof(buf), "%d", avctx->sample_fmt); - av_log(avctx, AV_LOG_ERROR, "Specified sample format %s is invalid or not supported\n", - (char *)av_x_if_null(av_get_sample_fmt_name(avctx->sample_fmt), buf)); - return AVERROR(EINVAL); - } - } if (avctx->codec->pix_fmts) { for (i = 0; avctx->codec->pix_fmts[i] != AV_PIX_FMT_NONE; i++) if (avctx->pix_fmt == avctx->codec->pix_fmts[i]) break; - if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_NONE - && !(avctx->codec_id == AV_CODEC_ID_MJPEG - && avctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL)) { + if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_NONE) { char buf[128]; snprintf(buf, sizeof(buf), "%d", avctx->pix_fmt); av_log(avctx, AV_LOG_ERROR, "Specified pixel format %s is invalid or not supported\n", @@ -580,74 +432,17 @@ FF_ENABLE_DEPRECATION_WARNINGS avctx->codec->pix_fmts[i] == AV_PIX_FMT_YUVJ444P) avctx->color_range = AVCOL_RANGE_JPEG; } - if (avctx->codec->supported_samplerates) { - for (i = 0; avctx->codec->supported_samplerates[i] != 0; i++) - if (avctx->sample_rate == avctx->codec->supported_samplerates[i]) - break; - if (avctx->codec->supported_samplerates[i] == 0) { - av_log(avctx, AV_LOG_ERROR, "Specified sample rate %d is not supported\n", - avctx->sample_rate); - return AVERROR(EINVAL); - } - } - if (avctx->sample_rate < 0) { - av_log(avctx, AV_LOG_ERROR, "Specified sample rate %d is not supported\n", - avctx->sample_rate); - return AVERROR(EINVAL); - } - if (avctx->codec->channel_layouts) { - if (!avctx->channel_layout) { - av_log(avctx, AV_LOG_WARNING, "Channel layout not specified\n"); - } else { - for (i = 0; avctx->codec->channel_layouts[i] != 0; i++) - if (avctx->channel_layout == avctx->codec->channel_layouts[i]) - break; - if (avctx->codec->channel_layouts[i] == 0) { - char buf[512]; - av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout); - av_log(avctx, AV_LOG_ERROR, "Specified channel layout '%s' is not supported\n", buf); - return AVERROR(EINVAL); - } - } - } - if (avctx->channel_layout && avctx->channels) { - int channels = av_get_channel_layout_nb_channels(avctx->channel_layout); - if (channels != avctx->channels) { - char buf[512]; - av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout); - av_log(avctx, AV_LOG_ERROR, - "Channel layout '%s' with %d channels does not match number of specified channels %d\n", - buf, channels, avctx->channels); - return AVERROR(EINVAL); - } - } else if (avctx->channel_layout) { - avctx->channels = av_get_channel_layout_nb_channels(avctx->channel_layout); - } - if (avctx->channels < 0) { - av_log(avctx, AV_LOG_ERROR, "Specified number of channels %d is not supported\n", - avctx->channels); - return AVERROR(EINVAL); - } - if(avctx->codec_type == AVMEDIA_TYPE_VIDEO) { - const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(avctx->pix_fmt); - if ( avctx->bits_per_raw_sample < 0 - || (avctx->bits_per_raw_sample > 8 && pixdesc->comp[0].depth <= 8)) { - av_log(avctx, AV_LOG_WARNING, "Specified bit depth %d not possible with the specified pixel formats depth %d\n", - avctx->bits_per_raw_sample, pixdesc->comp[0].depth); - avctx->bits_per_raw_sample = pixdesc->comp[0].depth; - } - if (avctx->width <= 0 || avctx->height <= 0) { - av_log(avctx, AV_LOG_ERROR, "dimensions not set\n"); - return AVERROR(EINVAL); - } - } - if ( (avctx->codec_type == AVMEDIA_TYPE_VIDEO || avctx->codec_type == AVMEDIA_TYPE_AUDIO) - && avctx->bit_rate>0 && avctx->bit_rate<1000) { - av_log(avctx, AV_LOG_WARNING, "Bitrate %"PRId64" is extremely low, maybe you mean %"PRId64"k\n", avctx->bit_rate, avctx->bit_rate); - } - if (!avctx->rc_initial_buffer_occupancy) - avctx->rc_initial_buffer_occupancy = avctx->rc_buffer_size * 3LL / 4; + if ( avctx->bits_per_raw_sample < 0 + || (avctx->bits_per_raw_sample > 8 && pixdesc->comp[0].depth <= 8)) { + av_log(avctx, AV_LOG_WARNING, "Specified bit depth %d not possible with the specified pixel formats depth %d\n", + avctx->bits_per_raw_sample, pixdesc->comp[0].depth); + avctx->bits_per_raw_sample = pixdesc->comp[0].depth; + } + if (avctx->width <= 0 || avctx->height <= 0) { + av_log(avctx, AV_LOG_ERROR, "dimensions not set\n"); + return AVERROR(EINVAL); + } if (avctx->ticks_per_frame && avctx->time_base.num && avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) { @@ -680,3 +475,159 @@ FF_ENABLE_DEPRECATION_WARNINGS return 0; } + +static int encode_preinit_audio(AVCodecContext *avctx) +{ + int i; + + if (avctx->codec->sample_fmts) { + for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) { + if (avctx->sample_fmt == avctx->codec->sample_fmts[i]) + break; + if (avctx->ch_layout.nb_channels == 1 && + av_get_planar_sample_fmt(avctx->sample_fmt) == + av_get_planar_sample_fmt(avctx->codec->sample_fmts[i])) { + avctx->sample_fmt = avctx->codec->sample_fmts[i]; + break; + } + } + if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) { + char buf[128]; + snprintf(buf, sizeof(buf), "%d", avctx->sample_fmt); + av_log(avctx, AV_LOG_ERROR, "Specified sample format %s is invalid or not supported\n", + (char *)av_x_if_null(av_get_sample_fmt_name(avctx->sample_fmt), buf)); + return AVERROR(EINVAL); + } + } + if (avctx->codec->supported_samplerates) { + for (i = 0; avctx->codec->supported_samplerates[i] != 0; i++) + if (avctx->sample_rate == avctx->codec->supported_samplerates[i]) + break; + if (avctx->codec->supported_samplerates[i] == 0) { + av_log(avctx, AV_LOG_ERROR, "Specified sample rate %d is not supported\n", + avctx->sample_rate); + return AVERROR(EINVAL); + } + } + if (avctx->sample_rate < 0) { + av_log(avctx, AV_LOG_ERROR, "Specified sample rate %d is not supported\n", + avctx->sample_rate); + return AVERROR(EINVAL); + } + if (avctx->codec->ch_layouts) { + if (!av_channel_layout_check(&avctx->ch_layout)) { + av_log(avctx, AV_LOG_WARNING, "Channel layout not specified correctly\n"); + return AVERROR(EINVAL); + } + + for (i = 0; avctx->codec->ch_layouts[i].nb_channels; i++) { + if (!av_channel_layout_compare(&avctx->ch_layout, &avctx->codec->ch_layouts[i])) + break; + } + if (!avctx->codec->ch_layouts[i].nb_channels) { + char buf[512]; + int ret = av_channel_layout_describe(&avctx->ch_layout, buf, sizeof(buf)); + if (ret > 0) + av_log(avctx, AV_LOG_ERROR, "Specified channel layout '%s' is not supported\n", buf); + return AVERROR(EINVAL); + } + } +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + if (avctx->channel_layout && avctx->channels) { + int channels = av_get_channel_layout_nb_channels(avctx->channel_layout); + if (channels != avctx->channels) { + char buf[512]; + av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout); + av_log(avctx, AV_LOG_ERROR, + "Channel layout '%s' with %d channels does not match number of specified channels %d\n", + buf, channels, avctx->channels); + return AVERROR(EINVAL); + } + } else if (avctx->channel_layout) { + avctx->channels = av_get_channel_layout_nb_channels(avctx->channel_layout); + } + if (avctx->channels < 0) { + av_log(avctx, AV_LOG_ERROR, "Specified number of channels %d is not supported\n", + avctx->channels); + return AVERROR(EINVAL); + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif + + if (!avctx->bits_per_raw_sample) + avctx->bits_per_raw_sample = 8 * av_get_bytes_per_sample(avctx->sample_fmt); + + return 0; +} + +int ff_encode_preinit(AVCodecContext *avctx) +{ + AVCodecInternal *avci = avctx->internal; + int ret = 0; + + if (avctx->time_base.num <= 0 || avctx->time_base.den <= 0) { + av_log(avctx, AV_LOG_ERROR, "The encoder timebase is not set.\n"); + return AVERROR(EINVAL); + } + + switch (avctx->codec_type) { + case AVMEDIA_TYPE_VIDEO: ret = encode_preinit_video(avctx); break; + case AVMEDIA_TYPE_AUDIO: ret = encode_preinit_audio(avctx); break; + } + if (ret < 0) + return ret; + + if ( (avctx->codec_type == AVMEDIA_TYPE_VIDEO || avctx->codec_type == AVMEDIA_TYPE_AUDIO) + && avctx->bit_rate>0 && avctx->bit_rate<1000) { + av_log(avctx, AV_LOG_WARNING, "Bitrate %"PRId64" is extremely low, maybe you mean %"PRId64"k\n", avctx->bit_rate, avctx->bit_rate); + } + + if (!avctx->rc_initial_buffer_occupancy) + avctx->rc_initial_buffer_occupancy = avctx->rc_buffer_size * 3LL / 4; + + if (avctx->codec_descriptor->props & AV_CODEC_PROP_INTRA_ONLY) + avctx->internal->intra_only_flag = AV_PKT_FLAG_KEY; + + if (ffcodec(avctx->codec)->cb_type == FF_CODEC_CB_TYPE_ENCODE) { + avci->in_frame = av_frame_alloc(); + if (!avci->in_frame) + return AVERROR(ENOMEM); + } + + return 0; +} + +int ff_encode_alloc_frame(AVCodecContext *avctx, AVFrame *frame) +{ + int ret; + + switch (avctx->codec->type) { + case AVMEDIA_TYPE_VIDEO: + frame->format = avctx->pix_fmt; + if (frame->width <= 0 || frame->height <= 0) { + frame->width = FFMAX(avctx->width, avctx->coded_width); + frame->height = FFMAX(avctx->height, avctx->coded_height); + } + + break; + case AVMEDIA_TYPE_AUDIO: + frame->sample_rate = avctx->sample_rate; + frame->format = avctx->sample_fmt; + if (!frame->ch_layout.nb_channels) { + ret = av_channel_layout_copy(&frame->ch_layout, &avctx->ch_layout); + if (ret < 0) + return ret; + } + break; + } + + ret = avcodec_default_get_buffer2(avctx, frame, 0); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + av_frame_unref(frame); + return ret; + } + + return 0; +} diff --git a/media/ffvpx/libavcodec/encode.h b/media/ffvpx/libavcodec/encode.h index 9af2f42483fd..b2536bf0f31b 100644 --- a/media/ffvpx/libavcodec/encode.h +++ b/media/ffvpx/libavcodec/encode.h @@ -44,9 +44,29 @@ int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame); */ int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags); +/** + * Allocate buffers for a frame. Encoder equivalent to ff_get_buffer(). + */ +int ff_encode_alloc_frame(AVCodecContext *avctx, AVFrame *frame); + +/** + * Check AVPacket size and allocate data. + * + * Encoders supporting FFCodec.encode2() can use this as a convenience to + * obtain a big enough buffer for the encoded bitstream. + * + * @param avctx the AVCodecContext of the encoder + * @param avpkt The AVPacket: on success, avpkt->data will point to a buffer + * of size at least `size`; the packet will not be refcounted. + * This packet must be initially blank. + * @param size an upper bound of the size of the packet to encode + * @return non negative on success, negative error code on failure + */ +int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size); + /* * Perform encoder initialization and validation. - * Called when opening the encoder, before the AVCodec.init() call. + * Called when opening the encoder, before the FFCodec.init() call. */ int ff_encode_preinit(AVCodecContext *avctx); diff --git a/media/ffvpx/libavcodec/error_resilience.h b/media/ffvpx/libavcodec/error_resilience.h index 664a76565927..53e5cf262121 100644 --- a/media/ffvpx/libavcodec/error_resilience.h +++ b/media/ffvpx/libavcodec/error_resilience.h @@ -24,7 +24,7 @@ #include "avcodec.h" #include "me_cmp.h" -#include "thread.h" +#include "threadframe.h" ///< current MB is the first after a resync marker #define VP_START 1 @@ -52,7 +52,8 @@ typedef struct ERPicture { typedef struct ERContext { AVCodecContext *avctx; - MECmpContext mecc; + + me_cmp_func sad; int mecc_inited; int *mb_index2xy; @@ -81,7 +82,6 @@ typedef struct ERContext { uint16_t pb_time; int quarter_sample; int partitioned_frame; - int ref_count; void (*decode_mb)(void *opaque, int ref, int mv_dir, int mv_type, int (*mv)[2][4][2], diff --git a/media/ffvpx/libavcodec/fdctdsp.c b/media/ffvpx/libavcodec/fdctdsp.c index b9c2c86322c6..5306c9d047e9 100644 --- a/media/ffvpx/libavcodec/fdctdsp.c +++ b/media/ffvpx/libavcodec/fdctdsp.c @@ -25,7 +25,7 @@ av_cold void ff_fdctdsp_init(FDCTDSPContext *c, AVCodecContext *avctx) { - const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8; + av_unused const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8; if (avctx->bits_per_raw_sample == 10 || avctx->bits_per_raw_sample == 9) { c->fdct = ff_jpeg_fdct_islow_10; @@ -43,8 +43,9 @@ av_cold void ff_fdctdsp_init(FDCTDSPContext *c, AVCodecContext *avctx) c->fdct248 = ff_fdct248_islow_8; } - if (ARCH_PPC) - ff_fdctdsp_init_ppc(c, avctx, high_bit_depth); - if (ARCH_X86) - ff_fdctdsp_init_x86(c, avctx, high_bit_depth); +#if ARCH_PPC + ff_fdctdsp_init_ppc(c, avctx, high_bit_depth); +#elif ARCH_X86 + ff_fdctdsp_init_x86(c, avctx, high_bit_depth); +#endif } diff --git a/media/ffvpx/libavcodec/fft-internal.h b/media/ffvpx/libavcodec/fft-internal.h index 3bd5a1123d84..d89a3e38ca67 100644 --- a/media/ffvpx/libavcodec/fft-internal.h +++ b/media/ffvpx/libavcodec/fft-internal.h @@ -19,6 +19,9 @@ #ifndef AVCODEC_FFT_INTERNAL_H #define AVCODEC_FFT_INTERNAL_H +#include "libavutil/mathematics.h" +#include "fft.h" + #if FFT_FLOAT #define FIX15(v) (v) @@ -36,10 +39,6 @@ #else /* FFT_FLOAT */ -#define SCALE_FLOAT(a, bits) lrint((a) * (double)(1 << (bits))) - -#if FFT_FIXED_32 - #define CMUL(dre, dim, are, aim, bre, bim) do { \ int64_t accu; \ (accu) = (int64_t)(bre) * (are); \ @@ -50,10 +49,6 @@ (dim) = (int)(((accu) + 0x40000000) >> 31); \ } while (0) -#define FIX15(a) av_clip(SCALE_FLOAT(a, 31), -2147483647, 2147483647) - -#endif /* FFT_FIXED_32 */ - #endif /* FFT_FLOAT */ #define ff_imdct_calc_c FFT_NAME(ff_imdct_calc_c) diff --git a/media/ffvpx/libavcodec/fft.h b/media/ffvpx/libavcodec/fft.h index e03ca01abfde..706c9d07f50c 100644 --- a/media/ffvpx/libavcodec/fft.h +++ b/media/ffvpx/libavcodec/fft.h @@ -26,10 +26,6 @@ #define FFT_FLOAT 1 #endif -#ifndef FFT_FIXED_32 -#define FFT_FIXED_32 0 -#endif - #include #include "config.h" @@ -45,15 +41,11 @@ typedef float FFTDouble; #else -#if FFT_FIXED_32 - #define Q31(x) (int)((x)*2147483648.0 + 0.5) #define FFT_NAME(x) x ## _fixed_32 typedef int32_t FFTSample; -#endif /* FFT_FIXED_32 */ - typedef struct FFTComplex { FFTSample re, im; } FFTComplex; diff --git a/media/ffvpx/libavcodec/fft_fixed_32.c b/media/ffvpx/libavcodec/fft_fixed_32.c index fbdbf847e23f..e18dc83891eb 100644 --- a/media/ffvpx/libavcodec/fft_fixed_32.c +++ b/media/ffvpx/libavcodec/fft_fixed_32.c @@ -48,5 +48,4 @@ */ #define FFT_FLOAT 0 -#define FFT_FIXED_32 1 #include "fft_template.c" diff --git a/media/ffvpx/libavcodec/fft_float.c b/media/ffvpx/libavcodec/fft_float.c index 73cc98d0d4b1..a9fd01978de6 100644 --- a/media/ffvpx/libavcodec/fft_float.c +++ b/media/ffvpx/libavcodec/fft_float.c @@ -17,5 +17,4 @@ */ #define FFT_FLOAT 1 -#define FFT_FIXED_32 0 #include "fft_template.c" diff --git a/media/ffvpx/libavcodec/fft_template.c b/media/ffvpx/libavcodec/fft_template.c index 3012372a74be..f2742a3ae8d6 100644 --- a/media/ffvpx/libavcodec/fft_template.c +++ b/media/ffvpx/libavcodec/fft_template.c @@ -33,9 +33,9 @@ #include "fft.h" #include "fft-internal.h" -#if FFT_FIXED_32 +#if !FFT_FLOAT #include "fft_table.h" -#else /* FFT_FIXED_32 */ +#else /* !FFT_FLOAT */ /* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */ #if !CONFIG_HARDCODED_TABLES @@ -136,7 +136,7 @@ COSTABLE_CONST FFTSample * const FFT_NAME(ff_cos_tabs)[] = { FFT_NAME(ff_cos_131072), }; -#endif /* FFT_FIXED_32 */ +#endif /* FFT_FLOAT */ static void fft_permute_c(FFTContext *s, FFTComplex *z); static void fft_calc_c(FFTContext *s, FFTComplex *z); @@ -226,20 +226,25 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse) s->mdct_calc = ff_mdct_calc_c; #endif -#if FFT_FIXED_32 - ff_fft_lut_init(); -#else /* FFT_FIXED_32 */ #if FFT_FLOAT - if (ARCH_AARCH64) ff_fft_init_aarch64(s); - if (ARCH_ARM) ff_fft_init_arm(s); - if (ARCH_PPC) ff_fft_init_ppc(s); - if (ARCH_X86) ff_fft_init_x86(s); - if (HAVE_MIPSFPU) ff_fft_init_mips(s); +#if ARCH_AARCH64 + ff_fft_init_aarch64(s); +#elif ARCH_ARM + ff_fft_init_arm(s); +#elif ARCH_PPC + ff_fft_init_ppc(s); +#elif ARCH_X86 + ff_fft_init_x86(s); +#endif +#if HAVE_MIPSFPU + ff_fft_init_mips(s); #endif for(j=4; j<=nbits; j++) { ff_init_ff_cos_tabs(j); } -#endif /* FFT_FIXED_32 */ +#else /* FFT_FLOAT */ + ff_fft_lut_init(); +#endif if (ARCH_X86 && FFT_FLOAT && s->fft_permutation == FF_FFT_PERM_AVX) { @@ -312,7 +317,7 @@ av_cold void ff_fft_end(FFTContext *s) av_freep(&s->tmp_buf); } -#if FFT_FIXED_32 +#if !FFT_FLOAT static void fft_calc_c(FFTContext *s, FFTComplex *z) { @@ -470,7 +475,7 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z) { } } -#else /* FFT_FIXED_32 */ +#else /* !FFT_FLOAT */ #define BUTTERFLIES(a0,a1,a2,a3) {\ BF(t3, t5, t5, t1);\ @@ -620,4 +625,4 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z) { fft_dispatch[s->nbits-2](z); } -#endif /* FFT_FIXED_32 */ +#endif /* !FFT_FLOAT */ diff --git a/media/ffvpx/libavcodec/flac.c b/media/ffvpx/libavcodec/flac.c index 7b075d4bd3ee..dd68830622ea 100644 --- a/media/ffvpx/libavcodec/flac.c +++ b/media/ffvpx/libavcodec/flac.c @@ -29,15 +29,15 @@ static const int8_t sample_size_table[] = { 0, 8, 12, 0, 16, 20, 24, 0 }; -static const uint64_t flac_channel_layouts[8] = { - AV_CH_LAYOUT_MONO, - AV_CH_LAYOUT_STEREO, - AV_CH_LAYOUT_SURROUND, - AV_CH_LAYOUT_QUAD, - AV_CH_LAYOUT_5POINT0, - AV_CH_LAYOUT_5POINT1, - AV_CH_LAYOUT_6POINT1, - AV_CH_LAYOUT_7POINT1 +static const AVChannelLayout flac_channel_layouts[8] = { + AV_CHANNEL_LAYOUT_MONO, + AV_CHANNEL_LAYOUT_STEREO, + AV_CHANNEL_LAYOUT_SURROUND, + AV_CHANNEL_LAYOUT_QUAD, + AV_CHANNEL_LAYOUT_5POINT0, + AV_CHANNEL_LAYOUT_5POINT1, + AV_CHANNEL_LAYOUT_6POINT1, + AV_CHANNEL_LAYOUT_7POINT1 }; static int64_t get_utf8(GetBitContext *gb) @@ -193,12 +193,18 @@ int ff_flac_is_extradata_valid(AVCodecContext *avctx, return 1; } -void ff_flac_set_channel_layout(AVCodecContext *avctx) +void ff_flac_set_channel_layout(AVCodecContext *avctx, int channels) { - if (avctx->channels <= FF_ARRAY_ELEMS(flac_channel_layouts)) - avctx->channel_layout = flac_channel_layouts[avctx->channels - 1]; + if (channels == avctx->ch_layout.nb_channels && + avctx->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) + return; + + av_channel_layout_uninit(&avctx->ch_layout); + if (channels <= FF_ARRAY_ELEMS(flac_channel_layouts)) + avctx->ch_layout = flac_channel_layouts[channels - 1]; else - avctx->channel_layout = 0; + avctx->ch_layout = (AVChannelLayout){ .order = AV_CHANNEL_ORDER_UNSPEC, + .nb_channels = channels }; } int ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, @@ -229,13 +235,9 @@ int ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, return AVERROR_INVALIDDATA; } - avctx->channels = s->channels; avctx->sample_rate = s->samplerate; avctx->bits_per_raw_sample = s->bps; - - if (!avctx->channel_layout || - av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels) - ff_flac_set_channel_layout(avctx); + ff_flac_set_channel_layout(avctx, s->channels); s->samples = get_bits64(&gb, 36); diff --git a/media/ffvpx/libavcodec/flac.h b/media/ffvpx/libavcodec/flac.h index 991ab43f3cc3..cb220ab4c025 100644 --- a/media/ffvpx/libavcodec/flac.h +++ b/media/ffvpx/libavcodec/flac.h @@ -131,7 +131,7 @@ int ff_flac_get_max_frame_size(int blocksize, int ch, int bps); int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, FLACFrameInfo *fi, int log_level_offset); -void ff_flac_set_channel_layout(AVCodecContext *avctx); +void ff_flac_set_channel_layout(AVCodecContext *avctx, int channels); /** * Parse the metadata block parameters from the header. diff --git a/media/ffvpx/libavcodec/flacdata.c b/media/ffvpx/libavcodec/flacdata.c index 1954f32d32d8..d96e3e096611 100644 --- a/media/ffvpx/libavcodec/flacdata.c +++ b/media/ffvpx/libavcodec/flacdata.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "internal.h" +#include "flacdata.h" const int ff_flac_sample_rate_table[16] = { 0, diff --git a/media/ffvpx/libavcodec/flacdata.h b/media/ffvpx/libavcodec/flacdata.h index e2c1e5d7f237..ef218407772f 100644 --- a/media/ffvpx/libavcodec/flacdata.h +++ b/media/ffvpx/libavcodec/flacdata.h @@ -22,7 +22,7 @@ #ifndef AVCODEC_FLACDATA_H #define AVCODEC_FLACDATA_H -#include "internal.h" +#include extern const int ff_flac_sample_rate_table[16]; diff --git a/media/ffvpx/libavcodec/flacdec.c b/media/ffvpx/libavcodec/flacdec.c index 9e55bc136181..87f20c742580 100644 --- a/media/ffvpx/libavcodec/flacdec.c +++ b/media/ffvpx/libavcodec/flacdec.c @@ -37,7 +37,7 @@ #include "libavutil/crc.h" #include "libavutil/opt.h" #include "avcodec.h" -#include "internal.h" +#include "codec_internal.h" #include "get_bits.h" #include "bytestream.h" #include "golomb.h" @@ -260,7 +260,7 @@ static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order) for (; i < samples; i++) *decoded++ = get_sbits_long(&gb, tmp); } else { - int real_limit = tmp ? (INT_MAX >> tmp) + 2 : INT_MAX; + int real_limit = (tmp > 1) ? (INT_MAX >> (tmp - 1)) + 2 : INT_MAX; for (; i < samples; i++) { int v = get_sr_golomb_flac(&gb, tmp, real_limit, 1); if (v == 0x80000000){ @@ -483,15 +483,14 @@ static int decode_frame(FLACContext *s) if ( s->flac_stream_info.channels && fi.channels != s->flac_stream_info.channels && s->got_streaminfo) { - s->flac_stream_info.channels = s->avctx->channels = fi.channels; - ff_flac_set_channel_layout(s->avctx); + s->flac_stream_info.channels = fi.channels; + ff_flac_set_channel_layout(s->avctx, fi.channels); ret = allocate_buffers(s); if (ret < 0) return ret; } - s->flac_stream_info.channels = s->avctx->channels = fi.channels; - if (!s->avctx->channel_layout) - ff_flac_set_channel_layout(s->avctx); + s->flac_stream_info.channels = fi.channels; + ff_flac_set_channel_layout(s->avctx, fi.channels); s->ch_mode = fi.ch_mode; if (!s->flac_stream_info.bps && !fi.bps) { @@ -555,11 +554,9 @@ static int decode_frame(FLACContext *s) return 0; } -static int flac_decode_frame(AVCodecContext *avctx, void *data, +static int flac_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt) { - AVFrame *frame = data; - ThreadFrame tframe = { .f = data }; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; FLACContext *s = avctx->priv_data; @@ -618,7 +615,7 @@ static int flac_decode_frame(AVCodecContext *avctx, void *data, /* get output buffer */ frame->nb_samples = s->blocksize; - if ((ret = ff_thread_get_buffer(avctx, &tframe, 0)) < 0) + if ((ret = ff_thread_get_buffer(avctx, frame, 0)) < 0) return ret; s->dsp.decorrelate[s->ch_mode](frame->data, s->decoded, @@ -660,22 +657,23 @@ static const AVClass flac_decoder_class = { .version = LIBAVUTIL_VERSION_INT, }; -AVCodec ff_flac_decoder = { - .name = "flac", - .long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"), - .type = AVMEDIA_TYPE_AUDIO, - .id = AV_CODEC_ID_FLAC, +const FFCodec ff_flac_decoder = { + .p.name = "flac", + .p.long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"), + .p.type = AVMEDIA_TYPE_AUDIO, + .p.id = AV_CODEC_ID_FLAC, .priv_data_size = sizeof(FLACContext), .init = flac_decode_init, .close = flac_decode_close, - .decode = flac_decode_frame, - .capabilities = AV_CODEC_CAP_CHANNEL_CONF | + FF_CODEC_DECODE_CB(flac_decode_frame), + .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, - .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, + .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_NONE }, - .priv_class = &flac_decoder_class, + .p.priv_class = &flac_decoder_class, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; diff --git a/media/ffvpx/libavcodec/flacdsp.c b/media/ffvpx/libavcodec/flacdsp.c index bc9a5dbed916..79002dcac017 100644 --- a/media/ffvpx/libavcodec/flacdsp.c +++ b/media/ffvpx/libavcodec/flacdsp.c @@ -19,6 +19,7 @@ */ #include "libavutil/attributes.h" +#include "libavutil/internal.h" #include "libavutil/samplefmt.h" #include "flacdsp.h" #include "config.h" @@ -123,8 +124,9 @@ av_cold void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt, int cha break; } - if (ARCH_ARM) - ff_flacdsp_init_arm(c, fmt, channels, bps); - if (ARCH_X86) - ff_flacdsp_init_x86(c, fmt, channels, bps); +#if ARCH_ARM + ff_flacdsp_init_arm(c, fmt, channels, bps); +#elif ARCH_X86 + ff_flacdsp_init_x86(c, fmt, channels, bps); +#endif } diff --git a/media/ffvpx/libavcodec/flacdsp.h b/media/ffvpx/libavcodec/flacdsp.h index 7bb0dd0e9a2e..4a7a36064a8d 100644 --- a/media/ffvpx/libavcodec/flacdsp.h +++ b/media/ffvpx/libavcodec/flacdsp.h @@ -20,7 +20,7 @@ #define AVCODEC_FLACDSP_H #include -#include "libavutil/internal.h" + #include "libavutil/samplefmt.h" typedef struct FLACDSPContext { diff --git a/media/ffvpx/libavcodec/flacdsp_lpc_template.c b/media/ffvpx/libavcodec/flacdsp_lpc_template.c index 5d532e067327..dd847d3b32ee 100644 --- a/media/ffvpx/libavcodec/flacdsp_lpc_template.c +++ b/media/ffvpx/libavcodec/flacdsp_lpc_template.c @@ -17,7 +17,7 @@ */ #include -#include "libavutil/avutil.h" +#include "libavutil/common.h" #include "mathops.h" #undef FUNC diff --git a/media/ffvpx/libavcodec/flacdsp_template.c b/media/ffvpx/libavcodec/flacdsp_template.c index 776c78da7195..0a6fe59e2869 100644 --- a/media/ffvpx/libavcodec/flacdsp_template.c +++ b/media/ffvpx/libavcodec/flacdsp_template.c @@ -19,7 +19,7 @@ */ #include -#include "libavutil/avutil.h" +#include "libavutil/macros.h" #undef FUNC #undef FSUF @@ -66,8 +66,8 @@ static void FUNC(flac_decorrelate_ls_c)(uint8_t **out, int32_t **in, int i; for (i = 0; i < len; i++) { - int a = in[0][i]; - int b = in[1][i]; + unsigned a = in[0][i]; + unsigned b = in[1][i]; S(samples, 0, i) = a << shift; S(samples, 1, i) = (a - b) << shift; } @@ -80,8 +80,8 @@ static void FUNC(flac_decorrelate_rs_c)(uint8_t **out, int32_t **in, int i; for (i = 0; i < len; i++) { - int a = in[0][i]; - int b = in[1][i]; + unsigned a = in[0][i]; + unsigned b = in[1][i]; S(samples, 0, i) = (a + b) << shift; S(samples, 1, i) = b << shift; } @@ -94,7 +94,7 @@ static void FUNC(flac_decorrelate_ms_c)(uint8_t **out, int32_t **in, int i; for (i = 0; i < len; i++) { - int a = in[0][i]; + unsigned a = in[0][i]; int b = in[1][i]; a -= b >> 1; S(samples, 0, i) = (a + b) << shift; diff --git a/media/ffvpx/libavcodec/frame_thread_encoder.h b/media/ffvpx/libavcodec/frame_thread_encoder.h index 9733fcdc2de7..201cba2a8f10 100644 --- a/media/ffvpx/libavcodec/frame_thread_encoder.h +++ b/media/ffvpx/libavcodec/frame_thread_encoder.h @@ -27,7 +27,7 @@ * Initialize frame thread encoder. * @note hardware encoders are not supported */ -int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options); +int ff_frame_thread_encoder_init(AVCodecContext *avctx); void ff_frame_thread_encoder_free(AVCodecContext *avctx); int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, AVFrame *frame, int *got_packet_ptr); diff --git a/media/ffvpx/libavcodec/get_bits.h b/media/ffvpx/libavcodec/get_bits.h index 66fb8775994b..16f8af510712 100644 --- a/media/ffvpx/libavcodec/get_bits.h +++ b/media/ffvpx/libavcodec/get_bits.h @@ -33,7 +33,8 @@ #include "libavutil/intreadwrite.h" #include "libavutil/log.h" #include "libavutil/avassert.h" -#include "avcodec.h" + +#include "defs.h" #include "mathops.h" #include "vlc.h" @@ -709,8 +710,8 @@ static inline const uint8_t *align_get_bits(GetBitContext *s) unsigned int index; \ \ index = SHOW_UBITS(name, gb, bits); \ - code = table[index][0]; \ - n = table[index][1]; \ + code = table[index].sym; \ + n = table[index].len; \ \ if (max_depth > 1 && n < 0) { \ LAST_SKIP_BITS(name, gb, bits); \ @@ -719,8 +720,8 @@ static inline const uint8_t *align_get_bits(GetBitContext *s) nb_bits = -n; \ \ index = SHOW_UBITS(name, gb, nb_bits) + code; \ - code = table[index][0]; \ - n = table[index][1]; \ + code = table[index].sym; \ + n = table[index].len; \ if (max_depth > 2 && n < 0) { \ LAST_SKIP_BITS(name, gb, nb_bits); \ UPDATE_CACHE(name, gb); \ @@ -728,8 +729,8 @@ static inline const uint8_t *align_get_bits(GetBitContext *s) nb_bits = -n; \ \ index = SHOW_UBITS(name, gb, nb_bits) + code; \ - code = table[index][0]; \ - n = table[index][1]; \ + code = table[index].sym; \ + n = table[index].len; \ } \ } \ SKIP_BITS(name, gb, n); \ @@ -774,15 +775,15 @@ static inline const uint8_t *align_get_bits(GetBitContext *s) /* Return the LUT element for the given bitstream configuration. */ static inline int set_idx(GetBitContext *s, int code, int *n, int *nb_bits, - VLC_TYPE (*table)[2]) + const VLCElem *table) { unsigned idx; *nb_bits = -*n; idx = show_bits(s, *nb_bits) + code; - *n = table[idx][1]; + *n = table[idx].len; - return table[idx][0]; + return table[idx].sym; } /** @@ -794,14 +795,14 @@ static inline int set_idx(GetBitContext *s, int code, int *n, int *nb_bits, * = (max_vlc_length + bits - 1) / bits * @returns the code parsed or -1 if no vlc matches */ -static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2], +static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth) { #if CACHED_BITSTREAM_READER int nb_bits; unsigned idx = show_bits(s, bits); - int code = table[idx][0]; - int n = table[idx][1]; + int code = table[idx].sym; + int n = table[idx].len; if (max_depth > 1 && n < 0) { skip_remaining(s, bits); diff --git a/media/ffvpx/libavcodec/get_buffer.c b/media/ffvpx/libavcodec/get_buffer.c new file mode 100644 index 000000000000..3e45a0479fe8 --- /dev/null +++ b/media/ffvpx/libavcodec/get_buffer.c @@ -0,0 +1,312 @@ +/* + * The default get_buffer2() implementation + * + * 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 + +#include "libavutil/avassert.h" +#include "libavutil/avutil.h" +#include "libavutil/buffer.h" +#include "libavutil/frame.h" +#include "libavutil/hwcontext.h" +#include "libavutil/imgutils.h" +#include "libavutil/mem.h" +#include "libavutil/samplefmt.h" +#include "libavutil/version.h" + +#include "avcodec.h" +#include "internal.h" + +typedef struct FramePool { + /** + * Pools for each data plane. For audio all the planes have the same size, + * so only pools[0] is used. + */ + AVBufferPool *pools[4]; + + /* + * Pool parameters + */ + int format; + int width, height; + int stride_align[AV_NUM_DATA_POINTERS]; + int linesize[4]; + int planes; + int channels; + int samples; +} FramePool; + +static void frame_pool_free(void *opaque, uint8_t *data) +{ + FramePool *pool = (FramePool*)data; + int i; + + for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++) + av_buffer_pool_uninit(&pool->pools[i]); + + av_freep(&data); +} + +static AVBufferRef *frame_pool_alloc(void) +{ + FramePool *pool = av_mallocz(sizeof(*pool)); + AVBufferRef *buf; + + if (!pool) + return NULL; + + buf = av_buffer_create((uint8_t*)pool, sizeof(*pool), + frame_pool_free, NULL, 0); + if (!buf) { + av_freep(&pool); + return NULL; + } + + return buf; +} + +static int update_frame_pool(AVCodecContext *avctx, AVFrame *frame) +{ + FramePool *pool = avctx->internal->pool ? + (FramePool*)avctx->internal->pool->data : NULL; + AVBufferRef *pool_buf; + int i, ret, ch, planes; + + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) { + int planar = av_sample_fmt_is_planar(frame->format); + ch = frame->ch_layout.nb_channels; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + if (!ch) + ch = frame->channels; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + planes = planar ? ch : 1; + } + + if (pool && pool->format == frame->format) { + if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && + pool->width == frame->width && pool->height == frame->height) + return 0; + if (avctx->codec_type == AVMEDIA_TYPE_AUDIO && pool->planes == planes && + pool->channels == ch && frame->nb_samples == pool->samples) + return 0; + } + + pool_buf = frame_pool_alloc(); + if (!pool_buf) + return AVERROR(ENOMEM); + pool = (FramePool*)pool_buf->data; + + switch (avctx->codec_type) { + case AVMEDIA_TYPE_VIDEO: { + int linesize[4]; + int w = frame->width; + int h = frame->height; + int unaligned; + ptrdiff_t linesize1[4]; + size_t size[4]; + + avcodec_align_dimensions2(avctx, &w, &h, pool->stride_align); + + do { + // NOTE: do not align linesizes individually, this breaks e.g. assumptions + // that linesize[0] == 2*linesize[1] in the MPEG-encoder for 4:2:2 + ret = av_image_fill_linesizes(linesize, avctx->pix_fmt, w); + if (ret < 0) + goto fail; + // increase alignment of w for next try (rhs gives the lowest bit set in w) + w += w & ~(w - 1); + + unaligned = 0; + for (i = 0; i < 4; i++) + unaligned |= linesize[i] % pool->stride_align[i]; + } while (unaligned); + + for (i = 0; i < 4; i++) + linesize1[i] = linesize[i]; + ret = av_image_fill_plane_sizes(size, avctx->pix_fmt, h, linesize1); + if (ret < 0) + goto fail; + + for (i = 0; i < 4; i++) { + pool->linesize[i] = linesize[i]; + if (size[i]) { + if (size[i] > INT_MAX - (16 + STRIDE_ALIGN - 1)) { + ret = AVERROR(EINVAL); + goto fail; + } + pool->pools[i] = av_buffer_pool_init(size[i] + 16 + STRIDE_ALIGN - 1, + CONFIG_MEMORY_POISONING ? + NULL : + av_buffer_allocz); + if (!pool->pools[i]) { + ret = AVERROR(ENOMEM); + goto fail; + } + } + } + pool->format = frame->format; + pool->width = frame->width; + pool->height = frame->height; + + break; + } + case AVMEDIA_TYPE_AUDIO: { + ret = av_samples_get_buffer_size(&pool->linesize[0], ch, + frame->nb_samples, frame->format, 0); + if (ret < 0) + goto fail; + + pool->pools[0] = av_buffer_pool_init(pool->linesize[0], NULL); + if (!pool->pools[0]) { + ret = AVERROR(ENOMEM); + goto fail; + } + + pool->format = frame->format; + pool->planes = planes; + pool->channels = ch; + pool->samples = frame->nb_samples; + break; + } + default: av_assert0(0); + } + + av_buffer_unref(&avctx->internal->pool); + avctx->internal->pool = pool_buf; + + return 0; +fail: + av_buffer_unref(&pool_buf); + return ret; +} + +static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame) +{ + FramePool *pool = (FramePool*)avctx->internal->pool->data; + int planes = pool->planes; + int i; + + frame->linesize[0] = pool->linesize[0]; + + if (planes > AV_NUM_DATA_POINTERS) { + frame->extended_data = av_calloc(planes, sizeof(*frame->extended_data)); + frame->nb_extended_buf = planes - AV_NUM_DATA_POINTERS; + frame->extended_buf = av_calloc(frame->nb_extended_buf, + sizeof(*frame->extended_buf)); + if (!frame->extended_data || !frame->extended_buf) { + av_freep(&frame->extended_data); + av_freep(&frame->extended_buf); + return AVERROR(ENOMEM); + } + } else { + frame->extended_data = frame->data; + av_assert0(frame->nb_extended_buf == 0); + } + + for (i = 0; i < FFMIN(planes, AV_NUM_DATA_POINTERS); i++) { + frame->buf[i] = av_buffer_pool_get(pool->pools[0]); + if (!frame->buf[i]) + goto fail; + frame->extended_data[i] = frame->data[i] = frame->buf[i]->data; + } + for (i = 0; i < frame->nb_extended_buf; i++) { + frame->extended_buf[i] = av_buffer_pool_get(pool->pools[0]); + if (!frame->extended_buf[i]) + goto fail; + frame->extended_data[i + AV_NUM_DATA_POINTERS] = frame->extended_buf[i]->data; + } + + if (avctx->debug & FF_DEBUG_BUFFERS) + av_log(avctx, AV_LOG_DEBUG, "default_get_buffer called on frame %p", frame); + + return 0; +fail: + av_frame_unref(frame); + return AVERROR(ENOMEM); +} + +static int video_get_buffer(AVCodecContext *s, AVFrame *pic) +{ + FramePool *pool = (FramePool*)s->internal->pool->data; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pic->format); + int i; + + if (pic->data[0] || pic->data[1] || pic->data[2] || pic->data[3]) { + av_log(s, AV_LOG_ERROR, "pic->data[*]!=NULL in avcodec_default_get_buffer\n"); + return -1; + } + + if (!desc) { + av_log(s, AV_LOG_ERROR, + "Unable to get pixel format descriptor for format %s\n", + av_get_pix_fmt_name(pic->format)); + return AVERROR(EINVAL); + } + + memset(pic->data, 0, sizeof(pic->data)); + pic->extended_data = pic->data; + + for (i = 0; i < 4 && pool->pools[i]; i++) { + pic->linesize[i] = pool->linesize[i]; + + pic->buf[i] = av_buffer_pool_get(pool->pools[i]); + if (!pic->buf[i]) + goto fail; + + pic->data[i] = pic->buf[i]->data; + } + for (; i < AV_NUM_DATA_POINTERS; i++) { + pic->data[i] = NULL; + pic->linesize[i] = 0; + } + + if (s->debug & FF_DEBUG_BUFFERS) + av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p\n", pic); + + return 0; +fail: + av_frame_unref(pic); + return AVERROR(ENOMEM); +} + +int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags) +{ + int ret; + + if (avctx->hw_frames_ctx) { + ret = av_hwframe_get_buffer(avctx->hw_frames_ctx, frame, 0); + frame->width = avctx->coded_width; + frame->height = avctx->coded_height; + return ret; + } + + if ((ret = update_frame_pool(avctx, frame)) < 0) + return ret; + + switch (avctx->codec_type) { + case AVMEDIA_TYPE_VIDEO: + return video_get_buffer(avctx, frame); + case AVMEDIA_TYPE_AUDIO: + return audio_get_buffer(avctx, frame); + default: + return -1; + } +} diff --git a/media/ffvpx/libavcodec/golomb.c b/media/ffvpx/libavcodec/golomb.c index 937ac22ce134..f9ca8149eb31 100644 --- a/media/ffvpx/libavcodec/golomb.c +++ b/media/ffvpx/libavcodec/golomb.c @@ -26,7 +26,7 @@ * @author Michael Niedermayer */ -#include "libavutil/common.h" +#include const uint8_t ff_golomb_vlc_len[512]={ 19,17,15,15,13,13,13,13,11,11,11,11,11,11,11,11,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, diff --git a/media/ffvpx/libavcodec/golomb.h b/media/ffvpx/libavcodec/golomb.h index 4d531cf8053c..164c2583b6c8 100644 --- a/media/ffvpx/libavcodec/golomb.h +++ b/media/ffvpx/libavcodec/golomb.h @@ -33,14 +33,12 @@ #include #include "get_bits.h" -#include "put_bits.h" #define INVALID_VLC 0x80000000 extern const uint8_t ff_golomb_vlc_len[512]; extern const uint8_t ff_ue_golomb_vlc_code[512]; extern const int8_t ff_se_golomb_vlc_code[512]; -extern const uint8_t ff_ue_golomb_len[256]; extern const uint8_t ff_interleaved_golomb_vlc_len[256]; extern const uint8_t ff_interleaved_ue_golomb_vlc_code[256]; @@ -615,135 +613,4 @@ static inline int get_te(GetBitContext *s, int r, char *file, const char *func, #define get_te0_golomb(a, r) get_te(a, r, __FILE__, __func__, __LINE__) #endif /* TRACE */ - -/** - * write unsigned exp golomb code. 2^16 - 2 at most - */ -static inline void set_ue_golomb(PutBitContext *pb, int i) -{ - av_assert2(i >= 0); - av_assert2(i <= 0xFFFE); - - if (i < 256) - put_bits(pb, ff_ue_golomb_len[i], i + 1); - else { - int e = av_log2(i + 1); - put_bits(pb, 2 * e + 1, i + 1); - } -} - -/** - * write unsigned exp golomb code. 2^32-2 at most. - */ -static inline void set_ue_golomb_long(PutBitContext *pb, uint32_t i) -{ - av_assert2(i <= (UINT32_MAX - 1)); - - if (i < 256) - put_bits(pb, ff_ue_golomb_len[i], i + 1); - else { - int e = av_log2(i + 1); - put_bits64(pb, 2 * e + 1, i + 1); - } -} - -/** - * write truncated unsigned exp golomb code. - */ -static inline void set_te_golomb(PutBitContext *pb, int i, int range) -{ - av_assert2(range >= 1); - av_assert2(i <= range); - - if (range == 2) - put_bits(pb, 1, i ^ 1); - else - set_ue_golomb(pb, i); -} - -/** - * write signed exp golomb code. 16 bits at most. - */ -static inline void set_se_golomb(PutBitContext *pb, int i) -{ - i = 2 * i - 1; - if (i < 0) - i ^= -1; //FIXME check if gcc does the right thing - set_ue_golomb(pb, i); -} - -/** - * write unsigned golomb rice code (ffv1). - */ -static inline void set_ur_golomb(PutBitContext *pb, int i, int k, int limit, - int esc_len) -{ - int e; - - av_assert2(i >= 0); - - e = i >> k; - if (e < limit) - put_bits(pb, e + k + 1, (1 << k) + av_mod_uintp2(i, k)); - else - put_bits(pb, limit + esc_len, i - limit + 1); -} - -/** - * write unsigned golomb rice code (jpegls). - */ -static inline void set_ur_golomb_jpegls(PutBitContext *pb, int i, int k, - int limit, int esc_len) -{ - int e; - - av_assert2(i >= 0); - - e = (i >> k) + 1; - if (e < limit) { - while (e > 31) { - put_bits(pb, 31, 0); - e -= 31; - } - put_bits(pb, e, 1); - if (k) - put_sbits(pb, k, i); - } else { - while (limit > 31) { - put_bits(pb, 31, 0); - limit -= 31; - } - put_bits(pb, limit, 1); - put_bits(pb, esc_len, i - 1); - } -} - -/** - * write signed golomb rice code (ffv1). - */ -static inline void set_sr_golomb(PutBitContext *pb, int i, int k, int limit, - int esc_len) -{ - int v; - - v = -2 * i - 1; - v ^= (v >> 31); - - set_ur_golomb(pb, v, k, limit, esc_len); -} - -/** - * write signed golomb rice code (flac). - */ -static inline void set_sr_golomb_flac(PutBitContext *pb, int i, int k, - int limit, int esc_len) -{ - int v; - - v = -2 * i - 1; - v ^= (v >> 31); - - set_ur_golomb_jpegls(pb, v, k, limit, esc_len); -} - #endif /* AVCODEC_GOLOMB_H */ diff --git a/media/ffvpx/libavcodec/h264chroma.h b/media/ffvpx/libavcodec/h264chroma.h index 5c89fd12df61..3259b4935fb5 100644 --- a/media/ffvpx/libavcodec/h264chroma.h +++ b/media/ffvpx/libavcodec/h264chroma.h @@ -36,5 +36,6 @@ void ff_h264chroma_init_arm(H264ChromaContext *c, int bit_depth); void ff_h264chroma_init_ppc(H264ChromaContext *c, int bit_depth); void ff_h264chroma_init_x86(H264ChromaContext *c, int bit_depth); void ff_h264chroma_init_mips(H264ChromaContext *c, int bit_depth); +void ff_h264chroma_init_loongarch(H264ChromaContext *c, int bit_depth); #endif /* AVCODEC_H264CHROMA_H */ diff --git a/media/ffvpx/libavcodec/h264dsp.h b/media/ffvpx/libavcodec/h264dsp.h index cbea3173c6a3..e0880c4d889c 100644 --- a/media/ffvpx/libavcodec/h264dsp.h +++ b/media/ffvpx/libavcodec/h264dsp.h @@ -89,16 +89,16 @@ typedef struct H264DSPContext { void (*h264_idct_add16)(uint8_t *dst /*align 16*/, const int *blockoffset, int16_t *block /*align 16*/, int stride, - const uint8_t nnzc[15 * 8]); + const uint8_t nnzc[5 * 8]); void (*h264_idct8_add4)(uint8_t *dst /*align 16*/, const int *blockoffset, int16_t *block /*align 16*/, int stride, - const uint8_t nnzc[15 * 8]); + const uint8_t nnzc[5 * 8]); void (*h264_idct_add8)(uint8_t **dst /*align 16*/, const int *blockoffset, int16_t *block /*align 16*/, int stride, const uint8_t nnzc[15 * 8]); void (*h264_idct_add16intra)(uint8_t *dst /*align 16*/, const int *blockoffset, int16_t *block /*align 16*/, - int stride, const uint8_t nnzc[15 * 8]); + int stride, const uint8_t nnzc[5 * 8]); void (*h264_luma_dc_dequant_idct)(int16_t *output, int16_t *input /*align 16*/, int qmul); void (*h264_chroma_dc_dequant_idct)(int16_t *block, int qmul); @@ -129,5 +129,7 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); void ff_h264dsp_init_mips(H264DSPContext *c, const int bit_depth, const int chroma_format_idc); +void ff_h264dsp_init_loongarch(H264DSPContext *c, const int bit_depth, + const int chroma_format_idc); #endif /* AVCODEC_H264DSP_H */ diff --git a/media/ffvpx/libavcodec/h264pred.c b/media/ffvpx/libavcodec/h264pred.c index 5632a58fd767..25f9995a0bf6 100644 --- a/media/ffvpx/libavcodec/h264pred.c +++ b/media/ffvpx/libavcodec/h264pred.c @@ -25,11 +25,13 @@ * @author Michael Niedermayer */ +#include "config.h" #include "libavutil/attributes.h" #include "libavutil/avassert.h" #include "libavutil/intreadwrite.h" -#include "avcodec.h" +#include "codec_id.h" #include "h264pred.h" +#include "mathops.h" #define BIT_DEPTH 8 #include "h264pred_template.c" @@ -51,6 +53,30 @@ #include "h264pred_template.c" #undef BIT_DEPTH +static void pred4x4_127_dc_c(uint8_t *src, const uint8_t *topright, + ptrdiff_t _stride) +{ + int stride = _stride; + const uint32_t a = 0x7F7F7F7FU; + + AV_WN32A(src + 0 * stride, a); + AV_WN32A(src + 1 * stride, a); + AV_WN32A(src + 2 * stride, a); + AV_WN32A(src + 3 * stride, a); +} + +static void pred4x4_129_dc_c(uint8_t *src, const uint8_t *topright, + ptrdiff_t _stride) +{ + int stride = _stride; + const uint32_t a = 0x81818181U; + + AV_WN32A(src + 0 * stride, a); + AV_WN32A(src + 1 * stride, a); + AV_WN32A(src + 2 * stride, a); + AV_WN32A(src + 3 * stride, a); +} + static void pred4x4_vertical_vp8_c(uint8_t *src, const uint8_t *topright, ptrdiff_t stride) { @@ -419,56 +445,19 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id, #define FUNCD(a) a ## _c #define H264_PRED(depth) \ - if(codec_id != AV_CODEC_ID_RV40){\ - if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8) {\ - h->pred4x4[VERT_PRED ]= FUNCD(pred4x4_vertical_vp8);\ - h->pred4x4[HOR_PRED ]= FUNCD(pred4x4_horizontal_vp8);\ - } else {\ - h->pred4x4[VERT_PRED ]= FUNCC(pred4x4_vertical , depth);\ - h->pred4x4[HOR_PRED ]= FUNCC(pred4x4_horizontal , depth);\ - }\ - h->pred4x4[DC_PRED ]= FUNCC(pred4x4_dc , depth);\ - if(codec_id == AV_CODEC_ID_SVQ3)\ - h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCD(pred4x4_down_left_svq3);\ - else\ - h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCC(pred4x4_down_left , depth);\ - h->pred4x4[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred4x4_down_right , depth);\ - h->pred4x4[VERT_RIGHT_PRED ]= FUNCC(pred4x4_vertical_right , depth);\ - h->pred4x4[HOR_DOWN_PRED ]= FUNCC(pred4x4_horizontal_down , depth);\ - if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8) {\ - h->pred4x4[VERT_LEFT_PRED ]= FUNCD(pred4x4_vertical_left_vp8);\ - } else\ - h->pred4x4[VERT_LEFT_PRED ]= FUNCC(pred4x4_vertical_left , depth);\ - h->pred4x4[HOR_UP_PRED ]= FUNCC(pred4x4_horizontal_up , depth);\ - if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) {\ - h->pred4x4[LEFT_DC_PRED ]= FUNCC(pred4x4_left_dc , depth);\ - h->pred4x4[TOP_DC_PRED ]= FUNCC(pred4x4_top_dc , depth);\ - } else {\ - h->pred4x4[TM_VP8_PRED ]= FUNCD(pred4x4_tm_vp8);\ - h->pred4x4[DC_127_PRED ]= FUNCC(pred4x4_127_dc , depth);\ - h->pred4x4[DC_129_PRED ]= FUNCC(pred4x4_129_dc , depth);\ - h->pred4x4[VERT_VP8_PRED ]= FUNCC(pred4x4_vertical , depth);\ - h->pred4x4[HOR_VP8_PRED ]= FUNCC(pred4x4_horizontal , depth);\ - }\ - if (codec_id != AV_CODEC_ID_VP8)\ - h->pred4x4[DC_128_PRED ]= FUNCC(pred4x4_128_dc , depth);\ - }else{\ - h->pred4x4[VERT_PRED ]= FUNCC(pred4x4_vertical , depth);\ - h->pred4x4[HOR_PRED ]= FUNCC(pred4x4_horizontal , depth);\ - h->pred4x4[DC_PRED ]= FUNCC(pred4x4_dc , depth);\ - h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCD(pred4x4_down_left_rv40);\ - h->pred4x4[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred4x4_down_right , depth);\ - h->pred4x4[VERT_RIGHT_PRED ]= FUNCC(pred4x4_vertical_right , depth);\ - h->pred4x4[HOR_DOWN_PRED ]= FUNCC(pred4x4_horizontal_down , depth);\ - h->pred4x4[VERT_LEFT_PRED ]= FUNCD(pred4x4_vertical_left_rv40);\ - h->pred4x4[HOR_UP_PRED ]= FUNCD(pred4x4_horizontal_up_rv40);\ - h->pred4x4[LEFT_DC_PRED ]= FUNCC(pred4x4_left_dc , depth);\ - h->pred4x4[TOP_DC_PRED ]= FUNCC(pred4x4_top_dc , depth);\ - h->pred4x4[DC_128_PRED ]= FUNCC(pred4x4_128_dc , depth);\ - h->pred4x4[DIAG_DOWN_LEFT_PRED_RV40_NODOWN]= FUNCD(pred4x4_down_left_rv40_nodown);\ - h->pred4x4[HOR_UP_PRED_RV40_NODOWN]= FUNCD(pred4x4_horizontal_up_rv40_nodown);\ - h->pred4x4[VERT_LEFT_PRED_RV40_NODOWN]= FUNCD(pred4x4_vertical_left_rv40_nodown);\ - }\ + h->pred4x4[VERT_PRED ] = FUNCC(pred4x4_vertical, depth);\ + h->pred4x4[HOR_PRED ] = FUNCC(pred4x4_horizontal, depth);\ + h->pred4x4[DC_PRED ] = FUNCC(pred4x4_dc, depth);\ + h->pred4x4[DIAG_DOWN_LEFT_PRED ] = FUNCC(pred4x4_down_left, depth);\ + h->pred4x4[DIAG_DOWN_RIGHT_PRED] = FUNCC(pred4x4_down_right, depth);\ + h->pred4x4[VERT_RIGHT_PRED ] = FUNCC(pred4x4_vertical_right, depth);\ + h->pred4x4[HOR_DOWN_PRED ] = FUNCC(pred4x4_horizontal_down, depth);\ + h->pred4x4[VERT_LEFT_PRED ] = FUNCC(pred4x4_vertical_left, depth);\ + h->pred4x4[HOR_UP_PRED ] = FUNCC(pred4x4_horizontal_up, depth);\ + h->pred4x4[LEFT_DC_PRED ] = FUNCC(pred4x4_left_dc, depth);\ + h->pred4x4[TOP_DC_PRED ] = FUNCC(pred4x4_top_dc, depth);\ + if (depth > 8 || codec_id != AV_CODEC_ID_VP8)\ + h->pred4x4[DC_128_PRED ] = FUNCC(pred4x4_128_dc, depth);\ \ h->pred8x8l[VERT_PRED ]= FUNCC(pred8x8l_vertical , depth);\ h->pred8x8l[HOR_PRED ]= FUNCC(pred8x8l_horizontal , depth);\ @@ -486,20 +475,15 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id, if (chroma_format_idc <= 1) {\ h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x8_vertical , depth);\ h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x8_horizontal , depth);\ + h->pred8x8[PLANE_PRED8x8] = FUNCC(pred8x8_plane, depth);\ } else {\ h->pred8x8[VERT_PRED8x8 ]= FUNCC(pred8x16_vertical , depth);\ h->pred8x8[HOR_PRED8x8 ]= FUNCC(pred8x16_horizontal , depth);\ + h->pred8x8[PLANE_PRED8x8] = FUNCC(pred8x16_plane, depth);\ }\ - if (codec_id != AV_CODEC_ID_VP7 && codec_id != AV_CODEC_ID_VP8) {\ - if (chroma_format_idc <= 1) {\ - h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x8_plane , depth);\ - } else {\ - h->pred8x8[PLANE_PRED8x8]= FUNCC(pred8x16_plane , depth);\ - }\ - } else\ - h->pred8x8[PLANE_PRED8x8]= FUNCD(pred8x8_tm_vp8);\ - if (codec_id != AV_CODEC_ID_RV40 && codec_id != AV_CODEC_ID_VP7 && \ - codec_id != AV_CODEC_ID_VP8) {\ + if (depth > 8 || (codec_id != AV_CODEC_ID_RV40 && \ + codec_id != AV_CODEC_ID_VP7 && \ + codec_id != AV_CODEC_ID_VP8)) { \ if (chroma_format_idc <= 1) {\ h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x8_dc , depth);\ h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x8_left_dc , depth);\ @@ -521,10 +505,6 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id, h->pred8x8[DC_PRED8x8 ]= FUNCD(pred8x8_dc_rv40);\ h->pred8x8[LEFT_DC_PRED8x8]= FUNCD(pred8x8_left_dc_rv40);\ h->pred8x8[TOP_DC_PRED8x8 ]= FUNCD(pred8x8_top_dc_rv40);\ - if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8) {\ - h->pred8x8[DC_127_PRED8x8]= FUNCC(pred8x8_127_dc , depth);\ - h->pred8x8[DC_129_PRED8x8]= FUNCC(pred8x8_129_dc , depth);\ - }\ }\ if (chroma_format_idc <= 1) {\ h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x8_128_dc , depth);\ @@ -535,23 +515,7 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id, h->pred16x16[DC_PRED8x8 ]= FUNCC(pred16x16_dc , depth);\ h->pred16x16[VERT_PRED8x8 ]= FUNCC(pred16x16_vertical , depth);\ h->pred16x16[HOR_PRED8x8 ]= FUNCC(pred16x16_horizontal , depth);\ - switch(codec_id){\ - case AV_CODEC_ID_SVQ3:\ - h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_plane_svq3);\ - break;\ - case AV_CODEC_ID_RV40:\ - h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_plane_rv40);\ - break;\ - case AV_CODEC_ID_VP7:\ - case AV_CODEC_ID_VP8:\ - h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_tm_vp8);\ - h->pred16x16[DC_127_PRED8x8]= FUNCC(pred16x16_127_dc , depth);\ - h->pred16x16[DC_129_PRED8x8]= FUNCC(pred16x16_129_dc , depth);\ - break;\ - default:\ - h->pred16x16[PLANE_PRED8x8 ]= FUNCC(pred16x16_plane , depth);\ - break;\ - }\ + h->pred16x16[PLANE_PRED8x8 ]= FUNCC(pred16x16_plane , depth);\ h->pred16x16[LEFT_DC_PRED8x8]= FUNCC(pred16x16_left_dc , depth);\ h->pred16x16[TOP_DC_PRED8x8 ]= FUNCC(pred16x16_top_dc , depth);\ h->pred16x16[DC_128_PRED8x8 ]= FUNCC(pred16x16_128_dc , depth);\ @@ -564,8 +528,8 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id, h->pred8x8l_filter_add [VERT_PRED ]= FUNCC(pred8x8l_vertical_filter_add , depth);\ h->pred8x8l_filter_add [ HOR_PRED ]= FUNCC(pred8x8l_horizontal_filter_add , depth);\ if (chroma_format_idc <= 1) {\ - h->pred8x8_add [VERT_PRED8x8]= FUNCC(pred8x8_vertical_add , depth);\ - h->pred8x8_add [ HOR_PRED8x8]= FUNCC(pred8x8_horizontal_add , depth);\ + h->pred8x8_add[VERT_PRED8x8] = FUNCC(pred8x8_vertical_add, depth);\ + h->pred8x8_add[ HOR_PRED8x8] = FUNCC(pred8x8_horizontal_add, depth);\ } else {\ h->pred8x8_add [VERT_PRED8x8]= FUNCC(pred8x16_vertical_add , depth);\ h->pred8x8_add [ HOR_PRED8x8]= FUNCC(pred8x16_horizontal_add , depth);\ @@ -589,15 +553,50 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id, default: av_assert0(bit_depth<=8); H264_PRED(8) + switch (codec_id) { + case AV_CODEC_ID_SVQ3: + h->pred4x4[DIAG_DOWN_LEFT_PRED] = FUNCD(pred4x4_down_left_svq3); + h->pred16x16[PLANE_PRED8x8 ] = FUNCD(pred16x16_plane_svq3); + break; + case AV_CODEC_ID_RV40: + h->pred4x4[DIAG_DOWN_LEFT_PRED] = FUNCD(pred4x4_down_left_rv40); + h->pred4x4[VERT_LEFT_PRED ] = FUNCD(pred4x4_vertical_left_rv40); + h->pred4x4[HOR_UP_PRED ] = FUNCD(pred4x4_horizontal_up_rv40); + h->pred4x4[DIAG_DOWN_LEFT_PRED_RV40_NODOWN] = FUNCD(pred4x4_down_left_rv40_nodown); + h->pred4x4[HOR_UP_PRED_RV40_NODOWN] = FUNCD(pred4x4_horizontal_up_rv40_nodown); + h->pred4x4[VERT_LEFT_PRED_RV40_NODOWN] = FUNCD(pred4x4_vertical_left_rv40_nodown); + h->pred16x16[PLANE_PRED8x8 ] = FUNCD(pred16x16_plane_rv40); + break; + case AV_CODEC_ID_VP7: + case AV_CODEC_ID_VP8: + h->pred4x4[VERT_PRED ] = FUNCD(pred4x4_vertical_vp8); + h->pred4x4[HOR_PRED ] = FUNCD(pred4x4_horizontal_vp8); + h->pred4x4[VERT_LEFT_PRED ] = FUNCD(pred4x4_vertical_left_vp8); + h->pred4x4[TM_VP8_PRED ] = FUNCD(pred4x4_tm_vp8); + h->pred4x4[VERT_VP8_PRED ] = FUNCC(pred4x4_vertical, 8); + h->pred4x4[DC_127_PRED ] = FUNCD(pred4x4_127_dc); + h->pred4x4[DC_129_PRED ] = FUNCD(pred4x4_129_dc); + h->pred4x4[HOR_VP8_PRED ] = FUNCC(pred4x4_horizontal, 8); + h->pred8x8[PLANE_PRED8x8 ] = FUNCD(pred8x8_tm_vp8); + h->pred8x8[DC_127_PRED8x8 ] = FUNCC(pred8x8_127_dc, 8); + h->pred8x8[DC_129_PRED8x8 ] = FUNCC(pred8x8_129_dc, 8); + h->pred16x16[PLANE_PRED8x8 ] = FUNCD(pred16x16_tm_vp8); + h->pred16x16[DC_127_PRED8x8] = FUNCC(pred16x16_127_dc, 8); + h->pred16x16[DC_129_PRED8x8] = FUNCC(pred16x16_129_dc, 8); + break; + } break; } - if (ARCH_AARCH64) - ff_h264_pred_init_aarch64(h, codec_id, bit_depth, chroma_format_idc); - if (ARCH_ARM) - ff_h264_pred_init_arm(h, codec_id, bit_depth, chroma_format_idc); - if (ARCH_X86) - ff_h264_pred_init_x86(h, codec_id, bit_depth, chroma_format_idc); - if (ARCH_MIPS) - ff_h264_pred_init_mips(h, codec_id, bit_depth, chroma_format_idc); +#if ARCH_AARCH64 + ff_h264_pred_init_aarch64(h, codec_id, bit_depth, chroma_format_idc); +#elif ARCH_ARM + ff_h264_pred_init_arm(h, codec_id, bit_depth, chroma_format_idc); +#elif ARCH_X86 + ff_h264_pred_init_x86(h, codec_id, bit_depth, chroma_format_idc); +#elif ARCH_MIPS + ff_h264_pred_init_mips(h, codec_id, bit_depth, chroma_format_idc); +#elif ARCH_LOONGARCH + ff_h264_pred_init_loongarch(h, codec_id, bit_depth, chroma_format_idc); +#endif } diff --git a/media/ffvpx/libavcodec/h264pred.h b/media/ffvpx/libavcodec/h264pred.h index 2863dc9bd194..cb008548fc28 100644 --- a/media/ffvpx/libavcodec/h264pred.h +++ b/media/ffvpx/libavcodec/h264pred.h @@ -86,6 +86,8 @@ #define DC_129_PRED8x8 8 //@} +#define PART_NOT_AVAILABLE -2 + /** * Context for storing H.264 prediction functions */ @@ -122,5 +124,7 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc); void ff_h264_pred_init_mips(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc); +void ff_h264_pred_init_loongarch(H264PredContext *h, int codec_id, + const int bit_depth, const int chroma_format_idc); #endif /* AVCODEC_H264PRED_H */ diff --git a/media/ffvpx/libavcodec/h264pred_template.c b/media/ffvpx/libavcodec/h264pred_template.c index 2b30fff70f5c..b5bc942a5ed0 100644 --- a/media/ffvpx/libavcodec/h264pred_template.c +++ b/media/ffvpx/libavcodec/h264pred_template.c @@ -111,32 +111,6 @@ static void FUNCC(pred4x4_128_dc)(uint8_t *_src, const uint8_t *topright, AV_WN4PA(src+3*stride, a); } -static void FUNCC(pred4x4_127_dc)(uint8_t *_src, const uint8_t *topright, - ptrdiff_t _stride) -{ - pixel *src = (pixel*)_src; - int stride = _stride>>(sizeof(pixel)-1); - const pixel4 a = PIXEL_SPLAT_X4((1<<(BIT_DEPTH-1))-1); - - AV_WN4PA(src+0*stride, a); - AV_WN4PA(src+1*stride, a); - AV_WN4PA(src+2*stride, a); - AV_WN4PA(src+3*stride, a); -} - -static void FUNCC(pred4x4_129_dc)(uint8_t *_src, const uint8_t *topright, - ptrdiff_t _stride) -{ - pixel *src = (pixel*)_src; - int stride = _stride>>(sizeof(pixel)-1); - const pixel4 a = PIXEL_SPLAT_X4((1<<(BIT_DEPTH-1))+1); - - AV_WN4PA(src+0*stride, a); - AV_WN4PA(src+1*stride, a); - AV_WN4PA(src+2*stride, a); - AV_WN4PA(src+3*stride, a); -} - #define LOAD_TOP_RIGHT_EDGE\ const unsigned av_unused t4 = topright[0];\ @@ -427,9 +401,11 @@ static void FUNCC(pred16x16_##n##_dc)(uint8_t *_src, ptrdiff_t stride)\ PREDICT_16x16_DC(PIXEL_SPLAT_X4(v));\ } -PRED16x16_X(127, (1<<(BIT_DEPTH-1))-1) PRED16x16_X(128, (1<<(BIT_DEPTH-1))+0) +#if BIT_DEPTH == 8 +PRED16x16_X(127, (1<<(BIT_DEPTH-1))-1) PRED16x16_X(129, (1<<(BIT_DEPTH-1))+1) +#endif static inline void FUNCC(pred16x16_plane_compat)(uint8_t *_src, ptrdiff_t _stride, @@ -551,9 +527,11 @@ static void FUNCC(pred8x8_##n##_dc)(uint8_t *_src, ptrdiff_t stride)\ }\ } -PRED8x8_X(127, (1<<(BIT_DEPTH-1))-1) PRED8x8_X(128, (1<<(BIT_DEPTH-1))+0) +#if BIT_DEPTH == 8 +PRED8x8_X(127, (1<<(BIT_DEPTH-1))-1) PRED8x8_X(129, (1<<(BIT_DEPTH-1))+1) +#endif static void FUNCC(pred8x16_128_dc)(uint8_t *_src, ptrdiff_t stride) { diff --git a/media/ffvpx/libavcodec/hpeldsp.h b/media/ffvpx/libavcodec/hpeldsp.h index 768139bfc96e..45e81b10a59c 100644 --- a/media/ffvpx/libavcodec/hpeldsp.h +++ b/media/ffvpx/libavcodec/hpeldsp.h @@ -102,5 +102,6 @@ void ff_hpeldsp_init_arm(HpelDSPContext *c, int flags); void ff_hpeldsp_init_ppc(HpelDSPContext *c, int flags); void ff_hpeldsp_init_x86(HpelDSPContext *c, int flags); void ff_hpeldsp_init_mips(HpelDSPContext *c, int flags); +void ff_hpeldsp_init_loongarch(HpelDSPContext *c, int flags); #endif /* AVCODEC_HPELDSP_H */ diff --git a/media/ffvpx/libavcodec/hwaccels.h b/media/ffvpx/libavcodec/hwaccels.h index 8e54cf73f90f..ff4daca0e2c6 100644 --- a/media/ffvpx/libavcodec/hwaccels.h +++ b/media/ffvpx/libavcodec/hwaccels.h @@ -47,7 +47,6 @@ extern const AVHWAccel ff_mjpeg_vaapi_hwaccel; extern const AVHWAccel ff_mpeg1_nvdec_hwaccel; extern const AVHWAccel ff_mpeg1_vdpau_hwaccel; extern const AVHWAccel ff_mpeg1_videotoolbox_hwaccel; -extern const AVHWAccel ff_mpeg1_xvmc_hwaccel; extern const AVHWAccel ff_mpeg2_d3d11va_hwaccel; extern const AVHWAccel ff_mpeg2_d3d11va2_hwaccel; extern const AVHWAccel ff_mpeg2_nvdec_hwaccel; @@ -55,11 +54,11 @@ extern const AVHWAccel ff_mpeg2_dxva2_hwaccel; extern const AVHWAccel ff_mpeg2_vaapi_hwaccel; extern const AVHWAccel ff_mpeg2_vdpau_hwaccel; extern const AVHWAccel ff_mpeg2_videotoolbox_hwaccel; -extern const AVHWAccel ff_mpeg2_xvmc_hwaccel; extern const AVHWAccel ff_mpeg4_nvdec_hwaccel; extern const AVHWAccel ff_mpeg4_vaapi_hwaccel; extern const AVHWAccel ff_mpeg4_vdpau_hwaccel; extern const AVHWAccel ff_mpeg4_videotoolbox_hwaccel; +extern const AVHWAccel ff_prores_videotoolbox_hwaccel; extern const AVHWAccel ff_vc1_d3d11va_hwaccel; extern const AVHWAccel ff_vc1_d3d11va2_hwaccel; extern const AVHWAccel ff_vc1_dxva2_hwaccel; @@ -74,6 +73,7 @@ extern const AVHWAccel ff_vp9_dxva2_hwaccel; extern const AVHWAccel ff_vp9_nvdec_hwaccel; extern const AVHWAccel ff_vp9_vaapi_hwaccel; extern const AVHWAccel ff_vp9_vdpau_hwaccel; +extern const AVHWAccel ff_vp9_videotoolbox_hwaccel; extern const AVHWAccel ff_wmv3_d3d11va_hwaccel; extern const AVHWAccel ff_wmv3_d3d11va2_hwaccel; extern const AVHWAccel ff_wmv3_dxva2_hwaccel; diff --git a/media/ffvpx/libavcodec/hwconfig.h b/media/ffvpx/libavcodec/hwconfig.h index f421dc909f44..721424912c46 100644 --- a/media/ffvpx/libavcodec/hwconfig.h +++ b/media/ffvpx/libavcodec/hwconfig.h @@ -78,8 +78,6 @@ typedef struct AVCodecHWConfigInternal { HW_CONFIG_HWACCEL(1, 1, 1, VIDEOTOOLBOX, VIDEOTOOLBOX, ff_ ## codec ## _videotoolbox_hwaccel) #define HWACCEL_D3D11VA(codec) \ HW_CONFIG_HWACCEL(0, 0, 1, D3D11VA_VLD, NONE, ff_ ## codec ## _d3d11va_hwaccel) -#define HWACCEL_XVMC(codec) \ - HW_CONFIG_HWACCEL(0, 0, 1, XVMC, NONE, ff_ ## codec ## _xvmc_hwaccel) #define HW_CONFIG_ENCODER(device, frames, ad_hoc, format, device_type_) \ &(const AVCodecHWConfigInternal) { \ diff --git a/media/ffvpx/libavcodec/idctdsp.c b/media/ffvpx/libavcodec/idctdsp.c index 846ed0b0f832..9035003b72c6 100644 --- a/media/ffvpx/libavcodec/idctdsp.c +++ b/media/ffvpx/libavcodec/idctdsp.c @@ -17,6 +17,7 @@ */ #include "config.h" +#include "config_components.h" #include "libavutil/attributes.h" #include "libavutil/common.h" #include "avcodec.h" @@ -26,7 +27,7 @@ #include "simple_idct.h" #include "xvididct.h" -av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, +av_cold void ff_init_scantable(const uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable) { int i, end; @@ -52,10 +53,11 @@ av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation, { int i; - if (ARCH_X86) - if (ff_init_scantable_permutation_x86(idct_permutation, - perm_type)) - return; +#if ARCH_X86 + if (ff_init_scantable_permutation_x86(idct_permutation, + perm_type)) + return; +#endif switch (perm_type) { case FF_IDCT_PERM_NONE: @@ -237,7 +239,7 @@ static void ff_jref_idct1_add(uint8_t *dest, ptrdiff_t line_size, int16_t *block av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx) { - const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8; + av_unused const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8; if (avctx->lowres==1) { c->idct_put = ff_jref_idct4_put; @@ -287,7 +289,6 @@ av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx) c->perm_type = FF_IDCT_PERM_NONE; #endif /* CONFIG_FAANIDCT */ } else { // accurate/default - /* Be sure FF_IDCT_NONE will select this one, since it uses FF_IDCT_PERM_NONE */ c->idct_put = ff_simple_idct_put_int16_8bit; c->idct_add = ff_simple_idct_add_int16_8bit; c->idct = ff_simple_idct_int16_8bit; @@ -303,18 +304,21 @@ av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx) if (CONFIG_MPEG4_DECODER && avctx->idct_algo == FF_IDCT_XVID) ff_xvid_idct_init(c, avctx); - if (ARCH_AARCH64) - ff_idctdsp_init_aarch64(c, avctx, high_bit_depth); - if (ARCH_ALPHA) - ff_idctdsp_init_alpha(c, avctx, high_bit_depth); - if (ARCH_ARM) - ff_idctdsp_init_arm(c, avctx, high_bit_depth); - if (ARCH_PPC) - ff_idctdsp_init_ppc(c, avctx, high_bit_depth); - if (ARCH_X86) - ff_idctdsp_init_x86(c, avctx, high_bit_depth); - if (ARCH_MIPS) - ff_idctdsp_init_mips(c, avctx, high_bit_depth); +#if ARCH_AARCH64 + ff_idctdsp_init_aarch64(c, avctx, high_bit_depth); +#elif ARCH_ALPHA + ff_idctdsp_init_alpha(c, avctx, high_bit_depth); +#elif ARCH_ARM + ff_idctdsp_init_arm(c, avctx, high_bit_depth); +#elif ARCH_PPC + ff_idctdsp_init_ppc(c, avctx, high_bit_depth); +#elif ARCH_X86 + ff_idctdsp_init_x86(c, avctx, high_bit_depth); +#elif ARCH_MIPS + ff_idctdsp_init_mips(c, avctx, high_bit_depth); +#elif ARCH_LOONGARCH + ff_idctdsp_init_loongarch(c, avctx, high_bit_depth); +#endif ff_init_scantable_permutation(c->idct_permutation, c->perm_type); diff --git a/media/ffvpx/libavcodec/idctdsp.h b/media/ffvpx/libavcodec/idctdsp.h index ca21a31a028c..e8f20acaf291 100644 --- a/media/ffvpx/libavcodec/idctdsp.h +++ b/media/ffvpx/libavcodec/idctdsp.h @@ -43,7 +43,7 @@ enum idct_permutation_type { FF_IDCT_PERM_SSE2, }; -void ff_init_scantable(uint8_t *permutation, ScanTable *st, +void ff_init_scantable(const uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable); void ff_init_scantable_permutation(uint8_t *idct_permutation, enum idct_permutation_type perm_type); @@ -118,5 +118,7 @@ void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth); void ff_idctdsp_init_mips(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth); +void ff_idctdsp_init_loongarch(IDCTDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth); #endif /* AVCODEC_IDCTDSP_H */ diff --git a/media/ffvpx/libavcodec/imgconvert.c b/media/ffvpx/libavcodec/imgconvert.c index 8de15634041a..96511ac7d6a7 100644 --- a/media/ffvpx/libavcodec/imgconvert.c +++ b/media/ffvpx/libavcodec/imgconvert.c @@ -25,46 +25,9 @@ */ #include "avcodec.h" -#include "internal.h" -#include "mathops.h" -#include "libavutil/avassert.h" -#include "libavutil/colorspace.h" -#include "libavutil/common.h" #include "libavutil/pixdesc.h" -#include "libavutil/internal.h" -#include "libavutil/imgutils.h" +#include "libavutil/pixfmt.h" -#if FF_API_GETCHROMA -void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift) -{ - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); - av_assert0(desc); - *h_shift = desc->log2_chroma_w; - *v_shift = desc->log2_chroma_h; -} -#endif - -#if FF_API_AVCODEC_PIX_FMT -int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, - enum AVPixelFormat src_pix_fmt, - int has_alpha) -{ - return av_get_pix_fmt_loss(dst_pix_fmt, src_pix_fmt, has_alpha); -} - -enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, - enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr) -{ - return av_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, has_alpha, loss_ptr); -} - -enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, - enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr) -{ - return av_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, has_alpha, loss_ptr); -} - -#endif enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *pix_fmt_list, enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr){ @@ -83,152 +46,3 @@ enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *p return best; } -#if FF_API_AVPICTURE -FF_DISABLE_DEPRECATION_WARNINGS -/* return true if yuv planar */ -static inline int is_yuv_planar(const AVPixFmtDescriptor *desc) -{ - int i; - int planes[4] = { 0 }; - - if ( desc->flags & AV_PIX_FMT_FLAG_RGB - || !(desc->flags & AV_PIX_FMT_FLAG_PLANAR)) - return 0; - - /* set the used planes */ - for (i = 0; i < desc->nb_components; i++) - planes[desc->comp[i].plane] = 1; - - /* if there is an unused plane, the format is not planar */ - for (i = 0; i < desc->nb_components; i++) - if (!planes[i]) - return 0; - return 1; -} - -int av_picture_crop(AVPicture *dst, const AVPicture *src, - enum AVPixelFormat pix_fmt, int top_band, int left_band) -{ - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); - int y_shift; - int x_shift; - int max_step[4]; - - if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB) - return -1; - - y_shift = desc->log2_chroma_h; - x_shift = desc->log2_chroma_w; - av_image_fill_max_pixsteps(max_step, NULL, desc); - - if (is_yuv_planar(desc)) { - dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band; - dst->data[1] = src->data[1] + ((top_band >> y_shift) * src->linesize[1]) + (left_band >> x_shift); - dst->data[2] = src->data[2] + ((top_band >> y_shift) * src->linesize[2]) + (left_band >> x_shift); - } else{ - if(top_band % (1<data[0] = src->data[0] + (top_band * src->linesize[0]) + (left_band * max_step[0]); - } - - dst->linesize[0] = src->linesize[0]; - dst->linesize[1] = src->linesize[1]; - dst->linesize[2] = src->linesize[2]; - return 0; -} - -int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, - enum AVPixelFormat pix_fmt, int padtop, int padbottom, int padleft, int padright, - int *color) -{ - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); - uint8_t *optr; - int y_shift; - int x_shift; - int yheight; - int i, y; - int max_step[4]; - - if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB) - return -1; - - if (!is_yuv_planar(desc)) { - if (src) - return -1; //TODO: Not yet implemented - - av_image_fill_max_pixsteps(max_step, NULL, desc); - - if (padtop || padleft) { - memset(dst->data[0], color[0], - dst->linesize[0] * padtop + (padleft * max_step[0])); - } - - if (padleft || padright) { - optr = dst->data[0] + dst->linesize[0] * padtop + - (dst->linesize[0] - (padright * max_step[0])); - yheight = height - 1 - (padtop + padbottom); - for (y = 0; y < yheight; y++) { - memset(optr, color[0], (padleft + padright) * max_step[0]); - optr += dst->linesize[0]; - } - } - - if (padbottom || padright) { - optr = dst->data[0] + dst->linesize[0] * (height - padbottom) - - (padright * max_step[0]); - memset(optr, color[0], dst->linesize[0] * padbottom + - (padright * max_step[0])); - } - - return 0; - } - - for (i = 0; i < 3; i++) { - x_shift = i ? desc->log2_chroma_w : 0; - y_shift = i ? desc->log2_chroma_h : 0; - - if (padtop || padleft) { - memset(dst->data[i], color[i], - dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift)); - } - - if (padleft || padright) { - optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) + - (dst->linesize[i] - (padright >> x_shift)); - yheight = (height - 1 - (padtop + padbottom)) >> y_shift; - for (y = 0; y < yheight; y++) { - memset(optr, color[i], (padleft + padright) >> x_shift); - optr += dst->linesize[i]; - } - } - - if (src) { /* first line */ - uint8_t *iptr = src->data[i]; - optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) + - (padleft >> x_shift); - memcpy(optr, iptr, (width - padleft - padright) >> x_shift); - iptr += src->linesize[i]; - optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) + - (dst->linesize[i] - (padright >> x_shift)); - yheight = (height - 1 - (padtop + padbottom)) >> y_shift; - for (y = 0; y < yheight; y++) { - memset(optr, color[i], (padleft + padright) >> x_shift); - memcpy(optr + ((padleft + padright) >> x_shift), iptr, - (width - padleft - padright) >> x_shift); - iptr += src->linesize[i]; - optr += dst->linesize[i]; - } - } - - if (padbottom || padright) { - optr = dst->data[i] + dst->linesize[i] * - ((height - padbottom) >> y_shift) - (padright >> x_shift); - memset(optr, color[i],dst->linesize[i] * - (padbottom >> y_shift) + (padright >> x_shift)); - } - } - - return 0; -} -FF_ENABLE_DEPRECATION_WARNINGS -#endif /* FF_API_AVPICTURE */ diff --git a/media/ffvpx/libavcodec/internal.h b/media/ffvpx/libavcodec/internal.h index d889c1883e77..17e1de8127ae 100644 --- a/media/ffvpx/libavcodec/internal.h +++ b/media/ffvpx/libavcodec/internal.h @@ -28,86 +28,13 @@ #include "libavutil/buffer.h" #include "libavutil/channel_layout.h" -#include "libavutil/fifo.h" #include "libavutil/mathematics.h" #include "libavutil/pixfmt.h" #include "avcodec.h" #include "config.h" -/** - * The codec does not modify any global variables in the init function, - * allowing to call the init function without locking any global mutexes. - */ -#define FF_CODEC_CAP_INIT_THREADSAFE (1 << 0) -/** - * The codec allows calling the close function for deallocation even if - * the init function returned a failure. Without this capability flag, a - * codec does such cleanup internally when returning failures from the - * init function and does not expect the close function to be called at - * all. - */ -#define FF_CODEC_CAP_INIT_CLEANUP (1 << 1) -/** - * Decoders marked with FF_CODEC_CAP_SETS_PKT_DTS want to set - * AVFrame.pkt_dts manually. If the flag is set, decode.c won't overwrite - * this field. If it's unset, decode.c tries to guess the pkt_dts field - * from the input AVPacket. - */ -#define FF_CODEC_CAP_SETS_PKT_DTS (1 << 2) -/** - * The decoder extracts and fills its parameters even if the frame is - * skipped due to the skip_frame setting. - */ -#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM (1 << 3) -/** - * The decoder sets the cropping fields in the output frames manually. - * If this cap is set, the generic code will initialize output frame - * dimensions to coded rather than display values. - */ -#define FF_CODEC_CAP_EXPORTS_CROPPING (1 << 4) -/** - * Codec initializes slice-based threading with a main function - */ -#define FF_CODEC_CAP_SLICE_THREAD_HAS_MF (1 << 5) -/* - * The codec supports frame threading and has inter-frame dependencies, so it - * uses ff_thread_report/await_progress(). - */ -#define FF_CODEC_CAP_ALLOCATE_PROGRESS (1 << 6) -/** - * Codec handles avctx->thread_count == 0 (auto) internally. - */ -#define FF_CODEC_CAP_AUTO_THREADS (1 << 7) -/** - * Codec handles output frame properties internally instead of letting the - * internal logic derive them from AVCodecInternal.last_pkt_props. - */ -#define FF_CODEC_CAP_SETS_FRAME_PROPS (1 << 8) - -/** - * AVCodec.codec_tags termination value - */ -#define FF_CODEC_TAGS_END -1 - - -#ifdef TRACE -# define ff_tlog(ctx, ...) av_log(ctx, AV_LOG_TRACE, __VA_ARGS__) -#else -# define ff_tlog(ctx, ...) do { } while(0) -#endif - - -#define FF_DEFAULT_QUANT_BIAS 999999 - -#define FF_QSCALE_TYPE_MPEG1 0 -#define FF_QSCALE_TYPE_MPEG2 1 -#define FF_QSCALE_TYPE_H264 2 -#define FF_QSCALE_TYPE_VP56 3 - #define FF_SANE_NB_CHANNELS 512U -#define FF_SIGNBIT(x) ((x) >> CHAR_BIT * sizeof(x) - 1) - #if HAVE_SIMD_ALIGN_64 # define STRIDE_ALIGN 64 /* AVX-512 */ #elif HAVE_SIMD_ALIGN_32 @@ -118,20 +45,10 @@ # define STRIDE_ALIGN 8 #endif -typedef struct DecodeSimpleContext { - AVPacket *in_pkt; -} DecodeSimpleContext; - -typedef struct EncodeSimpleContext { - AVFrame *in_frame; -} EncodeSimpleContext; - typedef struct AVCodecInternal { /** - * Whether the parent AVCodecContext is a copy of the context which had - * init() called on it. - * This is used by multithreading - shared tables and picture pointers - * should be freed from the original context only. + * When using frame-threaded decoding, this field is set for the first + * worker thread (e.g. to decode extradata just once). */ int is_copy; @@ -141,23 +58,27 @@ typedef struct AVCodecInternal { */ int last_audio_frame; -#if FF_API_OLD_ENCDEC - AVFrame *to_free; -#endif - AVBufferRef *pool; void *thread_ctx; - DecodeSimpleContext ds; - AVBSFContext *bsf; + /** + * This packet is used to hold the packet given to decoders + * implementing the .decode API; it is unused by the generic + * code for decoders implementing the .receive_frame API and + * may be freely used (but not freed) by them with the caveat + * that the packet will be unreferenced generically in + * avcodec_flush_buffers(). + */ + AVPacket *in_pkt; + struct AVBSFContext *bsf; /** * Properties (timestamps+side data) extracted from the last packet passed * for decoding. */ AVPacket *last_pkt_props; - AVFifoBuffer *pkt_props; + struct AVFifo *pkt_props; /** * temporary buffer used for encoders to store their bitstream @@ -165,9 +86,28 @@ typedef struct AVCodecInternal { uint8_t *byte_buffer; unsigned int byte_buffer_size; + /** + * This is set to AV_PKT_FLAG_KEY for encoders that encode intra-only + * formats (i.e. whose codec descriptor has AV_CODEC_PROP_INTRA_ONLY set). + * This is used to set said flag generically for said encoders. + */ + int intra_only_flag; + void *frame_thread_encoder; - EncodeSimpleContext es; + /** + * The input frame is stored here for encoders implementing the simple + * encode API. + * + * Not allocated in other cases. + */ + AVFrame *in_frame; + + /** + * If this is set, then FFCodec->close (if existing) needs to be called + * for the parent AVCodecContext. + */ + int needs_close; /** * Number of audio samples to skip at the start of the next decoded frame @@ -191,18 +131,6 @@ typedef struct AVCodecInternal { AVFrame *buffer_frame; int draining_done; -#if FF_API_OLD_ENCDEC - int compat_decode_warned; - /* this variable is set by the decoder internals to signal to the old - * API compat wrappers the amount of data consumed from the last packet */ - size_t compat_decode_consumed; - /* when a partial packet has been consumed, this stores the remaining size - * of the packet (that should be submitted in the next decode call */ - size_t compat_decode_partial_size; - AVFrame *compat_decode_frame; - AVPacket *compat_encode_packet; -#endif - int showed_multi_packet_warning; int skip_samples_multiplier; @@ -215,24 +143,20 @@ typedef struct AVCodecInternal { int initial_format; int initial_width, initial_height; int initial_sample_rate; +#if FF_API_OLD_CHANNEL_LAYOUT int initial_channels; uint64_t initial_channel_layout; +#endif + AVChannelLayout initial_ch_layout; } AVCodecInternal; -struct AVCodecDefault { - const uint8_t *key; - const uint8_t *value; -}; - -extern const uint8_t ff_log2_run[41]; - /** * Return the index into tab at which {a,b} match elements {[0],[1]} of tab. * If there is no such matching pair then size is returned. */ int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b); -unsigned int avpriv_toupper4(unsigned int x); +unsigned int ff_toupper4(unsigned int x); void ff_color_frame(AVFrame *frame, const int color[4]); @@ -243,34 +167,6 @@ void ff_color_frame(AVFrame *frame, const int color[4]); */ #define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE) -/** - * Check AVPacket size and/or allocate data. - * - * Encoders supporting AVCodec.encode2() can use this as a convenience to - * ensure the output packet data is large enough, whether provided by the user - * or allocated in this function. - * - * @param avctx the AVCodecContext of the encoder - * @param avpkt the AVPacket - * If avpkt->data is already set, avpkt->size is checked - * to ensure it is large enough. - * If avpkt->data is NULL, a new buffer is allocated. - * avpkt->size is set to the specified size. - * All other AVPacket fields will be reset with av_init_packet(). - * @param size the minimum required packet size - * @param min_size This is a hint to the allocation algorithm, which indicates - * to what minimal size the caller might later shrink the packet - * to. Encoders often allocate packets which are larger than the - * amount of data that is written into them as the exact amount is - * not known at the time of allocation. min_size represents the - * size a packet might be shrunk to by the caller. Can be set to - * 0. setting this roughly correctly allows the allocation code - * to choose between several allocation strategies to improve - * speed slightly. - * @return non negative on success, negative error code on failure - */ -int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size); - /** * Rescale from sample rate to AVCodecContext.time_base. */ @@ -320,10 +216,6 @@ int ff_thread_can_start_frame(AVCodecContext *avctx); int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx); -const uint8_t *avpriv_find_start_code(const uint8_t *p, - const uint8_t *end, - uint32_t *state); - int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec); /** @@ -398,10 +290,4 @@ int ff_int_from_list_or_default(void *ctx, const char * val_name, int val, void ff_dvdsub_parse_palette(uint32_t *palette, const char *p); -#if defined(_WIN32) && CONFIG_SHARED && !defined(BUILDING_avcodec) -# define av_export_avcodec __declspec(dllimport) -#else -# define av_export_avcodec -#endif - #endif /* AVCODEC_INTERNAL_H */ diff --git a/media/ffvpx/libavcodec/jfdctfst.c b/media/ffvpx/libavcodec/jfdctfst.c index bbcf5984901c..805e05808c97 100644 --- a/media/ffvpx/libavcodec/jfdctfst.c +++ b/media/ffvpx/libavcodec/jfdctfst.c @@ -66,9 +66,8 @@ * Independent JPEG Group's fast AAN dct. */ -#include -#include -#include "libavutil/common.h" +#include +#include "libavutil/attributes.h" #include "dct.h" #define DCTSIZE 8 diff --git a/media/ffvpx/libavcodec/jrevdct.c b/media/ffvpx/libavcodec/jrevdct.c index a1a0f571ad05..36160cb66308 100644 --- a/media/ffvpx/libavcodec/jrevdct.c +++ b/media/ffvpx/libavcodec/jrevdct.c @@ -62,7 +62,9 @@ * Independent JPEG Group's LLM idct. */ -#include "libavutil/common.h" +#include +#include + #include "libavutil/intreadwrite.h" #include "dct.h" diff --git a/media/ffvpx/libavcodec/libdav1d.c b/media/ffvpx/libavcodec/libdav1d.c index 91d179ce48ad..0a46cf226431 100644 --- a/media/ffvpx/libavcodec/libdav1d.c +++ b/media/ffvpx/libavcodec/libdav1d.c @@ -19,9 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "dav1d/dav1d.h" +#include #include "libavutil/avassert.h" +#include "libavutil/cpu.h" #include "libavutil/film_grain_params.h" #include "libavutil/mastering_display_metadata.h" #include "libavutil/imgutils.h" @@ -30,6 +31,7 @@ #include "atsc_a53.h" #include "avcodec.h" #include "bytestream.h" +#include "codec_internal.h" #include "decode.h" #include "internal.h" @@ -39,6 +41,9 @@ typedef struct Libdav1dContext { AVClass *class; Dav1dContext *c; + /* This packet coincides with AVCodecInternal.in_pkt + * and is not owned by us. */ + AVPacket *pkt; AVBufferPool *pool; int pool_size; @@ -123,13 +128,98 @@ static void libdav1d_picture_release(Dav1dPicture *p, void *cookie) av_buffer_unref(&buf); } +static void libdav1d_init_params(AVCodecContext *c, const Dav1dSequenceHeader *seq) +{ + c->profile = seq->profile; + c->level = ((seq->operating_points[0].major_level - 2) << 2) + | seq->operating_points[0].minor_level; + + switch (seq->chr) { + case DAV1D_CHR_VERTICAL: + c->chroma_sample_location = AVCHROMA_LOC_LEFT; + break; + case DAV1D_CHR_COLOCATED: + c->chroma_sample_location = AVCHROMA_LOC_TOPLEFT; + break; + } + c->colorspace = (enum AVColorSpace) seq->mtrx; + c->color_primaries = (enum AVColorPrimaries) seq->pri; + c->color_trc = (enum AVColorTransferCharacteristic) seq->trc; + c->color_range = seq->color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; + + if (seq->layout == DAV1D_PIXEL_LAYOUT_I444 && + seq->mtrx == DAV1D_MC_IDENTITY && + seq->pri == DAV1D_COLOR_PRI_BT709 && + seq->trc == DAV1D_TRC_SRGB) + c->pix_fmt = pix_fmt_rgb[seq->hbd]; + else + c->pix_fmt = pix_fmt[seq->layout][seq->hbd]; + + if (seq->num_units_in_tick && seq->time_scale) { + av_reduce(&c->framerate.den, &c->framerate.num, + seq->num_units_in_tick, seq->time_scale, INT_MAX); + if (seq->equal_picture_interval) + c->ticks_per_frame = seq->num_ticks_per_picture; + } + + if (seq->film_grain_present) + c->properties |= FF_CODEC_PROPERTY_FILM_GRAIN; + else + c->properties &= ~FF_CODEC_PROPERTY_FILM_GRAIN; +} + +static av_cold int libdav1d_parse_extradata(AVCodecContext *c) +{ + Dav1dSequenceHeader seq; + size_t offset = 0; + int res; + + if (!c->extradata || c->extradata_size <= 0) + return 0; + + if (c->extradata[0] & 0x80) { + int version = c->extradata[0] & 0x7F; + + if (version != 1 || c->extradata_size < 4) { + int explode = !!(c->err_recognition & AV_EF_EXPLODE); + av_log(c, explode ? AV_LOG_ERROR : AV_LOG_WARNING, + "Error decoding extradata\n"); + return explode ? AVERROR_INVALIDDATA : 0; + } + + // Do nothing if there are no configOBUs to parse + if (c->extradata_size == 4) + return 0; + + offset = 4; + } + + res = dav1d_parse_sequence_header(&seq, c->extradata + offset, + c->extradata_size - offset); + if (res < 0) + return 0; // Assume no seqhdr OBUs are present + + libdav1d_init_params(c, &seq); + res = ff_set_dimensions(c, seq.max_width, seq.max_height); + if (res < 0) + return res; + + return 0; +} + static av_cold int libdav1d_init(AVCodecContext *c) { Libdav1dContext *dav1d = c->priv_data; Dav1dSettings s; +#if FF_DAV1D_VERSION_AT_LEAST(6,0) + int threads = c->thread_count; +#else int threads = (c->thread_count ? c->thread_count : av_cpu_count()) * 3 / 2; +#endif int res; + dav1d->pkt = c->internal->in_pkt; + av_log(c, AV_LOG_INFO, "libdav1d %s\n", dav1d_version()); dav1d_default_settings(&s); @@ -141,19 +231,22 @@ static av_cold int libdav1d_init(AVCodecContext *c) s.frame_size_limit = c->max_pixels; if (dav1d->apply_grain >= 0) s.apply_grain = dav1d->apply_grain; - else if (c->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) - s.apply_grain = 0; + else + s.apply_grain = !(c->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN); s.all_layers = dav1d->all_layers; if (dav1d->operating_point >= 0) s.operating_point = dav1d->operating_point; +#if FF_DAV1D_VERSION_AT_LEAST(6,2) + s.strict_std_compliance = c->strict_std_compliance > 0; +#endif #if FF_DAV1D_VERSION_AT_LEAST(6,0) if (dav1d->frame_threads || dav1d->tile_threads) s.n_threads = FFMAX(dav1d->frame_threads, dav1d->tile_threads); else s.n_threads = FFMIN(threads, DAV1D_MAX_THREADS); - s.max_frame_delay = (c->flags & AV_CODEC_FLAG_LOW_DELAY) ? 1 : s.n_threads; + s.max_frame_delay = (c->flags & AV_CODEC_FLAG_LOW_DELAY) ? 1 : 0; av_log(c, AV_LOG_DEBUG, "Using %d threads, %d max_frame_delay\n", s.n_threads, s.max_frame_delay); #else @@ -167,6 +260,10 @@ static av_cold int libdav1d_init(AVCodecContext *c) s.n_frame_threads, s.n_tile_threads); #endif + res = libdav1d_parse_extradata(c); + if (res < 0) + return res; + res = dav1d_open(&dav1d->c, &s); if (res < 0) return AVERROR(ENOMEM); @@ -198,37 +295,41 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) Libdav1dContext *dav1d = c->priv_data; Dav1dData *data = &dav1d->data; Dav1dPicture pic = { 0 }, *p = &pic; +#if FF_DAV1D_VERSION_AT_LEAST(5,1) + enum Dav1dEventFlags event_flags = 0; +#endif int res; if (!data->sz) { - AVPacket pkt = { 0 }; + AVPacket *const pkt = dav1d->pkt; - res = ff_decode_get_packet(c, &pkt); + res = ff_decode_get_packet(c, pkt); if (res < 0 && res != AVERROR_EOF) return res; - if (pkt.size) { - res = dav1d_data_wrap(data, pkt.data, pkt.size, libdav1d_data_free, pkt.buf); + if (pkt->size) { + res = dav1d_data_wrap(data, pkt->data, pkt->size, + libdav1d_data_free, pkt->buf); if (res < 0) { - av_packet_unref(&pkt); + av_packet_unref(pkt); return res; } - data->m.timestamp = pkt.pts; - data->m.offset = pkt.pos; - data->m.duration = pkt.duration; + data->m.timestamp = pkt->pts; + data->m.offset = pkt->pos; + data->m.duration = pkt->duration; - pkt.buf = NULL; - av_packet_unref(&pkt); + pkt->buf = NULL; + av_packet_unref(pkt); if (c->reordered_opaque != AV_NOPTS_VALUE) { - uint8_t *reordered_opaque = av_malloc(sizeof(c->reordered_opaque)); + uint8_t *reordered_opaque = av_memdup(&c->reordered_opaque, + sizeof(c->reordered_opaque)); if (!reordered_opaque) { dav1d_data_unref(data); return AVERROR(ENOMEM); } - memcpy(reordered_opaque, &c->reordered_opaque, sizeof(c->reordered_opaque)); res = dav1d_data_wrap_user_data(data, reordered_opaque, libdav1d_user_data_free, reordered_opaque); if (res < 0) { @@ -237,6 +338,9 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) return res; } } + } else if (res >= 0) { + av_packet_unref(pkt); + return AVERROR(EAGAIN); } } @@ -244,8 +348,10 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) if (res < 0) { if (res == AVERROR(EINVAL)) res = AVERROR_INVALIDDATA; - if (res != AVERROR(EAGAIN)) + if (res != AVERROR(EAGAIN)) { + dav1d_data_unref(data); return res; + } } res = dav1d_get_picture(dav1d->c, p); @@ -274,9 +380,16 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) frame->linesize[1] = p->stride[1]; frame->linesize[2] = p->stride[1]; - c->profile = p->seq_hdr->profile; - c->level = ((p->seq_hdr->operating_points[0].major_level - 2) << 2) - | p->seq_hdr->operating_points[0].minor_level; +#if FF_DAV1D_VERSION_AT_LEAST(5,1) + dav1d_get_event_flags(dav1d->c, &event_flags); + if (c->pix_fmt == AV_PIX_FMT_NONE || + event_flags & DAV1D_EVENT_FLAG_NEW_SEQUENCE) +#endif + libdav1d_init_params(c, p->seq_hdr); + res = ff_decode_frame_props(c, frame); + if (res < 0) + goto fail; + frame->width = p->p.w; frame->height = p->p.h; if (c->width != p->p.w || c->height != p->p.h) { @@ -292,46 +405,13 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) INT_MAX); ff_set_sar(c, frame->sample_aspect_ratio); - switch (p->seq_hdr->chr) { - case DAV1D_CHR_VERTICAL: - frame->chroma_location = c->chroma_sample_location = AVCHROMA_LOC_LEFT; - break; - case DAV1D_CHR_COLOCATED: - frame->chroma_location = c->chroma_sample_location = AVCHROMA_LOC_TOPLEFT; - break; - } - frame->colorspace = c->colorspace = (enum AVColorSpace) p->seq_hdr->mtrx; - frame->color_primaries = c->color_primaries = (enum AVColorPrimaries) p->seq_hdr->pri; - frame->color_trc = c->color_trc = (enum AVColorTransferCharacteristic) p->seq_hdr->trc; - frame->color_range = c->color_range = p->seq_hdr->color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; - - if (p->p.layout == DAV1D_PIXEL_LAYOUT_I444 && - p->seq_hdr->mtrx == DAV1D_MC_IDENTITY && - p->seq_hdr->pri == DAV1D_COLOR_PRI_BT709 && - p->seq_hdr->trc == DAV1D_TRC_SRGB) - frame->format = c->pix_fmt = pix_fmt_rgb[p->seq_hdr->hbd]; - else - frame->format = c->pix_fmt = pix_fmt[p->p.layout][p->seq_hdr->hbd]; - if (p->m.user_data.data) memcpy(&frame->reordered_opaque, p->m.user_data.data, sizeof(frame->reordered_opaque)); else frame->reordered_opaque = AV_NOPTS_VALUE; - if (p->seq_hdr->num_units_in_tick && p->seq_hdr->time_scale) { - av_reduce(&c->framerate.den, &c->framerate.num, - p->seq_hdr->num_units_in_tick, p->seq_hdr->time_scale, INT_MAX); - if (p->seq_hdr->equal_picture_interval) - c->ticks_per_frame = p->seq_hdr->num_ticks_per_picture; - } - // match timestamps and packet size frame->pts = p->m.timestamp; -#if FF_API_PKT_PTS -FF_DISABLE_DEPRECATION_WARNINGS - frame->pkt_pts = p->m.timestamp; -FF_ENABLE_DEPRECATION_WARNINGS -#endif frame->pkt_dts = p->m.timestamp; frame->pkt_pos = p->m.offset; frame->pkt_size = p->m.size; @@ -479,8 +559,8 @@ static av_cold int libdav1d_close(AVCodecContext *c) #define OFFSET(x) offsetof(Libdav1dContext, x) #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM static const AVOption libdav1d_options[] = { - { "tilethreads", "Tile threads", OFFSET(tile_threads), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, DAV1D_MAX_TILE_THREADS, VD }, - { "framethreads", "Frame threads", OFFSET(frame_threads), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, DAV1D_MAX_FRAME_THREADS, VD }, + { "tilethreads", "Tile threads", OFFSET(tile_threads), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, DAV1D_MAX_TILE_THREADS, VD | AV_OPT_FLAG_DEPRECATED }, + { "framethreads", "Frame threads", OFFSET(frame_threads), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, DAV1D_MAX_FRAME_THREADS, VD | AV_OPT_FLAG_DEPRECATED }, { "filmgrain", "Apply Film Grain", OFFSET(apply_grain), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VD | AV_OPT_FLAG_DEPRECATED }, { "oppoint", "Select an operating point of the scalable bitstream", OFFSET(operating_point), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 31, VD }, { "alllayers", "Output all spatial layers", OFFSET(all_layers), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD }, @@ -494,19 +574,19 @@ static const AVClass libdav1d_class = { .version = LIBAVUTIL_VERSION_INT, }; -AVCodec ff_libdav1d_decoder = { - .name = "libdav1d", - .long_name = NULL_IF_CONFIG_SMALL("dav1d AV1 decoder by VideoLAN"), - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_AV1, +const FFCodec ff_libdav1d_decoder = { + .p.name = "libdav1d", + .p.long_name = NULL_IF_CONFIG_SMALL("dav1d AV1 decoder by VideoLAN"), + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_AV1, .priv_data_size = sizeof(Libdav1dContext), .init = libdav1d_init, .close = libdav1d_close, .flush = libdav1d_flush, - .receive_frame = libdav1d_receive_frame, - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS, + FF_CODEC_RECEIVE_FRAME_CB(libdav1d_receive_frame), + .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_SETS_PKT_DTS | FF_CODEC_CAP_AUTO_THREADS, - .priv_class = &libdav1d_class, - .wrapper_name = "libdav1d", + .p.priv_class = &libdav1d_class, + .p.wrapper_name = "libdav1d", }; diff --git a/media/ffvpx/libavcodec/mathops.h b/media/ffvpx/libavcodec/mathops.h index 1c35664318f8..f81d21f9c47a 100644 --- a/media/ffvpx/libavcodec/mathops.h +++ b/media/ffvpx/libavcodec/mathops.h @@ -25,12 +25,12 @@ #include #include "libavutil/common.h" -#include "libavutil/reverse.h" #include "config.h" #define MAX_NEG_CROP 1024 extern const uint32_t ff_inverse[257]; +extern const uint8_t ff_log2_run[41]; extern const uint8_t ff_sqrt_tab[256]; extern const uint8_t ff_crop_tab[256 + 2 * MAX_NEG_CROP]; extern const uint8_t ff_zigzag_direct[64]; @@ -126,6 +126,8 @@ static inline av_const int median4(int a, int b, int c, int d) } #endif +#define FF_SIGNBIT(x) ((x) >> CHAR_BIT * sizeof(x) - 1) + #ifndef sign_extend static inline av_const int sign_extend(int val, unsigned bits) { @@ -240,12 +242,4 @@ static inline int8_t ff_u8_to_s8(uint8_t a) return b.s8; } -static av_always_inline uint32_t bitswap_32(uint32_t x) -{ - return (uint32_t)ff_reverse[ x & 0xFF] << 24 | - (uint32_t)ff_reverse[(x >> 8) & 0xFF] << 16 | - (uint32_t)ff_reverse[(x >> 16) & 0xFF] << 8 | - (uint32_t)ff_reverse[ x >> 24]; -} - #endif /* AVCODEC_MATHOPS_H */ diff --git a/media/ffvpx/libavcodec/mathtables.c b/media/ffvpx/libavcodec/mathtables.c index 81eabc7a6545..8b0031eb0057 100644 --- a/media/ffvpx/libavcodec/mathtables.c +++ b/media/ffvpx/libavcodec/mathtables.c @@ -112,3 +112,12 @@ const uint8_t ff_zigzag_scan[16+1] = { 1 + 2 * 4, 0 + 3 * 4, 1 + 3 * 4, 2 + 2 * 4, 3 + 1 * 4, 3 + 2 * 4, 2 + 3 * 4, 3 + 3 * 4, }; + +const uint8_t ff_log2_run[41] = { + 0, 0, 0, 0, 1, 1, 1, 1, + 2, 2, 2, 2, 3, 3, 3, 3, + 4, 4, 5, 5, 6, 6, 7, 7, + 8, 9, 10, 11, 12, 13, 14, 15, +16, 17, 18, 19, 20, 21, 22, 23, +24, +}; diff --git a/media/ffvpx/libavcodec/motion_est.h b/media/ffvpx/libavcodec/motion_est.h index 5742e51486ce..d0950bf7e608 100644 --- a/media/ffvpx/libavcodec/motion_est.h +++ b/media/ffvpx/libavcodec/motion_est.h @@ -118,14 +118,14 @@ int ff_pre_estimate_p_frame_motion(struct MpegEncContext *s, int ff_epzs_motion_search(struct MpegEncContext *s, int *mx_ptr, int *my_ptr, int P[10][2], int src_index, int ref_index, - int16_t (*last_mv)[2], int ref_mv_scale, int size, - int h); + const int16_t (*last_mv)[2], int ref_mv_scale, + int size, int h); int ff_get_mb_score(struct MpegEncContext *s, int mx, int my, int src_index, int ref_index, int size, int h, int add_rate); int ff_get_best_fcode(struct MpegEncContext *s, - int16_t (*mv_table)[2], int type); + const int16_t (*mv_table)[2], int type); void ff_fix_long_p_mvs(struct MpegEncContext *s, int type); void ff_fix_long_mvs(struct MpegEncContext *s, uint8_t *field_select_table, diff --git a/media/ffvpx/libavcodec/moz.build b/media/ffvpx/libavcodec/moz.build index d952987a044d..45dcaeac340c 100644 --- a/media/ffvpx/libavcodec/moz.build +++ b/media/ffvpx/libavcodec/moz.build @@ -9,11 +9,12 @@ if CONFIG['FFVPX_ASFLAGS']: if CONFIG['CPU_ARCH'] == 'x86' or CONFIG['CPU_ARCH'] == 'x86_64': DIRS += ['x86'] - elif CONFIG['CPU_ARCH'] == 'aarch64': - DIRS += ['aarch64'] elif CONFIG['CPU_ARCH'] == 'arm': DIRS += ['arm'] +if CONFIG['CPU_ARCH'] == 'aarch64': + DIRS += ['aarch64'] + SharedLibrary('mozavcodec') SOURCES += [ 'allcodecs.c', @@ -40,6 +41,7 @@ SOURCES += [ 'flacdata.c', 'flacdec.c', 'flacdsp.c', + 'get_buffer.c', 'idctdsp.c', 'jfdctfst.c', 'jfdctint.c', @@ -54,6 +56,7 @@ SOURCES += [ 'mpegaudiodsp_data.c', 'mpegaudiodsp_fixed.c', 'mpegaudiodsp_float.c', + 'mpegaudiotabs.c', 'null_bsf.c', 'options.c', 'parser.c', @@ -65,6 +68,8 @@ SOURCES += [ 'reverse.c', 'simple_idct.c', 'utils.c', + 'version.c', + 'vlc.c', 'vorbis_parser.c', 'xiph.c' ] @@ -73,7 +78,6 @@ if not CONFIG['MOZ_FFVPX_AUDIOONLY']: SOURCES += [ 'av1dec.c', 'avpicture.c', - 'bitstream_filter.c', 'cbs.c', 'cbs_av1.c', 'golomb.c', diff --git a/media/ffvpx/libavcodec/mpegaudiodata.c b/media/ffvpx/libavcodec/mpegaudiodata.c index 0569281109ef..669590908fc5 100644 --- a/media/ffvpx/libavcodec/mpegaudiodata.c +++ b/media/ffvpx/libavcodec/mpegaudiodata.c @@ -26,19 +26,6 @@ #include "mpegaudiodata.h" - -const uint16_t avpriv_mpa_bitrate_tab[2][3][15] = { - { {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 }, - {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 }, - {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 } }, - { {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256}, - {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}, - {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160} - } -}; - -const uint16_t avpriv_mpa_freq_tab[3] = { 44100, 48000, 32000 }; - /*******************************************************/ /* layer 2 tables */ diff --git a/media/ffvpx/libavcodec/mpegaudiodata.h b/media/ffvpx/libavcodec/mpegaudiodata.h index 0a425ef6a83e..a4148a1ffecc 100644 --- a/media/ffvpx/libavcodec/mpegaudiodata.h +++ b/media/ffvpx/libavcodec/mpegaudiodata.h @@ -31,14 +31,13 @@ #include "config.h" -#include "internal.h" #include "vlc.h" #define MODE_EXT_MS_STEREO 2 #define MODE_EXT_I_STEREO 1 -extern av_export_avcodec const uint16_t avpriv_mpa_bitrate_tab[2][3][15]; -extern av_export_avcodec const uint16_t avpriv_mpa_freq_tab[3]; +extern const uint16_t ff_mpa_bitrate_tab[2][3][15]; +extern const uint16_t ff_mpa_freq_tab[3]; extern const int ff_mpa_sblimit_table[5]; extern const int ff_mpa_quant_steps[17]; extern const int ff_mpa_quant_bits[17]; diff --git a/media/ffvpx/libavcodec/mpegaudiodec_common.c b/media/ffvpx/libavcodec/mpegaudiodec_common.c index a963f6683a76..71fc2e7c81a7 100644 --- a/media/ffvpx/libavcodec/mpegaudiodec_common.c +++ b/media/ffvpx/libavcodec/mpegaudiodec_common.c @@ -28,6 +28,7 @@ #include #include "libavutil/avassert.h" +#include "libavutil/libm.h" #include "libavutil/thread.h" #include "mpegaudiodata.h" @@ -64,10 +65,10 @@ const uint8_t ff_lsf_nsf_table[6][3][4] = { /* mpegaudio layer 3 huffman tables */ VLC ff_huff_vlc[16]; -static VLC_TYPE huff_vlc_tables[128 + 128 + 128 + 130 + 128 + 154 + 166 + 142 + - 204 + 190 + 170 + 542 + 460 + 662 + 414][2]; +static VLCElem huff_vlc_tables[128 + 128 + 128 + 130 + 128 + 154 + 166 + 142 + + 204 + 190 + 170 + 542 + 460 + 662 + 414]; VLC ff_huff_quad_vlc[2]; -static VLC_TYPE huff_quad_vlc_tables[64 + 16][2]; +static VLCElem huff_quad_vlc_tables[64 + 16]; static const uint8_t mpa_hufflens[] = { /* Huffman table 1 - 4 entries */ diff --git a/media/ffvpx/libavcodec/mpegaudiodec_fixed.c b/media/ffvpx/libavcodec/mpegaudiodec_fixed.c index a3c8ddc21ed9..8a5721d38318 100644 --- a/media/ffvpx/libavcodec/mpegaudiodec_fixed.c +++ b/media/ffvpx/libavcodec/mpegaudiodec_fixed.c @@ -19,10 +19,12 @@ */ #include "config.h" +#include "config_components.h" #include "libavutil/samplefmt.h" #define USE_FLOATS 0 +#include "codec_internal.h" #include "mpegaudio.h" #define SHR(a,b) (((int)(a))>>(b)) @@ -59,91 +61,91 @@ static const int32_t csa_table[8][4] = { #include "mpegaudiodec_template.c" #if CONFIG_MP1_DECODER -AVCodec ff_mp1_decoder = { - .name = "mp1", - .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"), - .type = AVMEDIA_TYPE_AUDIO, - .id = AV_CODEC_ID_MP1, +const FFCodec ff_mp1_decoder = { + .p.name = "mp1", + .p.long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"), + .p.type = AVMEDIA_TYPE_AUDIO, + .p.id = AV_CODEC_ID_MP1, .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, - .decode = decode_frame, - .capabilities = AV_CODEC_CAP_CHANNEL_CONF | + FF_CODEC_DECODE_CB(decode_frame), + .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1, .flush = flush, - .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, + .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; #endif #if CONFIG_MP2_DECODER -AVCodec ff_mp2_decoder = { - .name = "mp2", - .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"), - .type = AVMEDIA_TYPE_AUDIO, - .id = AV_CODEC_ID_MP2, +const FFCodec ff_mp2_decoder = { + .p.name = "mp2", + .p.long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"), + .p.type = AVMEDIA_TYPE_AUDIO, + .p.id = AV_CODEC_ID_MP2, .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, - .decode = decode_frame, - .capabilities = AV_CODEC_CAP_CHANNEL_CONF | + FF_CODEC_DECODE_CB(decode_frame), + .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1, .flush = flush, - .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, + .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; #endif #if CONFIG_MP3_DECODER -AVCodec ff_mp3_decoder = { - .name = "mp3", - .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"), - .type = AVMEDIA_TYPE_AUDIO, - .id = AV_CODEC_ID_MP3, +const FFCodec ff_mp3_decoder = { + .p.name = "mp3", + .p.long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"), + .p.type = AVMEDIA_TYPE_AUDIO, + .p.id = AV_CODEC_ID_MP3, .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, - .decode = decode_frame, - .capabilities = AV_CODEC_CAP_CHANNEL_CONF | + FF_CODEC_DECODE_CB(decode_frame), + .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1, .flush = flush, - .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, + .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; #endif #if CONFIG_MP3ADU_DECODER -AVCodec ff_mp3adu_decoder = { - .name = "mp3adu", - .long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"), - .type = AVMEDIA_TYPE_AUDIO, - .id = AV_CODEC_ID_MP3ADU, +const FFCodec ff_mp3adu_decoder = { + .p.name = "mp3adu", + .p.long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"), + .p.type = AVMEDIA_TYPE_AUDIO, + .p.id = AV_CODEC_ID_MP3ADU, .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, - .decode = decode_frame_adu, - .capabilities = AV_CODEC_CAP_CHANNEL_CONF | + FF_CODEC_DECODE_CB(decode_frame_adu), + .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1, .flush = flush, - .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, + .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; #endif #if CONFIG_MP3ON4_DECODER -AVCodec ff_mp3on4_decoder = { - .name = "mp3on4", - .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"), - .type = AVMEDIA_TYPE_AUDIO, - .id = AV_CODEC_ID_MP3ON4, +const FFCodec ff_mp3on4_decoder = { + .p.name = "mp3on4", + .p.long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"), + .p.type = AVMEDIA_TYPE_AUDIO, + .p.id = AV_CODEC_ID_MP3ON4, .priv_data_size = sizeof(MP3On4DecodeContext), .init = decode_init_mp3on4, .close = decode_close_mp3on4, - .decode = decode_frame_mp3on4, - .capabilities = AV_CODEC_CAP_CHANNEL_CONF | + FF_CODEC_DECODE_CB(decode_frame_mp3on4), + .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1, .flush = flush_mp3on4, - .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, + .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, }; diff --git a/media/ffvpx/libavcodec/mpegaudiodec_template.c b/media/ffvpx/libavcodec/mpegaudiodec_template.c index 4fd9e3a6904b..a28cac986793 100644 --- a/media/ffvpx/libavcodec/mpegaudiodec_template.c +++ b/media/ffvpx/libavcodec/mpegaudiodec_template.c @@ -24,6 +24,8 @@ * MPEG Audio decoder */ +#include "config_components.h" + #include "libavutil/attributes.h" #include "libavutil/avassert.h" #include "libavutil/channel_layout.h" @@ -1546,8 +1548,8 @@ static int mp_decode_frame(MPADecodeContext *s, OUT_INT **samples, return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels; } -static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr, - AVPacket *avpkt) +static int decode_frame(AVCodecContext *avctx, AVFrame *frame, + int *got_frame_ptr, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; @@ -1580,8 +1582,9 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr, return AVERROR_INVALIDDATA; } /* update codec info */ - avctx->channels = s->nb_channels; - avctx->channel_layout = s->nb_channels == 1 ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO; + av_channel_layout_uninit(&avctx->ch_layout); + avctx->ch_layout = s->nb_channels == 1 ? (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO : + (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; if (!avctx->bit_rate) avctx->bit_rate = s->bit_rate; @@ -1593,7 +1596,7 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr, buf_size= s->frame_size; } - s->frame = data; + s->frame = frame; ret = mp_decode_frame(s, NULL, buf, buf_size); if (ret >= 0) { @@ -1630,7 +1633,7 @@ static void flush(AVCodecContext *avctx) } #if CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER -static int decode_frame_adu(AVCodecContext *avctx, void *data, +static int decode_frame_adu(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; @@ -1638,7 +1641,6 @@ static int decode_frame_adu(AVCodecContext *avctx, void *data, MPADecodeContext *s = avctx->priv_data; uint32_t header; int len, ret; - int av_unused out_size; len = buf_size; @@ -1662,14 +1664,15 @@ static int decode_frame_adu(AVCodecContext *avctx, void *data, } /* update codec info */ avctx->sample_rate = s->sample_rate; - avctx->channels = s->nb_channels; - avctx->channel_layout = s->nb_channels == 1 ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO; + av_channel_layout_uninit(&avctx->ch_layout); + avctx->ch_layout = s->nb_channels == 1 ? (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO : + (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; if (!avctx->bit_rate) avctx->bit_rate = s->bit_rate; s->frame_size = len; - s->frame = data; + s->frame = frame; ret = mp_decode_frame(s, NULL, buf, buf_size); if (ret < 0) { @@ -1757,8 +1760,8 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) } s->frames = mp3Frames[cfg.chan_config]; s->coff = chan_offset[cfg.chan_config]; - avctx->channels = ff_mpeg4audio_channels[cfg.chan_config]; - avctx->channel_layout = chan_layout[cfg.chan_config]; + av_channel_layout_uninit(&avctx->ch_layout); + av_channel_layout_from_mask(&avctx->ch_layout, chan_layout[cfg.chan_config]); if (cfg.sample_rate < 16000) s->syncword = 0xffe00000; @@ -1810,10 +1813,9 @@ static void flush_mp3on4(AVCodecContext *avctx) } -static int decode_frame_mp3on4(AVCodecContext *avctx, void *data, +static int decode_frame_mp3on4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt) { - AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MP3On4DecodeContext *s = avctx->priv_data; @@ -1855,8 +1857,8 @@ static int decode_frame_mp3on4(AVCodecContext *avctx, void *data, return AVERROR_INVALIDDATA; } - if (ch + m->nb_channels > avctx->channels || - s->coff[fr] + m->nb_channels > avctx->channels) { + if (ch + m->nb_channels > avctx->ch_layout.nb_channels || + s->coff[fr] + m->nb_channels > avctx->ch_layout.nb_channels) { av_log(avctx, AV_LOG_ERROR, "frame channel count exceeds codec " "channel count\n"); return AVERROR_INVALIDDATA; @@ -1881,7 +1883,7 @@ static int decode_frame_mp3on4(AVCodecContext *avctx, void *data, avctx->bit_rate += m->bit_rate; } - if (ch != avctx->channels) { + if (ch != avctx->ch_layout.nb_channels) { av_log(avctx, AV_LOG_ERROR, "failed to decode all channels\n"); return AVERROR_INVALIDDATA; } @@ -1889,7 +1891,7 @@ static int decode_frame_mp3on4(AVCodecContext *avctx, void *data, /* update codec info */ avctx->sample_rate = s->mp3decctx[0]->sample_rate; - frame->nb_samples = out_size / (avctx->channels * sizeof(OUT_INT)); + frame->nb_samples = out_size / (avctx->ch_layout.nb_channels * sizeof(OUT_INT)); *got_frame_ptr = 1; return buf_size; diff --git a/media/ffvpx/libavcodec/mpegaudiodecheader.c b/media/ffvpx/libavcodec/mpegaudiodecheader.c index 6cc79f18b566..ef63befbf473 100644 --- a/media/ffvpx/libavcodec/mpegaudiodecheader.c +++ b/media/ffvpx/libavcodec/mpegaudiodecheader.c @@ -24,10 +24,8 @@ * MPEG Audio header decoder. */ -#include "libavutil/common.h" +#include "libavutil/macros.h" -#include "avcodec.h" -#include "internal.h" #include "mpegaudio.h" #include "mpegaudiodata.h" #include "mpegaudiodecheader.h" @@ -54,9 +52,9 @@ int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header) s->layer = 4 - ((header >> 17) & 3); /* extract frequency */ sample_rate_index = (header >> 10) & 3; - if (sample_rate_index >= FF_ARRAY_ELEMS(avpriv_mpa_freq_tab)) + if (sample_rate_index >= FF_ARRAY_ELEMS(ff_mpa_freq_tab)) sample_rate_index = 0; - sample_rate = avpriv_mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25); + sample_rate = ff_mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25); sample_rate_index += 3 * (s->lsf + mpeg25); s->sample_rate_index = sample_rate_index; s->error_protection = ((header >> 16) & 1) ^ 1; @@ -77,7 +75,7 @@ int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header) s->nb_channels = 2; if (bitrate_index != 0) { - frame_size = avpriv_mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index]; + frame_size = ff_mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index]; s->bit_rate = frame_size * 1000; switch(s->layer) { case 1: diff --git a/media/ffvpx/libavcodec/mpegaudiodecheader.h b/media/ffvpx/libavcodec/mpegaudiodecheader.h index 1da2a4cb6f93..ed5d1f3b3362 100644 --- a/media/ffvpx/libavcodec/mpegaudiodecheader.h +++ b/media/ffvpx/libavcodec/mpegaudiodecheader.h @@ -27,7 +27,8 @@ #ifndef AVCODEC_MPEGAUDIODECHEADER_H #define AVCODEC_MPEGAUDIODECHEADER_H -#include "avcodec.h" +#include +#include "codec_id.h" #define MP3_MASK 0xFFFE0CCF diff --git a/media/ffvpx/libavcodec/mpegaudiodsp.c b/media/ffvpx/libavcodec/mpegaudiodsp.c index f03e24464467..5a5a679d918c 100644 --- a/media/ffvpx/libavcodec/mpegaudiodsp.c +++ b/media/ffvpx/libavcodec/mpegaudiodsp.c @@ -74,8 +74,9 @@ static av_cold void mpadsp_init_tabs(void) } } - if (ARCH_X86) - ff_mpadsp_init_x86_tabs(); +#if ARCH_X86 + ff_mpadsp_init_x86_tabs(); +#endif } av_cold void ff_mpadsp_init(MPADSPContext *s) @@ -94,10 +95,19 @@ av_cold void ff_mpadsp_init(MPADSPContext *s) s->imdct36_blocks_float = ff_imdct36_blocks_float; s->imdct36_blocks_fixed = ff_imdct36_blocks_fixed; - if (ARCH_AARCH64) ff_mpadsp_init_aarch64(s); - if (ARCH_ARM) ff_mpadsp_init_arm(s); - if (ARCH_PPC) ff_mpadsp_init_ppc(s); - if (ARCH_X86) ff_mpadsp_init_x86(s); - if (HAVE_MIPSFPU) ff_mpadsp_init_mipsfpu(s); - if (HAVE_MIPSDSP) ff_mpadsp_init_mipsdsp(s); +#if ARCH_AARCH64 + ff_mpadsp_init_aarch64(s); +#elif ARCH_ARM + ff_mpadsp_init_arm(s); +#elif ARCH_PPC + ff_mpadsp_init_ppc(s); +#elif ARCH_X86 + ff_mpadsp_init_x86(s); +#endif +#if HAVE_MIPSFPU + ff_mpadsp_init_mipsfpu(s); +#endif +#if HAVE_MIPSDSP + ff_mpadsp_init_mipsdsp(s); +#endif } diff --git a/media/ffvpx/libavcodec/mpegaudiodsp.h b/media/ffvpx/libavcodec/mpegaudiodsp.h index 4577d515d9d1..7bc635191abc 100644 --- a/media/ffvpx/libavcodec/mpegaudiodsp.h +++ b/media/ffvpx/libavcodec/mpegaudiodsp.h @@ -22,7 +22,7 @@ #include #include -#include "libavutil/common.h" +#include "libavutil/macros.h" typedef struct MPADSPContext { void (*apply_window_float)(float *synth_buf, float *window, diff --git a/media/ffvpx/libavcodec/mpegaudiodsp_template.c b/media/ffvpx/libavcodec/mpegaudiodsp_template.c index 97317967a20b..fbbd94e48646 100644 --- a/media/ffvpx/libavcodec/mpegaudiodsp_template.c +++ b/media/ffvpx/libavcodec/mpegaudiodsp_template.c @@ -21,7 +21,6 @@ #include #include "libavutil/attributes.h" -#include "libavutil/mem.h" #include "libavutil/mem_internal.h" #include "libavutil/thread.h" diff --git a/media/ffvpx/libavcodec/mpegaudiotab.h b/media/ffvpx/libavcodec/mpegaudiotab.h new file mode 100644 index 000000000000..bb2e5de4ea1b --- /dev/null +++ b/media/ffvpx/libavcodec/mpegaudiotab.h @@ -0,0 +1,102 @@ +/* + * mpeg audio layer 2 tables. Most of them come from the mpeg audio + * specification. + * + * Copyright (c) 2000, 2001 Fabrice Bellard + * + * 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 + */ + +/** + * @file + * mpeg audio layer 2 tables. + * Most of them come from the mpeg audio specification. + */ + +#ifndef AVCODEC_MPEGAUDIOTAB_H +#define AVCODEC_MPEGAUDIOTAB_H + +#include +#include "mpegaudio.h" + +static const int costab32[30] = { + FIX(0.54119610014619701222), + FIX(1.3065629648763763537), + + FIX(0.50979557910415917998), + FIX(2.5629154477415054814), + FIX(0.89997622313641556513), + FIX(0.60134488693504528634), + + FIX(0.5024192861881556782), + FIX(5.1011486186891552563), + FIX(0.78815462345125020249), + FIX(0.64682178335999007679), + FIX(0.56694403481635768927), + FIX(1.0606776859903470633), + FIX(1.7224470982383341955), + FIX(0.52249861493968885462), + + FIX(10.19000812354803287), + FIX(0.674808341455005678), + FIX(1.1694399334328846596), + FIX(0.53104259108978413284), + FIX(2.0577810099534108446), + FIX(0.58293496820613388554), + FIX(0.83934964541552681272), + FIX(0.50547095989754364798), + FIX(3.4076084184687189804), + FIX(0.62250412303566482475), + FIX(0.97256823786196078263), + FIX(0.51544730992262455249), + FIX(1.4841646163141661852), + FIX(0.5531038960344445421), + FIX(0.74453627100229857749), + FIX(0.5006029982351962726), +}; + +static const int bitinv32[32] = { + 0, 16, 8, 24, 4, 20, 12, 28, + 2, 18, 10, 26, 6, 22, 14, 30, + 1, 17, 9, 25, 5, 21, 13, 29, + 3, 19, 11, 27, 7, 23, 15, 31 +}; + + +/* signal to noise ratio of each quantification step (could be + computed from quant_steps[]). The values are dB multiplied by 10 +*/ +static const unsigned short quant_snr[17] = { + 70, 110, 160, 208, + 253, 316, 378, 439, + 499, 559, 620, 680, + 740, 800, 861, 920, + 980 +}; + +/* fixed psycho acoustic model. Values of SNR taken from the 'toolame' + project */ +static const float fixed_smr[SBLIMIT] = { + 30, 17, 16, 10, 3, 12, 8, 2.5, + 5, 5, 6, 6, 5, 6, 10, 6, + -4, -10, -21, -30, -42, -55, -68, -75, + -75, -75, -75, -75, -91, -107, -110, -108 +}; + +static const unsigned char nb_scale_factors[4] = { 3, 2, 1, 2 }; + +#endif /* AVCODEC_MPEGAUDIOTAB_H */ diff --git a/media/ffvpx/libavcodec/mpegaudiotabs.c b/media/ffvpx/libavcodec/mpegaudiotabs.c new file mode 100644 index 000000000000..eaa380c80851 --- /dev/null +++ b/media/ffvpx/libavcodec/mpegaudiotabs.c @@ -0,0 +1,22 @@ +/* + * MPEG Audio common tables + * copyright (c) 2002 Fabrice Bellard + * + * 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 "mpegaudiotabs.h" diff --git a/media/ffvpx/libavcodec/mpegaudiotabs.h b/media/ffvpx/libavcodec/mpegaudiotabs.h new file mode 100644 index 000000000000..671b83848d5d --- /dev/null +++ b/media/ffvpx/libavcodec/mpegaudiotabs.h @@ -0,0 +1,39 @@ +/* + * MPEG Audio common tables + * copyright (c) 2002 Fabrice Bellard + * + * 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 + */ + +#ifndef AVCODEC_MPEGAUDIOTABS_H +#define AVCODEC_MPEGAUDIOTABS_H + +#include + +const uint16_t ff_mpa_bitrate_tab[2][3][15] = { + { { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 }, + { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 }, + { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 } }, + { { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256 }, + { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 }, + { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 } + } +}; + +const uint16_t ff_mpa_freq_tab[3] = { 44100, 48000, 32000 }; + +#endif diff --git a/media/ffvpx/libavcodec/mpegpicture.h b/media/ffvpx/libavcodec/mpegpicture.h index 4bcd66679798..0671bbae8eff 100644 --- a/media/ffvpx/libavcodec/mpegpicture.h +++ b/media/ffvpx/libavcodec/mpegpicture.h @@ -27,8 +27,9 @@ #include "avcodec.h" #include "motion_est.h" -#include "thread.h" +#include "threadframe.h" +#define MPEGVIDEO_MAX_PLANES 4 #define MAX_PICTURE_COUNT 36 #define EDGE_WIDTH 16 @@ -88,7 +89,7 @@ typedef struct Picture { int reference; int shared; - uint64_t encoding_error[AV_NUM_DATA_POINTERS]; + uint64_t encoding_error[MPEGVIDEO_MAX_PLANES]; } Picture; /** @@ -107,8 +108,8 @@ int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me, int ff_mpeg_ref_picture(AVCodecContext *avctx, Picture *dst, Picture *src); void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *picture); -void ff_free_picture_tables(Picture *pic); -int ff_update_picture_tables(Picture *dst, Picture *src); +void ff_mpv_picture_free(AVCodecContext *avctx, Picture *pic); +int ff_update_picture_tables(Picture *dst, const Picture *src); int ff_find_unused_picture(AVCodecContext *avctx, Picture *picture, int shared); diff --git a/media/ffvpx/libavcodec/mpegutils.h b/media/ffvpx/libavcodec/mpegutils.h index 81f0b73bb153..c92f9192db2f 100644 --- a/media/ffvpx/libavcodec/mpegutils.h +++ b/media/ffvpx/libavcodec/mpegutils.h @@ -26,7 +26,6 @@ #include "libavutil/frame.h" #include "avcodec.h" -#include "version.h" /** * Return value for header parsers if frame is not coded. @@ -38,12 +37,6 @@ #define PICT_BOTTOM_FIELD 2 #define PICT_FRAME 3 -/** - * Value of Picture.reference when Picture is not a reference picture, but - * is held for delayed output. - */ -#define DELAYED_PIC_REF 4 - #define MAX_MB_BYTES (30 * 16 * 16 * 3 / 8 + 120) #define MAX_FCODE 7 @@ -143,7 +136,6 @@ void ff_draw_horiz_band(AVCodecContext *avctx, AVFrame *cur, AVFrame *last, */ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_table, uint32_t *mbtype_table, int8_t *qscale_table, int16_t (*motion_val[2])[2], - int *low_delay, int mb_width, int mb_height, int mb_stride, int quarter_sample); #endif /* AVCODEC_MPEGUTILS_H */ diff --git a/media/ffvpx/libavcodec/mpegvideo.h b/media/ffvpx/libavcodec/mpegvideo.h index 5a99c196561d..82889a0edd83 100644 --- a/media/ffvpx/libavcodec/mpegvideo.h +++ b/media/ffvpx/libavcodec/mpegvideo.h @@ -28,8 +28,6 @@ #ifndef AVCODEC_MPEGVIDEO_H #define AVCODEC_MPEGVIDEO_H -#include - #include "avcodec.h" #include "blockdsp.h" #include "error_resilience.h" @@ -39,42 +37,25 @@ #include "h263dsp.h" #include "hpeldsp.h" #include "idctdsp.h" -#include "internal.h" #include "me_cmp.h" #include "motion_est.h" #include "mpegpicture.h" #include "mpegvideodsp.h" #include "mpegvideoencdsp.h" -#include "mpegvideodata.h" #include "pixblockdsp.h" #include "put_bits.h" #include "ratecontrol.h" +#if FF_API_FLAG_TRUNCATED #include "parser.h" +#endif #include "mpegutils.h" -#include "mpeg12data.h" #include "qpeldsp.h" -#include "thread.h" #include "videodsp.h" -#include "libavutil/opt.h" -#include "libavutil/timecode.h" - #define MAX_THREADS 32 #define MAX_B_FRAMES 16 -/* Start codes. */ -#define SEQ_END_CODE 0x000001b7 -#define SEQ_START_CODE 0x000001b3 -#define GOP_START_CODE 0x000001b8 -#define PICTURE_START_CODE 0x00000100 -#define SLICE_MIN_START_CODE 0x00000101 -#define SLICE_MAX_START_CODE 0x000001af -#define EXT_START_CODE 0x000001b5 -#define USER_START_CODE 0x000001b2 -#define SLICE_START_CODE 0x000001b7 - - /** * MpegEncContext. */ @@ -96,6 +77,9 @@ typedef struct MpegEncContext { * offsets used in ASM. */ struct AVCodecContext *avctx; + /* The following pointer is intended for codecs sharing code + * between decoder and encoder and in need of a common context to do so. */ + void *private_ctx; /* the following parameters must be initialized before encoding */ int width, height;///< picture size. must be a multiple of 16 int gop_size; @@ -115,7 +99,6 @@ typedef struct MpegEncContext { int max_b_frames; ///< max number of B-frames for encoding int luma_elim_threshold; int chroma_elim_threshold; - int strict_std_compliance; ///< strictly follow the std (MPEG-4, ...) int workaround_bugs; ///< workaround bugs in encoders which cannot be detected automatically int codec_tag; ///< internal codec_tag upper case converted from avctx codec_tag /* the following fields are managed internally by the encoder */ @@ -137,7 +120,7 @@ typedef struct MpegEncContext { Picture **input_picture; ///< next pictures on display order for encoding Picture **reordered_input_picture; ///< pointer to the next pictures in coded order for encoding - int64_t user_specified_pts; ///< last non-zero pts from AVFrame which was passed into avcodec_encode_video2() + int64_t user_specified_pts; ///< last non-zero pts from AVFrame which was passed into avcodec_send_frame() /** * pts difference between the first and second input frame, used for * calculating dts of the first frame when there's a delay */ @@ -168,10 +151,10 @@ typedef struct MpegEncContext { Picture next_picture; /** - * copy of the source picture structure for encoding. + * Reference to the source picture for encoding. * note, linesize & data, might not match the source picture (for field pictures) */ - Picture new_picture; + AVFrame *new_picture; /** * copy of the current picture structure. @@ -208,14 +191,11 @@ typedef struct MpegEncContext { int *lambda_table; int adaptive_quant; ///< use adaptive quantization int dquant; ///< qscale difference to prev qscale - int closed_gop; ///< MPEG1/2 GOP is closed int pict_type; ///< AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ... int vbv_delay; int last_pict_type; //FIXME removes int last_non_b_pict_type; ///< used for MPEG-4 gmc B-frames & ratecontrol int droppable; - int frame_rate_index; - AVRational mpeg2_frame_rate_ext; int last_lambda_for[5]; ///< last lambda for a specific pict type int skipdct; ///< skip dct and code zero residual @@ -243,8 +223,8 @@ typedef struct MpegEncContext { int16_t (*b_bidir_forw_mv_table_base)[2]; int16_t (*b_bidir_back_mv_table_base)[2]; int16_t (*b_direct_mv_table_base)[2]; - int16_t (*p_field_mv_table_base[2][2])[2]; - int16_t (*b_field_mv_table_base[2][2][2])[2]; + int16_t (*p_field_mv_table_base)[2]; + int16_t (*b_field_mv_table_base)[2]; int16_t (*p_mv_table)[2]; ///< MV table (1MV per MB) P-frame encoding int16_t (*b_forw_mv_table)[2]; ///< MV table (1MV per MB) forward mode B-frame encoding int16_t (*b_back_mv_table)[2]; ///< MV table (1MV per MB) backward mode B-frame encoding @@ -253,8 +233,8 @@ typedef struct MpegEncContext { int16_t (*b_direct_mv_table)[2]; ///< MV table (1MV per MB) direct mode B-frame encoding int16_t (*p_field_mv_table[2][2])[2]; ///< MV table (2MV per MB) interlaced P-frame encoding int16_t (*b_field_mv_table[2][2][2])[2];///< MV table (4MV per MB) interlaced B-frame encoding - uint8_t (*p_field_select_table[2]); - uint8_t (*b_field_select_table[2][2]); + uint8_t (*p_field_select_table[2]); ///< Only the first element is allocated + uint8_t (*b_field_select_table[2][2]); ///< Only the first element is allocated int motion_est; ///< ME algorithm int me_penalty_compensation; int me_pre; ///< prepass for motion estimation @@ -301,7 +281,6 @@ typedef struct MpegEncContext { uint16_t chroma_intra_matrix[64]; uint16_t inter_matrix[64]; uint16_t chroma_inter_matrix[64]; - int force_duplicated_matrix; ///< Force duplication of mjpeg matrices, useful for rtp streaming int intra_quant_bias; ///< bias for the quantizer int inter_quant_bias; ///< bias for the quantizer @@ -315,7 +294,6 @@ typedef struct MpegEncContext { uint8_t *inter_ac_vlc_length; uint8_t *inter_ac_vlc_last_length; uint8_t *luma_dc_vlc_length; -#define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level)) int coded_score[12]; @@ -346,8 +324,6 @@ typedef struct MpegEncContext { int i_tex_bits; int p_tex_bits; int i_count; - int f_count; - int b_count; int skip_count; int misc_bits; ///< cbp, mb_type int last_bits; ///< temp var used for calculating the above vars @@ -357,9 +333,10 @@ typedef struct MpegEncContext { int resync_mb_y; ///< y position of last resync marker GetBitContext last_resync_gb; ///< used to search for the next resync marker int mb_num_left; ///< number of MBs left in this video packet (for partitioned Slices only) - int next_p_frame_damaged; ///< set if the next p frame is damaged, to avoid showing trashed B-frames +#if FF_API_FLAG_TRUNCATED ParseContext parse_context; +#endif /* H.263 specific */ int gob_index; @@ -369,9 +346,6 @@ typedef struct MpegEncContext { uint8_t *mb_info_ptr; int mb_info_size; int ehc_mode; -#if FF_API_MPV_RC_STRATEGY - int rc_strategy; ///< deprecated -#endif /* H.263+ specific */ int umvplus; ///< == H.263+ && unrestricted_mv @@ -401,12 +375,10 @@ typedef struct MpegEncContext { int mcsel; int quant_precision; int quarter_sample; ///< 1->qpel, 0->half pel ME/MC - int aspect_ratio_info; //FIXME remove int sprite_warping_accuracy; int data_partitioning; ///< data partitioning flag from header int partitioned_frame; ///< is current frame partitioned int low_delay; ///< no reordering needed / has no B-frames - int vo_type; PutBitContext tex_pb; ///< used for data partitioned VOPs PutBitContext pb2; ///< used for data partitioned VOPs int mpeg_quant; @@ -425,8 +397,6 @@ typedef struct MpegEncContext { /* MJPEG specific */ struct MJpegContext *mjpeg_ctx; int esc_pos; - int pred; - int huffman; /* MSMPEG4 specific */ int mv_table_index; @@ -441,31 +411,23 @@ typedef struct MpegEncContext { int per_mb_rl_table; int esc3_level_length; int esc3_run_length; - /** [mb_intra][isChroma][level][run][last] */ - int (*ac_stats)[2][MAX_LEVEL+1][MAX_RUN+1][2]; int inter_intra_pred; int mspel; - /* SpeedHQ specific */ - int slice_start; - /* decompression specific */ GetBitContext gb; /* MPEG-1 specific */ - int gop_picture_number; ///< index of the first picture of a GOP based on fake_pic_num & MPEG-1 specific int last_mv_dir; ///< last mv_dir, used for B-frame encoding - uint8_t *vbv_delay_ptr; ///< pointer to vbv_delay in the bitstream + int vbv_delay_pos; ///< offset of vbv_delay in the bitstream /* MPEG-2-specific - I wished not to have to support this mess. */ int progressive_sequence; int mpeg_f_code[2][2]; - int a53_cc; // picture structure defines are loaded from mpegutils.h int picture_structure; - int64_t timecode_frame_start; ///< GOP timecode frame start number, in non drop frame format int intra_dc_precision; int frame_pred_frame_dct; int top_field_first; @@ -474,8 +436,6 @@ typedef struct MpegEncContext { int brd_scale; int intra_vlc_format; int alternate_scan; - int seq_disp_ext; - int video_format; #define VIDEO_FORMAT_COMPONENT 0 #define VIDEO_FORMAT_PAL 1 #define VIDEO_FORMAT_NTSC 2 @@ -495,29 +455,18 @@ typedef struct MpegEncContext { int full_pel[2]; int interlaced_dct; int first_field; ///< is 1 for the first field of a field picture 0 otherwise - int drop_frame_timecode; ///< timecode is in drop frame format. - int scan_offset; ///< reserve space for SVCD scan offset user data. /* RTP specific */ int rtp_mode; int rtp_payload_size; - char *tc_opt_str; ///< timecode option string - AVTimecode tc; ///< timecode context - uint8_t *ptr_lastgob; - int swap_uv; //vcr2 codec is an MPEG-2 variant with U and V swapped - int pack_pblocks; //xvmc needs to keep blocks without gaps. int16_t (*pblocks[12])[64]; int16_t (*block)[64]; ///< points to one of the following blocks int16_t (*blocks)[12][64]; // for HQ mode we need to keep the best block int (*decode_mb)(struct MpegEncContext *s, int16_t block[12][64]); // used by some codecs to avoid a switch() - int32_t (*block32)[12][64]; - int dpcm_direction; // 0 = DCT, 1 = DPCM top to bottom scan, -1 = DPCM bottom to top scan - int16_t (*dpcm_macroblock)[3][256]; - #define SLICE_OK 0 #define SLICE_ERROR -1 #define SLICE_END -2 ///", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_MV0 }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ -{ "luma_elim_threshold", "single coefficient elimination threshold for luminance (negative values also consider dc coefficient)",\ - FF_MPV_OFFSET(luma_elim_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\ -{ "chroma_elim_threshold", "single coefficient elimination threshold for chrominance (negative values also consider dc coefficient)",\ - FF_MPV_OFFSET(chroma_elim_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\ -{ "quantizer_noise_shaping", NULL, FF_MPV_OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FF_MPV_OPT_FLAGS },\ -{ "error_rate", "Simulate errors in the bitstream to test error concealment.", \ - FF_MPV_OFFSET(error_rate), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FF_MPV_OPT_FLAGS },\ -{"qsquish", "how to keep quantizer between qmin and qmax (0 = clip, 1 = use differentiable function)", \ - FF_MPV_OFFSET(rc_qsquish), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, 0, 99, FF_MPV_OPT_FLAGS}, \ -{"rc_qmod_amp", "experimental quantizer modulation", FF_MPV_OFFSET(rc_qmod_amp), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ -{"rc_qmod_freq", "experimental quantizer modulation", FF_MPV_OFFSET(rc_qmod_freq), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS}, \ -{"rc_eq", "Set rate control equation. When computing the expression, besides the standard functions " \ - "defined in the section 'Expression Evaluation', the following functions are available: " \ - "bits2qp(bits), qp2bits(qp). Also the following constants are available: iTex pTex tex mv " \ - "fCode iCount mcVar var isI isP isB avgQP qComp avgIITex avgPITex avgPPTex avgBPTex avgTex.", \ - FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING, .flags = FF_MPV_OPT_FLAGS }, \ -{"rc_init_cplx", "initial complexity for 1-pass encoding", FF_MPV_OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ -{"rc_buf_aggressivity", "currently useless", FF_MPV_OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ -{"border_mask", "increase the quantizer for macroblocks close to borders", FF_MPV_OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ -{"lmin", "minimum Lagrange factor (VBR)", FF_MPV_OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 = 2*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"lmax", "maximum Lagrange factor (VBR)", FF_MPV_OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 31*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"ibias", "intra quant bias", FF_MPV_OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"pbias", "inter quant bias", FF_MPV_OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"motion_est", "motion estimation algorithm", FF_MPV_OFFSET(motion_est), AV_OPT_TYPE_INT, {.i64 = FF_ME_EPZS }, FF_ME_ZERO, FF_ME_XONE, FF_MPV_OPT_FLAGS, "motion_est" }, \ -{ "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ -{ "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ -{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ -{ "force_duplicated_matrix", "Always write luma and chroma matrix for mjpeg, useful for rtp streaming.", FF_MPV_OFFSET(force_duplicated_matrix), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS }, \ -{"b_strategy", "Strategy to choose between I/P/B-frames", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS }, \ -{"b_sensitivity", "Adjust sensitivity of b_frame_strategy 1", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"brd_scale", "Downscale frames for dynamic B-frame decision", FF_MPV_OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 3, FF_MPV_OPT_FLAGS }, \ -{"skip_threshold", "Frame skip threshold", FF_MPV_OFFSET(frame_skip_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"skip_factor", "Frame skip factor", FF_MPV_OFFSET(frame_skip_factor), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"skip_exp", "Frame skip exponent", FF_MPV_OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"skip_cmp", "Frame skip compare function", FF_MPV_OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{"sc_threshold", "Scene change threshold", FF_MPV_OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"noise_reduction", "Noise reduction", FF_MPV_OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"mpeg_quant", "Use MPEG quantizers instead of H.263", FF_MPV_OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS }, \ -{"ps", "RTP payload size in bytes", FF_MPV_OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"mepc", "Motion estimation bitrate penalty compensation (1.0 = 256)", FF_MPV_OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"mepre", "pre motion estimation", FF_MPV_OFFSET(me_pre), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"intra_penalty", "Penalty for intra blocks in block decision", FF_MPV_OFFSET(intra_penalty), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX/2, FF_MPV_OPT_FLAGS }, \ -{"a53cc", "Use A53 Closed Captions (if available)", FF_MPV_OFFSET(a53_cc), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FF_MPV_OPT_FLAGS }, \ -FF_MPV_RC_STRATEGY_OPTS - -extern const AVOption ff_mpv_generic_options[]; /** * Set the given MpegEncContext to common defaults (same for encoding @@ -689,8 +546,6 @@ extern const AVOption ff_mpv_generic_options[]; */ void ff_mpv_common_defaults(MpegEncContext *s); -void ff_dct_encode_init_x86(MpegEncContext *s); - int ff_mpv_common_init(MpegEncContext *s); void ff_mpv_common_init_arm(MpegEncContext *s); void ff_mpv_common_init_axp(MpegEncContext *s); @@ -698,46 +553,34 @@ void ff_mpv_common_init_neon(MpegEncContext *s); void ff_mpv_common_init_ppc(MpegEncContext *s); void ff_mpv_common_init_x86(MpegEncContext *s); void ff_mpv_common_init_mips(MpegEncContext *s); +/** + * Initialize an MpegEncContext's thread contexts. Presumes that + * slice_context_count is already set and that all the fields + * that are freed/reset in free_duplicate_context() are NULL. + */ +int ff_mpv_init_duplicate_contexts(MpegEncContext *s); +/** + * Initialize and allocates MpegEncContext fields dependent on the resolution. + */ +int ff_mpv_init_context_frame(MpegEncContext *s); +/** + * Frees and resets MpegEncContext fields depending on the resolution + * as well as the slice thread contexts. + * Is used during resolution changes to avoid a full reinitialization of the + * codec. + */ +void ff_mpv_free_context_frame(MpegEncContext *s); -int ff_mpv_common_frame_size_change(MpegEncContext *s); void ff_mpv_common_end(MpegEncContext *s); -void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx); void ff_mpv_reconstruct_mb(MpegEncContext *s, int16_t block[12][64]); -void ff_mpv_report_decode_progress(MpegEncContext *s); - -int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx); -void ff_mpv_frame_end(MpegEncContext *s); - -int ff_mpv_encode_init(AVCodecContext *avctx); -void ff_mpv_encode_init_x86(MpegEncContext *s); - -int ff_mpv_encode_end(AVCodecContext *avctx); -int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, - const AVFrame *frame, int *got_packet); -int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t size_increase); void ff_clean_intra_table_entries(MpegEncContext *s); -void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h); -void ff_mpeg_flush(AVCodecContext *avctx); -void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict); - -int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type); - -void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix); - -int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src); -int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src); +int ff_update_duplicate_context(MpegEncContext *dst, const MpegEncContext *src); void ff_set_qscale(MpegEncContext * s, int qscale); void ff_mpv_idct_init(MpegEncContext *s); -int ff_dct_encode_init(MpegEncContext *s); -void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[2][64], - const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra); -int ff_dct_quantize_c(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow); -void ff_block_permute(int16_t *block, uint8_t *permutation, - const uint8_t *scantable, int last); void ff_init_block_index(MpegEncContext *s); void ff_mpv_motion(MpegEncContext *s, @@ -762,22 +605,4 @@ static inline void ff_update_block_index(MpegEncContext *s){ s->dest[2]+= (2 >> s->chroma_x_shift) * block_size; } -static inline int get_bits_diff(MpegEncContext *s){ - const int bits= put_bits_count(&s->pb); - const int last= s->last_bits; - - s->last_bits = bits; - - return bits - last; -} - -static inline int mpeg_get_qscale(MpegEncContext *s) -{ - int qscale = get_bits(&s->gb, 5); - if (s->q_scale_type) - return ff_mpeg2_non_linear_qscale[qscale]; - else - return qscale << 1; -} - #endif /* AVCODEC_MPEGVIDEO_H */ diff --git a/media/ffvpx/libavcodec/null_bsf.c b/media/ffvpx/libavcodec/null_bsf.c index 595945027d00..28237076fbff 100644 --- a/media/ffvpx/libavcodec/null_bsf.c +++ b/media/ffvpx/libavcodec/null_bsf.c @@ -21,10 +21,9 @@ * Null bitstream filter -- pass the input through unchanged. */ -#include "bsf.h" #include "bsf_internal.h" -const AVBitStreamFilter ff_null_bsf = { - .name = "null", +const FFBitStreamFilter ff_null_bsf = { + .p.name = "null", .filter = ff_bsf_get_packet_ref, }; diff --git a/media/ffvpx/libavcodec/options.c b/media/ffvpx/libavcodec/options.c index 61689b48d94e..2e05d29e1ee6 100644 --- a/media/ffvpx/libavcodec/options.c +++ b/media/ffvpx/libavcodec/options.c @@ -24,8 +24,10 @@ * Options definition for AVCodecContext. */ +#include "config_components.h" + #include "avcodec.h" -#include "internal.h" +#include "codec_internal.h" #include "libavutil/avassert.h" #include "libavutil/internal.h" #include "libavutil/mem.h" @@ -39,7 +41,7 @@ FF_ENABLE_DEPRECATION_WARNINGS static const char* context_to_name(void* ptr) { AVCodecContext *avc= ptr; - if(avc && avc->codec && avc->codec->name) + if (avc && avc->codec) return avc->codec->name; else return "NULL"; @@ -53,25 +55,6 @@ static void *codec_child_next(void *obj, void *prev) return NULL; } -#if FF_API_CHILD_CLASS_NEXT -static const AVClass *codec_child_class_next(const AVClass *prev) -{ - void *iter = NULL; - const AVCodec *c = NULL; - - /* find the codec that corresponds to prev */ - while (prev && (c = av_codec_iterate(&iter))) - if (c->priv_class == prev) - break; - - /* find next codec with priv options */ - while (c = av_codec_iterate(&iter)) - if (c->priv_class) - return c->priv_class; - return NULL; -} -#endif - static const AVClass *codec_child_class_iterate(void **iter) { const AVCodec *c; @@ -85,8 +68,10 @@ static const AVClass *codec_child_class_iterate(void **iter) static AVClassCategory get_category(void *ptr) { AVCodecContext* avctx = ptr; - if(avctx->codec && avctx->codec->decode) return AV_CLASS_CATEGORY_DECODER; - else return AV_CLASS_CATEGORY_ENCODER; + if (avctx->codec && av_codec_is_decoder(avctx->codec)) + return AV_CLASS_CATEGORY_DECODER; + else + return AV_CLASS_CATEGORY_ENCODER; } static const AVClass av_codec_context_class = { @@ -96,9 +81,6 @@ static const AVClass av_codec_context_class = { .version = LIBAVUTIL_VERSION_INT, .log_level_offset_offset = offsetof(AVCodecContext, log_level_offset), .child_next = codec_child_next, -#if FF_API_CHILD_CLASS_NEXT - .child_class_next = codec_child_class_next, -#endif .child_class_iterate = codec_child_class_iterate, .category = AV_CLASS_CATEGORY_ENCODER, .get_category = get_category, @@ -106,6 +88,7 @@ static const AVClass av_codec_context_class = { static int init_context_defaults(AVCodecContext *s, const AVCodec *codec) { + const FFCodec *const codec2 = ffcodec(codec); int flags=0; memset(s, 0, sizeof(AVCodecContext)); @@ -125,6 +108,8 @@ static int init_context_defaults(AVCodecContext *s, const AVCodec *codec) flags= AV_OPT_FLAG_SUBTITLE_PARAM; av_opt_set_defaults2(s, flags, flags); + av_channel_layout_uninit(&s->ch_layout); + s->time_base = (AVRational){0,1}; s->framerate = (AVRational){ 0, 1 }; s->pkt_timebase = (AVRational){ 0, 1 }; @@ -134,26 +119,24 @@ static int init_context_defaults(AVCodecContext *s, const AVCodec *codec) s->execute = avcodec_default_execute; s->execute2 = avcodec_default_execute2; s->sample_aspect_ratio = (AVRational){0,1}; + s->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; s->pix_fmt = AV_PIX_FMT_NONE; s->sw_pix_fmt = AV_PIX_FMT_NONE; s->sample_fmt = AV_SAMPLE_FMT_NONE; s->reordered_opaque = AV_NOPTS_VALUE; - if(codec && codec->priv_data_size){ - if(!s->priv_data){ - s->priv_data= av_mallocz(codec->priv_data_size); - if (!s->priv_data) { - return AVERROR(ENOMEM); - } - } + if(codec && codec2->priv_data_size){ + s->priv_data = av_mallocz(codec2->priv_data_size); + if (!s->priv_data) + return AVERROR(ENOMEM); if(codec->priv_class){ *(const AVClass**)s->priv_data = codec->priv_class; av_opt_set_defaults(s->priv_data); } } - if (codec && codec->defaults) { + if (codec && codec2->defaults) { int ret; - const AVCodecDefault *d = codec->defaults; + const FFCodecDefault *d = codec2->defaults; while (d->key) { ret = av_opt_set(s, d->key, d->value, 0); av_assert0(ret >= 0); @@ -163,13 +146,6 @@ static int init_context_defaults(AVCodecContext *s, const AVCodec *codec) return 0; } -#if FF_API_GET_CONTEXT_DEFAULTS -int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec) -{ - return init_context_defaults(s, codec); -} -#endif - AVCodecContext *avcodec_alloc_context3(const AVCodec *codec) { AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext)); @@ -199,121 +175,18 @@ void avcodec_free_context(AVCodecContext **pavctx) av_freep(&avctx->intra_matrix); av_freep(&avctx->inter_matrix); av_freep(&avctx->rc_override); + av_channel_layout_uninit(&avctx->ch_layout); av_freep(pavctx); } -#if FF_API_COPY_CONTEXT -static void copy_context_reset(AVCodecContext *avctx) -{ - int i; - - av_opt_free(avctx); -#if FF_API_CODED_FRAME -FF_DISABLE_DEPRECATION_WARNINGS - av_frame_free(&avctx->coded_frame); -FF_ENABLE_DEPRECATION_WARNINGS -#endif - av_freep(&avctx->rc_override); - av_freep(&avctx->intra_matrix); - av_freep(&avctx->inter_matrix); - av_freep(&avctx->extradata); - av_freep(&avctx->subtitle_header); - av_buffer_unref(&avctx->hw_frames_ctx); - av_buffer_unref(&avctx->hw_device_ctx); - for (i = 0; i < avctx->nb_coded_side_data; i++) - av_freep(&avctx->coded_side_data[i].data); - av_freep(&avctx->coded_side_data); - avctx->subtitle_header_size = 0; - avctx->nb_coded_side_data = 0; - avctx->extradata_size = 0; -} - -int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src) -{ - const AVCodec *orig_codec = dest->codec; - uint8_t *orig_priv_data = dest->priv_data; - - if (avcodec_is_open(dest)) { // check that the dest context is uninitialized - av_log(dest, AV_LOG_ERROR, - "Tried to copy AVCodecContext %p into already-initialized %p\n", - src, dest); - return AVERROR(EINVAL); - } - - copy_context_reset(dest); - - memcpy(dest, src, sizeof(*dest)); - av_opt_copy(dest, src); - - dest->priv_data = orig_priv_data; - dest->codec = orig_codec; - - if (orig_priv_data && src->codec && src->codec->priv_class && - dest->codec && dest->codec->priv_class) - av_opt_copy(orig_priv_data, src->priv_data); - - - /* set values specific to opened codecs back to their default state */ - dest->slice_offset = NULL; - dest->hwaccel = NULL; - dest->internal = NULL; -#if FF_API_CODED_FRAME -FF_DISABLE_DEPRECATION_WARNINGS - dest->coded_frame = NULL; -FF_ENABLE_DEPRECATION_WARNINGS -#endif - - /* reallocate values that should be allocated separately */ - dest->extradata = NULL; - dest->coded_side_data = NULL; - dest->intra_matrix = NULL; - dest->inter_matrix = NULL; - dest->rc_override = NULL; - dest->subtitle_header = NULL; - dest->hw_frames_ctx = NULL; - dest->hw_device_ctx = NULL; - dest->nb_coded_side_data = 0; - -#define alloc_and_copy_or_fail(obj, size, pad) \ - if (src->obj && size > 0) { \ - dest->obj = av_malloc(size + pad); \ - if (!dest->obj) \ - goto fail; \ - memcpy(dest->obj, src->obj, size); \ - if (pad) \ - memset(((uint8_t *) dest->obj) + size, 0, pad); \ - } - alloc_and_copy_or_fail(extradata, src->extradata_size, - AV_INPUT_BUFFER_PADDING_SIZE); - dest->extradata_size = src->extradata_size; - alloc_and_copy_or_fail(intra_matrix, 64 * sizeof(int16_t), 0); - alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0); - alloc_and_copy_or_fail(rc_override, src->rc_override_count * sizeof(*src->rc_override), 0); - alloc_and_copy_or_fail(subtitle_header, src->subtitle_header_size, 1); - av_assert0(dest->subtitle_header_size == src->subtitle_header_size); -#undef alloc_and_copy_or_fail - - if (src->hw_frames_ctx) { - dest->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx); - if (!dest->hw_frames_ctx) - goto fail; - } - - return 0; - -fail: - copy_context_reset(dest); - return AVERROR(ENOMEM); -} -#endif - const AVClass *avcodec_get_class(void) { return &av_codec_context_class; } #if FF_API_GET_FRAME_CLASS +FF_DISABLE_DEPRECATION_WARNINGS #define FOFFSET(x) offsetof(AVFrame,x) static const AVOption frame_options[]={ @@ -324,7 +197,9 @@ static const AVOption frame_options[]={ {"width", "", FOFFSET(width), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0}, {"height", "", FOFFSET(height), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0}, {"format", "", FOFFSET(format), AV_OPT_TYPE_INT, {.i64 = -1 }, 0, INT_MAX, 0}, +#if FF_API_OLD_CHANNEL_LAYOUT {"channel_layout", "", FOFFSET(channel_layout), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, 0}, +#endif {"sample_rate", "", FOFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0}, {NULL}, }; @@ -340,6 +215,7 @@ const AVClass *avcodec_get_frame_class(void) { return &av_frame_class; } +FF_ENABLE_DEPRECATION_WARNINGS #endif #define SROFFSET(x) offsetof(AVSubtitleRect,x) diff --git a/media/ffvpx/libavcodec/options_table.h b/media/ffvpx/libavcodec/options_table.h index e12159f73451..e72b4d12b62a 100644 --- a/media/ffvpx/libavcodec/options_table.h +++ b/media/ffvpx/libavcodec/options_table.h @@ -22,13 +22,15 @@ #ifndef AVCODEC_OPTIONS_TABLE_H #define AVCODEC_OPTIONS_TABLE_H +#include "config_components.h" + #include #include #include #include "libavutil/opt.h" #include "avcodec.h" -#include "version.h" +#include "version_major.h" #define OFFSET(x) offsetof(AVCodecContext,x) #define DEFAULT 0 //should be NAN but it does not work as it is not a constant in glibc as required by ANSI/ISO C @@ -59,7 +61,9 @@ static const AVOption avcodec_options[] = { {"pass2", "use internal 2-pass ratecontrol in second pass mode", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PASS2 }, INT_MIN, INT_MAX, 0, "flags"}, {"gray", "only decode/encode grayscale", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_GRAY }, INT_MIN, INT_MAX, V|E|D, "flags"}, {"psnr", "error[?] variables will be set during encoding", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_PSNR }, INT_MIN, INT_MAX, V|E, "flags"}, -{"truncated", "Input bitstream might be randomly truncated", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_TRUNCATED }, INT_MIN, INT_MAX, V|D, "flags"}, +#if FF_API_FLAG_TRUNCATED +{"truncated", "(Deprecated, use parsers instead.) Input bitstream might be randomly truncated", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_TRUNCATED }, INT_MIN, INT_MAX, V|D | AV_OPT_FLAG_DEPRECATED, "flags"}, +#endif {"ildct", "use interlaced DCT", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_INTERLACED_DCT }, INT_MIN, INT_MAX, V|E, "flags"}, {"low_delay", "force low delay", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_LOW_DELAY }, INT_MIN, INT_MAX, V|D|E, "flags"}, {"global_header", "place global headers in extradata instead of every keyframe", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG_GLOBAL_HEADER }, INT_MIN, INT_MAX, V|A|E, "flags"}, @@ -87,7 +91,9 @@ static const AVOption avcodec_options[] = { {"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, INT_MAX}, {"g", "set the group of picture (GOP) size", OFFSET(gop_size), AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E}, {"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D|E}, +#if FF_API_OLD_CHANNEL_LAYOUT {"ac", "set number of audio channels", OFFSET(channels), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D|E}, +#endif {"cutoff", "set cutoff bandwidth", OFFSET(cutoff), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|E}, {"frame_size", NULL, OFFSET(frame_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|E}, {"frame_number", NULL, OFFSET(frame_number), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, @@ -101,21 +107,6 @@ static const AVOption avcodec_options[] = { {"qdiff", "maximum difference between the quantizer scales (VBR)", OFFSET(max_qdiff), AV_OPT_TYPE_INT, {.i64 = 3 }, INT_MIN, INT_MAX, V|E}, {"bf", "set maximum number of B-frames between non-B-frames", OFFSET(max_b_frames), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, -1, INT_MAX, V|E}, {"b_qfactor", "QP factor between P- and B-frames", OFFSET(b_quant_factor), AV_OPT_TYPE_FLOAT, {.dbl = 1.25 }, -FLT_MAX, FLT_MAX, V|E}, -#if FF_API_PRIVATE_OPT -{"b_strategy", "strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, V|E}, -{"ps", "RTP payload size in bytes", OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, -#endif -#if FF_API_STAT_BITS -{"mv_bits", NULL, OFFSET(mv_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, -{"header_bits", NULL, OFFSET(header_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, -{"i_tex_bits", NULL, OFFSET(i_tex_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, -{"p_tex_bits", NULL, OFFSET(p_tex_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, -{"i_count", NULL, OFFSET(i_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, -{"p_count", NULL, OFFSET(p_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, -{"skip_count", NULL, OFFSET(skip_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, -{"misc_bits", NULL, OFFSET(misc_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, -{"frame_bits", NULL, OFFSET(frame_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, -#endif {"codec_tag", NULL, OFFSET(codec_tag), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, {"bug", "work around not autodetected encoder bugs", OFFSET(workaround_bugs), AV_OPT_TYPE_FLAGS, {.i64 = FF_BUG_AUTODETECT }, INT_MIN, INT_MAX, V|D, "bug"}, {"autodetect", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_AUTODETECT }, INT_MIN, INT_MAX, V|D, "bug"}, @@ -151,9 +142,6 @@ static const AVOption avcodec_options[] = { {"aggressive", "consider things that a sane encoder should not do as an error", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_AGGRESSIVE | AV_EF_COMPLIANT | AV_EF_CAREFUL}, INT_MIN, INT_MAX, A|V|S|D|E, "err_detect"}, {"has_b_frames", NULL, OFFSET(has_b_frames), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX}, {"block_align", NULL, OFFSET(block_align), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX}, -#if FF_API_PRIVATE_OPT -{"mpeg_quant", "use MPEG quantizers instead of H.263", OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, -#endif {"rc_override_count", NULL, OFFSET(rc_override_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, {"maxrate", "maximum bitrate (in bits/s). Used for VBV together with bufsize.", OFFSET(rc_max_rate), AV_OPT_TYPE_INT64, {.i64 = DEFAULT }, 0, INT_MAX, V|A|E}, {"minrate", "minimum bitrate (in bits/s). Most useful in setting up a CBR encode. It is of little use otherwise.", @@ -194,12 +182,6 @@ static const AVOption avcodec_options[] = { {"deblock", "use strong deblock filter for damaged MBs", 0, AV_OPT_TYPE_CONST, {.i64 = FF_EC_DEBLOCK }, INT_MIN, INT_MAX, V|D, "ec"}, {"favor_inter", "favor predicting from the previous frame", 0, AV_OPT_TYPE_CONST, {.i64 = FF_EC_FAVOR_INTER }, INT_MIN, INT_MAX, V|D, "ec"}, {"bits_per_coded_sample", NULL, OFFSET(bits_per_coded_sample), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX}, -#if FF_API_PRIVATE_OPT -{"pred", "prediction method", OFFSET(prediction_method), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "pred"}, -{"left", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PRED_LEFT }, INT_MIN, INT_MAX, V|E, "pred"}, -{"plane", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PRED_PLANE }, INT_MIN, INT_MAX, V|E, "pred"}, -{"median", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PRED_MEDIAN }, INT_MIN, INT_MAX, V|E, "pred"}, -#endif {"aspect", "sample aspect ratio", OFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, 10, V|E}, {"sar", "sample aspect ratio", OFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, 10, V|E}, {"debug", "print specific debug info", OFFSET(debug), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT }, 0, INT_MAX, V|A|S|E|D, "debug"}, @@ -220,34 +202,15 @@ static const AVOption avcodec_options[] = { {"nomc", "skip motion compensation", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_NOMC }, INT_MIN, INT_MAX, V|A|D, "debug"}, {"dia_size", "diamond type & size for motion estimation", OFFSET(dia_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"last_pred", "amount of motion predictors from the previous frame", OFFSET(last_predictor_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, -#if FF_API_PRIVATE_OPT -{"preme", "pre motion estimation", OFFSET(pre_me), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, -#endif {"pre_dia_size", "diamond type & size for motion estimation pre-pass", OFFSET(pre_dia_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"subq", "sub-pel motion estimation quality", OFFSET(me_subpel_quality), AV_OPT_TYPE_INT, {.i64 = 8 }, INT_MIN, INT_MAX, V|E}, {"me_range", "limit motion vectors range (1023 for DivX player)", OFFSET(me_range), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"global_quality", NULL, OFFSET(global_quality), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|A|E}, -#if FF_API_CODER_TYPE -{"coder", NULL, OFFSET(coder_type), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "coder"}, -{"vlc", "variable length coder / Huffman coder", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_VLC }, INT_MIN, INT_MAX, V|E, "coder"}, -{"ac", "arithmetic coder", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_AC }, INT_MIN, INT_MAX, V|E, "coder"}, -{"raw", "raw (no encoding)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_RAW }, INT_MIN, INT_MAX, V|E, "coder"}, -{"rle", "run-length coder", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_RLE }, INT_MIN, INT_MAX, V|E, "coder"}, -#endif /* FF_API_CODER_TYPE */ -#if FF_API_PRIVATE_OPT -{"context", "context model", OFFSET(context_model), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, -#endif {"slice_flags", NULL, OFFSET(slice_flags), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, {"mbd", "macroblock decision algorithm (high quality mode)", OFFSET(mb_decision), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, 2, V|E, "mbd"}, {"simple", "use mbcmp", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MB_DECISION_SIMPLE }, INT_MIN, INT_MAX, V|E, "mbd"}, {"bits", "use fewest bits", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MB_DECISION_BITS }, INT_MIN, INT_MAX, V|E, "mbd"}, {"rd", "use best rate distortion", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MB_DECISION_RD }, INT_MIN, INT_MAX, V|E, "mbd"}, -#if FF_API_PRIVATE_OPT -{"sc_threshold", "scene change threshold", OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, -#endif -#if FF_API_PRIVATE_OPT -{"nr", "noise reduction", OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, -#endif {"rc_init_occupancy", "number of bits which should be loaded into the rc buffer before decoding starts", OFFSET(rc_initial_buffer_occupancy), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"threads", "set the number of threads", OFFSET(thread_count), AV_OPT_TYPE_INT, {.i64 = 1 }, 0, INT_MAX, V|A|E|D, "threads"}, {"auto", "autodetect a suitable number of threads to use", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, INT_MIN, INT_MAX, V|E|D, "threads"}, @@ -261,12 +224,6 @@ static const AVOption avcodec_options[] = { {"level", NULL, OFFSET(level), AV_OPT_TYPE_INT, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E|CC, "avctx.level"}, {"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "avctx.level"}, {"lowres", "decode at 1= 1/2, 2=1/4, 3=1/8 resolutions", OFFSET(lowres), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|A|D}, -#if FF_API_PRIVATE_OPT -{"skip_threshold", "frame skip threshold", OFFSET(frame_skip_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"skip_factor", "frame skip factor", OFFSET(frame_skip_factor), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"skip_exp", "frame skip exponent", OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"skipcmp", "frame skip compare function", OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -#endif {"cmp", "full-pel ME compare function", OFFSET(me_cmp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, {"subcmp", "sub-pel ME compare function", OFFSET(me_sub_cmp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, {"mbcmp", "macroblock compare function", OFFSET(mb_cmp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, @@ -292,9 +249,6 @@ static const AVOption avcodec_options[] = { {"msad", "sum of absolute differences, median predicted", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_MEDIAN_SAD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, {"mblmin", "minimum macroblock Lagrange factor (VBR)", OFFSET(mb_lmin), AV_OPT_TYPE_INT, {.i64 = FF_QP2LAMBDA * 2 }, 1, FF_LAMBDA_MAX, V|E}, {"mblmax", "maximum macroblock Lagrange factor (VBR)", OFFSET(mb_lmax), AV_OPT_TYPE_INT, {.i64 = FF_QP2LAMBDA * 31 }, 1, FF_LAMBDA_MAX, V|E}, -#if FF_API_PRIVATE_OPT -{"mepc", "motion estimation bitrate penalty compensation (1.0 = 256)", OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, INT_MIN, INT_MAX, V|E}, -#endif {"skip_loop_filter", "skip loop filtering process for the selected frames", OFFSET(skip_loop_filter), AV_OPT_TYPE_INT, {.i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"}, {"skip_idct" , "skip IDCT/dequantization for the selected frames", OFFSET(skip_idct), AV_OPT_TYPE_INT, {.i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"}, {"skip_frame" , "skip decoding for the selected frames", OFFSET(skip_frame), AV_OPT_TYPE_INT, {.i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"}, @@ -306,28 +260,17 @@ static const AVOption avcodec_options[] = { {"nointra" , "discard all frames except I frames", 0, AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONINTRA}, INT_MIN, INT_MAX, V|D, "avdiscard"}, {"all" , "discard all frames", 0, AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_ALL }, INT_MIN, INT_MAX, V|D, "avdiscard"}, {"bidir_refine", "refine the two motion vectors used in bidirectional macroblocks", OFFSET(bidir_refine), AV_OPT_TYPE_INT, {.i64 = 1 }, 0, 4, V|E}, -#if FF_API_PRIVATE_OPT -{"brd_scale", "downscale frames for dynamic B-frame decision", OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, 10, V|E}, -#endif {"keyint_min", "minimum interval between IDR-frames", OFFSET(keyint_min), AV_OPT_TYPE_INT, {.i64 = 25 }, INT_MIN, INT_MAX, V|E}, {"refs", "reference frames to consider for motion compensation", OFFSET(refs), AV_OPT_TYPE_INT, {.i64 = 1 }, INT_MIN, INT_MAX, V|E}, -#if FF_API_PRIVATE_OPT -{"chromaoffset", "chroma QP offset from luma", OFFSET(chromaoffset), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, -#endif {"trellis", "rate-distortion optimal quantization", OFFSET(trellis), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|A|E}, {"mv0_threshold", NULL, OFFSET(mv0_threshold), AV_OPT_TYPE_INT, {.i64 = 256 }, 0, INT_MAX, V|E}, -#if FF_API_PRIVATE_OPT -{"b_sensitivity", "adjust sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, V|E}, -#endif {"compression_level", NULL, OFFSET(compression_level), AV_OPT_TYPE_INT, {.i64 = FF_COMPRESSION_DEFAULT }, INT_MIN, INT_MAX, V|A|E}, -#if FF_API_PRIVATE_OPT -{"min_prediction_order", NULL, OFFSET(min_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E}, -{"max_prediction_order", NULL, OFFSET(max_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E}, -{"timecode_frame_start", "GOP timecode frame start number, in non-drop-frame format", OFFSET(timecode_frame_start), AV_OPT_TYPE_INT64, {.i64 = -1 }, -1, INT64_MAX, V|E}, -#endif {"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX}, -{"channel_layout", NULL, OFFSET(channel_layout), AV_OPT_TYPE_UINT64, {.i64 = DEFAULT }, 0, UINT64_MAX, A|E|D, "channel_layout"}, -{"request_channel_layout", NULL, OFFSET(request_channel_layout), AV_OPT_TYPE_UINT64, {.i64 = DEFAULT }, 0, UINT64_MAX, A|D, "request_channel_layout"}, +{"ch_layout", NULL, OFFSET(ch_layout), AV_OPT_TYPE_CHLAYOUT, {.str = NULL }, 0, 0, A|E|D, "ch_layout"}, +#if FF_API_OLD_CHANNEL_LAYOUT +{"channel_layout", NULL, OFFSET(channel_layout), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64 = DEFAULT }, 0, UINT64_MAX, A|E|D, "channel_layout"}, +{"request_channel_layout", NULL, OFFSET(request_channel_layout), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64 = DEFAULT }, 0, UINT64_MAX, A|D, "request_channel_layout"}, +#endif {"rc_max_vbv_use", NULL, OFFSET(rc_max_available_vbv_use), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, 0.0, FLT_MAX, V|E}, {"rc_min_vbv_use", NULL, OFFSET(rc_min_vbv_overflow_use), AV_OPT_TYPE_FLOAT, {.dbl = 3 }, 0.0, FLT_MAX, V|E}, {"ticks_per_frame", NULL, OFFSET(ticks_per_frame), AV_OPT_TYPE_INT, {.i64 = 1 }, 1, INT_MAX, A|V|E|D}, @@ -432,20 +375,9 @@ static const AVOption avcodec_options[] = { {"auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_CHARENC_MODE_AUTOMATIC}, INT_MIN, INT_MAX, S|D, "sub_charenc_mode"}, {"pre_decoder", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_CHARENC_MODE_PRE_DECODER}, INT_MIN, INT_MAX, S|D, "sub_charenc_mode"}, {"ignore", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_CHARENC_MODE_IGNORE}, INT_MIN, INT_MAX, S|D, "sub_charenc_mode"}, -#if FF_API_ASS_TIMING -{"sub_text_format", "set decoded text subtitle format", OFFSET(sub_text_format), AV_OPT_TYPE_INT, {.i64 = FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS}, 0, 1, S|D, "sub_text_format"}, -#else -{"sub_text_format", "set decoded text subtitle format", OFFSET(sub_text_format), AV_OPT_TYPE_INT, {.i64 = FF_SUB_TEXT_FMT_ASS}, 0, 1, S|D, "sub_text_format"}, -#endif +#if FF_API_SUB_TEXT_FORMAT +{"sub_text_format", "Deprecated, does nothing", OFFSET(sub_text_format), AV_OPT_TYPE_INT, {.i64 = FF_SUB_TEXT_FMT_ASS}, 0, 1, S|D | AV_OPT_FLAG_DEPRECATED, "sub_text_format"}, {"ass", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_TEXT_FMT_ASS}, INT_MIN, INT_MAX, S|D, "sub_text_format"}, -#if FF_API_ASS_TIMING -{"ass_with_timings", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS}, INT_MIN, INT_MAX, S|D, "sub_text_format"}, -#endif -#if FF_API_OLD_ENCDEC -{"refcounted_frames", NULL, OFFSET(refcounted_frames), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, A|V|D }, -#endif -#if FF_API_SIDEDATA_ONLY_PKT -{"side_data_only_packets", NULL, OFFSET(side_data_only_packets), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, A|V|E }, #endif {"apply_cropping", NULL, OFFSET(apply_cropping), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, V | D }, {"skip_alpha", "Skip processing alpha", OFFSET(skip_alpha), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, V|D }, diff --git a/media/ffvpx/libavcodec/packet.h b/media/ffvpx/libavcodec/packet.h index ca18ae631f36..404d520071ee 100644 --- a/media/ffvpx/libavcodec/packet.h +++ b/media/ffvpx/libavcodec/packet.h @@ -28,8 +28,9 @@ #include "libavutil/buffer.h" #include "libavutil/dict.h" #include "libavutil/rational.h" +#include "libavutil/version.h" -#include "libavcodec/version.h" +#include "libavcodec/version_major.h" /** * @defgroup lavc_packet AVPacket @@ -290,6 +291,14 @@ enum AVPacketSideDataType { */ AV_PKT_DATA_S12M_TIMECODE, + /** + * HDR10+ dynamic metadata associated with a video frame. The metadata is in + * the form of the AVDynamicHDRPlus struct and contains + * information for color volume transform - application 4 of + * SMPTE 2094-40:2016 standard. + */ + AV_PKT_DATA_DYNAMIC_HDR10_PLUS, + /** * The number of side data types. * This is not part of the public API/ABI in the sense that it may @@ -305,11 +314,7 @@ enum AVPacketSideDataType { typedef struct AVPacketSideData { uint8_t *data; -#if FF_API_BUFFER_SIZE_T - int size; -#else size_t size; -#endif enum AVPacketSideDataType type; } AVPacketSideData; @@ -388,15 +393,29 @@ typedef struct AVPacket { int64_t pos; ///< byte position in stream, -1 if unknown -#if FF_API_CONVERGENCE_DURATION /** - * @deprecated Same as the duration field, but as int64_t. This was required - * for Matroska subtitles, whose duration values could overflow when the - * duration field was still an int. + * for some private data of the user */ - attribute_deprecated - int64_t convergence_duration; -#endif + void *opaque; + + /** + * AVBufferRef for free use by the API user. FFmpeg will never check the + * contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when + * the packet is unreferenced. av_packet_copy_props() calls create a new + * reference with av_buffer_ref() for the target packet's opaque_ref field. + * + * This is unrelated to the opaque field, although it serves a similar + * purpose. + */ + AVBufferRef *opaque_ref; + + /** + * Time base of the packet's timestamps. + * In the future, this field may be set on packets output by encoders or + * demuxers, but its value will be by default ignored on input to decoders + * or muxers. + */ + AVRational time_base; } AVPacket; #if FF_API_INIT_PACKET @@ -429,8 +448,13 @@ typedef struct AVPacketList { #define AV_PKT_FLAG_DISPOSABLE 0x0010 enum AVSideDataParamChangeFlags { +#if FF_API_OLD_CHANNEL_LAYOUT + /** + * @deprecated those are not used by any decoder + */ AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001, AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002, +#endif AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004, AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008, }; @@ -529,45 +553,6 @@ int av_grow_packet(AVPacket *pkt, int grow_by); */ int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size); -#if FF_API_AVPACKET_OLD_API -/** - * @warning This is a hack - the packet memory allocation stuff is broken. The - * packet is allocated if it was not really allocated. - * - * @deprecated Use av_packet_ref or av_packet_make_refcounted - */ -attribute_deprecated -int av_dup_packet(AVPacket *pkt); -/** - * Copy packet, including contents - * - * @return 0 on success, negative AVERROR on fail - * - * @deprecated Use av_packet_ref - */ -attribute_deprecated -int av_copy_packet(AVPacket *dst, const AVPacket *src); - -/** - * Copy packet side data - * - * @return 0 on success, negative AVERROR on fail - * - * @deprecated Use av_packet_copy_props - */ -attribute_deprecated -int av_copy_packet_side_data(AVPacket *dst, const AVPacket *src); - -/** - * Free a packet. - * - * @deprecated Use av_packet_unref - * - * @param pkt packet to free - */ -attribute_deprecated -void av_free_packet(AVPacket *pkt); -#endif /** * Allocate new information of a packet. * @@ -577,11 +562,7 @@ void av_free_packet(AVPacket *pkt); * @return pointer to fresh allocated data or NULL otherwise */ uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, -#if FF_API_BUFFER_SIZE_T - int size); -#else size_t size); -#endif /** * Wrap an existing array as a packet side data. @@ -608,11 +589,7 @@ int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, * @return 0 on success, < 0 on failure */ int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, -#if FF_API_BUFFER_SIZE_T - int size); -#else size_t size); -#endif /** * Get side information from packet. @@ -624,19 +601,7 @@ int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, * @return pointer to data if present or NULL otherwise */ uint8_t* av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, -#if FF_API_BUFFER_SIZE_T - int *size); -#else size_t *size); -#endif - -#if FF_API_MERGE_SD_API -attribute_deprecated -int av_packet_merge_side_data(AVPacket *pkt); - -attribute_deprecated -int av_packet_split_side_data(AVPacket *pkt); -#endif const char *av_packet_side_data_name(enum AVPacketSideDataType type); @@ -647,11 +612,7 @@ const char *av_packet_side_data_name(enum AVPacketSideDataType type); * @param size pointer to store the size of the returned data * @return pointer to data if successful, NULL otherwise */ -#if FF_API_BUFFER_SIZE_T -uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size); -#else uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size); -#endif /** * Unpack a dictionary from side_data. * @@ -660,12 +621,8 @@ uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size); * @param dict the metadata storage dictionary * @return 0 on success, < 0 on failure */ -#if FF_API_BUFFER_SIZE_T -int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict); -#else int av_packet_unpack_dictionary(const uint8_t *data, size_t size, AVDictionary **dict); -#endif /** * Convenience function to free all the side data stored. diff --git a/media/ffvpx/libavcodec/packet_internal.h b/media/ffvpx/libavcodec/packet_internal.h index b1d91f634725..92a0d4e6d538 100644 --- a/media/ffvpx/libavcodec/packet_internal.h +++ b/media/ffvpx/libavcodec/packet_internal.h @@ -23,16 +23,19 @@ #include "packet.h" -typedef struct PacketList { +typedef struct PacketListEntry { + struct PacketListEntry *next; AVPacket pkt; - struct PacketList *next; +} PacketListEntry; + +typedef struct PacketList { + PacketListEntry *head, *tail; } PacketList; /** * Append an AVPacket to the list. * - * @param head List head element - * @param tail List tail element + * @param list A PacketList * @param pkt The packet being appended. The data described in it will * be made reference counted if it isn't already. * @param copy A callback to copy the contents of the packet to the list. @@ -41,8 +44,7 @@ typedef struct PacketList { * @return 0 on success, negative AVERROR value on failure. On failure, the packet and the list are unchanged. */ -int avpriv_packet_list_put(PacketList **head, PacketList **tail, - AVPacket *pkt, +int avpriv_packet_list_put(PacketList *list, AVPacket *pkt, int (*copy)(AVPacket *dst, const AVPacket *src), int flags); @@ -52,22 +54,17 @@ int avpriv_packet_list_put(PacketList **head, PacketList **tail, * @note The pkt will be overwritten completely on success. The caller * owns the packet and must unref it by itself. * - * @param head List head element - * @param tail List tail element + * @param head A pointer to a PacketList struct * @param pkt Pointer to an AVPacket struct * @return 0 on success, and a packet is returned. AVERROR(EAGAIN) if * the list was empty. */ -int avpriv_packet_list_get(PacketList **head, PacketList **tail, - AVPacket *pkt); +int avpriv_packet_list_get(PacketList *list, AVPacket *pkt); /** * Wipe the list and unref all the packets in it. - * - * @param head List head element - * @param tail List tail element */ -void avpriv_packet_list_free(PacketList **head, PacketList **tail); +void avpriv_packet_list_free(PacketList *list); int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type); diff --git a/media/ffvpx/libavcodec/parser.c b/media/ffvpx/libavcodec/parser.c index 11c41d6a0a0e..49de7e6a57a8 100644 --- a/media/ffvpx/libavcodec/parser.c +++ b/media/ffvpx/libavcodec/parser.c @@ -25,10 +25,8 @@ #include #include "libavutil/avassert.h" -#include "libavutil/internal.h" #include "libavutil/mem.h" -#include "internal.h" #include "parser.h" AVCodecParserContext *av_parser_init(int codec_id) @@ -46,7 +44,9 @@ AVCodecParserContext *av_parser_init(int codec_id) parser->codec_ids[1] == codec_id || parser->codec_ids[2] == codec_id || parser->codec_ids[3] == codec_id || - parser->codec_ids[4] == codec_id) + parser->codec_ids[4] == codec_id || + parser->codec_ids[5] == codec_id || + parser->codec_ids[6] == codec_id) goto found; } return NULL; @@ -55,7 +55,7 @@ found: s = av_mallocz(sizeof(AVCodecParserContext)); if (!s) goto err_out; - s->parser = (AVCodecParser*)parser; + s->parser = parser; s->priv_data = av_mallocz(parser->priv_data_size); if (!s->priv_data) goto err_out; @@ -67,11 +67,6 @@ found: goto err_out; } s->key_frame = -1; -#if FF_API_CONVERGENCE_DURATION -FF_DISABLE_DEPRECATION_WARNINGS - s->convergence_duration = 0; -FF_ENABLE_DEPRECATION_WARNINGS -#endif s->dts_sync_point = INT_MIN; s->dts_ref_dts_delta = INT_MIN; s->pts_dts_delta = INT_MIN; @@ -132,7 +127,9 @@ int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx, avctx->codec_id == s->parser->codec_ids[1] || avctx->codec_id == s->parser->codec_ids[2] || avctx->codec_id == s->parser->codec_ids[3] || - avctx->codec_id == s->parser->codec_ids[4]); + avctx->codec_id == s->parser->codec_ids[4] || + avctx->codec_id == s->parser->codec_ids[5] || + avctx->codec_id == s->parser->codec_ids[6]); if (!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) { s->next_frame_offset = @@ -189,42 +186,6 @@ int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx, return index; } -#if FF_API_PARSER_CHANGE -int av_parser_change(AVCodecParserContext *s, AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, int keyframe) -{ - if (s && s->parser->split) { - if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER || - avctx->flags2 & AV_CODEC_FLAG2_LOCAL_HEADER) { - int i = s->parser->split(avctx, buf, buf_size); - buf += i; - buf_size -= i; - } - } - - /* cast to avoid warning about discarding qualifiers */ - *poutbuf = (uint8_t *) buf; - *poutbuf_size = buf_size; - if (avctx->extradata) { - if (keyframe && (avctx->flags2 & AV_CODEC_FLAG2_LOCAL_HEADER)) { - int size = buf_size + avctx->extradata_size; - - *poutbuf_size = size; - *poutbuf = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE); - if (!*poutbuf) - return AVERROR(ENOMEM); - - memcpy(*poutbuf, avctx->extradata, avctx->extradata_size); - memcpy(*poutbuf + avctx->extradata_size, buf, - buf_size + AV_INPUT_BUFFER_PADDING_SIZE); - return 1; - } - } - - return 0; -} -#endif void av_parser_close(AVCodecParserContext *s) { if (s) { @@ -326,17 +287,3 @@ void ff_parse_close(AVCodecParserContext *s) av_freep(&pc->buffer); } - -int ff_mpeg4video_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size) -{ - uint32_t state = -1; - const uint8_t *ptr = buf, *end = buf + buf_size; - - while (ptr < end) { - ptr = avpriv_find_start_code(ptr, end, &state); - if (state == 0x1B3 || state == 0x1B6) - return ptr - 4 - buf; - } - - return 0; -} diff --git a/media/ffvpx/libavcodec/parser_list.c b/media/ffvpx/libavcodec/parser_list.c index b60c60bce994..7974c9bc10b8 100644 --- a/media/ffvpx/libavcodec/parser_list.c +++ b/media/ffvpx/libavcodec/parser_list.c @@ -1,8 +1,4 @@ static const AVCodecParser * const parser_list[] = { -#if CONFIG_VP8_PARSER &ff_vp8_parser, -#endif -#if CONFIG_VP9_PARSER &ff_vp9_parser, -#endif NULL }; diff --git a/media/ffvpx/libavcodec/parsers.c b/media/ffvpx/libavcodec/parsers.c index 3d944f5222ec..b59388835dfd 100644 --- a/media/ffvpx/libavcodec/parsers.c +++ b/media/ffvpx/libavcodec/parsers.c @@ -18,98 +18,65 @@ #include -#include "libavutil/thread.h" - #include "avcodec.h" -#include "version.h" -extern AVCodecParser ff_aac_parser; -extern AVCodecParser ff_aac_latm_parser; -extern AVCodecParser ff_ac3_parser; -extern AVCodecParser ff_adx_parser; -extern AVCodecParser ff_av1_parser; -extern AVCodecParser ff_avs2_parser; -extern AVCodecParser ff_avs3_parser; -extern AVCodecParser ff_bmp_parser; -extern AVCodecParser ff_cavsvideo_parser; -extern AVCodecParser ff_cook_parser; -extern AVCodecParser ff_cri_parser; -extern AVCodecParser ff_dca_parser; -extern AVCodecParser ff_dirac_parser; -extern AVCodecParser ff_dnxhd_parser; -extern AVCodecParser ff_dolby_e_parser; -extern AVCodecParser ff_dpx_parser; -extern AVCodecParser ff_dvaudio_parser; -extern AVCodecParser ff_dvbsub_parser; -extern AVCodecParser ff_dvdsub_parser; -extern AVCodecParser ff_dvd_nav_parser; -extern AVCodecParser ff_flac_parser; -extern AVCodecParser ff_g723_1_parser; -extern AVCodecParser ff_g729_parser; -extern AVCodecParser ff_gif_parser; -extern AVCodecParser ff_gsm_parser; -extern AVCodecParser ff_h261_parser; -extern AVCodecParser ff_h263_parser; -extern AVCodecParser ff_h264_parser; -extern AVCodecParser ff_hevc_parser; -extern AVCodecParser ff_ipu_parser; -extern AVCodecParser ff_jpeg2000_parser; -extern AVCodecParser ff_mjpeg_parser; -extern AVCodecParser ff_mlp_parser; -extern AVCodecParser ff_mpeg4video_parser; -extern AVCodecParser ff_mpegaudio_parser; -extern AVCodecParser ff_mpegvideo_parser; -extern AVCodecParser ff_opus_parser; -extern AVCodecParser ff_png_parser; -extern AVCodecParser ff_pnm_parser; -extern AVCodecParser ff_rv30_parser; -extern AVCodecParser ff_rv40_parser; -extern AVCodecParser ff_sbc_parser; -extern AVCodecParser ff_sipr_parser; -extern AVCodecParser ff_tak_parser; -extern AVCodecParser ff_vc1_parser; -extern AVCodecParser ff_vorbis_parser; -extern AVCodecParser ff_vp3_parser; -extern AVCodecParser ff_vp8_parser; -extern AVCodecParser ff_vp9_parser; -extern AVCodecParser ff_webp_parser; -extern AVCodecParser ff_xbm_parser; -extern AVCodecParser ff_xma_parser; +extern const AVCodecParser ff_aac_parser; +extern const AVCodecParser ff_aac_latm_parser; +extern const AVCodecParser ff_ac3_parser; +extern const AVCodecParser ff_adx_parser; +extern const AVCodecParser ff_amr_parser; +extern const AVCodecParser ff_av1_parser; +extern const AVCodecParser ff_avs2_parser; +extern const AVCodecParser ff_avs3_parser; +extern const AVCodecParser ff_bmp_parser; +extern const AVCodecParser ff_cavsvideo_parser; +extern const AVCodecParser ff_cook_parser; +extern const AVCodecParser ff_cri_parser; +extern const AVCodecParser ff_dca_parser; +extern const AVCodecParser ff_dirac_parser; +extern const AVCodecParser ff_dnxhd_parser; +extern const AVCodecParser ff_dolby_e_parser; +extern const AVCodecParser ff_dpx_parser; +extern const AVCodecParser ff_dvaudio_parser; +extern const AVCodecParser ff_dvbsub_parser; +extern const AVCodecParser ff_dvdsub_parser; +extern const AVCodecParser ff_dvd_nav_parser; +extern const AVCodecParser ff_flac_parser; +extern const AVCodecParser ff_g723_1_parser; +extern const AVCodecParser ff_g729_parser; +extern const AVCodecParser ff_gif_parser; +extern const AVCodecParser ff_gsm_parser; +extern const AVCodecParser ff_h261_parser; +extern const AVCodecParser ff_h263_parser; +extern const AVCodecParser ff_h264_parser; +extern const AVCodecParser ff_hevc_parser; +extern const AVCodecParser ff_ipu_parser; +extern const AVCodecParser ff_jpeg2000_parser; +extern const AVCodecParser ff_mjpeg_parser; +extern const AVCodecParser ff_mlp_parser; +extern const AVCodecParser ff_mpeg4video_parser; +extern const AVCodecParser ff_mpegaudio_parser; +extern const AVCodecParser ff_mpegvideo_parser; +extern const AVCodecParser ff_opus_parser; +extern const AVCodecParser ff_png_parser; +extern const AVCodecParser ff_pnm_parser; +extern const AVCodecParser ff_qoi_parser; +extern const AVCodecParser ff_rv30_parser; +extern const AVCodecParser ff_rv40_parser; +extern const AVCodecParser ff_sbc_parser; +extern const AVCodecParser ff_sipr_parser; +extern const AVCodecParser ff_tak_parser; +extern const AVCodecParser ff_vc1_parser; +extern const AVCodecParser ff_vorbis_parser; +extern const AVCodecParser ff_vp3_parser; +extern const AVCodecParser ff_vp8_parser; +extern const AVCodecParser ff_vp9_parser; +extern const AVCodecParser ff_webp_parser; +extern const AVCodecParser ff_xbm_parser; +extern const AVCodecParser ff_xma_parser; #include "libavcodec/parser_list.c" -#if FF_API_NEXT -FF_DISABLE_DEPRECATION_WARNINGS -static AVOnce av_parser_next_init = AV_ONCE_INIT; - -static void av_parser_init_next(void) -{ - AVCodecParser *prev = NULL, *p; - int i = 0; - while ((p = (AVCodecParser*)parser_list[i++])) { - if (prev) - prev->next = p; - prev = p; - } -} - -AVCodecParser *av_parser_next(const AVCodecParser *p) -{ - ff_thread_once(&av_parser_next_init, av_parser_init_next); - - if (p) - return p->next; - else - return (AVCodecParser*)parser_list[0]; -} - -void av_register_codec_parser(AVCodecParser *parser) -{ - ff_thread_once(&av_parser_next_init, av_parser_init_next); -} -FF_ENABLE_DEPRECATION_WARNINGS -#endif - const AVCodecParser *av_parser_iterate(void **opaque) { uintptr_t i = (uintptr_t)*opaque; diff --git a/media/ffvpx/libavcodec/pthread.c b/media/ffvpx/libavcodec/pthread.c index 14b7cca4fea8..60ba87dac484 100644 --- a/media/ffvpx/libavcodec/pthread.c +++ b/media/ffvpx/libavcodec/pthread.c @@ -29,8 +29,10 @@ * @see doc/multithreading.txt */ +#include "libavutil/thread.h" + #include "avcodec.h" -#include "internal.h" +#include "codec_internal.h" #include "pthread_internal.h" #include "thread.h" @@ -46,7 +48,9 @@ static void validate_thread_parameters(AVCodecContext *avctx) { int frame_threading_supported = (avctx->codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) +#if FF_API_FLAG_TRUNCATED && !(avctx->flags & AV_CODEC_FLAG_TRUNCATED) +#endif && !(avctx->flags & AV_CODEC_FLAG_LOW_DELAY) && !(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS); if (avctx->thread_count == 1) { @@ -56,7 +60,7 @@ static void validate_thread_parameters(AVCodecContext *avctx) } else if (avctx->codec->capabilities & AV_CODEC_CAP_SLICE_THREADS && avctx->thread_type & FF_THREAD_SLICE) { avctx->active_thread_type = FF_THREAD_SLICE; - } else if (!(avctx->codec->caps_internal & FF_CODEC_CAP_AUTO_THREADS)) { + } else if (!(ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_AUTO_THREADS)) { avctx->thread_count = 1; avctx->active_thread_type = 0; } @@ -86,3 +90,39 @@ void ff_thread_free(AVCodecContext *avctx) else ff_slice_thread_free(avctx); } + +av_cold void ff_pthread_free(void *obj, const unsigned offsets[]) +{ + unsigned cnt = *(unsigned*)((char*)obj + offsets[0]); + const unsigned *cur_offset = offsets; + + *(unsigned*)((char*)obj + offsets[0]) = 0; + + for (; *(++cur_offset) != THREAD_SENTINEL && cnt; cnt--) + pthread_mutex_destroy((pthread_mutex_t*)((char*)obj + *cur_offset)); + for (; *(++cur_offset) != THREAD_SENTINEL && cnt; cnt--) + pthread_cond_destroy ((pthread_cond_t *)((char*)obj + *cur_offset)); +} + +av_cold int ff_pthread_init(void *obj, const unsigned offsets[]) +{ + const unsigned *cur_offset = offsets; + unsigned cnt = 0; + int err; + +#define PTHREAD_INIT_LOOP(type) \ + for (; *(++cur_offset) != THREAD_SENTINEL; cnt++) { \ + pthread_ ## type ## _t *dst = (void*)((char*)obj + *cur_offset); \ + err = pthread_ ## type ## _init(dst, NULL); \ + if (err) { \ + err = AVERROR(err); \ + goto fail; \ + } \ + } + PTHREAD_INIT_LOOP(mutex) + PTHREAD_INIT_LOOP(cond) + +fail: + *(unsigned*)((char*)obj + offsets[0]) = cnt; + return err; +} diff --git a/media/ffvpx/libavcodec/pthread_frame.c b/media/ffvpx/libavcodec/pthread_frame.c index 9176027f15f9..8faea75a4982 100644 --- a/media/ffvpx/libavcodec/pthread_frame.c +++ b/media/ffvpx/libavcodec/pthread_frame.c @@ -28,11 +28,13 @@ #include #include "avcodec.h" +#include "codec_internal.h" #include "hwconfig.h" #include "internal.h" #include "pthread_internal.h" #include "thread.h" -#include "version.h" +#include "threadframe.h" +#include "version_major.h" #include "libavutil/avassert.h" #include "libavutil/buffer.h" @@ -66,7 +68,7 @@ enum { enum { UNINITIALIZED, ///< Thread has not been created, AVCodec->close mustn't be called - NEEDS_CLOSE, ///< AVCodec->close needs to be called + NEEDS_CLOSE, ///< FFCodec->close needs to be called INITIALIZED, ///< Thread has been properly set up }; @@ -181,7 +183,7 @@ static attribute_align_arg void *frame_worker_thread(void *arg) { PerThreadContext *p = arg; AVCodecContext *avctx = p->avctx; - const AVCodec *codec = avctx->codec; + const FFCodec *codec = ffcodec(avctx->codec); pthread_mutex_lock(&p->mutex); while (1) { @@ -216,14 +218,10 @@ FF_ENABLE_DEPRECATION_WARNINGS av_frame_unref(p->frame); p->got_frame = 0; - p->result = codec->decode(avctx, p->frame, &p->got_frame, p->avpkt); + p->result = codec->cb.decode(avctx, p->frame, &p->got_frame, p->avpkt); - if ((p->result < 0 || !p->got_frame) && p->frame->buf[0]) { - if (avctx->codec->caps_internal & FF_CODEC_CAP_ALLOCATE_PROGRESS) - av_log(avctx, AV_LOG_ERROR, "A frame threaded decoder did not " - "free the frame on failure. This is a bug, please report it.\n"); - av_frame_unref(p->frame); - } + if ((p->result < 0 || !p->got_frame) && p->frame->buf[0]) + ff_thread_release_buffer(avctx, p->frame); if (atomic_load(&p->state) == STATE_SETTING_UP) ff_thread_finish_setup(avctx); @@ -262,9 +260,10 @@ FF_ENABLE_DEPRECATION_WARNINGS */ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, int for_user) { + const FFCodec *const codec = ffcodec(dst->codec); int err = 0; - if (dst != src && (for_user || src->codec->update_thread_context)) { + if (dst != src && (for_user || codec->update_thread_context)) { dst->time_base = src->time_base; dst->framerate = src->framerate; dst->width = src->width; @@ -277,6 +276,7 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, dst->has_b_frames = src->has_b_frames; dst->idct_algo = src->idct_algo; + dst->properties = src->properties; dst->bits_per_coded_sample = src->bits_per_coded_sample; dst->sample_aspect_ratio = src->sample_aspect_ratio; @@ -296,10 +296,18 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, dst->hwaccel = src->hwaccel; dst->hwaccel_context = src->hwaccel_context; - dst->channels = src->channels; dst->sample_rate = src->sample_rate; dst->sample_fmt = src->sample_fmt; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + dst->channels = src->channels; dst->channel_layout = src->channel_layout; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + err = av_channel_layout_copy(&dst->ch_layout, &src->ch_layout); + if (err < 0) + return err; + dst->internal->hwaccel_priv_data = src->internal->hwaccel_priv_data; if (!!dst->hw_frames_ctx != !!src->hw_frames_ctx || @@ -321,14 +329,11 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, } if (for_user) { -#if FF_API_CODED_FRAME -FF_DISABLE_DEPRECATION_WARNINGS - dst->coded_frame = src->coded_frame; -FF_ENABLE_DEPRECATION_WARNINGS -#endif + if (codec->update_thread_context_for_user) + err = codec->update_thread_context_for_user(dst, src); } else { - if (dst->codec->update_thread_context) - err = dst->codec->update_thread_context(dst, src); + if (codec->update_thread_context) + err = codec->update_thread_context(dst, src); } return err; @@ -682,63 +687,22 @@ static void park_frame_worker_threads(FrameThreadContext *fctx, int thread_count async_lock(fctx); } -#define SENTINEL 0 // This forbids putting a mutex/condition variable at the front. -#define OFFSET_ARRAY(...) __VA_ARGS__, SENTINEL -#define DEFINE_OFFSET_ARRAY(type, name, mutexes, conds) \ -static const unsigned name ## _offsets[] = { offsetof(type, pthread_init_cnt),\ - OFFSET_ARRAY mutexes, \ - OFFSET_ARRAY conds } - #define OFF(member) offsetof(FrameThreadContext, member) -DEFINE_OFFSET_ARRAY(FrameThreadContext, thread_ctx, +DEFINE_OFFSET_ARRAY(FrameThreadContext, thread_ctx, pthread_init_cnt, (OFF(buffer_mutex), OFF(hwaccel_mutex), OFF(async_mutex)), (OFF(async_cond))); #undef OFF #define OFF(member) offsetof(PerThreadContext, member) -DEFINE_OFFSET_ARRAY(PerThreadContext, per_thread, +DEFINE_OFFSET_ARRAY(PerThreadContext, per_thread, pthread_init_cnt, (OFF(progress_mutex), OFF(mutex)), (OFF(input_cond), OFF(progress_cond), OFF(output_cond))); #undef OFF -static av_cold void free_pthread(void *obj, const unsigned offsets[]) -{ - unsigned cnt = *(unsigned*)((char*)obj + offsets[0]); - const unsigned *cur_offset = offsets; - - for (; *(++cur_offset) != SENTINEL && cnt; cnt--) - pthread_mutex_destroy((pthread_mutex_t*)((char*)obj + *cur_offset)); - for (; *(++cur_offset) != SENTINEL && cnt; cnt--) - pthread_cond_destroy ((pthread_cond_t *)((char*)obj + *cur_offset)); -} - -static av_cold int init_pthread(void *obj, const unsigned offsets[]) -{ - const unsigned *cur_offset = offsets; - unsigned cnt = 0; - int err; - -#define PTHREAD_INIT_LOOP(type) \ - for (; *(++cur_offset) != SENTINEL; cnt++) { \ - pthread_ ## type ## _t *dst = (void*)((char*)obj + *cur_offset); \ - err = pthread_ ## type ## _init(dst, NULL); \ - if (err) { \ - err = AVERROR(err); \ - goto fail; \ - } \ - } - PTHREAD_INIT_LOOP(mutex) - PTHREAD_INIT_LOOP(cond) - -fail: - *(unsigned*)((char*)obj + offsets[0]) = cnt; - return err; -} - void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) { FrameThreadContext *fctx = avctx->internal->thread_ctx; - const AVCodec *codec = avctx->codec; + const FFCodec *codec = ffcodec(avctx->codec); int i; park_frame_worker_threads(fctx, thread_count); @@ -750,13 +714,6 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) } } - if (fctx->prev_thread && fctx->prev_thread != fctx->threads) - if (update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0) < 0) { - av_log(avctx, AV_LOG_ERROR, "Final thread update failed\n"); - fctx->prev_thread->avctx->internal->is_copy = fctx->threads->avctx->internal->is_copy; - fctx->threads->avctx->internal->is_copy = 1; - } - for (i = 0; i < thread_count; i++) { PerThreadContext *p = &fctx->threads[i]; AVCodecContext *ctx = p->avctx; @@ -780,7 +737,7 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) av_freep(&p->released_buffers); #endif if (ctx->priv_data) { - if (codec->priv_class) + if (codec->p.priv_class) av_opt_free(ctx->priv_data); av_freep(&ctx->priv_data); } @@ -794,32 +751,28 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) av_frame_free(&p->frame); - free_pthread(p, per_thread_offsets); + ff_pthread_free(p, per_thread_offsets); av_packet_free(&p->avpkt); av_freep(&p->avctx); } av_freep(&fctx->threads); - free_pthread(fctx, thread_ctx_offsets); + ff_pthread_free(fctx, thread_ctx_offsets); av_freep(&avctx->internal->thread_ctx); - - if (avctx->priv_data && avctx->codec && avctx->codec->priv_class) - av_opt_free(avctx->priv_data); - avctx->codec = NULL; } static av_cold int init_thread(PerThreadContext *p, int *threads_to_free, FrameThreadContext *fctx, AVCodecContext *avctx, - AVCodecContext *src, const AVCodec *codec, int first) + const FFCodec *codec, int first) { AVCodecContext *copy; int err; atomic_init(&p->state, STATE_INPUT_READY); - copy = av_memdup(src, sizeof(*src)); + copy = av_memdup(avctx, sizeof(*avctx)); if (!copy) return AVERROR(ENOMEM); copy->priv_data = NULL; @@ -831,7 +784,7 @@ static av_cold int init_thread(PerThreadContext *p, int *threads_to_free, p->parent = fctx; p->avctx = copy; - copy->internal = av_memdup(src->internal, sizeof(*src->internal)); + copy->internal = av_mallocz(sizeof(*copy->internal)); if (!copy->internal) return AVERROR(ENOMEM); copy->internal->thread_ctx = p; @@ -843,15 +796,15 @@ static av_cold int init_thread(PerThreadContext *p, int *threads_to_free, if (!copy->priv_data) return AVERROR(ENOMEM); - if (codec->priv_class) { - *(const AVClass **)copy->priv_data = codec->priv_class; - err = av_opt_copy(copy->priv_data, src->priv_data); + if (codec->p.priv_class) { + *(const AVClass **)copy->priv_data = codec->p.priv_class; + err = av_opt_copy(copy->priv_data, avctx->priv_data); if (err < 0) return err; } } - err = init_pthread(p, per_thread_offsets); + err = ff_pthread_init(p, per_thread_offsets); if (err < 0) return err; @@ -889,8 +842,7 @@ static av_cold int init_thread(PerThreadContext *p, int *threads_to_free, int ff_frame_thread_init(AVCodecContext *avctx) { int thread_count = avctx->thread_count; - const AVCodec *codec = avctx->codec; - AVCodecContext *src = avctx; + const FFCodec *codec = ffcodec(avctx->codec); FrameThreadContext *fctx; int err, i = 0; @@ -912,9 +864,9 @@ int ff_frame_thread_init(AVCodecContext *avctx) if (!fctx) return AVERROR(ENOMEM); - err = init_pthread(fctx, thread_ctx_offsets); + err = ff_pthread_init(fctx, thread_ctx_offsets); if (err < 0) { - free_pthread(fctx, thread_ctx_offsets); + ff_pthread_free(fctx, thread_ctx_offsets); av_freep(&avctx->internal->thread_ctx); return err; } @@ -922,10 +874,10 @@ int ff_frame_thread_init(AVCodecContext *avctx) fctx->async_lock = 1; fctx->delaying = 1; - if (codec->type == AVMEDIA_TYPE_VIDEO) - avctx->delay = src->thread_count - 1; + if (codec->p.type == AVMEDIA_TYPE_VIDEO) + avctx->delay = avctx->thread_count - 1; - fctx->threads = av_mallocz_array(thread_count, sizeof(PerThreadContext)); + fctx->threads = av_calloc(thread_count, sizeof(*fctx->threads)); if (!fctx->threads) { err = AVERROR(ENOMEM); goto error; @@ -935,7 +887,7 @@ int ff_frame_thread_init(AVCodecContext *avctx) PerThreadContext *p = &fctx->threads[i]; int first = !i; - err = init_thread(p, &i, fctx, avctx, src, codec, first); + err = init_thread(p, &i, fctx, avctx, codec, first); if (err < 0) goto error; } @@ -974,8 +926,8 @@ void ff_thread_flush(AVCodecContext *avctx) release_delayed_buffers(p); #endif - if (avctx->codec->flush) - avctx->codec->flush(p->avctx); + if (ffcodec(avctx->codec)->flush) + ffcodec(avctx->codec)->flush(p->avctx); } } @@ -984,7 +936,7 @@ int ff_thread_can_start_frame(AVCodecContext *avctx) PerThreadContext *p = avctx->internal->thread_ctx; FF_DISABLE_DEPRECATION_WARNINGS if ((avctx->active_thread_type&FF_THREAD_FRAME) && atomic_load(&p->state) != STATE_SETTING_UP && - (avctx->codec->update_thread_context + (ffcodec(avctx->codec)->update_thread_context #if FF_API_THREAD_SAFE_CALLBACKS || !THREAD_SAFE_CALLBACKS(avctx) #endif @@ -995,19 +947,18 @@ FF_ENABLE_DEPRECATION_WARNINGS return 1; } -static int thread_get_buffer_internal(AVCodecContext *avctx, ThreadFrame *f, int flags) +static int thread_get_buffer_internal(AVCodecContext *avctx, AVFrame *f, int flags) { - PerThreadContext *p = avctx->internal->thread_ctx; + PerThreadContext *p; int err; - f->owner[0] = f->owner[1] = avctx; - if (!(avctx->active_thread_type & FF_THREAD_FRAME)) - return ff_get_buffer(avctx, f->f, flags); + return ff_get_buffer(avctx, f, flags); + p = avctx->internal->thread_ctx; FF_DISABLE_DEPRECATION_WARNINGS if (atomic_load(&p->state) != STATE_SETTING_UP && - (avctx->codec->update_thread_context + (ffcodec(avctx->codec)->update_thread_context #if FF_API_THREAD_SAFE_CALLBACKS || !THREAD_SAFE_CALLBACKS(avctx) #endif @@ -1017,28 +968,16 @@ FF_ENABLE_DEPRECATION_WARNINGS return -1; } - if (avctx->codec->caps_internal & FF_CODEC_CAP_ALLOCATE_PROGRESS) { - atomic_int *progress; - f->progress = av_buffer_alloc(2 * sizeof(*progress)); - if (!f->progress) { - return AVERROR(ENOMEM); - } - progress = (atomic_int*)f->progress->data; - - atomic_init(&progress[0], -1); - atomic_init(&progress[1], -1); - } - pthread_mutex_lock(&p->parent->buffer_mutex); #if !FF_API_THREAD_SAFE_CALLBACKS err = ff_get_buffer(avctx, f->f, flags); #else FF_DISABLE_DEPRECATION_WARNINGS if (THREAD_SAFE_CALLBACKS(avctx)) { - err = ff_get_buffer(avctx, f->f, flags); + err = ff_get_buffer(avctx, f, flags); } else { pthread_mutex_lock(&p->progress_mutex); - p->requested_frame = f->f; + p->requested_frame = f; p->requested_flags = flags; atomic_store_explicit(&p->state, STATE_GET_BUFFER, memory_order_release); pthread_cond_broadcast(&p->progress_cond); @@ -1051,12 +990,10 @@ FF_DISABLE_DEPRECATION_WARNINGS pthread_mutex_unlock(&p->progress_mutex); } - if (!THREAD_SAFE_CALLBACKS(avctx) && !avctx->codec->update_thread_context) + if (!THREAD_SAFE_CALLBACKS(avctx) && !ffcodec(avctx->codec)->update_thread_context) ff_thread_finish_setup(avctx); FF_ENABLE_DEPRECATION_WARNINGS #endif - if (err) - av_buffer_unref(&f->progress); pthread_mutex_unlock(&p->parent->buffer_mutex); @@ -1068,10 +1005,12 @@ FF_DISABLE_DEPRECATION_WARNINGS enum AVPixelFormat ff_thread_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt) { enum AVPixelFormat res; - PerThreadContext *p = avctx->internal->thread_ctx; + PerThreadContext *p; if (!(avctx->active_thread_type & FF_THREAD_FRAME) || avctx->thread_safe_callbacks || avctx->get_format == avcodec_default_get_format) return ff_get_format(avctx, fmt); + + p = avctx->internal->thread_ctx; if (atomic_load(&p->state) != STATE_SETTING_UP) { av_log(avctx, AV_LOG_ERROR, "get_format() cannot be called after ff_thread_finish_setup()\n"); return -1; @@ -1093,7 +1032,7 @@ enum AVPixelFormat ff_thread_get_format(AVCodecContext *avctx, const enum AVPixe FF_ENABLE_DEPRECATION_WARNINGS #endif -int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags) +int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags) { int ret = thread_get_buffer_internal(avctx, f, flags); if (ret < 0) @@ -1101,11 +1040,42 @@ int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags) return ret; } -void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f) +int ff_thread_get_ext_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags) +{ + int ret; + + f->owner[0] = f->owner[1] = avctx; + /* Hint: It is possible for this function to be called with codecs + * that don't support frame threading at all, namely in case + * a frame-threaded decoder shares code with codecs that are not. + * This currently affects non-MPEG-4 mpegvideo codecs and and VP7. + * The following check will always be true for them. */ + if (!(avctx->active_thread_type & FF_THREAD_FRAME)) + return ff_get_buffer(avctx, f->f, flags); + + if (ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_ALLOCATE_PROGRESS) { + atomic_int *progress; + f->progress = av_buffer_alloc(2 * sizeof(*progress)); + if (!f->progress) { + return AVERROR(ENOMEM); + } + progress = (atomic_int*)f->progress->data; + + atomic_init(&progress[0], -1); + atomic_init(&progress[1], -1); + } + + ret = ff_thread_get_buffer(avctx, f->f, flags); + if (ret) + av_buffer_unref(&f->progress); + return ret; +} + +void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f) { #if FF_API_THREAD_SAFE_CALLBACKS FF_DISABLE_DEPRECATION_WARNINGS - PerThreadContext *p = avctx->internal->thread_ctx; + PerThreadContext *p; FrameThreadContext *fctx; AVFrame *dst; int ret = 0; @@ -1114,24 +1084,22 @@ FF_DISABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS #endif - if (!f->f) + if (!f) return; if (avctx->debug & FF_DEBUG_BUFFERS) av_log(avctx, AV_LOG_DEBUG, "thread_release_buffer called on pic %p\n", f); - av_buffer_unref(&f->progress); - f->owner[0] = f->owner[1] = NULL; - #if !FF_API_THREAD_SAFE_CALLBACKS av_frame_unref(f->f); #else // when the frame buffers are not allocated, just reset it to clean state - if (can_direct_free || !f->f->buf[0]) { - av_frame_unref(f->f); + if (can_direct_free || !f->buf[0]) { + av_frame_unref(f); return; } + p = avctx->internal->thread_ctx; fctx = p->parent; pthread_mutex_lock(&fctx->buffer_mutex); @@ -1151,7 +1119,7 @@ FF_ENABLE_DEPRECATION_WARNINGS } dst = p->released_buffers[p->num_released_buffers]; - av_frame_move_ref(dst, f->f); + av_frame_move_ref(dst, f); p->num_released_buffers++; @@ -1162,10 +1130,17 @@ fail: // this leaks, but it is better than crashing if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Could not queue a frame for freeing, this will leak\n"); - memset(f->f->buf, 0, sizeof(f->f->buf)); - if (f->f->extended_buf) - memset(f->f->extended_buf, 0, f->f->nb_extended_buf * sizeof(*f->f->extended_buf)); - av_frame_unref(f->f); + memset(f->buf, 0, sizeof(f->buf)); + if (f->extended_buf) + memset(f->extended_buf, 0, f->nb_extended_buf * sizeof(*f->extended_buf)); + av_frame_unref(f); } #endif } + +void ff_thread_release_ext_buffer(AVCodecContext *avctx, ThreadFrame *f) +{ + av_buffer_unref(&f->progress); + f->owner[0] = f->owner[1] = NULL; + ff_thread_release_buffer(avctx, f->f); +} diff --git a/media/ffvpx/libavcodec/pthread_internal.h b/media/ffvpx/libavcodec/pthread_internal.h index d2115cbbafb1..d0b6a7a673b6 100644 --- a/media/ffvpx/libavcodec/pthread_internal.h +++ b/media/ffvpx/libavcodec/pthread_internal.h @@ -31,4 +31,36 @@ void ff_slice_thread_free(AVCodecContext *avctx); int ff_frame_thread_init(AVCodecContext *avctx); void ff_frame_thread_free(AVCodecContext *avctx, int thread_count); +#define THREAD_SENTINEL 0 // This forbids putting a mutex/condition variable at the front. +/** + * Initialize/destroy a list of mutexes/conditions contained in a structure. + * The positions of these mutexes/conditions in the structure are given by + * their offsets. Because it is undefined behaviour to destroy + * an uninitialized mutex/condition, ff_pthread_init() stores the number + * of successfully initialized mutexes and conditions in the object itself + * and ff_pthread_free() uses this number to destroy exactly the mutexes and + * condition variables that have been successfully initialized. + * + * @param obj The object containing the mutexes/conditions. + * @param[in] offsets An array of offsets. Its first member gives the offset + * of the variable that contains the count of successfully + * initialized mutexes/condition variables; said variable + * must be an unsigned int. Two arrays of offsets, each + * delimited by a THREAD_SENTINEL follow. The first + * contains the offsets of all the mutexes, the second + * contains the offsets of all the condition variables. + */ +int ff_pthread_init(void *obj, const unsigned offsets[]); +void ff_pthread_free(void *obj, const unsigned offsets[]); + +/** + * Macros to help creating the above lists. mutexes and conds need + * to be parentheses-enclosed lists of offsets in the containing structure. + */ +#define OFFSET_ARRAY(...) __VA_ARGS__, THREAD_SENTINEL +#define DEFINE_OFFSET_ARRAY(type, name, cnt_variable, mutexes, conds) \ +static const unsigned name ## _offsets[] = { offsetof(type, cnt_variable), \ + OFFSET_ARRAY mutexes, \ + OFFSET_ARRAY conds } + #endif // AVCODEC_PTHREAD_INTERNAL_H diff --git a/media/ffvpx/libavcodec/pthread_slice.c b/media/ffvpx/libavcodec/pthread_slice.c index 80c4579fc02e..0ad1965a220c 100644 --- a/media/ffvpx/libavcodec/pthread_slice.c +++ b/media/ffvpx/libavcodec/pthread_slice.c @@ -25,6 +25,7 @@ #include "config.h" #include "avcodec.h" +#include "codec_internal.h" #include "internal.h" #include "pthread_internal.h" #include "thread.h" @@ -155,7 +156,7 @@ int ff_slice_thread_init(AVCodecContext *avctx) } avctx->internal->thread_ctx = c = av_mallocz(sizeof(*c)); - mainfunc = avctx->codec->caps_internal & FF_CODEC_CAP_SLICE_THREAD_HAS_MF ? &main_function : NULL; + mainfunc = ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_SLICE_THREAD_HAS_MF ? &main_function : NULL; if (!c || (thread_count = avpriv_slicethread_create(&c->thread, avctx, worker_func, mainfunc, thread_count)) <= 1) { if (c) avpriv_slicethread_free(&c->thread); @@ -211,7 +212,7 @@ int ff_alloc_entries(AVCodecContext *avctx, int count) } p->thread_count = avctx->thread_count; - p->entries = av_mallocz_array(count, sizeof(int)); + p->entries = av_calloc(count, sizeof(*p->entries)); if (!p->progress_mutex) { p->progress_mutex = av_malloc_array(p->thread_count, sizeof(pthread_mutex_t)); diff --git a/media/ffvpx/libavcodec/put_bits.h b/media/ffvpx/libavcodec/put_bits.h index f07944a8fbee..4b4f977ad5b1 100644 --- a/media/ffvpx/libavcodec/put_bits.h +++ b/media/ffvpx/libavcodec/put_bits.h @@ -32,12 +32,18 @@ #include "config.h" #include "libavutil/intreadwrite.h" #include "libavutil/avassert.h" +#include "libavutil/common.h" -#include "version.h" - +#if ARCH_X86_64 +// TODO: Benchmark and optionally enable on other 64-bit architectures. +typedef uint64_t BitBuf; +#define AV_WBBUF AV_WB64 +#define AV_WLBUF AV_WL64 +#else typedef uint32_t BitBuf; #define AV_WBBUF AV_WB32 #define AV_WLBUF AV_WL32 +#endif static const int BUF_BITS = 8 * sizeof(BitBuf); @@ -45,7 +51,6 @@ typedef struct PutBitContext { BitBuf bit_buf; int bit_left; uint8_t *buf, *buf_ptr, *buf_end; - int size_in_bits; } PutBitContext; /** @@ -62,7 +67,6 @@ static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, buffer = NULL; } - s->size_in_bits = 8 * buffer_size; s->buf = buffer; s->buf_end = s->buf + buffer_size; s->buf_ptr = s->buf; @@ -78,6 +82,26 @@ static inline int put_bits_count(PutBitContext *s) return (s->buf_ptr - s->buf) * 8 + BUF_BITS - s->bit_left; } +/** + * @return the number of bytes output so far; may only be called + * when the PutBitContext is freshly initialized or flushed. + */ +static inline int put_bytes_output(const PutBitContext *s) +{ + av_assert2(s->bit_left == BUF_BITS); + return s->buf_ptr - s->buf; +} + +/** + * @param round_up When set, the number of bits written so far will be + * rounded up to the next byte. + * @return the number of bytes output so far. + */ +static inline int put_bytes_count(const PutBitContext *s, int round_up) +{ + return s->buf_ptr - s->buf + ((BUF_BITS - s->bit_left + (round_up ? 7 : 0)) >> 3); +} + /** * Rebase the bit writer onto a reallocated buffer. * @@ -93,7 +117,6 @@ static inline void rebase_put_bits(PutBitContext *s, uint8_t *buffer, s->buf_end = buffer + buffer_size; s->buf_ptr = buffer + (s->buf_ptr - s->buf); s->buf = buffer; - s->size_in_bits = 8 * buffer_size; } /** @@ -104,6 +127,16 @@ static inline int put_bits_left(PutBitContext* s) return (s->buf_end - s->buf_ptr) * 8 - BUF_BITS + s->bit_left; } +/** + * @param round_up When set, the number of bits written will be + * rounded up to the next byte. + * @return the number of bytes left. + */ +static inline int put_bytes_left(const PutBitContext *s, int round_up) +{ + return s->buf_end - s->buf_ptr - ((BUF_BITS - s->bit_left + (round_up ? 7 : 0)) >> 3); +} + /** * Pad the end of the output stream with zeros. */ @@ -140,11 +173,6 @@ static inline void flush_put_bits_le(PutBitContext *s) s->bit_buf = 0; } -#if FF_API_AVPRIV_PUT_BITS -void avpriv_align_put_bits(PutBitContext *s); -void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length); -#endif - #ifdef BITSTREAM_WRITER_LE #define ff_put_string ff_put_string_unsupported_here #define ff_copy_bits ff_copy_bits_unsupported_here @@ -377,7 +405,6 @@ static inline void set_put_bits_buffer_size(PutBitContext *s, int size) { av_assert0(size <= INT_MAX/8 - BUF_BITS); s->buf_end = s->buf + size; - s->size_in_bits = 8*size; } /** diff --git a/media/ffvpx/libavcodec/raw.c b/media/ffvpx/libavcodec/raw.c index 079d5c5d102a..a371bb36c431 100644 --- a/media/ffvpx/libavcodec/raw.c +++ b/media/ffvpx/libavcodec/raw.c @@ -24,11 +24,11 @@ * Raw Video Codec */ +#include "libavutil/macros.h" #include "avcodec.h" #include "raw.h" -#include "libavutil/common.h" -const PixelFormatTag ff_raw_pix_fmt_tags[] = { +static const PixelFormatTag raw_pix_fmt_tags[] = { { AV_PIX_FMT_YUV420P, MKTAG('I', '4', '2', '0') }, /* Planar formats */ { AV_PIX_FMT_YUV420P, MKTAG('I', 'Y', 'U', 'V') }, { AV_PIX_FMT_YUV420P, MKTAG('y', 'v', '1', '2') }, @@ -299,12 +299,12 @@ const PixelFormatTag ff_raw_pix_fmt_tags[] = { const struct PixelFormatTag *avpriv_get_raw_pix_fmt_tags(void) { - return ff_raw_pix_fmt_tags; + return raw_pix_fmt_tags; } unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat fmt) { - const PixelFormatTag *tags = ff_raw_pix_fmt_tags; + const PixelFormatTag *tags = raw_pix_fmt_tags; while (tags->pix_fmt >= 0) { if (tags->pix_fmt == fmt) return tags->fourcc; @@ -313,7 +313,7 @@ unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat fmt) return 0; } -const PixelFormatTag avpriv_pix_fmt_bps_avi[] = { +static const PixelFormatTag pix_fmt_bps_avi[] = { { AV_PIX_FMT_PAL8, 1 }, { AV_PIX_FMT_PAL8, 2 }, { AV_PIX_FMT_PAL8, 4 }, @@ -326,7 +326,7 @@ const PixelFormatTag avpriv_pix_fmt_bps_avi[] = { { AV_PIX_FMT_NONE, 0 }, }; -const PixelFormatTag avpriv_pix_fmt_bps_mov[] = { +static const PixelFormatTag pix_fmt_bps_mov[] = { { AV_PIX_FMT_PAL8, 1 }, { AV_PIX_FMT_PAL8, 2 }, { AV_PIX_FMT_PAL8, 4 }, @@ -337,3 +337,33 @@ const PixelFormatTag avpriv_pix_fmt_bps_mov[] = { { AV_PIX_FMT_PAL8, 33 }, { AV_PIX_FMT_NONE, 0 }, }; + +static enum AVPixelFormat find_pix_fmt(const PixelFormatTag *tags, + unsigned int fourcc) +{ + while (tags->pix_fmt != AV_PIX_FMT_NONE) { + if (tags->fourcc == fourcc) + return tags->pix_fmt; + tags++; + } + return AV_PIX_FMT_NONE; +} + +enum AVPixelFormat avpriv_pix_fmt_find(enum PixelFormatTagLists list, + unsigned fourcc) +{ + const PixelFormatTag *tags; + + switch (list) { + case PIX_FMT_LIST_RAW: + tags = raw_pix_fmt_tags; + break; + case PIX_FMT_LIST_AVI: + tags = pix_fmt_bps_avi; + break; + case PIX_FMT_LIST_MOV: + tags = pix_fmt_bps_mov; + break; + } + return find_pix_fmt(tags, fourcc); +} diff --git a/media/ffvpx/libavcodec/raw.h b/media/ffvpx/libavcodec/raw.h index 28a27b1f9e8d..9a4ddef8fc1b 100644 --- a/media/ffvpx/libavcodec/raw.h +++ b/media/ffvpx/libavcodec/raw.h @@ -27,22 +27,22 @@ #ifndef AVCODEC_RAW_H #define AVCODEC_RAW_H -#include "avcodec.h" -#include "internal.h" -#include "libavutil/internal.h" +#include "libavutil/pixfmt.h" typedef struct PixelFormatTag { enum AVPixelFormat pix_fmt; unsigned int fourcc; } PixelFormatTag; -extern const PixelFormatTag ff_raw_pix_fmt_tags[]; // exposed through avpriv_get_raw_pix_fmt_tags() - const struct PixelFormatTag *avpriv_get_raw_pix_fmt_tags(void); -enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc); +enum PixelFormatTagLists { + PIX_FMT_LIST_RAW, + PIX_FMT_LIST_AVI, + PIX_FMT_LIST_MOV, +}; -extern av_export_avcodec const PixelFormatTag avpriv_pix_fmt_bps_avi[]; -extern av_export_avcodec const PixelFormatTag avpriv_pix_fmt_bps_mov[]; +enum AVPixelFormat avpriv_pix_fmt_find(enum PixelFormatTagLists list, + unsigned fourcc); #endif /* AVCODEC_RAW_H */ diff --git a/media/ffvpx/libavcodec/rdft.c b/media/ffvpx/libavcodec/rdft.c index 6ba748423853..ac6f5d678112 100644 --- a/media/ffvpx/libavcodec/rdft.c +++ b/media/ffvpx/libavcodec/rdft.c @@ -20,6 +20,7 @@ */ #include #include +#include "libavutil/error.h" #include "libavutil/mathematics.h" #include "rdft.h" @@ -106,7 +107,9 @@ av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans) s->tsin = ff_cos_tabs[nbits] + (n >> 2); s->rdft_calc = rdft_calc_c; - if (ARCH_ARM) ff_rdft_init_arm(s); +#if ARCH_ARM + ff_rdft_init_arm(s); +#endif return 0; } diff --git a/media/ffvpx/libavcodec/rl.h b/media/ffvpx/libavcodec/rl.h index 26e0b32a907a..07e3da5003db 100644 --- a/media/ffvpx/libavcodec/rl.h +++ b/media/ffvpx/libavcodec/rl.h @@ -49,23 +49,35 @@ typedef struct RLTable { } RLTable; /** + * Initialize index_run, max_level and max_run from n, last, table_vlc, + * table_run and table_level. * @param static_store static uint8_t array[2][2*MAX_RUN + MAX_LEVEL + 3] * to hold the level and run tables. + * @note This function does not touch rl_vlc at all, hence there is no need + * to synchronize calls to ff_rl_init() and ff_rl_init_vlc() using the + * same RLTable. */ void ff_rl_init(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3]); + +/** + * Initialize rl_vlc from n, last, table_vlc, table_run and table_level. + * All rl_vlc pointers to be initialized must already point to a static + * buffer of `static_size` RL_VLC_ELEM elements; if a pointer is NULL, + * initializing further VLCs stops. + * @note This function does not touch what ff_rl_init() initializes at all, + * hence there is no need to synchronize calls to ff_rl_init() and + * ff_rl_init_vlc() using the same RLTable. + */ void ff_rl_init_vlc(RLTable *rl, unsigned static_size); #define INIT_VLC_RL(rl, static_size)\ {\ - int q;\ static RL_VLC_ELEM rl_vlc_table[32][static_size];\ \ - if(!rl.rl_vlc[0]){\ - for(q=0; q<32; q++)\ - rl.rl_vlc[q]= rl_vlc_table[q];\ + for (int q = 0; q < 32; q++) \ + rl.rl_vlc[q] = rl_vlc_table[q]; \ \ - ff_rl_init_vlc(&rl, static_size);\ - }\ + ff_rl_init_vlc(&rl, static_size); \ } #define INIT_FIRST_VLC_RL(rl, static_size) \ diff --git a/media/ffvpx/libavcodec/simple_idct.c b/media/ffvpx/libavcodec/simple_idct.c index 0ef167491a1c..eb13cff146ec 100644 --- a/media/ffvpx/libavcodec/simple_idct.c +++ b/media/ffvpx/libavcodec/simple_idct.c @@ -26,7 +26,6 @@ */ #include "libavutil/intreadwrite.h" -#include "avcodec.h" #include "mathops.h" #include "simple_idct.h" diff --git a/media/ffvpx/libavcodec/startcode.h b/media/ffvpx/libavcodec/startcode.h new file mode 100644 index 000000000000..8b75832aaf7f --- /dev/null +++ b/media/ffvpx/libavcodec/startcode.h @@ -0,0 +1,36 @@ +/* + * 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 + */ + +/** + * @file + * Accelerated start code search function for start codes common to + * MPEG-1/2/4 video, VC-1, H.264/5 + */ + +#ifndef AVCODEC_STARTCODE_H +#define AVCODEC_STARTCODE_H + +#include + +const uint8_t *avpriv_find_start_code(const uint8_t *p, + const uint8_t *end, + uint32_t *state); + +int ff_startcode_find_candidate_c(const uint8_t *buf, int size); + +#endif /* AVCODEC_STARTCODE_H */ diff --git a/media/ffvpx/libavcodec/thread.h b/media/ffvpx/libavcodec/thread.h index 413196269f59..d36dc83bd7c6 100644 --- a/media/ffvpx/libavcodec/thread.h +++ b/media/ffvpx/libavcodec/thread.h @@ -31,14 +31,6 @@ #include "avcodec.h" -typedef struct ThreadFrame { - AVFrame *f; - AVCodecContext *owner[2]; - // progress->data is an array of 2 ints holding progress for top/bottom - // fields - AVBufferRef *progress; -} ThreadFrame; - /** * Wait for decoding threads to finish and reset internal state. * Called by avcodec_flush_buffers(). @@ -52,10 +44,10 @@ void ff_thread_flush(AVCodecContext *avctx); * Returns the next available frame in picture. *got_picture_ptr * will be 0 if none is available. * The return value on success is the size of the consumed packet for - * compatibility with avcodec_decode_video2(). This means the decoder + * compatibility with FFCodec.decode. This means the decoder * has to consume the full packet. * - * Parameters are the same as avcodec_decode_video2(). + * Parameters are the same as FFCodec.decode. */ int ff_thread_decode_frame(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt); @@ -70,32 +62,6 @@ int ff_thread_decode_frame(AVCodecContext *avctx, AVFrame *picture, */ void ff_thread_finish_setup(AVCodecContext *avctx); -/** - * Notify later decoding threads when part of their reference picture is ready. - * Call this when some part of the picture is finished decoding. - * Later calls with lower values of progress have no effect. - * - * @param f The picture being decoded. - * @param progress Value, in arbitrary units, of how much of the picture has decoded. - * @param field The field being decoded, for field-picture codecs. - * 0 for top field or frame pictures, 1 for bottom field. - */ -void ff_thread_report_progress(ThreadFrame *f, int progress, int field); - -/** - * Wait for earlier decoding threads to finish reference pictures. - * Call this before accessing some part of a picture, with a given - * value for progress, and it will return after the responsible decoding - * thread calls ff_thread_report_progress() with the same or - * higher value for progress. - * - * @param f The picture being referenced. - * @param progress Value, in arbitrary units, to wait for. - * @param field The field being referenced, for field-picture codecs. - * 0 for top field or frame pictures, 1 for bottom field. - */ -void ff_thread_await_progress(ThreadFrame *f, int progress, int field); - #if FF_API_THREAD_SAFE_CALLBACKS /** * Wrapper around get_format() for frame-multithreaded codecs. @@ -118,7 +84,7 @@ enum AVPixelFormat ff_thread_get_format(AVCodecContext *avctx, const enum AVPixe * @param avctx The current context. * @param f The frame to write into. */ -int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags); +int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags); /** * Wrapper around release_buffer() frame-for multithreaded codecs. @@ -131,9 +97,7 @@ int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags); * @param avctx The current context. * @param f The picture being released. */ -void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f); - -int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src); +void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f); int ff_thread_init(AVCodecContext *s); int ff_slice_thread_execute_with_mainfunc(AVCodecContext *avctx, diff --git a/media/ffvpx/libavcodec/threadframe.h b/media/ffvpx/libavcodec/threadframe.h new file mode 100644 index 000000000000..dea4dadc6d08 --- /dev/null +++ b/media/ffvpx/libavcodec/threadframe.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2022 Andreas Rheinhardt + * + * 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 + */ + +#ifndef AVCODEC_THREADFRAME_H +#define AVCODEC_THREADFRAME_H + +#include "libavutil/frame.h" +#include "avcodec.h" + +typedef struct ThreadFrame { + AVFrame *f; + AVCodecContext *owner[2]; + // progress->data is an array of 2 ints holding progress for top/bottom + // fields + AVBufferRef *progress; +} ThreadFrame; + +/** + * Notify later decoding threads when part of their reference picture is ready. + * Call this when some part of the picture is finished decoding. + * Later calls with lower values of progress have no effect. + * + * @param f The picture being decoded. + * @param progress Value, in arbitrary units, of how much of the picture has decoded. + * @param field The field being decoded, for field-picture codecs. + * 0 for top field or frame pictures, 1 for bottom field. + */ +void ff_thread_report_progress(ThreadFrame *f, int progress, int field); + +/** + * Wait for earlier decoding threads to finish reference pictures. + * Call this before accessing some part of a picture, with a given + * value for progress, and it will return after the responsible decoding + * thread calls ff_thread_report_progress() with the same or + * higher value for progress. + * + * @param f The picture being referenced. + * @param progress Value, in arbitrary units, to wait for. + * @param field The field being referenced, for field-picture codecs. + * 0 for top field or frame pictures, 1 for bottom field. + */ +void ff_thread_await_progress(ThreadFrame *f, int progress, int field); + +/** + * Wrapper around ff_get_buffer() for frame-multithreaded codecs. + * Call this function instead of ff_get_buffer() if you might need + * to wait for progress on this frame. + * Cannot be called after the codec has called ff_thread_finish_setup(). + * + * @param avctx The current context. + * @param f The frame to write into. + * @note: It is fine to call this with codecs that do not support + * frame threading. + */ +int ff_thread_get_ext_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags); + +/** + * Unref a ThreadFrame. + * + * This is basically a wrapper around av_frame_unref() and should + * be called instead of it. + * + * @param avctx The current context. + * @param f The picture being released. + */ +void ff_thread_release_ext_buffer(AVCodecContext *avctx, ThreadFrame *f); + +int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src); + +#endif diff --git a/media/ffvpx/libavcodec/utils.c b/media/ffvpx/libavcodec/utils.c index 825094d2f31c..eb7e505a624c 100644 --- a/media/ffvpx/libavcodec/utils.c +++ b/media/ffvpx/libavcodec/utils.c @@ -27,25 +27,23 @@ #include "config.h" #include "libavutil/avassert.h" -#include "libavutil/avstring.h" +#include "libavutil/channel_layout.h" #include "libavutil/intreadwrite.h" -#include "libavutil/mem_internal.h" +#include "libavutil/mem.h" #include "libavutil/pixdesc.h" #include "libavutil/imgutils.h" #include "libavutil/pixfmt.h" #include "avcodec.h" #include "codec.h" +#include "codec_internal.h" #include "hwconfig.h" #include "thread.h" +#include "threadframe.h" #include "internal.h" #include "put_bits.h" -#include "raw.h" -#include "version.h" +#include "startcode.h" #include -#include -#include #include -#include void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size) { @@ -55,7 +53,8 @@ void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size) *size = 0; return; } - if (!ff_fast_malloc(p, size, min_size + AV_INPUT_BUFFER_PADDING_SIZE, 1)) + av_fast_mallocz(p, size, min_size + AV_INPUT_BUFFER_PADDING_SIZE); + if (*p) memset(*p + min_size, 0, AV_INPUT_BUFFER_PADDING_SIZE); } @@ -67,18 +66,25 @@ void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size) *size = 0; return; } - if (!ff_fast_malloc(p, size, min_size + AV_INPUT_BUFFER_PADDING_SIZE, 1)) + av_fast_malloc(p, size, min_size + AV_INPUT_BUFFER_PADDING_SIZE); + if (*p) memset(*p, 0, min_size + AV_INPUT_BUFFER_PADDING_SIZE); } -int av_codec_is_encoder(const AVCodec *codec) +int av_codec_is_encoder(const AVCodec *avcodec) { - return codec && (codec->encode_sub || codec->encode2 || codec->receive_packet); + const FFCodec *const codec = ffcodec(avcodec); + return codec && (codec->cb_type == FF_CODEC_CB_TYPE_ENCODE || + codec->cb_type == FF_CODEC_CB_TYPE_ENCODE_SUB || + codec->cb_type == FF_CODEC_CB_TYPE_RECEIVE_PACKET); } -int av_codec_is_decoder(const AVCodec *codec) +int av_codec_is_decoder(const AVCodec *avcodec) { - return codec && (codec->decode || codec->receive_frame); + const FFCodec *const codec = ffcodec(avcodec); + return codec && (codec->cb_type == FF_CODEC_CB_TYPE_DECODE || + codec->cb_type == FF_CODEC_CB_TYPE_DECODE_SUB || + codec->cb_type == FF_CODEC_CB_TYPE_RECEIVE_FRAME); } int ff_set_dimensions(AVCodecContext *s, int width, int height) @@ -384,8 +390,7 @@ int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, planar = av_sample_fmt_is_planar(sample_fmt); if (planar && nb_channels > AV_NUM_DATA_POINTERS) { - if (!(frame->extended_data = av_mallocz_array(nb_channels, - sizeof(*frame->extended_data)))) + if (!FF_ALLOCZ_TYPED_ARRAY(frame->extended_data, nb_channels)) return AVERROR(ENOMEM); } else { frame->extended_data = frame->data; @@ -435,37 +440,8 @@ void ff_color_frame(AVFrame *frame, const int c[4]) } } -enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags, - unsigned int fourcc) -{ - while (tags->pix_fmt >= 0) { - if (tags->fourcc == fourcc) - return tags->pix_fmt; - tags++; - } - return AV_PIX_FMT_NONE; -} - -#if FF_API_CODEC_GET_SET -MAKE_ACCESSORS(AVCodecContext, codec, AVRational, pkt_timebase) -MAKE_ACCESSORS(AVCodecContext, codec, const AVCodecDescriptor *, codec_descriptor) -MAKE_ACCESSORS(AVCodecContext, codec, int, lowres) -MAKE_ACCESSORS(AVCodecContext, codec, int, seek_preroll) -MAKE_ACCESSORS(AVCodecContext, codec, uint16_t*, chroma_intra_matrix) - -unsigned av_codec_get_codec_properties(const AVCodecContext *codec) -{ - return codec->properties; -} - -int av_codec_get_max_lowres(const AVCodec *codec) -{ - return codec->max_lowres; -} -#endif - int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec){ - return !!(codec->caps_internal & FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM); + return !!(ffcodec(codec)->caps_internal & FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM); } const char *avcodec_get_name(enum AVCodecID id) @@ -488,28 +464,6 @@ const char *avcodec_get_name(enum AVCodecID id) return "unknown_codec"; } -#if FF_API_TAG_STRING -size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag) -{ - int i, len, ret = 0; - -#define TAG_PRINT(x) \ - (((x) >= '0' && (x) <= '9') || \ - ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z') || \ - ((x) == '.' || (x) == ' ' || (x) == '-' || (x) == '_')) - - for (i = 0; i < 4; i++) { - len = snprintf(buf, buf_size, - TAG_PRINT(codec_tag & 0xFF) ? "%c" : "[%d]", codec_tag & 0xFF); - buf += len; - buf_size = buf_size > len ? buf_size - len : 0; - ret += len; - codec_tag >>= 8; - } - return ret; -} -#endif - const char *av_get_profile_name(const AVCodec *codec, int profile) { const AVProfile *p; @@ -630,6 +584,8 @@ enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be) int av_get_bits_per_sample(enum AVCodecID codec_id) { switch (codec_id) { + case AV_CODEC_ID_DFPWM: + return 1; case AV_CODEC_ID_ADPCM_SBPRO_2: return 2; case AV_CODEC_ID_ADPCM_SBPRO_3: @@ -746,6 +702,7 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, return 0; return frame_bytes * 28; case AV_CODEC_ID_ADPCM_4XM: + case AV_CODEC_ID_ADPCM_IMA_ACORN: case AV_CODEC_ID_ADPCM_IMA_DAT4: case AV_CODEC_ID_ADPCM_IMA_ISS: return (frame_bytes - 4 * ch) * 2 / ch; @@ -854,8 +811,16 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes) { - int duration = get_audio_frame_duration(avctx->codec_id, avctx->sample_rate, - avctx->channels, avctx->block_align, + int channels = avctx->ch_layout.nb_channels; + int duration; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + if (!channels) + channels = avctx->channels; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + duration = get_audio_frame_duration(avctx->codec_id, avctx->sample_rate, + channels, avctx->block_align, avctx->codec_tag, avctx->bits_per_coded_sample, avctx->bit_rate, avctx->extradata, avctx->frame_size, frame_bytes); @@ -864,8 +829,16 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes) int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes) { - int duration = get_audio_frame_duration(par->codec_id, par->sample_rate, - par->channels, par->block_align, + int channels = par->ch_layout.nb_channels; + int duration; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + if (!channels) + channels = par->channels; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + duration = get_audio_frame_duration(par->codec_id, par->sample_rate, + channels, par->block_align, par->codec_tag, par->bits_per_coded_sample, par->bit_rate, par->extradata, par->frame_size, frame_bytes); @@ -901,8 +874,9 @@ int ff_match_2uint16(const uint16_t(*tab)[2], int size, int a, int b) return i; } -const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index) +const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *avcodec, int index) { + const FFCodec *const codec = ffcodec(avcodec); int i; if (!codec->hw_configs || index < 0) return NULL; @@ -912,25 +886,6 @@ const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index) return &codec->hw_configs[index]->public; } -#if FF_API_USER_VISIBLE_AVHWACCEL -AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel) -{ - return NULL; -} - -void av_register_hwaccel(AVHWAccel *hwaccel) -{ -} -#endif - -unsigned int avpriv_toupper4(unsigned int x) -{ - return av_toupper(x & 0xFF) + - (av_toupper((x >> 8) & 0xFF) << 8) + - (av_toupper((x >> 16) & 0xFF) << 16) + -((unsigned)av_toupper((x >> 24) & 0xFF) << 24); -} - int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src) { int ret; @@ -946,7 +901,7 @@ int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src) if (src->progress && !(dst->progress = av_buffer_ref(src->progress))) { - ff_thread_release_buffer(dst->owner[0], dst); + ff_thread_release_ext_buffer(dst->owner[0], dst); return AVERROR(ENOMEM); } @@ -960,14 +915,26 @@ enum AVPixelFormat ff_thread_get_format(AVCodecContext *avctx, const enum AVPixe return ff_get_format(avctx, fmt); } -int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags) +int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags) +{ + return ff_get_buffer(avctx, f, flags); +} + +int ff_thread_get_ext_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags) { f->owner[0] = f->owner[1] = avctx; return ff_get_buffer(avctx, f->f, flags); } -void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f) +void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f) { + if (f) + av_frame_unref(f); +} + +void ff_thread_release_ext_buffer(AVCodecContext *avctx, ThreadFrame *f) +{ + f->owner[0] = f->owner[1] = NULL; if (f->f) av_frame_unref(f->f); } diff --git a/media/ffvpx/libavcodec/vaapi_av1.c b/media/ffvpx/libavcodec/vaapi_av1.c index 16b7e35747cf..63374c31c986 100644 --- a/media/ffvpx/libavcodec/vaapi_av1.c +++ b/media/ffvpx/libavcodec/vaapi_av1.c @@ -18,15 +18,37 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/frame.h" #include "libavutil/pixdesc.h" #include "hwconfig.h" #include "vaapi_decode.h" +#include "internal.h" #include "av1dec.h" +#include "thread.h" + +typedef struct VAAPIAV1FrameRef { + AVFrame *frame; + int valid; +} VAAPIAV1FrameRef; + +typedef struct VAAPIAV1DecContext { + VAAPIDecodeContext base; + + /** + * For film grain case, VAAPI generate 2 output for each frame, + * current_frame will not apply film grain, and will be used for + * references for next frames. Maintain the reference list without + * applying film grain here. And current_display_picture will be + * used to apply film grain and push to downstream. + */ + VAAPIAV1FrameRef ref_tab[AV1_NUM_REF_FRAMES]; + AVFrame *tmp_frame; +} VAAPIAV1DecContext; static VASurfaceID vaapi_av1_surface_id(AV1Frame *vf) { if (vf) - return ff_vaapi_get_surface_id(vf->tf.f); + return ff_vaapi_get_surface_id(vf->f); else return VA_INVALID_SURFACE; } @@ -49,6 +71,48 @@ static int8_t vaapi_av1_get_bit_depth_idx(AVCodecContext *avctx) return bit_depth == 8 ? 0 : bit_depth == 10 ? 1 : 2; } +static int vaapi_av1_decode_init(AVCodecContext *avctx) +{ + VAAPIAV1DecContext *ctx = avctx->internal->hwaccel_priv_data; + + ctx->tmp_frame = av_frame_alloc(); + if (!ctx->tmp_frame) { + av_log(avctx, AV_LOG_ERROR, + "Failed to allocate frame.\n"); + return AVERROR(ENOMEM); + } + + for (int i = 0; i < FF_ARRAY_ELEMS(ctx->ref_tab); i++) { + ctx->ref_tab[i].frame = av_frame_alloc(); + if (!ctx->ref_tab[i].frame) { + av_log(avctx, AV_LOG_ERROR, + "Failed to allocate reference table frame %d.\n", i); + return AVERROR(ENOMEM); + } + ctx->ref_tab[i].valid = 0; + } + + return ff_vaapi_decode_init(avctx); +} + +static int vaapi_av1_decode_uninit(AVCodecContext *avctx) +{ + VAAPIAV1DecContext *ctx = avctx->internal->hwaccel_priv_data; + + if (ctx->tmp_frame->buf[0]) + ff_thread_release_buffer(avctx, ctx->tmp_frame); + av_frame_free(&ctx->tmp_frame); + + for (int i = 0; i < FF_ARRAY_ELEMS(ctx->ref_tab); i++) { + if (ctx->ref_tab[i].frame->buf[0]) + ff_thread_release_buffer(avctx, ctx->ref_tab[i].frame); + av_frame_free(&ctx->ref_tab[i].frame); + } + + return ff_vaapi_decode_uninit(avctx); +} + + static int vaapi_av1_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) @@ -58,40 +122,62 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, const AV1RawFrameHeader *frame_header = s->raw_frame_header; const AV1RawFilmGrainParams *film_grain = &s->cur_frame.film_grain; VAAPIDecodePicture *pic = s->cur_frame.hwaccel_picture_private; + VAAPIAV1DecContext *ctx = avctx->internal->hwaccel_priv_data; VADecPictureParameterBufferAV1 pic_param; int8_t bit_depth_idx; int err = 0; int apply_grain = !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) && film_grain->apply_grain; uint8_t remap_lr_type[4] = {AV1_RESTORE_NONE, AV1_RESTORE_SWITCHABLE, AV1_RESTORE_WIENER, AV1_RESTORE_SGRPROJ}; - - pic->output_surface = vaapi_av1_surface_id(&s->cur_frame); + uint8_t segmentation_feature_signed[AV1_SEG_LVL_MAX] = {1, 1, 1, 1, 1, 0, 0, 0}; + uint8_t segmentation_feature_max[AV1_SEG_LVL_MAX] = {255, AV1_MAX_LOOP_FILTER, + AV1_MAX_LOOP_FILTER, AV1_MAX_LOOP_FILTER, AV1_MAX_LOOP_FILTER, 7 , 0 , 0 }; bit_depth_idx = vaapi_av1_get_bit_depth_idx(avctx); if (bit_depth_idx < 0) goto fail; + if (apply_grain) { + if (ctx->tmp_frame->buf[0]) + ff_thread_release_buffer(avctx, ctx->tmp_frame); + err = ff_thread_get_buffer(avctx, ctx->tmp_frame, AV_GET_BUFFER_FLAG_REF); + if (err < 0) + goto fail; + pic->output_surface = ff_vaapi_get_surface_id(ctx->tmp_frame); + } else { + pic->output_surface = vaapi_av1_surface_id(&s->cur_frame); + } + memset(&pic_param, 0, sizeof(VADecPictureParameterBufferAV1)); pic_param = (VADecPictureParameterBufferAV1) { - .profile = seq->seq_profile, - .order_hint_bits_minus_1 = seq->order_hint_bits_minus_1, - .bit_depth_idx = bit_depth_idx, - .current_frame = pic->output_surface, - .current_display_picture = pic->output_surface, - .frame_width_minus1 = frame_header->frame_width_minus_1, - .frame_height_minus1 = frame_header->frame_height_minus_1, - .primary_ref_frame = frame_header->primary_ref_frame, - .order_hint = frame_header->order_hint, - .tile_cols = frame_header->tile_cols, - .tile_rows = frame_header->tile_rows, - .context_update_tile_id = frame_header->context_update_tile_id, - .interp_filter = frame_header->interpolation_filter, - .filter_level[0] = frame_header->loop_filter_level[0], - .filter_level[1] = frame_header->loop_filter_level[1], - .filter_level_u = frame_header->loop_filter_level[2], - .filter_level_v = frame_header->loop_filter_level[3], - .base_qindex = frame_header->base_q_idx, - .cdef_damping_minus_3 = frame_header->cdef_damping_minus_3, - .cdef_bits = frame_header->cdef_bits, + .profile = seq->seq_profile, + .order_hint_bits_minus_1 = seq->order_hint_bits_minus_1, + .bit_depth_idx = bit_depth_idx, + .matrix_coefficients = seq->color_config.matrix_coefficients, + .current_frame = pic->output_surface, + .current_display_picture = vaapi_av1_surface_id(&s->cur_frame), + .frame_width_minus1 = frame_header->frame_width_minus_1, + .frame_height_minus1 = frame_header->frame_height_minus_1, + .primary_ref_frame = frame_header->primary_ref_frame, + .order_hint = frame_header->order_hint, + .tile_cols = frame_header->tile_cols, + .tile_rows = frame_header->tile_rows, + .context_update_tile_id = frame_header->context_update_tile_id, + .superres_scale_denominator = frame_header->use_superres ? + frame_header->coded_denom + AV1_SUPERRES_DENOM_MIN : + AV1_SUPERRES_NUM, + .interp_filter = frame_header->interpolation_filter, + .filter_level[0] = frame_header->loop_filter_level[0], + .filter_level[1] = frame_header->loop_filter_level[1], + .filter_level_u = frame_header->loop_filter_level[2], + .filter_level_v = frame_header->loop_filter_level[3], + .base_qindex = frame_header->base_q_idx, + .y_dc_delta_q = frame_header->delta_q_y_dc, + .u_dc_delta_q = frame_header->delta_q_u_dc, + .u_ac_delta_q = frame_header->delta_q_u_ac, + .v_dc_delta_q = frame_header->delta_q_v_dc, + .v_ac_delta_q = frame_header->delta_q_v_ac, + .cdef_damping_minus_3 = frame_header->cdef_damping_minus_3, + .cdef_bits = frame_header->cdef_bits, .seq_info_fields.fields = { .still_picture = seq->still_picture, .use_128x128_superblock = seq->use_128x128_superblock, @@ -162,12 +248,15 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, .mode_ref_delta_update = frame_header->loop_filter_delta_update, }, .mode_control_fields.bits = { - .delta_q_present_flag = frame_header->delta_q_present, - .log2_delta_q_res = frame_header->delta_q_res, - .tx_mode = frame_header->tx_mode, - .reference_select = frame_header->reference_select, - .reduced_tx_set_used = frame_header->reduced_tx_set, - .skip_mode_present = frame_header->skip_mode_present, + .delta_q_present_flag = frame_header->delta_q_present, + .log2_delta_q_res = frame_header->delta_q_res, + .delta_lf_present_flag = frame_header->delta_lf_present, + .log2_delta_lf_res = frame_header->delta_lf_res, + .delta_lf_multi = frame_header->delta_lf_multi, + .tx_mode = frame_header->tx_mode, + .reference_select = frame_header->reference_select, + .reduced_tx_set_used = frame_header->reduced_tx_set, + .skip_mode_present = frame_header->skip_mode_present, }, .loop_restoration_fields.bits = { .yframe_restoration_type = remap_lr_type[frame_header->lr_type[0]], @@ -178,6 +267,9 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, }, .qmatrix_fields.bits = { .using_qmatrix = frame_header->using_qmatrix, + .qm_y = frame_header->qm_y, + .qm_u = frame_header->qm_u, + .qm_v = frame_header->qm_v, } }; @@ -185,7 +277,9 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, if (pic_param.pic_info_fields.bits.frame_type == AV1_FRAME_KEY) pic_param.ref_frame_map[i] = VA_INVALID_ID; else - pic_param.ref_frame_map[i] = vaapi_av1_surface_id(&s->ref[i]); + pic_param.ref_frame_map[i] = ctx->ref_tab[i].valid ? + ff_vaapi_get_surface_id(ctx->ref_tab[i].frame) : + vaapi_av1_surface_id(&s->ref[i]); } for (int i = 0; i < AV1_REFS_PER_FRAME; i++) { pic_param.ref_frame_idx[i] = frame_header->ref_frame_idx[i]; @@ -213,10 +307,22 @@ static int vaapi_av1_start_frame(AVCodecContext *avctx, frame_header->height_in_sbs_minus_1[i]; } for (int i = AV1_REF_FRAME_LAST; i <= AV1_REF_FRAME_ALTREF; i++) { - pic_param.wm[i - 1].wmtype = s->cur_frame.gm_type[i]; + pic_param.wm[i - 1].invalid = s->cur_frame.gm_invalid[i]; + pic_param.wm[i - 1].wmtype = s->cur_frame.gm_type[i]; for (int j = 0; j < 6; j++) pic_param.wm[i - 1].wmmat[j] = s->cur_frame.gm_params[i][j]; } + for (int i = 0; i < AV1_MAX_SEGMENTS; i++) { + for (int j = 0; j < AV1_SEG_LVL_MAX; j++) { + pic_param.seg_info.feature_mask[i] |= (frame_header->feature_enabled[i][j] << j); + if (segmentation_feature_signed[j]) + pic_param.seg_info.feature_data[i][j] = av_clip(frame_header->feature_value[i][j], + -segmentation_feature_max[j], segmentation_feature_max[j]); + else + pic_param.seg_info.feature_data[i][j] = av_clip(frame_header->feature_value[i][j], + 0, segmentation_feature_max[j]); + } + } if (apply_grain) { for (int i = 0; i < film_grain->num_y_points; i++) { pic_param.film_grain_info.point_y_value[i] = @@ -263,8 +369,34 @@ fail: static int vaapi_av1_end_frame(AVCodecContext *avctx) { const AV1DecContext *s = avctx->priv_data; + const AV1RawFrameHeader *header = s->raw_frame_header; + const AV1RawFilmGrainParams *film_grain = &s->cur_frame.film_grain; VAAPIDecodePicture *pic = s->cur_frame.hwaccel_picture_private; - return ff_vaapi_decode_issue(avctx, pic); + VAAPIAV1DecContext *ctx = avctx->internal->hwaccel_priv_data; + + int apply_grain = !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) && film_grain->apply_grain; + int ret; + ret = ff_vaapi_decode_issue(avctx, pic); + if (ret < 0) + return ret; + + for (int i = 0; i < AV1_NUM_REF_FRAMES; i++) { + if (header->refresh_frame_flags & (1 << i)) { + if (ctx->ref_tab[i].frame->buf[0]) + ff_thread_release_buffer(avctx, ctx->ref_tab[i].frame); + + if (apply_grain) { + ret = av_frame_ref(ctx->ref_tab[i].frame, ctx->tmp_frame); + if (ret < 0) + return ret; + ctx->ref_tab[i].valid = 1; + } else { + ctx->ref_tab[i].valid = 0; + } + } + } + + return 0; } static int vaapi_av1_decode_slice(AVCodecContext *avctx, @@ -311,9 +443,9 @@ const AVHWAccel ff_av1_vaapi_hwaccel = { .end_frame = vaapi_av1_end_frame, .decode_slice = vaapi_av1_decode_slice, .frame_priv_data_size = sizeof(VAAPIDecodePicture), - .init = ff_vaapi_decode_init, - .uninit = ff_vaapi_decode_uninit, + .init = vaapi_av1_decode_init, + .uninit = vaapi_av1_decode_uninit, .frame_params = ff_vaapi_common_frame_params, - .priv_data_size = sizeof(VAAPIDecodeContext), + .priv_data_size = sizeof(VAAPIAV1DecContext), .caps_internal = HWACCEL_CAP_ASYNC_SAFE, }; diff --git a/media/ffvpx/libavcodec/vaapi_decode.c b/media/ffvpx/libavcodec/vaapi_decode.c index 57a0eb4e6e13..a7abddb06be8 100644 --- a/media/ffvpx/libavcodec/vaapi_decode.c +++ b/media/ffvpx/libavcodec/vaapi_decode.c @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config_components.h" + #include "libavutil/avassert.h" #include "libavutil/common.h" #include "libavutil/pixdesc.h" @@ -577,10 +579,10 @@ static int vaapi_decode_make_config(AVCodecContext *avctx, switch (avctx->codec_id) { case AV_CODEC_ID_H264: case AV_CODEC_ID_HEVC: + case AV_CODEC_ID_AV1: frames->initial_pool_size += 16; break; case AV_CODEC_ID_VP9: - case AV_CODEC_ID_AV1: frames->initial_pool_size += 8; break; case AV_CODEC_ID_VP8: @@ -640,46 +642,6 @@ int ff_vaapi_decode_init(AVCodecContext *avctx) ctx->va_config = VA_INVALID_ID; ctx->va_context = VA_INVALID_ID; -#if FF_API_STRUCT_VAAPI_CONTEXT - if (avctx->hwaccel_context) { - av_log(avctx, AV_LOG_WARNING, "Using deprecated struct " - "vaapi_context in decode.\n"); - - ctx->have_old_context = 1; - ctx->old_context = avctx->hwaccel_context; - - // Really we only want the VAAPI device context, but this - // allocates a whole generic device context because we don't - // have any other way to determine how big it should be. - ctx->device_ref = - av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_VAAPI); - if (!ctx->device_ref) { - err = AVERROR(ENOMEM); - goto fail; - } - ctx->device = (AVHWDeviceContext*)ctx->device_ref->data; - ctx->hwctx = ctx->device->hwctx; - - ctx->hwctx->display = ctx->old_context->display; - - // The old VAAPI decode setup assumed this quirk was always - // present, so set it here to avoid the behaviour changing. - ctx->hwctx->driver_quirks = - AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS; - - } -#endif - -#if FF_API_STRUCT_VAAPI_CONTEXT - if (ctx->have_old_context) { - ctx->va_config = ctx->old_context->config_id; - ctx->va_context = ctx->old_context->context_id; - - av_log(avctx, AV_LOG_DEBUG, "Using user-supplied decoder " - "context: %#x/%#x.\n", ctx->va_config, ctx->va_context); - } else { -#endif - err = ff_decode_get_hw_frames_ctx(avctx, AV_HWDEVICE_TYPE_VAAPI); if (err < 0) goto fail; @@ -690,7 +652,7 @@ int ff_vaapi_decode_init(AVCodecContext *avctx) ctx->hwctx = ctx->device->hwctx; err = vaapi_decode_make_config(avctx, ctx->frames->device_ref, - &ctx->va_config, avctx->hw_frames_ctx); + &ctx->va_config, NULL); if (err) goto fail; @@ -709,9 +671,6 @@ int ff_vaapi_decode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_DEBUG, "Decode context initialised: " "%#x/%#x.\n", ctx->va_config, ctx->va_context); -#if FF_API_STRUCT_VAAPI_CONTEXT - } -#endif return 0; @@ -725,12 +684,6 @@ int ff_vaapi_decode_uninit(AVCodecContext *avctx) VAAPIDecodeContext *ctx = avctx->internal->hwaccel_priv_data; VAStatus vas; -#if FF_API_STRUCT_VAAPI_CONTEXT - if (ctx->have_old_context) { - av_buffer_unref(&ctx->device_ref); - } else { -#endif - if (ctx->va_context != VA_INVALID_ID) { vas = vaDestroyContext(ctx->hwctx->display, ctx->va_context); if (vas != VA_STATUS_SUCCESS) { @@ -748,9 +701,5 @@ int ff_vaapi_decode_uninit(AVCodecContext *avctx) } } -#if FF_API_STRUCT_VAAPI_CONTEXT - } -#endif - return 0; } diff --git a/media/ffvpx/libavcodec/vaapi_decode.h b/media/ffvpx/libavcodec/vaapi_decode.h index 6b415dd1d36d..6beda14e52e8 100644 --- a/media/ffvpx/libavcodec/vaapi_decode.h +++ b/media/ffvpx/libavcodec/vaapi_decode.h @@ -27,11 +27,6 @@ #include "avcodec.h" -#include "version.h" -#if FF_API_STRUCT_VAAPI_CONTEXT -#include "vaapi.h" -#endif - static inline VASurfaceID ff_vaapi_get_surface_id(AVFrame *pic) { return (uintptr_t)pic->data[3]; @@ -56,14 +51,6 @@ typedef struct VAAPIDecodeContext { VAConfigID va_config; VAContextID va_context; -#if FF_API_STRUCT_VAAPI_CONTEXT -FF_DISABLE_DEPRECATION_WARNINGS - int have_old_context; - struct vaapi_context *old_context; - AVBufferRef *device_ref; -FF_ENABLE_DEPRECATION_WARNINGS -#endif - AVHWDeviceContext *device; AVVAAPIDeviceContext *hwctx; diff --git a/media/ffvpx/libavcodec/version.c b/media/ffvpx/libavcodec/version.c new file mode 100644 index 000000000000..d7966b20153d --- /dev/null +++ b/media/ffvpx/libavcodec/version.c @@ -0,0 +1,50 @@ +/* + * Version functions. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" + +#include "libavutil/avassert.h" +#include "avcodec.h" +#include "codec_id.h" +#include "version.h" + +#include "libavutil/ffversion.h" +const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION; + +unsigned avcodec_version(void) +{ + av_assert0(AV_CODEC_ID_PCM_S8_PLANAR==65563); + av_assert0(AV_CODEC_ID_ADPCM_G722==69660); + av_assert0(AV_CODEC_ID_SRT==94216); + av_assert0(LIBAVCODEC_VERSION_MICRO >= 100); + + return LIBAVCODEC_VERSION_INT; +} + +const char *avcodec_configuration(void) +{ + return FFMPEG_CONFIGURATION; +} + +const char *avcodec_license(void) +{ +#define LICENSE_PREFIX "libavcodec license: " + return &LICENSE_PREFIX FFMPEG_LICENSE[sizeof(LICENSE_PREFIX) - 1]; +} diff --git a/media/ffvpx/libavcodec/version.h b/media/ffvpx/libavcodec/version.h index cfdde469600b..2a08e42d7eac 100644 --- a/media/ffvpx/libavcodec/version.h +++ b/media/ffvpx/libavcodec/version.h @@ -27,8 +27,9 @@ #include "libavutil/version.h" -#define LIBAVCODEC_VERSION_MAJOR 58 -#define LIBAVCODEC_VERSION_MINOR 134 +#include "version_major.h" + +#define LIBAVCODEC_VERSION_MINOR 33 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ @@ -41,132 +42,4 @@ #define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) -/** - * FF_API_* defines may be placed below to indicate public API that will be - * dropped at a future version bump. The defines themselves are not part of - * the public API and may change, break or disappear at any time. - * - * @note, when bumping the major version it is recommended to manually - * disable each FF_API_* in its own commit instead of disabling them all - * at once through the bump. This improves the git bisect-ability of the change. - */ - -#ifndef FF_API_AVCTX_TIMEBASE -#define FF_API_AVCTX_TIMEBASE (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_CODED_FRAME -#define FF_API_CODED_FRAME (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_SIDEDATA_ONLY_PKT -#define FF_API_SIDEDATA_ONLY_PKT (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_VDPAU_PROFILE -#define FF_API_VDPAU_PROFILE (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_CONVERGENCE_DURATION -#define FF_API_CONVERGENCE_DURATION (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_AVPICTURE -#define FF_API_AVPICTURE (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_AVPACKET_OLD_API -#define FF_API_AVPACKET_OLD_API (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_RTP_CALLBACK -#define FF_API_RTP_CALLBACK (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_VBV_DELAY -#define FF_API_VBV_DELAY (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_CODER_TYPE -#define FF_API_CODER_TYPE (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_STAT_BITS -#define FF_API_STAT_BITS (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_PRIVATE_OPT -#define FF_API_PRIVATE_OPT (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_ASS_TIMING -#define FF_API_ASS_TIMING (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_OLD_BSF -#define FF_API_OLD_BSF (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_COPY_CONTEXT -#define FF_API_COPY_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_GET_CONTEXT_DEFAULTS -#define FF_API_GET_CONTEXT_DEFAULTS (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_NVENC_OLD_NAME -#define FF_API_NVENC_OLD_NAME (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_STRUCT_VAAPI_CONTEXT -#define FF_API_STRUCT_VAAPI_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_MERGE_SD_API -#define FF_API_MERGE_SD_API (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_TAG_STRING -#define FF_API_TAG_STRING (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_GETCHROMA -#define FF_API_GETCHROMA (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_CODEC_GET_SET -#define FF_API_CODEC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_USER_VISIBLE_AVHWACCEL -#define FF_API_USER_VISIBLE_AVHWACCEL (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_LOCKMGR -#define FF_API_LOCKMGR (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_NEXT -#define FF_API_NEXT (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_UNSANITIZED_BITRATES -#define FF_API_UNSANITIZED_BITRATES (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_OPENH264_SLICE_MODE -#define FF_API_OPENH264_SLICE_MODE (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_OPENH264_CABAC -#define FF_API_OPENH264_CABAC (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_UNUSED_CODEC_CAPS -#define FF_API_UNUSED_CODEC_CAPS (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_AVPRIV_PUT_BITS -#define FF_API_AVPRIV_PUT_BITS (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_OLD_ENCDEC -#define FF_API_OLD_ENCDEC (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_AVCODEC_PIX_FMT -#define FF_API_AVCODEC_PIX_FMT (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_MPV_RC_STRATEGY -#define FF_API_MPV_RC_STRATEGY (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_PARSER_CHANGE -#define FF_API_PARSER_CHANGE (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_THREAD_SAFE_CALLBACKS -#define FF_API_THREAD_SAFE_CALLBACKS (LIBAVCODEC_VERSION_MAJOR < 60) -#endif -#ifndef FF_API_DEBUG_MV -#define FF_API_DEBUG_MV (LIBAVCODEC_VERSION_MAJOR < 60) -#endif -#ifndef FF_API_GET_FRAME_CLASS -#define FF_API_GET_FRAME_CLASS (LIBAVCODEC_VERSION_MAJOR < 60) -#endif -#ifndef FF_API_AUTO_THREADS -#define FF_API_AUTO_THREADS (LIBAVCODEC_VERSION_MAJOR < 60) -#endif -#ifndef FF_API_INIT_PACKET -#define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 60) -#endif - #endif /* AVCODEC_VERSION_H */ diff --git a/media/ffvpx/libavcodec/version_major.h b/media/ffvpx/libavcodec/version_major.h new file mode 100644 index 000000000000..1e23ed5e03e3 --- /dev/null +++ b/media/ffvpx/libavcodec/version_major.h @@ -0,0 +1,54 @@ +/* + * 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 + */ + +#ifndef AVCODEC_VERSION_MAJOR_H +#define AVCODEC_VERSION_MAJOR_H + +/** + * @file + * @ingroup libavc + * Libavcodec version macros. + */ + +#define LIBAVCODEC_VERSION_MAJOR 59 + +/** + * FF_API_* defines may be placed below to indicate public API that will be + * dropped at a future version bump. The defines themselves are not part of + * the public API and may change, break or disappear at any time. + * + * @note, when bumping the major version it is recommended to manually + * disable each FF_API_* in its own commit instead of disabling them all + * at once through the bump. This improves the git bisect-ability of the change. + */ + +#define FF_API_OPENH264_SLICE_MODE (LIBAVCODEC_VERSION_MAJOR < 60) +#define FF_API_OPENH264_CABAC (LIBAVCODEC_VERSION_MAJOR < 60) +#define FF_API_UNUSED_CODEC_CAPS (LIBAVCODEC_VERSION_MAJOR < 60) +#define FF_API_THREAD_SAFE_CALLBACKS (LIBAVCODEC_VERSION_MAJOR < 60) +#define FF_API_DEBUG_MV (LIBAVCODEC_VERSION_MAJOR < 60) +#define FF_API_GET_FRAME_CLASS (LIBAVCODEC_VERSION_MAJOR < 60) +#define FF_API_AUTO_THREADS (LIBAVCODEC_VERSION_MAJOR < 60) +#define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 60) +#define FF_API_AVCTX_TIMEBASE (LIBAVCODEC_VERSION_MAJOR < 60) +#define FF_API_FLAG_TRUNCATED (LIBAVCODEC_VERSION_MAJOR < 60) +#define FF_API_SUB_TEXT_FORMAT (LIBAVCODEC_VERSION_MAJOR < 60) +#define FF_API_IDCT_NONE (LIBAVCODEC_VERSION_MAJOR < 60) +#define FF_API_SVTAV1_OPTS (LIBAVCODEC_VERSION_MAJOR < 60) + +#endif /* AVCODEC_VERSION_MAJOR_H */ diff --git a/media/ffvpx/libavcodec/videodsp.c b/media/ffvpx/libavcodec/videodsp.c index ce9e9eb1439d..90dc1aacbd2f 100644 --- a/media/ffvpx/libavcodec/videodsp.c +++ b/media/ffvpx/libavcodec/videodsp.c @@ -18,9 +18,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" #include "libavutil/attributes.h" #include "libavutil/avassert.h" -#include "libavutil/common.h" +#include "libavutil/macros.h" #include "videodsp.h" #define BIT_DEPTH 8 @@ -44,14 +45,17 @@ av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc) ctx->emulated_edge_mc = ff_emulated_edge_mc_16; } - if (ARCH_AARCH64) - ff_videodsp_init_aarch64(ctx, bpc); - if (ARCH_ARM) - ff_videodsp_init_arm(ctx, bpc); - if (ARCH_PPC) - ff_videodsp_init_ppc(ctx, bpc); - if (ARCH_X86) - ff_videodsp_init_x86(ctx, bpc); - if (ARCH_MIPS) - ff_videodsp_init_mips(ctx, bpc); +#if ARCH_AARCH64 + ff_videodsp_init_aarch64(ctx, bpc); +#elif ARCH_ARM + ff_videodsp_init_arm(ctx, bpc); +#elif ARCH_PPC + ff_videodsp_init_ppc(ctx, bpc); +#elif ARCH_X86 + ff_videodsp_init_x86(ctx, bpc); +#elif ARCH_MIPS + ff_videodsp_init_mips(ctx, bpc); +#elif ARCH_LOONGARCH64 + ff_videodsp_init_loongarch(ctx, bpc); +#endif } diff --git a/media/ffvpx/libavcodec/videodsp.h b/media/ffvpx/libavcodec/videodsp.h index c0545f22b027..b5219d236c95 100644 --- a/media/ffvpx/libavcodec/videodsp.h +++ b/media/ffvpx/libavcodec/videodsp.h @@ -36,7 +36,6 @@ void ff_emulated_edge_mc_ ## depth(uint8_t *dst, const uint8_t *src, \ int src_x, int src_y, int w, int h); EMULATED_EDGE(8) -EMULATED_EDGE(16) typedef struct VideoDSPContext { /** @@ -84,5 +83,6 @@ void ff_videodsp_init_arm(VideoDSPContext *ctx, int bpc); void ff_videodsp_init_ppc(VideoDSPContext *ctx, int bpc); void ff_videodsp_init_x86(VideoDSPContext *ctx, int bpc); void ff_videodsp_init_mips(VideoDSPContext *ctx, int bpc); +void ff_videodsp_init_loongarch(VideoDSPContext *ctx, int bpc); #endif /* AVCODEC_VIDEODSP_H */ diff --git a/media/ffvpx/libavcodec/videodsp_template.c b/media/ffvpx/libavcodec/videodsp_template.c index 55123a584468..324d70f2cb26 100644 --- a/media/ffvpx/libavcodec/videodsp_template.c +++ b/media/ffvpx/libavcodec/videodsp_template.c @@ -20,6 +20,10 @@ */ #include "bit_depth_template.c" +#if BIT_DEPTH != 8 +// ff_emulated_edge_mc_8 is used by the x86 MpegVideoDSP API. +static +#endif void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src, ptrdiff_t buf_linesize, ptrdiff_t src_linesize, diff --git a/media/ffvpx/libavcodec/vlc.c b/media/ffvpx/libavcodec/vlc.c new file mode 100644 index 000000000000..96f2b28c7e61 --- /dev/null +++ b/media/ffvpx/libavcodec/vlc.c @@ -0,0 +1,378 @@ +/* + * API for creating VLC trees + * Copyright (c) 2000, 2001 Fabrice Bellard + * Copyright (c) 2002-2004 Michael Niedermayer + * Copyright (c) 2010 Loren Merritt + * + * 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 +#include +#include +#include + +#include "libavutil/attributes.h" +#include "libavutil/avassert.h" +#include "libavutil/error.h" +#include "libavutil/internal.h" +#include "libavutil/log.h" +#include "libavutil/macros.h" +#include "libavutil/mem.h" +#include "libavutil/qsort.h" +#include "libavutil/reverse.h" +#include "vlc.h" + +#define GET_DATA(v, table, i, wrap, size) \ +{ \ + const uint8_t *ptr = (const uint8_t *)table + i * wrap; \ + switch(size) { \ + case 1: \ + v = *(const uint8_t *)ptr; \ + break; \ + case 2: \ + v = *(const uint16_t *)ptr; \ + break; \ + case 4: \ + default: \ + av_assert1(size == 4); \ + v = *(const uint32_t *)ptr; \ + break; \ + } \ +} + + +static int alloc_table(VLC *vlc, int size, int use_static) +{ + int index = vlc->table_size; + + vlc->table_size += size; + if (vlc->table_size > vlc->table_allocated) { + if (use_static) + abort(); // cannot do anything, init_vlc() is used with too little memory + vlc->table_allocated += (1 << vlc->bits); + vlc->table = av_realloc_f(vlc->table, vlc->table_allocated, sizeof(*vlc->table)); + if (!vlc->table) { + vlc->table_allocated = 0; + vlc->table_size = 0; + return AVERROR(ENOMEM); + } + memset(vlc->table + vlc->table_allocated - (1 << vlc->bits), 0, sizeof(*vlc->table) << vlc->bits); + } + return index; +} + +#define LOCALBUF_ELEMS 1500 // the maximum currently needed is 1296 by rv34 + +static av_always_inline uint32_t bitswap_32(uint32_t x) +{ + return (uint32_t)ff_reverse[ x & 0xFF] << 24 | + (uint32_t)ff_reverse[(x >> 8) & 0xFF] << 16 | + (uint32_t)ff_reverse[(x >> 16) & 0xFF] << 8 | + (uint32_t)ff_reverse[ x >> 24]; +} + +typedef struct VLCcode { + uint8_t bits; + VLCBaseType symbol; + /** codeword, with the first bit-to-be-read in the msb + * (even if intended for a little-endian bitstream reader) */ + uint32_t code; +} VLCcode; + +static int vlc_common_init(VLC *vlc, int nb_bits, int nb_codes, + VLCcode **buf, int flags) +{ + vlc->bits = nb_bits; + vlc->table_size = 0; + if (flags & INIT_VLC_USE_NEW_STATIC) { + av_assert0(nb_codes <= LOCALBUF_ELEMS); + } else { + vlc->table = NULL; + vlc->table_allocated = 0; + } + if (nb_codes > LOCALBUF_ELEMS) { + *buf = av_malloc_array(nb_codes, sizeof(VLCcode)); + if (!*buf) + return AVERROR(ENOMEM); + } + + return 0; +} + +static int compare_vlcspec(const void *a, const void *b) +{ + const VLCcode *sa = a, *sb = b; + return (sa->code >> 1) - (sb->code >> 1); +} + +/** + * Build VLC decoding tables suitable for use with get_vlc(). + * + * @param vlc the context to be initialized + * + * @param table_nb_bits max length of vlc codes to store directly in this table + * (Longer codes are delegated to subtables.) + * + * @param nb_codes number of elements in codes[] + * + * @param codes descriptions of the vlc codes + * These must be ordered such that codes going into the same subtable are contiguous. + * Sorting by VLCcode.code is sufficient, though not necessary. + */ +static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, + VLCcode *codes, int flags) +{ + int table_size, table_index; + VLCElem *table; + + if (table_nb_bits > 30) + return AVERROR(EINVAL); + table_size = 1 << table_nb_bits; + table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); + ff_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size); + if (table_index < 0) + return table_index; + table = &vlc->table[table_index]; + + /* first pass: map codes and compute auxiliary table sizes */ + for (int i = 0; i < nb_codes; i++) { + int n = codes[i].bits; + uint32_t code = codes[i].code; + int symbol = codes[i].symbol; + ff_dlog(NULL, "i=%d n=%d code=0x%"PRIx32"\n", i, n, code); + if (n <= table_nb_bits) { + /* no need to add another table */ + int j = code >> (32 - table_nb_bits); + int nb = 1 << (table_nb_bits - n); + int inc = 1; + + if (flags & INIT_VLC_OUTPUT_LE) { + j = bitswap_32(code); + inc = 1 << n; + } + for (int k = 0; k < nb; k++) { + int bits = table[j].len; + int oldsym = table[j].sym; + ff_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n); + if ((bits || oldsym) && (bits != n || oldsym != symbol)) { + av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); + return AVERROR_INVALIDDATA; + } + table[j].len = n; + table[j].sym = symbol; + j += inc; + } + } else { + /* fill auxiliary table recursively */ + uint32_t code_prefix; + int index, subtable_bits, j, k; + + n -= table_nb_bits; + code_prefix = code >> (32 - table_nb_bits); + subtable_bits = n; + codes[i].bits = n; + codes[i].code = code << table_nb_bits; + for (k = i + 1; k < nb_codes; k++) { + n = codes[k].bits - table_nb_bits; + if (n <= 0) + break; + code = codes[k].code; + if (code >> (32 - table_nb_bits) != code_prefix) + break; + codes[k].bits = n; + codes[k].code = code << table_nb_bits; + subtable_bits = FFMAX(subtable_bits, n); + } + subtable_bits = FFMIN(subtable_bits, table_nb_bits); + j = (flags & INIT_VLC_OUTPUT_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix; + table[j].len = -subtable_bits; + ff_dlog(NULL, "%4x: n=%d (subtable)\n", + j, codes[i].bits + table_nb_bits); + index = build_table(vlc, subtable_bits, k-i, codes+i, flags); + if (index < 0) + return index; + /* note: realloc has been done, so reload tables */ + table = &vlc->table[table_index]; + table[j].sym = index; + if (table[j].sym != index) { + avpriv_request_sample(NULL, "strange codes"); + return AVERROR_PATCHWELCOME; + } + i = k-1; + } + } + + for (int i = 0; i < table_size; i++) { + if (table[i].len == 0) + table[i].sym = -1; + } + + return table_index; +} + +static int vlc_common_end(VLC *vlc, int nb_bits, int nb_codes, VLCcode *codes, + int flags, VLCcode localbuf[LOCALBUF_ELEMS]) +{ + int ret = build_table(vlc, nb_bits, nb_codes, codes, flags); + + if (flags & INIT_VLC_USE_NEW_STATIC) { + if (vlc->table_size != vlc->table_allocated && + !(flags & (INIT_VLC_STATIC_OVERLONG & ~INIT_VLC_USE_NEW_STATIC))) + av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", vlc->table_size, vlc->table_allocated); + av_assert0(ret >= 0); + } else { + if (codes != localbuf) + av_free(codes); + if (ret < 0) { + av_freep(&vlc->table); + return ret; + } + } + return 0; +} + +/* Build VLC decoding tables suitable for use with get_vlc(). + + 'nb_bits' sets the decoding table size (2^nb_bits) entries. The + bigger it is, the faster is the decoding. But it should not be too + big to save memory and L1 cache. '9' is a good compromise. + + 'nb_codes' : number of vlcs codes + + 'bits' : table which gives the size (in bits) of each vlc code. + + 'codes' : table which gives the bit pattern of of each vlc code. + + 'symbols' : table which gives the values to be returned from get_vlc(). + + 'xxx_wrap' : give the number of bytes between each entry of the + 'bits' or 'codes' tables. + + 'xxx_size' : gives the number of bytes of each entry of the 'bits' + or 'codes' tables. Currently 1,2 and 4 are supported. + + 'wrap' and 'size' make it possible to use any memory configuration and types + (byte/word/long) to store the 'bits', 'codes', and 'symbols' tables. +*/ +int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, + const void *bits, int bits_wrap, int bits_size, + const void *codes, int codes_wrap, int codes_size, + const void *symbols, int symbols_wrap, int symbols_size, + int flags) +{ + VLCcode localbuf[LOCALBUF_ELEMS], *buf = localbuf; + int j, ret; + + ret = vlc_common_init(vlc, nb_bits, nb_codes, &buf, flags); + if (ret < 0) + return ret; + + av_assert0(symbols_size <= 2 || !symbols); + j = 0; +#define COPY(condition)\ + for (int i = 0; i < nb_codes; i++) { \ + unsigned len; \ + GET_DATA(len, bits, i, bits_wrap, bits_size); \ + if (!(condition)) \ + continue; \ + if (len > 3*nb_bits || len > 32) { \ + av_log(NULL, AV_LOG_ERROR, "Too long VLC (%u) in init_vlc\n", len);\ + if (buf != localbuf) \ + av_free(buf); \ + return AVERROR(EINVAL); \ + } \ + buf[j].bits = len; \ + GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size); \ + if (buf[j].code >= (1LL< nb_bits); + // qsort is the slowest part of init_vlc, and could probably be improved or avoided + AV_QSORT(buf, j, struct VLCcode, compare_vlcspec); + COPY(len && len <= nb_bits); + nb_codes = j; + + return vlc_common_end(vlc, nb_bits, nb_codes, buf, + flags, localbuf); +} + +int ff_init_vlc_from_lengths(VLC *vlc, int nb_bits, int nb_codes, + const int8_t *lens, int lens_wrap, + const void *symbols, int symbols_wrap, int symbols_size, + int offset, int flags, void *logctx) +{ + VLCcode localbuf[LOCALBUF_ELEMS], *buf = localbuf; + uint64_t code; + int ret, j, len_max = FFMIN(32, 3 * nb_bits); + + ret = vlc_common_init(vlc, nb_bits, nb_codes, &buf, flags); + if (ret < 0) + return ret; + + j = code = 0; + for (int i = 0; i < nb_codes; i++, lens += lens_wrap) { + int len = *lens; + if (len > 0) { + unsigned sym; + + buf[j].bits = len; + if (symbols) + GET_DATA(sym, symbols, i, symbols_wrap, symbols_size) + else + sym = i; + buf[j].symbol = sym + offset; + buf[j++].code = code; + } else if (len < 0) { + len = -len; + } else + continue; + if (len > len_max || code & ((1U << (32 - len)) - 1)) { + av_log(logctx, AV_LOG_ERROR, "Invalid VLC (length %u)\n", len); + goto fail; + } + code += 1U << (32 - len); + if (code > UINT32_MAX + 1ULL) { + av_log(logctx, AV_LOG_ERROR, "Overdetermined VLC tree\n"); + goto fail; + } + } + return vlc_common_end(vlc, nb_bits, j, buf, flags, localbuf); +fail: + if (buf != localbuf) + av_free(buf); + return AVERROR_INVALIDDATA; +} + +void ff_free_vlc(VLC *vlc) +{ + av_freep(&vlc->table); +} diff --git a/media/ffvpx/libavcodec/vlc.h b/media/ffvpx/libavcodec/vlc.h index 6879c3ca6a7c..e63c484755aa 100644 --- a/media/ffvpx/libavcodec/vlc.h +++ b/media/ffvpx/libavcodec/vlc.h @@ -21,11 +21,16 @@ #include -#define VLC_TYPE int16_t +// When changing this, be sure to also update tableprint_vlc.h accordingly. +typedef int16_t VLCBaseType; + +typedef struct VLCElem { + VLCBaseType sym, len; +} VLCElem; typedef struct VLC { int bits; - VLC_TYPE (*table)[2]; ///< code, bits + VLCElem *table; int table_size, table_allocated; } VLC; @@ -98,7 +103,7 @@ void ff_free_vlc(VLC *vlc); #define INIT_CUSTOM_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, \ h, i, j, flags, static_size) \ do { \ - static VLC_TYPE table[static_size][2]; \ + static VLCElem table[static_size]; \ (vlc)->table = table; \ (vlc)->table_allocated = static_size; \ ff_init_vlc_sparse(vlc, bits, a, b, c, d, e, f, g, h, i, j, \ @@ -127,7 +132,7 @@ void ff_free_vlc(VLC *vlc); symbols, symbols_wrap, symbols_size, \ offset, flags, static_size) \ do { \ - static VLC_TYPE table[static_size][2]; \ + static VLCElem table[static_size]; \ (vlc)->table = table; \ (vlc)->table_allocated = static_size; \ ff_init_vlc_from_lengths(vlc, bits, nb_codes, lens, len_wrap, \ diff --git a/media/ffvpx/libavcodec/vorbis_parser.c b/media/ffvpx/libavcodec/vorbis_parser.c index 0b2c97cde583..a7d15d4ce999 100644 --- a/media/ffvpx/libavcodec/vorbis_parser.c +++ b/media/ffvpx/libavcodec/vorbis_parser.c @@ -25,6 +25,8 @@ * Determines the duration for each packet. */ +#include "config_components.h" + #include "libavutil/log.h" #include "get_bits.h" @@ -332,7 +334,7 @@ static void vorbis_parser_close(AVCodecParserContext *ctx) av_vorbis_parse_free(&s->vp); } -AVCodecParser ff_vorbis_parser = { +const AVCodecParser ff_vorbis_parser = { .codec_ids = { AV_CODEC_ID_VORBIS }, .priv_data_size = sizeof(VorbisParseContext), .parser_parse = vorbis_parse, diff --git a/media/ffvpx/libavcodec/vp56.h b/media/ffvpx/libavcodec/vp56.h index 46090f25c93c..d2e6ad3ed004 100644 --- a/media/ffvpx/libavcodec/vp56.h +++ b/media/ffvpx/libavcodec/vp56.h @@ -216,14 +216,16 @@ struct vp56_context { }; -int ff_vp56_init(AVCodecContext *avctx, int flip, int has_alpha); +/** + * Initializes an VP56Context. Expects its caller to clean up + * in case of error. + */ int ff_vp56_init_context(AVCodecContext *avctx, VP56Context *s, int flip, int has_alpha); -int ff_vp56_free(AVCodecContext *avctx); int ff_vp56_free_context(VP56Context *s); void ff_vp56_init_dequant(VP56Context *s, int quantizer); -int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, - AVPacket *avpkt); +int ff_vp56_decode_frame(AVCodecContext *avctx, AVFrame *frame, + int *got_frame, AVPacket *avpkt); /** diff --git a/media/ffvpx/libavcodec/vp56rac.c b/media/ffvpx/libavcodec/vp56rac.c index 64fb6a99b4fb..19e7dcf2bb89 100644 --- a/media/ffvpx/libavcodec/vp56rac.c +++ b/media/ffvpx/libavcodec/vp56rac.c @@ -19,7 +19,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/common.h" +#include +#include "libavutil/error.h" +#include "bytestream.h" #include "vp56.h" const uint8_t ff_vp56_norm_shift[256]= { diff --git a/media/ffvpx/libavcodec/vp8.c b/media/ffvpx/libavcodec/vp8.c index d16e7b6aa34e..f521f2c9de56 100644 --- a/media/ffvpx/libavcodec/vp8.c +++ b/media/ffvpx/libavcodec/vp8.c @@ -24,15 +24,19 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config_components.h" + #include "libavutil/imgutils.h" #include "libavutil/mem_internal.h" #include "avcodec.h" +#include "codec_internal.h" #include "hwconfig.h" #include "internal.h" #include "mathops.h" #include "rectangle.h" #include "thread.h" +#include "threadframe.h" #include "vp8.h" #include "vp8data.h" @@ -71,8 +75,8 @@ static void free_buffers(VP8Context *s) static int vp8_alloc_frame(VP8Context *s, VP8Frame *f, int ref) { int ret; - if ((ret = ff_thread_get_buffer(s->avctx, &f->tf, - ref ? AV_GET_BUFFER_FLAG_REF : 0)) < 0) + if ((ret = ff_thread_get_ext_buffer(s->avctx, &f->tf, + ref ? AV_GET_BUFFER_FLAG_REF : 0)) < 0) return ret; if (!(f->seg_map = av_buffer_allocz(s->mb_width * s->mb_height))) goto fail; @@ -89,7 +93,7 @@ static int vp8_alloc_frame(VP8Context *s, VP8Frame *f, int ref) fail: av_buffer_unref(&f->seg_map); - ff_thread_release_buffer(s->avctx, &f->tf); + ff_thread_release_ext_buffer(s->avctx, &f->tf); return AVERROR(ENOMEM); } @@ -98,7 +102,7 @@ static void vp8_release_frame(VP8Context *s, VP8Frame *f) av_buffer_unref(&f->seg_map); av_buffer_unref(&f->hwaccel_priv_buf); f->hwaccel_picture_private = NULL; - ff_thread_release_buffer(s->avctx, &f->tf); + ff_thread_release_ext_buffer(s->avctx, &f->tf); } #if CONFIG_VP8_DECODER @@ -2621,7 +2625,7 @@ static int vp8_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata, } static av_always_inline -int vp78_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, +int vp78_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, const AVPacket *avpkt, int is_vp7) { VP8Context *s = avctx->priv_data; @@ -2719,7 +2723,7 @@ int vp78_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, s->next_framep[VP56_FRAME_CURRENT] = curframe; - if (avctx->codec->update_thread_context) + if (ffcodec(avctx->codec)->update_thread_context) ff_thread_finish_setup(avctx); if (avctx->hwaccel) { @@ -2796,7 +2800,7 @@ skip_decode: s->prob[0] = s->prob[1]; if (!s->invisible) { - if ((ret = av_frame_ref(data, curframe->tf.f)) < 0) + if ((ret = av_frame_ref(rframe, curframe->tf.f)) < 0) return ret; *got_frame = 1; } @@ -2807,17 +2811,17 @@ err: return ret; } -int ff_vp8_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, - AVPacket *avpkt) +int ff_vp8_decode_frame(AVCodecContext *avctx, AVFrame *frame, + int *got_frame, AVPacket *avpkt) { - return vp78_decode_frame(avctx, data, got_frame, avpkt, IS_VP8); + return vp78_decode_frame(avctx, frame, got_frame, avpkt, IS_VP8); } #if CONFIG_VP7_DECODER -static int vp7_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, - AVPacket *avpkt) +static int vp7_decode_frame(AVCodecContext *avctx, AVFrame *frame, + int *got_frame, AVPacket *avpkt) { - return vp78_decode_frame(avctx, data, got_frame, avpkt, IS_VP7); + return vp78_decode_frame(avctx, frame, got_frame, avpkt, IS_VP7); } #endif /* CONFIG_VP7_DECODER */ @@ -2826,9 +2830,6 @@ av_cold int ff_vp8_decode_free(AVCodecContext *avctx) VP8Context *s = avctx->priv_data; int i; - if (!s) - return 0; - vp8_decode_flush_impl(avctx, 1); for (i = 0; i < FF_ARRAY_ELEMS(s->frames); i++) av_frame_free(&s->frames[i].tf.f); @@ -2938,32 +2939,35 @@ static int vp8_decode_update_thread_context(AVCodecContext *dst, #endif /* CONFIG_VP8_DECODER */ #if CONFIG_VP7_DECODER -AVCodec ff_vp7_decoder = { - .name = "vp7", - .long_name = NULL_IF_CONFIG_SMALL("On2 VP7"), - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_VP7, +const FFCodec ff_vp7_decoder = { + .p.name = "vp7", + .p.long_name = NULL_IF_CONFIG_SMALL("On2 VP7"), + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_VP7, .priv_data_size = sizeof(VP8Context), .init = vp7_decode_init, .close = ff_vp8_decode_free, - .decode = vp7_decode_frame, - .capabilities = AV_CODEC_CAP_DR1, + FF_CODEC_DECODE_CB(vp7_decode_frame), + .p.capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .flush = vp8_decode_flush, }; #endif /* CONFIG_VP7_DECODER */ #if CONFIG_VP8_DECODER -AVCodec ff_vp8_decoder = { - .name = "vp8", - .long_name = NULL_IF_CONFIG_SMALL("On2 VP8"), - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_VP8, +const FFCodec ff_vp8_decoder = { + .p.name = "vp8", + .p.long_name = NULL_IF_CONFIG_SMALL("On2 VP8"), + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_VP8, .priv_data_size = sizeof(VP8Context), .init = ff_vp8_decode_init, .close = ff_vp8_decode_free, - .decode = ff_vp8_decode_frame, - .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + FF_CODEC_DECODE_CB(ff_vp8_decode_frame), + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | + FF_CODEC_CAP_ALLOCATE_PROGRESS, .flush = vp8_decode_flush, .update_thread_context = ONLY_IF_THREADS_ENABLED(vp8_decode_update_thread_context), .hw_configs = (const AVCodecHWConfigInternal *const []) { @@ -2975,6 +2979,5 @@ AVCodec ff_vp8_decoder = { #endif NULL }, - .caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS, }; #endif /* CONFIG_VP7_DECODER */ diff --git a/media/ffvpx/libavcodec/vp8.h b/media/ffvpx/libavcodec/vp8.h index e6091dfe042d..8fe45573ed01 100644 --- a/media/ffvpx/libavcodec/vp8.h +++ b/media/ffvpx/libavcodec/vp8.h @@ -33,7 +33,7 @@ #include "libavutil/thread.h" #include "h264pred.h" -#include "thread.h" +#include "threadframe.h" #include "vp56.h" #include "vp8dsp.h" @@ -344,8 +344,8 @@ typedef struct VP8Context { int ff_vp8_decode_init(AVCodecContext *avctx); -int ff_vp8_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, - AVPacket *avpkt); +int ff_vp8_decode_frame(AVCodecContext *avctx, AVFrame *frame, + int *got_frame, AVPacket *avpkt); int ff_vp8_decode_free(AVCodecContext *avctx); diff --git a/media/ffvpx/libavcodec/vp8_parser.c b/media/ffvpx/libavcodec/vp8_parser.c index 7ce35e7535ce..98b752bfb9d7 100644 --- a/media/ffvpx/libavcodec/vp8_parser.c +++ b/media/ffvpx/libavcodec/vp8_parser.c @@ -73,7 +73,7 @@ static int parse(AVCodecParserContext *s, return buf_size; } -AVCodecParser ff_vp8_parser = { +const AVCodecParser ff_vp8_parser = { .codec_ids = { AV_CODEC_ID_VP8 }, .parser_parse = parse, }; diff --git a/media/ffvpx/libavcodec/vp8dsp.c b/media/ffvpx/libavcodec/vp8dsp.c index 4ff63d078425..a92774ed5ee3 100644 --- a/media/ffvpx/libavcodec/vp8dsp.c +++ b/media/ffvpx/libavcodec/vp8dsp.c @@ -25,6 +25,8 @@ * VP8 compatible video decoder */ +#include "config_components.h" + #include "libavutil/common.h" #include "libavutil/intreadwrite.h" @@ -673,14 +675,15 @@ av_cold void ff_vp78dsp_init(VP8DSPContext *dsp) VP78_BILINEAR_MC_FUNC(1, 8); VP78_BILINEAR_MC_FUNC(2, 4); - if (ARCH_AARCH64) - ff_vp78dsp_init_aarch64(dsp); - if (ARCH_ARM) - ff_vp78dsp_init_arm(dsp); - if (ARCH_PPC) - ff_vp78dsp_init_ppc(dsp); - if (ARCH_X86) - ff_vp78dsp_init_x86(dsp); +#if ARCH_AARCH64 + ff_vp78dsp_init_aarch64(dsp); +#elif ARCH_ARM + ff_vp78dsp_init_arm(dsp); +#elif ARCH_PPC + ff_vp78dsp_init_ppc(dsp); +#elif ARCH_X86 + ff_vp78dsp_init_x86(dsp); +#endif } #if CONFIG_VP7_DECODER @@ -735,13 +738,16 @@ av_cold void ff_vp8dsp_init(VP8DSPContext *dsp) dsp->vp8_v_loop_filter_simple = vp8_v_loop_filter_simple_c; dsp->vp8_h_loop_filter_simple = vp8_h_loop_filter_simple_c; - if (ARCH_AARCH64) - ff_vp8dsp_init_aarch64(dsp); - if (ARCH_ARM) - ff_vp8dsp_init_arm(dsp); - if (ARCH_X86) - ff_vp8dsp_init_x86(dsp); - if (ARCH_MIPS) - ff_vp8dsp_init_mips(dsp); +#if ARCH_AARCH64 + ff_vp8dsp_init_aarch64(dsp); +#elif ARCH_ARM + ff_vp8dsp_init_arm(dsp); +#elif ARCH_X86 + ff_vp8dsp_init_x86(dsp); +#elif ARCH_MIPS + ff_vp8dsp_init_mips(dsp); +#elif ARCH_LOONGARCH + ff_vp8dsp_init_loongarch(dsp); +#endif } #endif /* CONFIG_VP8_DECODER */ diff --git a/media/ffvpx/libavcodec/vp8dsp.h b/media/ffvpx/libavcodec/vp8dsp.h index cfe1524b0b38..7c6208df397b 100644 --- a/media/ffvpx/libavcodec/vp8dsp.h +++ b/media/ffvpx/libavcodec/vp8dsp.h @@ -101,6 +101,7 @@ void ff_vp8dsp_init_aarch64(VP8DSPContext *c); void ff_vp8dsp_init_arm(VP8DSPContext *c); void ff_vp8dsp_init_x86(VP8DSPContext *c); void ff_vp8dsp_init_mips(VP8DSPContext *c); +void ff_vp8dsp_init_loongarch(VP8DSPContext *c); #define IS_VP7 1 #define IS_VP8 0 diff --git a/media/ffvpx/libavcodec/vp9.c b/media/ffvpx/libavcodec/vp9.c index 4659f94ee8b6..fee79fb45bb3 100644 --- a/media/ffvpx/libavcodec/vp9.c +++ b/media/ffvpx/libavcodec/vp9.c @@ -21,12 +21,18 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config_components.h" + #include "avcodec.h" +#include "codec_internal.h" #include "get_bits.h" #include "hwconfig.h" #include "internal.h" #include "profiles.h" #include "thread.h" +#include "threadframe.h" +#include "pthread_internal.h" + #include "videodsp.h" #include "vp56.h" #include "vp9.h" @@ -39,15 +45,9 @@ #define VP9_SYNCCODE 0x498342 #if HAVE_THREADS -static void vp9_free_entries(AVCodecContext *avctx) { - VP9Context *s = avctx->priv_data; - - if (avctx->active_thread_type & FF_THREAD_SLICE) { - pthread_mutex_destroy(&s->progress_mutex); - pthread_cond_destroy(&s->progress_cond); - av_freep(&s->entries); - } -} +DEFINE_OFFSET_ARRAY(VP9Context, vp9_context, pthread_init_cnt, + (offsetof(VP9Context, progress_mutex)), + (offsetof(VP9Context, progress_cond))); static int vp9_alloc_entries(AVCodecContext *avctx, int n) { VP9Context *s = avctx->priv_data; @@ -58,17 +58,11 @@ static int vp9_alloc_entries(AVCodecContext *avctx, int n) { av_freep(&s->entries); s->entries = av_malloc_array(n, sizeof(atomic_int)); - - if (!s->entries) { - av_freep(&s->entries); + if (!s->entries) return AVERROR(ENOMEM); - } for (i = 0; i < n; i++) atomic_init(&s->entries[i], 0); - - pthread_mutex_init(&s->progress_mutex, NULL); - pthread_cond_init(&s->progress_cond, NULL); } return 0; } @@ -90,7 +84,6 @@ static void vp9_await_tile_progress(VP9Context *s, int field, int n) { pthread_mutex_unlock(&s->progress_mutex); } #else -static void vp9_free_entries(AVCodecContext *avctx) {} static int vp9_alloc_entries(AVCodecContext *avctx, int n) { return 0; } #endif @@ -103,7 +96,7 @@ static void vp9_tile_data_free(VP9TileData *td) static void vp9_frame_unref(AVCodecContext *avctx, VP9Frame *f) { - ff_thread_release_buffer(avctx, &f->tf); + ff_thread_release_ext_buffer(avctx, &f->tf); av_buffer_unref(&f->extradata); av_buffer_unref(&f->hwaccel_priv_buf); f->segmentation_map = NULL; @@ -115,7 +108,7 @@ static int vp9_frame_alloc(AVCodecContext *avctx, VP9Frame *f) VP9Context *s = avctx->priv_data; int ret, sz; - ret = ff_thread_get_buffer(avctx, &f->tf, AV_GET_BUFFER_FLAG_REF); + ret = ff_thread_get_ext_buffer(avctx, &f->tf, AV_GET_BUFFER_FLAG_REF); if (ret < 0) return ret; @@ -192,7 +185,8 @@ static int update_size(AVCodecContext *avctx, int w, int h) CONFIG_VP9_D3D11VA_HWACCEL * 2 + \ CONFIG_VP9_NVDEC_HWACCEL + \ CONFIG_VP9_VAAPI_HWACCEL + \ - CONFIG_VP9_VDPAU_HWACCEL) + CONFIG_VP9_VDPAU_HWACCEL + \ + CONFIG_VP9_VIDEOTOOLBOX_HWACCEL) enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts; VP9Context *s = avctx->priv_data; uint8_t *p; @@ -223,6 +217,9 @@ static int update_size(AVCodecContext *avctx, int w, int h) #endif #if CONFIG_VP9_VDPAU_HWACCEL *fmtp++ = AV_PIX_FMT_VDPAU; +#endif +#if CONFIG_VP9_VIDEOTOOLBOX_HWACCEL + *fmtp++ = AV_PIX_FMT_VIDEOTOOLBOX; #endif break; case AV_PIX_FMT_YUV420P12: @@ -792,11 +789,10 @@ static int decode_frame_header(AVCodecContext *avctx, if (s->td) { for (i = 0; i < s->active_tile_cols; i++) vp9_tile_data_free(&s->td[i]); - av_free(s->td); + av_freep(&s->td); } s->s.h.tiling.tile_cols = 1 << s->s.h.tiling.log2_tile_cols; - vp9_free_entries(avctx); s->active_tile_cols = avctx->active_thread_type == FF_THREAD_SLICE ? s->s.h.tiling.tile_cols : 1; vp9_alloc_entries(avctx, s->sb_rows); @@ -805,7 +801,7 @@ static int decode_frame_header(AVCodecContext *avctx, } else { n_range_coders = s->s.h.tiling.tile_cols; } - s->td = av_mallocz_array(s->active_tile_cols, sizeof(VP9TileData) + + s->td = av_calloc(s->active_tile_cols, sizeof(VP9TileData) + n_range_coders * sizeof(VP56RangeCoder)); if (!s->td) return AVERROR(ENOMEM); @@ -1244,14 +1240,17 @@ static av_cold int vp9_decode_free(AVCodecContext *avctx) } av_buffer_pool_uninit(&s->frame_extradata_pool); for (i = 0; i < 8; i++) { - ff_thread_release_buffer(avctx, &s->s.refs[i]); + ff_thread_release_ext_buffer(avctx, &s->s.refs[i]); av_frame_free(&s->s.refs[i].f); - ff_thread_release_buffer(avctx, &s->next_refs[i]); + ff_thread_release_ext_buffer(avctx, &s->next_refs[i]); av_frame_free(&s->next_refs[i].f); } free_buffers(s); - vp9_free_entries(avctx); +#if HAVE_THREADS + av_freep(&s->entries); + ff_pthread_free(s, vp9_context_offsets); +#endif av_freep(&s->td); return 0; } @@ -1551,7 +1550,7 @@ static int vp9_export_enc_params(VP9Context *s, VP9Frame *frame) return 0; } -static int vp9_decode_frame(AVCodecContext *avctx, void *frame, +static int vp9_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt) { const uint8_t *data = pkt->data; @@ -1571,16 +1570,11 @@ static int vp9_decode_frame(AVCodecContext *avctx, void *frame, } if ((ret = av_frame_ref(frame, s->s.refs[ref].f)) < 0) return ret; - ((AVFrame *)frame)->pts = pkt->pts; -#if FF_API_PKT_PTS -FF_DISABLE_DEPRECATION_WARNINGS - ((AVFrame *)frame)->pkt_pts = pkt->pts; -FF_ENABLE_DEPRECATION_WARNINGS -#endif - ((AVFrame *)frame)->pkt_dts = pkt->dts; + frame->pts = pkt->pts; + frame->pkt_dts = pkt->dts; for (i = 0; i < 8; i++) { if (s->next_refs[i].f->buf[0]) - ff_thread_release_buffer(avctx, &s->next_refs[i]); + ff_thread_release_ext_buffer(avctx, &s->next_refs[i]); if (s->s.refs[i].f->buf[0] && (ret = ff_thread_ref_frame(&s->next_refs[i], &s->s.refs[i])) < 0) return ret; @@ -1620,7 +1614,7 @@ FF_ENABLE_DEPRECATION_WARNINGS // ref frame setup for (i = 0; i < 8; i++) { if (s->next_refs[i].f->buf[0]) - ff_thread_release_buffer(avctx, &s->next_refs[i]); + ff_thread_release_ext_buffer(avctx, &s->next_refs[i]); if (s->s.h.refreshrefmask & (1 << i)) { ret = ff_thread_ref_frame(&s->next_refs[i], &s->s.frames[CUR_FRAME].tf); } else if (s->s.refs[i].f->buf[0]) { @@ -1769,7 +1763,7 @@ finish: // ref frame setup for (i = 0; i < 8; i++) { if (s->s.refs[i].f->buf[0]) - ff_thread_release_buffer(avctx, &s->s.refs[i]); + ff_thread_release_ext_buffer(avctx, &s->s.refs[i]); if (s->next_refs[i].f->buf[0] && (ret = ff_thread_ref_frame(&s->s.refs[i], &s->next_refs[i])) < 0) return ret; @@ -1792,43 +1786,37 @@ static void vp9_decode_flush(AVCodecContext *avctx) for (i = 0; i < 3; i++) vp9_frame_unref(avctx, &s->s.frames[i]); for (i = 0; i < 8; i++) - ff_thread_release_buffer(avctx, &s->s.refs[i]); -} - -static int init_frames(AVCodecContext *avctx) -{ - VP9Context *s = avctx->priv_data; - int i; - - for (i = 0; i < 3; i++) { - s->s.frames[i].tf.f = av_frame_alloc(); - if (!s->s.frames[i].tf.f) { - vp9_decode_free(avctx); - av_log(avctx, AV_LOG_ERROR, "Failed to allocate frame buffer %d\n", i); - return AVERROR(ENOMEM); - } - } - for (i = 0; i < 8; i++) { - s->s.refs[i].f = av_frame_alloc(); - s->next_refs[i].f = av_frame_alloc(); - if (!s->s.refs[i].f || !s->next_refs[i].f) { - vp9_decode_free(avctx); - av_log(avctx, AV_LOG_ERROR, "Failed to allocate frame buffer %d\n", i); - return AVERROR(ENOMEM); - } - } - - return 0; + ff_thread_release_ext_buffer(avctx, &s->s.refs[i]); } static av_cold int vp9_decode_init(AVCodecContext *avctx) { VP9Context *s = avctx->priv_data; + int ret; s->last_bpp = 0; s->s.h.filter.sharpness = -1; - return init_frames(avctx); +#if HAVE_THREADS + if (avctx->active_thread_type & FF_THREAD_SLICE) { + ret = ff_pthread_init(s, vp9_context_offsets); + if (ret < 0) + return ret; + } +#endif + + for (int i = 0; i < 3; i++) { + s->s.frames[i].tf.f = av_frame_alloc(); + if (!s->s.frames[i].tf.f) + return AVERROR(ENOMEM); + } + for (int i = 0; i < 8; i++) { + s->s.refs[i].f = av_frame_alloc(); + s->next_refs[i].f = av_frame_alloc(); + if (!s->s.refs[i].f || !s->next_refs[i].f) + return AVERROR(ENOMEM); + } + return 0; } #if HAVE_THREADS @@ -1847,7 +1835,7 @@ static int vp9_decode_update_thread_context(AVCodecContext *dst, const AVCodecCo } for (i = 0; i < 8; i++) { if (s->s.refs[i].f->buf[0]) - ff_thread_release_buffer(dst, &s->s.refs[i]); + ff_thread_release_ext_buffer(dst, &s->s.refs[i]); if (ssrc->next_refs[i].f->buf[0]) { if ((ret = ff_thread_ref_frame(&s->s.refs[i], &ssrc->next_refs[i])) < 0) return ret; @@ -1878,21 +1866,22 @@ static int vp9_decode_update_thread_context(AVCodecContext *dst, const AVCodecCo } #endif -AVCodec ff_vp9_decoder = { - .name = "vp9", - .long_name = NULL_IF_CONFIG_SMALL("Google VP9"), - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_VP9, +const FFCodec ff_vp9_decoder = { + .p.name = "vp9", + .p.long_name = NULL_IF_CONFIG_SMALL("Google VP9"), + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_VP9, .priv_data_size = sizeof(VP9Context), .init = vp9_decode_init, .close = vp9_decode_free, - .decode = vp9_decode_frame, - .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS, - .caps_internal = FF_CODEC_CAP_SLICE_THREAD_HAS_MF | + FF_CODEC_DECODE_CB(vp9_decode_frame), + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP | + FF_CODEC_CAP_SLICE_THREAD_HAS_MF | FF_CODEC_CAP_ALLOCATE_PROGRESS, .flush = vp9_decode_flush, .update_thread_context = ONLY_IF_THREADS_ENABLED(vp9_decode_update_thread_context), - .profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles), + .p.profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles), .bsfs = "vp9_superframe_split", .hw_configs = (const AVCodecHWConfigInternal *const []) { #if CONFIG_VP9_DXVA2_HWACCEL @@ -1912,6 +1901,9 @@ AVCodec ff_vp9_decoder = { #endif #if CONFIG_VP9_VDPAU_HWACCEL HWACCEL_VDPAU(vp9), +#endif +#if CONFIG_VP9_VIDEOTOOLBOX_HWACCEL + HWACCEL_VIDEOTOOLBOX(vp9), #endif NULL }, diff --git a/media/ffvpx/libavcodec/vp9_parser.c b/media/ffvpx/libavcodec/vp9_parser.c index c957a75667b5..ffcb93505f24 100644 --- a/media/ffvpx/libavcodec/vp9_parser.c +++ b/media/ffvpx/libavcodec/vp9_parser.c @@ -64,7 +64,7 @@ static int parse(AVCodecParserContext *ctx, return size; } -AVCodecParser ff_vp9_parser = { +const AVCodecParser ff_vp9_parser = { .codec_ids = { AV_CODEC_ID_VP9 }, .parser_parse = parse, }; diff --git a/media/ffvpx/libavcodec/vp9_superframe_split_bsf.c b/media/ffvpx/libavcodec/vp9_superframe_split_bsf.c index ed0444561acd..cddd48119ce2 100644 --- a/media/ffvpx/libavcodec/vp9_superframe_split_bsf.c +++ b/media/ffvpx/libavcodec/vp9_superframe_split_bsf.c @@ -51,6 +51,9 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, AVPacket *out) return ret; in = s->buffer_pkt; + if (!in->size) + goto passthrough; + marker = in->data[in->size - 1]; if ((marker & 0xe0) == 0xc0) { int length_size = 1 + ((marker >> 3) & 0x3); @@ -70,7 +73,7 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, AVPacket *out) frame_size |= bytestream2_get_byte(&bc) << (j * 8); total_size += frame_size; - if (frame_size < 0 || total_size > in->size - idx_size) { + if (frame_size <= 0 || total_size > in->size - idx_size) { av_log(ctx, AV_LOG_ERROR, "Invalid frame size in a superframe: %d\n", frame_size); ret = AVERROR(EINVAL); @@ -121,6 +124,7 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, AVPacket *out) out->pts = AV_NOPTS_VALUE; } else { +passthrough: av_packet_move_ref(out, s->buffer_pkt); } @@ -155,12 +159,12 @@ static void vp9_superframe_split_uninit(AVBSFContext *ctx) av_packet_free(&s->buffer_pkt); } -const AVBitStreamFilter ff_vp9_superframe_split_bsf = { - .name = "vp9_superframe_split", +const FFBitStreamFilter ff_vp9_superframe_split_bsf = { + .p.name = "vp9_superframe_split", + .p.codec_ids = (const enum AVCodecID []){ AV_CODEC_ID_VP9, AV_CODEC_ID_NONE }, .priv_data_size = sizeof(VP9SFSplitContext), .init = vp9_superframe_split_init, .flush = vp9_superframe_split_flush, .close = vp9_superframe_split_uninit, .filter = vp9_superframe_split_filter, - .codec_ids = (const enum AVCodecID []){ AV_CODEC_ID_VP9, AV_CODEC_ID_NONE }, }; diff --git a/media/ffvpx/libavcodec/vp9block.c b/media/ffvpx/libavcodec/vp9block.c index ec16e26c6985..5fdda6354540 100644 --- a/media/ffvpx/libavcodec/vp9block.c +++ b/media/ffvpx/libavcodec/vp9block.c @@ -23,9 +23,7 @@ #include "libavutil/avassert.h" -#include "avcodec.h" -#include "internal.h" -#include "videodsp.h" +#include "threadframe.h" #include "vp56.h" #include "vp9.h" #include "vp9data.h" diff --git a/media/ffvpx/libavcodec/vp9dec.h b/media/ffvpx/libavcodec/vp9dec.h index d82b258a3d81..9cbd5839a8ac 100644 --- a/media/ffvpx/libavcodec/vp9dec.h +++ b/media/ffvpx/libavcodec/vp9dec.h @@ -105,6 +105,7 @@ typedef struct VP9Context { pthread_mutex_t progress_mutex; pthread_cond_t progress_cond; atomic_int *entries; + unsigned pthread_init_cnt; #endif uint8_t ss_h, ss_v; diff --git a/media/ffvpx/libavcodec/vp9dsp.c b/media/ffvpx/libavcodec/vp9dsp.c index 41b8ad1ad17e..d8ddf74d4fb9 100644 --- a/media/ffvpx/libavcodec/vp9dsp.c +++ b/media/ffvpx/libavcodec/vp9dsp.c @@ -21,8 +21,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" + +#include "libavutil/attributes.h" #include "libavutil/avassert.h" -#include "libavutil/common.h" #include "libavutil/mem_internal.h" #include "vp9dsp.h" @@ -94,8 +96,15 @@ av_cold void ff_vp9dsp_init(VP9DSPContext *dsp, int bpp, int bitexact) ff_vp9dsp_init_12(dsp); } - if (ARCH_AARCH64) ff_vp9dsp_init_aarch64(dsp, bpp); - if (ARCH_ARM) ff_vp9dsp_init_arm(dsp, bpp); - if (ARCH_X86) ff_vp9dsp_init_x86(dsp, bpp, bitexact); - if (ARCH_MIPS) ff_vp9dsp_init_mips(dsp, bpp); +#if ARCH_AARCH64 + ff_vp9dsp_init_aarch64(dsp, bpp); +#elif ARCH_ARM + ff_vp9dsp_init_arm(dsp, bpp); +#elif ARCH_X86 + ff_vp9dsp_init_x86(dsp, bpp, bitexact); +#elif ARCH_MIPS + ff_vp9dsp_init_mips(dsp, bpp); +#elif ARCH_LOONGARCH + ff_vp9dsp_init_loongarch(dsp, bpp); +#endif } diff --git a/media/ffvpx/libavcodec/vp9dsp.h b/media/ffvpx/libavcodec/vp9dsp.h index e2256316a8f5..700dd72de8ef 100644 --- a/media/ffvpx/libavcodec/vp9dsp.h +++ b/media/ffvpx/libavcodec/vp9dsp.h @@ -132,5 +132,6 @@ void ff_vp9dsp_init_aarch64(VP9DSPContext *dsp, int bpp); void ff_vp9dsp_init_arm(VP9DSPContext *dsp, int bpp); void ff_vp9dsp_init_x86(VP9DSPContext *dsp, int bpp, int bitexact); void ff_vp9dsp_init_mips(VP9DSPContext *dsp, int bpp); +void ff_vp9dsp_init_loongarch(VP9DSPContext *dsp, int bpp); #endif /* AVCODEC_VP9DSP_H */ diff --git a/media/ffvpx/libavcodec/vp9mvs.c b/media/ffvpx/libavcodec/vp9mvs.c index 88db1c341c16..ddce9b6c84ad 100644 --- a/media/ffvpx/libavcodec/vp9mvs.c +++ b/media/ffvpx/libavcodec/vp9mvs.c @@ -21,7 +21,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "internal.h" +#include "threadframe.h" #include "vp56.h" #include "vp9.h" #include "vp9data.h" diff --git a/media/ffvpx/libavcodec/vp9recon.c b/media/ffvpx/libavcodec/vp9recon.c index e38cf99ec570..bfafde8c9c30 100644 --- a/media/ffvpx/libavcodec/vp9recon.c +++ b/media/ffvpx/libavcodec/vp9recon.c @@ -24,8 +24,7 @@ #include "libavutil/avassert.h" #include "libavutil/mem_internal.h" -#include "avcodec.h" -#include "internal.h" +#include "threadframe.h" #include "videodsp.h" #include "vp9data.h" #include "vp9dec.h" diff --git a/media/ffvpx/libavcodec/vp9shared.h b/media/ffvpx/libavcodec/vp9shared.h index 54726df742f9..ebaa11d2c19a 100644 --- a/media/ffvpx/libavcodec/vp9shared.h +++ b/media/ffvpx/libavcodec/vp9shared.h @@ -28,7 +28,7 @@ #include #include "vp9.h" -#include "thread.h" +#include "threadframe.h" #include "vp56.h" enum BlockPartition { diff --git a/media/ffvpx/libavcodec/x86/dct32.asm b/media/ffvpx/libavcodec/x86/dct32.asm index 21e2f21c97b9..37fba51543dd 100644 --- a/media/ffvpx/libavcodec/x86/dct32.asm +++ b/media/ffvpx/libavcodec/x86/dct32.asm @@ -387,7 +387,7 @@ INIT_XMM %endif -; void ff_dct32_float_sse(FFTSample *out, const FFTSample *in) +; void ff_dct32_float(FFTSample *out, const FFTSample *in) %macro DCT32_FUNC 0 cglobal dct32_float, 2, 3, 16, out, in, tmp ; pass 1 @@ -474,18 +474,8 @@ cglobal dct32_float, 2, 3, 16, out, in, tmp %endmacro %macro LOAD_INV 2 -%if cpuflag(sse2) pshufd %1, %2, 0x1b -%elif cpuflag(sse) - movaps %1, %2 - shufps %1, %1, 0x1b -%endif %endmacro -%if ARCH_X86_32 -INIT_XMM sse -DCT32_FUNC -%endif - INIT_XMM sse2 DCT32_FUNC diff --git a/media/ffvpx/libavcodec/x86/dct_init.c b/media/ffvpx/libavcodec/x86/dct_init.c index c31ef92238b1..d0e4b34dd321 100644 --- a/media/ffvpx/libavcodec/x86/dct_init.c +++ b/media/ffvpx/libavcodec/x86/dct_init.c @@ -22,7 +22,6 @@ #include "libavutil/x86/cpu.h" #include "libavcodec/dct.h" -void ff_dct32_float_sse(FFTSample *out, const FFTSample *in); void ff_dct32_float_sse2(FFTSample *out, const FFTSample *in); void ff_dct32_float_avx(FFTSample *out, const FFTSample *in); @@ -30,10 +29,6 @@ av_cold void ff_dct_init_x86(DCTContext *s) { int cpu_flags = av_get_cpu_flags(); -#if ARCH_X86_32 - if (EXTERNAL_SSE(cpu_flags)) - s->dct32 = ff_dct32_float_sse; -#endif if (EXTERNAL_SSE2(cpu_flags)) s->dct32 = ff_dct32_float_sse2; if (EXTERNAL_AVX_FAST(cpu_flags)) diff --git a/media/ffvpx/libavcodec/x86/fdct.c b/media/ffvpx/libavcodec/x86/fdct.c index d77f60c86fe5..f4677ff4bed3 100644 --- a/media/ffvpx/libavcodec/x86/fdct.c +++ b/media/ffvpx/libavcodec/x86/fdct.c @@ -30,12 +30,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/common.h" +#include "config.h" +#include "libavutil/attributes.h" +#include "libavutil/macros.h" #include "libavutil/mem_internal.h" #include "libavutil/x86/asm.h" #include "fdct.h" -#if HAVE_MMX_INLINE +#if HAVE_SSE2_INLINE ////////////////////////////////////////////////////////////////////// // @@ -69,8 +71,6 @@ DECLARE_ALIGNED(16, static const int16_t, ocos_4_16)[8] = { DECLARE_ALIGNED(16, static const int16_t, fdct_one_corr)[8] = { X8(1) }; -DECLARE_ALIGNED(8, static const int32_t, fdct_r_row)[2] = {RND_FRW_ROW, RND_FRW_ROW }; - static const struct { DECLARE_ALIGNED(16, const int32_t, fdct_r_row_sse2)[4]; @@ -80,80 +80,6 @@ static const struct }}; //DECLARE_ALIGNED(16, static const long, fdct_r_row_sse2)[4] = {RND_FRW_ROW, RND_FRW_ROW, RND_FRW_ROW, RND_FRW_ROW}; -DECLARE_ALIGNED(8, static const int16_t, tab_frw_01234567)[] = { // forward_dct coeff table - 16384, 16384, 22725, 19266, - 16384, 16384, 12873, 4520, - 21407, 8867, 19266, -4520, - -8867, -21407, -22725, -12873, - 16384, -16384, 12873, -22725, - -16384, 16384, 4520, 19266, - 8867, -21407, 4520, -12873, - 21407, -8867, 19266, -22725, - - 22725, 22725, 31521, 26722, - 22725, 22725, 17855, 6270, - 29692, 12299, 26722, -6270, - -12299, -29692, -31521, -17855, - 22725, -22725, 17855, -31521, - -22725, 22725, 6270, 26722, - 12299, -29692, 6270, -17855, - 29692, -12299, 26722, -31521, - - 21407, 21407, 29692, 25172, - 21407, 21407, 16819, 5906, - 27969, 11585, 25172, -5906, - -11585, -27969, -29692, -16819, - 21407, -21407, 16819, -29692, - -21407, 21407, 5906, 25172, - 11585, -27969, 5906, -16819, - 27969, -11585, 25172, -29692, - - 19266, 19266, 26722, 22654, - 19266, 19266, 15137, 5315, - 25172, 10426, 22654, -5315, - -10426, -25172, -26722, -15137, - 19266, -19266, 15137, -26722, - -19266, 19266, 5315, 22654, - 10426, -25172, 5315, -15137, - 25172, -10426, 22654, -26722, - - 16384, 16384, 22725, 19266, - 16384, 16384, 12873, 4520, - 21407, 8867, 19266, -4520, - -8867, -21407, -22725, -12873, - 16384, -16384, 12873, -22725, - -16384, 16384, 4520, 19266, - 8867, -21407, 4520, -12873, - 21407, -8867, 19266, -22725, - - 19266, 19266, 26722, 22654, - 19266, 19266, 15137, 5315, - 25172, 10426, 22654, -5315, - -10426, -25172, -26722, -15137, - 19266, -19266, 15137, -26722, - -19266, 19266, 5315, 22654, - 10426, -25172, 5315, -15137, - 25172, -10426, 22654, -26722, - - 21407, 21407, 29692, 25172, - 21407, 21407, 16819, 5906, - 27969, 11585, 25172, -5906, - -11585, -27969, -29692, -16819, - 21407, -21407, 16819, -29692, - -21407, 21407, 5906, 25172, - 11585, -27969, 5906, -16819, - 27969, -11585, 25172, -29692, - - 22725, 22725, 31521, 26722, - 22725, 22725, 17855, 6270, - 29692, 12299, 26722, -6270, - -12299, -29692, -31521, -17855, - 22725, -22725, 17855, -31521, - -22725, 22725, 6270, 26722, - 12299, -29692, 6270, -17855, - 29692, -12299, 26722, -31521, -}; - static const struct { DECLARE_ALIGNED(16, const int16_t, tab_frw_01234567_sse2)[256]; @@ -373,7 +299,6 @@ static av_always_inline void fdct_col_##cpu(const int16_t *in, int16_t *out, int "r" (out + offset), "r" (ocos_4_16)); \ } -FDCT_COL(mmx, mm, movq) FDCT_COL(sse2, xmm, movdqa) static av_always_inline void fdct_row_sse2(const int16_t *in, int16_t *out) @@ -441,148 +366,6 @@ static av_always_inline void fdct_row_sse2(const int16_t *in, int16_t *out) ); } -static av_always_inline void fdct_row_mmxext(const int16_t *in, int16_t *out, - const int16_t *table) -{ - __asm__ volatile ( - "pshufw $0x1B, 8(%0), %%mm5 \n\t" - "movq (%0), %%mm0 \n\t" - "movq %%mm0, %%mm1 \n\t" - "paddsw %%mm5, %%mm0 \n\t" - "psubsw %%mm5, %%mm1 \n\t" - "movq %%mm0, %%mm2 \n\t" - "punpckldq %%mm1, %%mm0 \n\t" - "punpckhdq %%mm1, %%mm2 \n\t" - "movq (%1), %%mm1 \n\t" - "movq 8(%1), %%mm3 \n\t" - "movq 16(%1), %%mm4 \n\t" - "movq 24(%1), %%mm5 \n\t" - "movq 32(%1), %%mm6 \n\t" - "movq 40(%1), %%mm7 \n\t" - "pmaddwd %%mm0, %%mm1 \n\t" - "pmaddwd %%mm2, %%mm3 \n\t" - "pmaddwd %%mm0, %%mm4 \n\t" - "pmaddwd %%mm2, %%mm5 \n\t" - "pmaddwd %%mm0, %%mm6 \n\t" - "pmaddwd %%mm2, %%mm7 \n\t" - "pmaddwd 48(%1), %%mm0 \n\t" - "pmaddwd 56(%1), %%mm2 \n\t" - "paddd %%mm1, %%mm3 \n\t" - "paddd %%mm4, %%mm5 \n\t" - "paddd %%mm6, %%mm7 \n\t" - "paddd %%mm0, %%mm2 \n\t" - "movq (%2), %%mm0 \n\t" - "paddd %%mm0, %%mm3 \n\t" - "paddd %%mm0, %%mm5 \n\t" - "paddd %%mm0, %%mm7 \n\t" - "paddd %%mm0, %%mm2 \n\t" - "psrad $"S(SHIFT_FRW_ROW)", %%mm3 \n\t" - "psrad $"S(SHIFT_FRW_ROW)", %%mm5 \n\t" - "psrad $"S(SHIFT_FRW_ROW)", %%mm7 \n\t" - "psrad $"S(SHIFT_FRW_ROW)", %%mm2 \n\t" - "packssdw %%mm5, %%mm3 \n\t" - "packssdw %%mm2, %%mm7 \n\t" - "movq %%mm3, (%3) \n\t" - "movq %%mm7, 8(%3) \n\t" - : - : "r" (in), "r" (table), "r" (fdct_r_row), "r" (out)); -} - -static av_always_inline void fdct_row_mmx(const int16_t *in, int16_t *out, const int16_t *table) -{ - //FIXME reorder (I do not have an old MMX-only CPU here to benchmark ...) - __asm__ volatile( - "movd 12(%0), %%mm1 \n\t" - "punpcklwd 8(%0), %%mm1 \n\t" - "movq %%mm1, %%mm2 \n\t" - "psrlq $0x20, %%mm1 \n\t" - "movq 0(%0), %%mm0 \n\t" - "punpcklwd %%mm2, %%mm1 \n\t" - "movq %%mm0, %%mm5 \n\t" - "paddsw %%mm1, %%mm0 \n\t" - "psubsw %%mm1, %%mm5 \n\t" - "movq %%mm0, %%mm2 \n\t" - "punpckldq %%mm5, %%mm0 \n\t" - "punpckhdq %%mm5, %%mm2 \n\t" - "movq 0(%1), %%mm1 \n\t" - "movq 8(%1), %%mm3 \n\t" - "movq 16(%1), %%mm4 \n\t" - "movq 24(%1), %%mm5 \n\t" - "movq 32(%1), %%mm6 \n\t" - "movq 40(%1), %%mm7 \n\t" - "pmaddwd %%mm0, %%mm1 \n\t" - "pmaddwd %%mm2, %%mm3 \n\t" - "pmaddwd %%mm0, %%mm4 \n\t" - "pmaddwd %%mm2, %%mm5 \n\t" - "pmaddwd %%mm0, %%mm6 \n\t" - "pmaddwd %%mm2, %%mm7 \n\t" - "pmaddwd 48(%1), %%mm0 \n\t" - "pmaddwd 56(%1), %%mm2 \n\t" - "paddd %%mm1, %%mm3 \n\t" - "paddd %%mm4, %%mm5 \n\t" - "paddd %%mm6, %%mm7 \n\t" - "paddd %%mm0, %%mm2 \n\t" - "movq (%2), %%mm0 \n\t" - "paddd %%mm0, %%mm3 \n\t" - "paddd %%mm0, %%mm5 \n\t" - "paddd %%mm0, %%mm7 \n\t" - "paddd %%mm0, %%mm2 \n\t" - "psrad $"S(SHIFT_FRW_ROW)", %%mm3 \n\t" - "psrad $"S(SHIFT_FRW_ROW)", %%mm5 \n\t" - "psrad $"S(SHIFT_FRW_ROW)", %%mm7 \n\t" - "psrad $"S(SHIFT_FRW_ROW)", %%mm2 \n\t" - "packssdw %%mm5, %%mm3 \n\t" - "packssdw %%mm2, %%mm7 \n\t" - "movq %%mm3, 0(%3) \n\t" - "movq %%mm7, 8(%3) \n\t" - : - : "r" (in), "r" (table), "r" (fdct_r_row), "r" (out)); -} - -void ff_fdct_mmx(int16_t *block) -{ - DECLARE_ALIGNED(8, int64_t, align_tmp)[16]; - int16_t * block1= (int16_t*)align_tmp; - const int16_t *table= tab_frw_01234567; - int i; - - fdct_col_mmx(block, block1, 0); - fdct_col_mmx(block, block1, 4); - - for(i=8;i>0;i--) { - fdct_row_mmx(block1, block, table); - block1 += 8; - table += 32; - block += 8; - } -} - -#endif /* HAVE_MMX_INLINE */ - -#if HAVE_MMXEXT_INLINE - -void ff_fdct_mmxext(int16_t *block) -{ - DECLARE_ALIGNED(8, int64_t, align_tmp)[16]; - int16_t *block1= (int16_t*)align_tmp; - const int16_t *table= tab_frw_01234567; - int i; - - fdct_col_mmx(block, block1, 0); - fdct_col_mmx(block, block1, 4); - - for(i=8;i>0;i--) { - fdct_row_mmxext(block1, block, table); - block1 += 8; - table += 32; - block += 8; - } -} - -#endif /* HAVE_MMXEXT_INLINE */ - -#if HAVE_SSE2_INLINE - void ff_fdct_sse2(int16_t *block) { DECLARE_ALIGNED(16, int64_t, align_tmp)[16]; diff --git a/media/ffvpx/libavcodec/x86/fdct.h b/media/ffvpx/libavcodec/x86/fdct.h index 648cdc5350f4..164d4fb30e92 100644 --- a/media/ffvpx/libavcodec/x86/fdct.h +++ b/media/ffvpx/libavcodec/x86/fdct.h @@ -21,8 +21,6 @@ #include -void ff_fdct_mmx(int16_t *block); -void ff_fdct_mmxext(int16_t *block); void ff_fdct_sse2(int16_t *block); #endif /* AVCODEC_X86_FDCT_H */ diff --git a/media/ffvpx/libavcodec/x86/fdctdsp_init.c b/media/ffvpx/libavcodec/x86/fdctdsp_init.c index 0cb5fd625b3d..92a842433ddb 100644 --- a/media/ffvpx/libavcodec/x86/fdctdsp_init.c +++ b/media/ffvpx/libavcodec/x86/fdctdsp_init.c @@ -31,12 +31,6 @@ av_cold void ff_fdctdsp_init_x86(FDCTDSPContext *c, AVCodecContext *avctx, if (!high_bit_depth) { if ((dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX)) { - if (INLINE_MMX(cpu_flags)) - c->fdct = ff_fdct_mmx; - - if (INLINE_MMXEXT(cpu_flags)) - c->fdct = ff_fdct_mmxext; - if (INLINE_SSE2(cpu_flags)) c->fdct = ff_fdct_sse2; } diff --git a/media/ffvpx/libavcodec/x86/fft.asm b/media/ffvpx/libavcodec/x86/fft.asm index a671e8f48e58..a44596e5655c 100644 --- a/media/ffvpx/libavcodec/x86/fft.asm +++ b/media/ffvpx/libavcodec/x86/fft.asm @@ -1,5 +1,5 @@ ;****************************************************************************** -;* FFT transform with SSE/3DNow optimizations +;* FFT transform with SSE/AVX optimizations ;* Copyright (c) 2008 Loren Merritt ;* Copyright (c) 2011 Vitor Sessak ;* @@ -92,29 +92,6 @@ cextern cos_ %+ i SECTION .text -%macro T2_3DNOW 4 ; z0, z1, mem0, mem1 - mova %1, %3 - mova %2, %1 - pfadd %1, %4 - pfsub %2, %4 -%endmacro - -%macro T4_3DNOW 6 ; z0, z1, z2, z3, tmp0, tmp1 - mova %5, %3 - pfsub %3, %4 - pfadd %5, %4 ; {t6,t5} - pxor %3, [ps_m1p1] ; {t8,t7} - mova %6, %1 - movd [r0+12], %3 - punpckhdq %3, [r0+8] - pfadd %1, %5 ; {r0,i0} - pfsub %6, %5 ; {r2,i2} - mova %4, %2 - pfadd %2, %3 ; {r1,i1} - pfsub %4, %3 ; {r3,i3} - SWAP %3, %6 -%endmacro - ; in: %1 = {r0,i0,r2,i2,r4,i4,r6,i6} ; %2 = {r1,i1,r3,i3,r5,i5,r7,i7} ; %3, %4, %5 tmp @@ -199,7 +176,7 @@ SECTION .text vextractf128 %4 %+ H(%5), %3, 0 vextractf128 %4(%5 + 1), %2, 1 vextractf128 %4 %+ H(%5 + 1), %3, 1 -%elif cpuflag(sse) || cpuflag(3dnow) +%elif cpuflag(sse) mova %3, %2 unpcklps %2, %1 unpckhps %3, %1 @@ -310,12 +287,6 @@ IF%1 mova Z(1), m5 %endif %endmacro -%macro PUNPCK 3 - mova %3, %1 - punpckldq %1, %2 - punpckhdq %3, %2 -%endmacro - %define Z(x) [r0+mmsize*x] %define Z2(x) [r0+mmsize*x] %define ZH(x) [r0+mmsize*x+mmsize/2] @@ -462,68 +433,6 @@ fft16_sse: ret -%macro FFT48_3DNOW 0 -align 16 -fft4 %+ SUFFIX: - T2_3DNOW m0, m1, Z(0), Z(1) - mova m2, Z(2) - mova m3, Z(3) - T4_3DNOW m0, m1, m2, m3, m4, m5 - PUNPCK m0, m1, m4 - PUNPCK m2, m3, m5 - mova Z(0), m0 - mova Z(1), m4 - mova Z(2), m2 - mova Z(3), m5 - ret - -align 16 -fft8 %+ SUFFIX: - T2_3DNOW m0, m1, Z(0), Z(1) - mova m2, Z(2) - mova m3, Z(3) - T4_3DNOW m0, m1, m2, m3, m4, m5 - mova Z(0), m0 - mova Z(2), m2 - T2_3DNOW m4, m5, Z(4), Z(5) - T2_3DNOW m6, m7, Z2(6), Z2(7) - PSWAPD m0, m5 - PSWAPD m2, m7 - pxor m0, [ps_m1p1] - pxor m2, [ps_m1p1] - pfsub m5, m0 - pfadd m7, m2 - pfmul m5, [ps_root2] - pfmul m7, [ps_root2] - T4_3DNOW m1, m3, m5, m7, m0, m2 - mova Z(5), m5 - mova Z2(7), m7 - mova m0, Z(0) - mova m2, Z(2) - T4_3DNOW m0, m2, m4, m6, m5, m7 - PUNPCK m0, m1, m5 - PUNPCK m2, m3, m7 - mova Z(0), m0 - mova Z(1), m5 - mova Z(2), m2 - mova Z(3), m7 - PUNPCK m4, Z(5), m5 - PUNPCK m6, Z2(7), m7 - mova Z(4), m4 - mova Z(5), m5 - mova Z2(6), m6 - mova Z2(7), m7 - ret -%endmacro - -%if ARCH_X86_32 -INIT_MMX 3dnowext -FFT48_3DNOW - -INIT_MMX 3dnow -FFT48_3DNOW -%endif - %define Z(x) [zcq + o1q*(x&6) + mmsize*(x&1)] %define Z2(x) [zcq + o3q + mmsize*(x&1)] %define ZH(x) [zcq + o1q*(x&6) + mmsize*(x&1) + mmsize/2] @@ -575,7 +484,7 @@ INIT_XMM sse DECL_PASS pass_sse, PASS_BIG 1 DECL_PASS pass_interleave_sse, PASS_BIG 0 -%macro FFT_CALC_FUNC 0 +INIT_XMM sse cglobal fft_calc, 2,5,8 mov r3d, [r0 + FFTContext.nbits] PUSH r1 @@ -592,36 +501,16 @@ cglobal fft_calc, 2,5,8 shl r2, cl sub r4, r2 .loop: -%if mmsize == 8 - PSWAPD m0, [r4 + r2 + 4] - mova [r4 + r2 + 4], m0 -%else movaps xmm0, [r4 + r2] movaps xmm1, xmm0 unpcklps xmm0, [r4 + r2 + 16] unpckhps xmm1, [r4 + r2 + 16] movaps [r4 + r2], xmm0 movaps [r4 + r2 + 16], xmm1 -%endif add r2, mmsize*2 jl .loop .end: -%if cpuflag(3dnow) - femms - RET -%else REP_RET -%endif -%endmacro - -%if ARCH_X86_32 -INIT_MMX 3dnow -FFT_CALC_FUNC -INIT_MMX 3dnowext -FFT_CALC_FUNC -%endif -INIT_XMM sse -FFT_CALC_FUNC cglobal fft_permute, 2,7,1 mov r4, [r0 + FFTContext.revtab] @@ -656,7 +545,7 @@ cglobal fft_permute, 2,7,1 jl .loopcopy REP_RET -%macro IMDCT_CALC_FUNC 0 +INIT_XMM sse cglobal imdct_calc, 3,5,3 mov r3d, [r0 + FFTContext.mdctsize] mov r4, [r0 + FFTContext.imdcthalf] @@ -684,52 +573,17 @@ cglobal imdct_calc, 3,5,3 neg r2 mova m2, [ps_neg] .loop: -%if mmsize == 8 - PSWAPD m0, [r1 + r3] - PSWAPD m1, [r0 + r2] - pxor m0, m2 -%else mova m0, [r1 + r3] mova m1, [r0 + r2] shufps m0, m0, 0x1b shufps m1, m1, 0x1b xorps m0, m2 -%endif mova [r0 + r3], m1 mova [r1 + r2], m0 sub r3, mmsize add r2, mmsize jl .loop -%if cpuflag(3dnow) - femms - RET -%else REP_RET -%endif -%endmacro - -%if ARCH_X86_32 -INIT_MMX 3dnow -IMDCT_CALC_FUNC -INIT_MMX 3dnowext -IMDCT_CALC_FUNC -%endif - -INIT_XMM sse -IMDCT_CALC_FUNC - -%if ARCH_X86_32 -INIT_MMX 3dnow -%define mulps pfmul -%define addps pfadd -%define subps pfsub -%define unpcklps punpckldq -%define unpckhps punpckhdq -DECL_PASS pass_3dnow, PASS_SMALL 1, [wq], [wq+o1q] -DECL_PASS pass_interleave_3dnow, PASS_BIG 0 -%define pass_3dnowext pass_3dnow -%define pass_interleave_3dnowext pass_interleave_3dnow -%endif %ifdef PIC %define SECTION_REL - $$ @@ -785,14 +639,6 @@ DECL_FFT 6, _interleave INIT_XMM sse DECL_FFT 5 DECL_FFT 5, _interleave -%if ARCH_X86_32 -INIT_MMX 3dnow -DECL_FFT 4 -DECL_FFT 4, _interleave -INIT_MMX 3dnowext -DECL_FFT 4 -DECL_FFT 4, _interleave -%endif INIT_XMM sse %undef mulps @@ -802,37 +648,6 @@ INIT_XMM sse %undef unpckhps %macro PREROTATER 5 ;-2*k, 2*k, input+n4, tcos+n8, tsin+n8 -%if mmsize == 8 ; j*2+2-n4, n4-2-j*2, input+n4, tcos+n8, tsin+n8 - PSWAPD m0, [%3+%2*4] - movq m2, [%3+%1*4-8] - movq m3, m0 - punpckldq m0, m2 - punpckhdq m2, m3 - movd m1, [%4+%1*2-4] ; tcos[j] - movd m3, [%4+%2*2] ; tcos[n4-j-1] - punpckldq m1, [%5+%1*2-4] ; tsin[j] - punpckldq m3, [%5+%2*2] ; tsin[n4-j-1] - - mova m4, m0 - PSWAPD m5, m1 - pfmul m0, m1 - pfmul m4, m5 - mova m6, m2 - PSWAPD m5, m3 - pfmul m2, m3 - pfmul m6, m5 -%if cpuflag(3dnowext) - pfpnacc m0, m4 - pfpnacc m2, m6 -%else - SBUTTERFLY dq, 0, 4, 1 - SBUTTERFLY dq, 2, 6, 3 - pxor m4, m7 - pxor m6, m7 - pfadd m0, m4 - pfadd m2, m6 -%endif -%else movaps xmm0, [%3+%2*4] movaps xmm1, [%3+%1*4-0x10] movaps xmm2, xmm0 @@ -853,29 +668,15 @@ INIT_XMM sse movaps xmm0, xmm1 unpcklps xmm1, xmm2 unpckhps xmm0, xmm2 -%endif %endmacro %macro CMUL 6 ;j, xmm0, xmm1, 3, 4, 5 -%if cpuflag(sse) mulps m6, %3, [%5+%1] mulps m7, %2, [%5+%1] mulps %2, %2, [%6+%1] mulps %3, %3, [%6+%1] subps %2, %2, m6 addps %3, %3, m7 -%elif cpuflag(3dnow) - mova m6, [%1+%2*2] - mova %3, [%1+%2*2+8] - mova %4, m6 - mova m7, %3 - pfmul m6, [%5+%2] - pfmul %3, [%6+%2] - pfmul %4, [%6+%2] - pfmul m7, [%5+%2] - pfsub %3, m6 - pfadd %4, m7 -%endif %endmacro %macro POSROTATESHUF 5 ;j, k, z+n8, tcos+n8, tsin+n8 @@ -909,7 +710,7 @@ INIT_XMM sse sub %2, 0x20 add %1, 0x20 jl .post -%elif cpuflag(sse) +%else movaps xmm1, [%3+%1*2] movaps xmm0, [%3+%1*2+0x10] CMUL %1, xmm0, xmm1, %3, %4, %5 @@ -931,24 +732,6 @@ INIT_XMM sse sub %2, 0x10 add %1, 0x10 jl .post -%elif cpuflag(3dnow) - CMUL %3, %1, m0, m1, %4, %5 - CMUL %3, %2, m2, m3, %4, %5 - movd [%3+%1*2+ 0], m0 - movd [%3+%2*2+12], m1 - movd [%3+%2*2+ 0], m2 - movd [%3+%1*2+12], m3 - psrlq m0, 32 - psrlq m1, 32 - psrlq m2, 32 - psrlq m3, 32 - movd [%3+%1*2+ 8], m0 - movd [%3+%2*2+ 4], m1 - movd [%3+%2*2+ 8], m2 - movd [%3+%1*2+ 4], m3 - sub %2, 8 - add %1, 8 - jl .post %endif %endmacro @@ -981,39 +764,21 @@ cglobal imdct_half, 3,12,8; FFTContext *s, FFTSample *output, const FFTSample *i push rrevtab %endif -%if mmsize == 8 - sub r3, 2 -%else sub r3, 4 -%endif -%if ARCH_X86_64 || mmsize == 8 +%if ARCH_X86_64 xor r4, r4 sub r4, r3 %endif -%if notcpuflag(3dnowext) && mmsize == 8 - movd m7, [ps_neg] -%endif .pre: %if ARCH_X86_64 == 0 ;unspill -%if mmsize != 8 xor r4, r4 sub r4, r3 -%endif mov rtcos, [esp+8] mov rtsin, [esp+4] %endif PREROTATER r4, r3, r2, rtcos, rtsin -%if mmsize == 8 - mov r6, [esp] ; rrevtab = ptr+n8 - movzx r5, word [rrevtab+r4-2] ; rrevtab[j] - movzx r6, word [rrevtab+r3] ; rrevtab[n4-j-1] - mova [r1+r5*8], m0 - mova [r1+r6*8], m2 - add r4, 2 - sub r3, 2 -%else %if ARCH_X86_64 movzx r5, word [rrevtab+r4-4] movzx r6, word [rrevtab+r4-2] @@ -1036,7 +801,6 @@ cglobal imdct_half, 3,12,8; FFTContext *s, FFTSample *output, const FFTSample *i movhps [r1+r4*8], xmm1 %endif sub r3, 4 -%endif jns .pre mov r5, r0 @@ -1061,23 +825,12 @@ cglobal imdct_half, 3,12,8; FFTContext *s, FFTSample *output, const FFTSample *i POSROTATESHUF r0, r1, r6, rtcos, rtsin %if ARCH_X86_64 == 0 add esp, 12 -%endif -%if mmsize == 8 - femms %endif RET %endmacro DECL_IMDCT -%if ARCH_X86_32 -INIT_MMX 3dnow -DECL_IMDCT - -INIT_MMX 3dnowext -DECL_IMDCT -%endif - INIT_YMM avx %if HAVE_AVX_EXTERNAL diff --git a/media/ffvpx/libavcodec/x86/fft.h b/media/ffvpx/libavcodec/x86/fft.h index 398091eb1f58..37418ec1f4b8 100644 --- a/media/ffvpx/libavcodec/x86/fft.h +++ b/media/ffvpx/libavcodec/x86/fft.h @@ -24,13 +24,7 @@ void ff_fft_permute_sse(FFTContext *s, FFTComplex *z); void ff_fft_calc_avx(FFTContext *s, FFTComplex *z); void ff_fft_calc_sse(FFTContext *s, FFTComplex *z); -void ff_fft_calc_3dnow(FFTContext *s, FFTComplex *z); -void ff_fft_calc_3dnowext(FFTContext *s, FFTComplex *z); -void ff_imdct_calc_3dnow(FFTContext *s, FFTSample *output, const FFTSample *input); -void ff_imdct_half_3dnow(FFTContext *s, FFTSample *output, const FFTSample *input); -void ff_imdct_calc_3dnowext(FFTContext *s, FFTSample *output, const FFTSample *input); -void ff_imdct_half_3dnowext(FFTContext *s, FFTSample *output, const FFTSample *input); void ff_imdct_calc_sse(FFTContext *s, FFTSample *output, const FFTSample *input); void ff_imdct_half_sse(FFTContext *s, FFTSample *output, const FFTSample *input); void ff_imdct_half_avx(FFTContext *s, FFTSample *output, const FFTSample *input); diff --git a/media/ffvpx/libavcodec/x86/fft_init.c b/media/ffvpx/libavcodec/x86/fft_init.c index 928f1dcda72c..df79d57dc765 100644 --- a/media/ffvpx/libavcodec/x86/fft_init.c +++ b/media/ffvpx/libavcodec/x86/fft_init.c @@ -31,20 +31,6 @@ av_cold void ff_fft_init_x86(FFTContext *s) if (s->nbits > 16) return; -#if ARCH_X86_32 - if (EXTERNAL_AMD3DNOW(cpu_flags)) { - s->imdct_calc = ff_imdct_calc_3dnow; - s->imdct_half = ff_imdct_half_3dnow; - s->fft_calc = ff_fft_calc_3dnow; - } - - if (EXTERNAL_AMD3DNOWEXT(cpu_flags)) { - s->imdct_calc = ff_imdct_calc_3dnowext; - s->imdct_half = ff_imdct_half_3dnowext; - s->fft_calc = ff_fft_calc_3dnowext; - } -#endif /* ARCH_X86_32 */ - if (EXTERNAL_SSE(cpu_flags)) { s->imdct_calc = ff_imdct_calc_sse; s->imdct_half = ff_imdct_half_sse; diff --git a/media/ffvpx/libavcodec/x86/flacdsp_init.c b/media/ffvpx/libavcodec/x86/flacdsp_init.c index 1971f81b8dea..ed2e5ed15bf1 100644 --- a/media/ffvpx/libavcodec/x86/flacdsp_init.c +++ b/media/ffvpx/libavcodec/x86/flacdsp_init.c @@ -18,9 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/attributes.h" #include "libavcodec/flacdsp.h" #include "libavutil/x86/cpu.h" #include "config.h" +#include "config_components.h" void ff_flac_lpc_32_sse4(int32_t *samples, const int coeffs[32], int order, int qlevel, int len); diff --git a/media/ffvpx/libavcodec/x86/h264_intrapred.asm b/media/ffvpx/libavcodec/x86/h264_intrapred.asm index b36c198fbb6b..31840a14720f 100644 --- a/media/ffvpx/libavcodec/x86/h264_intrapred.asm +++ b/media/ffvpx/libavcodec/x86/h264_intrapred.asm @@ -48,22 +48,6 @@ cextern pw_8 ; void ff_pred16x16_vertical_8(uint8_t *src, ptrdiff_t stride) ;----------------------------------------------------------------------------- -INIT_MMX mmx -cglobal pred16x16_vertical_8, 2,3 - sub r0, r1 - mov r2, 8 - movq mm0, [r0+0] - movq mm1, [r0+8] -.loop: - movq [r0+r1*1+0], mm0 - movq [r0+r1*1+8], mm1 - movq [r0+r1*2+0], mm0 - movq [r0+r1*2+8], mm1 - lea r0, [r0+r1*2] - dec r2 - jg .loop - REP_RET - INIT_XMM sse cglobal pred16x16_vertical_8, 2,3 sub r0, r1 @@ -114,8 +98,6 @@ cglobal pred16x16_horizontal_8, 2,3 REP_RET %endmacro -INIT_MMX mmx -PRED16x16_H INIT_MMX mmxext PRED16x16_H INIT_XMM ssse3 @@ -154,14 +136,6 @@ cglobal pred16x16_dc_8, 2,7 %endif SPLATB_REG m0, r2, m1 -%if mmsize==8 - mov r3d, 8 -.loop: - mova [r4+r1*0+0], m0 - mova [r4+r1*0+8], m0 - mova [r4+r1*1+0], m0 - mova [r4+r1*1+8], m0 -%else mov r3d, 4 .loop: mova [r4+r1*0], m0 @@ -169,15 +143,12 @@ cglobal pred16x16_dc_8, 2,7 lea r4, [r4+r1*2] mova [r4+r1*0], m0 mova [r4+r1*1], m0 -%endif lea r4, [r4+r1*2] dec r3d jg .loop REP_RET %endmacro -INIT_MMX mmxext -PRED16x16_DC INIT_XMM sse2 PRED16x16_DC INIT_XMM ssse3 @@ -187,47 +158,6 @@ PRED16x16_DC ; void ff_pred16x16_tm_vp8_8(uint8_t *src, ptrdiff_t stride) ;----------------------------------------------------------------------------- -%macro PRED16x16_TM 0 -cglobal pred16x16_tm_vp8_8, 2,5 - sub r0, r1 - pxor mm7, mm7 - movq mm0, [r0+0] - movq mm2, [r0+8] - movq mm1, mm0 - movq mm3, mm2 - punpcklbw mm0, mm7 - punpckhbw mm1, mm7 - punpcklbw mm2, mm7 - punpckhbw mm3, mm7 - movzx r3d, byte [r0-1] - mov r4d, 16 -.loop: - movzx r2d, byte [r0+r1-1] - sub r2d, r3d - movd mm4, r2d - SPLATW mm4, mm4, 0 - movq mm5, mm4 - movq mm6, mm4 - movq mm7, mm4 - paddw mm4, mm0 - paddw mm5, mm1 - paddw mm6, mm2 - paddw mm7, mm3 - packuswb mm4, mm5 - packuswb mm6, mm7 - movq [r0+r1+0], mm4 - movq [r0+r1+8], mm6 - add r0, r1 - dec r4d - jg .loop - REP_RET -%endmacro - -INIT_MMX mmx -PRED16x16_TM -INIT_MMX mmxext -PRED16x16_TM - INIT_XMM sse2 cglobal pred16x16_tm_vp8_8, 2,6,6 sub r0, r1 @@ -311,22 +241,6 @@ cglobal pred16x16_plane_%1_8, 2,9,7 neg r1 ; -stride movh m0, [r0+r1 -1] -%if mmsize == 8 - pxor m4, m4 - movh m1, [r0+r1 +3 ] - movh m2, [r0+r1 +8 ] - movh m3, [r0+r1 +12] - punpcklbw m0, m4 - punpcklbw m1, m4 - punpcklbw m2, m4 - punpcklbw m3, m4 - pmullw m0, [pw_m8tom1 ] - pmullw m1, [pw_m8tom1+8] - pmullw m2, [pw_1to8 ] - pmullw m3, [pw_1to8 +8] - paddw m0, m2 - paddw m1, m3 -%else ; mmsize == 16 %if cpuflag(ssse3) movhps m0, [r0+r1 +8] pmaddubsw m0, [plane_shuf] ; H coefficients @@ -340,21 +254,10 @@ cglobal pred16x16_plane_%1_8, 2,9,7 paddw m0, m1 %endif movhlps m1, m0 -%endif paddw m0, m1 -%if cpuflag(mmxext) PSHUFLW m1, m0, 0xE -%elif cpuflag(mmx) - mova m1, m0 - psrlq m1, 32 -%endif paddw m0, m1 -%if cpuflag(mmxext) PSHUFLW m1, m0, 0x1 -%elif cpuflag(mmx) - mova m1, m0 - psrlq m1, 16 -%endif paddw m0, m1 ; sum of H coefficients lea r4, [r0+r2*8-1] @@ -496,24 +399,10 @@ cglobal pred16x16_plane_%1_8, 2,9,7 SWAP 0, 1 %endif mova m2, m0 -%if mmsize == 8 - mova m5, m0 -%endif pmullw m0, [pw_0to7] ; 0*H, 1*H, ..., 7*H (words) -%if mmsize == 16 psllw m2, 3 -%else - psllw m5, 3 - psllw m2, 2 - mova m6, m5 - paddw m6, m2 -%endif paddw m0, m3 ; a + {0,1,2,3,4,5,6,7}*H paddw m2, m0 ; a + {8,9,10,11,12,13,14,15}*H -%if mmsize == 8 - paddw m5, m0 ; a + {8,9,10,11}*H - paddw m6, m0 ; a + {12,13,14,15}*H -%endif mov r4, 8 .loop: @@ -523,20 +412,8 @@ cglobal pred16x16_plane_%1_8, 2,9,7 psraw m4, 5 packuswb m3, m4 mova [r0], m3 -%if mmsize == 8 - mova m3, m5 ; b[8..11] - mova m4, m6 ; b[12..15] - psraw m3, 5 - psraw m4, 5 - packuswb m3, m4 - mova [r0+8], m3 -%endif paddw m0, m1 paddw m2, m1 -%if mmsize == 8 - paddw m5, m1 - paddw m6, m1 -%endif mova m3, m0 ; b[0..7] mova m4, m2 ; b[8..15] @@ -544,20 +421,8 @@ cglobal pred16x16_plane_%1_8, 2,9,7 psraw m4, 5 packuswb m3, m4 mova [r0+r2], m3 -%if mmsize == 8 - mova m3, m5 ; b[8..11] - mova m4, m6 ; b[12..15] - psraw m3, 5 - psraw m4, 5 - packuswb m3, m4 - mova [r0+r2+8], m3 -%endif paddw m0, m1 paddw m2, m1 -%if mmsize == 8 - paddw m5, m1 - paddw m6, m1 -%endif lea r0, [r0+r2*2] dec r4 @@ -565,14 +430,6 @@ cglobal pred16x16_plane_%1_8, 2,9,7 REP_RET %endmacro -INIT_MMX mmx -H264_PRED16x16_PLANE h264 -H264_PRED16x16_PLANE rv40 -H264_PRED16x16_PLANE svq3 -INIT_MMX mmxext -H264_PRED16x16_PLANE h264 -H264_PRED16x16_PLANE rv40 -H264_PRED16x16_PLANE svq3 INIT_XMM sse2 H264_PRED16x16_PLANE h264 H264_PRED16x16_PLANE rv40 @@ -592,14 +449,6 @@ cglobal pred8x8_plane_8, 2,9,7 neg r1 ; -stride movd m0, [r0+r1 -1] -%if mmsize == 8 - pxor m2, m2 - movh m1, [r0+r1 +4 ] - punpcklbw m0, m2 - punpcklbw m1, m2 - pmullw m0, [pw_m4to4] - pmullw m1, [pw_m4to4+8] -%else ; mmsize == 16 %if cpuflag(ssse3) movhps m0, [r0+r1 +4] ; this reads 4 bytes more than necessary pmaddubsw m0, [plane8_shuf] ; H coefficients @@ -611,25 +460,14 @@ cglobal pred8x8_plane_8, 2,9,7 pmullw m0, [pw_m4to4] %endif movhlps m1, m0 -%endif paddw m0, m1 %if notcpuflag(ssse3) -%if cpuflag(mmxext) PSHUFLW m1, m0, 0xE -%elif cpuflag(mmx) - mova m1, m0 - psrlq m1, 32 -%endif paddw m0, m1 %endif ; !ssse3 -%if cpuflag(mmxext) PSHUFLW m1, m0, 0x1 -%elif cpuflag(mmx) - mova m1, m0 - psrlq m1, 16 -%endif paddw m0, m1 ; sum of H coefficients lea r4, [r0+r2*4-1] @@ -699,20 +537,12 @@ cglobal pred8x8_plane_8, 2,9,7 SPLATW m0, m0, 0 ; H SPLATW m1, m1, 0 ; V SPLATW m3, m3, 0 ; a -%if mmsize == 8 - mova m2, m0 -%endif pmullw m0, [pw_0to7] ; 0*H, 1*H, ..., 7*H (words) paddw m0, m3 ; a + {0,1,2,3,4,5,6,7}*H -%if mmsize == 8 - psllw m2, 2 - paddw m2, m0 ; a + {4,5,6,7}*H -%endif mov r4, 4 ALIGN 16 .loop: -%if mmsize == 16 mova m3, m0 ; b[0..7] paddw m0, m1 psraw m3, 5 @@ -722,24 +552,6 @@ ALIGN 16 packuswb m3, m4 movh [r0], m3 movhps [r0+r2], m3 -%else ; mmsize == 8 - mova m3, m0 ; b[0..3] - mova m4, m2 ; b[4..7] - paddw m0, m1 - paddw m2, m1 - psraw m3, 5 - psraw m4, 5 - mova m5, m0 ; V+b[0..3] - mova m6, m2 ; V+b[4..7] - paddw m0, m1 - paddw m2, m1 - psraw m5, 5 - psraw m6, 5 - packuswb m3, m4 - packuswb m5, m6 - mova [r0], m3 - mova [r0+r2], m5 -%endif lea r0, [r0+r2*2] dec r4 @@ -747,10 +559,6 @@ ALIGN 16 REP_RET %endmacro -INIT_MMX mmx -H264_PRED8x8_PLANE -INIT_MMX mmxext -H264_PRED8x8_PLANE INIT_XMM sse2 H264_PRED8x8_PLANE INIT_XMM ssse3 @@ -794,8 +602,6 @@ cglobal pred8x8_horizontal_8, 2,3 REP_RET %endmacro -INIT_MMX mmx -PRED8x8_H INIT_MMX mmxext PRED8x8_H INIT_MMX ssse3 @@ -937,46 +743,6 @@ cglobal pred8x8_dc_rv40_8, 2,7 ; void ff_pred8x8_tm_vp8_8(uint8_t *src, ptrdiff_t stride) ;----------------------------------------------------------------------------- -%macro PRED8x8_TM 0 -cglobal pred8x8_tm_vp8_8, 2,6 - sub r0, r1 - pxor mm7, mm7 - movq mm0, [r0] - movq mm1, mm0 - punpcklbw mm0, mm7 - punpckhbw mm1, mm7 - movzx r4d, byte [r0-1] - mov r5d, 4 -.loop: - movzx r2d, byte [r0+r1*1-1] - movzx r3d, byte [r0+r1*2-1] - sub r2d, r4d - sub r3d, r4d - movd mm2, r2d - movd mm4, r3d - SPLATW mm2, mm2, 0 - SPLATW mm4, mm4, 0 - movq mm3, mm2 - movq mm5, mm4 - paddw mm2, mm0 - paddw mm3, mm1 - paddw mm4, mm0 - paddw mm5, mm1 - packuswb mm2, mm3 - packuswb mm4, mm5 - movq [r0+r1*1], mm2 - movq [r0+r1*2], mm4 - lea r0, [r0+r1*2] - dec r5d - jg .loop - REP_RET -%endmacro - -INIT_MMX mmx -PRED8x8_TM -INIT_MMX mmxext -PRED8x8_TM - INIT_XMM sse2 cglobal pred8x8_tm_vp8_8, 2,6,4 sub r0, r1 @@ -1333,114 +1099,6 @@ PRED8x8L_VERTICAL ; int has_topright, ptrdiff_t stride) ;----------------------------------------------------------------------------- -INIT_MMX mmxext -cglobal pred8x8l_down_left_8, 4,5 - sub r0, r3 - movq mm0, [r0-8] - movq mm3, [r0] - movq mm1, [r0+8] - movq mm2, mm3 - movq mm4, mm3 - PALIGNR mm2, mm0, 7, mm0 - PALIGNR mm1, mm4, 1, mm4 - test r1d, r1d - jz .fix_lt_2 - test r2d, r2d - jz .fix_tr_1 - jmp .do_top -.fix_lt_2: - movq mm5, mm3 - pxor mm5, mm2 - psllq mm5, 56 - psrlq mm5, 56 - pxor mm2, mm5 - test r2d, r2d - jnz .do_top -.fix_tr_1: - movq mm5, mm3 - pxor mm5, mm1 - psrlq mm5, 56 - psllq mm5, 56 - pxor mm1, mm5 - jmp .do_top -.fix_tr_2: - punpckhbw mm3, mm3 - pshufw mm1, mm3, 0xFF - jmp .do_topright -.do_top: - PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5 - movq mm7, mm4 - test r2d, r2d - jz .fix_tr_2 - movq mm0, [r0+8] - movq mm5, mm0 - movq mm2, mm0 - movq mm4, mm0 - psrlq mm5, 56 - PALIGNR mm2, mm3, 7, mm3 - PALIGNR mm5, mm4, 1, mm4 - PRED4x4_LOWPASS mm1, mm2, mm5, mm0, mm4 -.do_topright: - lea r1, [r0+r3*2] - movq mm6, mm1 - psrlq mm1, 56 - movq mm4, mm1 - lea r2, [r1+r3*2] - movq mm2, mm6 - PALIGNR mm2, mm7, 1, mm0 - movq mm3, mm6 - PALIGNR mm3, mm7, 7, mm0 - PALIGNR mm4, mm6, 1, mm0 - movq mm5, mm7 - movq mm1, mm7 - movq mm7, mm6 - lea r4, [r2+r3*2] - psllq mm1, 8 - PRED4x4_LOWPASS mm0, mm1, mm2, mm5, mm6 - PRED4x4_LOWPASS mm1, mm3, mm4, mm7, mm6 - movq [r4+r3*2], mm1 - movq mm2, mm0 - psllq mm1, 8 - psrlq mm2, 56 - psllq mm0, 8 - por mm1, mm2 - movq [r4+r3*1], mm1 - movq mm2, mm0 - psllq mm1, 8 - psrlq mm2, 56 - psllq mm0, 8 - por mm1, mm2 - movq [r2+r3*2], mm1 - movq mm2, mm0 - psllq mm1, 8 - psrlq mm2, 56 - psllq mm0, 8 - por mm1, mm2 - movq [r2+r3*1], mm1 - movq mm2, mm0 - psllq mm1, 8 - psrlq mm2, 56 - psllq mm0, 8 - por mm1, mm2 - movq [r1+r3*2], mm1 - movq mm2, mm0 - psllq mm1, 8 - psrlq mm2, 56 - psllq mm0, 8 - por mm1, mm2 - movq [r1+r3*1], mm1 - movq mm2, mm0 - psllq mm1, 8 - psrlq mm2, 56 - psllq mm0, 8 - por mm1, mm2 - movq [r0+r3*2], mm1 - psllq mm1, 8 - psrlq mm0, 56 - por mm1, mm0 - movq [r0+r3*1], mm1 - RET - %macro PRED8x8L_DOWN_LEFT 0 cglobal pred8x8l_down_left_8, 4,4 sub r0, r3 @@ -1530,142 +1188,10 @@ INIT_MMX ssse3 PRED8x8L_DOWN_LEFT ;----------------------------------------------------------------------------- -; void ff_pred8x8l_down_right_8_mmxext(uint8_t *src, int has_topleft, -; int has_topright, ptrdiff_t stride) +; void ff_pred8x8l_down_right_8(uint8_t *src, int has_topleft, +; int has_topright, ptrdiff_t stride) ;----------------------------------------------------------------------------- -INIT_MMX mmxext -cglobal pred8x8l_down_right_8, 4,5 - sub r0, r3 - lea r4, [r0+r3*2] - movq mm0, [r0+r3*1-8] - punpckhbw mm0, [r0+r3*0-8] - movq mm1, [r4+r3*1-8] - punpckhbw mm1, [r0+r3*2-8] - mov r4, r0 - punpckhwd mm1, mm0 - lea r0, [r0+r3*4] - movq mm2, [r0+r3*1-8] - punpckhbw mm2, [r0+r3*0-8] - lea r0, [r0+r3*2] - movq mm3, [r0+r3*1-8] - punpckhbw mm3, [r0+r3*0-8] - punpckhwd mm3, mm2 - punpckhdq mm3, mm1 - lea r0, [r0+r3*2] - movq mm0, [r0+r3*0-8] - movq mm1, [r4] - mov r0, r4 - movq mm4, mm3 - movq mm2, mm3 - PALIGNR mm4, mm0, 7, mm0 - PALIGNR mm1, mm2, 1, mm2 - test r1d, r1d ; top_left - jz .fix_lt_1 -.do_left: - movq mm0, mm4 - PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5 - movq mm4, mm0 - movq mm7, mm2 - movq mm6, mm2 - PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5 - psllq mm1, 56 - PALIGNR mm7, mm1, 7, mm3 - movq mm0, [r0-8] - movq mm3, [r0] - movq mm1, [r0+8] - movq mm2, mm3 - movq mm4, mm3 - PALIGNR mm2, mm0, 7, mm0 - PALIGNR mm1, mm4, 1, mm4 - test r1d, r1d ; top_left - jz .fix_lt_2 - test r2d, r2d ; top_right - jz .fix_tr_1 -.do_top: - PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5 - movq mm5, mm4 - jmp .body -.fix_lt_1: - movq mm5, mm3 - pxor mm5, mm4 - psrlq mm5, 56 - psllq mm5, 48 - pxor mm1, mm5 - jmp .do_left -.fix_lt_2: - movq mm5, mm3 - pxor mm5, mm2 - psllq mm5, 56 - psrlq mm5, 56 - pxor mm2, mm5 - test r2d, r2d ; top_right - jnz .do_top -.fix_tr_1: - movq mm5, mm3 - pxor mm5, mm1 - psrlq mm5, 56 - psllq mm5, 56 - pxor mm1, mm5 - jmp .do_top -.body: - lea r1, [r0+r3*2] - movq mm1, mm7 - movq mm7, mm5 - movq mm5, mm6 - movq mm2, mm7 - lea r2, [r1+r3*2] - PALIGNR mm2, mm6, 1, mm0 - movq mm3, mm7 - PALIGNR mm3, mm6, 7, mm0 - movq mm4, mm7 - lea r4, [r2+r3*2] - psrlq mm4, 8 - PRED4x4_LOWPASS mm0, mm1, mm2, mm5, mm6 - PRED4x4_LOWPASS mm1, mm3, mm4, mm7, mm6 - movq [r4+r3*2], mm0 - movq mm2, mm1 - psrlq mm0, 8 - psllq mm2, 56 - psrlq mm1, 8 - por mm0, mm2 - movq [r4+r3*1], mm0 - movq mm2, mm1 - psrlq mm0, 8 - psllq mm2, 56 - psrlq mm1, 8 - por mm0, mm2 - movq [r2+r3*2], mm0 - movq mm2, mm1 - psrlq mm0, 8 - psllq mm2, 56 - psrlq mm1, 8 - por mm0, mm2 - movq [r2+r3*1], mm0 - movq mm2, mm1 - psrlq mm0, 8 - psllq mm2, 56 - psrlq mm1, 8 - por mm0, mm2 - movq [r1+r3*2], mm0 - movq mm2, mm1 - psrlq mm0, 8 - psllq mm2, 56 - psrlq mm1, 8 - por mm0, mm2 - movq [r1+r3*1], mm0 - movq mm2, mm1 - psrlq mm0, 8 - psllq mm2, 56 - psrlq mm1, 8 - por mm0, mm2 - movq [r0+r3*2], mm0 - psrlq mm0, 8 - psllq mm1, 56 - por mm0, mm1 - movq [r0+r3*1], mm0 - RET - %macro PRED8x8L_DOWN_RIGHT 0 cglobal pred8x8l_down_right_8, 4,5 sub r0, r3 @@ -1786,113 +1312,6 @@ PRED8x8L_DOWN_RIGHT ; int has_topright, ptrdiff_t stride) ;----------------------------------------------------------------------------- -INIT_MMX mmxext -cglobal pred8x8l_vertical_right_8, 4,5 - sub r0, r3 - lea r4, [r0+r3*2] - movq mm0, [r0+r3*1-8] - punpckhbw mm0, [r0+r3*0-8] - movq mm1, [r4+r3*1-8] - punpckhbw mm1, [r0+r3*2-8] - mov r4, r0 - punpckhwd mm1, mm0 - lea r0, [r0+r3*4] - movq mm2, [r0+r3*1-8] - punpckhbw mm2, [r0+r3*0-8] - lea r0, [r0+r3*2] - movq mm3, [r0+r3*1-8] - punpckhbw mm3, [r0+r3*0-8] - punpckhwd mm3, mm2 - punpckhdq mm3, mm1 - lea r0, [r0+r3*2] - movq mm0, [r0+r3*0-8] - movq mm1, [r4] - mov r0, r4 - movq mm4, mm3 - movq mm2, mm3 - PALIGNR mm4, mm0, 7, mm0 - PALIGNR mm1, mm2, 1, mm2 - test r1d, r1d - jz .fix_lt_1 - jmp .do_left -.fix_lt_1: - movq mm5, mm3 - pxor mm5, mm4 - psrlq mm5, 56 - psllq mm5, 48 - pxor mm1, mm5 - jmp .do_left -.fix_lt_2: - movq mm5, mm3 - pxor mm5, mm2 - psllq mm5, 56 - psrlq mm5, 56 - pxor mm2, mm5 - test r2d, r2d - jnz .do_top -.fix_tr_1: - movq mm5, mm3 - pxor mm5, mm1 - psrlq mm5, 56 - psllq mm5, 56 - pxor mm1, mm5 - jmp .do_top -.do_left: - movq mm0, mm4 - PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5 - movq mm7, mm2 - movq mm0, [r0-8] - movq mm3, [r0] - movq mm1, [r0+8] - movq mm2, mm3 - movq mm4, mm3 - PALIGNR mm2, mm0, 7, mm0 - PALIGNR mm1, mm4, 1, mm4 - test r1d, r1d - jz .fix_lt_2 - test r2d, r2d - jz .fix_tr_1 -.do_top: - PRED4x4_LOWPASS mm6, mm2, mm1, mm3, mm5 - lea r1, [r0+r3*2] - movq mm2, mm6 - movq mm3, mm6 - PALIGNR mm3, mm7, 7, mm0 - PALIGNR mm6, mm7, 6, mm1 - movq mm4, mm3 - pavgb mm3, mm2 - lea r2, [r1+r3*2] - PRED4x4_LOWPASS mm0, mm6, mm2, mm4, mm5 - movq [r0+r3*1], mm3 - movq [r0+r3*2], mm0 - movq mm5, mm0 - movq mm6, mm3 - movq mm1, mm7 - movq mm2, mm1 - psllq mm2, 8 - movq mm3, mm1 - psllq mm3, 16 - lea r4, [r2+r3*2] - PRED4x4_LOWPASS mm0, mm1, mm3, mm2, mm4 - PALIGNR mm6, mm0, 7, mm2 - movq [r1+r3*1], mm6 - psllq mm0, 8 - PALIGNR mm5, mm0, 7, mm1 - movq [r1+r3*2], mm5 - psllq mm0, 8 - PALIGNR mm6, mm0, 7, mm2 - movq [r2+r3*1], mm6 - psllq mm0, 8 - PALIGNR mm5, mm0, 7, mm1 - movq [r2+r3*2], mm5 - psllq mm0, 8 - PALIGNR mm6, mm0, 7, mm2 - movq [r4+r3*1], mm6 - psllq mm0, 8 - PALIGNR mm5, mm0, 7, mm1 - movq [r4+r3*2], mm5 - RET - %macro PRED8x8L_VERTICAL_RIGHT 0 cglobal pred8x8l_vertical_right_8, 4,5,7 ; manually spill XMM registers for Win64 because @@ -2192,121 +1611,6 @@ PRED8x8L_HORIZONTAL_UP ; int has_topright, ptrdiff_t stride) ;----------------------------------------------------------------------------- -INIT_MMX mmxext -cglobal pred8x8l_horizontal_down_8, 4,5 - sub r0, r3 - lea r4, [r0+r3*2] - movq mm0, [r0+r3*1-8] - punpckhbw mm0, [r0+r3*0-8] - movq mm1, [r4+r3*1-8] - punpckhbw mm1, [r0+r3*2-8] - mov r4, r0 - punpckhwd mm1, mm0 - lea r0, [r0+r3*4] - movq mm2, [r0+r3*1-8] - punpckhbw mm2, [r0+r3*0-8] - lea r0, [r0+r3*2] - movq mm3, [r0+r3*1-8] - punpckhbw mm3, [r0+r3*0-8] - punpckhwd mm3, mm2 - punpckhdq mm3, mm1 - lea r0, [r0+r3*2] - movq mm0, [r0+r3*0-8] - movq mm1, [r4] - mov r0, r4 - movq mm4, mm3 - movq mm2, mm3 - PALIGNR mm4, mm0, 7, mm0 - PALIGNR mm1, mm2, 1, mm2 - test r1d, r1d - jnz .do_left -.fix_lt_1: - movq mm5, mm3 - pxor mm5, mm4 - psrlq mm5, 56 - psllq mm5, 48 - pxor mm1, mm5 - jmp .do_left -.fix_lt_2: - movq mm5, mm3 - pxor mm5, mm2 - psllq mm5, 56 - psrlq mm5, 56 - pxor mm2, mm5 - test r2d, r2d - jnz .do_top -.fix_tr_1: - movq mm5, mm3 - pxor mm5, mm1 - psrlq mm5, 56 - psllq mm5, 56 - pxor mm1, mm5 - jmp .do_top -.do_left: - movq mm0, mm4 - PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5 - movq mm4, mm0 - movq mm7, mm2 - movq mm6, mm2 - PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5 - psllq mm1, 56 - PALIGNR mm7, mm1, 7, mm3 - movq mm0, [r0-8] - movq mm3, [r0] - movq mm1, [r0+8] - movq mm2, mm3 - movq mm4, mm3 - PALIGNR mm2, mm0, 7, mm0 - PALIGNR mm1, mm4, 1, mm4 - test r1d, r1d - jz .fix_lt_2 - test r2d, r2d - jz .fix_tr_1 -.do_top: - PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5 - movq mm5, mm4 - lea r1, [r0+r3*2] - psllq mm7, 56 - movq mm2, mm5 - movq mm3, mm6 - movq mm4, mm2 - PALIGNR mm2, mm6, 7, mm5 - PALIGNR mm6, mm7, 7, mm0 - lea r2, [r1+r3*2] - PALIGNR mm4, mm3, 1, mm7 - movq mm5, mm3 - pavgb mm3, mm6 - PRED4x4_LOWPASS mm0, mm4, mm6, mm5, mm7 - movq mm4, mm2 - movq mm1, mm2 - lea r4, [r2+r3*2] - psrlq mm4, 16 - psrlq mm1, 8 - PRED4x4_LOWPASS mm6, mm4, mm2, mm1, mm5 - movq mm7, mm3 - punpcklbw mm3, mm0 - punpckhbw mm7, mm0 - movq mm1, mm7 - movq mm0, mm7 - movq mm4, mm7 - movq [r4+r3*2], mm3 - PALIGNR mm7, mm3, 2, mm5 - movq [r4+r3*1], mm7 - PALIGNR mm1, mm3, 4, mm5 - movq [r2+r3*2], mm1 - PALIGNR mm0, mm3, 6, mm3 - movq [r2+r3*1], mm0 - movq mm2, mm6 - movq mm3, mm6 - movq [r1+r3*2], mm4 - PALIGNR mm6, mm4, 2, mm5 - movq [r1+r3*1], mm6 - PALIGNR mm2, mm4, 4, mm5 - movq [r0+r3*2], mm2 - PALIGNR mm3, mm4, 6, mm4 - movq [r0+r3*1], mm3 - RET - %macro PRED8x8L_HORIZONTAL_DOWN 0 cglobal pred8x8l_horizontal_down_8, 4,5 sub r0, r3 @@ -2472,7 +1776,7 @@ cglobal pred4x4_dc_8, 3,5 ; ptrdiff_t stride) ;----------------------------------------------------------------------------- -%macro PRED4x4_TM 0 +INIT_MMX mmxext cglobal pred4x4_tm_vp8_8, 3,6 sub r0, r2 pxor mm7, mm7 @@ -2487,15 +1791,8 @@ cglobal pred4x4_tm_vp8_8, 3,6 sub r3d, r4d movd mm2, r1d movd mm4, r3d -%if cpuflag(mmxext) pshufw mm2, mm2, 0 pshufw mm4, mm4, 0 -%else - punpcklwd mm2, mm2 - punpcklwd mm4, mm4 - punpckldq mm2, mm2 - punpckldq mm4, mm4 -%endif paddw mm2, mm0 paddw mm4, mm0 packuswb mm2, mm2 @@ -2506,12 +1803,6 @@ cglobal pred4x4_tm_vp8_8, 3,6 dec r5d jg .loop REP_RET -%endmacro - -INIT_MMX mmx -PRED4x4_TM -INIT_MMX mmxext -PRED4x4_TM INIT_XMM ssse3 cglobal pred4x4_tm_vp8_8, 3,3 diff --git a/media/ffvpx/libavcodec/x86/h264_intrapred_10bit.asm b/media/ffvpx/libavcodec/x86/h264_intrapred_10bit.asm index 629e0a72e3ad..c4645d434ee1 100644 --- a/media/ffvpx/libavcodec/x86/h264_intrapred_10bit.asm +++ b/media/ffvpx/libavcodec/x86/h264_intrapred_10bit.asm @@ -334,12 +334,7 @@ cglobal pred8x8_horizontal_10, 2, 3 ;----------------------------------------------------------------------------- %macro MOV8 2-3 ; sort of a hack, but it works -%if mmsize==8 - movq [%1+0], %2 - movq [%1+8], %3 -%else movdqa [%1], %2 -%endif %endmacro %macro PRED8x8_DC 1 @@ -348,17 +343,9 @@ cglobal pred8x8_dc_10, 2, 6 pxor m4, m4 movq m0, [r0+0] movq m1, [r0+8] -%if mmsize==16 punpcklwd m0, m1 movhlps m1, m0 paddw m0, m1 -%else - pshufw m2, m0, 00001110b - pshufw m3, m1, 00001110b - paddw m0, m2 - paddw m1, m3 - punpcklwd m0, m1 -%endif %1 m2, m0, 00001110b paddw m0, m2 @@ -389,17 +376,10 @@ cglobal pred8x8_dc_10, 2, 6 paddw m0, m3 psrlw m0, 2 pavgw m0, m4 ; s0+s2, s1, s3, s1+s3 -%if mmsize==16 punpcklwd m0, m0 pshufd m3, m0, 11111010b punpckldq m0, m0 SWAP 0,1 -%else - pshufw m1, m0, 0x00 - pshufw m2, m0, 0x55 - pshufw m3, m0, 0xaa - pshufw m4, m0, 0xff -%endif MOV8 r0+r1*1, m1, m2 MOV8 r0+r1*2, m1, m2 MOV8 r0+r5*1, m1, m2 @@ -411,8 +391,6 @@ cglobal pred8x8_dc_10, 2, 6 RET %endmacro -INIT_MMX mmxext -PRED8x8_DC pshufw INIT_XMM sse2 PRED8x8_DC pshuflw @@ -510,7 +488,7 @@ cglobal pred8x8_plane_10, 2, 7, 7 ; void ff_pred8x8l_128_dc_10(pixel *src, int has_topleft, int has_topright, ; ptrdiff_t stride) ;----------------------------------------------------------------------------- -%macro PRED8x8L_128_DC 0 +INIT_XMM sse2 cglobal pred8x8l_128_dc_10, 4, 4 mova m0, [pw_512] ; (1<<(BIT_DEPTH-1)) lea r1, [r3*3] @@ -524,12 +502,6 @@ cglobal pred8x8l_128_dc_10, 4, 4 MOV8 r2+r3*2, m0, m0 MOV8 r2+r1*1, m0, m0 RET -%endmacro - -INIT_MMX mmxext -PRED8x8L_128_DC -INIT_XMM sse2 -PRED8x8L_128_DC ;----------------------------------------------------------------------------- ; void ff_pred8x8l_top_dc_10(pixel *src, int has_topleft, int has_topright, @@ -1008,22 +980,14 @@ PRED8x8L_HORIZONTAL_UP %macro MOV16 3-5 mova [%1+ 0], %2 mova [%1+mmsize], %3 -%if mmsize==8 - mova [%1+ 16], %4 - mova [%1+ 24], %5 -%endif %endmacro -%macro PRED16x16_VERTICAL 0 +INIT_XMM sse2 cglobal pred16x16_vertical_10, 2, 3 sub r0, r1 mov r2d, 8 mova m0, [r0+ 0] mova m1, [r0+mmsize] -%if mmsize==8 - mova m2, [r0+16] - mova m3, [r0+24] -%endif .loop: MOV16 r0+r1*1, m0, m1, m2, m3 MOV16 r0+r1*2, m0, m1, m2, m3 @@ -1031,17 +995,11 @@ cglobal pred16x16_vertical_10, 2, 3 dec r2d jg .loop REP_RET -%endmacro - -INIT_MMX mmxext -PRED16x16_VERTICAL -INIT_XMM sse2 -PRED16x16_VERTICAL ;----------------------------------------------------------------------------- ; void ff_pred16x16_horizontal_10(pixel *src, ptrdiff_t stride) ;----------------------------------------------------------------------------- -%macro PRED16x16_HORIZONTAL 0 +INIT_XMM sse2 cglobal pred16x16_horizontal_10, 2, 3 mov r2d, 8 .vloop: @@ -1055,26 +1013,16 @@ cglobal pred16x16_horizontal_10, 2, 3 dec r2d jg .vloop REP_RET -%endmacro - -INIT_MMX mmxext -PRED16x16_HORIZONTAL -INIT_XMM sse2 -PRED16x16_HORIZONTAL ;----------------------------------------------------------------------------- ; void ff_pred16x16_dc_10(pixel *src, ptrdiff_t stride) ;----------------------------------------------------------------------------- -%macro PRED16x16_DC 0 +INIT_XMM sse2 cglobal pred16x16_dc_10, 2, 6 mov r5, r0 sub r0, r1 mova m0, [r0+0] paddw m0, [r0+mmsize] -%if mmsize==8 - paddw m0, [r0+16] - paddw m0, [r0+24] -%endif HADDW m0, m2 lea r0, [r0+r1-2] @@ -1101,25 +1049,15 @@ cglobal pred16x16_dc_10, 2, 6 dec r3d jg .loop REP_RET -%endmacro - -INIT_MMX mmxext -PRED16x16_DC -INIT_XMM sse2 -PRED16x16_DC ;----------------------------------------------------------------------------- ; void ff_pred16x16_top_dc_10(pixel *src, ptrdiff_t stride) ;----------------------------------------------------------------------------- -%macro PRED16x16_TOP_DC 0 +INIT_XMM sse2 cglobal pred16x16_top_dc_10, 2, 3 sub r0, r1 mova m0, [r0+0] paddw m0, [r0+mmsize] -%if mmsize==8 - paddw m0, [r0+16] - paddw m0, [r0+24] -%endif HADDW m0, m2 SPLATW m0, m0 @@ -1133,17 +1071,11 @@ cglobal pred16x16_top_dc_10, 2, 3 dec r2d jg .loop REP_RET -%endmacro - -INIT_MMX mmxext -PRED16x16_TOP_DC -INIT_XMM sse2 -PRED16x16_TOP_DC ;----------------------------------------------------------------------------- ; void ff_pred16x16_left_dc_10(pixel *src, ptrdiff_t stride) ;----------------------------------------------------------------------------- -%macro PRED16x16_LEFT_DC 0 +INIT_XMM sse2 cglobal pred16x16_left_dc_10, 2, 6 mov r5, r0 @@ -1170,17 +1102,11 @@ cglobal pred16x16_left_dc_10, 2, 6 dec r3d jg .loop REP_RET -%endmacro - -INIT_MMX mmxext -PRED16x16_LEFT_DC -INIT_XMM sse2 -PRED16x16_LEFT_DC ;----------------------------------------------------------------------------- ; void ff_pred16x16_128_dc_10(pixel *src, ptrdiff_t stride) ;----------------------------------------------------------------------------- -%macro PRED16x16_128_DC 0 +INIT_XMM sse2 cglobal pred16x16_128_dc_10, 2,3 mova m0, [pw_512] mov r2d, 8 @@ -1191,9 +1117,3 @@ cglobal pred16x16_128_dc_10, 2,3 dec r2d jg .loop REP_RET -%endmacro - -INIT_MMX mmxext -PRED16x16_128_DC -INIT_XMM sse2 -PRED16x16_128_DC diff --git a/media/ffvpx/libavcodec/x86/h264_intrapred_init.c b/media/ffvpx/libavcodec/x86/h264_intrapred_init.c index bdd5125d688f..ee46927a24c9 100644 --- a/media/ffvpx/libavcodec/x86/h264_intrapred_init.c +++ b/media/ffvpx/libavcodec/x86/h264_intrapred_init.c @@ -18,10 +18,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include +#include +#include "config.h" #include "libavutil/attributes.h" #include "libavutil/cpu.h" #include "libavutil/x86/cpu.h" -#include "libavcodec/avcodec.h" +#include "libavcodec/codec_id.h" #include "libavcodec/h264pred.h" #define PRED4x4(TYPE, DEPTH, OPT) \ @@ -49,7 +52,6 @@ PRED4x4(horizontal_down, 10, avx) void ff_pred8x8_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, \ ptrdiff_t stride); -PRED8x8(dc, 10, mmxext) PRED8x8(dc, 10, sse2) PRED8x8(top_dc, 10, sse2) PRED8x8(plane, 10, sse2) @@ -64,7 +66,6 @@ void ff_pred8x8l_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, \ PRED8x8L(dc, 10, sse2) PRED8x8L(dc, 10, avx) -PRED8x8L(128_dc, 10, mmxext) PRED8x8L(128_dc, 10, sse2) PRED8x8L(top_dc, 10, sse2) PRED8x8L(top_dc, 10, avx) @@ -90,42 +91,25 @@ PRED8x8L(horizontal_up, 10, avx) void ff_pred16x16_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, \ ptrdiff_t stride); -PRED16x16(dc, 10, mmxext) PRED16x16(dc, 10, sse2) -PRED16x16(top_dc, 10, mmxext) PRED16x16(top_dc, 10, sse2) -PRED16x16(128_dc, 10, mmxext) PRED16x16(128_dc, 10, sse2) -PRED16x16(left_dc, 10, mmxext) PRED16x16(left_dc, 10, sse2) -PRED16x16(vertical, 10, mmxext) PRED16x16(vertical, 10, sse2) -PRED16x16(horizontal, 10, mmxext) PRED16x16(horizontal, 10, sse2) /* 8-bit versions */ -PRED16x16(vertical, 8, mmx) PRED16x16(vertical, 8, sse) -PRED16x16(horizontal, 8, mmx) PRED16x16(horizontal, 8, mmxext) PRED16x16(horizontal, 8, ssse3) -PRED16x16(dc, 8, mmxext) PRED16x16(dc, 8, sse2) PRED16x16(dc, 8, ssse3) -PRED16x16(plane_h264, 8, mmx) -PRED16x16(plane_h264, 8, mmxext) PRED16x16(plane_h264, 8, sse2) PRED16x16(plane_h264, 8, ssse3) -PRED16x16(plane_rv40, 8, mmx) -PRED16x16(plane_rv40, 8, mmxext) PRED16x16(plane_rv40, 8, sse2) PRED16x16(plane_rv40, 8, ssse3) -PRED16x16(plane_svq3, 8, mmx) -PRED16x16(plane_svq3, 8, mmxext) PRED16x16(plane_svq3, 8, sse2) PRED16x16(plane_svq3, 8, ssse3) -PRED16x16(tm_vp8, 8, mmx) -PRED16x16(tm_vp8, 8, mmxext) PRED16x16(tm_vp8, 8, sse2) PRED16x16(tm_vp8, 8, avx2) @@ -133,15 +117,10 @@ PRED8x8(top_dc, 8, mmxext) PRED8x8(dc_rv40, 8, mmxext) PRED8x8(dc, 8, mmxext) PRED8x8(vertical, 8, mmx) -PRED8x8(horizontal, 8, mmx) PRED8x8(horizontal, 8, mmxext) PRED8x8(horizontal, 8, ssse3) -PRED8x8(plane, 8, mmx) -PRED8x8(plane, 8, mmxext) PRED8x8(plane, 8, sse2) PRED8x8(plane, 8, ssse3) -PRED8x8(tm_vp8, 8, mmx) -PRED8x8(tm_vp8, 8, mmxext) PRED8x8(tm_vp8, 8, sse2) PRED8x8(tm_vp8, 8, ssse3) @@ -153,20 +132,16 @@ PRED8x8L(horizontal, 8, mmxext) PRED8x8L(horizontal, 8, ssse3) PRED8x8L(vertical, 8, mmxext) PRED8x8L(vertical, 8, ssse3) -PRED8x8L(down_left, 8, mmxext) PRED8x8L(down_left, 8, sse2) PRED8x8L(down_left, 8, ssse3) -PRED8x8L(down_right, 8, mmxext) PRED8x8L(down_right, 8, sse2) PRED8x8L(down_right, 8, ssse3) -PRED8x8L(vertical_right, 8, mmxext) PRED8x8L(vertical_right, 8, sse2) PRED8x8L(vertical_right, 8, ssse3) PRED8x8L(vertical_left, 8, sse2) PRED8x8L(vertical_left, 8, ssse3) PRED8x8L(horizontal_up, 8, mmxext) PRED8x8L(horizontal_up, 8, ssse3) -PRED8x8L(horizontal_down, 8, mmxext) PRED8x8L(horizontal_down, 8, sse2) PRED8x8L(horizontal_down, 8, ssse3) @@ -177,7 +152,6 @@ PRED4x4(vertical_left, 8, mmxext) PRED4x4(vertical_right, 8, mmxext) PRED4x4(horizontal_up, 8, mmxext) PRED4x4(horizontal_down, 8, mmxext) -PRED4x4(tm_vp8, 8, mmx) PRED4x4(tm_vp8, 8, mmxext) PRED4x4(tm_vp8, 8, ssse3) PRED4x4(vertical_vp8, 8, mmxext) @@ -190,44 +164,20 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, if (bit_depth == 8) { if (EXTERNAL_MMX(cpu_flags)) { - h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_8_mmx; - h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_mmx; if (chroma_format_idc <= 1) { h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x8_vertical_8_mmx; - h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_8_mmx; - } - if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8) { - h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_8_mmx; - h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_8_mmx; - h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_8_mmx; - } else { - if (chroma_format_idc <= 1) - h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_8_mmx; - if (codec_id == AV_CODEC_ID_SVQ3) { - if (cpu_flags & AV_CPU_FLAG_CMOV) - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_8_mmx; - } else if (codec_id == AV_CODEC_ID_RV40) { - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_8_mmx; - } else { - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_8_mmx; - } } } if (EXTERNAL_MMXEXT(cpu_flags)) { h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_mmxext; - h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_8_mmxext; if (chroma_format_idc <= 1) h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_horizontal_8_mmxext; h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_8_mmxext; h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_8_mmxext; h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_8_mmxext; h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_8_mmxext; - h->pred8x8l [DIAG_DOWN_RIGHT_PRED ] = ff_pred8x8l_down_right_8_mmxext; - h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_8_mmxext; h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_8_mmxext; - h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_8_mmxext; - h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_8_mmxext; h->pred4x4 [DIAG_DOWN_RIGHT_PRED ] = ff_pred4x4_down_right_8_mmxext; h->pred4x4 [VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_8_mmxext; h->pred4x4 [HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_8_mmxext; @@ -249,21 +199,9 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, } } if (codec_id == AV_CODEC_ID_VP7 || codec_id == AV_CODEC_ID_VP8) { - h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_8_mmxext; h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_rv40_8_mmxext; - h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_8_mmxext; h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_8_mmxext; h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_8_mmxext; - } else { - if (chroma_format_idc <= 1) - h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_8_mmxext; - if (codec_id == AV_CODEC_ID_SVQ3) { - h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_svq3_8_mmxext; - } else if (codec_id == AV_CODEC_ID_RV40) { - h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_rv40_8_mmxext; - } else { - h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_h264_8_mmxext; - } } } @@ -334,18 +272,6 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, if (EXTERNAL_MMXEXT(cpu_flags)) { h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_mmxext; h->pred4x4[HOR_UP_PRED ] = ff_pred4x4_horizontal_up_10_mmxext; - - if (chroma_format_idc <= 1) - h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_mmxext; - - h->pred8x8l[DC_128_PRED ] = ff_pred8x8l_128_dc_10_mmxext; - - h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_10_mmxext; - h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_10_mmxext; - h->pred16x16[DC_128_PRED8x8 ] = ff_pred16x16_128_dc_10_mmxext; - h->pred16x16[LEFT_DC_PRED8x8 ] = ff_pred16x16_left_dc_10_mmxext; - h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_10_mmxext; - h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_10_mmxext; } if (EXTERNAL_SSE2(cpu_flags)) { h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_sse2; diff --git a/media/ffvpx/libavcodec/x86/idctdsp.asm b/media/ffvpx/libavcodec/x86/idctdsp.asm index 089425a9ab01..1cfdb5419df9 100644 --- a/media/ffvpx/libavcodec/x86/idctdsp.asm +++ b/media/ffvpx/libavcodec/x86/idctdsp.asm @@ -37,47 +37,24 @@ SECTION .text %macro PUT_SIGNED_PIXELS_CLAMPED_HALF 1 mova m1, [blockq+mmsize*0+%1] mova m2, [blockq+mmsize*2+%1] -%if mmsize == 8 - mova m3, [blockq+mmsize*4+%1] - mova m4, [blockq+mmsize*6+%1] -%endif packsswb m1, [blockq+mmsize*1+%1] packsswb m2, [blockq+mmsize*3+%1] -%if mmsize == 8 - packsswb m3, [blockq+mmsize*5+%1] - packsswb m4, [blockq+mmsize*7+%1] -%endif paddb m1, m0 paddb m2, m0 -%if mmsize == 8 - paddb m3, m0 - paddb m4, m0 - movq [pixelsq+lsizeq*0], m1 - movq [pixelsq+lsizeq*1], m2 - movq [pixelsq+lsizeq*2], m3 - movq [pixelsq+lsize3q ], m4 -%else movq [pixelsq+lsizeq*0], m1 movhps [pixelsq+lsizeq*1], m1 movq [pixelsq+lsizeq*2], m2 movhps [pixelsq+lsize3q ], m2 -%endif %endmacro -%macro PUT_SIGNED_PIXELS_CLAMPED 1 -cglobal put_signed_pixels_clamped, 3, 4, %1, block, pixels, lsize, lsize3 +INIT_XMM sse2 +cglobal put_signed_pixels_clamped, 3, 4, 3, block, pixels, lsize, lsize3 mova m0, [pb_80] lea lsize3q, [lsizeq*3] PUT_SIGNED_PIXELS_CLAMPED_HALF 0 lea pixelsq, [pixelsq+lsizeq*4] PUT_SIGNED_PIXELS_CLAMPED_HALF 64 RET -%endmacro - -INIT_MMX mmx -PUT_SIGNED_PIXELS_CLAMPED 0 -INIT_XMM sse2 -PUT_SIGNED_PIXELS_CLAMPED 3 ;-------------------------------------------------------------------------- ; void ff_put_pixels_clamped(const int16_t *block, uint8_t *pixels, @@ -87,40 +64,21 @@ PUT_SIGNED_PIXELS_CLAMPED 3 %macro PUT_PIXELS_CLAMPED_HALF 1 mova m0, [blockq+mmsize*0+%1] mova m1, [blockq+mmsize*2+%1] -%if mmsize == 8 - mova m2, [blockq+mmsize*4+%1] - mova m3, [blockq+mmsize*6+%1] -%endif packuswb m0, [blockq+mmsize*1+%1] packuswb m1, [blockq+mmsize*3+%1] -%if mmsize == 8 - packuswb m2, [blockq+mmsize*5+%1] - packuswb m3, [blockq+mmsize*7+%1] - movq [pixelsq], m0 - movq [lsizeq+pixelsq], m1 - movq [2*lsizeq+pixelsq], m2 - movq [lsize3q+pixelsq], m3 -%else movq [pixelsq], m0 movhps [lsizeq+pixelsq], m0 movq [2*lsizeq+pixelsq], m1 movhps [lsize3q+pixelsq], m1 -%endif %endmacro -%macro PUT_PIXELS_CLAMPED 0 +INIT_XMM sse2 cglobal put_pixels_clamped, 3, 4, 2, block, pixels, lsize, lsize3 lea lsize3q, [lsizeq*3] PUT_PIXELS_CLAMPED_HALF 0 lea pixelsq, [pixelsq+lsizeq*4] PUT_PIXELS_CLAMPED_HALF 64 RET -%endmacro - -INIT_MMX mmx -PUT_PIXELS_CLAMPED -INIT_XMM sse2 -PUT_PIXELS_CLAMPED ;-------------------------------------------------------------------------- ; void ff_add_pixels_clamped(const int16_t *block, uint8_t *pixels, @@ -130,41 +88,18 @@ PUT_PIXELS_CLAMPED %macro ADD_PIXELS_CLAMPED 1 mova m0, [blockq+mmsize*0+%1] mova m1, [blockq+mmsize*1+%1] -%if mmsize == 8 - mova m5, [blockq+mmsize*2+%1] - mova m6, [blockq+mmsize*3+%1] -%endif movq m2, [pixelsq] movq m3, [pixelsq+lsizeq] -%if mmsize == 8 - mova m7, m2 - punpcklbw m2, m4 - punpckhbw m7, m4 - paddsw m0, m2 - paddsw m1, m7 - mova m7, m3 - punpcklbw m3, m4 - punpckhbw m7, m4 - paddsw m5, m3 - paddsw m6, m7 -%else punpcklbw m2, m4 punpcklbw m3, m4 paddsw m0, m2 paddsw m1, m3 -%endif packuswb m0, m1 -%if mmsize == 8 - packuswb m5, m6 - movq [pixelsq], m0 - movq [pixelsq+lsizeq], m5 -%else movq [pixelsq], m0 movhps [pixelsq+lsizeq], m0 -%endif %endmacro -%macro ADD_PIXELS_CLAMPED 0 +INIT_XMM sse2 cglobal add_pixels_clamped, 3, 3, 5, block, pixels, lsize pxor m4, m4 ADD_PIXELS_CLAMPED 0 @@ -175,9 +110,3 @@ cglobal add_pixels_clamped, 3, 3, 5, block, pixels, lsize lea pixelsq, [pixelsq+lsizeq*2] ADD_PIXELS_CLAMPED 96 RET -%endmacro - -INIT_MMX mmx -ADD_PIXELS_CLAMPED -INIT_XMM sse2 -ADD_PIXELS_CLAMPED diff --git a/media/ffvpx/libavcodec/x86/idctdsp.h b/media/ffvpx/libavcodec/x86/idctdsp.h index 0d0bdb5f578a..738e4e36e4e3 100644 --- a/media/ffvpx/libavcodec/x86/idctdsp.h +++ b/media/ffvpx/libavcodec/x86/idctdsp.h @@ -22,16 +22,10 @@ #include #include -void ff_add_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels, - ptrdiff_t line_size); void ff_add_pixels_clamped_sse2(const int16_t *block, uint8_t *pixels, ptrdiff_t line_size); -void ff_put_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels, - ptrdiff_t line_size); void ff_put_pixels_clamped_sse2(const int16_t *block, uint8_t *pixels, ptrdiff_t line_size); -void ff_put_signed_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels, - ptrdiff_t line_size); void ff_put_signed_pixels_clamped_sse2(const int16_t *block, uint8_t *pixels, ptrdiff_t line_size); diff --git a/media/ffvpx/libavcodec/x86/idctdsp_init.c b/media/ffvpx/libavcodec/x86/idctdsp_init.c index 9103b92ce7ae..f28a1ad744cb 100644 --- a/media/ffvpx/libavcodec/x86/idctdsp_init.c +++ b/media/ffvpx/libavcodec/x86/idctdsp_init.c @@ -63,28 +63,24 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx, { int cpu_flags = av_get_cpu_flags(); +#if ARCH_X86_32 if (EXTERNAL_MMX(cpu_flags)) { - c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmx; - c->put_pixels_clamped = ff_put_pixels_clamped_mmx; - c->add_pixels_clamped = ff_add_pixels_clamped_mmx; - if (!high_bit_depth && avctx->lowres == 0 && (avctx->idct_algo == FF_IDCT_AUTO || avctx->idct_algo == FF_IDCT_SIMPLEAUTO || avctx->idct_algo == FF_IDCT_SIMPLEMMX)) { - c->idct_put = ff_simple_idct_put_mmx; - c->idct_add = ff_simple_idct_add_mmx; c->idct = ff_simple_idct_mmx; - c->perm_type = FF_IDCT_PERM_SIMPLE; } } +#endif if (EXTERNAL_SSE2(cpu_flags)) { c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_sse2; c->put_pixels_clamped = ff_put_pixels_clamped_sse2; c->add_pixels_clamped = ff_add_pixels_clamped_sse2; +#if ARCH_X86_32 if (!high_bit_depth && avctx->lowres == 0 && (avctx->idct_algo == FF_IDCT_AUTO || @@ -94,6 +90,7 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx, c->idct_add = ff_simple_idct_add_sse2; c->perm_type = FF_IDCT_PERM_SIMPLE; } +#endif if (ARCH_X86_64 && !high_bit_depth && diff --git a/media/ffvpx/libavcodec/x86/imdct36.asm b/media/ffvpx/libavcodec/x86/imdct36.asm index b386ab95fc1c..888c6bf4d687 100644 --- a/media/ffvpx/libavcodec/x86/imdct36.asm +++ b/media/ffvpx/libavcodec/x86/imdct36.asm @@ -373,11 +373,6 @@ cglobal imdct36_float, 4,4,9, out, buf, in, win RET %endmacro -%if ARCH_X86_32 -INIT_XMM sse -DEFINE_IMDCT -%endif - INIT_XMM sse2 DEFINE_IMDCT diff --git a/media/ffvpx/libavcodec/x86/moz.build b/media/ffvpx/libavcodec/x86/moz.build index 580f1daa63c8..693218099ae6 100644 --- a/media/ffvpx/libavcodec/x86/moz.build +++ b/media/ffvpx/libavcodec/x86/moz.build @@ -19,7 +19,6 @@ SOURCES += [ 'idctdsp_init.c', 'imdct36.asm', 'mpegaudiodsp.c', - 'simple_idct.asm', 'videodsp.asm', 'videodsp_init.c', 'vp8dsp.asm', @@ -39,10 +38,11 @@ SOURCES += [ 'vp9mc_16bpp.asm', ] -if CONFIG['CPU_ARCH'] == "x86_64": - SOURCES += [ - 'simple_idct10.asm', - ] +if CONFIG['CPU_ARCH'] == 'x86': + SOURCES += [ 'simple_idct.asm' ] + +if CONFIG['CPU_ARCH'] == 'x86_64': + SOURCES += [ 'simple_idct10.asm' ] if CONFIG['MOZ_LIBAV_FFT']: SOURCES += [ diff --git a/media/ffvpx/libavcodec/x86/mpegaudiodsp.c b/media/ffvpx/libavcodec/x86/mpegaudiodsp.c index 50692f29cea7..6586fe0726cb 100644 --- a/media/ffvpx/libavcodec/x86/mpegaudiodsp.c +++ b/media/ffvpx/libavcodec/x86/mpegaudiodsp.c @@ -19,9 +19,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + +#include "config.h" #include "libavutil/attributes.h" #include "libavutil/cpu.h" -#include "libavutil/internal.h" #include "libavutil/mem_internal.h" #include "libavutil/x86/asm.h" #include "libavutil/x86/cpu.h" @@ -32,9 +34,6 @@ static void imdct36_blocks_ ## CPU(float *out, float *buf, float *in, int count, void ff_imdct36_float_ ## CPU(float *out, float *buf, float *in, float *win); #if HAVE_X86ASM -#if ARCH_X86_32 -DECL(sse) -#endif DECL(sse2) DECL(sse3) DECL(ssse3) @@ -228,9 +227,6 @@ static void imdct36_blocks_ ## CPU1(float *out, float *buf, float *in, \ } #if HAVE_SSE -#if ARCH_X86_32 -DECL_IMDCT_BLOCKS(sse,sse) -#endif DECL_IMDCT_BLOCKS(sse2,sse) DECL_IMDCT_BLOCKS(sse3,sse) DECL_IMDCT_BLOCKS(ssse3,sse) @@ -269,11 +265,6 @@ av_cold void ff_mpadsp_init_x86(MPADSPContext *s) #if HAVE_X86ASM #if HAVE_SSE -#if ARCH_X86_32 - if (EXTERNAL_SSE(cpu_flags)) { - s->imdct36_blocks_float = imdct36_blocks_sse; - } -#endif if (EXTERNAL_SSE2(cpu_flags)) { s->imdct36_blocks_float = imdct36_blocks_sse2; } diff --git a/media/ffvpx/libavcodec/x86/simple_idct.asm b/media/ffvpx/libavcodec/x86/simple_idct.asm index 6fedbb5784bd..dcf0da6df121 100644 --- a/media/ffvpx/libavcodec/x86/simple_idct.asm +++ b/media/ffvpx/libavcodec/x86/simple_idct.asm @@ -25,6 +25,7 @@ %include "libavutil/x86/x86util.asm" +%if ARCH_X86_32 SECTION_RODATA cextern pb_80 @@ -846,26 +847,6 @@ cglobal simple_idct, 1, 2, 8, 128, block, t0 IDCT RET -cglobal simple_idct_put, 3, 5, 8, 128, pixels, lsize, block, lsize3, t0 - IDCT - lea lsize3q, [lsizeq*3] - PUT_PIXELS_CLAMPED_HALF 0 - lea pixelsq, [pixelsq+lsizeq*4] - PUT_PIXELS_CLAMPED_HALF 64 -RET - -cglobal simple_idct_add, 3, 4, 8, 128, pixels, lsize, block, t0 - IDCT - pxor m4, m4 - ADD_PIXELS_CLAMPED 0 - lea pixelsq, [pixelsq+lsizeq*2] - ADD_PIXELS_CLAMPED 32 - lea pixelsq, [pixelsq+lsizeq*2] - ADD_PIXELS_CLAMPED 64 - lea pixelsq, [pixelsq+lsizeq*2] - ADD_PIXELS_CLAMPED 96 -RET - INIT_XMM sse2 cglobal simple_idct_put, 3, 5, 8, 128, pixels, lsize, block, lsize3, t0 @@ -887,3 +868,4 @@ cglobal simple_idct_add, 3, 4, 8, 128, pixels, lsize, block, t0 lea pixelsq, [pixelsq+lsizeq*2] ADD_PIXELS_CLAMPED 96 RET +%endif diff --git a/media/ffvpx/libavcodec/x86/videodsp.asm b/media/ffvpx/libavcodec/x86/videodsp.asm index e237860700be..b19a8300c54c 100644 --- a/media/ffvpx/libavcodec/x86/videodsp.asm +++ b/media/ffvpx/libavcodec/x86/videodsp.asm @@ -45,7 +45,6 @@ SECTION .text jnz .%1_y_loop %endmacro -%macro vvar_fn 0 ; .----. <- zero ; | | <- top is copied from first line in body of source ; |----| <- start_y @@ -53,6 +52,7 @@ SECTION .text ; |----| <- end_y ; | | <- bottom is copied from last line in body of source ; '----' <- bh +INIT_XMM sse %if ARCH_X86_64 cglobal emu_edge_vvar, 7, 8, 1, dst, dst_stride, src, src_stride, \ start_y, end_y, bh, w @@ -81,15 +81,6 @@ cglobal emu_edge_vvar, 1, 6, 1, dst, src, start_y, end_y, bh, w V_COPY_ROW bottom, bhq ; v_copy_row(bottom, bh) .end: ; } RET -%endmacro - -%if ARCH_X86_32 -INIT_MMX mmx -vvar_fn -%endif - -INIT_XMM sse -vvar_fn %macro hvar_fn 0 cglobal emu_edge_hvar, 5, 6, 1, dst, dst_stride, start_x, n_words, h, w @@ -105,11 +96,7 @@ cglobal emu_edge_hvar, 5, 6, 1, dst, dst_stride, start_x, n_words, h, w imul wd, 0x01010101 ; w *= 0x01010101 movd m0, wd mov wq, n_wordsq ; initialize w -%if cpuflag(sse2) pshufd m0, m0, q0000 ; splat -%else ; mmx - punpckldq m0, m0 ; splat -%endif ; mmx/sse %endif ; avx2 .x_loop: ; do { movu [dstq+wq*2], m0 ; write($reg, $mmsize) @@ -123,11 +110,6 @@ cglobal emu_edge_hvar, 5, 6, 1, dst, dst_stride, start_x, n_words, h, w RET %endmacro -%if ARCH_X86_32 -INIT_MMX mmx -hvar_fn -%endif - INIT_XMM sse2 hvar_fn @@ -338,9 +320,6 @@ cglobal emu_edge_vfix %+ %%n, 1, 5, 1, dst, src, start_y, end_y, bh INIT_MMX mmx VERTICAL_EXTEND 1, 15 -%if ARCH_X86_32 -VERTICAL_EXTEND 16, 22 -%endif INIT_XMM sse VERTICAL_EXTEND 16, 22 @@ -438,9 +417,6 @@ cglobal emu_edge_hfix %+ %%n, 4, 5, 1, dst, dst_stride, start_x, bh, val INIT_MMX mmx H_EXTEND 2, 14 -%if ARCH_X86_32 -H_EXTEND 16, 22 -%endif INIT_XMM sse2 H_EXTEND 16, 22 @@ -450,19 +426,11 @@ INIT_XMM avx2 H_EXTEND 8, 22 %endif -%macro PREFETCH_FN 1 +INIT_MMX mmxext cglobal prefetch, 3, 3, 0, buf, stride, h .loop: - %1 [bufq] + prefetcht0 [bufq] add bufq, strideq dec hd jg .loop REP_RET -%endmacro - -INIT_MMX mmxext -PREFETCH_FN prefetcht0 -%if ARCH_X86_32 -INIT_MMX 3dnow -PREFETCH_FN prefetch -%endif diff --git a/media/ffvpx/libavcodec/x86/videodsp_init.c b/media/ffvpx/libavcodec/x86/videodsp_init.c index eeebb415479d..a14c9635fb55 100644 --- a/media/ffvpx/libavcodec/x86/videodsp_init.c +++ b/media/ffvpx/libavcodec/x86/videodsp_init.c @@ -24,7 +24,6 @@ #include "libavutil/avassert.h" #include "libavutil/common.h" #include "libavutil/cpu.h" -#include "libavutil/mem.h" #include "libavutil/x86/asm.h" #include "libavutil/x86/cpu.h" #include "libavcodec/videodsp.h" @@ -53,26 +52,6 @@ extern emu_edge_vfix_func ff_emu_edge_vfix12_mmx; extern emu_edge_vfix_func ff_emu_edge_vfix13_mmx; extern emu_edge_vfix_func ff_emu_edge_vfix14_mmx; extern emu_edge_vfix_func ff_emu_edge_vfix15_mmx; -extern emu_edge_vfix_func ff_emu_edge_vfix16_mmx; -extern emu_edge_vfix_func ff_emu_edge_vfix17_mmx; -extern emu_edge_vfix_func ff_emu_edge_vfix18_mmx; -extern emu_edge_vfix_func ff_emu_edge_vfix19_mmx; -extern emu_edge_vfix_func ff_emu_edge_vfix20_mmx; -extern emu_edge_vfix_func ff_emu_edge_vfix21_mmx; -extern emu_edge_vfix_func ff_emu_edge_vfix22_mmx; -#if ARCH_X86_32 -static emu_edge_vfix_func * const vfixtbl_mmx[22] = { - &ff_emu_edge_vfix1_mmx, &ff_emu_edge_vfix2_mmx, &ff_emu_edge_vfix3_mmx, - &ff_emu_edge_vfix4_mmx, &ff_emu_edge_vfix5_mmx, &ff_emu_edge_vfix6_mmx, - &ff_emu_edge_vfix7_mmx, &ff_emu_edge_vfix8_mmx, &ff_emu_edge_vfix9_mmx, - &ff_emu_edge_vfix10_mmx, &ff_emu_edge_vfix11_mmx, &ff_emu_edge_vfix12_mmx, - &ff_emu_edge_vfix13_mmx, &ff_emu_edge_vfix14_mmx, &ff_emu_edge_vfix15_mmx, - &ff_emu_edge_vfix16_mmx, &ff_emu_edge_vfix17_mmx, &ff_emu_edge_vfix18_mmx, - &ff_emu_edge_vfix19_mmx, &ff_emu_edge_vfix20_mmx, &ff_emu_edge_vfix21_mmx, - &ff_emu_edge_vfix22_mmx -}; -#endif -extern emu_edge_vvar_func ff_emu_edge_vvar_mmx; extern emu_edge_vfix_func ff_emu_edge_vfix16_sse; extern emu_edge_vfix_func ff_emu_edge_vfix17_sse; extern emu_edge_vfix_func ff_emu_edge_vfix18_sse; @@ -104,19 +83,6 @@ extern emu_edge_hfix_func ff_emu_edge_hfix8_mmx; extern emu_edge_hfix_func ff_emu_edge_hfix10_mmx; extern emu_edge_hfix_func ff_emu_edge_hfix12_mmx; extern emu_edge_hfix_func ff_emu_edge_hfix14_mmx; -extern emu_edge_hfix_func ff_emu_edge_hfix16_mmx; -extern emu_edge_hfix_func ff_emu_edge_hfix18_mmx; -extern emu_edge_hfix_func ff_emu_edge_hfix20_mmx; -extern emu_edge_hfix_func ff_emu_edge_hfix22_mmx; -#if ARCH_X86_32 -static emu_edge_hfix_func * const hfixtbl_mmx[11] = { - ff_emu_edge_hfix2_mmx, ff_emu_edge_hfix4_mmx, ff_emu_edge_hfix6_mmx, - ff_emu_edge_hfix8_mmx, ff_emu_edge_hfix10_mmx, ff_emu_edge_hfix12_mmx, - ff_emu_edge_hfix14_mmx, ff_emu_edge_hfix16_mmx, ff_emu_edge_hfix18_mmx, - ff_emu_edge_hfix20_mmx, ff_emu_edge_hfix22_mmx -}; -#endif -extern emu_edge_hvar_func ff_emu_edge_hvar_mmx; extern emu_edge_hfix_func ff_emu_edge_hfix16_sse2; extern emu_edge_hfix_func ff_emu_edge_hfix18_sse2; extern emu_edge_hfix_func ff_emu_edge_hfix20_sse2; @@ -222,30 +188,6 @@ static av_always_inline void emulated_edge_mc(uint8_t *dst, const uint8_t *src, } } -#if ARCH_X86_32 -static av_noinline void emulated_edge_mc_mmx(uint8_t *buf, const uint8_t *src, - ptrdiff_t buf_stride, - ptrdiff_t src_stride, - int block_w, int block_h, - int src_x, int src_y, int w, int h) -{ - emulated_edge_mc(buf, src, buf_stride, src_stride, block_w, block_h, - src_x, src_y, w, h, vfixtbl_mmx, &ff_emu_edge_vvar_mmx, - hfixtbl_mmx, &ff_emu_edge_hvar_mmx); -} - -static av_noinline void emulated_edge_mc_sse(uint8_t *buf, const uint8_t *src, - ptrdiff_t buf_stride, - ptrdiff_t src_stride, - int block_w, int block_h, - int src_x, int src_y, int w, int h) -{ - emulated_edge_mc(buf, src, buf_stride, src_stride, block_w, block_h, - src_x, src_y, w, h, vfixtbl_sse, &ff_emu_edge_vvar_sse, - hfixtbl_mmx, &ff_emu_edge_hvar_mmx); -} -#endif - static av_noinline void emulated_edge_mc_sse2(uint8_t *buf, const uint8_t *src, ptrdiff_t buf_stride, ptrdiff_t src_stride, @@ -274,29 +216,15 @@ static av_noinline void emulated_edge_mc_avx2(uint8_t *buf, const uint8_t *src, #endif /* HAVE_X86ASM */ void ff_prefetch_mmxext(uint8_t *buf, ptrdiff_t stride, int h); -void ff_prefetch_3dnow(uint8_t *buf, ptrdiff_t stride, int h); av_cold void ff_videodsp_init_x86(VideoDSPContext *ctx, int bpc) { #if HAVE_X86ASM int cpu_flags = av_get_cpu_flags(); -#if ARCH_X86_32 - if (EXTERNAL_MMX(cpu_flags) && bpc <= 8) { - ctx->emulated_edge_mc = emulated_edge_mc_mmx; - } - if (EXTERNAL_AMD3DNOW(cpu_flags)) { - ctx->prefetch = ff_prefetch_3dnow; - } -#endif /* ARCH_X86_32 */ if (EXTERNAL_MMXEXT(cpu_flags)) { ctx->prefetch = ff_prefetch_mmxext; } -#if ARCH_X86_32 - if (EXTERNAL_SSE(cpu_flags) && bpc <= 8) { - ctx->emulated_edge_mc = emulated_edge_mc_sse; - } -#endif /* ARCH_X86_32 */ if (EXTERNAL_SSE2(cpu_flags) && bpc <= 8) { ctx->emulated_edge_mc = emulated_edge_mc_sse2; } diff --git a/media/ffvpx/libavcodec/x86/vp56_arith.h b/media/ffvpx/libavcodec/x86/vp56_arith.h index 810cc8dcd817..9f7639980c3a 100644 --- a/media/ffvpx/libavcodec/x86/vp56_arith.h +++ b/media/ffvpx/libavcodec/x86/vp56_arith.h @@ -25,6 +25,8 @@ #define AVCODEC_X86_VP56_ARITH_H #if HAVE_INLINE_ASM && HAVE_FAST_CMOV && HAVE_6REGS +#include "libavutil/attributes.h" + #define vp56_rac_get_prob vp56_rac_get_prob static av_always_inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) { diff --git a/media/ffvpx/libavcodec/x86/vp8dsp.asm b/media/ffvpx/libavcodec/x86/vp8dsp.asm index 75de5690a1a0..1c59e884edc1 100644 --- a/media/ffvpx/libavcodec/x86/vp8dsp.asm +++ b/media/ffvpx/libavcodec/x86/vp8dsp.asm @@ -840,25 +840,6 @@ cglobal put_vp8_pixels8, 5, 5, 0, dst, dststride, src, srcstride, height jg .nextrow REP_RET -%if ARCH_X86_32 -INIT_MMX mmx -cglobal put_vp8_pixels16, 5, 5, 0, dst, dststride, src, srcstride, height -.nextrow: - movq mm0, [srcq+srcstrideq*0+0] - movq mm1, [srcq+srcstrideq*0+8] - movq mm2, [srcq+srcstrideq*1+0] - movq mm3, [srcq+srcstrideq*1+8] - lea srcq, [srcq+srcstrideq*2] - movq [dstq+dststrideq*0+0], mm0 - movq [dstq+dststrideq*0+8], mm1 - movq [dstq+dststrideq*1+0], mm2 - movq [dstq+dststrideq*1+8], mm3 - lea dstq, [dstq+dststrideq*2] - sub heightd, 2 - jg .nextrow - REP_RET -%endif - INIT_XMM sse cglobal put_vp8_pixels16, 5, 5, 2, dst, dststride, src, srcstride, height .nextrow: @@ -895,32 +876,6 @@ cglobal put_vp8_pixels16, 5, 5, 2, dst, dststride, src, srcstride, height %4 [dst2q+strideq+%3], m5 %endmacro -%if ARCH_X86_32 -INIT_MMX mmx -cglobal vp8_idct_dc_add, 3, 3, 0, dst, block, stride - ; load data - movd m0, [blockq] - - ; calculate DC - paddw m0, [pw_4] - pxor m1, m1 - psraw m0, 3 - movd [blockq], m1 - psubw m1, m0 - packuswb m0, m0 - packuswb m1, m1 - punpcklbw m0, m0 - punpcklbw m1, m1 - punpcklwd m0, m0 - punpcklwd m1, m1 - - ; add DC - DEFINE_ARGS dst1, dst2, stride - lea dst2q, [dst1q+strideq*2] - ADD_DC m0, m1, 0, movh - RET -%endif - %macro VP8_IDCT_DC_ADD 0 cglobal vp8_idct_dc_add, 3, 3, 6, dst, block, stride ; load data @@ -971,44 +926,6 @@ VP8_IDCT_DC_ADD ; void ff_vp8_idct_dc_add4y_(uint8_t *dst, int16_t block[4][16], ptrdiff_t stride); ;----------------------------------------------------------------------------- -%if ARCH_X86_32 -INIT_MMX mmx -cglobal vp8_idct_dc_add4y, 3, 3, 0, dst, block, stride - ; load data - movd m0, [blockq+32*0] ; A - movd m1, [blockq+32*2] ; C - punpcklwd m0, [blockq+32*1] ; A B - punpcklwd m1, [blockq+32*3] ; C D - punpckldq m0, m1 ; A B C D - pxor m6, m6 - - ; calculate DC - paddw m0, [pw_4] - movd [blockq+32*0], m6 - movd [blockq+32*1], m6 - movd [blockq+32*2], m6 - movd [blockq+32*3], m6 - psraw m0, 3 - psubw m6, m0 - packuswb m0, m0 - packuswb m6, m6 - punpcklbw m0, m0 ; AABBCCDD - punpcklbw m6, m6 ; AABBCCDD - movq m1, m0 - movq m7, m6 - punpcklbw m0, m0 ; AAAABBBB - punpckhbw m1, m1 ; CCCCDDDD - punpcklbw m6, m6 ; AAAABBBB - punpckhbw m7, m7 ; CCCCDDDD - - ; add DC - DEFINE_ARGS dst1, dst2, stride - lea dst2q, [dst1q+strideq*2] - ADD_DC m0, m6, 0, mova - ADD_DC m1, m7, 8, mova - RET -%endif - INIT_XMM sse2 cglobal vp8_idct_dc_add4y, 3, 3, 6, dst, block, stride ; load data @@ -1117,7 +1034,7 @@ cglobal vp8_idct_dc_add4uv, 3, 3, 0, dst, block, stride SWAP %4, %3 %endmacro -%macro VP8_IDCT_ADD 0 +INIT_MMX sse cglobal vp8_idct_add, 3, 3, 0, dst, block, stride ; load block data movq m0, [blockq+ 0] @@ -1126,17 +1043,9 @@ cglobal vp8_idct_add, 3, 3, 0, dst, block, stride movq m3, [blockq+24] movq m6, [pw_20091] movq m7, [pw_17734] -%if cpuflag(sse) xorps xmm0, xmm0 movaps [blockq+ 0], xmm0 movaps [blockq+16], xmm0 -%else - pxor m4, m4 - movq [blockq+ 0], m4 - movq [blockq+ 8], m4 - movq [blockq+16], m4 - movq [blockq+24], m4 -%endif ; actual IDCT VP8_IDCT_TRANSFORM4x4_1D 0, 1, 2, 3, 4, 5 @@ -1153,14 +1062,6 @@ cglobal vp8_idct_add, 3, 3, 0, dst, block, stride STORE_DIFFx2 m2, m3, m6, m7, m4, 3, dst2q, strideq RET -%endmacro - -%if ARCH_X86_32 -INIT_MMX mmx -VP8_IDCT_ADD -%endif -INIT_MMX sse -VP8_IDCT_ADD ;----------------------------------------------------------------------------- ; void ff_vp8_luma_dc_wht(int16_t block[4][4][16], int16_t dc[16]) @@ -1193,23 +1094,15 @@ VP8_IDCT_ADD SWAP %1, %4, %3 %endmacro -%macro VP8_DC_WHT 0 +INIT_MMX sse cglobal vp8_luma_dc_wht, 2, 3, 0, block, dc1, dc2 movq m0, [dc1q] movq m1, [dc1q+8] movq m2, [dc1q+16] movq m3, [dc1q+24] -%if cpuflag(sse) xorps xmm0, xmm0 movaps [dc1q+ 0], xmm0 movaps [dc1q+16], xmm0 -%else - pxor m4, m4 - movq [dc1q+ 0], m4 - movq [dc1q+ 8], m4 - movq [dc1q+16], m4 - movq [dc1q+24], m4 -%endif HADAMARD4_1D 0, 1, 2, 3 TRANSPOSE4x4W 0, 1, 2, 3, 4 paddw m0, [pw_3] @@ -1221,11 +1114,3 @@ cglobal vp8_luma_dc_wht, 2, 3, 0, block, dc1, dc2 SCATTER_WHT 0, 1, 0 SCATTER_WHT 2, 3, 2 RET -%endmacro - -%if ARCH_X86_32 -INIT_MMX mmx -VP8_DC_WHT -%endif -INIT_MMX sse -VP8_DC_WHT diff --git a/media/ffvpx/libavcodec/x86/vp8dsp_init.c b/media/ffvpx/libavcodec/x86/vp8dsp_init.c index dffa7a2418c0..cceb346ced23 100644 --- a/media/ffvpx/libavcodec/x86/vp8dsp_init.c +++ b/media/ffvpx/libavcodec/x86/vp8dsp_init.c @@ -22,7 +22,6 @@ #include "libavutil/attributes.h" #include "libavutil/cpu.h" -#include "libavutil/mem.h" #include "libavutil/mem_internal.h" #include "libavutil/x86/cpu.h" #include "libavcodec/vp8dsp.h" @@ -113,9 +112,6 @@ void ff_put_vp8_bilinear8_v_ssse3 (uint8_t *dst, ptrdiff_t dststride, void ff_put_vp8_pixels8_mmx (uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); -void ff_put_vp8_pixels16_mmx(uint8_t *dst, ptrdiff_t dststride, - uint8_t *src, ptrdiff_t srcstride, - int height, int mx, int my); void ff_put_vp8_pixels16_sse(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int height, int mx, int my); @@ -141,19 +137,6 @@ static void ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \ dst + 4, dststride, src + 4, srcstride, height, mx, my); \ } -#if ARCH_X86_32 -TAP_W8 (mmxext, epel, h4) -TAP_W8 (mmxext, epel, h6) -TAP_W16(mmxext, epel, h6) -TAP_W8 (mmxext, epel, v4) -TAP_W8 (mmxext, epel, v6) -TAP_W16(mmxext, epel, v6) -TAP_W8 (mmxext, bilinear, h) -TAP_W16(mmxext, bilinear, h) -TAP_W8 (mmxext, bilinear, v) -TAP_W16(mmxext, bilinear, v) -#endif - TAP_W16(sse2, epel, h6) TAP_W16(sse2, epel, v6) TAP_W16(sse2, bilinear, h) @@ -178,16 +161,8 @@ static void ff_put_vp8_epel ## SIZE ## _h ## TAPNUMX ## v ## TAPNUMY ## _ ## OPT dst, dststride, tmpptr, SIZE, height, mx, my); \ } -#if ARCH_X86_32 -#define HVTAPMMX(x, y) \ -HVTAP(mmxext, 8, x, y, 4, 8) \ -HVTAP(mmxext, 8, x, y, 8, 16) - -HVTAP(mmxext, 8, 6, 6, 16, 16) -#else #define HVTAPMMX(x, y) \ HVTAP(mmxext, 8, x, y, 4, 8) -#endif HVTAPMMX(4, 4) HVTAPMMX(4, 6) @@ -222,31 +197,21 @@ static void ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT( \ } HVBILIN(mmxext, 8, 4, 8) -#if ARCH_X86_32 -HVBILIN(mmxext, 8, 8, 16) -HVBILIN(mmxext, 8, 16, 16) -#endif HVBILIN(sse2, 8, 8, 16) HVBILIN(sse2, 8, 16, 16) HVBILIN(ssse3, 8, 4, 8) HVBILIN(ssse3, 8, 8, 16) HVBILIN(ssse3, 8, 16, 16) -void ff_vp8_idct_dc_add_mmx(uint8_t *dst, int16_t block[16], - ptrdiff_t stride); void ff_vp8_idct_dc_add_sse2(uint8_t *dst, int16_t block[16], ptrdiff_t stride); void ff_vp8_idct_dc_add_sse4(uint8_t *dst, int16_t block[16], ptrdiff_t stride); -void ff_vp8_idct_dc_add4y_mmx(uint8_t *dst, int16_t block[4][16], - ptrdiff_t stride); void ff_vp8_idct_dc_add4y_sse2(uint8_t *dst, int16_t block[4][16], ptrdiff_t stride); void ff_vp8_idct_dc_add4uv_mmx(uint8_t *dst, int16_t block[2][16], ptrdiff_t stride); -void ff_vp8_luma_dc_wht_mmx(int16_t block[4][4][16], int16_t dc[16]); void ff_vp8_luma_dc_wht_sse(int16_t block[4][4][16], int16_t dc[16]); -void ff_vp8_idct_add_mmx(uint8_t *dst, int16_t block[16], ptrdiff_t stride); void ff_vp8_idct_add_sse(uint8_t *dst, int16_t block[16], ptrdiff_t stride); #define DECLARE_LOOP_FILTER(NAME) \ @@ -285,8 +250,6 @@ void ff_vp8_h_loop_filter8uv_mbedge_ ## NAME(uint8_t *dstU, \ ptrdiff_t s, \ int e, int i, int hvt); -DECLARE_LOOP_FILTER(mmx) -DECLARE_LOOP_FILTER(mmxext) DECLARE_LOOP_FILTER(sse2) DECLARE_LOOP_FILTER(ssse3) DECLARE_LOOP_FILTER(sse4) @@ -323,10 +286,6 @@ av_cold void ff_vp78dsp_init_x86(VP8DSPContext *c) int cpu_flags = av_get_cpu_flags(); if (EXTERNAL_MMX(cpu_flags)) { -#if ARCH_X86_32 - c->put_vp8_epel_pixels_tab[0][0][0] = - c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_mmx; -#endif c->put_vp8_epel_pixels_tab[1][0][0] = c->put_vp8_bilinear_pixels_tab[1][0][0] = ff_put_vp8_pixels8_mmx; } @@ -336,12 +295,6 @@ av_cold void ff_vp78dsp_init_x86(VP8DSPContext *c) if (EXTERNAL_MMXEXT(cpu_flags)) { VP8_MC_FUNC(2, 4, mmxext); VP8_BILINEAR_MC_FUNC(2, 4, mmxext); -#if ARCH_X86_32 - VP8_LUMA_MC_FUNC(0, 16, mmxext); - VP8_MC_FUNC(1, 8, mmxext); - VP8_BILINEAR_MC_FUNC(0, 16, mmxext); - VP8_BILINEAR_MC_FUNC(1, 8, mmxext); -#endif } if (EXTERNAL_SSE(cpu_flags)) { @@ -349,7 +302,7 @@ av_cold void ff_vp78dsp_init_x86(VP8DSPContext *c) c->put_vp8_bilinear_pixels_tab[0][0][0] = ff_put_vp8_pixels16_sse; } - if (EXTERNAL_SSE2(cpu_flags) || EXTERNAL_SSE2_SLOW(cpu_flags)) { + if (EXTERNAL_SSE2_SLOW(cpu_flags)) { VP8_LUMA_MC_FUNC(0, 16, sse2); VP8_MC_FUNC(1, 8, sse2); VP8_BILINEAR_MC_FUNC(0, 16, sse2); @@ -374,44 +327,6 @@ av_cold void ff_vp8dsp_init_x86(VP8DSPContext *c) if (EXTERNAL_MMX(cpu_flags)) { c->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_mmx; -#if ARCH_X86_32 - c->vp8_idct_dc_add = ff_vp8_idct_dc_add_mmx; - c->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_mmx; - c->vp8_idct_add = ff_vp8_idct_add_mmx; - c->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_mmx; - - c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmx; - c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmx; - - c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_mmx; - c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_mmx; - c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_mmx; - c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_mmx; - - c->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16y_mbedge_mmx; - c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_mmx; - c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_mmx; - c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_mmx; -#endif - } - - /* note that 4-tap width=16 functions are missing because w=16 - * is only used for luma, and luma is always a copy or sixtap. */ - if (EXTERNAL_MMXEXT(cpu_flags)) { -#if ARCH_X86_32 - c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmxext; - c->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmxext; - - c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_mmxext; - c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_mmxext; - c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_mmxext; - c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_mmxext; - - c->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16y_mbedge_mmxext; - c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_mmxext; - c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_mmxext; - c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_mmxext; -#endif } if (EXTERNAL_SSE(cpu_flags)) { @@ -419,7 +334,7 @@ av_cold void ff_vp8dsp_init_x86(VP8DSPContext *c) c->vp8_luma_dc_wht = ff_vp8_luma_dc_wht_sse; } - if (EXTERNAL_SSE2(cpu_flags) || EXTERNAL_SSE2_SLOW(cpu_flags)) { + if (EXTERNAL_SSE2_SLOW(cpu_flags)) { c->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_sse2; c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_sse2; diff --git a/media/ffvpx/libavcodec/x86/vp8dsp_loopfilter.asm b/media/ffvpx/libavcodec/x86/vp8dsp_loopfilter.asm index caeb40526706..ef397efd3e11 100644 --- a/media/ffvpx/libavcodec/x86/vp8dsp_loopfilter.asm +++ b/media/ffvpx/libavcodec/x86/vp8dsp_loopfilter.asm @@ -46,30 +46,6 @@ SECTION .text ; void ff_vp8_h/v_loop_filter_simple_(uint8_t *dst, ptrdiff_t stride, int flim); ;----------------------------------------------------------------------------- -; macro called with 7 mm register indexes as argument, and 4 regular registers -; -; first 4 mm registers will carry the transposed pixel data -; the other three are scratchspace (one would be sufficient, but this allows -; for more spreading/pipelining and thus faster execution on OOE CPUs) -; -; first two regular registers are buf+4*stride and buf+5*stride -; third is -stride, fourth is +stride -%macro READ_8x4_INTERLEAVED 11 - ; interleave 8 (A-H) rows of 4 pixels each - movd m%1, [%8+%10*4] ; A0-3 - movd m%5, [%9+%10*4] ; B0-3 - movd m%2, [%8+%10*2] ; C0-3 - movd m%6, [%8+%10] ; D0-3 - movd m%3, [%8] ; E0-3 - movd m%7, [%9] ; F0-3 - movd m%4, [%9+%11] ; G0-3 - punpcklbw m%1, m%5 ; A/B interleaved - movd m%5, [%9+%11*2] ; H0-3 - punpcklbw m%2, m%6 ; C/D interleaved - punpcklbw m%3, m%7 ; E/F interleaved - punpcklbw m%4, m%5 ; G/H interleaved -%endmacro - ; macro called with 7 mm register indexes as argument, and 5 regular registers ; first 11 mean the same as READ_8x4_TRANSPOSED above ; fifth regular register is scratchspace to reach the bottom 8 rows, it @@ -112,26 +88,6 @@ SECTION .text punpcklbw m%4, m%5 ; G/H/O/P interleaved %endmacro -; write 4 mm registers of 2 dwords each -; first four arguments are mm register indexes containing source data -; last four are registers containing buf+4*stride, buf+5*stride, -; -stride and +stride -%macro WRITE_4x2D 8 - ; write out (2 dwords per register) - movd [%5+%7*4], m%1 - movd [%5+%7*2], m%2 - movd [%5], m%3 - movd [%6+%8], m%4 - punpckhdq m%1, m%1 - punpckhdq m%2, m%2 - punpckhdq m%3, m%3 - punpckhdq m%4, m%4 - movd [%6+%7*4], m%1 - movd [%5+%7], m%2 - movd [%6], m%3 - movd [%6+%8*2], m%4 -%endmacro - ; write 4 xmm registers of 4 dwords each ; arguments same as WRITE_2x4D, but with an extra register, so that the 5 regular ; registers contain buf+4*stride, buf+5*stride, buf+12*stride, -stride and +stride @@ -192,42 +148,6 @@ SECTION .text movd [%7+%9*2], m%4 %endmacro -; write 4 or 8 words in the mmx/xmm registers as 8 lines -; 1 and 2 are the registers to write, this can be the same (for SSE2) -; for pre-SSE4: -; 3 is a general-purpose register that we will clobber -; for SSE4: -; 3 is a pointer to the destination's 5th line -; 4 is a pointer to the destination's 4th line -; 5/6 is -stride and +stride -%macro WRITE_2x4W 6 - movd %3d, %1 - punpckhdq %1, %1 - mov [%4+%5*4], %3w - shr %3, 16 - add %4, %6 - mov [%4+%5*4], %3w - - movd %3d, %1 - add %4, %5 - mov [%4+%5*2], %3w - shr %3, 16 - mov [%4+%5 ], %3w - - movd %3d, %2 - punpckhdq %2, %2 - mov [%4 ], %3w - shr %3, 16 - mov [%4+%6 ], %3w - - movd %3d, %2 - add %4, %6 - mov [%4+%6 ], %3w - shr %3, 16 - mov [%4+%6*2], %3w - add %4, %5 -%endmacro - %macro WRITE_8W 5 %if cpuflag(sse4) pextrw [%3+%4*4], %1, 0 @@ -269,29 +189,19 @@ SECTION .text %macro SIMPLE_LOOPFILTER 2 cglobal vp8_%1_loop_filter_simple, 3, %2, 8, dst, stride, flim, cntr -%if mmsize == 8 ; mmx/mmxext - mov cntrq, 2 -%endif %if cpuflag(ssse3) pxor m0, m0 %endif SPLATB_REG m7, flim, m0 ; splat "flim" into register ; set up indexes to address 4 rows -%if mmsize == 8 - DEFINE_ARGS dst1, mstride, stride, cntr, dst2 -%else DEFINE_ARGS dst1, mstride, stride, dst3, dst2 -%endif mov strideq, mstrideq neg mstrideq %ifidn %1, h lea dst1q, [dst1q+4*strideq-2] %endif -%if mmsize == 8 ; mmx / mmxext -.next8px: -%endif %ifidn %1, v ; read 4 half/full rows of pixels mova m0, [dst1q+mstrideq*2] ; p1 @@ -301,11 +211,7 @@ cglobal vp8_%1_loop_filter_simple, 3, %2, 8, dst, stride, flim, cntr %else ; h lea dst2q, [dst1q+ strideq] -%if mmsize == 8 ; mmx/mmxext - READ_8x4_INTERLEAVED 0, 1, 2, 3, 4, 5, 6, dst1q, dst2q, mstrideq, strideq -%else ; sse2 READ_16x4_INTERLEAVED 0, 1, 2, 3, 4, 5, 6, dst1q, dst2q, mstrideq, strideq, dst3q -%endif TRANSPOSE4x4W 0, 1, 2, 3, 4 %endif @@ -380,7 +286,6 @@ cglobal vp8_%1_loop_filter_simple, 3, %2, 8, dst, stride, flim, cntr inc dst1q SBUTTERFLY bw, 6, 4, 0 -%if mmsize == 16 ; sse2 %if cpuflag(sse4) inc dst2q %endif @@ -390,35 +295,11 @@ cglobal vp8_%1_loop_filter_simple, 3, %2, 8, dst, stride, flim, cntr inc dst3q %endif WRITE_8W m4, dst3q, dst2q, mstrideq, strideq -%else ; mmx/mmxext - WRITE_2x4W m6, m4, dst2q, dst1q, mstrideq, strideq -%endif %endif -%if mmsize == 8 ; mmx/mmxext - ; next 8 pixels -%ifidn %1, v - add dst1q, 8 ; advance 8 cols = pixels -%else ; h - lea dst1q, [dst1q+strideq*8-1] ; advance 8 rows = lines -%endif - dec cntrq - jg .next8px - REP_RET -%else ; sse2 RET -%endif %endmacro -%if ARCH_X86_32 -INIT_MMX mmx -SIMPLE_LOOPFILTER v, 4 -SIMPLE_LOOPFILTER h, 5 -INIT_MMX mmxext -SIMPLE_LOOPFILTER v, 4 -SIMPLE_LOOPFILTER h, 5 -%endif - INIT_XMM sse2 SIMPLE_LOOPFILTER v, 3 SIMPLE_LOOPFILTER h, 5 @@ -485,9 +366,6 @@ cglobal vp8_%1_loop_filter16y_inner, 5, 5, 13, stack_size, dst, stride, flimE, f %if %2 == 8 ; chroma DEFINE_ARGS dst1, dst8, mstride, stride, dst2 -%elif mmsize == 8 - DEFINE_ARGS dst1, mstride, stride, dst2, cntr - mov cntrq, 2 %else DEFINE_ARGS dst1, mstride, stride, dst2, dst8 %endif @@ -500,9 +378,6 @@ cglobal vp8_%1_loop_filter16y_inner, 5, 5, 13, stack_size, dst, stride, flimE, f %endif %endif -%if mmsize == 8 -.next8px: -%endif ; read lea dst2q, [dst1q+strideq] %ifidn %1, v @@ -527,33 +402,7 @@ cglobal vp8_%1_loop_filter16y_inner, 5, 5, 13, stack_size, dst, stride, flimE, f movhps m7, [dst8q+ strideq*2] add dst8q, mstrideq %endif -%elif mmsize == 8 ; mmx/mmxext (h) - ; read 8 rows of 8px each - movu m0, [dst1q+mstrideq*4] - movu m1, [dst2q+mstrideq*4] - movu m2, [dst1q+mstrideq*2] - movu m3, [dst1q+mstrideq ] - movu m4, [dst1q] - movu m5, [dst2q] - movu m6, [dst2q+ strideq ] - - ; 8x8 transpose - TRANSPOSE4x4B 0, 1, 2, 3, 7 - mova m_q0backup, m1 - movu m7, [dst2q+ strideq*2] - TRANSPOSE4x4B 4, 5, 6, 7, 1 - SBUTTERFLY dq, 0, 4, 1 ; p3/p2 - SBUTTERFLY dq, 2, 6, 1 ; q0/q1 - SBUTTERFLY dq, 3, 7, 1 ; q2/q3 - mova m1, m_q0backup - mova m_q0backup, m2 ; store q0 - SBUTTERFLY dq, 1, 5, 2 ; p1/p0 - mova m_p0backup, m5 ; store p0 - SWAP 1, 4 - SWAP 2, 4 - SWAP 6, 3 - SWAP 5, 3 -%else ; sse2 (h) +%else ; h %if %2 == 16 lea dst8q, [dst1q+ strideq*8] %endif @@ -641,25 +490,9 @@ cglobal vp8_%1_loop_filter16y_inner, 5, 5, 13, stack_size, dst, stride, flimE, f psubusb m6, m5 ; q2-q1 por m6, m4 ; abs(q2-q1) -%if notcpuflag(mmxext) - mova m4, m_flimI - pxor m3, m3 - psubusb m0, m4 - psubusb m1, m4 - psubusb m7, m4 - psubusb m6, m4 - pcmpeqb m0, m3 ; abs(p3-p2) <= I - pcmpeqb m1, m3 ; abs(p2-p1) <= I - pcmpeqb m7, m3 ; abs(q3-q2) <= I - pcmpeqb m6, m3 ; abs(q2-q1) <= I - pand m0, m1 - pand m7, m6 - pand m0, m7 -%else ; mmxext/sse2 pmaxub m0, m1 pmaxub m6, m7 pmaxub m0, m6 -%endif ; normal_limit and high_edge_variance for p1-p0, q1-q0 SWAP 7, 3 ; now m7 is zero @@ -681,18 +514,8 @@ cglobal vp8_%1_loop_filter16y_inner, 5, 5, 13, stack_size, dst, stride, flimE, f psubusb m1, m3 ; p1-p0 psubusb m6, m2 ; p0-p1 por m1, m6 ; abs(p1-p0) -%if notcpuflag(mmxext) - mova m6, m1 - psubusb m1, m4 - psubusb m6, m_hevthr - pcmpeqb m1, m7 ; abs(p1-p0) <= I - pcmpeqb m6, m7 ; abs(p1-p0) <= hev_thresh - pand m0, m1 - mova m_maskres, m6 -%else ; mmxext/sse2 pmaxub m0, m1 ; max_I SWAP 1, 4 ; max_hev_thresh -%endif SWAP 6, 4 ; now m6 is I %ifidn %1, v @@ -712,17 +535,6 @@ cglobal vp8_%1_loop_filter16y_inner, 5, 5, 13, stack_size, dst, stride, flimE, f psubusb m1, m5 ; q0-q1 psubusb m7, m4 ; q1-q0 por m1, m7 ; abs(q1-q0) -%if notcpuflag(mmxext) - mova m7, m1 - psubusb m1, m6 - psubusb m7, m_hevthr - pxor m6, m6 - pcmpeqb m1, m6 ; abs(q1-q0) <= I - pcmpeqb m7, m6 ; abs(q1-q0) <= hev_thresh - mova m6, m_maskres - pand m0, m1 ; abs([pq][321]-[pq][210]) <= I - pand m6, m7 -%else ; mmxext/sse2 pxor m7, m7 pmaxub m0, m1 pmaxub m6, m1 @@ -730,7 +542,6 @@ cglobal vp8_%1_loop_filter16y_inner, 5, 5, 13, stack_size, dst, stride, flimE, f psubusb m6, m_hevthr pcmpeqb m0, m7 ; max(abs(..)) <= I pcmpeqb m6, m7 ; !(max(abs..) > thresh) -%endif %ifdef m12 SWAP 6, 12 %else @@ -820,25 +631,12 @@ cglobal vp8_%1_loop_filter16y_inner, 5, 5, 13, stack_size, dst, stride, flimE, f %else mova m6, m_maskres %endif -%if notcpuflag(mmxext) - mova m7, [pb_1] -%else ; mmxext/sse2 pxor m7, m7 -%endif pand m0, m6 pand m1, m6 -%if notcpuflag(mmxext) - paddusb m0, m7 - pand m1, [pb_FE] - pandn m7, m0 - psrlq m1, 1 - psrlq m7, 1 - SWAP 0, 7 -%else ; mmxext/sse2 psubusb m1, [pb_1] pavgb m0, m7 ; a pavgb m1, m7 ; -a -%endif psubusb m5, m0 psubusb m2, m1 paddusb m5, m1 ; q1-a @@ -863,51 +661,13 @@ cglobal vp8_%1_loop_filter16y_inner, 5, 5, 13, stack_size, dst, stride, flimE, f ; 4x8/16 transpose TRANSPOSE4x4B 2, 3, 4, 5, 6 -%if mmsize == 8 ; mmx/mmxext (h) - WRITE_4x2D 2, 3, 4, 5, dst1q, dst2q, mstrideq, strideq -%else ; sse2 (h) lea dst8q, [dst8q+mstrideq +2] WRITE_4x4D 2, 3, 4, 5, dst1q, dst2q, dst8q, mstrideq, strideq, %2 %endif -%endif -%if mmsize == 8 -%if %2 == 8 ; chroma -%ifidn %1, h - sub dst1q, 2 -%endif - cmp dst1q, dst8q - mov dst1q, dst8q - jnz .next8px -%else -%ifidn %1, h - lea dst1q, [dst1q+ strideq*8-2] -%else ; v - add dst1q, 8 -%endif - dec cntrq - jg .next8px -%endif - REP_RET -%else ; mmsize == 16 RET -%endif %endmacro -%if ARCH_X86_32 -INIT_MMX mmx -INNER_LOOPFILTER v, 16 -INNER_LOOPFILTER h, 16 -INNER_LOOPFILTER v, 8 -INNER_LOOPFILTER h, 8 - -INIT_MMX mmxext -INNER_LOOPFILTER v, 16 -INNER_LOOPFILTER h, 16 -INNER_LOOPFILTER v, 8 -INNER_LOOPFILTER h, 8 -%endif - INIT_XMM sse2 INNER_LOOPFILTER v, 16 INNER_LOOPFILTER h, 16 @@ -992,9 +752,6 @@ cglobal vp8_%1_loop_filter16y_mbedge, 5, 5, 15, stack_size, dst1, stride, flimE, %if %2 == 8 ; chroma DEFINE_ARGS dst1, dst8, mstride, stride, dst2 -%elif mmsize == 8 - DEFINE_ARGS dst1, mstride, stride, dst2, cntr - mov cntrq, 2 %else DEFINE_ARGS dst1, mstride, stride, dst2, dst8 %endif @@ -1007,9 +764,6 @@ cglobal vp8_%1_loop_filter16y_mbedge, 5, 5, 15, stack_size, dst1, stride, flimE, %endif %endif -%if mmsize == 8 -.next8px: -%endif ; read lea dst2q, [dst1q+ strideq ] %ifidn %1, v @@ -1034,33 +788,7 @@ cglobal vp8_%1_loop_filter16y_mbedge, 5, 5, 15, stack_size, dst1, stride, flimE, movhps m7, [dst8q+ strideq*2] add dst8q, mstrideq %endif -%elif mmsize == 8 ; mmx/mmxext (h) - ; read 8 rows of 8px each - movu m0, [dst1q+mstrideq*4] - movu m1, [dst2q+mstrideq*4] - movu m2, [dst1q+mstrideq*2] - movu m3, [dst1q+mstrideq ] - movu m4, [dst1q] - movu m5, [dst2q] - movu m6, [dst2q+ strideq ] - - ; 8x8 transpose - TRANSPOSE4x4B 0, 1, 2, 3, 7 - mova m_q0backup, m1 - movu m7, [dst2q+ strideq*2] - TRANSPOSE4x4B 4, 5, 6, 7, 1 - SBUTTERFLY dq, 0, 4, 1 ; p3/p2 - SBUTTERFLY dq, 2, 6, 1 ; q0/q1 - SBUTTERFLY dq, 3, 7, 1 ; q2/q3 - mova m1, m_q0backup - mova m_q0backup, m2 ; store q0 - SBUTTERFLY dq, 1, 5, 2 ; p1/p0 - mova m_p0backup, m5 ; store p0 - SWAP 1, 4 - SWAP 2, 4 - SWAP 6, 3 - SWAP 5, 3 -%else ; sse2 (h) +%else ; h %if %2 == 16 lea dst8q, [dst1q+ strideq*8 ] %endif @@ -1150,25 +878,9 @@ cglobal vp8_%1_loop_filter16y_mbedge, 5, 5, 15, stack_size, dst1, stride, flimE, psubusb m6, m5 ; q2-q1 por m6, m4 ; abs(q2-q1) -%if notcpuflag(mmxext) - mova m4, m_flimI - pxor m3, m3 - psubusb m0, m4 - psubusb m1, m4 - psubusb m7, m4 - psubusb m6, m4 - pcmpeqb m0, m3 ; abs(p3-p2) <= I - pcmpeqb m1, m3 ; abs(p2-p1) <= I - pcmpeqb m7, m3 ; abs(q3-q2) <= I - pcmpeqb m6, m3 ; abs(q2-q1) <= I - pand m0, m1 - pand m7, m6 - pand m0, m7 -%else ; mmxext/sse2 pmaxub m0, m1 pmaxub m6, m7 pmaxub m0, m6 -%endif ; normal_limit and high_edge_variance for p1-p0, q1-q0 SWAP 7, 3 ; now m7 is zero @@ -1190,18 +902,8 @@ cglobal vp8_%1_loop_filter16y_mbedge, 5, 5, 15, stack_size, dst1, stride, flimE, psubusb m1, m3 ; p1-p0 psubusb m6, m2 ; p0-p1 por m1, m6 ; abs(p1-p0) -%if notcpuflag(mmxext) - mova m6, m1 - psubusb m1, m4 - psubusb m6, m_hevthr - pcmpeqb m1, m7 ; abs(p1-p0) <= I - pcmpeqb m6, m7 ; abs(p1-p0) <= hev_thresh - pand m0, m1 - mova m_maskres, m6 -%else ; mmxext/sse2 pmaxub m0, m1 ; max_I SWAP 1, 4 ; max_hev_thresh -%endif SWAP 6, 4 ; now m6 is I %ifidn %1, v @@ -1221,17 +923,6 @@ cglobal vp8_%1_loop_filter16y_mbedge, 5, 5, 15, stack_size, dst1, stride, flimE, psubusb m1, m5 ; q0-q1 psubusb m7, m4 ; q1-q0 por m1, m7 ; abs(q1-q0) -%if notcpuflag(mmxext) - mova m7, m1 - psubusb m1, m6 - psubusb m7, m_hevthr - pxor m6, m6 - pcmpeqb m1, m6 ; abs(q1-q0) <= I - pcmpeqb m7, m6 ; abs(q1-q0) <= hev_thresh - mova m6, m_maskres - pand m0, m1 ; abs([pq][321]-[pq][210]) <= I - pand m6, m7 -%else ; mmxext/sse2 pxor m7, m7 pmaxub m0, m1 pmaxub m6, m1 @@ -1239,7 +930,6 @@ cglobal vp8_%1_loop_filter16y_mbedge, 5, 5, 15, stack_size, dst1, stride, flimE, psubusb m6, m_hevthr pcmpeqb m0, m7 ; max(abs(..)) <= I pcmpeqb m6, m7 ; !(max(abs..) > thresh) -%endif %ifdef m12 SWAP 6, 12 %else @@ -1510,11 +1200,6 @@ cglobal vp8_%1_loop_filter16y_mbedge, 5, 5, 15, stack_size, dst1, stride, flimE, TRANSPOSE4x4B 1, 2, 3, 4, 0 SBUTTERFLY bw, 5, 6, 0 -%if mmsize == 8 ; mmx/mmxext (h) - WRITE_4x2D 1, 2, 3, 4, dst1q, dst2q, mstrideq, strideq - add dst1q, 4 - WRITE_2x4W m5, m6, dst2q, dst1q, mstrideq, strideq -%else ; sse2 (h) lea dst8q, [dst8q+mstrideq+1] WRITE_4x4D 1, 2, 3, 4, dst1q, dst2q, dst8q, mstrideq, strideq, %2 lea dst1q, [dst2q+mstrideq+4] @@ -1528,45 +1213,10 @@ cglobal vp8_%1_loop_filter16y_mbedge, 5, 5, 15, stack_size, dst1, stride, flimE, %endif WRITE_8W m6, dst2q, dst8q, mstrideq, strideq %endif -%endif -%if mmsize == 8 -%if %2 == 8 ; chroma -%ifidn %1, h - sub dst1q, 5 -%endif - cmp dst1q, dst8q - mov dst1q, dst8q - jnz .next8px -%else -%ifidn %1, h - lea dst1q, [dst1q+ strideq*8-5] -%else ; v - add dst1q, 8 -%endif - dec cntrq - jg .next8px -%endif - REP_RET -%else ; mmsize == 16 RET -%endif %endmacro -%if ARCH_X86_32 -INIT_MMX mmx -MBEDGE_LOOPFILTER v, 16 -MBEDGE_LOOPFILTER h, 16 -MBEDGE_LOOPFILTER v, 8 -MBEDGE_LOOPFILTER h, 8 - -INIT_MMX mmxext -MBEDGE_LOOPFILTER v, 16 -MBEDGE_LOOPFILTER h, 16 -MBEDGE_LOOPFILTER v, 8 -MBEDGE_LOOPFILTER h, 8 -%endif - INIT_XMM sse2 MBEDGE_LOOPFILTER v, 16 MBEDGE_LOOPFILTER h, 16 diff --git a/media/ffvpx/libavcodec/x86/vp9dsp_init.c b/media/ffvpx/libavcodec/x86/vp9dsp_init.c index 837cce850819..8d11dbc34802 100644 --- a/media/ffvpx/libavcodec/x86/vp9dsp_init.c +++ b/media/ffvpx/libavcodec/x86/vp9dsp_init.c @@ -22,7 +22,6 @@ #include "libavutil/attributes.h" #include "libavutil/cpu.h" -#include "libavutil/mem.h" #include "libavutil/x86/cpu.h" #include "libavcodec/vp9dsp.h" #include "libavcodec/x86/vp9dsp_init.h" diff --git a/media/ffvpx/libavcodec/x86/vp9dsp_init.h b/media/ffvpx/libavcodec/x86/vp9dsp_init.h index ebe7ca8ad025..fc1e0557fa94 100644 --- a/media/ffvpx/libavcodec/x86/vp9dsp_init.h +++ b/media/ffvpx/libavcodec/x86/vp9dsp_init.h @@ -23,6 +23,7 @@ #ifndef AVCODEC_X86_VP9DSP_INIT_H #define AVCODEC_X86_VP9DSP_INIT_H +#include "libavutil/attributes.h" #include "libavutil/mem_internal.h" #include "libavcodec/vp9dsp.h" diff --git a/media/ffvpx/libavcodec/x86/vp9dsp_init_16bpp.c b/media/ffvpx/libavcodec/x86/vp9dsp_init_16bpp.c index 60d10a12a3a6..e5afea1512dc 100644 --- a/media/ffvpx/libavcodec/x86/vp9dsp_init_16bpp.c +++ b/media/ffvpx/libavcodec/x86/vp9dsp_init_16bpp.c @@ -22,7 +22,6 @@ #include "libavutil/attributes.h" #include "libavutil/cpu.h" -#include "libavutil/mem.h" #include "libavutil/x86/cpu.h" #include "libavcodec/vp9dsp.h" #include "libavcodec/x86/vp9dsp_init.h" @@ -55,6 +54,8 @@ decl_ipred_fn(dl, 16, 16, avx2); decl_ipred_fn(dl, 32, 16, avx2); decl_ipred_fn(dr, 16, 16, avx2); decl_ipred_fn(dr, 32, 16, avx2); +decl_ipred_fn(vl, 16, 16, avx2); +decl_ipred_fn(hd, 16, 16, avx2); #define decl_ipred_dir_funcs(type) \ decl_ipred_fns(type, 16, sse2, sse2); \ @@ -140,6 +141,8 @@ av_cold void ff_vp9dsp_init_16bpp_x86(VP9DSPContext *dsp) init_ipred_func(dl, DIAG_DOWN_LEFT, 16, 16, avx2); init_ipred_func(dl, DIAG_DOWN_LEFT, 32, 16, avx2); init_ipred_func(dr, DIAG_DOWN_RIGHT, 16, 16, avx2); + init_ipred_func(vl, VERT_LEFT, 16, 16, avx2); + init_ipred_func(hd, HOR_DOWN, 16, 16, avx2); #if ARCH_X86_64 init_ipred_func(dr, DIAG_DOWN_RIGHT, 32, 16, avx2); #endif diff --git a/media/ffvpx/libavcodec/x86/vp9dsp_init_16bpp_template.c b/media/ffvpx/libavcodec/x86/vp9dsp_init_16bpp_template.c index b56afc7f5041..f93ea2468ea5 100644 --- a/media/ffvpx/libavcodec/x86/vp9dsp_init_16bpp_template.c +++ b/media/ffvpx/libavcodec/x86/vp9dsp_init_16bpp_template.c @@ -22,7 +22,6 @@ #include "libavutil/attributes.h" #include "libavutil/cpu.h" -#include "libavutil/mem.h" #include "libavutil/x86/cpu.h" #include "libavcodec/vp9dsp.h" #include "libavcodec/x86/vp9dsp_init.h" diff --git a/media/ffvpx/libavcodec/x86/vp9intrapred_16bpp.asm b/media/ffvpx/libavcodec/x86/vp9intrapred_16bpp.asm index 32b698243a89..808056a809ec 100644 --- a/media/ffvpx/libavcodec/x86/vp9intrapred_16bpp.asm +++ b/media/ffvpx/libavcodec/x86/vp9intrapred_16bpp.asm @@ -1222,6 +1222,111 @@ cglobal vp9_ipred_dr_16x16_16, 4, 5, 6, dst, stride, l, a mova [dst3q+strideq*4], m5 ; 7 RET +cglobal vp9_ipred_vl_16x16_16, 4, 5, 7, dst, stride, l, a + movifnidn aq, amp + mova m0, [aq] ; abcdefghijklmnop + vpbroadcastw xm1, [aq+30] ; pppppppp + vperm2i128 m2, m0, m1, q0201 ; ijklmnoppppppppp + vpalignr m3, m2, m0, 2 ; bcdefghijklmnopp + vperm2i128 m4, m3, m1, q0201 ; jklmnopppppppppp + vpalignr m5, m2, m0, 4 ; cdefghijklmnoppp + vperm2i128 m6, m5, m1, q0201 ; klmnoppppppppppp + LOWPASS 5, 3, 0 ; BCDEFGHIJKLMNOPP + LOWPASS 6, 4, 2 ; JKLMNOPPPPPPPPPP + pavgw m3, m0 ; abcdefghijklmnop + pavgw m4, m2 ; ijklmnoppppppppp + DEFINE_ARGS dst, stride, stride3, stride5, dst4 + lea dst4q, [dstq+strideq*4] + lea stride3q, [strideq*3] + lea stride5q, [stride3q+strideq*2] + + mova [dstq+strideq*0], m3 ; 0 abcdefghijklmnop + mova [dstq+strideq*1], m5 ; 1 BCDEFGHIJKLMNOPP + vpalignr m0, m4, m3, 2 + vpalignr m1, m6, m5, 2 + mova [dstq+strideq*2 ], m0 ; 2 bcdefghijklmnopp + mova [dstq+stride3q*1], m1 ; 3 CDEFGHIJKLMNOPPP + vpalignr m0, m4, m3, 4 + vpalignr m1, m6, m5, 4 + mova [dst4q+strideq*0], m0 ; 4 cdefghijklmnoppp + mova [dstq+stride5q*1], m1 ; 5 DEFGHIJKLMNOPPPP + vpalignr m0, m4, m3, 6 + vpalignr m1, m6, m5, 6 + mova [ dstq+stride3q*2], m0 ; 6 defghijklmnopppp + mova [dst4q+stride3q*1], m1 ; 7 EFGHIJKLMNOPPPPP + vpalignr m0, m4, m3, 8 + vpalignr m1, m6, m5, 8 + mova [ dstq+strideq*8], m0 ; 8 efghijklmnoppppp + mova [dst4q+stride5q*1], m1 ; 9 FGHIJKLMNOPPPPPP + vpalignr m0, m4, m3, 10 + mova [dstq+stride5q*2], m0 ; 10 fghijklmnopppppp + vpalignr m0, m4, m3, 12 + mova [dst4q+strideq*8], m0 ; 12 ghijklmnoppppppp + vpalignr m0, m4, m3, 14 + mova [dst4q+stride5q*2], m0 ; 14 hijklmnopppppppp + sub dst4q, strideq + vpalignr m1, m6, m5, 10 + mova [dst4q+strideq*8], m1 ; 11 GHIJKLMNOPPPPPPP + vpalignr m1, m6, m5, 12 + mova [dst4q+stride5q*2], m1 ; 13 HIJKLMNOPPPPPPPP + vpalignr m1, m6, m5, 14 + mova [dst4q+stride3q*4], m1 ; 15 IJKLMNOPPPPPPPPP + RET + +cglobal vp9_ipred_hd_16x16_16, 4, 5, 7, dst, stride, l, a + movu m0, [aq-2] ; *abcdefghijklmno + mova m1, [lq] ; klmnopqrstuvwxyz + vperm2i128 m2, m1, m0, q0201 ; stuvwxyz*abcdefg + vpalignr m3, m2, m1, 2 ; lmnopqrstuvwxyz* + vpalignr m4, m2, m1, 4 ; mnopqrstuvwxyz*a + LOWPASS 4, 3, 1 ; LMNOPQRSTUVWXYZ# + pavgw m3, m1 ; klmnopqrstuvwxyz + mova m1, [aq] ; abcdefghijklmnop + movu m2, [aq+2] ; bcdefghijklmnop. + LOWPASS 2, 1, 0 ; ABCDEFGHIJKLMNO. + vpunpcklwd m0, m3, m4 ; kLlMmNnOsTtUuVvW + vpunpckhwd m1, m3, m4 ; oPpQqRrSwXxYyZz# + vperm2i128 m3, m1, m0, q0002 ; kLlMmNnOoPpQqRrS + vperm2i128 m4, m0, m1, q0301 ; sTtUuVvWwXxYyZz# + vperm2i128 m0, m4, m2, q0201 ; wXxYyZz#ABCDEFGH + vperm2i128 m1, m3, m4, q0201 ; oPpQqRrSsTtUuVvW + DEFINE_ARGS dst, stride, stride3, stride5, dst5 + lea stride3q, [strideq*3] + lea stride5q, [stride3q+strideq*2] + lea dst5q, [dstq+stride5q] + + mova [dst5q+stride5q*2], m3 ; 15 kLlMmNnOoPpQqRrS + mova [dst5q+stride3q*2], m1 ; 11 oPpQqRrSsTtUuVvW + mova [dst5q+strideq*2], m4 ; 7 sTtUuVvWwXxYyZz# + mova [dstq+stride3q*1], m0 ; 3 wXxYyZz#ABCDEFGH + vpalignr m5, m4, m1, 4 + mova [dstq+stride5q*2], m5 ; 10 pQqRrSsTtUuVvWwX + vpalignr m5, m0, m4, 4 + vpalignr m6, m2, m0, 4 + mova [dstq+stride3q*2], m5 ; 6 tUuVvWwXxYyZz#AB + mova [dstq+strideq*2], m6 ; 2 xYyZz#ABCDEFGHIJ + vpalignr m5, m4, m1, 8 + mova [dst5q+strideq*4], m5 ; 9 qRrSsTtUuVvWwXxY + vpalignr m5, m0, m4, 8 + vpalignr m6, m2, m0, 8 + mova [dstq+stride5q*1], m5 ; 5 uVvWwXxYyZz#ABCD + mova [dstq+strideq*1], m6 ; 1 yZz#ABCDEFGHIJKL + vpalignr m5, m1, m3, 12 + vpalignr m6, m4, m1, 12 + mova [dstq+stride3q*4], m5 ; 12 nOoPpQqRrSsTtUuV + mova [dst5q+stride3q], m6 ; 8 rSsTtUuVvWwXxYyZ + vpalignr m5, m0, m4, 12 + vpalignr m6, m2, m0, 12 + mova [dstq+strideq*4], m5 ; 4 nOoPpQqRrSsTtUuV + mova [dstq+strideq*0], m6 ; 0 z#ABCDEFGHIJKLMN + sub dst5q, strideq + vpalignr m5, m1, m3, 4 + mova [dst5q+stride5q*2], m5 ; 14 lMmNnOoPpQqRrSsT + sub dst5q, strideq + vpalignr m5, m1, m3, 8 + mova [dst5q+stride5q*2], m5 ; 13 mNnOoPpQqRrSsTtU + RET + %if ARCH_X86_64 cglobal vp9_ipred_dr_32x32_16, 4, 7, 10, dst, stride, l, a mova m0, [lq+mmsize*0+0] ; l[0-15] diff --git a/media/ffvpx/libavcodec/x86/vp9mc.asm b/media/ffvpx/libavcodec/x86/vp9mc.asm index f64161b2c288..efc4cfbef13b 100644 --- a/media/ffvpx/libavcodec/x86/vp9mc.asm +++ b/media/ffvpx/libavcodec/x86/vp9mc.asm @@ -604,7 +604,12 @@ cglobal vp9_%1%2 %+ %%szsuf, 5, 5, %8, dst, dstride, src, sstride, h %%pavg m0, [dstq] %%pavg m1, [dstq+d%3] %%pavg m2, [dstq+d%4] +%if %2 == 4 + %%srcfn m4, [dstq+d%5] + %%pavg m3, m4 +%else %%pavg m3, [dstq+d%5] +%endif %if %2/mmsize == 8 %%pavg m4, [dstq+mmsize*4] %%pavg m5, [dstq+mmsize*5] diff --git a/media/ffvpx/libavcodec/xiph.c b/media/ffvpx/libavcodec/xiph.c index 3073315e634a..218b0813e9e7 100644 --- a/media/ffvpx/libavcodec/xiph.c +++ b/media/ffvpx/libavcodec/xiph.c @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include +#include "libavutil/error.h" #include "libavutil/intreadwrite.h" #include "xiph.h" diff --git a/media/ffvpx/libavcodec/xiph.h b/media/ffvpx/libavcodec/xiph.h index 1741a51b65d5..4ab246952810 100644 --- a/media/ffvpx/libavcodec/xiph.h +++ b/media/ffvpx/libavcodec/xiph.h @@ -21,7 +21,7 @@ #ifndef AVCODEC_XIPH_H #define AVCODEC_XIPH_H -#include "libavutil/common.h" +#include /** * Split a single extradata buffer into the three headers that most diff --git a/media/ffvpx/libavutil/aarch64/asm.S b/media/ffvpx/libavutil/aarch64/asm.S index d1fa72b3c65a..a7782415d7ae 100644 --- a/media/ffvpx/libavutil/aarch64/asm.S +++ b/media/ffvpx/libavutil/aarch64/asm.S @@ -36,6 +36,125 @@ # define __has_feature(x) 0 #endif + +/* Support macros for + * - Armv8.3-A Pointer Authentication and + * - Armv8.5-A Branch Target Identification + * features which require emitting a .note.gnu.property section with the + * appropriate architecture-dependent feature bits set. + * + * |AARCH64_SIGN_LINK_REGISTER| and |AARCH64_VALIDATE_LINK_REGISTER| expand to + * PACIxSP and AUTIxSP, respectively. |AARCH64_SIGN_LINK_REGISTER| should be + * used immediately before saving the LR register (x30) to the stack. + * |AARCH64_VALIDATE_LINK_REGISTER| should be used immediately after restoring + * it. Note |AARCH64_SIGN_LINK_REGISTER|'s modifications to LR must be undone + * with |AARCH64_VALIDATE_LINK_REGISTER| before RET. The SP register must also + * have the same value at the two points. For example: + * + * .global f + * f: + * AARCH64_SIGN_LINK_REGISTER + * stp x29, x30, [sp, #-96]! + * mov x29, sp + * ... + * ldp x29, x30, [sp], #96 + * AARCH64_VALIDATE_LINK_REGISTER + * ret + * + * |AARCH64_VALID_CALL_TARGET| expands to BTI 'c'. Either it, or + * |AARCH64_SIGN_LINK_REGISTER|, must be used at every point that may be an + * indirect call target. In particular, all symbols exported from a file must + * begin with one of these macros. For example, a leaf function that does not + * save LR can instead use |AARCH64_VALID_CALL_TARGET|: + * + * .globl return_zero + * return_zero: + * AARCH64_VALID_CALL_TARGET + * mov x0, #0 + * ret + * + * A non-leaf function which does not immediately save LR may need both macros + * because |AARCH64_SIGN_LINK_REGISTER| appears late. For example, the function + * may jump to an alternate implementation before setting up the stack: + * + * .globl with_early_jump + * with_early_jump: + * AARCH64_VALID_CALL_TARGET + * cmp x0, #128 + * b.lt .Lwith_early_jump_128 + * AARCH64_SIGN_LINK_REGISTER + * stp x29, x30, [sp, #-96]! + * mov x29, sp + * ... + * ldp x29, x30, [sp], #96 + * AARCH64_VALIDATE_LINK_REGISTER + * ret + * + * .Lwith_early_jump_128: + * ... + * ret + * + * These annotations are only required with indirect calls. Private symbols that + * are only the target of direct calls do not require annotations. Also note + * that |AARCH64_VALID_CALL_TARGET| is only valid for indirect calls (BLR), not + * indirect jumps (BR). Indirect jumps in assembly are supported through + * |AARCH64_VALID_JUMP_TARGET|. Landing Pads which shall serve for jumps and + * calls can be created using |AARCH64_VALID_JUMP_CALL_TARGET|. + * + * Although not necessary, it is safe to use these macros in 32-bit ARM + * assembly. This may be used to simplify dual 32-bit and 64-bit files. + * + * References: + * - "ELF for the Arm® 64-bit Architecture" + * https: *github.com/ARM-software/abi-aa/blob/master/aaelf64/aaelf64.rst + * - "Providing protection for complex software" + * https://developer.arm.com/architectures/learn-the-architecture/providing-protection-for-complex-software + */ +#if defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT == 1) +# define GNU_PROPERTY_AARCH64_BTI (1 << 0) // Has BTI +# define AARCH64_VALID_CALL_TARGET hint #34 // BTI 'c' +# define AARCH64_VALID_JUMP_TARGET hint #38 // BTI 'j' +#else +# define GNU_PROPERTY_AARCH64_BTI 0 // No BTI +# define AARCH64_VALID_CALL_TARGET +# define AARCH64_VALID_JUMP_TARGET +#endif + +#if defined(__ARM_FEATURE_PAC_DEFAULT) +# if ((__ARM_FEATURE_PAC_DEFAULT & (1 << 0)) != 0) // authentication using key A +# define AARCH64_SIGN_LINK_REGISTER paciasp +# define AARCH64_VALIDATE_LINK_REGISTER autiasp +# elif ((__ARM_FEATURE_PAC_DEFAULT & (1 << 1)) != 0) // authentication using key B +# define AARCH64_SIGN_LINK_REGISTER pacibsp +# define AARCH64_VALIDATE_LINK_REGISTER autibsp +# else +# error Pointer authentication defines no valid key! +# endif +# if ((__ARM_FEATURE_PAC_DEFAULT & (1 << 2)) != 0) +# error Authentication of leaf functions is enabled but not supported in FFmpeg! +# endif +# define GNU_PROPERTY_AARCH64_PAC (1 << 1) +#else +# define GNU_PROPERTY_AARCH64_PAC 0 +# define AARCH64_SIGN_LINK_REGISTER +# define AARCH64_VALIDATE_LINK_REGISTER +#endif + + +#if (GNU_PROPERTY_AARCH64_BTI != 0 || GNU_PROPERTY_AARCH64_PAC != 0) && defined(__ELF__) + .pushsection .note.gnu.property, "a" + .balign 8 + .long 4 + .long 0x10 + .long 0x5 + .asciz "GNU" + .long 0xc0000000 /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */ + .long 4 + .long (GNU_PROPERTY_AARCH64_BTI | GNU_PROPERTY_AARCH64_PAC) + .long 0 + .popsection +#endif + .macro function name, export=0, align=2 .macro endfunc ELF .size \name, . - \name @@ -49,6 +168,7 @@ FUNC .endfunc ELF .type EXTERN_ASM\name, %function FUNC .func EXTERN_ASM\name EXTERN_ASM\name: + AARCH64_VALID_CALL_TARGET .else ELF .type \name, %function FUNC .func \name diff --git a/media/ffvpx/libavutil/aarch64/bswap.h b/media/ffvpx/libavutil/aarch64/bswap.h index 90b8a63c0a69..1e735c52cf76 100644 --- a/media/ffvpx/libavutil/aarch64/bswap.h +++ b/media/ffvpx/libavutil/aarch64/bswap.h @@ -47,5 +47,4 @@ static av_always_inline av_const uint64_t av_bswap64(uint64_t x) } #endif /* HAVE_INLINE_ASM */ - #endif /* AVUTIL_AARCH64_BSWAP_H */ diff --git a/media/ffvpx/libavutil/adler32.c b/media/ffvpx/libavutil/adler32.c index 5ed5ff55a382..7124f188029f 100644 --- a/media/ffvpx/libavutil/adler32.c +++ b/media/ffvpx/libavutil/adler32.c @@ -32,8 +32,8 @@ #include "config.h" #include "adler32.h" -#include "common.h" #include "intreadwrite.h" +#include "macros.h" #define BASE 65521L /* largest prime smaller than 65536 */ @@ -41,12 +41,7 @@ #define DO4(buf) DO1(buf); DO1(buf); DO1(buf); DO1(buf); #define DO16(buf) DO4(buf); DO4(buf); DO4(buf); DO4(buf); -#if FF_API_CRYPTO_SIZE_T -unsigned long av_adler32_update(unsigned long adler, const uint8_t * buf, - unsigned int len) -#else AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf, size_t len) -#endif { unsigned long s1 = adler & 0xffff; unsigned long s2 = adler >> 16; diff --git a/media/ffvpx/libavutil/adler32.h b/media/ffvpx/libavutil/adler32.h index e7a8f83729e3..232d07f5fe82 100644 --- a/media/ffvpx/libavutil/adler32.h +++ b/media/ffvpx/libavutil/adler32.h @@ -30,7 +30,6 @@ #include #include #include "attributes.h" -#include "version.h" /** * @defgroup lavu_adler32 Adler-32 @@ -40,11 +39,7 @@ * @{ */ -#if FF_API_CRYPTO_SIZE_T -typedef unsigned long AVAdler; -#else typedef uint32_t AVAdler; -#endif /** * Calculate the Adler32 checksum of a buffer. @@ -59,11 +54,7 @@ typedef uint32_t AVAdler; * @return updated checksum */ AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf, -#if FF_API_CRYPTO_SIZE_T - unsigned int len) av_pure; -#else size_t len) av_pure; -#endif /** * @} diff --git a/media/ffvpx/libavutil/arm/cpu.c b/media/ffvpx/libavutil/arm/cpu.c index 81e85e252557..c84a655c3764 100644 --- a/media/ffvpx/libavutil/arm/cpu.c +++ b/media/ffvpx/libavutil/arm/cpu.c @@ -38,6 +38,10 @@ #include #include "libavutil/avstring.h" +#if HAVE_GETAUXVAL +#include +#endif + #define AT_HWCAP 16 /* Relevant HWCAP values from kernel headers */ @@ -48,6 +52,19 @@ #define HWCAP_VFPv3 (1 << 13) #define HWCAP_TLS (1 << 15) +static int get_auxval(uint32_t *hwcap) +{ +#if HAVE_GETAUXVAL + unsigned long ret = getauxval(AT_HWCAP); + if (ret == 0) + return -1; + *hwcap = ret; + return 0; +#else + return -1; +#endif +} + static int get_hwcap(uint32_t *hwcap) { struct { uint32_t a_type; uint32_t a_val; } auxv; @@ -106,9 +123,10 @@ int ff_get_cpu_flags_arm(void) int flags = CORE_CPU_FLAGS; uint32_t hwcap; - if (get_hwcap(&hwcap) < 0) - if (get_cpuinfo(&hwcap) < 0) - return flags; + if (get_auxval(&hwcap) < 0) + if (get_hwcap(&hwcap) < 0) + if (get_cpuinfo(&hwcap) < 0) + return flags; #define check_cap(cap, flag) do { \ if (hwcap & HWCAP_ ## cap) \ diff --git a/media/ffvpx/libavutil/attributes.h b/media/ffvpx/libavutil/attributes.h index 5cb9fe345288..04c615c952c4 100644 --- a/media/ffvpx/libavutil/attributes.h +++ b/media/ffvpx/libavutil/attributes.h @@ -110,7 +110,7 @@ * scheduled for removal. */ #ifndef AV_NOWARN_DEPRECATED -#if AV_GCC_VERSION_AT_LEAST(4,6) +#if AV_GCC_VERSION_AT_LEAST(4,6) || defined(__clang__) # define AV_NOWARN_DEPRECATED(code) \ _Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \ diff --git a/media/ffvpx/libavutil/avassert.h b/media/ffvpx/libavutil/avassert.h index 9abeadea4a23..51e462bbae70 100644 --- a/media/ffvpx/libavutil/avassert.h +++ b/media/ffvpx/libavutil/avassert.h @@ -28,8 +28,8 @@ #define AVUTIL_AVASSERT_H #include -#include "avutil.h" #include "log.h" +#include "macros.h" /** * assert() equivalent, that is always enabled. diff --git a/media/ffvpx/libavutil/avconfig.h b/media/ffvpx/libavutil/avconfig.h index f10aa6186b4f..c289fbb551c1 100644 --- a/media/ffvpx/libavutil/avconfig.h +++ b/media/ffvpx/libavutil/avconfig.h @@ -1,4 +1,4 @@ -/* Generated by ffconf */ +/* Generated by ffmpeg configure */ #ifndef AVUTIL_AVCONFIG_H #define AVUTIL_AVCONFIG_H #define AV_HAVE_BIGENDIAN 0 diff --git a/media/ffvpx/libavutil/avsscanf.c b/media/ffvpx/libavutil/avsscanf.c new file mode 100644 index 000000000000..7061e6d96513 --- /dev/null +++ b/media/ffvpx/libavutil/avsscanf.c @@ -0,0 +1,970 @@ +/* + * Copyright (c) 2005-2014 Rich Felker, et al. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "avstring.h" +#include "libm.h" + +typedef struct FFFILE { + size_t buf_size; + unsigned char *buf; + unsigned char *rpos, *rend; + unsigned char *shend; + ptrdiff_t shlim, shcnt; + void *cookie; + size_t (*read)(struct FFFILE *, unsigned char *, size_t); +} FFFILE; + +#define SIZE_hh -2 +#define SIZE_h -1 +#define SIZE_def 0 +#define SIZE_l 1 +#define SIZE_L 2 +#define SIZE_ll 3 + +#define shcnt(f) ((f)->shcnt + ((f)->rpos - (f)->buf)) + +static int fftoread(FFFILE *f) +{ + f->rpos = f->rend = f->buf + f->buf_size; + return 0; +} + +static size_t ffstring_read(FFFILE *f, unsigned char *buf, size_t len) +{ + char *src = f->cookie; + size_t k = len+256; + char *end = memchr(src, 0, k); + + if (end) k = end-src; + if (k < len) len = k; + memcpy(buf, src, len); + f->rpos = (void *)(src+len); + f->rend = (void *)(src+k); + f->cookie = src+k; + + return len; +} + +static int ffuflow(FFFILE *f) +{ + unsigned char c; + if (!fftoread(f) && f->read(f, &c, 1)==1) return c; + return EOF; +} + +static void ffshlim(FFFILE *f, ptrdiff_t lim) +{ + f->shlim = lim; + f->shcnt = f->buf - f->rpos; + /* If lim is nonzero, rend must be a valid pointer. */ + if (lim && f->rend - f->rpos > lim) + f->shend = f->rpos + lim; + else + f->shend = f->rend; +} + +static int ffshgetc(FFFILE *f) +{ + int c; + ptrdiff_t cnt = shcnt(f); + if (f->shlim && cnt >= f->shlim || (c=ffuflow(f)) < 0) { + f->shcnt = f->buf - f->rpos + cnt; + f->shend = 0; + return EOF; + } + cnt++; + if (f->shlim && f->rend - f->rpos > f->shlim - cnt) + f->shend = f->rpos + (f->shlim - cnt); + else + f->shend = f->rend; + f->shcnt = f->buf - f->rpos + cnt; + if (f->rpos[-1] != c) f->rpos[-1] = c; + return c; +} + +#define shlim(f, lim) ffshlim((f), (lim)) +#define shgetc(f) (((f)->rpos < (f)->shend) ? *(f)->rpos++ : ffshgetc(f)) +#define shunget(f) ((f)->shend ? (void)(f)->rpos-- : (void)0) + +static const unsigned char table[] = { -1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1, + -1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24, + 25,26,27,28,29,30,31,32,33,34,35,-1,-1,-1,-1,-1, + -1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24, + 25,26,27,28,29,30,31,32,33,34,35,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, +}; + +static unsigned long long ffintscan(FFFILE *f, unsigned base, int pok, unsigned long long lim) +{ + const unsigned char *val = table+1; + int c, neg=0; + unsigned x; + unsigned long long y; + if (base > 36 || base == 1) { + errno = EINVAL; + return 0; + } + while (av_isspace((c=shgetc(f)))); + if (c=='+' || c=='-') { + neg = -(c=='-'); + c = shgetc(f); + } + if ((base == 0 || base == 16) && c=='0') { + c = shgetc(f); + if ((c|32)=='x') { + c = shgetc(f); + if (val[c]>=16) { + shunget(f); + if (pok) shunget(f); + else shlim(f, 0); + return 0; + } + base = 16; + } else if (base == 0) { + base = 8; + } + } else { + if (base == 0) base = 10; + if (val[c] >= base) { + shunget(f); + shlim(f, 0); + errno = EINVAL; + return 0; + } + } + if (base == 10) { + for (x=0; c-'0'<10U && x<=UINT_MAX/10-1; c=shgetc(f)) + x = x*10 + (c-'0'); + for (y=x; c-'0'<10U && y<=ULLONG_MAX/10 && 10*y<=ULLONG_MAX-(c-'0'); c=shgetc(f)) + y = y*10 + (c-'0'); + if (c-'0'>=10U) goto done; + } else if (!(base & base-1)) { + int bs = "\0\1\2\4\7\3\6\5"[(0x17*base)>>5&7]; + for (x=0; val[c]>bs; c=shgetc(f)) + y = y<=lim) { + if (!(lim&1) && !neg) { + errno = ERANGE; + return lim-1; + } else if (y>lim) { + errno = ERANGE; + return lim; + } + } + return (y^neg)-neg; +} + +static long long scanexp(FFFILE *f, int pok) +{ + int c; + int x; + long long y; + int neg = 0; + + c = shgetc(f); + if (c=='+' || c=='-') { + neg = (c=='-'); + c = shgetc(f); + if (c-'0'>=10U && pok) shunget(f); + } + if (c-'0'>=10U) { + shunget(f); + return LLONG_MIN; + } + for (x=0; c-'0'<10U && x=0) { + shunget(f); + } + if (!gotdig) { + errno = EINVAL; + shlim(f, 0); + return 0; + } + + /* Handle zero specially to avoid nasty special cases later */ + if (!x[0]) return sign * 0.0; + + /* Optimize small integers (w/no exponent) and over/under-flow */ + if (lrp==dc && dc<10 && (bits>30 || x[0]>>bits==0)) + return sign * (double)x[0]; + if (lrp > -emin/2) { + errno = ERANGE; + return sign * DBL_MAX * DBL_MAX; + } + if (lrp < emin-2*DBL_MANT_DIG) { + errno = ERANGE; + return sign * DBL_MIN * DBL_MIN; + } + + /* Align incomplete final B1B digit */ + if (j) { + for (; j<9; j++) x[k]*=10; + k++; + j=0; + } + + a = 0; + z = k; + e2 = 0; + rp = lrp; + + /* Optimize small to mid-size integers (even in exp. notation) */ + if (lnz<9 && lnz<=rp && rp < 18) { + int bitlim; + if (rp == 9) return sign * (double)x[0]; + if (rp < 9) return sign * (double)x[0] / p10s[8-rp]; + bitlim = bits-3*(int)(rp-9); + if (bitlim>30 || x[0]>>bitlim==0) + return sign * (double)x[0] * p10s[rp-10]; + } + + /* Drop trailing zeros */ + for (; !x[z-1]; z--); + + /* Align radix point to B1B digit boundary */ + if (rp % 9) { + int rpm9 = rp>=0 ? rp%9 : rp%9+9; + int p10 = p10s[8-rpm9]; + uint32_t carry = 0; + for (k=a; k!=z; k++) { + uint32_t tmp = x[k] % p10; + x[k] = x[k]/p10 + carry; + carry = 1000000000/p10 * tmp; + if (k==a && !x[k]) { + a = (a+1 & MASK); + rp -= 9; + } + } + if (carry) x[z++] = carry; + rp += 9-rpm9; + } + + /* Upscale until desired number of bits are left of radix point */ + while (rp < 9*LD_B1B_DIG || (rp == 9*LD_B1B_DIG && x[a] 1000000000) { + carry = tmp / 1000000000; + x[k] = tmp % 1000000000; + } else { + carry = 0; + x[k] = tmp; + } + if (k==(z-1 & MASK) && k!=a && !x[k]) z = k; + if (k==a) break; + } + if (carry) { + rp += 9; + a = (a-1 & MASK); + if (a == z) { + z = (z-1 & MASK); + x[z-1 & MASK] |= x[z]; + } + x[a] = carry; + } + } + + /* Downscale until exactly number of bits are left of radix point */ + for (;;) { + uint32_t carry = 0; + int sh = 1; + for (i=0; i th[i]) break; + } + if (i==LD_B1B_DIG && rp==9*LD_B1B_DIG) break; + /* FIXME: find a way to compute optimal sh */ + if (rp > 9+9*LD_B1B_DIG) sh = 9; + e2 += sh; + for (k=a; k!=z; k=(k+1 & MASK)) { + uint32_t tmp = x[k] & (1<>sh) + carry; + carry = (1000000000>>sh) * tmp; + if (k==a && !x[k]) { + a = (a+1 & MASK); + i--; + rp -= 9; + } + } + if (carry) { + if ((z+1 & MASK) != a) { + x[z] = carry; + z = (z+1 & MASK); + } else x[z-1 & MASK] |= 1; + } + } + + /* Assemble desired bits into floating point variable */ + for (y=i=0; i DBL_MANT_DIG+e2-emin) { + bits = DBL_MANT_DIG+e2-emin; + if (bits<0) bits=0; + denormal = 1; + } + + /* Calculate bias term to force rounding, move out lower bits */ + if (bits < DBL_MANT_DIG) { + bias = copysign(scalbn(1, 2*DBL_MANT_DIG-bits-1), y); + frac = fmod(y, scalbn(1, DBL_MANT_DIG-bits)); + y -= frac; + y += bias; + } + + /* Process tail of decimal input so it can affect rounding */ + if ((a+i & MASK) != z) { + uint32_t t = x[a+i & MASK]; + if (t < 500000000 && (t || (a+i+1 & MASK) != z)) + frac += 0.25*sign; + else if (t > 500000000) + frac += 0.75*sign; + else if (t == 500000000) { + if ((a+i+1 & MASK) == z) + frac += 0.5*sign; + else + frac += 0.75*sign; + } + if (DBL_MANT_DIG-bits >= 2 && !fmod(frac, 1)) + frac++; + } + + y += frac; + y -= bias; + + if ((e2+DBL_MANT_DIG & INT_MAX) > emax-5) { + if (fabs(y) >= pow(2, DBL_MANT_DIG)) { + if (denormal && bits==DBL_MANT_DIG+e2-emin) + denormal = 0; + y *= 0.5; + e2++; + } + if (e2+DBL_MANT_DIG>emax || (denormal && frac)) + errno = ERANGE; + } + + return scalbn(y, e2); +} + +static double hexfloat(FFFILE *f, int bits, int emin, int sign, int pok) +{ + uint32_t x = 0; + double y = 0; + double scale = 1; + double bias = 0; + int gottail = 0, gotrad = 0, gotdig = 0; + long long rp = 0; + long long dc = 0; + long long e2 = 0; + int d; + int c; + + c = shgetc(f); + + /* Skip leading zeros */ + for (; c=='0'; c = shgetc(f)) + gotdig = 1; + + if (c=='.') { + gotrad = 1; + c = shgetc(f); + /* Count zeros after the radix point before significand */ + for (rp=0; c=='0'; c = shgetc(f), rp--) gotdig = 1; + } + + for (; c-'0'<10U || (c|32)-'a'<6U || c=='.'; c = shgetc(f)) { + if (c=='.') { + if (gotrad) break; + rp = dc; + gotrad = 1; + } else { + gotdig = 1; + if (c > '9') d = (c|32)+10-'a'; + else d = c-'0'; + if (dc<8) { + x = x*16 + d; + } else if (dc < DBL_MANT_DIG/4+1) { + y += d*(scale/=16); + } else if (d && !gottail) { + y += 0.5*scale; + gottail = 1; + } + dc++; + } + } + if (!gotdig) { + shunget(f); + if (pok) { + shunget(f); + if (gotrad) shunget(f); + } else { + shlim(f, 0); + } + return sign * 0.0; + } + if (!gotrad) rp = dc; + while (dc<8) x *= 16, dc++; + if ((c|32)=='p') { + e2 = scanexp(f, pok); + if (e2 == LLONG_MIN) { + if (pok) { + shunget(f); + } else { + shlim(f, 0); + return 0; + } + e2 = 0; + } + } else { + shunget(f); + } + e2 += 4*rp - 32; + + if (!x) return sign * 0.0; + if (e2 > -emin) { + errno = ERANGE; + return sign * DBL_MAX * DBL_MAX; + } + if (e2 < emin-2*DBL_MANT_DIG) { + errno = ERANGE; + return sign * DBL_MIN * DBL_MIN; + } + + while (x < 0x80000000) { + if (y>=0.5) { + x += x + 1; + y += y - 1; + } else { + x += x; + y += y; + } + e2--; + } + + if (bits > 32+e2-emin) { + bits = 32+e2-emin; + if (bits<0) bits=0; + } + + if (bits < DBL_MANT_DIG) + bias = copysign(scalbn(1, 32+DBL_MANT_DIG-bits-1), sign); + + if (bits<32 && y && !(x&1)) x++, y=0; + + y = bias + sign*(double)x + sign*y; + y -= bias; + + if (!y) errno = ERANGE; + + return scalbn(y, e2); +} + +static double fffloatscan(FFFILE *f, int prec, int pok) +{ + int sign = 1; + size_t i; + int bits; + int emin; + int c; + + switch (prec) { + case 0: + bits = FLT_MANT_DIG; + emin = FLT_MIN_EXP-bits; + break; + case 1: + bits = DBL_MANT_DIG; + emin = DBL_MIN_EXP-bits; + break; + case 2: + bits = DBL_MANT_DIG; + emin = DBL_MIN_EXP-bits; + break; + default: + return 0; + } + + while (av_isspace((c = shgetc(f)))); + + if (c=='+' || c=='-') { + sign -= 2*(c=='-'); + c = shgetc(f); + } + + for (i=0; i<8 && (c|32)=="infinity"[i]; i++) + if (i<7) c = shgetc(f); + if (i==3 || i==8 || (i>3 && pok)) { + if (i!=8) { + shunget(f); + if (pok) for (; i>3; i--) shunget(f); + } + return sign * INFINITY; + } + if (!i) for (i=0; i<3 && (c|32)=="nan"[i]; i++) + if (i<2) c = shgetc(f); + if (i==3) { + if (shgetc(f) != '(') { + shunget(f); + return NAN; + } + for (i=1; ; i++) { + c = shgetc(f); + if (c-'0'<10U || c-'A'<26U || c-'a'<26U || c=='_') + continue; + if (c==')') return NAN; + shunget(f); + if (!pok) { + errno = EINVAL; + shlim(f, 0); + return 0; + } + while (i--) shunget(f); + return NAN; + } + return NAN; + } + + if (i) { + shunget(f); + errno = EINVAL; + shlim(f, 0); + return 0; + } + + if (c=='0') { + c = shgetc(f); + if ((c|32) == 'x') + return hexfloat(f, bits, emin, sign, pok); + shunget(f); + c = '0'; + } + + return decfloat(f, c, bits, emin, sign, pok); +} + +static void *arg_n(va_list ap, unsigned int n) +{ + void *p; + unsigned int i; + va_list ap2; + va_copy(ap2, ap); + for (i=n; i>1; i--) va_arg(ap2, void *); + p = va_arg(ap2, void *); + va_end(ap2); + return p; +} + +static void store_int(void *dest, int size, unsigned long long i) +{ + if (!dest) return; + switch (size) { + case SIZE_hh: + *(char *)dest = i; + break; + case SIZE_h: + *(short *)dest = i; + break; + case SIZE_def: + *(int *)dest = i; + break; + case SIZE_l: + *(long *)dest = i; + break; + case SIZE_ll: + *(long long *)dest = i; + break; + } +} + +static int ff_vfscanf(FFFILE *f, const char *fmt, va_list ap) +{ + int width; + int size; + int base; + const unsigned char *p; + int c, t; + char *s; + void *dest=NULL; + int invert; + int matches=0; + unsigned long long x; + double y; + ptrdiff_t pos = 0; + unsigned char scanset[257]; + size_t i; + + for (p=(const unsigned char *)fmt; *p; p++) { + + if (av_isspace(*p)) { + while (av_isspace(p[1])) p++; + shlim(f, 0); + while (av_isspace(shgetc(f))); + shunget(f); + pos += shcnt(f); + continue; + } + if (*p != '%' || p[1] == '%') { + shlim(f, 0); + if (*p == '%') { + p++; + while (av_isspace((c=shgetc(f)))); + } else { + c = shgetc(f); + } + if (c!=*p) { + shunget(f); + if (c<0) goto input_fail; + goto match_fail; + } + pos += shcnt(f); + continue; + } + + p++; + if (*p=='*') { + dest = 0; p++; + } else if (av_isdigit(*p) && p[1]=='$') { + dest = arg_n(ap, *p-'0'); p+=2; + } else { + dest = va_arg(ap, void *); + } + + for (width=0; av_isdigit(*p); p++) { + width = 10*width + *p - '0'; + } + + if (*p=='m') { + s = 0; + p++; + } + + size = SIZE_def; + switch (*p++) { + case 'h': + if (*p == 'h') p++, size = SIZE_hh; + else size = SIZE_h; + break; + case 'l': + if (*p == 'l') p++, size = SIZE_ll; + else size = SIZE_l; + break; + case 'j': + size = SIZE_ll; + break; + case 'z': + case 't': + size = SIZE_l; + break; + case 'L': + size = SIZE_L; + break; + case 'd': case 'i': case 'o': case 'u': case 'x': + case 'a': case 'e': case 'f': case 'g': + case 'A': case 'E': case 'F': case 'G': case 'X': + case 's': case 'c': case '[': + case 'S': case 'C': + case 'p': case 'n': + p--; + break; + default: + goto fmt_fail; + } + + t = *p; + + /* C or S */ + if ((t&0x2f) == 3) { + t |= 32; + size = SIZE_l; + } + + switch (t) { + case 'c': + if (width < 1) width = 1; + case '[': + break; + case 'n': + store_int(dest, size, pos); + /* do not increment match count, etc! */ + continue; + default: + shlim(f, 0); + while (av_isspace(shgetc(f))); + shunget(f); + pos += shcnt(f); + } + + shlim(f, width); + if (shgetc(f) < 0) goto input_fail; + shunget(f); + + switch (t) { + case 's': + case 'c': + case '[': + if (t == 'c' || t == 's') { + memset(scanset, -1, sizeof scanset); + scanset[0] = 0; + if (t == 's') { + scanset[1 + '\t'] = 0; + scanset[1 + '\n'] = 0; + scanset[1 + '\v'] = 0; + scanset[1 + '\f'] = 0; + scanset[1 + '\r'] = 0; + scanset[1 + ' ' ] = 0; + } + } else { + if (*++p == '^') p++, invert = 1; + else invert = 0; + memset(scanset, invert, sizeof scanset); + scanset[0] = 0; + if (*p == '-') p++, scanset[1+'-'] = 1-invert; + else if (*p == ']') p++, scanset[1+']'] = 1-invert; + for (; *p != ']'; p++) { + if (!*p) goto fmt_fail; + if (*p=='-' && p[1] && p[1] != ']') + for (c=p++[-1]; c<*p; c++) + scanset[1+c] = 1-invert; + scanset[1+*p] = 1-invert; + } + } + s = 0; + i = 0; + if ((s = dest)) { + while (scanset[(c=shgetc(f))+1]) + s[i++] = c; + } else { + while (scanset[(c=shgetc(f))+1]); + } + shunget(f); + if (!shcnt(f)) goto match_fail; + if (t == 'c' && shcnt(f) != width) goto match_fail; + if (t != 'c') { + if (s) s[i] = 0; + } + break; + case 'p': + case 'X': + case 'x': + base = 16; + goto int_common; + case 'o': + base = 8; + goto int_common; + case 'd': + case 'u': + base = 10; + goto int_common; + case 'i': + base = 0; +int_common: + x = ffintscan(f, base, 0, ULLONG_MAX); + if (!shcnt(f)) + goto match_fail; + if (t=='p' && dest) + *(void **)dest = (void *)(uintptr_t)x; + else + store_int(dest, size, x); + break; + case 'a': case 'A': + case 'e': case 'E': + case 'f': case 'F': + case 'g': case 'G': + y = fffloatscan(f, size, 0); + if (!shcnt(f)) + goto match_fail; + if (dest) { + switch (size) { + case SIZE_def: + *(float *)dest = y; + break; + case SIZE_l: + *(double *)dest = y; + break; + case SIZE_L: + *(double *)dest = y; + break; + } + } + break; + } + + pos += shcnt(f); + if (dest) matches++; + } + if (0) { +fmt_fail: +input_fail: + if (!matches) matches--; + } +match_fail: + return matches; +} + +static int ff_vsscanf(const char *s, const char *fmt, va_list ap) +{ + FFFILE f = { + .buf = (void *)s, .cookie = (void *)s, + .read = ffstring_read, + }; + + return ff_vfscanf(&f, fmt, ap); +} + +int av_sscanf(const char *string, const char *format, ...) +{ + int ret; + va_list ap; + va_start(ap, format); + ret = ff_vsscanf(string, format, ap); + va_end(ap); + return ret; +} diff --git a/media/ffvpx/libavutil/avstring.c b/media/ffvpx/libavutil/avstring.c index 49e8df55aa3b..5ddbe9219e8e 100644 --- a/media/ffvpx/libavutil/avstring.c +++ b/media/ffvpx/libavutil/avstring.c @@ -19,17 +19,20 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #include #include #include #include "config.h" -#include "common.h" #include "mem.h" #include "avassert.h" #include "avstring.h" #include "bprint.h" +#include "error.h" +#include "macros.h" +#include "version.h" int av_strstart(const char *str, const char *pfx, const char **ptr) { diff --git a/media/ffvpx/libavutil/avutil.h b/media/ffvpx/libavutil/avutil.h index 4d633156d14d..64b68bdbd33c 100644 --- a/media/ffvpx/libavutil/avutil.h +++ b/media/ffvpx/libavutil/avutil.h @@ -331,12 +331,18 @@ unsigned av_int_list_length_for_size(unsigned elsize, #define av_int_list_length(list, term) \ av_int_list_length_for_size(sizeof(*(list)), list, term) +#if FF_API_AV_FOPEN_UTF8 /** * Open a file using a UTF-8 filename. * The API of this function matches POSIX fopen(), errors are returned through * errno. + * @deprecated Avoid using it, as on Windows, the FILE* allocated by this + * function may be allocated with a different CRT than the caller + * who uses the FILE*. No replacement provided in public API. */ +attribute_deprecated FILE *av_fopen_utf8(const char *path, const char *mode); +#endif /** * Return the fractional representation of the internal time base. diff --git a/media/ffvpx/libavutil/avutil.symbols b/media/ffvpx/libavutil/avutil.symbols index ad84cf680b0f..9d30a5c95855 100644 --- a/media/ffvpx/libavutil/avutil.symbols +++ b/media/ffvpx/libavutil/avutil.symbols @@ -30,7 +30,13 @@ av_buffer_replace av_buffer_ref av_buffer_unref av_calloc +av_channel_layout_check +av_channel_layout_copy +av_channel_layout_compare av_channel_layout_extract_channel +av_channel_layout_describe +av_channel_layout_from_mask +av_channel_layout_uninit av_chroma_location_name av_color_primaries_name av_color_range_name @@ -68,20 +74,26 @@ av_expr_free av_expr_parse av_expr_parse_and_eval av_fast_malloc +av_fast_mallocz av_fast_realloc av_fifo_alloc +av_fifo_alloc2 av_fifo_alloc_array +av_fifo_can_read av_fifo_drain av_fifo_free av_fifo_freep +av_fifo_freep2 av_fifo_generic_peek av_fifo_generic_read av_fifo_generic_write av_fifo_grow av_fifo_realloc2 +av_fifo_read av_fifo_reset av_fifo_size av_fifo_space +av_fifo_write av_find_best_pix_fmt_of_2 av_find_info_tag av_find_nearest_q_idx @@ -96,20 +108,8 @@ av_frame_clone av_frame_copy av_frame_copy_props av_frame_free -av_frame_get_best_effort_timestamp av_frame_get_buffer -av_frame_get_channel_layout -av_frame_get_channels -av_frame_get_color_range -av_frame_get_colorspace -av_frame_get_decode_error_flags -av_frame_get_metadata -av_frame_get_pkt_duration -av_frame_get_pkt_pos -av_frame_get_pkt_size av_frame_get_plane_buffer -av_frame_get_qp_table -av_frame_get_sample_rate av_frame_get_side_data av_frame_is_writable av_frame_make_writable @@ -120,18 +120,6 @@ av_frame_new_side_data_from_buf #endif av_frame_ref av_frame_remove_side_data -av_frame_set_best_effort_timestamp -av_frame_set_channel_layout -av_frame_set_channels -av_frame_set_color_range -av_frame_set_colorspace -av_frame_set_decode_error_flags -av_frame_set_metadata -av_frame_set_pkt_duration -av_frame_set_pkt_pos -av_frame_set_pkt_size -av_frame_set_qp_table -av_frame_set_sample_rate av_frame_side_data_name av_frame_unref av_free @@ -211,7 +199,6 @@ av_memcpy_backptr av_memdup av_mul_q av_nearer_q -av_opt_child_class_next av_opt_child_next av_opt_copy av_opt_eval_double @@ -262,7 +249,6 @@ av_opt_set_video_rate av_opt_show2 av_parse_color av_parse_cpu_caps -av_parse_cpu_flags av_parse_ratio av_parse_time av_parse_video_rate @@ -293,7 +279,6 @@ av_samples_copy av_samples_fill_arrays av_samples_get_buffer_size av_samples_set_silence -av_set_cpu_flags_mask av_set_options_string av_small_strptime av_strcasecmp @@ -314,9 +299,7 @@ av_sub_q av_timegm av_usleep av_utf8_decode -av_util_ffversion av_vbprintf -av_version_info #ifndef MOZ_FFVPX_AUDIOONLY av_video_enc_params_create_side_data #endif @@ -328,9 +311,6 @@ avpriv_report_missing_feature avpriv_request_sample avpriv_scalarproduct_float_c avpriv_set_systematic_pal2 -avutil_configuration -avutil_license -avutil_version #if defined(XP_WIN) && !defined(_ARM64_) avpriv_emms_asm #endif diff --git a/media/ffvpx/libavutil/base64.c b/media/ffvpx/libavutil/base64.c index a1316b94381a..3e66f4fcbe5a 100644 --- a/media/ffvpx/libavutil/base64.c +++ b/media/ffvpx/libavutil/base64.c @@ -24,10 +24,12 @@ * @author Ryan Martell (with lots of Michael) */ -#include "common.h" +#include +#include + #include "base64.h" +#include "error.h" #include "intreadwrite.h" -#include "timer.h" /* ---------------- private code */ static const uint8_t map2[256] = diff --git a/media/ffvpx/libavutil/bprint.c b/media/ffvpx/libavutil/bprint.c index e12fb263fe79..5b540ebc9e66 100644 --- a/media/ffvpx/libavutil/bprint.c +++ b/media/ffvpx/libavutil/bprint.c @@ -18,16 +18,16 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #include #include #include -#include "avassert.h" #include "avstring.h" #include "bprint.h" -#include "common.h" #include "compat/va_copy.h" #include "error.h" +#include "macros.h" #include "mem.h" #define av_bprint_room(buf) ((buf)->size - FFMIN((buf)->len, (buf)->size)) @@ -245,10 +245,8 @@ int av_bprint_finalize(AVBPrint *buf, char **ret_str) str = buf->str; buf->str = NULL; } else { - str = av_malloc(real_size); - if (str) - memcpy(str, buf->str, real_size); - else + str = av_memdup(buf->str, real_size); + if (!str) ret = AVERROR(ENOMEM); } *ret_str = str; diff --git a/media/ffvpx/libavutil/buffer.c b/media/ffvpx/libavutil/buffer.c index 858633e8c73b..54590be56604 100644 --- a/media/ffvpx/libavutil/buffer.c +++ b/media/ffvpx/libavutil/buffer.c @@ -26,16 +26,11 @@ #include "mem.h" #include "thread.h" -AVBufferRef *av_buffer_create(uint8_t *data, buffer_size_t size, - void (*free)(void *opaque, uint8_t *data), - void *opaque, int flags) +static AVBufferRef *buffer_create(AVBuffer *buf, uint8_t *data, size_t size, + void (*free)(void *opaque, uint8_t *data), + void *opaque, int flags) { AVBufferRef *ref = NULL; - AVBuffer *buf = NULL; - - buf = av_mallocz(sizeof(*buf)); - if (!buf) - return NULL; buf->data = data; buf->size = size; @@ -47,10 +42,8 @@ AVBufferRef *av_buffer_create(uint8_t *data, buffer_size_t size, buf->flags = flags; ref = av_mallocz(sizeof(*ref)); - if (!ref) { - av_freep(&buf); + if (!ref) return NULL; - } ref->buffer = buf; ref->data = data; @@ -59,12 +52,29 @@ AVBufferRef *av_buffer_create(uint8_t *data, buffer_size_t size, return ref; } +AVBufferRef *av_buffer_create(uint8_t *data, size_t size, + void (*free)(void *opaque, uint8_t *data), + void *opaque, int flags) +{ + AVBufferRef *ret; + AVBuffer *buf = av_mallocz(sizeof(*buf)); + if (!buf) + return NULL; + + ret = buffer_create(buf, data, size, free, opaque, flags); + if (!ret) { + av_free(buf); + return NULL; + } + return ret; +} + void av_buffer_default_free(void *opaque, uint8_t *data) { av_free(data); } -AVBufferRef *av_buffer_alloc(buffer_size_t size) +AVBufferRef *av_buffer_alloc(size_t size) { AVBufferRef *ret = NULL; uint8_t *data = NULL; @@ -80,7 +90,7 @@ AVBufferRef *av_buffer_alloc(buffer_size_t size) return ret; } -AVBufferRef *av_buffer_allocz(buffer_size_t size) +AVBufferRef *av_buffer_allocz(size_t size) { AVBufferRef *ret = av_buffer_alloc(size); if (!ret) @@ -90,7 +100,7 @@ AVBufferRef *av_buffer_allocz(buffer_size_t size) return ret; } -AVBufferRef *av_buffer_ref(AVBufferRef *buf) +AVBufferRef *av_buffer_ref(const AVBufferRef *buf) { AVBufferRef *ret = av_mallocz(sizeof(*ret)); @@ -117,8 +127,12 @@ static void buffer_replace(AVBufferRef **dst, AVBufferRef **src) av_freep(dst); if (atomic_fetch_sub_explicit(&b->refcount, 1, memory_order_acq_rel) == 1) { + /* b->free below might already free the structure containing *b, + * so we have to read the flag now to avoid use-after-free. */ + int free_avbuffer = !(b->flags_internal & BUFFER_FLAG_NO_FREE); b->free(b->opaque, b->data); - av_freep(&b); + if (free_avbuffer) + av_free(b); } } @@ -166,7 +180,7 @@ int av_buffer_make_writable(AVBufferRef **pbuf) return 0; } -int av_buffer_realloc(AVBufferRef **pbuf, buffer_size_t size) +int av_buffer_realloc(AVBufferRef **pbuf, size_t size) { AVBufferRef *buf = *pbuf; uint8_t *tmp; @@ -216,7 +230,7 @@ int av_buffer_realloc(AVBufferRef **pbuf, buffer_size_t size) return 0; } -int av_buffer_replace(AVBufferRef **pdst, AVBufferRef *src) +int av_buffer_replace(AVBufferRef **pdst, const AVBufferRef *src) { AVBufferRef *dst = *pdst; AVBufferRef *tmp; @@ -242,8 +256,8 @@ int av_buffer_replace(AVBufferRef **pdst, AVBufferRef *src) return 0; } -AVBufferPool *av_buffer_pool_init2(buffer_size_t size, void *opaque, - AVBufferRef* (*alloc)(void *opaque, buffer_size_t size), +AVBufferPool *av_buffer_pool_init2(size_t size, void *opaque, + AVBufferRef* (*alloc)(void *opaque, size_t size), void (*pool_free)(void *opaque)) { AVBufferPool *pool = av_mallocz(sizeof(*pool)); @@ -263,7 +277,7 @@ AVBufferPool *av_buffer_pool_init2(buffer_size_t size, void *opaque, return pool; } -AVBufferPool *av_buffer_pool_init(buffer_size_t size, AVBufferRef* (*alloc)(buffer_size_t size)) +AVBufferPool *av_buffer_pool_init(size_t size, AVBufferRef* (*alloc)(size_t size)) { AVBufferPool *pool = av_mallocz(sizeof(*pool)); if (!pool) @@ -378,11 +392,13 @@ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool) ff_mutex_lock(&pool->mutex); buf = pool->pool; if (buf) { - ret = av_buffer_create(buf->data, pool->size, pool_release_buffer, - buf, 0); + memset(&buf->buffer, 0, sizeof(buf->buffer)); + ret = buffer_create(&buf->buffer, buf->data, pool->size, + pool_release_buffer, buf, 0); if (ret) { pool->pool = buf->next; buf->next = NULL; + buf->buffer.flags_internal |= BUFFER_FLAG_NO_FREE; } } else { ret = pool_alloc_buffer(pool); @@ -395,7 +411,7 @@ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool) return ret; } -void *av_buffer_pool_buffer_get_opaque(AVBufferRef *ref) +void *av_buffer_pool_buffer_get_opaque(const AVBufferRef *ref) { BufferPoolEntry *buf = ref->buffer->opaque; av_assert0(buf); diff --git a/media/ffvpx/libavutil/buffer.h b/media/ffvpx/libavutil/buffer.h index 241a80ed6709..e1ef5b7f07fc 100644 --- a/media/ffvpx/libavutil/buffer.h +++ b/media/ffvpx/libavutil/buffer.h @@ -28,8 +28,6 @@ #include #include -#include "version.h" - /** * @defgroup lavu_buffer AVBuffer * @ingroup lavu_data @@ -93,11 +91,7 @@ typedef struct AVBufferRef { /** * Size of data in bytes. */ -#if FF_API_BUFFER_SIZE_T - int size; -#else size_t size; -#endif } AVBufferRef; /** @@ -105,21 +99,13 @@ typedef struct AVBufferRef { * * @return an AVBufferRef of given size or NULL when out of memory */ -#if FF_API_BUFFER_SIZE_T -AVBufferRef *av_buffer_alloc(int size); -#else AVBufferRef *av_buffer_alloc(size_t size); -#endif /** * Same as av_buffer_alloc(), except the returned buffer will be initialized * to zero. */ -#if FF_API_BUFFER_SIZE_T -AVBufferRef *av_buffer_allocz(int size); -#else AVBufferRef *av_buffer_allocz(size_t size); -#endif /** * Always treat the buffer as read-only, even when it has only one @@ -142,11 +128,7 @@ AVBufferRef *av_buffer_allocz(size_t size); * * @return an AVBufferRef referring to data on success, NULL on failure. */ -#if FF_API_BUFFER_SIZE_T -AVBufferRef *av_buffer_create(uint8_t *data, int size, -#else AVBufferRef *av_buffer_create(uint8_t *data, size_t size, -#endif void (*free)(void *opaque, uint8_t *data), void *opaque, int flags); @@ -163,7 +145,7 @@ void av_buffer_default_free(void *opaque, uint8_t *data); * @return a new AVBufferRef referring to the same AVBuffer as buf or NULL on * failure. */ -AVBufferRef *av_buffer_ref(AVBufferRef *buf); +AVBufferRef *av_buffer_ref(const AVBufferRef *buf); /** * Free a given reference and automatically free the buffer if there are no more @@ -214,11 +196,7 @@ int av_buffer_make_writable(AVBufferRef **buf); * reference to it (i.e. the one passed to this function). In all other cases * a new buffer is allocated and the data is copied. */ -#if FF_API_BUFFER_SIZE_T -int av_buffer_realloc(AVBufferRef **buf, int size); -#else int av_buffer_realloc(AVBufferRef **buf, size_t size); -#endif /** * Ensure dst refers to the same data as src. @@ -234,7 +212,7 @@ int av_buffer_realloc(AVBufferRef **buf, size_t size); * @return 0 on success * AVERROR(ENOMEM) on memory allocation failure. */ -int av_buffer_replace(AVBufferRef **dst, AVBufferRef *src); +int av_buffer_replace(AVBufferRef **dst, const AVBufferRef *src); /** * @} @@ -285,11 +263,7 @@ typedef struct AVBufferPool AVBufferPool; * (av_buffer_alloc()). * @return newly created buffer pool on success, NULL on error. */ -#if FF_API_BUFFER_SIZE_T -AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size)); -#else AVBufferPool *av_buffer_pool_init(size_t size, AVBufferRef* (*alloc)(size_t size)); -#endif /** * Allocate and initialize a buffer pool with a more complex allocator. @@ -306,13 +280,8 @@ AVBufferPool *av_buffer_pool_init(size_t size, AVBufferRef* (*alloc)(size_t size * data. May be NULL. * @return newly created buffer pool on success, NULL on error. */ -#if FF_API_BUFFER_SIZE_T -AVBufferPool *av_buffer_pool_init2(int size, void *opaque, - AVBufferRef* (*alloc)(void *opaque, int size), -#else AVBufferPool *av_buffer_pool_init2(size_t size, void *opaque, AVBufferRef* (*alloc)(void *opaque, size_t size), -#endif void (*pool_free)(void *opaque)); /** @@ -344,7 +313,7 @@ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool); * therefore you have to use this function to access the original opaque * parameter of an allocated buffer. */ -void *av_buffer_pool_buffer_get_opaque(AVBufferRef *ref); +void *av_buffer_pool_buffer_get_opaque(const AVBufferRef *ref); /** * @} diff --git a/media/ffvpx/libavutil/buffer_internal.h b/media/ffvpx/libavutil/buffer_internal.h index d902772ed3eb..adb916aaa225 100644 --- a/media/ffvpx/libavutil/buffer_internal.h +++ b/media/ffvpx/libavutil/buffer_internal.h @@ -22,7 +22,6 @@ #include #include -#include "internal.h" #include "buffer.h" #include "thread.h" @@ -30,10 +29,15 @@ * The buffer was av_realloc()ed, so it is reallocatable. */ #define BUFFER_FLAG_REALLOCATABLE (1 << 0) +/** + * The AVBuffer structure is part of a larger structure + * and should not be freed. + */ +#define BUFFER_FLAG_NO_FREE (1 << 1) struct AVBuffer { uint8_t *data; /**< data described by this buffer */ - buffer_size_t size; /**< size of data in bytes */ + size_t size; /**< size of data in bytes */ /** * number of existing AVBufferRef instances referring to this buffer @@ -73,6 +77,12 @@ typedef struct BufferPoolEntry { AVBufferPool *pool; struct BufferPoolEntry *next; + + /* + * An AVBuffer structure to (re)use as AVBuffer for subsequent uses + * of this BufferPoolEntry. + */ + AVBuffer buffer; } BufferPoolEntry; struct AVBufferPool { @@ -90,10 +100,10 @@ struct AVBufferPool { */ atomic_uint refcount; - buffer_size_t size; + size_t size; void *opaque; - AVBufferRef* (*alloc)(buffer_size_t size); - AVBufferRef* (*alloc2)(void *opaque, buffer_size_t size); + AVBufferRef* (*alloc)(size_t size); + AVBufferRef* (*alloc2)(void *opaque, size_t size); void (*pool_free)(void *opaque); }; diff --git a/media/ffvpx/libavutil/channel_layout.c b/media/ffvpx/libavutil/channel_layout.c index ac773a9e634c..21b70173b77c 100644 --- a/media/ffvpx/libavutil/channel_layout.c +++ b/media/ffvpx/libavutil/channel_layout.c @@ -24,12 +24,19 @@ */ #include +#include +#include -#include "avstring.h" -#include "avutil.h" +#include "avassert.h" #include "channel_layout.h" #include "bprint.h" #include "common.h" +#include "error.h" +#include "macros.h" +#include "opt.h" + +#define CHAN_IS_AMBI(x) ((x) >= AV_CHAN_AMBISONIC_BASE &&\ + (x) <= AV_CHAN_AMBISONIC_END) struct channel_name { const char *name; @@ -37,81 +44,166 @@ struct channel_name { }; static const struct channel_name channel_names[] = { - [0] = { "FL", "front left" }, - [1] = { "FR", "front right" }, - [2] = { "FC", "front center" }, - [3] = { "LFE", "low frequency" }, - [4] = { "BL", "back left" }, - [5] = { "BR", "back right" }, - [6] = { "FLC", "front left-of-center" }, - [7] = { "FRC", "front right-of-center" }, - [8] = { "BC", "back center" }, - [9] = { "SL", "side left" }, - [10] = { "SR", "side right" }, - [11] = { "TC", "top center" }, - [12] = { "TFL", "top front left" }, - [13] = { "TFC", "top front center" }, - [14] = { "TFR", "top front right" }, - [15] = { "TBL", "top back left" }, - [16] = { "TBC", "top back center" }, - [17] = { "TBR", "top back right" }, - [29] = { "DL", "downmix left" }, - [30] = { "DR", "downmix right" }, - [31] = { "WL", "wide left" }, - [32] = { "WR", "wide right" }, - [33] = { "SDL", "surround direct left" }, - [34] = { "SDR", "surround direct right" }, - [35] = { "LFE2", "low frequency 2" }, - [36] = { "TSL", "top side left" }, - [37] = { "TSR", "top side right" }, - [38] = { "BFC", "bottom front center" }, - [39] = { "BFL", "bottom front left" }, - [40] = { "BFR", "bottom front right" }, + [AV_CHAN_FRONT_LEFT ] = { "FL", "front left" }, + [AV_CHAN_FRONT_RIGHT ] = { "FR", "front right" }, + [AV_CHAN_FRONT_CENTER ] = { "FC", "front center" }, + [AV_CHAN_LOW_FREQUENCY ] = { "LFE", "low frequency" }, + [AV_CHAN_BACK_LEFT ] = { "BL", "back left" }, + [AV_CHAN_BACK_RIGHT ] = { "BR", "back right" }, + [AV_CHAN_FRONT_LEFT_OF_CENTER ] = { "FLC", "front left-of-center" }, + [AV_CHAN_FRONT_RIGHT_OF_CENTER] = { "FRC", "front right-of-center" }, + [AV_CHAN_BACK_CENTER ] = { "BC", "back center" }, + [AV_CHAN_SIDE_LEFT ] = { "SL", "side left" }, + [AV_CHAN_SIDE_RIGHT ] = { "SR", "side right" }, + [AV_CHAN_TOP_CENTER ] = { "TC", "top center" }, + [AV_CHAN_TOP_FRONT_LEFT ] = { "TFL", "top front left" }, + [AV_CHAN_TOP_FRONT_CENTER ] = { "TFC", "top front center" }, + [AV_CHAN_TOP_FRONT_RIGHT ] = { "TFR", "top front right" }, + [AV_CHAN_TOP_BACK_LEFT ] = { "TBL", "top back left" }, + [AV_CHAN_TOP_BACK_CENTER ] = { "TBC", "top back center" }, + [AV_CHAN_TOP_BACK_RIGHT ] = { "TBR", "top back right" }, + [AV_CHAN_STEREO_LEFT ] = { "DL", "downmix left" }, + [AV_CHAN_STEREO_RIGHT ] = { "DR", "downmix right" }, + [AV_CHAN_WIDE_LEFT ] = { "WL", "wide left" }, + [AV_CHAN_WIDE_RIGHT ] = { "WR", "wide right" }, + [AV_CHAN_SURROUND_DIRECT_LEFT ] = { "SDL", "surround direct left" }, + [AV_CHAN_SURROUND_DIRECT_RIGHT] = { "SDR", "surround direct right" }, + [AV_CHAN_LOW_FREQUENCY_2 ] = { "LFE2", "low frequency 2" }, + [AV_CHAN_TOP_SIDE_LEFT ] = { "TSL", "top side left" }, + [AV_CHAN_TOP_SIDE_RIGHT ] = { "TSR", "top side right" }, + [AV_CHAN_BOTTOM_FRONT_CENTER ] = { "BFC", "bottom front center" }, + [AV_CHAN_BOTTOM_FRONT_LEFT ] = { "BFL", "bottom front left" }, + [AV_CHAN_BOTTOM_FRONT_RIGHT ] = { "BFR", "bottom front right" }, }; -static const char *get_channel_name(int channel_id) +static const char *get_channel_name(enum AVChannel channel_id) { - if (channel_id < 0 || channel_id >= FF_ARRAY_ELEMS(channel_names)) + if ((unsigned) channel_id >= FF_ARRAY_ELEMS(channel_names) || + !channel_names[channel_id].name) return NULL; return channel_names[channel_id].name; } -static const struct { +void av_channel_name_bprint(AVBPrint *bp, enum AVChannel channel_id) +{ + if (channel_id >= AV_CHAN_AMBISONIC_BASE && + channel_id <= AV_CHAN_AMBISONIC_END) + av_bprintf(bp, "AMBI%d", channel_id - AV_CHAN_AMBISONIC_BASE); + else if ((unsigned)channel_id < FF_ARRAY_ELEMS(channel_names) && + channel_names[channel_id].name) + av_bprintf(bp, "%s", channel_names[channel_id].name); + else if (channel_id == AV_CHAN_NONE) + av_bprintf(bp, "NONE"); + else + av_bprintf(bp, "USR%d", channel_id); +} + +int av_channel_name(char *buf, size_t buf_size, enum AVChannel channel_id) +{ + AVBPrint bp; + + if (!buf && buf_size) + return AVERROR(EINVAL); + + av_bprint_init_for_buffer(&bp, buf, buf_size); + av_channel_name_bprint(&bp, channel_id); + + return bp.len; +} + +void av_channel_description_bprint(AVBPrint *bp, enum AVChannel channel_id) +{ + if (channel_id >= AV_CHAN_AMBISONIC_BASE && + channel_id <= AV_CHAN_AMBISONIC_END) + av_bprintf(bp, "ambisonic ACN %d", channel_id - AV_CHAN_AMBISONIC_BASE); + else if ((unsigned)channel_id < FF_ARRAY_ELEMS(channel_names) && + channel_names[channel_id].description) + av_bprintf(bp, "%s", channel_names[channel_id].description); + else if (channel_id == AV_CHAN_NONE) + av_bprintf(bp, "none"); + else + av_bprintf(bp, "user %d", channel_id); +} + +int av_channel_description(char *buf, size_t buf_size, enum AVChannel channel_id) +{ + AVBPrint bp; + + if (!buf && buf_size) + return AVERROR(EINVAL); + + av_bprint_init_for_buffer(&bp, buf, buf_size); + av_channel_description_bprint(&bp, channel_id); + + return bp.len; +} + +enum AVChannel av_channel_from_string(const char *str) +{ + int i; + char *endptr = (char *)str; + enum AVChannel id = AV_CHAN_NONE; + + if (!strncmp(str, "AMBI", 4)) { + i = strtol(str + 4, NULL, 0); + if (i < 0 || i > AV_CHAN_AMBISONIC_END - AV_CHAN_AMBISONIC_BASE) + return AV_CHAN_NONE; + return AV_CHAN_AMBISONIC_BASE + i; + } + + for (i = 0; i < FF_ARRAY_ELEMS(channel_names); i++) { + if (channel_names[i].name && !strcmp(str, channel_names[i].name)) + return i; + } + if (!strncmp(str, "USR", 3)) { + const char *p = str + 3; + id = strtol(p, &endptr, 0); + } + if (id >= 0 && !*endptr) + return id; + + return AV_CHAN_NONE; +} + +struct channel_layout_name { const char *name; - int nb_channels; - uint64_t layout; -} channel_layout_map[] = { - { "mono", 1, AV_CH_LAYOUT_MONO }, - { "stereo", 2, AV_CH_LAYOUT_STEREO }, - { "2.1", 3, AV_CH_LAYOUT_2POINT1 }, - { "3.0", 3, AV_CH_LAYOUT_SURROUND }, - { "3.0(back)", 3, AV_CH_LAYOUT_2_1 }, - { "4.0", 4, AV_CH_LAYOUT_4POINT0 }, - { "quad", 4, AV_CH_LAYOUT_QUAD }, - { "quad(side)", 4, AV_CH_LAYOUT_2_2 }, - { "3.1", 4, AV_CH_LAYOUT_3POINT1 }, - { "5.0", 5, AV_CH_LAYOUT_5POINT0_BACK }, - { "5.0(side)", 5, AV_CH_LAYOUT_5POINT0 }, - { "4.1", 5, AV_CH_LAYOUT_4POINT1 }, - { "5.1", 6, AV_CH_LAYOUT_5POINT1_BACK }, - { "5.1(side)", 6, AV_CH_LAYOUT_5POINT1 }, - { "6.0", 6, AV_CH_LAYOUT_6POINT0 }, - { "6.0(front)", 6, AV_CH_LAYOUT_6POINT0_FRONT }, - { "hexagonal", 6, AV_CH_LAYOUT_HEXAGONAL }, - { "6.1", 7, AV_CH_LAYOUT_6POINT1 }, - { "6.1(back)", 7, AV_CH_LAYOUT_6POINT1_BACK }, - { "6.1(front)", 7, AV_CH_LAYOUT_6POINT1_FRONT }, - { "7.0", 7, AV_CH_LAYOUT_7POINT0 }, - { "7.0(front)", 7, AV_CH_LAYOUT_7POINT0_FRONT }, - { "7.1", 8, AV_CH_LAYOUT_7POINT1 }, - { "7.1(wide)", 8, AV_CH_LAYOUT_7POINT1_WIDE_BACK }, - { "7.1(wide-side)", 8, AV_CH_LAYOUT_7POINT1_WIDE }, - { "octagonal", 8, AV_CH_LAYOUT_OCTAGONAL }, - { "hexadecagonal", 16, AV_CH_LAYOUT_HEXADECAGONAL }, - { "downmix", 2, AV_CH_LAYOUT_STEREO_DOWNMIX, }, - { "22.2", 24, AV_CH_LAYOUT_22POINT2, }, + AVChannelLayout layout; }; +static const struct channel_layout_name channel_layout_map[] = { + { "mono", AV_CHANNEL_LAYOUT_MONO }, + { "stereo", AV_CHANNEL_LAYOUT_STEREO }, + { "2.1", AV_CHANNEL_LAYOUT_2POINT1 }, + { "3.0", AV_CHANNEL_LAYOUT_SURROUND }, + { "3.0(back)", AV_CHANNEL_LAYOUT_2_1 }, + { "4.0", AV_CHANNEL_LAYOUT_4POINT0 }, + { "quad", AV_CHANNEL_LAYOUT_QUAD }, + { "quad(side)", AV_CHANNEL_LAYOUT_2_2 }, + { "3.1", AV_CHANNEL_LAYOUT_3POINT1 }, + { "5.0", AV_CHANNEL_LAYOUT_5POINT0_BACK }, + { "5.0(side)", AV_CHANNEL_LAYOUT_5POINT0 }, + { "4.1", AV_CHANNEL_LAYOUT_4POINT1 }, + { "5.1", AV_CHANNEL_LAYOUT_5POINT1_BACK }, + { "5.1(side)", AV_CHANNEL_LAYOUT_5POINT1 }, + { "6.0", AV_CHANNEL_LAYOUT_6POINT0 }, + { "6.0(front)", AV_CHANNEL_LAYOUT_6POINT0_FRONT }, + { "hexagonal", AV_CHANNEL_LAYOUT_HEXAGONAL }, + { "6.1", AV_CHANNEL_LAYOUT_6POINT1 }, + { "6.1(back)", AV_CHANNEL_LAYOUT_6POINT1_BACK }, + { "6.1(front)", AV_CHANNEL_LAYOUT_6POINT1_FRONT }, + { "7.0", AV_CHANNEL_LAYOUT_7POINT0 }, + { "7.0(front)", AV_CHANNEL_LAYOUT_7POINT0_FRONT }, + { "7.1", AV_CHANNEL_LAYOUT_7POINT1 }, + { "7.1(wide)", AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK }, + { "7.1(wide-side)", AV_CHANNEL_LAYOUT_7POINT1_WIDE }, + { "octagonal", AV_CHANNEL_LAYOUT_OCTAGONAL }, + { "hexadecagonal", AV_CHANNEL_LAYOUT_HEXADECAGONAL }, + { "downmix", AV_CHANNEL_LAYOUT_STEREO_DOWNMIX, }, + { "22.2", AV_CHANNEL_LAYOUT_22POINT2, }, +}; + +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS static uint64_t get_channel_layout_single(const char *name, int name_len) { int i; @@ -121,7 +213,7 @@ static uint64_t get_channel_layout_single(const char *name, int name_len) for (i = 0; i < FF_ARRAY_ELEMS(channel_layout_map); i++) { if (strlen(channel_layout_map[i].name) == name_len && !memcmp(channel_layout_map[i].name, name, name_len)) - return channel_layout_map[i].layout; + return channel_layout_map[i].layout.u.mask; } for (i = 0; i < FF_ARRAY_ELEMS(channel_names); i++) if (channel_names[i].name && @@ -189,8 +281,8 @@ void av_bprint_channel_layout(struct AVBPrint *bp, nb_channels = av_get_channel_layout_nb_channels(channel_layout); for (i = 0; i < FF_ARRAY_ELEMS(channel_layout_map); i++) - if (nb_channels == channel_layout_map[i].nb_channels && - channel_layout == channel_layout_map[i].layout) { + if (nb_channels == channel_layout_map[i].layout.nb_channels && + channel_layout == channel_layout_map[i].layout.u.mask) { av_bprintf(bp, "%s", channel_layout_map[i].name); return; } @@ -231,8 +323,8 @@ int av_get_channel_layout_nb_channels(uint64_t channel_layout) int64_t av_get_default_channel_layout(int nb_channels) { int i; for (i = 0; i < FF_ARRAY_ELEMS(channel_layout_map); i++) - if (nb_channels == channel_layout_map[i].nb_channels) - return channel_layout_map[i].layout; + if (nb_channels == channel_layout_map[i].layout.nb_channels) + return channel_layout_map[i].layout.u.mask; return 0; } @@ -287,7 +379,626 @@ int av_get_standard_channel_layout(unsigned index, uint64_t *layout, { if (index >= FF_ARRAY_ELEMS(channel_layout_map)) return AVERROR_EOF; - if (layout) *layout = channel_layout_map[index].layout; + if (layout) *layout = channel_layout_map[index].layout.u.mask; if (name) *name = channel_layout_map[index].name; return 0; } +FF_ENABLE_DEPRECATION_WARNINGS +#endif + +int av_channel_layout_from_mask(AVChannelLayout *channel_layout, + uint64_t mask) +{ + if (!mask) + return AVERROR(EINVAL); + + channel_layout->order = AV_CHANNEL_ORDER_NATIVE; + channel_layout->nb_channels = av_popcount64(mask); + channel_layout->u.mask = mask; + + return 0; +} + +int av_channel_layout_from_string(AVChannelLayout *channel_layout, + const char *str) +{ + int i; + int channels = 0, nb_channels = 0, native = 1; + enum AVChannel highest_channel = AV_CHAN_NONE; + const char *dup; + char *chlist, *end; + uint64_t mask = 0; + + /* channel layout names */ + for (i = 0; i < FF_ARRAY_ELEMS(channel_layout_map); i++) { + if (channel_layout_map[i].name && !strcmp(str, channel_layout_map[i].name)) { + *channel_layout = channel_layout_map[i].layout; + return 0; + } + } + + /* ambisonic */ + if (!strncmp(str, "ambisonic ", 10)) { + const char *p = str + 10; + char *endptr; + AVChannelLayout extra = {0}; + int order; + + order = strtol(p, &endptr, 0); + if (order < 0 || order + 1 > INT_MAX / (order + 1) || + (*endptr && *endptr != '+')) + return AVERROR(EINVAL); + + channel_layout->order = AV_CHANNEL_ORDER_AMBISONIC; + channel_layout->nb_channels = (order + 1) * (order + 1); + + if (*endptr) { + int ret = av_channel_layout_from_string(&extra, endptr + 1); + if (ret < 0) + return ret; + if (extra.nb_channels >= INT_MAX - channel_layout->nb_channels) { + av_channel_layout_uninit(&extra); + return AVERROR(EINVAL); + } + + if (extra.order == AV_CHANNEL_ORDER_NATIVE) { + channel_layout->u.mask = extra.u.mask; + } else { + channel_layout->order = AV_CHANNEL_ORDER_CUSTOM; + channel_layout->u.map = + av_calloc(channel_layout->nb_channels + extra.nb_channels, + sizeof(*channel_layout->u.map)); + if (!channel_layout->u.map) { + av_channel_layout_uninit(&extra); + return AVERROR(ENOMEM); + } + + for (i = 0; i < channel_layout->nb_channels; i++) + channel_layout->u.map[i].id = AV_CHAN_AMBISONIC_BASE + i; + for (i = 0; i < extra.nb_channels; i++) { + enum AVChannel ch = av_channel_layout_channel_from_index(&extra, i); + if (CHAN_IS_AMBI(ch)) { + av_channel_layout_uninit(&extra); + return AVERROR(EINVAL); + } + channel_layout->u.map[channel_layout->nb_channels + i].id = ch; + if (extra.order == AV_CHANNEL_ORDER_CUSTOM && + extra.u.map[i].name[0]) + av_strlcpy(channel_layout->u.map[channel_layout->nb_channels + i].name, + extra.u.map[i].name, + sizeof(channel_layout->u.map[channel_layout->nb_channels + i].name)); + } + } + channel_layout->nb_channels += extra.nb_channels; + av_channel_layout_uninit(&extra); + } + + return 0; + } + + chlist = av_strdup(str); + if (!chlist) + return AVERROR(ENOMEM); + + /* channel names */ + av_sscanf(str, "%d channels (%[^)]", &nb_channels, chlist); + end = strchr(str, ')'); + + dup = chlist; + while (*dup) { + char *channel, *chname; + int ret = av_opt_get_key_value(&dup, "@", "+", AV_OPT_FLAG_IMPLICIT_KEY, &channel, &chname); + if (ret < 0) { + av_free(chlist); + return ret; + } + if (*dup) + dup++; // skip separator + if (channel && !*channel) + av_freep(&channel); + for (i = 0; i < FF_ARRAY_ELEMS(channel_names); i++) { + if (channel_names[i].name && !strcmp(channel ? channel : chname, channel_names[i].name)) { + if (channel || i < highest_channel || mask & (1ULL << i)) + native = 0; // Not a native layout, use a custom one + highest_channel = i; + mask |= 1ULL << i; + break; + } + } + + if (!channel && i >= FF_ARRAY_ELEMS(channel_names)) { + char *endptr = chname; + enum AVChannel id = AV_CHAN_NONE; + + if (!strncmp(chname, "USR", 3)) { + const char *p = chname + 3; + id = strtol(p, &endptr, 0); + } + if (id < 0 || *endptr) { + native = 0; // Unknown channel name + channels = 0; + mask = 0; + av_free(chname); + break; + } + if (id > 63) + native = 0; // Not a native layout, use a custom one + else { + if (id < highest_channel || mask & (1ULL << id)) + native = 0; // Not a native layout, use a custom one + highest_channel = id; + mask |= 1ULL << id; + } + } + channels++; + av_free(channel); + av_free(chname); + } + + if (mask && native) { + av_free(chlist); + if (nb_channels && ((nb_channels != channels) || (!end || *++end))) + return AVERROR(EINVAL); + av_channel_layout_from_mask(channel_layout, mask); + return 0; + } + + /* custom layout of channel names */ + if (channels && !native) { + int idx = 0; + + if (nb_channels && ((nb_channels != channels) || (!end || *++end))) { + av_free(chlist); + return AVERROR(EINVAL); + } + + channel_layout->u.map = av_calloc(channels, sizeof(*channel_layout->u.map)); + if (!channel_layout->u.map) { + av_free(chlist); + return AVERROR(ENOMEM); + } + + channel_layout->order = AV_CHANNEL_ORDER_CUSTOM; + channel_layout->nb_channels = channels; + + dup = chlist; + while (*dup) { + char *channel, *chname; + int ret = av_opt_get_key_value(&dup, "@", "+", AV_OPT_FLAG_IMPLICIT_KEY, &channel, &chname); + if (ret < 0) { + av_freep(&channel_layout->u.map); + av_free(chlist); + return ret; + } + if (*dup) + dup++; // skip separator + for (i = 0; i < FF_ARRAY_ELEMS(channel_names); i++) { + if (channel_names[i].name && !strcmp(channel ? channel : chname, channel_names[i].name)) { + channel_layout->u.map[idx].id = i; + if (channel) + av_strlcpy(channel_layout->u.map[idx].name, chname, sizeof(channel_layout->u.map[idx].name)); + idx++; + break; + } + } + if (i >= FF_ARRAY_ELEMS(channel_names)) { + const char *p = (channel ? channel : chname) + 3; + channel_layout->u.map[idx].id = strtol(p, NULL, 0); + if (channel) + av_strlcpy(channel_layout->u.map[idx].name, chname, sizeof(channel_layout->u.map[idx].name)); + idx++; + } + av_free(channel); + av_free(chname); + } + av_free(chlist); + + return 0; + } + av_freep(&chlist); + + errno = 0; + mask = strtoull(str, &end, 0); + + /* channel layout mask */ + if (!errno && !*end && !strchr(str, '-') && mask) { + av_channel_layout_from_mask(channel_layout, mask); + return 0; + } + + errno = 0; + channels = strtol(str, &end, 10); + + /* number of channels */ + if (!errno && !strcmp(end, "c") && channels > 0) { + av_channel_layout_default(channel_layout, channels); + if (channel_layout->order == AV_CHANNEL_ORDER_NATIVE) + return 0; + } + + /* number of unordered channels */ + if (!errno && (!strcmp(end, "C") || !strcmp(end, " channels")) + && channels > 0) { + channel_layout->order = AV_CHANNEL_ORDER_UNSPEC; + channel_layout->nb_channels = channels; + return 0; + } + + return AVERROR(EINVAL); +} + +void av_channel_layout_uninit(AVChannelLayout *channel_layout) +{ + if (channel_layout->order == AV_CHANNEL_ORDER_CUSTOM) + av_freep(&channel_layout->u.map); + memset(channel_layout, 0, sizeof(*channel_layout)); +} + +int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src) +{ + av_channel_layout_uninit(dst); + *dst = *src; + if (src->order == AV_CHANNEL_ORDER_CUSTOM) { + dst->u.map = av_malloc_array(src->nb_channels, sizeof(*dst->u.map)); + if (!dst->u.map) + return AVERROR(ENOMEM); + memcpy(dst->u.map, src->u.map, src->nb_channels * sizeof(*src->u.map)); + } + return 0; +} + +/** + * If the layout is n-th order standard-order ambisonic, with optional + * extra non-diegetic channels at the end, return the order. + * Return a negative error code otherwise. + */ +static int ambisonic_order(const AVChannelLayout *channel_layout) +{ + int i, highest_ambi, order; + + highest_ambi = -1; + if (channel_layout->order == AV_CHANNEL_ORDER_AMBISONIC) + highest_ambi = channel_layout->nb_channels - av_popcount64(channel_layout->u.mask) - 1; + else { + const AVChannelCustom *map = channel_layout->u.map; + av_assert0(channel_layout->order == AV_CHANNEL_ORDER_CUSTOM); + + for (i = 0; i < channel_layout->nb_channels; i++) { + int is_ambi = CHAN_IS_AMBI(map[i].id); + + /* ambisonic following non-ambisonic */ + if (i > 0 && is_ambi && !CHAN_IS_AMBI(map[i - 1].id)) + return AVERROR(EINVAL); + + /* non-default ordering */ + if (is_ambi && map[i].id - AV_CHAN_AMBISONIC_BASE != i) + return AVERROR(EINVAL); + + if (CHAN_IS_AMBI(map[i].id)) + highest_ambi = i; + } + } + /* no ambisonic channels*/ + if (highest_ambi < 0) + return AVERROR(EINVAL); + + order = floor(sqrt(highest_ambi)); + /* incomplete order - some harmonics are missing */ + if ((order + 1) * (order + 1) != highest_ambi + 1) + return AVERROR(EINVAL); + + return order; +} + +/** + * If the custom layout is n-th order standard-order ambisonic, with optional + * extra non-diegetic channels at the end, write its string description in bp. + * Return a negative error code otherwise. + */ +static int try_describe_ambisonic(AVBPrint *bp, const AVChannelLayout *channel_layout) +{ + int nb_ambi_channels; + int order = ambisonic_order(channel_layout); + if (order < 0) + return order; + + av_bprintf(bp, "ambisonic %d", order); + + /* extra channels present */ + nb_ambi_channels = (order + 1) * (order + 1); + if (nb_ambi_channels < channel_layout->nb_channels) { + AVChannelLayout extra = { 0 }; + + if (channel_layout->order == AV_CHANNEL_ORDER_AMBISONIC) { + extra.order = AV_CHANNEL_ORDER_NATIVE; + extra.nb_channels = av_popcount64(channel_layout->u.mask); + extra.u.mask = channel_layout->u.mask; + } else { + extra.order = AV_CHANNEL_ORDER_CUSTOM; + extra.nb_channels = channel_layout->nb_channels - nb_ambi_channels; + extra.u.map = channel_layout->u.map + nb_ambi_channels; + } + + av_bprint_chars(bp, '+', 1); + av_channel_layout_describe_bprint(&extra, bp); + /* Not calling uninit here on extra because we don't own the u.map pointer */ + } + + return 0; +} + +int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout, + AVBPrint *bp) +{ + int i; + + switch (channel_layout->order) { + case AV_CHANNEL_ORDER_NATIVE: + for (i = 0; i < FF_ARRAY_ELEMS(channel_layout_map); i++) + if (channel_layout->u.mask == channel_layout_map[i].layout.u.mask) { + av_bprintf(bp, "%s", channel_layout_map[i].name); + return 0; + } + // fall-through + case AV_CHANNEL_ORDER_CUSTOM: + if (channel_layout->order == AV_CHANNEL_ORDER_CUSTOM) { + int res = try_describe_ambisonic(bp, channel_layout); + if (res >= 0) + return 0; + } + if (channel_layout->nb_channels) + av_bprintf(bp, "%d channels (", channel_layout->nb_channels); + for (i = 0; i < channel_layout->nb_channels; i++) { + enum AVChannel ch = av_channel_layout_channel_from_index(channel_layout, i); + + if (i) + av_bprintf(bp, "+"); + av_channel_name_bprint(bp, ch); + if (channel_layout->order == AV_CHANNEL_ORDER_CUSTOM && + channel_layout->u.map[i].name[0]) + av_bprintf(bp, "@%s", channel_layout->u.map[i].name); + } + if (channel_layout->nb_channels) { + av_bprintf(bp, ")"); + return 0; + } + // fall-through + case AV_CHANNEL_ORDER_UNSPEC: + av_bprintf(bp, "%d channels", channel_layout->nb_channels); + return 0; + case AV_CHANNEL_ORDER_AMBISONIC: + return try_describe_ambisonic(bp, channel_layout); + default: + return AVERROR(EINVAL); + } +} + +int av_channel_layout_describe(const AVChannelLayout *channel_layout, + char *buf, size_t buf_size) +{ + AVBPrint bp; + int ret; + + if (!buf && buf_size) + return AVERROR(EINVAL); + + av_bprint_init_for_buffer(&bp, buf, buf_size); + ret = av_channel_layout_describe_bprint(channel_layout, &bp); + if (ret < 0) + return ret; + + return bp.len; +} + +enum AVChannel +av_channel_layout_channel_from_index(const AVChannelLayout *channel_layout, + unsigned int idx) +{ + int i; + + if (idx >= channel_layout->nb_channels) + return AV_CHAN_NONE; + + switch (channel_layout->order) { + case AV_CHANNEL_ORDER_CUSTOM: + return channel_layout->u.map[idx].id; + case AV_CHANNEL_ORDER_AMBISONIC: { + int ambi_channels = channel_layout->nb_channels - av_popcount64(channel_layout->u.mask); + if (idx < ambi_channels) + return AV_CHAN_AMBISONIC_BASE + idx; + idx -= ambi_channels; + } + // fall-through + case AV_CHANNEL_ORDER_NATIVE: + for (i = 0; i < 64; i++) { + if ((1ULL << i) & channel_layout->u.mask && !idx--) + return i; + } + default: + return AV_CHAN_NONE; + } +} + +enum AVChannel +av_channel_layout_channel_from_string(const AVChannelLayout *channel_layout, + const char *str) +{ + int index = av_channel_layout_index_from_string(channel_layout, str); + + if (index < 0) + return AV_CHAN_NONE; + + return av_channel_layout_channel_from_index(channel_layout, index); +} + +int av_channel_layout_index_from_channel(const AVChannelLayout *channel_layout, + enum AVChannel channel) +{ + int i; + + if (channel == AV_CHAN_NONE) + return AVERROR(EINVAL); + + switch (channel_layout->order) { + case AV_CHANNEL_ORDER_CUSTOM: + for (i = 0; i < channel_layout->nb_channels; i++) + if (channel_layout->u.map[i].id == channel) + return i; + return AVERROR(EINVAL); + case AV_CHANNEL_ORDER_AMBISONIC: + case AV_CHANNEL_ORDER_NATIVE: { + uint64_t mask = channel_layout->u.mask; + int ambi_channels = channel_layout->nb_channels - av_popcount64(mask); + if (channel_layout->order == AV_CHANNEL_ORDER_AMBISONIC && + channel >= AV_CHAN_AMBISONIC_BASE) { + if (channel - AV_CHAN_AMBISONIC_BASE >= ambi_channels) + return AVERROR(EINVAL); + return channel - AV_CHAN_AMBISONIC_BASE; + } + if ((unsigned)channel > 63 || !(mask & (1ULL << channel))) + return AVERROR(EINVAL); + mask &= (1ULL << channel) - 1; + return av_popcount64(mask) + ambi_channels; + } + default: + return AVERROR(EINVAL); + } +} + +int av_channel_layout_index_from_string(const AVChannelLayout *channel_layout, + const char *str) +{ + char *chname; + enum AVChannel ch = AV_CHAN_NONE; + + switch (channel_layout->order) { + case AV_CHANNEL_ORDER_CUSTOM: + chname = strstr(str, "@"); + if (chname) { + char buf[16]; + chname++; + av_strlcpy(buf, str, FFMIN(sizeof(buf), chname - str)); + if (!*chname) + chname = NULL; + ch = av_channel_from_string(buf); + if (ch == AV_CHAN_NONE && *buf) + return AVERROR(EINVAL); + } + for (int i = 0; chname && i < channel_layout->nb_channels; i++) { + if (!strcmp(chname, channel_layout->u.map[i].name) && + (ch == AV_CHAN_NONE || ch == channel_layout->u.map[i].id)) + return i; + } + // fall-through + case AV_CHANNEL_ORDER_AMBISONIC: + case AV_CHANNEL_ORDER_NATIVE: + ch = av_channel_from_string(str); + if (ch == AV_CHAN_NONE) + return AVERROR(EINVAL); + return av_channel_layout_index_from_channel(channel_layout, ch); + } + + return AVERROR(EINVAL); +} + +int av_channel_layout_check(const AVChannelLayout *channel_layout) +{ + if (channel_layout->nb_channels <= 0) + return 0; + + switch (channel_layout->order) { + case AV_CHANNEL_ORDER_NATIVE: + return av_popcount64(channel_layout->u.mask) == channel_layout->nb_channels; + case AV_CHANNEL_ORDER_CUSTOM: + if (!channel_layout->u.map) + return 0; + for (int i = 0; i < channel_layout->nb_channels; i++) { + if (channel_layout->u.map[i].id == AV_CHAN_NONE) + return 0; + } + return 1; + case AV_CHANNEL_ORDER_AMBISONIC: + /* If non-diegetic channels are present, ensure they are taken into account */ + return av_popcount64(channel_layout->u.mask) < channel_layout->nb_channels; + case AV_CHANNEL_ORDER_UNSPEC: + return 1; + default: + return 0; + } +} + +int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1) +{ + int i; + + /* different channel counts -> not equal */ + if (chl->nb_channels != chl1->nb_channels) + return 1; + + /* if only one is unspecified -> not equal */ + if ((chl->order == AV_CHANNEL_ORDER_UNSPEC) != + (chl1->order == AV_CHANNEL_ORDER_UNSPEC)) + return 1; + /* both are unspecified -> equal */ + else if (chl->order == AV_CHANNEL_ORDER_UNSPEC) + return 0; + + /* can compare masks directly */ + if ((chl->order == AV_CHANNEL_ORDER_NATIVE || + chl->order == AV_CHANNEL_ORDER_AMBISONIC) && + chl->order == chl1->order) + return chl->u.mask != chl1->u.mask; + + /* compare channel by channel */ + for (i = 0; i < chl->nb_channels; i++) + if (av_channel_layout_channel_from_index(chl, i) != + av_channel_layout_channel_from_index(chl1, i)) + return 1; + return 0; +} + +void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels) +{ + int i; + for (i = 0; i < FF_ARRAY_ELEMS(channel_layout_map); i++) + if (nb_channels == channel_layout_map[i].layout.nb_channels) { + *ch_layout = channel_layout_map[i].layout; + return; + } + + ch_layout->order = AV_CHANNEL_ORDER_UNSPEC; + ch_layout->nb_channels = nb_channels; +} + +const AVChannelLayout *av_channel_layout_standard(void **opaque) +{ + uintptr_t i = (uintptr_t)*opaque; + const AVChannelLayout *ch_layout = NULL; + + if (i < FF_ARRAY_ELEMS(channel_layout_map)) { + ch_layout = &channel_layout_map[i].layout; + *opaque = (void*)(i + 1); + } + + return ch_layout; +} + +uint64_t av_channel_layout_subset(const AVChannelLayout *channel_layout, + uint64_t mask) +{ + uint64_t ret = 0; + int i; + + switch (channel_layout->order) { + case AV_CHANNEL_ORDER_NATIVE: + case AV_CHANNEL_ORDER_AMBISONIC: + return channel_layout->u.mask & mask; + case AV_CHANNEL_ORDER_CUSTOM: + for (i = 0; i < 64; i++) + if (mask & (1ULL << i) && av_channel_layout_index_from_channel(channel_layout, i) >= 0) + ret |= (1ULL << i); + break; + } + + return ret; +} diff --git a/media/ffvpx/libavutil/channel_layout.h b/media/ffvpx/libavutil/channel_layout.h index d39ae1177afe..4dd6614de900 100644 --- a/media/ffvpx/libavutil/channel_layout.h +++ b/media/ffvpx/libavutil/channel_layout.h @@ -23,6 +23,10 @@ #define AVUTIL_CHANNEL_LAYOUT_H #include +#include + +#include "version.h" +#include "attributes.h" /** * @file @@ -34,6 +38,111 @@ * @{ */ +enum AVChannel { + ///< Invalid channel index + AV_CHAN_NONE = -1, + AV_CHAN_FRONT_LEFT, + AV_CHAN_FRONT_RIGHT, + AV_CHAN_FRONT_CENTER, + AV_CHAN_LOW_FREQUENCY, + AV_CHAN_BACK_LEFT, + AV_CHAN_BACK_RIGHT, + AV_CHAN_FRONT_LEFT_OF_CENTER, + AV_CHAN_FRONT_RIGHT_OF_CENTER, + AV_CHAN_BACK_CENTER, + AV_CHAN_SIDE_LEFT, + AV_CHAN_SIDE_RIGHT, + AV_CHAN_TOP_CENTER, + AV_CHAN_TOP_FRONT_LEFT, + AV_CHAN_TOP_FRONT_CENTER, + AV_CHAN_TOP_FRONT_RIGHT, + AV_CHAN_TOP_BACK_LEFT, + AV_CHAN_TOP_BACK_CENTER, + AV_CHAN_TOP_BACK_RIGHT, + /** Stereo downmix. */ + AV_CHAN_STEREO_LEFT = 29, + /** See above. */ + AV_CHAN_STEREO_RIGHT, + AV_CHAN_WIDE_LEFT, + AV_CHAN_WIDE_RIGHT, + AV_CHAN_SURROUND_DIRECT_LEFT, + AV_CHAN_SURROUND_DIRECT_RIGHT, + AV_CHAN_LOW_FREQUENCY_2, + AV_CHAN_TOP_SIDE_LEFT, + AV_CHAN_TOP_SIDE_RIGHT, + AV_CHAN_BOTTOM_FRONT_CENTER, + AV_CHAN_BOTTOM_FRONT_LEFT, + AV_CHAN_BOTTOM_FRONT_RIGHT, + + /** Channel is empty can be safely skipped. */ + AV_CHAN_UNUSED = 0x200, + + /** Channel contains data, but its position is unknown. */ + AV_CHAN_UNKNOWN = 0x300, + + /** + * Range of channels between AV_CHAN_AMBISONIC_BASE and + * AV_CHAN_AMBISONIC_END represent Ambisonic components using the ACN system. + * + * Given a channel id between AV_CHAN_AMBISONIC_BASE and + * AV_CHAN_AMBISONIC_END (inclusive), the ACN index of the channel is + * = - AV_CHAN_AMBISONIC_BASE. + * + * @note these values are only used for AV_CHANNEL_ORDER_CUSTOM channel + * orderings, the AV_CHANNEL_ORDER_AMBISONIC ordering orders the channels + * implicitly by their position in the stream. + */ + AV_CHAN_AMBISONIC_BASE = 0x400, + // leave space for 1024 ids, which correspond to maximum order-32 harmonics, + // which should be enough for the foreseeable use cases + AV_CHAN_AMBISONIC_END = 0x7ff, +}; + +enum AVChannelOrder { + /** + * Only the channel count is specified, without any further information + * about the channel order. + */ + AV_CHANNEL_ORDER_UNSPEC, + /** + * The native channel order, i.e. the channels are in the same order in + * which they are defined in the AVChannel enum. This supports up to 63 + * different channels. + */ + AV_CHANNEL_ORDER_NATIVE, + /** + * The channel order does not correspond to any other predefined order and + * is stored as an explicit map. For example, this could be used to support + * layouts with 64 or more channels, or with empty/skipped (AV_CHAN_SILENCE) + * channels at arbitrary positions. + */ + AV_CHANNEL_ORDER_CUSTOM, + /** + * The audio is represented as the decomposition of the sound field into + * spherical harmonics. Each channel corresponds to a single expansion + * component. Channels are ordered according to ACN (Ambisonic Channel + * Number). + * + * The channel with the index n in the stream contains the spherical + * harmonic of degree l and order m given by + * @code{.unparsed} + * l = floor(sqrt(n)), + * m = n - l * (l + 1). + * @endcode + * + * Conversely given a spherical harmonic of degree l and order m, the + * corresponding channel index n is given by + * @code{.unparsed} + * n = l * (l + 1) + m. + * @endcode + * + * Normalization is assumed to be SN3D (Schmidt Semi-Normalization) + * as defined in AmbiX format $ 2.1. + */ + AV_CHANNEL_ORDER_AMBISONIC, +}; + + /** * @defgroup channel_masks Audio channel masks * @@ -46,41 +155,46 @@ * * @{ */ -#define AV_CH_FRONT_LEFT 0x00000001 -#define AV_CH_FRONT_RIGHT 0x00000002 -#define AV_CH_FRONT_CENTER 0x00000004 -#define AV_CH_LOW_FREQUENCY 0x00000008 -#define AV_CH_BACK_LEFT 0x00000010 -#define AV_CH_BACK_RIGHT 0x00000020 -#define AV_CH_FRONT_LEFT_OF_CENTER 0x00000040 -#define AV_CH_FRONT_RIGHT_OF_CENTER 0x00000080 -#define AV_CH_BACK_CENTER 0x00000100 -#define AV_CH_SIDE_LEFT 0x00000200 -#define AV_CH_SIDE_RIGHT 0x00000400 -#define AV_CH_TOP_CENTER 0x00000800 -#define AV_CH_TOP_FRONT_LEFT 0x00001000 -#define AV_CH_TOP_FRONT_CENTER 0x00002000 -#define AV_CH_TOP_FRONT_RIGHT 0x00004000 -#define AV_CH_TOP_BACK_LEFT 0x00008000 -#define AV_CH_TOP_BACK_CENTER 0x00010000 -#define AV_CH_TOP_BACK_RIGHT 0x00020000 -#define AV_CH_STEREO_LEFT 0x20000000 ///< Stereo downmix. -#define AV_CH_STEREO_RIGHT 0x40000000 ///< See AV_CH_STEREO_LEFT. -#define AV_CH_WIDE_LEFT 0x0000000080000000ULL -#define AV_CH_WIDE_RIGHT 0x0000000100000000ULL -#define AV_CH_SURROUND_DIRECT_LEFT 0x0000000200000000ULL -#define AV_CH_SURROUND_DIRECT_RIGHT 0x0000000400000000ULL -#define AV_CH_LOW_FREQUENCY_2 0x0000000800000000ULL -#define AV_CH_TOP_SIDE_LEFT 0x0000001000000000ULL -#define AV_CH_TOP_SIDE_RIGHT 0x0000002000000000ULL -#define AV_CH_BOTTOM_FRONT_CENTER 0x0000004000000000ULL -#define AV_CH_BOTTOM_FRONT_LEFT 0x0000008000000000ULL -#define AV_CH_BOTTOM_FRONT_RIGHT 0x0000010000000000ULL +#define AV_CH_FRONT_LEFT (1ULL << AV_CHAN_FRONT_LEFT ) +#define AV_CH_FRONT_RIGHT (1ULL << AV_CHAN_FRONT_RIGHT ) +#define AV_CH_FRONT_CENTER (1ULL << AV_CHAN_FRONT_CENTER ) +#define AV_CH_LOW_FREQUENCY (1ULL << AV_CHAN_LOW_FREQUENCY ) +#define AV_CH_BACK_LEFT (1ULL << AV_CHAN_BACK_LEFT ) +#define AV_CH_BACK_RIGHT (1ULL << AV_CHAN_BACK_RIGHT ) +#define AV_CH_FRONT_LEFT_OF_CENTER (1ULL << AV_CHAN_FRONT_LEFT_OF_CENTER ) +#define AV_CH_FRONT_RIGHT_OF_CENTER (1ULL << AV_CHAN_FRONT_RIGHT_OF_CENTER) +#define AV_CH_BACK_CENTER (1ULL << AV_CHAN_BACK_CENTER ) +#define AV_CH_SIDE_LEFT (1ULL << AV_CHAN_SIDE_LEFT ) +#define AV_CH_SIDE_RIGHT (1ULL << AV_CHAN_SIDE_RIGHT ) +#define AV_CH_TOP_CENTER (1ULL << AV_CHAN_TOP_CENTER ) +#define AV_CH_TOP_FRONT_LEFT (1ULL << AV_CHAN_TOP_FRONT_LEFT ) +#define AV_CH_TOP_FRONT_CENTER (1ULL << AV_CHAN_TOP_FRONT_CENTER ) +#define AV_CH_TOP_FRONT_RIGHT (1ULL << AV_CHAN_TOP_FRONT_RIGHT ) +#define AV_CH_TOP_BACK_LEFT (1ULL << AV_CHAN_TOP_BACK_LEFT ) +#define AV_CH_TOP_BACK_CENTER (1ULL << AV_CHAN_TOP_BACK_CENTER ) +#define AV_CH_TOP_BACK_RIGHT (1ULL << AV_CHAN_TOP_BACK_RIGHT ) +#define AV_CH_STEREO_LEFT (1ULL << AV_CHAN_STEREO_LEFT ) +#define AV_CH_STEREO_RIGHT (1ULL << AV_CHAN_STEREO_RIGHT ) +#define AV_CH_WIDE_LEFT (1ULL << AV_CHAN_WIDE_LEFT ) +#define AV_CH_WIDE_RIGHT (1ULL << AV_CHAN_WIDE_RIGHT ) +#define AV_CH_SURROUND_DIRECT_LEFT (1ULL << AV_CHAN_SURROUND_DIRECT_LEFT ) +#define AV_CH_SURROUND_DIRECT_RIGHT (1ULL << AV_CHAN_SURROUND_DIRECT_RIGHT) +#define AV_CH_LOW_FREQUENCY_2 (1ULL << AV_CHAN_LOW_FREQUENCY_2 ) +#define AV_CH_TOP_SIDE_LEFT (1ULL << AV_CHAN_TOP_SIDE_LEFT ) +#define AV_CH_TOP_SIDE_RIGHT (1ULL << AV_CHAN_TOP_SIDE_RIGHT ) +#define AV_CH_BOTTOM_FRONT_CENTER (1ULL << AV_CHAN_BOTTOM_FRONT_CENTER ) +#define AV_CH_BOTTOM_FRONT_LEFT (1ULL << AV_CHAN_BOTTOM_FRONT_LEFT ) +#define AV_CH_BOTTOM_FRONT_RIGHT (1ULL << AV_CHAN_BOTTOM_FRONT_RIGHT ) +#if FF_API_OLD_CHANNEL_LAYOUT /** Channel mask value used for AVCodecContext.request_channel_layout to indicate that the user requests the channel order of the decoder output - to be the native codec channel order. */ + to be the native codec channel order. + @deprecated channel order is now indicated in a special field in + AVChannelLayout + */ #define AV_CH_LAYOUT_NATIVE 0x8000000000000000ULL +#endif /** * @} @@ -128,6 +242,149 @@ enum AVMatrixEncoding { AV_MATRIX_ENCODING_NB }; +/** + * @} + */ + +/** + * An AVChannelCustom defines a single channel within a custom order layout + * + * Unlike most structures in FFmpeg, sizeof(AVChannelCustom) is a part of the + * public ABI. + * + * No new fields may be added to it without a major version bump. + */ +typedef struct AVChannelCustom { + enum AVChannel id; + char name[16]; + void *opaque; +} AVChannelCustom; + +/** + * An AVChannelLayout holds information about the channel layout of audio data. + * + * A channel layout here is defined as a set of channels ordered in a specific + * way (unless the channel order is AV_CHANNEL_ORDER_UNSPEC, in which case an + * AVChannelLayout carries only the channel count). + * + * Unlike most structures in Libav, sizeof(AVChannelLayout) is a part of the + * public ABI and may be used by the caller. E.g. it may be allocated on stack + * or embedded in caller-defined structs. + * + * AVChannelLayout can be initialized as follows: + * - default initialization with {0}, followed by setting all used fields + * correctly; + * - by assigning one of the predefined AV_CHANNEL_LAYOUT_* initializers; + * - with a constructor function, such as av_channel_layout_default(), + * av_channel_layout_from_mask() or av_channel_layout_from_string(). + * + * The channel layout must be unitialized with av_channel_layout_uninit() + * + * Copying an AVChannelLayout via assigning is forbidden, + * av_channel_layout_copy() must be used instead (and its return value should + * be checked) + * + * No new fields may be added to it without a major version bump, except for + * new elements of the union fitting in sizeof(uint64_t). + */ +typedef struct AVChannelLayout { + /** + * Channel order used in this layout. + * This is a mandatory field. + */ + enum AVChannelOrder order; + + /** + * Number of channels in this layout. Mandatory field. + */ + int nb_channels; + + /** + * Details about which channels are present in this layout. + * For AV_CHANNEL_ORDER_UNSPEC, this field is undefined and must not be + * used. + */ + union { + /** + * This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used + * for AV_CHANNEL_ORDER_AMBISONIC to signal non-diegetic channels. + * It is a bitmask, where the position of each set bit means that the + * AVChannel with the corresponding value is present. + * + * I.e. when (mask & (1 << AV_CHAN_FOO)) is non-zero, then AV_CHAN_FOO + * is present in the layout. Otherwise it is not present. + * + * @note when a channel layout using a bitmask is constructed or + * modified manually (i.e. not using any of the av_channel_layout_* + * functions), the code doing it must ensure that the number of set bits + * is equal to nb_channels. + */ + uint64_t mask; + /** + * This member must be used when the channel order is + * AV_CHANNEL_ORDER_CUSTOM. It is a nb_channels-sized array, with each + * element signalling the presence of the AVChannel with the + * corresponding value in map[i].id. + * + * I.e. when map[i].id is equal to AV_CHAN_FOO, then AV_CH_FOO is the + * i-th channel in the audio data. + * + * When map[i].id is in the range between AV_CHAN_AMBISONIC_BASE and + * AV_CHAN_AMBISONIC_END (inclusive), the channel contains an ambisonic + * component with ACN index (as defined above) + * n = map[i].id - AV_CHAN_AMBISONIC_BASE. + * + * map[i].name may be filled with a 0-terminated string, in which case + * it will be used for the purpose of identifying the channel with the + * convenience functions below. Otherise it must be zeroed. + */ + AVChannelCustom *map; + } u; + + /** + * For some private data of the user. + */ + void *opaque; +} AVChannelLayout; + +#define AV_CHANNEL_LAYOUT_MASK(nb, m) \ + { .order = AV_CHANNEL_ORDER_NATIVE, .nb_channels = (nb), .u = { .mask = (m) }} + +#define AV_CHANNEL_LAYOUT_MONO AV_CHANNEL_LAYOUT_MASK(1, AV_CH_LAYOUT_MONO) +#define AV_CHANNEL_LAYOUT_STEREO AV_CHANNEL_LAYOUT_MASK(2, AV_CH_LAYOUT_STEREO) +#define AV_CHANNEL_LAYOUT_2POINT1 AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_2POINT1) +#define AV_CHANNEL_LAYOUT_2_1 AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_2_1) +#define AV_CHANNEL_LAYOUT_SURROUND AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_SURROUND) +#define AV_CHANNEL_LAYOUT_3POINT1 AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_3POINT1) +#define AV_CHANNEL_LAYOUT_4POINT0 AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_4POINT0) +#define AV_CHANNEL_LAYOUT_4POINT1 AV_CHANNEL_LAYOUT_MASK(5, AV_CH_LAYOUT_4POINT1) +#define AV_CHANNEL_LAYOUT_2_2 AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_2_2) +#define AV_CHANNEL_LAYOUT_QUAD AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_QUAD) +#define AV_CHANNEL_LAYOUT_5POINT0 AV_CHANNEL_LAYOUT_MASK(5, AV_CH_LAYOUT_5POINT0) +#define AV_CHANNEL_LAYOUT_5POINT1 AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_5POINT1) +#define AV_CHANNEL_LAYOUT_5POINT0_BACK AV_CHANNEL_LAYOUT_MASK(5, AV_CH_LAYOUT_5POINT0_BACK) +#define AV_CHANNEL_LAYOUT_5POINT1_BACK AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_5POINT1_BACK) +#define AV_CHANNEL_LAYOUT_6POINT0 AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_6POINT0) +#define AV_CHANNEL_LAYOUT_6POINT0_FRONT AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_6POINT0_FRONT) +#define AV_CHANNEL_LAYOUT_HEXAGONAL AV_CHANNEL_LAYOUT_MASK(6, AV_CH_LAYOUT_HEXAGONAL) +#define AV_CHANNEL_LAYOUT_6POINT1 AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_6POINT1) +#define AV_CHANNEL_LAYOUT_6POINT1_BACK AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_6POINT1_BACK) +#define AV_CHANNEL_LAYOUT_6POINT1_FRONT AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_6POINT1_FRONT) +#define AV_CHANNEL_LAYOUT_7POINT0 AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_7POINT0) +#define AV_CHANNEL_LAYOUT_7POINT0_FRONT AV_CHANNEL_LAYOUT_MASK(7, AV_CH_LAYOUT_7POINT0_FRONT) +#define AV_CHANNEL_LAYOUT_7POINT1 AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1) +#define AV_CHANNEL_LAYOUT_7POINT1_WIDE AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1_WIDE) +#define AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_7POINT1_WIDE_BACK) +#define AV_CHANNEL_LAYOUT_OCTAGONAL AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_OCTAGONAL) +#define AV_CHANNEL_LAYOUT_HEXADECAGONAL AV_CHANNEL_LAYOUT_MASK(16, AV_CH_LAYOUT_HEXADECAGONAL) +#define AV_CHANNEL_LAYOUT_STEREO_DOWNMIX AV_CHANNEL_LAYOUT_MASK(2, AV_CH_LAYOUT_STEREO_DOWNMIX) +#define AV_CHANNEL_LAYOUT_22POINT2 AV_CHANNEL_LAYOUT_MASK(24, AV_CH_LAYOUT_22POINT2) +#define AV_CHANNEL_LAYOUT_AMBISONIC_FIRST_ORDER \ + { .order = AV_CHANNEL_ORDER_AMBISONIC, .nb_channels = 4, .u = { .mask = 0 }} + +struct AVBPrint; + +#if FF_API_OLD_CHANNEL_LAYOUT /** * Return a channel layout id that matches name, or 0 if no match is found. * @@ -144,7 +401,10 @@ enum AVMatrixEncoding { * AV_CH_* macros). * * Example: "stereo+FC" = "2c+FC" = "2c+1c" = "0x7" + * + * @deprecated use av_channel_layout_from_string() */ +attribute_deprecated uint64_t av_get_channel_layout(const char *name); /** @@ -158,7 +418,9 @@ uint64_t av_get_channel_layout(const char *name); * @param[out] nb_channels number of channels * * @return 0 on success, AVERROR(EINVAL) if the parsing fails. + * @deprecated use av_channel_layout_from_string() */ +attribute_deprecated int av_get_extended_channel_layout(const char *name, uint64_t* channel_layout, int* nb_channels); /** @@ -167,23 +429,31 @@ int av_get_extended_channel_layout(const char *name, uint64_t* channel_layout, i * * @param buf put here the string containing the channel layout * @param buf_size size in bytes of the buffer + * @deprecated use av_channel_layout_describe() */ +attribute_deprecated void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout); -struct AVBPrint; /** * Append a description of a channel layout to a bprint buffer. + * @deprecated use av_channel_layout_describe() */ +attribute_deprecated void av_bprint_channel_layout(struct AVBPrint *bp, int nb_channels, uint64_t channel_layout); /** * Return the number of channels in the channel layout. + * @deprecated use AVChannelLayout.nb_channels */ +attribute_deprecated int av_get_channel_layout_nb_channels(uint64_t channel_layout); /** * Return default channel layout for a given number of channels. + * + * @deprecated use av_channel_layout_default() */ +attribute_deprecated int64_t av_get_default_channel_layout(int nb_channels); /** @@ -194,20 +464,28 @@ int64_t av_get_default_channel_layout(int nb_channels); * * @return index of channel in channel_layout on success, a negative AVERROR * on error. + * + * @deprecated use av_channel_layout_index_from_channel() */ +attribute_deprecated int av_get_channel_layout_channel_index(uint64_t channel_layout, uint64_t channel); /** * Get the channel with the given index in channel_layout. + * @deprecated use av_channel_layout_channel_from_index() */ +attribute_deprecated uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index); /** * Get the name of a given channel. * * @return channel name on success, NULL on error. + * + * @deprecated use av_channel_name() */ +attribute_deprecated const char *av_get_channel_name(uint64_t channel); /** @@ -215,7 +493,9 @@ const char *av_get_channel_name(uint64_t channel); * * @param channel a channel layout with a single channel * @return channel description on success, NULL on error + * @deprecated use av_channel_description() */ +attribute_deprecated const char *av_get_channel_description(uint64_t channel); /** @@ -226,9 +506,240 @@ const char *av_get_channel_description(uint64_t channel); * @param[out] name name of the layout * @return 0 if the layout exists, * <0 if index is beyond the limits + * @deprecated use av_channel_layout_standard() */ +attribute_deprecated int av_get_standard_channel_layout(unsigned index, uint64_t *layout, const char **name); +#endif + +/** + * Get a human readable string in an abbreviated form describing a given channel. + * This is the inverse function of @ref av_channel_from_string(). + * + * @param buf pre-allocated buffer where to put the generated string + * @param buf_size size in bytes of the buffer. + * @return amount of bytes needed to hold the output string, or a negative AVERROR + * on failure. If the returned value is bigger than buf_size, then the + * string was truncated. + */ +int av_channel_name(char *buf, size_t buf_size, enum AVChannel channel); + +/** + * bprint variant of av_channel_name(). + * + * @note the string will be appended to the bprint buffer. + */ +void av_channel_name_bprint(struct AVBPrint *bp, enum AVChannel channel_id); + +/** + * Get a human readable string describing a given channel. + * + * @param buf pre-allocated buffer where to put the generated string + * @param buf_size size in bytes of the buffer. + * @return amount of bytes needed to hold the output string, or a negative AVERROR + * on failure. If the returned value is bigger than buf_size, then the + * string was truncated. + */ +int av_channel_description(char *buf, size_t buf_size, enum AVChannel channel); + +/** + * bprint variant of av_channel_description(). + * + * @note the string will be appended to the bprint buffer. + */ +void av_channel_description_bprint(struct AVBPrint *bp, enum AVChannel channel_id); + +/** + * This is the inverse function of @ref av_channel_name(). + * + * @return the channel with the given name + * AV_CHAN_NONE when name does not identify a known channel + */ +enum AVChannel av_channel_from_string(const char *name); + +/** + * Initialize a native channel layout from a bitmask indicating which channels + * are present. + * + * @param channel_layout the layout structure to be initialized + * @param mask bitmask describing the channel layout + * + * @return 0 on success + * AVERROR(EINVAL) for invalid mask values + */ +int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask); + +/** + * Initialize a channel layout from a given string description. + * The input string can be represented by: + * - the formal channel layout name (returned by av_channel_layout_describe()) + * - single or multiple channel names (returned by av_channel_name(), eg. "FL", + * or concatenated with "+", each optionally containing a custom name after + * a "@", eg. "FL@Left+FR@Right+LFE") + * - a decimal or hexadecimal value of a native channel layout (eg. "4" or "0x4") + * - the number of channels with default layout (eg. "4c") + * - the number of unordered channels (eg. "4C" or "4 channels") + * - the ambisonic order followed by optional non-diegetic channels (eg. + * "ambisonic 2+stereo") + * + * @param channel_layout input channel layout + * @param str string describing the channel layout + * @return 0 channel layout was detected, AVERROR_INVALIDATATA otherwise + */ +int av_channel_layout_from_string(AVChannelLayout *channel_layout, + const char *str); + +/** + * Get the default channel layout for a given number of channels. + * + * @param channel_layout the layout structure to be initialized + * @param nb_channels number of channels + */ +void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels); + +/** + * Iterate over all standard channel layouts. + * + * @param opaque a pointer where libavutil will store the iteration state. Must + * point to NULL to start the iteration. + * + * @return the standard channel layout or NULL when the iteration is + * finished + */ +const AVChannelLayout *av_channel_layout_standard(void **opaque); + +/** + * Free any allocated data in the channel layout and reset the channel + * count to 0. + * + * @param channel_layout the layout structure to be uninitialized + */ +void av_channel_layout_uninit(AVChannelLayout *channel_layout); + +/** + * Make a copy of a channel layout. This differs from just assigning src to dst + * in that it allocates and copies the map for AV_CHANNEL_ORDER_CUSTOM. + * + * @note the destination channel_layout will be always uninitialized before copy. + * + * @param dst destination channel layout + * @param src source channel layout + * @return 0 on success, a negative AVERROR on error. + */ +int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src); + +/** + * Get a human-readable string describing the channel layout properties. + * The string will be in the same format that is accepted by + * @ref av_channel_layout_from_string(), allowing to rebuild the same + * channel layout, except for opaque pointers. + * + * @param channel_layout channel layout to be described + * @param buf pre-allocated buffer where to put the generated string + * @param buf_size size in bytes of the buffer. + * @return amount of bytes needed to hold the output string, or a negative AVERROR + * on failure. If the returned value is bigger than buf_size, then the + * string was truncated. + */ +int av_channel_layout_describe(const AVChannelLayout *channel_layout, + char *buf, size_t buf_size); + +/** + * bprint variant of av_channel_layout_describe(). + * + * @note the string will be appended to the bprint buffer. + * @return 0 on success, or a negative AVERROR value on failure. + */ +int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout, + struct AVBPrint *bp); + +/** + * Get the channel with the given index in a channel layout. + * + * @param channel_layout input channel layout + * @return channel with the index idx in channel_layout on success or + * AV_CHAN_NONE on failure (if idx is not valid or the channel order is + * unspecified) + */ +enum AVChannel +av_channel_layout_channel_from_index(const AVChannelLayout *channel_layout, unsigned int idx); + +/** + * Get the index of a given channel in a channel layout. In case multiple + * channels are found, only the first match will be returned. + * + * @param channel_layout input channel layout + * @return index of channel in channel_layout on success or a negative number if + * channel is not present in channel_layout. + */ +int av_channel_layout_index_from_channel(const AVChannelLayout *channel_layout, + enum AVChannel channel); + +/** + * Get the index in a channel layout of a channel described by the given string. + * In case multiple channels are found, only the first match will be returned. + * + * This function accepts channel names in the same format as + * @ref av_channel_from_string(). + * + * @param channel_layout input channel layout + * @return a channel index described by the given string, or a negative AVERROR + * value. + */ +int av_channel_layout_index_from_string(const AVChannelLayout *channel_layout, + const char *name); + +/** + * Get a channel described by the given string. + * + * This function accepts channel names in the same format as + * @ref av_channel_from_string(). + * + * @param channel_layout input channel layout + * @return a channel described by the given string in channel_layout on success + * or AV_CHAN_NONE on failure (if the string is not valid or the channel + * order is unspecified) + */ +enum AVChannel +av_channel_layout_channel_from_string(const AVChannelLayout *channel_layout, + const char *name); + +/** + * Find out what channels from a given set are present in a channel layout, + * without regard for their positions. + * + * @param channel_layout input channel layout + * @param mask a combination of AV_CH_* representing a set of channels + * @return a bitfield representing all the channels from mask that are present + * in channel_layout + */ +uint64_t av_channel_layout_subset(const AVChannelLayout *channel_layout, + uint64_t mask); + +/** + * Check whether a channel layout is valid, i.e. can possibly describe audio + * data. + * + * @param channel_layout input channel layout + * @return 1 if channel_layout is valid, 0 otherwise. + */ +int av_channel_layout_check(const AVChannelLayout *channel_layout); + +/** + * Check whether two channel layouts are semantically the same, i.e. the same + * channels are present on the same positions in both. + * + * If one of the channel layouts is AV_CHANNEL_ORDER_UNSPEC, while the other is + * not, they are considered to be unequal. If both are AV_CHANNEL_ORDER_UNSPEC, + * they are considered equal iff the channel counts are the same in both. + * + * @param chl input channel layout + * @param chl1 input channel layout + * @return 0 if chl and chl1 are equal, 1 if they are not equal. A negative + * AVERROR code if one or both are invalid. + */ +int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1); /** * @} diff --git a/media/ffvpx/libavutil/color_utils.c b/media/ffvpx/libavutil/color_utils.c index eb8bc7b5fc0d..5e221fb79832 100644 --- a/media/ffvpx/libavutil/color_utils.c +++ b/media/ffvpx/libavutil/color_utils.c @@ -21,7 +21,6 @@ #include #include -#include "common.h" #include "libavutil/color_utils.h" #include "libavutil/pixfmt.h" diff --git a/media/ffvpx/libavutil/common.h b/media/ffvpx/libavutil/common.h index aee353d3993d..fd1404be6cf3 100644 --- a/media/ffvpx/libavutil/common.h +++ b/media/ffvpx/libavutil/common.h @@ -41,14 +41,6 @@ #include "attributes.h" #include "macros.h" -#include "version.h" -#include "libavutil/avconfig.h" - -#if AV_HAVE_BIGENDIAN -# define AV_NE(be, le) (be) -#else -# define AV_NE(be, le) (le) -#endif //rounded division & shift #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) @@ -89,25 +81,6 @@ #define FFABSU(a) ((a) <= 0 ? -(unsigned)(a) : (unsigned)(a)) #define FFABS64U(a) ((a) <= 0 ? -(uint64_t)(a) : (uint64_t)(a)) -/** - * Comparator. - * For two numerical expressions x and y, gives 1 if x > y, -1 if x < y, and 0 - * if x == y. This is useful for instance in a qsort comparator callback. - * Furthermore, compilers are able to optimize this to branchless code, and - * there is no risk of overflow with signed types. - * As with many macros, this evaluates its argument multiple times, it thus - * must not have a side-effect. - */ -#define FFDIFFSIGN(x,y) (((x)>(y)) - ((x)<(y))) - -#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) -#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c) -#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) -#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) - -#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) -#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) - /* misc math functions */ #ifdef HAVE_AV_CONFIG_H @@ -405,6 +378,8 @@ static av_always_inline int64_t av_sat_sub64_c(int64_t a, int64_t b) { /** * Clip a float value into the amin-amax range. + * If a is nan or -inf amin will be returned. + * If a is +inf amax will be returned. * @param a value to clip * @param amin minimum value of the clip range * @param amax maximum value of the clip range @@ -415,13 +390,13 @@ static av_always_inline av_const float av_clipf_c(float a, float amin, float ama #if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 if (amin > amax) abort(); #endif - if (a < amin) return amin; - else if (a > amax) return amax; - else return a; + return FFMIN(FFMAX(a, amin), amax); } /** * Clip a double value into the amin-amax range. + * If a is nan or -inf amin will be returned. + * If a is +inf amax will be returned. * @param a value to clip * @param amin minimum value of the clip range * @param amax maximum value of the clip range @@ -432,9 +407,7 @@ static av_always_inline av_const double av_clipd_c(double a, double amin, double #if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 if (amin > amax) abort(); #endif - if (a < amin) return amin; - else if (a > amax) return amax; - else return a; + return FFMIN(FFMAX(a, amin), amax); } /** Compute ceil(log2(x)). @@ -475,9 +448,6 @@ static av_always_inline av_const int av_parity_c(uint32_t v) return av_popcount(v) & 1; } -#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24)) -#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24)) - /** * Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form. * diff --git a/media/ffvpx/libavutil/cpu.c b/media/ffvpx/libavutil/cpu.c index 6bd0f07a6238..0035e927a540 100644 --- a/media/ffvpx/libavutil/cpu.c +++ b/media/ffvpx/libavutil/cpu.c @@ -16,16 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include -#include - -#include "attributes.h" -#include "cpu.h" -#include "cpu_internal.h" #include "config.h" -#include "opt.h" -#include "common.h" #if HAVE_SCHED_GETAFFINITY #ifndef _GNU_SOURCE @@ -33,6 +24,17 @@ #endif #include #endif + +#include +#include +#include + +#include "attributes.h" +#include "cpu.h" +#include "cpu_internal.h" +#include "opt.h" +#include "common.h" + #if HAVE_GETPROCESSAFFINITYMASK || HAVE_WINRT #include #endif @@ -48,19 +50,23 @@ #endif static atomic_int cpu_flags = ATOMIC_VAR_INIT(-1); +static atomic_int cpu_count = ATOMIC_VAR_INIT(-1); static int get_cpu_flags(void) { - if (ARCH_MIPS) - return ff_get_cpu_flags_mips(); - if (ARCH_AARCH64) - return ff_get_cpu_flags_aarch64(); - if (ARCH_ARM) - return ff_get_cpu_flags_arm(); - if (ARCH_PPC) - return ff_get_cpu_flags_ppc(); - if (ARCH_X86) - return ff_get_cpu_flags_x86(); +#if ARCH_MIPS + return ff_get_cpu_flags_mips(); +#elif ARCH_AARCH64 + return ff_get_cpu_flags_aarch64(); +#elif ARCH_ARM + return ff_get_cpu_flags_arm(); +#elif ARCH_PPC + return ff_get_cpu_flags_ppc(); +#elif ARCH_X86 + return ff_get_cpu_flags_x86(); +#elif ARCH_LOONGARCH + return ff_get_cpu_flags_loongarch(); +#endif return 0; } @@ -102,97 +108,6 @@ int av_get_cpu_flags(void) return flags; } -void av_set_cpu_flags_mask(int mask) -{ - atomic_store_explicit(&cpu_flags, get_cpu_flags() & mask, - memory_order_relaxed); -} - -int av_parse_cpu_flags(const char *s) -{ -#define CPUFLAG_MMXEXT (AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT | AV_CPU_FLAG_CMOV) -#define CPUFLAG_3DNOW (AV_CPU_FLAG_3DNOW | AV_CPU_FLAG_MMX) -#define CPUFLAG_3DNOWEXT (AV_CPU_FLAG_3DNOWEXT | CPUFLAG_3DNOW) -#define CPUFLAG_SSE (AV_CPU_FLAG_SSE | CPUFLAG_MMXEXT) -#define CPUFLAG_SSE2 (AV_CPU_FLAG_SSE2 | CPUFLAG_SSE) -#define CPUFLAG_SSE2SLOW (AV_CPU_FLAG_SSE2SLOW | CPUFLAG_SSE2) -#define CPUFLAG_SSE3 (AV_CPU_FLAG_SSE3 | CPUFLAG_SSE2) -#define CPUFLAG_SSE3SLOW (AV_CPU_FLAG_SSE3SLOW | CPUFLAG_SSE3) -#define CPUFLAG_SSSE3 (AV_CPU_FLAG_SSSE3 | CPUFLAG_SSE3) -#define CPUFLAG_SSE4 (AV_CPU_FLAG_SSE4 | CPUFLAG_SSSE3) -#define CPUFLAG_SSE42 (AV_CPU_FLAG_SSE42 | CPUFLAG_SSE4) -#define CPUFLAG_AVX (AV_CPU_FLAG_AVX | CPUFLAG_SSE42) -#define CPUFLAG_AVXSLOW (AV_CPU_FLAG_AVXSLOW | CPUFLAG_AVX) -#define CPUFLAG_XOP (AV_CPU_FLAG_XOP | CPUFLAG_AVX) -#define CPUFLAG_FMA3 (AV_CPU_FLAG_FMA3 | CPUFLAG_AVX) -#define CPUFLAG_FMA4 (AV_CPU_FLAG_FMA4 | CPUFLAG_AVX) -#define CPUFLAG_AVX2 (AV_CPU_FLAG_AVX2 | CPUFLAG_AVX) -#define CPUFLAG_BMI2 (AV_CPU_FLAG_BMI2 | AV_CPU_FLAG_BMI1) -#define CPUFLAG_AESNI (AV_CPU_FLAG_AESNI | CPUFLAG_SSE42) -#define CPUFLAG_AVX512 (AV_CPU_FLAG_AVX512 | CPUFLAG_AVX2) - static const AVOption cpuflags_opts[] = { - { "flags" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" }, -#if ARCH_PPC - { "altivec" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ALTIVEC }, .unit = "flags" }, -#elif ARCH_X86 - { "mmx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMX }, .unit = "flags" }, - { "mmxext" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_MMXEXT }, .unit = "flags" }, - { "sse" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE }, .unit = "flags" }, - { "sse2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE2 }, .unit = "flags" }, - { "sse2slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE2SLOW }, .unit = "flags" }, - { "sse3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE3 }, .unit = "flags" }, - { "sse3slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE3SLOW }, .unit = "flags" }, - { "ssse3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSSE3 }, .unit = "flags" }, - { "atom" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ATOM }, .unit = "flags" }, - { "sse4.1" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE4 }, .unit = "flags" }, - { "sse4.2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE42 }, .unit = "flags" }, - { "avx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVX }, .unit = "flags" }, - { "avxslow" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVXSLOW }, .unit = "flags" }, - { "xop" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_XOP }, .unit = "flags" }, - { "fma3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA3 }, .unit = "flags" }, - { "fma4" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA4 }, .unit = "flags" }, - { "avx2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVX2 }, .unit = "flags" }, - { "bmi1" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_BMI1 }, .unit = "flags" }, - { "bmi2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_BMI2 }, .unit = "flags" }, - { "3dnow" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_3DNOW }, .unit = "flags" }, - { "3dnowext", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_3DNOWEXT }, .unit = "flags" }, - { "cmov", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_CMOV }, .unit = "flags" }, - { "aesni" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AESNI }, .unit = "flags" }, - { "avx512" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVX512 }, .unit = "flags" }, -#elif ARCH_ARM - { "armv5te", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV5TE }, .unit = "flags" }, - { "armv6", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV6 }, .unit = "flags" }, - { "armv6t2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV6T2 }, .unit = "flags" }, - { "vfp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP }, .unit = "flags" }, - { "vfp_vm", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP_VM }, .unit = "flags" }, - { "vfpv3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFPV3 }, .unit = "flags" }, - { "neon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON }, .unit = "flags" }, -#elif ARCH_AARCH64 - { "armv8", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV8 }, .unit = "flags" }, - { "neon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON }, .unit = "flags" }, - { "vfp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP }, .unit = "flags" }, -#elif ARCH_MIPS - { "mmi", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMI }, .unit = "flags" }, - { "msa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MSA }, .unit = "flags" }, -#endif - { NULL }, - }; - static const AVClass class = { - .class_name = "cpuflags", - .item_name = av_default_item_name, - .option = cpuflags_opts, - .version = LIBAVUTIL_VERSION_INT, - }; - - int flags = 0, ret; - const AVClass *pclass = &class; - - if ((ret = av_opt_eval_flags(&pclass, &cpuflags_opts[0], s, &flags)) < 0) - return ret; - - return flags & INT_MAX; -} - int av_parse_cpu_caps(unsigned *flags, const char *s) { static const AVOption cpuflags_opts[] = { @@ -225,6 +140,8 @@ int av_parse_cpu_caps(unsigned *flags, const char *s) { "cmov", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_CMOV }, .unit = "flags" }, { "aesni", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_AESNI }, .unit = "flags" }, { "avx512" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_AVX512 }, .unit = "flags" }, + { "avx512icl", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_AVX512ICL }, .unit = "flags" }, + { "slowgather", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SLOW_GATHER }, .unit = "flags" }, #define CPU_FLAG_P2 AV_CPU_FLAG_CMOV | AV_CPU_FLAG_MMX #define CPU_FLAG_P3 CPU_FLAG_P2 | AV_CPU_FLAG_MMX2 | AV_CPU_FLAG_SSE @@ -258,6 +175,9 @@ int av_parse_cpu_caps(unsigned *flags, const char *s) #elif ARCH_MIPS { "mmi", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMI }, .unit = "flags" }, { "msa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MSA }, .unit = "flags" }, +#elif ARCH_LOONGARCH + { "lsx", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_LSX }, .unit = "flags" }, + { "lasx", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_LASX }, .unit = "flags" }, #endif { NULL }, }; @@ -274,9 +194,10 @@ int av_parse_cpu_caps(unsigned *flags, const char *s) int av_cpu_count(void) { - static volatile int printed; + static atomic_int printed = ATOMIC_VAR_INIT(0); int nb_cpus = 1; + int count = 0; #if HAVE_WINRT SYSTEM_INFO sysinfo; #endif @@ -312,26 +233,39 @@ int av_cpu_count(void) nb_cpus = sysinfo.dwNumberOfProcessors; #endif - if (!printed) { + if (!atomic_exchange_explicit(&printed, 1, memory_order_relaxed)) av_log(NULL, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus); - printed = 1; + + count = atomic_load_explicit(&cpu_count, memory_order_relaxed); + + if (count > 0) { + nb_cpus = count; + av_log(NULL, AV_LOG_DEBUG, "overriding to %d logical cores\n", nb_cpus); } return nb_cpus; } +void av_cpu_force_count(int count) +{ + atomic_store_explicit(&cpu_count, count, memory_order_relaxed); +} + size_t av_cpu_max_align(void) { - if (ARCH_MIPS) - return ff_get_cpu_max_align_mips(); - if (ARCH_AARCH64) - return ff_get_cpu_max_align_aarch64(); - if (ARCH_ARM) - return ff_get_cpu_max_align_arm(); - if (ARCH_PPC) - return ff_get_cpu_max_align_ppc(); - if (ARCH_X86) - return ff_get_cpu_max_align_x86(); +#if ARCH_MIPS + return ff_get_cpu_max_align_mips(); +#elif ARCH_AARCH64 + return ff_get_cpu_max_align_aarch64(); +#elif ARCH_ARM + return ff_get_cpu_max_align_arm(); +#elif ARCH_PPC + return ff_get_cpu_max_align_ppc(); +#elif ARCH_X86 + return ff_get_cpu_max_align_x86(); +#elif ARCH_LOONGARCH + return ff_get_cpu_max_align_loongarch(); +#endif return 8; } diff --git a/media/ffvpx/libavutil/cpu.h b/media/ffvpx/libavutil/cpu.h index 83099dd96973..9711e574c514 100644 --- a/media/ffvpx/libavutil/cpu.h +++ b/media/ffvpx/libavutil/cpu.h @@ -23,8 +23,6 @@ #include -#include "attributes.h" - #define AV_CPU_FLAG_FORCE 0x80000000 /* force usage of selected flags (OR) */ /* lower 16 bits - CPU features */ @@ -56,6 +54,8 @@ #define AV_CPU_FLAG_BMI1 0x20000 ///< Bit Manipulation Instruction Set 1 #define AV_CPU_FLAG_BMI2 0x40000 ///< Bit Manipulation Instruction Set 2 #define AV_CPU_FLAG_AVX512 0x100000 ///< AVX-512 functions: requires OS support even if YMM/ZMM registers aren't used +#define AV_CPU_FLAG_AVX512ICL 0x200000 ///< F/CD/BW/DQ/VL/VNNI/IFMA/VBMI/VBMI2/VPOPCNTDQ/BITALG/GFNI/VAES/VPCLMULQDQ +#define AV_CPU_FLAG_SLOW_GATHER 0x2000000 ///< CPU has slow gathers. #define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard #define AV_CPU_FLAG_VSX 0x0002 ///< ISA 2.06 @@ -74,6 +74,10 @@ #define AV_CPU_FLAG_MMI (1 << 0) #define AV_CPU_FLAG_MSA (1 << 1) +//Loongarch SIMD extension. +#define AV_CPU_FLAG_LSX (1 << 0) +#define AV_CPU_FLAG_LASX (1 << 1) + /** * Return the flags which specify extensions supported by the CPU. * The returned value is affected by av_force_cpu_flags() if that was used @@ -88,25 +92,6 @@ int av_get_cpu_flags(void); */ void av_force_cpu_flags(int flags); -/** - * Set a mask on flags returned by av_get_cpu_flags(). - * This function is mainly useful for testing. - * Please use av_force_cpu_flags() and av_get_cpu_flags() instead which are more flexible - */ -attribute_deprecated void av_set_cpu_flags_mask(int mask); - -/** - * Parse CPU flags from a string. - * - * The returned flags contain the specified flags as well as related unspecified flags. - * - * This function exists only for compatibility with libav. - * Please use av_parse_cpu_caps() when possible. - * @return a combination of AV_CPU_* flags, negative on error. - */ -attribute_deprecated -int av_parse_cpu_flags(const char *s); - /** * Parse CPU caps from a string and update the given AV_CPU_* flags based on that. * @@ -119,6 +104,12 @@ int av_parse_cpu_caps(unsigned *flags, const char *s); */ int av_cpu_count(void); +/** + * Overrides cpu count detection and forces the specified count. + * Count < 1 disables forcing of specific count. + */ +void av_cpu_force_count(int count); + /** * Get the maximum data alignment that may be required by FFmpeg. * diff --git a/media/ffvpx/libavutil/cpu_internal.h b/media/ffvpx/libavutil/cpu_internal.h index 889764320b50..650d47fc9624 100644 --- a/media/ffvpx/libavutil/cpu_internal.h +++ b/media/ffvpx/libavutil/cpu_internal.h @@ -30,12 +30,15 @@ (HAVE_ ## cpuext ## suffix && ((flags) & AV_CPU_FLAG_ ## cpuext) && \ !((flags) & AV_CPU_FLAG_ ## slow_cpuext ## SLOW)) +#define CPUEXT_SUFFIX_SLOW(flags, suffix, cpuext) \ + (HAVE_ ## cpuext ## suffix && \ + ((flags) & (AV_CPU_FLAG_ ## cpuext | AV_CPU_FLAG_ ## cpuext ## SLOW))) + #define CPUEXT_SUFFIX_SLOW2(flags, suffix, cpuext, slow_cpuext) \ (HAVE_ ## cpuext ## suffix && ((flags) & AV_CPU_FLAG_ ## cpuext) && \ - ((flags) & AV_CPU_FLAG_ ## slow_cpuext ## SLOW)) + ((flags) & (AV_CPU_FLAG_ ## slow_cpuext | AV_CPU_FLAG_ ## slow_cpuext ## SLOW))) #define CPUEXT_SUFFIX_FAST(flags, suffix, cpuext) CPUEXT_SUFFIX_FAST2(flags, suffix, cpuext, cpuext) -#define CPUEXT_SUFFIX_SLOW(flags, suffix, cpuext) CPUEXT_SUFFIX_SLOW2(flags, suffix, cpuext, cpuext) #define CPUEXT(flags, cpuext) CPUEXT_SUFFIX(flags, , cpuext) #define CPUEXT_FAST(flags, cpuext) CPUEXT_SUFFIX_FAST(flags, , cpuext) @@ -46,11 +49,13 @@ int ff_get_cpu_flags_aarch64(void); int ff_get_cpu_flags_arm(void); int ff_get_cpu_flags_ppc(void); int ff_get_cpu_flags_x86(void); +int ff_get_cpu_flags_loongarch(void); size_t ff_get_cpu_max_align_mips(void); size_t ff_get_cpu_max_align_aarch64(void); size_t ff_get_cpu_max_align_arm(void); size_t ff_get_cpu_max_align_ppc(void); size_t ff_get_cpu_max_align_x86(void); +size_t ff_get_cpu_max_align_loongarch(void); #endif /* AVUTIL_CPU_INTERNAL_H */ diff --git a/media/ffvpx/libavutil/crc.c b/media/ffvpx/libavutil/crc.c index c45ea63a6221..703b56f4e0a7 100644 --- a/media/ffvpx/libavutil/crc.c +++ b/media/ffvpx/libavutil/crc.c @@ -23,8 +23,8 @@ #include "thread.h" #include "avassert.h" #include "bswap.h" -#include "common.h" #include "crc.h" +#include "error.h" #if CONFIG_HARDCODED_TABLES static const AVCRC av_crc_table[AV_CRC_MAX][257] = { diff --git a/media/ffvpx/libavutil/crc.h b/media/ffvpx/libavutil/crc.h index 47e22b4c7872..24a2e3caed0f 100644 --- a/media/ffvpx/libavutil/crc.h +++ b/media/ffvpx/libavutil/crc.h @@ -30,7 +30,6 @@ #include #include #include "attributes.h" -#include "version.h" /** * @defgroup lavu_crc32 CRC diff --git a/media/ffvpx/libavutil/dict.h b/media/ffvpx/libavutil/dict.h index 118f1f00ed20..0d1afc6c64ab 100644 --- a/media/ffvpx/libavutil/dict.h +++ b/media/ffvpx/libavutil/dict.h @@ -32,8 +32,6 @@ #include -#include "version.h" - /** * @addtogroup lavu_dict AVDictionary * @ingroup lavu_data diff --git a/media/ffvpx/libavutil/error.c b/media/ffvpx/libavutil/error.c index b96304837bb7..938a8bc00027 100644 --- a/media/ffvpx/libavutil/error.c +++ b/media/ffvpx/libavutil/error.c @@ -18,9 +18,12 @@ #undef _GNU_SOURCE #define _XOPEN_SOURCE 600 /* XSI-compliant version of strerror_r */ -#include "avutil.h" +#include +#include +#include "config.h" #include "avstring.h" -#include "common.h" +#include "error.h" +#include "macros.h" struct error_entry { int num; diff --git a/media/ffvpx/libavutil/error.h b/media/ffvpx/libavutil/error.h index 71df4da353b9..0d3269aa6da1 100644 --- a/media/ffvpx/libavutil/error.h +++ b/media/ffvpx/libavutil/error.h @@ -27,6 +27,8 @@ #include #include +#include "macros.h" + /** * @addtogroup lavu_error * diff --git a/media/ffvpx/libavutil/eval.h b/media/ffvpx/libavutil/eval.h index 068c62cdab03..57afc2d562f8 100644 --- a/media/ffvpx/libavutil/eval.h +++ b/media/ffvpx/libavutil/eval.h @@ -26,8 +26,6 @@ #ifndef AVUTIL_EVAL_H #define AVUTIL_EVAL_H -#include "avutil.h" - typedef struct AVExpr AVExpr; /** diff --git a/media/ffvpx/libavutil/fftime.h b/media/ffvpx/libavutil/fftime.h index 8f3b320e381b..dc169b064a0d 100644 --- a/media/ffvpx/libavutil/fftime.h +++ b/media/ffvpx/libavutil/fftime.h @@ -22,7 +22,6 @@ #define AVUTIL_TIME_H #include -#include /** * Get the current time in microseconds. diff --git a/media/ffvpx/libavutil/ffversion.h b/media/ffvpx/libavutil/ffversion.h index 24771fc80d17..1cbedf850db7 100644 --- a/media/ffvpx/libavutil/ffversion.h +++ b/media/ffvpx/libavutil/ffversion.h @@ -1,5 +1,5 @@ /* Automatically generated by version.sh, do not manually edit! */ #ifndef AVUTIL_FFVERSION_H #define AVUTIL_FFVERSION_H -#define FFMPEG_VERSION "n4.0.2-6-g2be51cbeea" +#define FFMPEG_VERSION "N-103120-gc8b1f2bcc4" #endif /* AVUTIL_FFVERSION_H */ diff --git a/media/ffvpx/libavutil/fifo.c b/media/ffvpx/libavutil/fifo.c index 1060aedf1351..51a5af6f396c 100644 --- a/media/ffvpx/libavutil/fifo.c +++ b/media/ffvpx/libavutil/fifo.c @@ -20,13 +20,291 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "avassert.h" -#include "common.h" -#include "fifo.h" +#include +#include -static AVFifoBuffer *fifo_alloc_common(void *buffer, size_t size) +#include "avassert.h" +#include "error.h" +#include "fifo.h" +#include "macros.h" +#include "mem.h" + +// by default the FIFO can be auto-grown to 1MB +#define AUTO_GROW_DEFAULT_BYTES (1024 * 1024) + +struct AVFifo { + uint8_t *buffer; + + size_t elem_size, nb_elems; + size_t offset_r, offset_w; + // distinguishes the ambiguous situation offset_r == offset_w + int is_empty; + + unsigned int flags; + size_t auto_grow_limit; +}; + +AVFifo *av_fifo_alloc2(size_t nb_elems, size_t elem_size, + unsigned int flags) +{ + AVFifo *f; + void *buffer = NULL; + + if (!elem_size) + return NULL; + + if (nb_elems) { + buffer = av_realloc_array(NULL, nb_elems, elem_size); + if (!buffer) + return NULL; + } + f = av_mallocz(sizeof(*f)); + if (!f) { + av_free(buffer); + return NULL; + } + f->buffer = buffer; + f->nb_elems = nb_elems; + f->elem_size = elem_size; + f->is_empty = 1; + + f->flags = flags; + f->auto_grow_limit = FFMAX(AUTO_GROW_DEFAULT_BYTES / elem_size, 1); + + return f; +} + +void av_fifo_auto_grow_limit(AVFifo *f, size_t max_elems) +{ + f->auto_grow_limit = max_elems; +} + +size_t av_fifo_elem_size(const AVFifo *f) +{ + return f->elem_size; +} + +size_t av_fifo_can_read(const AVFifo *f) +{ + if (f->offset_w <= f->offset_r && !f->is_empty) + return f->nb_elems - f->offset_r + f->offset_w; + return f->offset_w - f->offset_r; +} + +size_t av_fifo_can_write(const AVFifo *f) +{ + return f->nb_elems - av_fifo_can_read(f); +} + +int av_fifo_grow2(AVFifo *f, size_t inc) +{ + uint8_t *tmp; + + if (inc > SIZE_MAX - f->nb_elems) + return AVERROR(EINVAL); + + tmp = av_realloc_array(f->buffer, f->nb_elems + inc, f->elem_size); + if (!tmp) + return AVERROR(ENOMEM); + f->buffer = tmp; + + // move the data from the beginning of the ring buffer + // to the newly allocated space + if (f->offset_w <= f->offset_r && !f->is_empty) { + const size_t copy = FFMIN(inc, f->offset_w); + memcpy(tmp + f->nb_elems * f->elem_size, tmp, copy * f->elem_size); + if (copy < f->offset_w) { + memmove(tmp, tmp + copy * f->elem_size, + (f->offset_w - copy) * f->elem_size); + f->offset_w -= copy; + } else + f->offset_w = copy == inc ? 0 : f->nb_elems + copy; + } + + f->nb_elems += inc; + + return 0; +} + +static int fifo_check_space(AVFifo *f, size_t to_write) +{ + const size_t can_write = av_fifo_can_write(f); + const size_t need_grow = to_write > can_write ? to_write - can_write : 0; + size_t can_grow; + + if (!need_grow) + return 0; + + can_grow = f->auto_grow_limit > f->nb_elems ? + f->auto_grow_limit - f->nb_elems : 0; + if ((f->flags & AV_FIFO_FLAG_AUTO_GROW) && need_grow <= can_grow) { + // allocate a bit more than necessary, if we can + const size_t inc = (need_grow < can_grow / 2 ) ? need_grow * 2 : can_grow; + return av_fifo_grow2(f, inc); + } + + return AVERROR(ENOSPC); +} + +static int fifo_write_common(AVFifo *f, const uint8_t *buf, size_t *nb_elems, + AVFifoCB read_cb, void *opaque) +{ + size_t to_write = *nb_elems; + size_t offset_w; + int ret = 0; + + ret = fifo_check_space(f, to_write); + if (ret < 0) + return ret; + + offset_w = f->offset_w; + + while (to_write > 0) { + size_t len = FFMIN(f->nb_elems - offset_w, to_write); + uint8_t *wptr = f->buffer + offset_w * f->elem_size; + + if (read_cb) { + ret = read_cb(opaque, wptr, &len); + if (ret < 0 || len == 0) + break; + } else { + memcpy(wptr, buf, len * f->elem_size); + buf += len * f->elem_size; + } + offset_w += len; + if (offset_w >= f->nb_elems) + offset_w = 0; + to_write -= len; + } + f->offset_w = offset_w; + + if (*nb_elems != to_write) + f->is_empty = 0; + *nb_elems -= to_write; + + return ret; +} + +int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems) +{ + return fifo_write_common(f, buf, &nb_elems, NULL, NULL); +} + +int av_fifo_write_from_cb(AVFifo *f, AVFifoCB read_cb, + void *opaque, size_t *nb_elems) +{ + return fifo_write_common(f, NULL, nb_elems, read_cb, opaque); +} + +static int fifo_peek_common(const AVFifo *f, uint8_t *buf, size_t *nb_elems, + size_t offset, AVFifoCB write_cb, void *opaque) +{ + size_t to_read = *nb_elems; + size_t offset_r = f->offset_r; + size_t can_read = av_fifo_can_read(f); + int ret = 0; + + if (offset > can_read || to_read > can_read - offset) { + *nb_elems = 0; + return AVERROR(EINVAL); + } + + if (offset_r >= f->nb_elems - offset) + offset_r -= f->nb_elems - offset; + else + offset_r += offset; + + while (to_read > 0) { + size_t len = FFMIN(f->nb_elems - offset_r, to_read); + uint8_t *rptr = f->buffer + offset_r * f->elem_size; + + if (write_cb) { + ret = write_cb(opaque, rptr, &len); + if (ret < 0 || len == 0) + break; + } else { + memcpy(buf, rptr, len * f->elem_size); + buf += len * f->elem_size; + } + offset_r += len; + if (offset_r >= f->nb_elems) + offset_r = 0; + to_read -= len; + } + + *nb_elems -= to_read; + + return ret; +} + +int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems) +{ + int ret = fifo_peek_common(f, buf, &nb_elems, 0, NULL, NULL); + av_fifo_drain2(f, nb_elems); + return ret; +} + +int av_fifo_read_to_cb(AVFifo *f, AVFifoCB write_cb, + void *opaque, size_t *nb_elems) +{ + int ret = fifo_peek_common(f, NULL, nb_elems, 0, write_cb, opaque); + av_fifo_drain2(f, *nb_elems); + return ret; +} + +int av_fifo_peek(AVFifo *f, void *buf, size_t nb_elems, size_t offset) +{ + return fifo_peek_common(f, buf, &nb_elems, offset, NULL, NULL); +} + +int av_fifo_peek_to_cb(AVFifo *f, AVFifoCB write_cb, void *opaque, + size_t *nb_elems, size_t offset) +{ + return fifo_peek_common(f, NULL, nb_elems, offset, write_cb, opaque); +} + +void av_fifo_drain2(AVFifo *f, size_t size) +{ + const size_t cur_size = av_fifo_can_read(f); + + av_assert0(cur_size >= size); + if (cur_size == size) + f->is_empty = 1; + + if (f->offset_r >= f->nb_elems - size) + f->offset_r -= f->nb_elems - size; + else + f->offset_r += size; +} + +void av_fifo_reset2(AVFifo *f) +{ + f->offset_r = f->offset_w = 0; + f->is_empty = 1; +} + +void av_fifo_freep2(AVFifo **f) +{ + if (*f) { + av_freep(&(*f)->buffer); + av_freep(f); + } +} + + +#if FF_API_FIFO_OLD_API +FF_DISABLE_DEPRECATION_WARNINGS +#define OLD_FIFO_SIZE_MAX (size_t)FFMIN3(INT_MAX, UINT32_MAX, SIZE_MAX) + +AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size) { AVFifoBuffer *f; + void *buffer; + + if (nmemb > OLD_FIFO_SIZE_MAX / size) + return NULL; + + buffer = av_realloc_array(NULL, nmemb, size); if (!buffer) return NULL; f = av_mallocz(sizeof(AVFifoBuffer)); @@ -35,21 +313,14 @@ static AVFifoBuffer *fifo_alloc_common(void *buffer, size_t size) return NULL; } f->buffer = buffer; - f->end = f->buffer + size; + f->end = f->buffer + nmemb * size; av_fifo_reset(f); return f; } AVFifoBuffer *av_fifo_alloc(unsigned int size) { - void *buffer = av_malloc(size); - return fifo_alloc_common(buffer, size); -} - -AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size) -{ - void *buffer = av_malloc_array(nmemb, size); - return fifo_alloc_common(buffer, nmemb * size); + return av_fifo_alloc_array(size, 1); } void av_fifo_free(AVFifoBuffer *f) @@ -88,18 +359,35 @@ int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size) { unsigned int old_size = f->end - f->buffer; - if (old_size < new_size) { - int len = av_fifo_size(f); - AVFifoBuffer *f2 = av_fifo_alloc(new_size); + if (new_size > OLD_FIFO_SIZE_MAX) + return AVERROR(EINVAL); - if (!f2) + if (old_size < new_size) { + size_t offset_r = f->rptr - f->buffer; + size_t offset_w = f->wptr - f->buffer; + uint8_t *tmp; + + tmp = av_realloc(f->buffer, new_size); + if (!tmp) return AVERROR(ENOMEM); - av_fifo_generic_read(f, f2->buffer, len, NULL); - f2->wptr += len; - f2->wndx += len; - av_free(f->buffer); - *f = *f2; - av_free(f2); + + // move the data from the beginning of the ring buffer + // to the newly allocated space + // the second condition distinguishes full vs empty fifo + if (offset_w <= offset_r && av_fifo_size(f)) { + const size_t copy = FFMIN(new_size - old_size, offset_w); + memcpy(tmp + old_size, tmp, copy); + if (copy < offset_w) { + memmove(tmp, tmp + copy , offset_w - copy); + offset_w -= copy; + } else + offset_w = old_size + copy; + } + + f->buffer = tmp; + f->end = f->buffer + new_size; + f->rptr = f->buffer + offset_r; + f->wptr = f->buffer + offset_w; } return 0; } @@ -126,6 +414,9 @@ int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, uint32_t wndx= f->wndx; uint8_t *wptr= f->wptr; + if (size > av_fifo_space(f)) + return AVERROR(ENOSPC); + do { int len = FFMIN(f->end - wptr, size); if (func) { @@ -136,7 +427,6 @@ int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, memcpy(wptr, src, len); src = (uint8_t *)src + len; } -// Write memory barrier needed for SMP here in theory wptr += len; if (wptr >= f->end) wptr = f->buffer; @@ -152,13 +442,8 @@ int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_siz { uint8_t *rptr = f->rptr; - av_assert2(offset >= 0); - - /* - * *ndx are indexes modulo 2^32, they are intended to overflow, - * to handle *ndx greater than 4gb. - */ - av_assert2(buf_size + (unsigned)offset <= f->wndx - f->rndx); + if (offset < 0 || buf_size > av_fifo_size(f) - offset) + return AVERROR(EINVAL); if (offset >= f->end - rptr) rptr += offset - (f->end - f->buffer); @@ -189,31 +474,15 @@ int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_siz int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void *, void *, int)) { -// Read memory barrier needed for SMP here in theory - uint8_t *rptr = f->rptr; - - do { - int len = FFMIN(f->end - rptr, buf_size); - if (func) - func(dest, rptr, len); - else { - memcpy(dest, rptr, len); - dest = (uint8_t *)dest + len; - } -// memory barrier needed for SMP here in theory - rptr += len; - if (rptr >= f->end) - rptr -= f->end - f->buffer; - buf_size -= len; - } while (buf_size > 0); - - return 0; + return av_fifo_generic_peek_at(f, dest, 0, buf_size, func); } int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void *, void *, int)) { -// Read memory barrier needed for SMP here in theory + if (buf_size > av_fifo_size(f)) + return AVERROR(EINVAL); + do { int len = FFMIN(f->end - f->rptr, buf_size); if (func) @@ -222,7 +491,6 @@ int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, memcpy(dest, f->rptr, len); dest = (uint8_t *)dest + len; } -// memory barrier needed for SMP here in theory av_fifo_drain(f, len); buf_size -= len; } while (buf_size > 0); @@ -238,3 +506,5 @@ void av_fifo_drain(AVFifoBuffer *f, int size) f->rptr -= f->end - f->buffer; f->rndx += size; } +FF_ENABLE_DEPRECATION_WARNINGS +#endif diff --git a/media/ffvpx/libavutil/fifo.h b/media/ffvpx/libavutil/fifo.h index dc7bc6f0dd79..4eed364afc5f 100644 --- a/media/ffvpx/libavutil/fifo.h +++ b/media/ffvpx/libavutil/fifo.h @@ -24,10 +24,205 @@ #ifndef AVUTIL_FIFO_H #define AVUTIL_FIFO_H +#include #include -#include "avutil.h" -#include "attributes.h" +#include "attributes.h" +#include "version.h" + +typedef struct AVFifo AVFifo; + +/** + * Callback for writing or reading from a FIFO, passed to (and invoked from) the + * av_fifo_*_cb() functions. It may be invoked multiple times from a single + * av_fifo_*_cb() call and may process less data than the maximum size indicated + * by nb_elems. + * + * @param opaque the opaque pointer provided to the av_fifo_*_cb() function + * @param buf the buffer for reading or writing the data, depending on which + * av_fifo_*_cb function is called + * @param nb_elems On entry contains the maximum number of elements that can be + * read from / written into buf. On success, the callback should + * update it to contain the number of elements actually written. + * + * @return 0 on success, a negative error code on failure (will be returned from + * the invoking av_fifo_*_cb() function) + */ +typedef int AVFifoCB(void *opaque, void *buf, size_t *nb_elems); + +/** + * Automatically resize the FIFO on writes, so that the data fits. This + * automatic resizing happens up to a limit that can be modified with + * av_fifo_auto_grow_limit(). + */ +#define AV_FIFO_FLAG_AUTO_GROW (1 << 0) + +/** + * Allocate and initialize an AVFifo with a given element size. + * + * @param elems initial number of elements that can be stored in the FIFO + * @param elem_size Size in bytes of a single element. Further operations on + * the returned FIFO will implicitly use this element size. + * @param flags a combination of AV_FIFO_FLAG_* + * + * @return newly-allocated AVFifo on success, a negative error code on failure + */ +AVFifo *av_fifo_alloc2(size_t elems, size_t elem_size, + unsigned int flags); + +/** + * @return Element size for FIFO operations. This element size is set at + * FIFO allocation and remains constant during its lifetime + */ +size_t av_fifo_elem_size(const AVFifo *f); + +/** + * Set the maximum size (in elements) to which the FIFO can be resized + * automatically. Has no effect unless AV_FIFO_FLAG_AUTO_GROW is used. + */ +void av_fifo_auto_grow_limit(AVFifo *f, size_t max_elems); + +/** + * @return number of elements available for reading from the given FIFO. + */ +size_t av_fifo_can_read(const AVFifo *f); + +/** + * @return number of elements that can be written into the given FIFO. + */ +size_t av_fifo_can_write(const AVFifo *f); + +/** + * Enlarge an AVFifo. + * + * On success, the FIFO will be large enough to hold exactly + * inc + av_fifo_can_read() + av_fifo_can_write() + * elements. In case of failure, the old FIFO is kept unchanged. + * + * @param f AVFifo to resize + * @param inc number of elements to allocate for, in addition to the current + * allocated size + * @return a non-negative number on success, a negative error code on failure + */ +int av_fifo_grow2(AVFifo *f, size_t inc); + +/** + * Write data into a FIFO. + * + * In case nb_elems > av_fifo_can_write(f), nothing is written and an error + * is returned. + * + * @param f the FIFO buffer + * @param buf Data to be written. nb_elems * av_fifo_elem_size(f) bytes will be + * read from buf on success. + * @param nb_elems number of elements to write into FIFO + * + * @return a non-negative number on success, a negative error code on failure + */ +int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems); + +/** + * Write data from a user-provided callback into a FIFO. + * + * @param f the FIFO buffer + * @param read_cb Callback supplying the data to the FIFO. May be called + * multiple times. + * @param opaque opaque user data to be provided to read_cb + * @param nb_elems Should point to the maximum number of elements that can be + * written. Will be updated to contain the number of elements + * actually written. + * + * @return non-negative number on success, a negative error code on failure + */ +int av_fifo_write_from_cb(AVFifo *f, AVFifoCB read_cb, + void *opaque, size_t *nb_elems); + +/** + * Read data from a FIFO. + * + * In case nb_elems > av_fifo_can_read(f), nothing is read and an error + * is returned. + * + * @param f the FIFO buffer + * @param buf Buffer to store the data. nb_elems * av_fifo_elem_size(f) bytes + * will be written into buf on success. + * @param nb_elems number of elements to read from FIFO + * + * @return a non-negative number on success, a negative error code on failure + */ +int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems); + +/** + * Feed data from a FIFO into a user-provided callback. + * + * @param f the FIFO buffer + * @param write_cb Callback the data will be supplied to. May be called + * multiple times. + * @param opaque opaque user data to be provided to write_cb + * @param nb_elems Should point to the maximum number of elements that can be + * read. Will be updated to contain the total number of elements + * actually sent to the callback. + * + * @return non-negative number on success, a negative error code on failure + */ +int av_fifo_read_to_cb(AVFifo *f, AVFifoCB write_cb, + void *opaque, size_t *nb_elems); + +/** + * Read data from a FIFO without modifying FIFO state. + * + * Returns an error if an attempt is made to peek to nonexistent elements + * (i.e. if offset + nb_elems is larger than av_fifo_can_read(f)). + * + * @param f the FIFO buffer + * @param buf Buffer to store the data. nb_elems * av_fifo_elem_size(f) bytes + * will be written into buf. + * @param nb_elems number of elements to read from FIFO + * @param offset number of initial elements to skip. + * + * @return a non-negative number on success, a negative error code on failure + */ +int av_fifo_peek(AVFifo *f, void *buf, size_t nb_elems, size_t offset); + +/** + * Feed data from a FIFO into a user-provided callback. + * + * @param f the FIFO buffer + * @param write_cb Callback the data will be supplied to. May be called + * multiple times. + * @param opaque opaque user data to be provided to write_cb + * @param nb_elems Should point to the maximum number of elements that can be + * read. Will be updated to contain the total number of elements + * actually sent to the callback. + * @param offset number of initial elements to skip; offset + *nb_elems must not + * be larger than av_fifo_can_read(f). + * + * @return a non-negative number on success, a negative error code on failure + */ +int av_fifo_peek_to_cb(AVFifo *f, AVFifoCB write_cb, void *opaque, + size_t *nb_elems, size_t offset); + +/** + * Discard the specified amount of data from an AVFifo. + * @param size number of elements to discard, MUST NOT be larger than + * av_fifo_can_read(f) + */ +void av_fifo_drain2(AVFifo *f, size_t size); + +/* + * Empty the AVFifo. + * @param f AVFifo to reset + */ +void av_fifo_reset2(AVFifo *f); + +/** + * Free an AVFifo and reset pointer to NULL. + * @param f Pointer to an AVFifo to free. *f == NULL is allowed. + */ +void av_fifo_freep2(AVFifo **f); + + +#if FF_API_FIFO_OLD_API typedef struct AVFifoBuffer { uint8_t *buffer; uint8_t *rptr, *wptr, *end; @@ -38,7 +233,9 @@ typedef struct AVFifoBuffer { * Initialize an AVFifoBuffer. * @param size of FIFO * @return AVFifoBuffer or NULL in case of memory allocation failure + * @deprecated use av_fifo_alloc2() */ +attribute_deprecated AVFifoBuffer *av_fifo_alloc(unsigned int size); /** @@ -46,25 +243,33 @@ AVFifoBuffer *av_fifo_alloc(unsigned int size); * @param nmemb number of elements * @param size size of the single element * @return AVFifoBuffer or NULL in case of memory allocation failure + * @deprecated use av_fifo_alloc2() */ +attribute_deprecated AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size); /** * Free an AVFifoBuffer. * @param f AVFifoBuffer to free + * @deprecated use the AVFifo API with av_fifo_freep2() */ +attribute_deprecated void av_fifo_free(AVFifoBuffer *f); /** * Free an AVFifoBuffer and reset pointer to NULL. * @param f AVFifoBuffer to free + * @deprecated use the AVFifo API with av_fifo_freep2() */ +attribute_deprecated void av_fifo_freep(AVFifoBuffer **f); /** * Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied. * @param f AVFifoBuffer to reset + * @deprecated use av_fifo_reset2() with the new AVFifo-API */ +attribute_deprecated void av_fifo_reset(AVFifoBuffer *f); /** @@ -72,7 +277,9 @@ void av_fifo_reset(AVFifoBuffer *f); * amount of data you can read from it. * @param f AVFifoBuffer to read from * @return size + * @deprecated use av_fifo_can_read() with the new AVFifo-API */ +attribute_deprecated int av_fifo_size(const AVFifoBuffer *f); /** @@ -80,7 +287,9 @@ int av_fifo_size(const AVFifoBuffer *f); * amount of data you can write into it. * @param f AVFifoBuffer to write into * @return size + * @deprecated use av_fifo_can_write() with the new AVFifo-API */ +attribute_deprecated int av_fifo_space(const AVFifoBuffer *f); /** @@ -91,7 +300,13 @@ int av_fifo_space(const AVFifoBuffer *f); * @param buf_size number of bytes to read * @param func generic read function * @param dest data destination + * + * @return a non-negative number on success, a negative error code on failure + * + * @deprecated use the new AVFifo-API with av_fifo_peek() when func == NULL, + * av_fifo_peek_to_cb() otherwise */ +attribute_deprecated int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_size, void (*func)(void*, void*, int)); /** @@ -101,7 +316,13 @@ int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_siz * @param buf_size number of bytes to read * @param func generic read function * @param dest data destination + * + * @return a non-negative number on success, a negative error code on failure + * + * @deprecated use the new AVFifo-API with av_fifo_peek() when func == NULL, + * av_fifo_peek_to_cb() otherwise */ +attribute_deprecated int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int)); /** @@ -110,7 +331,13 @@ int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func) * @param buf_size number of bytes to read * @param func generic read function * @param dest data destination + * + * @return a non-negative number on success, a negative error code on failure + * + * @deprecated use the new AVFifo-API with av_fifo_read() when func == NULL, + * av_fifo_read_to_cb() otherwise */ +attribute_deprecated int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int)); /** @@ -124,8 +351,12 @@ int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func) * func must return the number of bytes written to dest_buf, or <= 0 to * indicate no more data available to write. * If func is NULL, src is interpreted as a simple byte array for source data. - * @return the number of bytes written to the FIFO + * @return the number of bytes written to the FIFO or a negative error code on failure + * + * @deprecated use the new AVFifo-API with av_fifo_write() when func == NULL, + * av_fifo_write_from_cb() otherwise */ +attribute_deprecated int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int)); /** @@ -135,7 +366,11 @@ int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void * @param f AVFifoBuffer to resize * @param size new AVFifoBuffer size in bytes * @return <0 for failure, >=0 otherwise + * + * @deprecated use the new AVFifo-API with av_fifo_grow2() to increase FIFO size, + * decreasing FIFO size is not supported */ +attribute_deprecated int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size); /** @@ -146,16 +381,24 @@ int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size); * @param f AVFifoBuffer to resize * @param additional_space the amount of space in bytes to allocate in addition to av_fifo_size() * @return <0 for failure, >=0 otherwise + * + * @deprecated use the new AVFifo-API with av_fifo_grow2(); note that unlike + * this function it adds to the allocated size, rather than to the used size */ +attribute_deprecated int av_fifo_grow(AVFifoBuffer *f, unsigned int additional_space); /** * Read and discard the specified amount of data from an AVFifoBuffer. * @param f AVFifoBuffer to read from * @param size amount of data to read in bytes + * + * @deprecated use the new AVFifo-API with av_fifo_drain2() */ +attribute_deprecated void av_fifo_drain(AVFifoBuffer *f, int size); +#if FF_API_FIFO_PEEK2 /** * Return a pointer to the data stored in a FIFO buffer at a certain offset. * The FIFO buffer is not modified. @@ -165,7 +408,9 @@ void av_fifo_drain(AVFifoBuffer *f, int size); * than the used buffer size or the returned pointer will * point outside to the buffer data. * The used buffer size can be checked with av_fifo_size(). + * @deprecated use the new AVFifo-API with av_fifo_peek() or av_fifo_peek_to_cb() */ +attribute_deprecated static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs) { uint8_t *ptr = f->rptr + offs; @@ -175,5 +420,7 @@ static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs) ptr = f->end - (f->buffer - ptr); return ptr; } +#endif +#endif #endif /* AVUTIL_FIFO_H */ diff --git a/media/ffvpx/libavutil/film_grain_params.h b/media/ffvpx/libavutil/film_grain_params.h index 7629e3a0412a..f3bd0a4a6a34 100644 --- a/media/ffvpx/libavutil/film_grain_params.h +++ b/media/ffvpx/libavutil/film_grain_params.h @@ -28,6 +28,11 @@ enum AVFilmGrainParamsType { * The union is valid when interpreted as AVFilmGrainAOMParams (codec.aom) */ AV_FILM_GRAIN_PARAMS_AV1, + + /** + * The union is valid when interpreted as AVFilmGrainH274Params (codec.h274) + */ + AV_FILM_GRAIN_PARAMS_H274, }; /** @@ -117,6 +122,89 @@ typedef struct AVFilmGrainAOMParams { int limit_output_range; } AVFilmGrainAOMParams; +/** + * This structure describes how to handle film grain synthesis for codecs using + * the ITU-T H.274 Versatile suplemental enhancement information message. + * + * @note The struct must be allocated as part of AVFilmGrainParams using + * av_film_grain_params_alloc(). Its size is not a part of the public ABI. + */ +typedef struct AVFilmGrainH274Params { + /** + * Specifies the film grain simulation mode. + * 0 = Frequency filtering, 1 = Auto-regression + */ + int model_id; + + /** + * Specifies the bit depth used for the luma component. + */ + int bit_depth_luma; + + /** + * Specifies the bit depth used for the chroma components. + */ + int bit_depth_chroma; + + enum AVColorRange color_range; + enum AVColorPrimaries color_primaries; + enum AVColorTransferCharacteristic color_trc; + enum AVColorSpace color_space; + + /** + * Specifies the blending mode used to blend the simulated film grain + * with the decoded images. + * + * 0 = Additive, 1 = Multiplicative + */ + int blending_mode_id; + + /** + * Specifies a scale factor used in the film grain characterization equations. + */ + int log2_scale_factor; + + /** + * Indicates if the modelling of film grain for a given component is present. + */ + int component_model_present[3 /* y, cb, cr */]; + + /** + * Specifies the number of intensity intervals for which a specific set of + * model values has been estimated, with a range of [1, 256]. + */ + uint16_t num_intensity_intervals[3 /* y, cb, cr */]; + + /** + * Specifies the number of model values present for each intensity interval + * in which the film grain has been modelled, with a range of [1, 6]. + */ + uint8_t num_model_values[3 /* y, cb, cr */]; + + /** + * Specifies the lower ounds of each intensity interval for whichthe set of + * model values applies for the component. + */ + uint8_t intensity_interval_lower_bound[3 /* y, cb, cr */][256 /* intensity interval */]; + + /** + * Specifies the upper bound of each intensity interval for which the set of + * model values applies for the component. + */ + uint8_t intensity_interval_upper_bound[3 /* y, cb, cr */][256 /* intensity interval */]; + + /** + * Specifies the model values for the component for each intensity interval. + * - When model_id == 0, the following applies: + * For comp_model_value[y], the range of values is [0, 2^bit_depth_luma - 1] + * For comp_model_value[cb..cr], the range of values is [0, 2^bit_depth_chroma - 1] + * - Otherwise, the following applies: + * For comp_model_value[y], the range of values is [-2^(bit_depth_luma - 1), 2^(bit_depth_luma - 1) - 1] + * For comp_model_value[cb..cr], the range of values is [-2^(bit_depth_chroma - 1), 2^(bit_depth_chroma - 1) - 1] + */ + int16_t comp_model_value[3 /* y, cb, cr */][256 /* intensity interval */][6 /* model value */]; +} AVFilmGrainH274Params; + /** * This structure describes how to handle film grain synthesis in video * for specific codecs. Must be present on every frame where film grain is @@ -133,6 +221,9 @@ typedef struct AVFilmGrainParams { /** * Seed to use for the synthesis process, if the codec allows for it. + * + * @note For H.264, this refers to `pic_offset` as defined in + * SMPTE RDD 5-2006. */ uint64_t seed; @@ -143,6 +234,7 @@ typedef struct AVFilmGrainParams { */ union { AVFilmGrainAOMParams aom; + AVFilmGrainH274Params h274; } codec; } AVFilmGrainParams; diff --git a/media/ffvpx/libavutil/fixed_dsp.c b/media/ffvpx/libavutil/fixed_dsp.c index f1b195f1840b..154f3bc2d345 100644 --- a/media/ffvpx/libavutil/fixed_dsp.c +++ b/media/ffvpx/libavutil/fixed_dsp.c @@ -45,6 +45,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "common.h" #include "fixed_dsp.h" static void vector_fmul_add_c(int *dst, const int *src0, const int *src1, const int *src2, int len){ @@ -161,8 +162,9 @@ AVFixedDSPContext * avpriv_alloc_fixed_dsp(int bit_exact) fdsp->butterflies_fixed = butterflies_fixed_c; fdsp->scalarproduct_fixed = scalarproduct_fixed_c; - if (ARCH_X86) - ff_fixed_dsp_init_x86(fdsp); +#if ARCH_X86 + ff_fixed_dsp_init_x86(fdsp); +#endif return fdsp; } diff --git a/media/ffvpx/libavutil/fixed_dsp.h b/media/ffvpx/libavutil/fixed_dsp.h index f554cb503831..fec806ff2da3 100644 --- a/media/ffvpx/libavutil/fixed_dsp.h +++ b/media/ffvpx/libavutil/fixed_dsp.h @@ -49,8 +49,8 @@ #define AVUTIL_FIXED_DSP_H #include +#include "config.h" #include "attributes.h" -#include "common.h" #include "libavcodec/mathops.h" typedef struct AVFixedDSPContext { diff --git a/media/ffvpx/libavutil/float_dsp.c b/media/ffvpx/libavutil/float_dsp.c index 6e28d71b570c..8676c8b0f8d6 100644 --- a/media/ffvpx/libavutil/float_dsp.c +++ b/media/ffvpx/libavutil/float_dsp.c @@ -150,15 +150,16 @@ av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact) fdsp->butterflies_float = butterflies_float_c; fdsp->scalarproduct_float = avpriv_scalarproduct_float_c; - if (ARCH_AARCH64) - ff_float_dsp_init_aarch64(fdsp); - if (ARCH_ARM) - ff_float_dsp_init_arm(fdsp); - if (ARCH_PPC) - ff_float_dsp_init_ppc(fdsp, bit_exact); - if (ARCH_X86) - ff_float_dsp_init_x86(fdsp); - if (ARCH_MIPS) - ff_float_dsp_init_mips(fdsp); +#if ARCH_AARCH64 + ff_float_dsp_init_aarch64(fdsp); +#elif ARCH_ARM + ff_float_dsp_init_arm(fdsp); +#elif ARCH_PPC + ff_float_dsp_init_ppc(fdsp, bit_exact); +#elif ARCH_X86 + ff_float_dsp_init_x86(fdsp); +#elif ARCH_MIPS + ff_float_dsp_init_mips(fdsp); +#endif return fdsp; } diff --git a/media/ffvpx/libavutil/frame.c b/media/ffvpx/libavutil/frame.c index 75e347bf2f0a..4c16488c66f2 100644 --- a/media/ffvpx/libavutil/frame.c +++ b/media/ffvpx/libavutil/frame.c @@ -20,6 +20,7 @@ #include "avassert.h" #include "buffer.h" #include "common.h" +#include "cpu.h" #include "dict.h" #include "frame.h" #include "imgutils.h" @@ -27,99 +28,14 @@ #include "samplefmt.h" #include "hwcontext.h" -#if FF_API_FRAME_GET_SET -MAKE_ACCESSORS(AVFrame, frame, int64_t, best_effort_timestamp) -MAKE_ACCESSORS(AVFrame, frame, int64_t, pkt_duration) -MAKE_ACCESSORS(AVFrame, frame, int64_t, pkt_pos) -MAKE_ACCESSORS(AVFrame, frame, int64_t, channel_layout) -MAKE_ACCESSORS(AVFrame, frame, int, channels) -MAKE_ACCESSORS(AVFrame, frame, int, sample_rate) -MAKE_ACCESSORS(AVFrame, frame, AVDictionary *, metadata) -MAKE_ACCESSORS(AVFrame, frame, int, decode_error_flags) -MAKE_ACCESSORS(AVFrame, frame, int, pkt_size) -MAKE_ACCESSORS(AVFrame, frame, enum AVColorSpace, colorspace) -MAKE_ACCESSORS(AVFrame, frame, enum AVColorRange, color_range) -#endif - +#if FF_API_OLD_CHANNEL_LAYOUT #define CHECK_CHANNELS_CONSISTENCY(frame) \ av_assert2(!(frame)->channel_layout || \ (frame)->channels == \ av_get_channel_layout_nb_channels((frame)->channel_layout)) - -#if FF_API_FRAME_QP -struct qp_properties { - int stride; - int type; -}; - -int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int qp_type) -{ - struct qp_properties *p; - AVFrameSideData *sd; - AVBufferRef *ref; - -FF_DISABLE_DEPRECATION_WARNINGS - av_buffer_unref(&f->qp_table_buf); - - f->qp_table_buf = buf; - f->qscale_table = buf->data; - f->qstride = stride; - f->qscale_type = qp_type; -FF_ENABLE_DEPRECATION_WARNINGS - - av_frame_remove_side_data(f, AV_FRAME_DATA_QP_TABLE_PROPERTIES); - av_frame_remove_side_data(f, AV_FRAME_DATA_QP_TABLE_DATA); - - ref = av_buffer_ref(buf); - if (!av_frame_new_side_data_from_buf(f, AV_FRAME_DATA_QP_TABLE_DATA, ref)) { - av_buffer_unref(&ref); - return AVERROR(ENOMEM); - } - - sd = av_frame_new_side_data(f, AV_FRAME_DATA_QP_TABLE_PROPERTIES, - sizeof(struct qp_properties)); - if (!sd) - return AVERROR(ENOMEM); - - p = (struct qp_properties *)sd->data; - p->stride = stride; - p->type = qp_type; - - return 0; -} - -int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type) -{ - AVBufferRef *buf = NULL; - - *stride = 0; - *type = 0; - -FF_DISABLE_DEPRECATION_WARNINGS - if (f->qp_table_buf) { - *stride = f->qstride; - *type = f->qscale_type; - buf = f->qp_table_buf; -FF_ENABLE_DEPRECATION_WARNINGS - } else { - AVFrameSideData *sd; - struct qp_properties *p; - sd = av_frame_get_side_data(f, AV_FRAME_DATA_QP_TABLE_PROPERTIES); - if (!sd) - return NULL; - p = (struct qp_properties *)sd->data; - sd = av_frame_get_side_data(f, AV_FRAME_DATA_QP_TABLE_DATA); - if (!sd) - return NULL; - *stride = p->stride; - *type = p->type; - buf = sd->buf; - } - - return buf ? buf->data : NULL; -} #endif +#if FF_API_COLORSPACE_NAME const char *av_get_colorspace_name(enum AVColorSpace val) { static const char * const name[] = { @@ -135,25 +51,18 @@ const char *av_get_colorspace_name(enum AVColorSpace val) return NULL; return name[val]; } - +#endif static void get_frame_defaults(AVFrame *frame) { - if (frame->extended_data != frame->data) - av_freep(&frame->extended_data); - memset(frame, 0, sizeof(*frame)); frame->pts = frame->pkt_dts = AV_NOPTS_VALUE; -#if FF_API_PKT_PTS -FF_DISABLE_DEPRECATION_WARNINGS - frame->pkt_pts = AV_NOPTS_VALUE; -FF_ENABLE_DEPRECATION_WARNINGS -#endif frame->best_effort_timestamp = AV_NOPTS_VALUE; frame->pkt_duration = 0; frame->pkt_pos = -1; frame->pkt_size = -1; + frame->time_base = (AVRational){ 0, 1 }; frame->key_frame = 1; frame->sample_aspect_ratio = (AVRational){ 0, 1 }; frame->format = -1; /* unknown */ @@ -189,12 +98,11 @@ static void wipe_side_data(AVFrame *frame) AVFrame *av_frame_alloc(void) { - AVFrame *frame = av_mallocz(sizeof(*frame)); + AVFrame *frame = av_malloc(sizeof(*frame)); if (!frame) return NULL; - frame->extended_data = NULL; get_frame_defaults(frame); return frame; @@ -280,18 +188,27 @@ fail: static int get_audio_buffer(AVFrame *frame, int align) { - int channels; int planar = av_sample_fmt_is_planar(frame->format); - int planes; + int channels, planes; int ret, i; - if (!frame->channels) - frame->channels = av_get_channel_layout_nb_channels(frame->channel_layout); - - channels = frame->channels; - planes = planar ? channels : 1; - - CHECK_CHANNELS_CONSISTENCY(frame); +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + if (!frame->ch_layout.nb_channels) { + if (frame->channel_layout) { + av_channel_layout_from_mask(&frame->ch_layout, frame->channel_layout); + } else { + frame->ch_layout.nb_channels = frame->channels; + frame->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + } + } + frame->channels = frame->ch_layout.nb_channels; + frame->channel_layout = frame->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ? + frame->ch_layout.u.mask : 0; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + channels = frame->ch_layout.nb_channels; + planes = planar ? channels : 1; if (!frame->linesize[0]) { ret = av_samples_get_buffer_size(&frame->linesize[0], channels, frame->nb_samples, frame->format, @@ -301,9 +218,9 @@ static int get_audio_buffer(AVFrame *frame, int align) } if (planes > AV_NUM_DATA_POINTERS) { - frame->extended_data = av_mallocz_array(planes, + frame->extended_data = av_calloc(planes, sizeof(*frame->extended_data)); - frame->extended_buf = av_mallocz_array((planes - AV_NUM_DATA_POINTERS), + frame->extended_buf = av_calloc(planes - AV_NUM_DATA_POINTERS, sizeof(*frame->extended_buf)); if (!frame->extended_data || !frame->extended_buf) { av_freep(&frame->extended_data); @@ -339,10 +256,17 @@ int av_frame_get_buffer(AVFrame *frame, int align) if (frame->format < 0) return AVERROR(EINVAL); +FF_DISABLE_DEPRECATION_WARNINGS if (frame->width > 0 && frame->height > 0) return get_video_buffer(frame, align); - else if (frame->nb_samples > 0 && (frame->channel_layout || frame->channels > 0)) + else if (frame->nb_samples > 0 && + (av_channel_layout_check(&frame->ch_layout) +#if FF_API_OLD_CHANNEL_LAYOUT + || frame->channel_layout || frame->channels > 0 +#endif + )) return get_audio_buffer(frame, align); +FF_ENABLE_DEPRECATION_WARNINGS return AVERROR(EINVAL); } @@ -365,15 +289,11 @@ static int frame_copy_props(AVFrame *dst, const AVFrame *src, int force_copy) dst->palette_has_changed = src->palette_has_changed; dst->sample_rate = src->sample_rate; dst->opaque = src->opaque; -#if FF_API_PKT_PTS -FF_DISABLE_DEPRECATION_WARNINGS - dst->pkt_pts = src->pkt_pts; -FF_ENABLE_DEPRECATION_WARNINGS -#endif dst->pkt_dts = src->pkt_dts; dst->pkt_pos = src->pkt_pos; dst->pkt_size = src->pkt_size; dst->pkt_duration = src->pkt_duration; + dst->time_base = src->time_base; dst->reordered_opaque = src->reordered_opaque; dst->quality = src->quality; dst->best_effort_timestamp = src->best_effort_timestamp; @@ -389,12 +309,6 @@ FF_ENABLE_DEPRECATION_WARNINGS av_dict_copy(&dst->metadata, src->metadata, 0); -#if FF_API_ERROR_FRAME -FF_DISABLE_DEPRECATION_WARNINGS - memcpy(dst->error, src->error, sizeof(dst->error)); -FF_ENABLE_DEPRECATION_WARNINGS -#endif - for (i = 0; i < src->nb_side_data; i++) { const AVFrameSideData *sd_src = src->side_data[i]; AVFrameSideData *sd_dst; @@ -421,20 +335,6 @@ FF_ENABLE_DEPRECATION_WARNINGS av_dict_copy(&sd_dst->metadata, sd_src->metadata, 0); } -#if FF_API_FRAME_QP -FF_DISABLE_DEPRECATION_WARNINGS - dst->qscale_table = NULL; - dst->qstride = 0; - dst->qscale_type = 0; - av_buffer_replace(&dst->qp_table_buf, src->qp_table_buf); - if (dst->qp_table_buf) { - dst->qscale_table = dst->qp_table_buf->data; - dst->qstride = src->qstride; - dst->qscale_type = src->qscale_type; - } -FF_ENABLE_DEPRECATION_WARNINGS -#endif - ret = av_buffer_replace(&dst->opaque_ref, src->opaque_ref); ret |= av_buffer_replace(&dst->private_ref, src->private_ref); return ret; @@ -445,19 +345,44 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src) int i, ret = 0; av_assert1(dst->width == 0 && dst->height == 0); +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS av_assert1(dst->channels == 0); +FF_ENABLE_DEPRECATION_WARNINGS +#endif + av_assert1(dst->ch_layout.nb_channels == 0 && + dst->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC); dst->format = src->format; dst->width = src->width; dst->height = src->height; + dst->nb_samples = src->nb_samples; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS dst->channels = src->channels; dst->channel_layout = src->channel_layout; - dst->nb_samples = src->nb_samples; + if (!av_channel_layout_check(&src->ch_layout)) { + if (src->channel_layout) + av_channel_layout_from_mask(&dst->ch_layout, src->channel_layout); + else { + dst->ch_layout.nb_channels = src->channels; + dst->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; + } + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif ret = frame_copy_props(dst, src, 0); if (ret < 0) goto fail; + // this check is needed only until FF_API_OLD_CHANNEL_LAYOUT is out + if (av_channel_layout_check(&src->ch_layout)) { + ret = av_channel_layout_copy(&dst->ch_layout, &src->ch_layout); + if (ret < 0) + goto fail; + } + /* duplicate the frame data if it's not refcounted */ if (!src->buf[0]) { ret = av_frame_get_buffer(dst, 0); @@ -468,7 +393,7 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src) if (ret < 0) goto fail; - return ret; + return 0; } /* ref the buffers */ @@ -483,8 +408,8 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src) } if (src->extended_buf) { - dst->extended_buf = av_mallocz_array(sizeof(*dst->extended_buf), - src->nb_extended_buf); + dst->extended_buf = av_calloc(src->nb_extended_buf, + sizeof(*dst->extended_buf)); if (!dst->extended_buf) { ret = AVERROR(ENOMEM); goto fail; @@ -510,13 +435,12 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src) /* duplicate extended data */ if (src->extended_data != src->data) { - int ch = src->channels; + int ch = dst->ch_layout.nb_channels; if (!ch) { ret = AVERROR(EINVAL); goto fail; } - CHECK_CHANNELS_CONSISTENCY(src); dst->extended_data = av_malloc_array(sizeof(*dst->extended_data), ch); if (!dst->extended_data) { @@ -565,29 +489,34 @@ void av_frame_unref(AVFrame *frame) av_buffer_unref(&frame->extended_buf[i]); av_freep(&frame->extended_buf); av_dict_free(&frame->metadata); -#if FF_API_FRAME_QP -FF_DISABLE_DEPRECATION_WARNINGS - av_buffer_unref(&frame->qp_table_buf); -FF_ENABLE_DEPRECATION_WARNINGS -#endif av_buffer_unref(&frame->hw_frames_ctx); av_buffer_unref(&frame->opaque_ref); av_buffer_unref(&frame->private_ref); + if (frame->extended_data != frame->data) + av_freep(&frame->extended_data); + + av_channel_layout_uninit(&frame->ch_layout); + get_frame_defaults(frame); } void av_frame_move_ref(AVFrame *dst, AVFrame *src) { av_assert1(dst->width == 0 && dst->height == 0); +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS av_assert1(dst->channels == 0); +FF_ENABLE_DEPRECATION_WARNINGS +#endif + av_assert1(dst->ch_layout.nb_channels == 0 && + dst->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC); *dst = *src; if (src->extended_data == src->data) dst->extended_data = dst->data; - memset(src, 0, sizeof(*src)); get_frame_defaults(src); } @@ -623,9 +552,18 @@ int av_frame_make_writable(AVFrame *frame) tmp.format = frame->format; tmp.width = frame->width; tmp.height = frame->height; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS tmp.channels = frame->channels; tmp.channel_layout = frame->channel_layout; +FF_ENABLE_DEPRECATION_WARNINGS +#endif tmp.nb_samples = frame->nb_samples; + ret = av_channel_layout_copy(&tmp.ch_layout, &frame->ch_layout); + if (ret < 0) { + av_frame_unref(&tmp); + return ret; + } if (frame->hw_frames_ctx) ret = av_hwframe_get_buffer(frame->hw_frames_ctx, &tmp, 0); @@ -666,10 +604,18 @@ AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int plane) int planes, i; if (frame->nb_samples) { - int channels = frame->channels; + int channels = frame->ch_layout.nb_channels; + +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + if (!channels) { + channels = frame->channels; + CHECK_CHANNELS_CONSISTENCY(frame); + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif if (!channels) return NULL; - CHECK_CHANNELS_CONSISTENCY(frame); planes = av_sample_fmt_is_planar(frame->format) ? channels : 1; } else planes = 4; @@ -725,7 +671,7 @@ AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, AVFrameSideData *av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, - buffer_size_t size) + size_t size) { AVFrameSideData *ret; AVBufferRef *buf = av_buffer_alloc(size); @@ -775,16 +721,35 @@ static int frame_copy_video(AVFrame *dst, const AVFrame *src) static int frame_copy_audio(AVFrame *dst, const AVFrame *src) { int planar = av_sample_fmt_is_planar(dst->format); - int channels = dst->channels; + int channels = dst->ch_layout.nb_channels; int planes = planar ? channels : 1; int i; - if (dst->nb_samples != src->nb_samples || - dst->channels != src->channels || - dst->channel_layout != src->channel_layout) - return AVERROR(EINVAL); +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + if (!channels || !src->ch_layout.nb_channels) { + if (dst->channels != src->channels || + dst->channel_layout != src->channel_layout) + return AVERROR(EINVAL); + CHECK_CHANNELS_CONSISTENCY(src); + } + if (!channels) { + channels = dst->channels; + planes = planar ? channels : 1; + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif - CHECK_CHANNELS_CONSISTENCY(src); + if (dst->nb_samples != src->nb_samples || +#if FF_API_OLD_CHANNEL_LAYOUT + (av_channel_layout_check(&dst->ch_layout) && + av_channel_layout_check(&src->ch_layout) && +#endif + av_channel_layout_compare(&dst->ch_layout, &src->ch_layout)) +#if FF_API_OLD_CHANNEL_LAYOUT + ) +#endif + return AVERROR(EINVAL); for (i = 0; i < planes; i++) if (!dst->extended_data[i] || !src->extended_data[i]) @@ -801,10 +766,17 @@ int av_frame_copy(AVFrame *dst, const AVFrame *src) if (dst->format != src->format || dst->format < 0) return AVERROR(EINVAL); +FF_DISABLE_DEPRECATION_WARNINGS if (dst->width > 0 && dst->height > 0) return frame_copy_video(dst, src); - else if (dst->nb_samples > 0 && dst->channels > 0) + else if (dst->nb_samples > 0 && + (av_channel_layout_check(&dst->ch_layout) +#if FF_API_OLD_CHANNEL_LAYOUT + || dst->channels > 0 +#endif + )) return frame_copy_audio(dst, src); +FF_ENABLE_DEPRECATION_WARNINGS return AVERROR(EINVAL); } @@ -843,15 +815,15 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type) case AV_FRAME_DATA_S12M_TIMECODE: return "SMPTE 12-1 timecode"; case AV_FRAME_DATA_SPHERICAL: return "Spherical Mapping"; case AV_FRAME_DATA_ICC_PROFILE: return "ICC profile"; -#if FF_API_FRAME_QP - case AV_FRAME_DATA_QP_TABLE_PROPERTIES: return "QP table properties"; - case AV_FRAME_DATA_QP_TABLE_DATA: return "QP table data"; -#endif case AV_FRAME_DATA_DYNAMIC_HDR_PLUS: return "HDR Dynamic Metadata SMPTE2094-40 (HDR10+)"; + case AV_FRAME_DATA_DYNAMIC_HDR_VIVID: return "HDR Dynamic Metadata CUVA 005.1 2021 (Vivid)"; case AV_FRAME_DATA_REGIONS_OF_INTEREST: return "Regions Of Interest"; 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_DETECTION_BBOXES: return "Bounding boxes for object detection and classification"; + case AV_FRAME_DATA_DOVI_RPU_BUFFER: return "Dolby Vision RPU Data"; + case AV_FRAME_DATA_DOVI_METADATA: return "Dolby Vision Metadata"; } return NULL; } @@ -866,7 +838,7 @@ static int calc_cropping_offsets(size_t offsets[4], const AVFrame *frame, int shift_x = (i == 1 || i == 2) ? desc->log2_chroma_w : 0; int shift_y = (i == 1 || i == 2) ? desc->log2_chroma_h : 0; - if (desc->flags & (AV_PIX_FMT_FLAG_PAL | FF_PSEUDOPAL) && i == 1) { + if (desc->flags & AV_PIX_FMT_FLAG_PAL && i == 1) { offsets[i] = 0; break; } diff --git a/media/ffvpx/libavutil/frame.h b/media/ffvpx/libavutil/frame.h index 7d1f8e293579..33fac2054cf1 100644 --- a/media/ffvpx/libavutil/frame.h +++ b/media/ffvpx/libavutil/frame.h @@ -30,6 +30,7 @@ #include "avutil.h" #include "buffer.h" +#include "channel_layout.h" #include "dict.h" #include "rational.h" #include "samplefmt.h" @@ -142,23 +143,6 @@ enum AVFrameSideDataType { */ AV_FRAME_DATA_ICC_PROFILE, -#if FF_API_FRAME_QP - /** - * Implementation-specific description of the format of AV_FRAME_QP_TABLE_DATA. - * The contents of this side data are undocumented and internal; use - * av_frame_set_qp_table() and av_frame_get_qp_table() to access this in a - * meaningful way instead. - */ - AV_FRAME_DATA_QP_TABLE_PROPERTIES, - - /** - * Raw QP table data. Its format is described by - * AV_FRAME_DATA_QP_TABLE_PROPERTIES. Use av_frame_set_qp_table() and - * av_frame_get_qp_table() to access this instead. - */ - AV_FRAME_DATA_QP_TABLE_DATA, -#endif - /** * Timecode which conforms to SMPTE ST 12-1. The data is an array of 4 uint32_t * where the first uint32_t describes how many (1-3) of the other timecodes are used. @@ -198,6 +182,33 @@ 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, + * as described by AVDetectionBBoxHeader. + */ + AV_FRAME_DATA_DETECTION_BBOXES, + + /** + * Dolby Vision RPU raw data, suitable for passing to x265 + * or other libraries. Array of uint8_t, with NAL emulation + * bytes intact. + */ + AV_FRAME_DATA_DOVI_RPU_BUFFER, + + /** + * Parsed Dolby Vision metadata, suitable for passing to a software + * implementation. The payload is the AVDOVIMetadata struct defined in + * libavutil/dovi_meta.h. + */ + AV_FRAME_DATA_DOVI_METADATA, + + /** + * HDR Vivid dynamic metadata associated with a video frame. The payload is + * an AVDynamicHDRVivid type and contains information for color + * volume transform - CUVA 005.1-2021. + */ + AV_FRAME_DATA_DYNAMIC_HDR_VIVID, }; enum AVActiveFormatDescription { @@ -220,11 +231,7 @@ enum AVActiveFormatDescription { typedef struct AVFrameSideData { enum AVFrameSideDataType type; uint8_t *data; -#if FF_API_BUFFER_SIZE_T - int size; -#else size_t size; -#endif AVDictionary *metadata; AVBufferRef *buf; } AVFrameSideData; @@ -319,21 +326,32 @@ typedef struct AVFrame { #define AV_NUM_DATA_POINTERS 8 /** * pointer to the picture/channel planes. - * This might be different from the first allocated byte + * This might be different from the first allocated byte. For video, + * it could even point to the end of the image data. + * + * All pointers in data and extended_data must point into one of the + * AVBufferRef in buf or extended_buf. * * Some decoders access areas outside 0,0 - width,height, please * see avcodec_align_dimensions2(). Some filters and swscale can read * up to 16 bytes beyond the planes, if these filters are to be used, * then 16 extra bytes must be allocated. * - * NOTE: Except for hwaccel formats, pointers not needed by the format - * MUST be set to NULL. + * NOTE: Pointers not needed by the format MUST be set to NULL. + * + * @attention In case of video, the data[] pointers can point to the + * end of image data in order to reverse line order, when used in + * combination with negative values in the linesize[] array. */ uint8_t *data[AV_NUM_DATA_POINTERS]; /** - * For video, size in bytes of each picture line. - * For audio, size in bytes of each plane. + * For video, a positive or negative value, which is typically indicating + * the size in bytes of each picture line, but it can also be: + * - the negative byte size of lines for vertical flipping + * (with data[n] pointing to the end of the data + * - a positive or negative multiple of the byte size as for accessing + * even and odd fields of a frame (possibly flipped) * * For audio, only linesize[0] may be set. For planar audio, each channel * plane must be the same size. @@ -345,6 +363,9 @@ typedef struct AVFrame { * * @note The linesize may be larger than the size of usable data -- there * may be extra padding present for performance reasons. + * + * @attention In case of video, line size values can be negative to achieve + * a vertically inverted iteration over image lines. */ int linesize[AV_NUM_DATA_POINTERS]; @@ -410,15 +431,6 @@ typedef struct AVFrame { */ int64_t pts; -#if FF_API_PKT_PTS - /** - * PTS copied from the AVPacket that was decoded to produce this frame. - * @deprecated use the pts field instead - */ - attribute_deprecated - int64_t pkt_pts; -#endif - /** * DTS copied from the AVPacket that triggered returning this frame. (if frame threading isn't used) * This is also the Presentation time of this AVFrame calculated from @@ -426,6 +438,14 @@ typedef struct AVFrame { */ int64_t pkt_dts; + /** + * Time base for the timestamps in this frame. + * In the future, this field may be set on frames output by decoders or + * filters, but its value will be by default ignored on input to encoders + * or filters. + */ + AVRational time_base; + /** * picture number in bitstream order */ @@ -445,14 +465,6 @@ typedef struct AVFrame { */ void *opaque; -#if FF_API_ERROR_FRAME - /** - * @deprecated unused - */ - attribute_deprecated - uint64_t error[AV_NUM_DATA_POINTERS]; -#endif - /** * When decoding, this signals how much the picture must be delayed. * extra_delay = repeat_pict / (2*fps) @@ -489,16 +501,20 @@ typedef struct AVFrame { */ int sample_rate; +#if FF_API_OLD_CHANNEL_LAYOUT /** * Channel layout of the audio data. + * @deprecated use ch_layout instead */ + attribute_deprecated uint64_t channel_layout; +#endif /** - * AVBuffer references backing the data for this frame. If all elements of - * this array are NULL, then this frame is not reference counted. This array - * must be filled contiguously -- if buf[i] is non-NULL then buf[j] must - * also be non-NULL for all j < i. + * AVBuffer references backing the data for this frame. All the pointers in + * data and extended_data must point inside one of the buffers in buf or + * extended_buf. This array must be filled contiguously -- if buf[i] is + * non-NULL then buf[j] must also be non-NULL for all j < i. * * There may be at most one AVBuffer per data plane, so for video this array * always contains all the references. For planar audio with more than @@ -616,12 +632,16 @@ typedef struct AVFrame { #define FF_DECODE_ERROR_CONCEALMENT_ACTIVE 4 #define FF_DECODE_ERROR_DECODE_SLICES 8 +#if FF_API_OLD_CHANNEL_LAYOUT /** * number of audio channels, only used for audio. * - encoding: unused * - decoding: Read by user. + * @deprecated use ch_layout instead */ + attribute_deprecated int channels; +#endif /** * size of the corresponding packet containing the compressed @@ -632,24 +652,6 @@ typedef struct AVFrame { */ int pkt_size; -#if FF_API_FRAME_QP - /** - * QP table - */ - attribute_deprecated - int8_t *qscale_table; - /** - * QP store stride - */ - attribute_deprecated - int qstride; - - attribute_deprecated - int qscale_type; - - attribute_deprecated - AVBufferRef *qp_table_buf; -#endif /** * For hwaccel-format frames, this should be a reference to the * AVHWFramesContext describing the frame. @@ -695,71 +697,23 @@ typedef struct AVFrame { * for the target frame's private_ref field. */ AVBufferRef *private_ref; + + /** + * Channel layout of the audio data. + */ + AVChannelLayout ch_layout; } AVFrame; -#if FF_API_FRAME_GET_SET -/** - * Accessors for some AVFrame fields. These used to be provided for ABI - * compatibility, and do not need to be used anymore. - */ -attribute_deprecated -int64_t av_frame_get_best_effort_timestamp(const AVFrame *frame); -attribute_deprecated -void av_frame_set_best_effort_timestamp(AVFrame *frame, int64_t val); -attribute_deprecated -int64_t av_frame_get_pkt_duration (const AVFrame *frame); -attribute_deprecated -void av_frame_set_pkt_duration (AVFrame *frame, int64_t val); -attribute_deprecated -int64_t av_frame_get_pkt_pos (const AVFrame *frame); -attribute_deprecated -void av_frame_set_pkt_pos (AVFrame *frame, int64_t val); -attribute_deprecated -int64_t av_frame_get_channel_layout (const AVFrame *frame); -attribute_deprecated -void av_frame_set_channel_layout (AVFrame *frame, int64_t val); -attribute_deprecated -int av_frame_get_channels (const AVFrame *frame); -attribute_deprecated -void av_frame_set_channels (AVFrame *frame, int val); -attribute_deprecated -int av_frame_get_sample_rate (const AVFrame *frame); -attribute_deprecated -void av_frame_set_sample_rate (AVFrame *frame, int val); -attribute_deprecated -AVDictionary *av_frame_get_metadata (const AVFrame *frame); -attribute_deprecated -void av_frame_set_metadata (AVFrame *frame, AVDictionary *val); -attribute_deprecated -int av_frame_get_decode_error_flags (const AVFrame *frame); -attribute_deprecated -void av_frame_set_decode_error_flags (AVFrame *frame, int val); -attribute_deprecated -int av_frame_get_pkt_size(const AVFrame *frame); -attribute_deprecated -void av_frame_set_pkt_size(AVFrame *frame, int val); -#if FF_API_FRAME_QP -attribute_deprecated -int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type); -attribute_deprecated -int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int type); -#endif -attribute_deprecated -enum AVColorSpace av_frame_get_colorspace(const AVFrame *frame); -attribute_deprecated -void av_frame_set_colorspace(AVFrame *frame, enum AVColorSpace val); -attribute_deprecated -enum AVColorRange av_frame_get_color_range(const AVFrame *frame); -attribute_deprecated -void av_frame_set_color_range(AVFrame *frame, enum AVColorRange val); -#endif +#if FF_API_COLORSPACE_NAME /** * Get the name of a colorspace. * @return a static string identifying the colorspace; can be NULL. + * @deprecated use av_color_space_name() */ +attribute_deprecated const char *av_get_colorspace_name(enum AVColorSpace val); - +#endif /** * Allocate an AVFrame and set its fields to default values. The resulting * struct must be freed using av_frame_free(). @@ -827,7 +781,7 @@ void av_frame_move_ref(AVFrame *dst, AVFrame *src); * The following fields must be set on frame before calling this function: * - format (pixel format for video, sample format for audio) * - width and height for video - * - nb_samples and channel_layout for audio + * - nb_samples and ch_layout for audio * * This function will fill AVFrame.data and AVFrame.buf arrays and, if * necessary, allocate and fill AVFrame.extended_data and AVFrame.extended_buf. @@ -917,11 +871,7 @@ AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int plane); */ AVFrameSideData *av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, -#if FF_API_BUFFER_SIZE_T - int size); -#else size_t size); -#endif /** * Add a new side data to a frame from an existing AVBufferRef diff --git a/media/ffvpx/libavutil/hwcontext.c b/media/ffvpx/libavutil/hwcontext.c index d13d0f7c9bc2..ab9ad3703ec7 100644 --- a/media/ffvpx/libavutil/hwcontext.c +++ b/media/ffvpx/libavutil/hwcontext.c @@ -18,6 +18,7 @@ #include "config.h" +#include "avassert.h" #include "buffer.h" #include "common.h" #include "hwcontext.h" @@ -308,7 +309,7 @@ static int hwframe_pool_prealloc(AVBufferRef *ref) AVFrame **frames; int i, ret = 0; - frames = av_mallocz_array(ctx->initial_pool_size, sizeof(*frames)); + frames = av_calloc(ctx->initial_pool_size, sizeof(*frames)); if (!frames) return AVERROR(ENOMEM); @@ -788,6 +789,8 @@ fail: int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags) { + AVBufferRef *orig_dst_frames = dst->hw_frames_ctx; + enum AVPixelFormat orig_dst_fmt = dst->format; AVHWFramesContext *src_frames, *dst_frames; HWMapDescriptor *hwmap; int ret; @@ -824,8 +827,10 @@ int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags) src_frames->internal->hw_type->map_from) { ret = src_frames->internal->hw_type->map_from(src_frames, dst, src, flags); - if (ret != AVERROR(ENOSYS)) + if (ret >= 0) return ret; + else if (ret != AVERROR(ENOSYS)) + goto fail; } } @@ -836,12 +841,30 @@ int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags) dst_frames->internal->hw_type->map_to) { ret = dst_frames->internal->hw_type->map_to(dst_frames, dst, src, flags); - if (ret != AVERROR(ENOSYS)) + if (ret >= 0) return ret; + else if (ret != AVERROR(ENOSYS)) + goto fail; } } return AVERROR(ENOSYS); + +fail: + // if the caller provided dst frames context, it should be preserved + // by this function + av_assert0(orig_dst_frames == NULL || + orig_dst_frames == dst->hw_frames_ctx); + + // preserve user-provided dst frame fields, but clean + // anything we might have set + dst->hw_frames_ctx = NULL; + av_frame_unref(dst); + + dst->hw_frames_ctx = orig_dst_frames; + dst->format = orig_dst_fmt; + + return ret; } int av_hwframe_ctx_create_derived(AVBufferRef **derived_frame_ctx, diff --git a/media/ffvpx/libavutil/hwcontext.h b/media/ffvpx/libavutil/hwcontext.h index 04d19d89c2b8..c18b7e1e8b31 100644 --- a/media/ffvpx/libavutil/hwcontext.h +++ b/media/ffvpx/libavutil/hwcontext.h @@ -571,6 +571,10 @@ enum { * possible with the given arguments and hwframe setup, while other return * values indicate that it failed somehow. * + * On failure, the destination frame will be left blank, except for the + * hw_frames_ctx/format fields thay may have been set by the caller - those will + * be preserved as they were. + * * @param dst Destination frame, to contain the mapping. * @param src Source frame, to be mapped. * @param flags Some combination of AV_HWFRAME_MAP_* flags. diff --git a/media/ffvpx/libavutil/hwcontext_drm.h b/media/ffvpx/libavutil/hwcontext_drm.h new file mode 100644 index 000000000000..42709f215ef9 --- /dev/null +++ b/media/ffvpx/libavutil/hwcontext_drm.h @@ -0,0 +1,169 @@ +/* + * 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 + */ + +#ifndef AVUTIL_HWCONTEXT_DRM_H +#define AVUTIL_HWCONTEXT_DRM_H + +#include +#include + +/** + * @file + * API-specific header for AV_HWDEVICE_TYPE_DRM. + * + * Internal frame allocation is not currently supported - all frames + * must be allocated by the user. Thus AVHWFramesContext is always + * NULL, though this may change if support for frame allocation is + * added in future. + */ + +enum { + /** + * The maximum number of layers/planes in a DRM frame. + */ + AV_DRM_MAX_PLANES = 4 +}; + +/** + * DRM object descriptor. + * + * Describes a single DRM object, addressing it as a PRIME file + * descriptor. + */ +typedef struct AVDRMObjectDescriptor { + /** + * DRM PRIME fd for the object. + */ + int fd; + /** + * Total size of the object. + * + * (This includes any parts not which do not contain image data.) + */ + size_t size; + /** + * Format modifier applied to the object (DRM_FORMAT_MOD_*). + * + * If the format modifier is unknown then this should be set to + * DRM_FORMAT_MOD_INVALID. + */ + uint64_t format_modifier; +} AVDRMObjectDescriptor; + +/** + * DRM plane descriptor. + * + * Describes a single plane of a layer, which is contained within + * a single object. + */ +typedef struct AVDRMPlaneDescriptor { + /** + * Index of the object containing this plane in the objects + * array of the enclosing frame descriptor. + */ + int object_index; + /** + * Offset within that object of this plane. + */ + ptrdiff_t offset; + /** + * Pitch (linesize) of this plane. + */ + ptrdiff_t pitch; +} AVDRMPlaneDescriptor; + +/** + * DRM layer descriptor. + * + * Describes a single layer within a frame. This has the structure + * defined by its format, and will contain one or more planes. + */ +typedef struct AVDRMLayerDescriptor { + /** + * Format of the layer (DRM_FORMAT_*). + */ + uint32_t format; + /** + * Number of planes in the layer. + * + * This must match the number of planes required by format. + */ + int nb_planes; + /** + * Array of planes in this layer. + */ + AVDRMPlaneDescriptor planes[AV_DRM_MAX_PLANES]; +} AVDRMLayerDescriptor; + +/** + * DRM frame descriptor. + * + * This is used as the data pointer for AV_PIX_FMT_DRM_PRIME frames. + * It is also used by user-allocated frame pools - allocating in + * AVHWFramesContext.pool must return AVBufferRefs which contain + * an object of this type. + * + * The fields of this structure should be set such it can be + * imported directly by EGL using the EGL_EXT_image_dma_buf_import + * and EGL_EXT_image_dma_buf_import_modifiers extensions. + * (Note that the exact layout of a particular format may vary between + * platforms - we only specify that the same platform should be able + * to import it.) + * + * The total number of planes must not exceed AV_DRM_MAX_PLANES, and + * the order of the planes by increasing layer index followed by + * increasing plane index must be the same as the order which would + * be used for the data pointers in the equivalent software format. + */ +typedef struct AVDRMFrameDescriptor { + /** + * Number of DRM objects making up this frame. + */ + int nb_objects; + /** + * Array of objects making up the frame. + */ + AVDRMObjectDescriptor objects[AV_DRM_MAX_PLANES]; + /** + * Number of layers in the frame. + */ + int nb_layers; + /** + * Array of layers in the frame. + */ + AVDRMLayerDescriptor layers[AV_DRM_MAX_PLANES]; +} AVDRMFrameDescriptor; + +/** + * DRM device. + * + * Allocated as AVHWDeviceContext.hwctx. + */ +typedef struct AVDRMDeviceContext { + /** + * File descriptor of DRM device. + * + * This is used as the device to create frames on, and may also be + * used in some derivation and mapping operations. + * + * If no device is required, set to -1. + */ + int fd; +} AVDRMDeviceContext; + +#endif /* AVUTIL_HWCONTEXT_DRM_H */ diff --git a/media/ffvpx/libavutil/hwcontext_vaapi.c b/media/ffvpx/libavutil/hwcontext_vaapi.c index 00c5159dd0c6..c3a98bc4b11b 100644 --- a/media/ffvpx/libavutil/hwcontext_vaapi.c +++ b/media/ffvpx/libavutil/hwcontext_vaapi.c @@ -44,9 +44,7 @@ #include "buffer.h" #include "common.h" #include "hwcontext.h" -#if CONFIG_LIBDRM #include "hwcontext_drm.h" -#endif #include "hwcontext_internal.h" #include "hwcontext_vaapi.h" #include "mem.h" @@ -81,6 +79,9 @@ typedef struct VAAPIFramesContext { unsigned int rt_format; // Whether vaDeriveImage works. int derive_works; + // Caches whether VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 is unsupported for + // surface imports. + int prime_2_import_unsupported; } VAAPIFramesContext; typedef struct VAAPIMapping { @@ -466,7 +467,7 @@ static void vaapi_buffer_free(void *opaque, uint8_t *data) } } -static AVBufferRef *vaapi_pool_alloc(void *opaque, buffer_size_t size) +static AVBufferRef *vaapi_pool_alloc(void *opaque, size_t size) { AVHWFramesContext *hwfc = opaque; VAAPIFramesContext *ctx = hwfc->internal->priv; @@ -991,6 +992,7 @@ static const struct { } vaapi_drm_format_map[] = { #ifdef DRM_FORMAT_R8 DRM_MAP(NV12, 2, DRM_FORMAT_R8, DRM_FORMAT_RG88), + DRM_MAP(NV12, 2, DRM_FORMAT_R8, DRM_FORMAT_GR88), #endif DRM_MAP(NV12, 1, DRM_FORMAT_NV12), #if defined(VA_FOURCC_P010) && defined(DRM_FORMAT_R16) @@ -1024,16 +1026,23 @@ static void vaapi_unmap_from_drm(AVHWFramesContext *dst_fc, static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, const AVFrame *src, int flags) { +#if VA_CHECK_VERSION(1, 1, 0) + VAAPIFramesContext *src_vafc = src_fc->internal->priv; + int use_prime2; +#else + int k; +#endif AVHWFramesContext *dst_fc = (AVHWFramesContext*)dst->hw_frames_ctx->data; AVVAAPIDeviceContext *dst_dev = dst_fc->device_ctx->hwctx; const AVDRMFrameDescriptor *desc; const VAAPIFormatDescriptor *format_desc; VASurfaceID surface_id; - VAStatus vas; + VAStatus vas = VA_STATUS_SUCCESS; uint32_t va_fourcc; - int err, i, j, k; + int err, i, j; +#if !VA_CHECK_VERSION(1, 1, 0) unsigned long buffer_handle; VASurfaceAttribExternalBuffers buffer_desc; VASurfaceAttrib attrs[2] = { @@ -1050,6 +1059,7 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, .value.value.p = &buffer_desc, } }; +#endif desc = (AVDRMFrameDescriptor*)src->data[0]; @@ -1085,6 +1095,119 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, format_desc = vaapi_format_from_fourcc(va_fourcc); av_assert0(format_desc); +#if VA_CHECK_VERSION(1, 1, 0) + use_prime2 = !src_vafc->prime_2_import_unsupported && + desc->objects[0].format_modifier != DRM_FORMAT_MOD_INVALID; + if (use_prime2) { + VADRMPRIMESurfaceDescriptor prime_desc; + VASurfaceAttrib prime_attrs[2] = { + { + .type = VASurfaceAttribMemoryType, + .flags = VA_SURFACE_ATTRIB_SETTABLE, + .value.type = VAGenericValueTypeInteger, + .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2, + }, + { + .type = VASurfaceAttribExternalBufferDescriptor, + .flags = VA_SURFACE_ATTRIB_SETTABLE, + .value.type = VAGenericValueTypePointer, + .value.value.p = &prime_desc, + } + }; + prime_desc.fourcc = va_fourcc; + prime_desc.width = src_fc->width; + prime_desc.height = src_fc->height; + prime_desc.num_objects = desc->nb_objects; + for (i = 0; i < desc->nb_objects; ++i) { + prime_desc.objects[i].fd = desc->objects[i].fd; + prime_desc.objects[i].size = desc->objects[i].size; + prime_desc.objects[i].drm_format_modifier = + desc->objects[i].format_modifier; + } + + prime_desc.num_layers = desc->nb_layers; + for (i = 0; i < desc->nb_layers; ++i) { + prime_desc.layers[i].drm_format = desc->layers[i].format; + prime_desc.layers[i].num_planes = desc->layers[i].nb_planes; + for (j = 0; j < desc->layers[i].nb_planes; ++j) { + prime_desc.layers[i].object_index[j] = + desc->layers[i].planes[j].object_index; + prime_desc.layers[i].offset[j] = desc->layers[i].planes[j].offset; + prime_desc.layers[i].pitch[j] = desc->layers[i].planes[j].pitch; + } + + if (format_desc->chroma_planes_swapped && + desc->layers[i].nb_planes == 3) { + FFSWAP(uint32_t, prime_desc.layers[i].pitch[1], + prime_desc.layers[i].pitch[2]); + FFSWAP(uint32_t, prime_desc.layers[i].offset[1], + prime_desc.layers[i].offset[2]); + } + } + + /* + * We can query for PRIME_2 support with vaQuerySurfaceAttributes, but that + * that needs the config_id which we don't have here . Both Intel and + * Gallium seem to do the correct error checks, so lets just try the + * PRIME_2 import first. + */ + vas = vaCreateSurfaces(dst_dev->display, format_desc->rt_format, + src->width, src->height, &surface_id, 1, + prime_attrs, FF_ARRAY_ELEMS(prime_attrs)); + if (vas != VA_STATUS_SUCCESS) + src_vafc->prime_2_import_unsupported = 1; + } + + if (!use_prime2 || vas != VA_STATUS_SUCCESS) { + int k; + unsigned long buffer_handle; + VASurfaceAttribExternalBuffers buffer_desc; + VASurfaceAttrib buffer_attrs[2] = { + { + .type = VASurfaceAttribMemoryType, + .flags = VA_SURFACE_ATTRIB_SETTABLE, + .value.type = VAGenericValueTypeInteger, + .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME, + }, + { + .type = VASurfaceAttribExternalBufferDescriptor, + .flags = VA_SURFACE_ATTRIB_SETTABLE, + .value.type = VAGenericValueTypePointer, + .value.value.p = &buffer_desc, + } + }; + + buffer_handle = desc->objects[0].fd; + buffer_desc.pixel_format = va_fourcc; + buffer_desc.width = src_fc->width; + buffer_desc.height = src_fc->height; + buffer_desc.data_size = desc->objects[0].size; + buffer_desc.buffers = &buffer_handle; + buffer_desc.num_buffers = 1; + buffer_desc.flags = 0; + + k = 0; + for (i = 0; i < desc->nb_layers; i++) { + for (j = 0; j < desc->layers[i].nb_planes; j++) { + buffer_desc.pitches[k] = desc->layers[i].planes[j].pitch; + buffer_desc.offsets[k] = desc->layers[i].planes[j].offset; + ++k; + } + } + buffer_desc.num_planes = k; + + if (format_desc->chroma_planes_swapped && + buffer_desc.num_planes == 3) { + FFSWAP(uint32_t, buffer_desc.pitches[1], buffer_desc.pitches[2]); + FFSWAP(uint32_t, buffer_desc.offsets[1], buffer_desc.offsets[2]); + } + + vas = vaCreateSurfaces(dst_dev->display, format_desc->rt_format, + src->width, src->height, + &surface_id, 1, + buffer_attrs, FF_ARRAY_ELEMS(buffer_attrs)); + } +#else buffer_handle = desc->objects[0].fd; buffer_desc.pixel_format = va_fourcc; buffer_desc.width = src_fc->width; @@ -1114,6 +1237,7 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, src->width, src->height, &surface_id, 1, attrs, FF_ARRAY_ELEMS(attrs)); +#endif if (vas != VA_STATUS_SUCCESS) { av_log(dst_fc, AV_LOG_ERROR, "Failed to create surface from DRM " "object: %d (%s).\n", vas, vaErrorStr(vas)); diff --git a/media/ffvpx/libavutil/imgutils.c b/media/ffvpx/libavutil/imgutils.c index bd1333170ace..9ab5757cf619 100644 --- a/media/ffvpx/libavutil/imgutils.c +++ b/media/ffvpx/libavutil/imgutils.c @@ -123,8 +123,7 @@ int av_image_fill_plane_sizes(size_t sizes[4], enum AVPixelFormat pix_fmt, return AVERROR(EINVAL); sizes[0] = linesizes[0] * (size_t)height; - if (desc->flags & AV_PIX_FMT_FLAG_PAL || - desc->flags & FF_PSEUDOPAL) { + if (desc->flags & AV_PIX_FMT_FLAG_PAL) { sizes[1] = 256 * 4; /* palette is stored here as 256 32 bits words */ return 0; } @@ -166,6 +165,9 @@ int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int hei ret += sizes[i]; } + if (!ptr) + return ret; + data[0] = ptr; for (i = 1; i < 4 && sizes[i]; i++) data[i] = data[i - 1] + sizes[i - 1]; @@ -250,7 +252,7 @@ int av_image_alloc(uint8_t *pointers[4], int linesizes[4], av_free(buf); return ret; } - if (desc->flags & AV_PIX_FMT_FLAG_PAL || (desc->flags & FF_PSEUDOPAL && pointers[1])) { + if (desc->flags & AV_PIX_FMT_FLAG_PAL) { avpriv_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt); if (align < 4) { av_log(NULL, AV_LOG_ERROR, "Formats with a palette require a minimum alignment of 4\n"); @@ -259,8 +261,7 @@ int av_image_alloc(uint8_t *pointers[4], int linesizes[4], } } - if ((desc->flags & AV_PIX_FMT_FLAG_PAL || - desc->flags & FF_PSEUDOPAL) && pointers[1] && + if (desc->flags & AV_PIX_FMT_FLAG_PAL && pointers[1] && pointers[1] - pointers[0] > linesizes[0] * h) { /* zero-initialize the padding before the palette */ memset(pointers[0] + linesizes[0] * h, 0, @@ -355,9 +356,9 @@ static void image_copy_plane(uint8_t *dst, ptrdiff_t dst_linesize, } } -static void image_copy_plane_uc_from(uint8_t *dst, ptrdiff_t dst_linesize, - const uint8_t *src, ptrdiff_t src_linesize, - ptrdiff_t bytewidth, int height) +void av_image_copy_plane_uc_from(uint8_t *dst, ptrdiff_t dst_linesize, + const uint8_t *src, ptrdiff_t src_linesize, + ptrdiff_t bytewidth, int height) { int ret = -1; @@ -388,8 +389,7 @@ static void image_copy(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4], if (!desc || desc->flags & AV_PIX_FMT_FLAG_HWACCEL) return; - if (desc->flags & AV_PIX_FMT_FLAG_PAL || - desc->flags & FF_PSEUDOPAL) { + if (desc->flags & AV_PIX_FMT_FLAG_PAL) { copy_plane(dst_data[0], dst_linesizes[0], src_data[0], src_linesizes[0], width, height); @@ -440,7 +440,7 @@ void av_image_copy_uc_from(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4 enum AVPixelFormat pix_fmt, int width, int height) { image_copy(dst_data, dst_linesizes, src_data, src_linesizes, pix_fmt, - width, height, image_copy_plane_uc_from); + width, height, av_image_copy_plane_uc_from); } int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4], @@ -478,10 +478,6 @@ int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, if (ret < 0) return ret; - // do not include palette for these pseudo-paletted formats - if (desc->flags & FF_PSEUDOPAL) - return FFALIGN(width, align) * height; - ret = av_image_fill_linesizes(linesize, pix_fmt, width); if (ret < 0) return ret; diff --git a/media/ffvpx/libavutil/imgutils.h b/media/ffvpx/libavutil/imgutils.h index 5eccbf0bf787..be53335568fa 100644 --- a/media/ffvpx/libavutil/imgutils.h +++ b/media/ffvpx/libavutil/imgutils.h @@ -27,8 +27,10 @@ * @{ */ -#include "avutil.h" +#include +#include #include "pixdesc.h" +#include "pixfmt.h" #include "rational.h" /** @@ -124,6 +126,24 @@ void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height); +/** + * Copy image data located in uncacheable (e.g. GPU mapped) memory. Where + * available, this function will use special functionality for reading from such + * memory, which may result in greatly improved performance compared to plain + * av_image_copy_plane(). + * + * bytewidth must be contained by both absolute values of dst_linesize + * and src_linesize, otherwise the function behavior is undefined. + * + * @note The linesize parameters have the type ptrdiff_t here, while they are + * int for av_image_copy_plane(). + * @note On x86, the linesizes currently need to be aligned to the cacheline + * size (i.e. 64) to get improved performance. + */ +void av_image_copy_plane_uc_from(uint8_t *dst, ptrdiff_t dst_linesize, + const uint8_t *src, ptrdiff_t src_linesize, + ptrdiff_t bytewidth, int height); + /** * Copy image in src_data to dst_data. * diff --git a/media/ffvpx/libavutil/integer.c b/media/ffvpx/libavutil/integer.c index 78e252fbde24..b709c6d487fe 100644 --- a/media/ffvpx/libavutil/integer.c +++ b/media/ffvpx/libavutil/integer.c @@ -25,9 +25,11 @@ * @author Michael Niedermayer */ -#include "common.h" +#include + #include "integer.h" #include "avassert.h" +#include "intmath.h" static const AVInteger zero_i; diff --git a/media/ffvpx/libavutil/integer.h b/media/ffvpx/libavutil/integer.h index 45f733c04c2b..2d9b5bb10fa7 100644 --- a/media/ffvpx/libavutil/integer.h +++ b/media/ffvpx/libavutil/integer.h @@ -29,7 +29,7 @@ #define AVUTIL_INTEGER_H #include -#include "common.h" +#include "attributes.h" #define AV_INTEGER_SIZE 8 diff --git a/media/ffvpx/libavutil/internal.h b/media/ffvpx/libavutil/internal.h index 2ed1c2abb167..b44cbaaa7bf4 100644 --- a/media/ffvpx/libavutil/internal.h +++ b/media/ffvpx/libavutil/internal.h @@ -37,14 +37,13 @@ #include #include #include +#include #include "config.h" #include "attributes.h" #include "timer.h" -#include "cpu.h" #include "dict.h" #include "macros.h" #include "pixfmt.h" -#include "version.h" #if ARCH_X86 # include "x86/emms.h" @@ -87,10 +86,6 @@ #define FF_MEMORY_POISON 0x2a -#define MAKE_ACCESSORS(str, name, type, field) \ - type av_##name##_get_##field(const str *s) { return s->field; } \ - void av_##name##_set_##field(str *s, type v) { s->field = v; } - /* Check if the hard coded offset of a struct member still matches reality. * Induce a compilation failure if not. */ @@ -100,10 +95,15 @@ #define FF_ALLOC_TYPED_ARRAY(p, nelem) (p = av_malloc_array(nelem, sizeof(*p))) -#define FF_ALLOCZ_TYPED_ARRAY(p, nelem) (p = av_mallocz_array(nelem, sizeof(*p))) +#define FF_ALLOCZ_TYPED_ARRAY(p, nelem) (p = av_calloc(nelem, sizeof(*p))) #define FF_PTR_ADD(ptr, off) ((off) ? (ptr) + (off) : (ptr)) +/** + * Access a field in a structure by its offset. + */ +#define FF_FIELD_AT(type, off, obj) (*(type *)((char *)&(obj) + (off))) + #include "libm.h" /** @@ -184,8 +184,10 @@ void avpriv_request_sample(void *avc, #pragma comment(linker, "/include:" EXTERN_PREFIX "avpriv_snprintf") #endif +#define avpriv_fopen_utf8 ff_fopen_utf8 #define avpriv_open ff_open #define avpriv_tempfile ff_tempfile + #define PTRDIFF_SPECIFIER "Id" #define SIZE_SPECIFIER "Iu" #else @@ -199,6 +201,12 @@ void avpriv_request_sample(void *avc, # define ff_dlog(ctx, ...) do { if (0) av_log(ctx, AV_LOG_DEBUG, __VA_ARGS__); } while (0) #endif +#ifdef TRACE +# define ff_tlog(ctx, ...) av_log(ctx, AV_LOG_TRACE, __VA_ARGS__) +#else +# define ff_tlog(ctx, ...) do { } while(0) +#endif + // For debuging we use signed operations so overflows can be detected (by ubsan) // For production we use unsigned so there are no undefined operations #ifdef CHECKED @@ -251,6 +259,11 @@ static av_always_inline av_const int64_t ff_rint64_clip(double a, int64_t amin, av_warn_unused_result int avpriv_open(const char *filename, int flags, ...); +/** + * Open a file using a UTF-8 filename. + */ +FILE *avpriv_fopen_utf8(const char *path, const char *mode); + /** * Wrapper to work around the lack of mkstemp() on mingw. * Also, tries to create file in /tmp first, if possible. @@ -292,20 +305,4 @@ void ff_check_pixfmt_descriptors(void); */ int avpriv_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp); -// Helper macro for AV_PIX_FMT_FLAG_PSEUDOPAL deprecation. Code inside FFmpeg -// should always use FF_PSEUDOPAL. Once the public API flag gets removed, all -// code using it is dead code. -#if FF_API_PSEUDOPAL -#define FF_PSEUDOPAL AV_PIX_FMT_FLAG_PSEUDOPAL -#else -#define FF_PSEUDOPAL 0 -#endif - -// Temporary typedef to simplify porting all AVBufferRef users to size_t -#if FF_API_BUFFER_SIZE_T -typedef int buffer_size_t; -#else -typedef size_t buffer_size_t; -#endif - #endif /* AVUTIL_INTERNAL_H */ diff --git a/media/ffvpx/libavutil/lls.c b/media/ffvpx/libavutil/lls.c index 0560b6a79caf..c1e038daf166 100644 --- a/media/ffvpx/libavutil/lls.c +++ b/media/ffvpx/libavutil/lls.c @@ -28,9 +28,8 @@ #include #include +#include "config.h" #include "attributes.h" -#include "internal.h" -#include "version.h" #include "lls.h" static void update_lls(LLSModel *m, const double *var) @@ -118,6 +117,7 @@ av_cold void avpriv_init_lls(LLSModel *m, int indep_count) m->indep_count = indep_count; m->update_lls = update_lls; m->evaluate_lls = evaluate_lls; - if (ARCH_X86) - ff_init_lls_x86(m); +#if ARCH_X86 + ff_init_lls_x86(m); +#endif } diff --git a/media/ffvpx/libavutil/lls.h b/media/ffvpx/libavutil/lls.h index 5f849206f74d..070927582219 100644 --- a/media/ffvpx/libavutil/lls.h +++ b/media/ffvpx/libavutil/lls.h @@ -25,7 +25,6 @@ #include "macros.h" #include "mem_internal.h" -#include "version.h" #define MAX_VARS 32 #define MAX_VARS_ALIGN FFALIGN(MAX_VARS+1,4) diff --git a/media/ffvpx/libavutil/log.c b/media/ffvpx/libavutil/log.c index 66defa9c424b..5948e5046763 100644 --- a/media/ffvpx/libavutil/log.c +++ b/media/ffvpx/libavutil/log.c @@ -32,9 +32,11 @@ #if HAVE_IO_H #include #endif +#include #include +#include #include -#include "avutil.h" +#include #include "bprint.h" #include "common.h" #include "internal.h" diff --git a/media/ffvpx/libavutil/log.h b/media/ffvpx/libavutil/log.h index 8edd6bbf2b8b..ab7ceabe2234 100644 --- a/media/ffvpx/libavutil/log.h +++ b/media/ffvpx/libavutil/log.h @@ -22,7 +22,6 @@ #define AVUTIL_LOG_H #include -#include "avutil.h" #include "attributes.h" #include "version.h" @@ -107,24 +106,6 @@ typedef struct AVClass { */ int parent_log_context_offset; - /** - * Return next AVOptions-enabled child or NULL - */ - void* (*child_next)(void *obj, void *prev); - -#if FF_API_CHILD_CLASS_NEXT - /** - * Return an AVClass corresponding to the next potential - * AVOptions-enabled child. - * - * The difference between child_next and this is that - * child_next iterates over _already existing_ objects, while - * child_class_next iterates over _all possible_ children. - */ - attribute_deprecated - const struct AVClass* (*child_class_next)(const struct AVClass *prev); -#endif - /** * Category used for visualization (like color) * This is only set if the category is equal for all objects using this class. @@ -144,6 +125,11 @@ typedef struct AVClass { */ int (*query_ranges)(struct AVOptionRanges **, void *obj, const char *key, int flags); + /** + * Return next AVOptions-enabled child or NULL + */ + void* (*child_next)(void *obj, void *prev); + /** * Iterate over the AVClasses corresponding to potential AVOptions-enabled * children. diff --git a/media/ffvpx/libavutil/macros.h b/media/ffvpx/libavutil/macros.h index 2007ee561987..2a7567c3ea8f 100644 --- a/media/ffvpx/libavutil/macros.h +++ b/media/ffvpx/libavutil/macros.h @@ -25,6 +25,36 @@ #ifndef AVUTIL_MACROS_H #define AVUTIL_MACROS_H +#include "libavutil/avconfig.h" + +#if AV_HAVE_BIGENDIAN +# define AV_NE(be, le) (be) +#else +# define AV_NE(be, le) (le) +#endif + +/** + * Comparator. + * For two numerical expressions x and y, gives 1 if x > y, -1 if x < y, and 0 + * if x == y. This is useful for instance in a qsort comparator callback. + * Furthermore, compilers are able to optimize this to branchless code, and + * there is no risk of overflow with signed types. + * As with many macros, this evaluates its argument multiple times, it thus + * must not have a side-effect. + */ +#define FFDIFFSIGN(x,y) (((x)>(y)) - ((x)<(y))) + +#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) +#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c) +#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) +#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) + +#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) +#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) + +#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24)) +#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24)) + /** * @addtogroup preproc_misc Preprocessor String Macros * diff --git a/media/ffvpx/libavutil/mathematics.c b/media/ffvpx/libavutil/mathematics.c index 2de2b39da089..b878317d6320 100644 --- a/media/ffvpx/libavutil/mathematics.c +++ b/media/ffvpx/libavutil/mathematics.c @@ -26,11 +26,11 @@ #include #include +#include "avutil.h" #include "mathematics.h" #include "libavutil/intmath.h" #include "libavutil/common.h" #include "avassert.h" -#include "version.h" /* Stein's binary GCD algorithm: * https://en.wikipedia.org/wiki/Binary_GCD_algorithm */ diff --git a/media/ffvpx/libavutil/mem.c b/media/ffvpx/libavutil/mem.c index cfb6d8ab8ffa..a0c9a428491f 100644 --- a/media/ffvpx/libavutil/mem.c +++ b/media/ffvpx/libavutil/mem.c @@ -31,16 +31,19 @@ #include #include #include +#include #include #if HAVE_MALLOC_H #include #endif +#include "attributes.h" #include "avassert.h" -#include "avutil.h" -#include "common.h" #include "dynarray.h" +#include "error.h" +#include "internal.h" #include "intreadwrite.h" +#include "macros.h" #include "mem.h" #ifdef MALLOC_PREFIX @@ -59,8 +62,6 @@ void free(void *ptr); #endif /* MALLOC_PREFIX */ -#include "mem_internal.h" - #define ALIGN (HAVE_AVX512 ? 64 : (HAVE_AVX ? 32 : 16)) /* NOTE: if you want to override these functions with your own @@ -68,17 +69,35 @@ void free(void *ptr); * dynamic libraries and remove -Wl,-Bsymbolic from the linker flags. * Note that this will cost performance. */ -static size_t max_alloc_size= INT_MAX; +static atomic_size_t max_alloc_size = ATOMIC_VAR_INIT(INT_MAX); void av_max_alloc(size_t max){ - max_alloc_size = max; + atomic_store_explicit(&max_alloc_size, max, memory_order_relaxed); +} + +static int size_mult(size_t a, size_t b, size_t *r) +{ + size_t t; + +#if (!defined(__INTEL_COMPILER) && AV_GCC_VERSION_AT_LEAST(5,1)) || AV_HAS_BUILTIN(__builtin_mul_overflow) + if (__builtin_mul_overflow(a, b, &t)) + return AVERROR(EINVAL); +#else + t = a * b; + /* Hack inspired from glibc: don't try the division if nelem and elsize + * are both less than sqrt(SIZE_MAX). */ + if ((a | b) >= ((size_t)1 << (sizeof(size_t) * 4)) && a && t / a != b) + return AVERROR(EINVAL); +#endif + *r = t; + return 0; } void *av_malloc(size_t size) { void *ptr = NULL; - if (size > max_alloc_size) + if (size > atomic_load_explicit(&max_alloc_size, memory_order_relaxed)) return NULL; #if HAVE_POSIX_MEMALIGN @@ -133,14 +152,20 @@ void *av_malloc(size_t size) void *av_realloc(void *ptr, size_t size) { - if (size > max_alloc_size) + void *ret; + if (size > atomic_load_explicit(&max_alloc_size, memory_order_relaxed)) return NULL; #if HAVE_ALIGNED_MALLOC - return _aligned_realloc(ptr, size + !size, ALIGN); + ret = _aligned_realloc(ptr, size + !size, ALIGN); #else - return realloc(ptr, size + !size); + ret = realloc(ptr, size + !size); #endif +#if CONFIG_MEMORY_POISONING + if (ret && !ptr) + memset(ret, FF_MEMORY_POISON, size); +#endif + return ret; } void *av_realloc_f(void *ptr, size_t nelem, size_t elsize) @@ -148,7 +173,7 @@ void *av_realloc_f(void *ptr, size_t nelem, size_t elsize) size_t size; void *r; - if (av_size_mult(elsize, nelem, &size)) { + if (size_mult(elsize, nelem, &size)) { av_free(ptr); return NULL; } @@ -182,23 +207,25 @@ int av_reallocp(void *ptr, size_t size) void *av_malloc_array(size_t nmemb, size_t size) { size_t result; - if (av_size_mult(nmemb, size, &result) < 0) + if (size_mult(nmemb, size, &result) < 0) return NULL; return av_malloc(result); } +#if FF_API_AV_MALLOCZ_ARRAY void *av_mallocz_array(size_t nmemb, size_t size) { size_t result; - if (av_size_mult(nmemb, size, &result) < 0) + if (size_mult(nmemb, size, &result) < 0) return NULL; return av_mallocz(result); } +#endif void *av_realloc_array(void *ptr, size_t nmemb, size_t size) { size_t result; - if (av_size_mult(nmemb, size, &result) < 0) + if (size_mult(nmemb, size, &result) < 0) return NULL; return av_realloc(ptr, result); } @@ -245,7 +272,7 @@ void *av_mallocz(size_t size) void *av_calloc(size_t nmemb, size_t size) { size_t result; - if (av_size_mult(nmemb, size, &result) < 0) + if (size_mult(nmemb, size, &result) < 0) return NULL; return av_mallocz(result); } @@ -477,15 +504,19 @@ void av_memcpy_backptr(uint8_t *dst, int back, int cnt) void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size) { + size_t max_size; + if (min_size <= *size) return ptr; - if (min_size > max_alloc_size) { + max_size = atomic_load_explicit(&max_alloc_size, memory_order_relaxed); + + if (min_size > max_size) { *size = 0; return NULL; } - min_size = FFMIN(max_alloc_size, FFMAX(min_size + min_size / 16 + 32, min_size)); + min_size = FFMIN(max_size, FFMAX(min_size + min_size / 16 + 32, min_size)); ptr = av_realloc(ptr, min_size); /* we could set this to the unmodified min_size but this is safer @@ -499,12 +530,45 @@ void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size) return ptr; } +static inline void fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc) +{ + size_t max_size; + void *val; + + memcpy(&val, ptr, sizeof(val)); + if (min_size <= *size) { + av_assert0(val || !min_size); + return; + } + + max_size = atomic_load_explicit(&max_alloc_size, memory_order_relaxed); + + if (min_size > max_size) { + av_freep(ptr); + *size = 0; + return; + } + min_size = FFMIN(max_size, FFMAX(min_size + min_size / 16 + 32, min_size)); + av_freep(ptr); + val = zero_realloc ? av_mallocz(min_size) : av_malloc(min_size); + memcpy(ptr, &val, sizeof(val)); + if (!val) + min_size = 0; + *size = min_size; + return; +} + void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size) { - ff_fast_malloc(ptr, size, min_size, 0); + fast_malloc(ptr, size, min_size, 0); } void av_fast_mallocz(void *ptr, unsigned int *size, size_t min_size) { - ff_fast_malloc(ptr, size, min_size, 1); + fast_malloc(ptr, size, min_size, 1); +} + +int av_size_mult(size_t a, size_t b, size_t *r) +{ + return size_mult(a, b, r); } diff --git a/media/ffvpx/libavutil/mem.h b/media/ffvpx/libavutil/mem.h index e21a1feaaeab..d91174196c9c 100644 --- a/media/ffvpx/libavutil/mem.h +++ b/media/ffvpx/libavutil/mem.h @@ -31,7 +31,6 @@ #include #include "attributes.h" -#include "error.h" #include "avutil.h" #include "version.h" @@ -238,20 +237,20 @@ av_alloc_size(1, 2) void *av_malloc_array(size_t nmemb, size_t size); * @see av_mallocz() * @see av_malloc_array() */ -av_alloc_size(1, 2) void *av_mallocz_array(size_t nmemb, size_t size); +void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib av_alloc_size(1, 2); +#if FF_API_AV_MALLOCZ_ARRAY /** - * Non-inlined equivalent of av_mallocz_array(). - * - * Created for symmetry with the calloc() C function. + * @deprecated use av_calloc() */ -void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib; +attribute_deprecated +void *av_mallocz_array(size_t nmemb, size_t size) av_malloc_attrib av_alloc_size(1, 2); +#endif /** * Allocate, reallocate, or free a block of memory. * - * If `ptr` is `NULL` and `size` > 0, allocate a new block. If `size` is - * zero, free the memory block pointed to by `ptr`. Otherwise, expand or + * If `ptr` is `NULL` and `size` > 0, allocate a new block. Otherwise, expand or * shrink that block of memory according to `size`. * * @param ptr Pointer to a memory block already allocated with @@ -260,10 +259,11 @@ void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib; * reallocated * * @return Pointer to a newly-reallocated block or `NULL` if the block - * cannot be reallocated or the function is used to free the memory block + * cannot be reallocated * * @warning Unlike av_malloc(), the returned pointer is not guaranteed to be - * correctly aligned. + * correctly aligned. The returned pointer must be freed after even + * if size is zero. * @see av_fast_realloc() * @see av_reallocp() */ @@ -311,8 +311,7 @@ void *av_realloc_f(void *ptr, size_t nelem, size_t elsize); /** * Allocate, reallocate, or free an array. * - * If `ptr` is `NULL` and `nmemb` > 0, allocate a new block. If - * `nmemb` is zero, free the memory block pointed to by `ptr`. + * If `ptr` is `NULL` and `nmemb` > 0, allocate a new block. * * @param ptr Pointer to a memory block already allocated with * av_realloc() or `NULL` @@ -320,19 +319,19 @@ void *av_realloc_f(void *ptr, size_t nelem, size_t elsize); * @param size Size of the single element of the array * * @return Pointer to a newly-reallocated block or NULL if the block - * cannot be reallocated or the function is used to free the memory block + * cannot be reallocated * * @warning Unlike av_malloc(), the allocated memory is not guaranteed to be - * correctly aligned. + * correctly aligned. The returned pointer must be freed after even if + * nmemb is zero. * @see av_reallocp_array() */ av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t size); /** - * Allocate, reallocate, or free an array through a pointer to a pointer. + * Allocate, reallocate an array through a pointer to a pointer. * - * If `*ptr` is `NULL` and `nmemb` > 0, allocate a new block. If `nmemb` is - * zero, free the memory block pointed to by `*ptr`. + * If `*ptr` is `NULL` and `nmemb` > 0, allocate a new block. * * @param[in,out] ptr Pointer to a pointer to a memory block already * allocated with av_realloc(), or a pointer to `NULL`. @@ -343,7 +342,7 @@ av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t size) * @return Zero on success, an AVERROR error code on failure * * @warning Unlike av_malloc(), the allocated memory is not guaranteed to be - * correctly aligned. + * correctly aligned. *ptr must be freed after even if nmemb is zero. */ int av_reallocp_array(void *ptr, size_t nmemb, size_t size); @@ -672,16 +671,7 @@ void *av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size, * @param[out] r Pointer to the result of the operation * @return 0 on success, AVERROR(EINVAL) on overflow */ -static inline int av_size_mult(size_t a, size_t b, size_t *r) -{ - size_t t = a * b; - /* Hack inspired from glibc: don't try the division if nelem and elsize - * are both less than sqrt(SIZE_MAX). */ - if ((a | b) >= ((size_t)1 << (sizeof(size_t) * 4)) && a && t / a != b) - return AVERROR(EINVAL); - *r = t; - return 0; -} +int av_size_mult(size_t a, size_t b, size_t *r); /** * Set the maximum size that may be allocated in one block. diff --git a/media/ffvpx/libavutil/mem_internal.h b/media/ffvpx/libavutil/mem_internal.h index ee2575c85f9c..ed846aac52f0 100644 --- a/media/ffvpx/libavutil/mem_internal.h +++ b/media/ffvpx/libavutil/mem_internal.h @@ -136,22 +136,4 @@ # define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_A(32, t, v, __VA_ARGS__,,)) #endif -static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc) -{ - void *val; - - memcpy(&val, ptr, sizeof(val)); - if (min_size <= *size) { - av_assert0(val || !min_size); - return 0; - } - min_size = FFMAX(min_size + min_size / 16 + 32, min_size); - av_freep(ptr); - val = zero_realloc ? av_mallocz(min_size) : av_malloc(min_size); - memcpy(ptr, &val, sizeof(val)); - if (!val) - min_size = 0; - *size = min_size; - return 1; -} #endif /* AVUTIL_MEM_INTERNAL_H */ diff --git a/media/ffvpx/libavutil/moz.build b/media/ffvpx/libavutil/moz.build index 671f6aaabaea..fc0396c3ef73 100644 --- a/media/ffvpx/libavutil/moz.build +++ b/media/ffvpx/libavutil/moz.build @@ -11,11 +11,13 @@ if CONFIG['FFVPX_ASFLAGS']: DIRS += ['x86'] elif CONFIG['CPU_ARCH'] == 'arm': DIRS += ['arm'] - elif CONFIG['CPU_ARCH'] == 'aarch64': - DIRS += ['aarch64'] + +if CONFIG['CPU_ARCH'] == 'aarch64': + DIRS += ['aarch64'] SharedLibrary('mozavutil') SOURCES += [ + 'avsscanf.c', 'avstring.c', 'bprint.c', 'buffer.c', @@ -45,6 +47,7 @@ SOURCES += [ 'time.c', 'utils.c' ] + if not CONFIG['MOZ_FFVPX_AUDIOONLY']: SOURCES += [ 'adler32.c', diff --git a/media/ffvpx/libavutil/opt.c b/media/ffvpx/libavutil/opt.c index 590146b5fbb9..8ffb10449bd1 100644 --- a/media/ffvpx/libavutil/opt.c +++ b/media/ffvpx/libavutil/opt.c @@ -39,6 +39,7 @@ #include "opt.h" #include "samplefmt.h" #include "bprint.h" +#include "version.h" #include @@ -71,7 +72,11 @@ static int read_number(const AVOption *o, const void *dst, double *num, int *den case AV_OPT_TYPE_INT: *intnum = *(int *)dst; return 0; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS case AV_OPT_TYPE_CHANNEL_LAYOUT: +FF_ENABLE_DEPRECATION_WARNINGS +#endif case AV_OPT_TYPE_DURATION: case AV_OPT_TYPE_INT64: case AV_OPT_TYPE_UINT64: @@ -126,7 +131,11 @@ static int write_number(void *obj, const AVOption *o, void *dst, double num, int *(int *)dst = llrint(num / den) * intnum; break; case AV_OPT_TYPE_DURATION: +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS case AV_OPT_TYPE_CHANNEL_LAYOUT: +FF_ENABLE_DEPRECATION_WARNINGS +#endif case AV_OPT_TYPE_INT64:{ double d = num / den; if (intnum == 1 && d == (double)INT64_MAX) { @@ -262,9 +271,12 @@ static int set_string_number(void *obj, void *target_obj, const AVOption *o, con const char * const_names[64]; int search_flags = (o->flags & AV_OPT_FLAG_CHILD_CONSTS) ? AV_OPT_SEARCH_CHILDREN : 0; const AVOption *o_named = av_opt_find(target_obj, i ? buf : val, o->unit, 0, search_flags); - if (o_named && o_named->type == AV_OPT_TYPE_CONST) + if (o_named && o_named->type == AV_OPT_TYPE_CONST) { d = DEFAULT_NUMVAL(o_named); - else { + if (o_named->flags & AV_OPT_FLAG_DEPRECATED) + av_log(obj, AV_LOG_WARNING, "The \"%s\" option is deprecated: %s\n", + o_named->name, o_named->help); + } else { if (o->unit) { for (o_named = NULL; o_named = av_opt_next(target_obj, o_named); ) { if (o_named->type == AV_OPT_TYPE_CONST && @@ -462,6 +474,16 @@ static int set_string_dict(void *obj, const AVOption *o, const char *val, uint8_ return 0; } +static int set_string_channel_layout(void *obj, const AVOption *o, + const char *val, void *dst) +{ + AVChannelLayout *channel_layout = dst; + av_channel_layout_uninit(channel_layout); + if (!val) + return 0; + return av_channel_layout_from_string(channel_layout, val); +} + int av_opt_set(void *obj, const char *name, const char *val, int search_flags) { int ret = 0; @@ -469,12 +491,17 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags) const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); if (!o || !target_obj) return AVERROR_OPTION_NOT_FOUND; +FF_DISABLE_DEPRECATION_WARNINGS if (!val && (o->type != AV_OPT_TYPE_STRING && o->type != AV_OPT_TYPE_PIXEL_FMT && o->type != AV_OPT_TYPE_SAMPLE_FMT && o->type != AV_OPT_TYPE_IMAGE_SIZE && o->type != AV_OPT_TYPE_DURATION && o->type != AV_OPT_TYPE_COLOR && - o->type != AV_OPT_TYPE_CHANNEL_LAYOUT && o->type != AV_OPT_TYPE_BOOL)) +#if FF_API_OLD_CHANNEL_LAYOUT + o->type != AV_OPT_TYPE_CHANNEL_LAYOUT && +#endif + o->type != AV_OPT_TYPE_BOOL)) return AVERROR(EINVAL); +FF_ENABLE_DEPRECATION_WARNINGS if (o->flags & AV_OPT_FLAG_READONLY) return AVERROR(EINVAL); @@ -530,6 +557,8 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags) } case AV_OPT_TYPE_COLOR: return set_string_color(obj, o, val, dst); +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS case AV_OPT_TYPE_CHANNEL_LAYOUT: if (!val || !strcmp(val, "none")) { *(int64_t *)dst = 0; @@ -543,6 +572,15 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags) return ret; } break; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + case AV_OPT_TYPE_CHLAYOUT: + ret = set_string_channel_layout(obj, o, val, dst); + if (ret < 0) { + av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as channel layout\n", val); + ret = AVERROR(EINVAL); + } + return ret; case AV_OPT_TYPE_DICT: return set_string_dict(obj, o, val, dst); } @@ -706,6 +744,8 @@ int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, return set_format(obj, name, fmt, search_flags, AV_OPT_TYPE_SAMPLE_FMT, "sample", AV_SAMPLE_FMT_NB); } +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS int av_opt_set_channel_layout(void *obj, const char *name, int64_t cl, int search_flags) { void *target_obj; @@ -721,6 +761,8 @@ int av_opt_set_channel_layout(void *obj, const char *name, int64_t cl, int searc *(int64_t *)(((uint8_t *)target_obj) + o->offset) = cl; return 0; } +FF_ENABLE_DEPRECATION_WARNINGS +#endif int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags) @@ -741,6 +783,22 @@ int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, return 0; } +int av_opt_set_chlayout(void *obj, const char *name, + const AVChannelLayout *channel_layout, + int search_flags) +{ + void *target_obj; + const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); + AVChannelLayout *dst; + + if (!o || !target_obj) + return AVERROR_OPTION_NOT_FOUND; + + dst = (AVChannelLayout*)((uint8_t*)target_obj + o->offset); + + return av_channel_layout_copy(dst, channel_layout); +} + static void format_duration(char *buf, size_t size, int64_t d) { char *e; @@ -869,10 +927,18 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) (int)((uint8_t *)dst)[0], (int)((uint8_t *)dst)[1], (int)((uint8_t *)dst)[2], (int)((uint8_t *)dst)[3]); break; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS case AV_OPT_TYPE_CHANNEL_LAYOUT: + i64 = *(int64_t *)dst; ret = snprintf(buf, sizeof(buf), "0x%"PRIx64, i64); break; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + case AV_OPT_TYPE_CHLAYOUT: + ret = av_channel_layout_describe(dst, buf, sizeof(buf)); + break; case AV_OPT_TYPE_DICT: if (!*(AVDictionary **)dst && (search_flags & AV_OPT_ALLOW_NULL)) { *out_val = NULL; @@ -917,7 +983,10 @@ int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_v if ((ret = get_number(obj, name, NULL, &num, &den, &intnum, search_flags)) < 0) return ret; - *out_val = num * intnum / den; + if (num == den) + *out_val = intnum; + else + *out_val = num * intnum / den; return 0; } @@ -1011,6 +1080,8 @@ int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum AV return get_format(obj, name, search_flags, out_fmt, AV_OPT_TYPE_SAMPLE_FMT, "sample"); } +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS int av_opt_get_channel_layout(void *obj, const char *name, int search_flags, int64_t *cl) { void *dst, *target_obj; @@ -1027,6 +1098,24 @@ int av_opt_get_channel_layout(void *obj, const char *name, int search_flags, int *cl = *(int64_t *)dst; return 0; } +FF_ENABLE_DEPRECATION_WARNINGS +#endif + +int av_opt_get_chlayout(void *obj, const char *name, int search_flags, AVChannelLayout *cl) +{ + void *dst, *target_obj; + const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); + if (!o || !target_obj) + return AVERROR_OPTION_NOT_FOUND; + if (o->type != AV_OPT_TYPE_CHLAYOUT) { + av_log(obj, AV_LOG_ERROR, + "The value for option '%s' is not a channel layout.\n", name); + return AVERROR(EINVAL); + } + + dst = ((uint8_t*)target_obj) + o->offset; + return av_channel_layout_copy(cl, dst); +} int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDictionary **out_val) { @@ -1167,7 +1256,7 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, av_log(av_log_obj, AV_LOG_INFO, " %-15s ", opt->name); else av_log(av_log_obj, AV_LOG_INFO, " %s%-17s ", - (opt->flags & AV_OPT_FLAG_FILTERING_PARAM) ? "" : "-", + (opt->flags & AV_OPT_FLAG_FILTERING_PARAM) ? " " : "-", opt->name); switch (opt->type) { @@ -1219,7 +1308,12 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, case AV_OPT_TYPE_COLOR: av_log(av_log_obj, AV_LOG_INFO, "%-12s ", ""); break; + case AV_OPT_TYPE_CHLAYOUT: +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS case AV_OPT_TYPE_CHANNEL_LAYOUT: +FF_ENABLE_DEPRECATION_WARNINGS +#endif av_log(av_log_obj, AV_LOG_INFO, "%-12s ", ""); break; case AV_OPT_TYPE_BOOL: @@ -1276,6 +1370,7 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, opt->type == AV_OPT_TYPE_IMAGE_SIZE || opt->type == AV_OPT_TYPE_STRING || opt->type == AV_OPT_TYPE_DICT || + opt->type == AV_OPT_TYPE_CHLAYOUT || opt->type == AV_OPT_TYPE_VIDEO_RATE) && !opt->default_val.str)) { av_log(av_log_obj, AV_LOG_INFO, " (default "); @@ -1328,11 +1423,16 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, case AV_OPT_TYPE_STRING: case AV_OPT_TYPE_DICT: case AV_OPT_TYPE_VIDEO_RATE: + case AV_OPT_TYPE_CHLAYOUT: av_log(av_log_obj, AV_LOG_INFO, "\"%s\"", opt->default_val.str); break; +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS case AV_OPT_TYPE_CHANNEL_LAYOUT: av_log(av_log_obj, AV_LOG_INFO, "0x%"PRIx64, opt->default_val.i64); break; +FF_ENABLE_DEPRECATION_WARNINGS +#endif } av_log(av_log_obj, AV_LOG_INFO, ")"); } @@ -1382,7 +1482,11 @@ void av_opt_set_defaults2(void *s, int mask, int flags) case AV_OPT_TYPE_INT64: case AV_OPT_TYPE_UINT64: case AV_OPT_TYPE_DURATION: +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS case AV_OPT_TYPE_CHANNEL_LAYOUT: +FF_ENABLE_DEPRECATION_WARNINGS +#endif case AV_OPT_TYPE_PIXEL_FMT: case AV_OPT_TYPE_SAMPLE_FMT: write_number(s, opt, dst, 1, 1, opt->default_val.i64); @@ -1415,6 +1519,9 @@ void av_opt_set_defaults2(void *s, int mask, int flags) case AV_OPT_TYPE_BINARY: set_string_binary(s, opt, opt->default_val.str, dst); break; + case AV_OPT_TYPE_CHLAYOUT: + set_string_channel_layout(s, opt, opt->default_val.str, dst); + break; case AV_OPT_TYPE_DICT: set_string_dict(s, opt, opt->default_val.str, dst); break; @@ -1622,6 +1729,10 @@ void av_opt_free(void *obj) av_dict_free((AVDictionary **)(((uint8_t *)obj) + o->offset)); break; + case AV_OPT_TYPE_CHLAYOUT: + av_channel_layout_uninit((AVChannelLayout *)(((uint8_t *)obj) + o->offset)); + break; + default: break; } @@ -1632,7 +1743,7 @@ int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags) { AVDictionaryEntry *t = NULL; AVDictionary *tmp = NULL; - int ret = 0; + int ret; if (!options) return 0; @@ -1646,11 +1757,10 @@ int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags) av_dict_free(&tmp); return ret; } - ret = 0; } av_dict_free(options); *options = tmp; - return ret; + return 0; } int av_opt_set_dict(void *obj, AVDictionary **options) @@ -1717,29 +1827,10 @@ void *av_opt_child_next(void *obj, void *prev) return NULL; } -#if FF_API_CHILD_CLASS_NEXT -FF_DISABLE_DEPRECATION_WARNINGS -const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev) -{ - if (parent->child_class_next) - return parent->child_class_next(prev); - return NULL; -} -FF_ENABLE_DEPRECATION_WARNINGS -#endif - const AVClass *av_opt_child_class_iterate(const AVClass *parent, void **iter) { if (parent->child_class_iterate) return parent->child_class_iterate(iter); -#if FF_API_CHILD_CLASS_NEXT -FF_DISABLE_DEPRECATION_WARNINGS - if (parent->child_class_next) { - *iter = parent->child_class_next(*iter); - return *iter; - } -FF_ENABLE_DEPRECATION_WARNINGS -#endif return NULL; } @@ -1759,7 +1850,11 @@ static int opt_size(enum AVOptionType type) case AV_OPT_TYPE_FLAGS: return sizeof(int); case AV_OPT_TYPE_DURATION: +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS case AV_OPT_TYPE_CHANNEL_LAYOUT: +FF_ENABLE_DEPRECATION_WARNINGS +#endif case AV_OPT_TYPE_INT64: case AV_OPT_TYPE_UINT64: return sizeof(int64_t); @@ -1826,12 +1921,16 @@ int av_opt_copy(void *dst, const void *src) } else if (o->type == AV_OPT_TYPE_DICT) { AVDictionary **sdict = (AVDictionary **) field_src; AVDictionary **ddict = (AVDictionary **) field_dst; + int ret2; if (*sdict != *ddict) av_dict_free(ddict); *ddict = NULL; - av_dict_copy(ddict, *sdict, 0); - if (av_dict_count(*sdict) != av_dict_count(*ddict)) - ret = AVERROR(ENOMEM); + ret2 = av_dict_copy(ddict, *sdict, 0); + if (ret2 < 0) + ret = ret2; + } else if (o->type == AV_OPT_TYPE_CHLAYOUT) { + if (field_dst != field_src) + ret = av_channel_layout_copy(field_dst, field_src); } else { int size = opt_size(o->type); if (size < 0) @@ -1847,10 +1946,7 @@ int av_opt_query_ranges(AVOptionRanges **ranges_arg, void *obj, const char *key, { int ret; const AVClass *c = *(AVClass**)obj; - int (*callback)(AVOptionRanges **, void *obj, const char *key, int flags) = NULL; - - if (c->version > (52 << 16 | 11 << 8)) - callback = c->query_ranges; + int (*callback)(AVOptionRanges **, void *obj, const char *key, int flags) = c->query_ranges; if (!callback) callback = av_opt_query_ranges_default; @@ -1898,7 +1994,11 @@ int av_opt_query_ranges_default(AVOptionRanges **ranges_arg, void *obj, const ch case AV_OPT_TYPE_DOUBLE: case AV_OPT_TYPE_DURATION: case AV_OPT_TYPE_COLOR: +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS case AV_OPT_TYPE_CHANNEL_LAYOUT: +FF_ENABLE_DEPRECATION_WARNINGS +#endif break; case AV_OPT_TYPE_STRING: range->component_min = 0; @@ -1978,12 +2078,24 @@ int av_opt_is_set_to_default(void *obj, const AVOption *o) case AV_OPT_TYPE_PIXEL_FMT: case AV_OPT_TYPE_SAMPLE_FMT: case AV_OPT_TYPE_INT: +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS case AV_OPT_TYPE_CHANNEL_LAYOUT: +FF_ENABLE_DEPRECATION_WARNINGS +#endif case AV_OPT_TYPE_DURATION: case AV_OPT_TYPE_INT64: case AV_OPT_TYPE_UINT64: read_number(o, dst, NULL, NULL, &i64); return o->default_val.i64 == i64; + case AV_OPT_TYPE_CHLAYOUT: { + AVChannelLayout ch_layout = { 0 }; + if (o->default_val.str) { + if ((ret = av_channel_layout_from_string(&ch_layout, o->default_val.str)) < 0) + return ret; + } + return !av_channel_layout_compare((AVChannelLayout *)dst, &ch_layout); + } case AV_OPT_TYPE_STRING: str = *(char **)dst; if (str == o->default_val.str) //2 NULLs diff --git a/media/ffvpx/libavutil/opt.h b/media/ffvpx/libavutil/opt.h index 8dc020a8200a..461b5d3b6bb2 100644 --- a/media/ffvpx/libavutil/opt.h +++ b/media/ffvpx/libavutil/opt.h @@ -29,11 +29,11 @@ #include "rational.h" #include "avutil.h" +#include "channel_layout.h" #include "dict.h" #include "log.h" #include "pixfmt.h" #include "samplefmt.h" -#include "version.h" /** * @defgroup avoptions AVOptions @@ -238,8 +238,11 @@ enum AVOptionType{ AV_OPT_TYPE_VIDEO_RATE, ///< offset must point to AVRational AV_OPT_TYPE_DURATION, AV_OPT_TYPE_COLOR, +#if FF_API_OLD_CHANNEL_LAYOUT AV_OPT_TYPE_CHANNEL_LAYOUT, +#endif AV_OPT_TYPE_BOOL, + AV_OPT_TYPE_CHLAYOUT, }; /** @@ -648,19 +651,6 @@ const AVOption *av_opt_next(const void *obj, const AVOption *prev); */ void *av_opt_child_next(void *obj, void *prev); -#if FF_API_CHILD_CLASS_NEXT -/** - * Iterate over potential AVOptions-enabled children of parent. - * - * @param prev result of a previous call to this function or NULL - * @return AVClass corresponding to next potential child or NULL - * - * @deprecated use av_opt_child_class_iterate - */ -attribute_deprecated -const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev); -#endif - /** * Iterate over potential AVOptions-enabled children of parent. * @@ -707,7 +697,11 @@ int av_opt_set_image_size(void *obj, const char *name, int w, int h, int search_ int av_opt_set_pixel_fmt (void *obj, const char *name, enum AVPixelFormat fmt, int search_flags); int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags); int av_opt_set_video_rate(void *obj, const char *name, AVRational val, int search_flags); +#if FF_API_OLD_CHANNEL_LAYOUT +attribute_deprecated int av_opt_set_channel_layout(void *obj, const char *name, int64_t ch_layout, int search_flags); +#endif +int av_opt_set_chlayout(void *obj, const char *name, const AVChannelLayout *layout, int search_flags); /** * @note Any old dictionary present is discarded and replaced with a copy of the new one. The * caller still owns val is and responsible for freeing it. @@ -762,7 +756,11 @@ int av_opt_get_image_size(void *obj, const char *name, int search_flags, int *w_ int av_opt_get_pixel_fmt (void *obj, const char *name, int search_flags, enum AVPixelFormat *out_fmt); int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum AVSampleFormat *out_fmt); int av_opt_get_video_rate(void *obj, const char *name, int search_flags, AVRational *out_val); +#if FF_API_OLD_CHANNEL_LAYOUT +attribute_deprecated int av_opt_get_channel_layout(void *obj, const char *name, int search_flags, int64_t *ch_layout); +#endif +int av_opt_get_chlayout(void *obj, const char *name, int search_flags, AVChannelLayout *layout); /** * @param[out] out_val The returned dictionary is a copy of the actual value and must * be freed with av_dict_free() by the caller @@ -804,9 +802,16 @@ int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags /** * Copy options from src object into dest object. * + * The underlying AVClass of both src and dest must coincide. The guarantee + * below does not apply if this is not fulfilled. + * * Options that require memory allocation (e.g. string or binary) are malloc'ed in dest object. * Original memory allocated for such options is freed unless both src and dest options points to the same memory. * + * Even on error it is guaranteed that allocated options from src and dest + * no longer alias each other afterwards; in particular calling av_opt_free() + * on both src and dest is safe afterwards if dest has been memdup'ed from src. + * * @param dest Object to copy from * @param src Object to copy into * @return 0 on success, negative on error diff --git a/media/ffvpx/libavutil/parseutils.c b/media/ffvpx/libavutil/parseutils.c index 497e858bb340..c2916c458b87 100644 --- a/media/ffvpx/libavutil/parseutils.c +++ b/media/ffvpx/libavutil/parseutils.c @@ -28,7 +28,7 @@ #include "common.h" #include "eval.h" #include "log.h" -//#include "random_seed.h" +/* #include "random_seed.h" */ #include "time_internal.h" #include "parseutils.h" #include "fftime.h" @@ -102,6 +102,7 @@ static const VideoSizeAbbr video_size_abbrs[] = { { "wsxga", 1600,1024 }, { "wuxga", 1920,1200 }, { "woxga", 2560,1600 }, + { "wqhd", 2560,1440 }, { "wqsxga", 3200,2048 }, { "wquxga", 3840,2400 }, { "whsxga", 6400,4096 }, @@ -111,6 +112,7 @@ static const VideoSizeAbbr video_size_abbrs[] = { { "hd480", 852, 480 }, { "hd720", 1280, 720 }, { "hd1080", 1920,1080 }, + { "quadhd", 2560,1440 }, { "2k", 2048,1080 }, /* Digital Cinema System Specification */ { "2kdci", 2048,1080 }, { "2kflat", 1998,1080 }, diff --git a/media/ffvpx/libavutil/pixdesc.c b/media/ffvpx/libavutil/pixdesc.c index 18c7a0efc821..6e57a82cb640 100644 --- a/media/ffvpx/libavutil/pixdesc.c +++ b/media/ffvpx/libavutil/pixdesc.c @@ -29,7 +29,6 @@ #include "pixdesc.h" #include "internal.h" #include "intreadwrite.h" -#include "version.h" void av_read_image_line2(void *dst, const uint8_t *data[4], const int linesize[4], @@ -167,9 +166,6 @@ void av_write_image_line(const uint16_t *src, av_write_image_line2(src, data, linesize, desc, x, y, c, w, 2); } -#if FF_API_PLUS1_MINUS1 -FF_DISABLE_DEPRECATION_WARNINGS -#endif static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { [AV_PIX_FMT_YUV420P] = { .name = "yuv420p", @@ -177,9 +173,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */ - { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 1, 0, 0, 8 }, /* U */ + { 2, 1, 0, 0, 8 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -189,9 +185,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 8, 1, 7, 1 }, /* Y */ - { 0, 4, 1, 0, 8, 3, 7, 2 }, /* U */ - { 0, 4, 3, 0, 8, 3, 7, 4 }, /* V */ + { 0, 2, 0, 0, 8 }, /* Y */ + { 0, 4, 1, 0, 8 }, /* U */ + { 0, 4, 3, 0, 8 }, /* V */ }, }, [AV_PIX_FMT_YVYU422] = { @@ -200,9 +196,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 8, 1, 7, 1 }, /* Y */ - { 0, 4, 3, 0, 8, 3, 7, 4 }, /* U */ - { 0, 4, 1, 0, 8, 3, 7, 2 }, /* V */ + { 0, 2, 0, 0, 8 }, /* Y */ + { 0, 4, 3, 0, 8 }, /* U */ + { 0, 4, 1, 0, 8 }, /* V */ }, }, [AV_PIX_FMT_Y210LE] = { @@ -211,9 +207,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 4, 0, 6, 10, 3, 9, 1 }, /* Y */ - { 0, 8, 2, 6, 10, 7, 9, 3 }, /* U */ - { 0, 8, 6, 6, 10, 7, 9, 7 }, /* V */ + { 0, 4, 0, 6, 10 }, /* Y */ + { 0, 8, 2, 6, 10 }, /* U */ + { 0, 8, 6, 6, 10 }, /* V */ }, }, [AV_PIX_FMT_Y210BE] = { @@ -222,9 +218,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 4, 0, 6, 10, 3, 9, 1 }, /* Y */ - { 0, 8, 2, 6, 10, 7, 9, 3 }, /* U */ - { 0, 8, 6, 6, 10, 7, 9, 7 }, /* V */ + { 0, 4, 0, 6, 10 }, /* Y */ + { 0, 8, 2, 6, 10 }, /* U */ + { 0, 8, 6, 6, 10 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE, }, @@ -234,9 +230,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 3, 0, 0, 8, 2, 7, 1 }, /* R */ - { 0, 3, 1, 0, 8, 2, 7, 2 }, /* G */ - { 0, 3, 2, 0, 8, 2, 7, 3 }, /* B */ + { 0, 3, 0, 0, 8 }, /* R */ + { 0, 3, 1, 0, 8 }, /* G */ + { 0, 3, 2, 0, 8 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_RGB, }, @@ -246,9 +242,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 3, 2, 0, 8, 2, 7, 3 }, /* R */ - { 0, 3, 1, 0, 8, 2, 7, 2 }, /* G */ - { 0, 3, 0, 0, 8, 2, 7, 1 }, /* B */ + { 0, 3, 2, 0, 8 }, /* R */ + { 0, 3, 1, 0, 8 }, /* G */ + { 0, 3, 0, 0, 8 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_RGB, }, @@ -258,9 +254,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w= 0, .log2_chroma_h= 0, .comp = { - { 0, 4, 2, 4, 10, 3, 9, 2 }, /* R */ - { 0, 4, 1, 2, 10, 3, 9, 3 }, /* G */ - { 0, 4, 0, 0, 10, 3, 9, 4 }, /* B */ + { 0, 4, 2, 4, 10 }, /* R */ + { 0, 4, 1, 2, 10 }, /* G */ + { 0, 4, 0, 0, 10 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_RGB, }, @@ -270,9 +266,33 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w= 0, .log2_chroma_h= 0, .comp = { - { 0, 4, 0, 4, 10, 3, 9, 2 }, /* R */ - { 0, 4, 1, 2, 10, 3, 9, 3 }, /* G */ - { 0, 4, 2, 0, 10, 3, 9, 4 }, /* B */ + { 0, 4, 0, 4, 10 }, /* R */ + { 0, 4, 1, 2, 10 }, /* G */ + { 0, 4, 2, 0, 10 }, /* B */ + }, + .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BE, + }, + [AV_PIX_FMT_X2BGR10LE] = { + .name = "x2bgr10le", + .nb_components= 3, + .log2_chroma_w= 0, + .log2_chroma_h= 0, + .comp = { + { 0, 4, 0, 0, 10 }, /* R */ + { 0, 4, 1, 2, 10 }, /* G */ + { 0, 4, 2, 4, 10 }, /* B */ + }, + .flags = AV_PIX_FMT_FLAG_RGB, + }, + [AV_PIX_FMT_X2BGR10BE] = { + .name = "x2bgr10be", + .nb_components= 3, + .log2_chroma_w= 0, + .log2_chroma_h= 0, + .comp = { + { 0, 4, 2, 0, 10 }, /* R */ + { 0, 4, 1, 2, 10 }, /* G */ + { 0, 4, 0, 4, 10 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BE, }, @@ -282,9 +302,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */ - { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 1, 0, 0, 8 }, /* U */ + { 2, 1, 0, 0, 8 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -294,9 +314,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */ - { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 1, 0, 0, 8 }, /* U */ + { 2, 1, 0, 0, 8 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -306,9 +326,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 2, .log2_chroma_h = 2, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */ - { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 1, 0, 0, 8 }, /* U */ + { 2, 1, 0, 0, 8 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -318,9 +338,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 2, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */ - { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 1, 0, 0, 8 }, /* U */ + { 2, 1, 0, 0, 8 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -330,9 +350,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 2, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */ - { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 1, 0, 0, 8 }, /* U */ + { 2, 1, 0, 0, 8 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -342,9 +362,8 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ + { 0, 1, 0, 0, 8 }, /* Y */ }, - .flags = FF_PSEUDOPAL, .alias = "gray8,y8", }, [AV_PIX_FMT_MONOWHITE] = { @@ -353,7 +372,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 0, 1, 0, 0, 1 }, /* Y */ + { 0, 1, 0, 0, 1 }, /* Y */ }, .flags = AV_PIX_FMT_FLAG_BITSTREAM, }, @@ -363,7 +382,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 7, 1, 0, 0, 1 }, /* Y */ + { 0, 1, 0, 7, 1 }, /* Y */ }, .flags = AV_PIX_FMT_FLAG_BITSTREAM, }, @@ -373,7 +392,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, + { 0, 1, 0, 0, 8 }, }, .flags = AV_PIX_FMT_FLAG_PAL | AV_PIX_FMT_FLAG_ALPHA, }, @@ -383,9 +402,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */ - { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 1, 0, 0, 8 }, /* U */ + { 2, 1, 0, 0, 8 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -395,9 +414,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */ - { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 1, 0, 0, 8 }, /* U */ + { 2, 1, 0, 0, 8 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -407,25 +426,27 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */ - { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 1, 0, 0, 8 }, /* U */ + { 2, 1, 0, 0, 8 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, +#if FF_API_XVMC [AV_PIX_FMT_XVMC] = { .name = "xvmc", .flags = AV_PIX_FMT_FLAG_HWACCEL, }, +#endif [AV_PIX_FMT_UYVY422] = { .name = "uyvy422", .nb_components = 3, .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 1, 0, 8, 1, 7, 2 }, /* Y */ - { 0, 4, 0, 0, 8, 3, 7, 1 }, /* U */ - { 0, 4, 2, 0, 8, 3, 7, 3 }, /* V */ + { 0, 2, 1, 0, 8 }, /* Y */ + { 0, 4, 0, 0, 8 }, /* U */ + { 0, 4, 2, 0, 8 }, /* V */ }, }, [AV_PIX_FMT_UYYVYY411] = { @@ -434,9 +455,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 2, .log2_chroma_h = 0, .comp = { - { 0, 4, 1, 0, 8, 3, 7, 2 }, /* Y */ - { 0, 6, 0, 0, 8, 5, 7, 1 }, /* U */ - { 0, 6, 3, 0, 8, 5, 7, 4 }, /* V */ + { 0, 4, 1, 0, 8 }, /* Y */ + { 0, 6, 0, 0, 8 }, /* U */ + { 0, 6, 3, 0, 8 }, /* V */ }, }, [AV_PIX_FMT_BGR8] = { @@ -445,11 +466,11 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 0, 3, 0, 2, 1 }, /* R */ - { 0, 1, 0, 3, 3, 0, 2, 1 }, /* G */ - { 0, 1, 0, 6, 2, 0, 1, 1 }, /* B */ + { 0, 1, 0, 0, 3 }, /* R */ + { 0, 1, 0, 3, 3 }, /* G */ + { 0, 1, 0, 6, 2 }, /* B */ }, - .flags = AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL, + .flags = AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_BGR4] = { .name = "bgr4", @@ -457,9 +478,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 4, 3, 0, 1, 3, 0, 4 }, /* R */ - { 0, 4, 1, 0, 2, 3, 1, 2 }, /* G */ - { 0, 4, 0, 0, 1, 3, 0, 1 }, /* B */ + { 0, 4, 3, 0, 1 }, /* R */ + { 0, 4, 1, 0, 2 }, /* G */ + { 0, 4, 0, 0, 1 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_RGB, }, @@ -469,11 +490,11 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 0, 1, 0, 0, 1 }, /* R */ - { 0, 1, 0, 1, 2, 0, 1, 1 }, /* G */ - { 0, 1, 0, 3, 1, 0, 0, 1 }, /* B */ + { 0, 1, 0, 0, 1 }, /* R */ + { 0, 1, 0, 1, 2 }, /* G */ + { 0, 1, 0, 3, 1 }, /* B */ }, - .flags = AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL, + .flags = AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_RGB8] = { .name = "rgb8", @@ -481,11 +502,11 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 6, 2, 0, 1, 1 }, /* R */ - { 0, 1, 0, 3, 3, 0, 2, 1 }, /* G */ - { 0, 1, 0, 0, 3, 0, 2, 1 }, /* B */ + { 0, 1, 0, 6, 2 }, /* R */ + { 0, 1, 0, 3, 3 }, /* G */ + { 0, 1, 0, 0, 3 }, /* B */ }, - .flags = AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL, + .flags = AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_RGB4] = { .name = "rgb4", @@ -493,9 +514,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 4, 0, 0, 1, 3, 0, 1 }, /* R */ - { 0, 4, 1, 0, 2, 3, 1, 2 }, /* G */ - { 0, 4, 3, 0, 1, 3, 0, 4 }, /* B */ + { 0, 4, 0, 0, 1 }, /* R */ + { 0, 4, 1, 0, 2 }, /* G */ + { 0, 4, 3, 0, 1 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_RGB, }, @@ -505,11 +526,11 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 3, 1, 0, 0, 1 }, /* R */ - { 0, 1, 0, 1, 2, 0, 1, 1 }, /* G */ - { 0, 1, 0, 0, 1, 0, 0, 1 }, /* B */ + { 0, 1, 0, 3, 1 }, /* R */ + { 0, 1, 0, 1, 2 }, /* G */ + { 0, 1, 0, 0, 1 }, /* B */ }, - .flags = AV_PIX_FMT_FLAG_RGB | FF_PSEUDOPAL, + .flags = AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_NV12] = { .name = "nv12", @@ -517,9 +538,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 2, 0, 0, 8, 1, 7, 1 }, /* U */ - { 1, 2, 1, 0, 8, 1, 7, 2 }, /* V */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 2, 0, 0, 8 }, /* U */ + { 1, 2, 1, 0, 8 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -529,9 +550,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 2, 1, 0, 8, 1, 7, 2 }, /* U */ - { 1, 2, 0, 0, 8, 1, 7, 1 }, /* V */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 2, 1, 0, 8 }, /* U */ + { 1, 2, 0, 0, 8 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -541,10 +562,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 4, 1, 0, 8, 3, 7, 2 }, /* R */ - { 0, 4, 2, 0, 8, 3, 7, 3 }, /* G */ - { 0, 4, 3, 0, 8, 3, 7, 4 }, /* B */ - { 0, 4, 0, 0, 8, 3, 7, 1 }, /* A */ + { 0, 4, 1, 0, 8 }, /* R */ + { 0, 4, 2, 0, 8 }, /* G */ + { 0, 4, 3, 0, 8 }, /* B */ + { 0, 4, 0, 0, 8 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, }, @@ -554,10 +575,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 4, 0, 0, 8, 3, 7, 1 }, /* R */ - { 0, 4, 1, 0, 8, 3, 7, 2 }, /* G */ - { 0, 4, 2, 0, 8, 3, 7, 3 }, /* B */ - { 0, 4, 3, 0, 8, 3, 7, 4 }, /* A */ + { 0, 4, 0, 0, 8 }, /* R */ + { 0, 4, 1, 0, 8 }, /* G */ + { 0, 4, 2, 0, 8 }, /* B */ + { 0, 4, 3, 0, 8 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, }, @@ -567,10 +588,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 4, 3, 0, 8, 3, 7, 4 }, /* R */ - { 0, 4, 2, 0, 8, 3, 7, 3 }, /* G */ - { 0, 4, 1, 0, 8, 3, 7, 2 }, /* B */ - { 0, 4, 0, 0, 8, 3, 7, 1 }, /* A */ + { 0, 4, 3, 0, 8 }, /* R */ + { 0, 4, 2, 0, 8 }, /* G */ + { 0, 4, 1, 0, 8 }, /* B */ + { 0, 4, 0, 0, 8 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, }, @@ -580,10 +601,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 4, 2, 0, 8, 3, 7, 3 }, /* R */ - { 0, 4, 1, 0, 8, 3, 7, 2 }, /* G */ - { 0, 4, 0, 0, 8, 3, 7, 1 }, /* B */ - { 0, 4, 3, 0, 8, 3, 7, 4 }, /* A */ + { 0, 4, 2, 0, 8 }, /* R */ + { 0, 4, 1, 0, 8 }, /* G */ + { 0, 4, 0, 0, 8 }, /* B */ + { 0, 4, 3, 0, 8 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, }, @@ -593,9 +614,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w= 0, .log2_chroma_h= 0, .comp = { - { 0, 4, 1, 0, 8, 3, 7, 2 }, /* R */ - { 0, 4, 2, 0, 8, 3, 7, 3 }, /* G */ - { 0, 4, 3, 0, 8, 3, 7, 4 }, /* B */ + { 0, 4, 1, 0, 8 }, /* R */ + { 0, 4, 2, 0, 8 }, /* G */ + { 0, 4, 3, 0, 8 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_RGB, }, @@ -605,9 +626,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w= 0, .log2_chroma_h= 0, .comp = { - { 0, 4, 0, 0, 8, 3, 7, 1 }, /* R */ - { 0, 4, 1, 0, 8, 3, 7, 2 }, /* G */ - { 0, 4, 2, 0, 8, 3, 7, 3 }, /* B */ + { 0, 4, 0, 0, 8 }, /* R */ + { 0, 4, 1, 0, 8 }, /* G */ + { 0, 4, 2, 0, 8 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_RGB, }, @@ -617,9 +638,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w= 0, .log2_chroma_h= 0, .comp = { - { 0, 4, 3, 0, 8, 3, 7, 4 }, /* R */ - { 0, 4, 2, 0, 8, 3, 7, 3 }, /* G */ - { 0, 4, 1, 0, 8, 3, 7, 2 }, /* B */ + { 0, 4, 3, 0, 8 }, /* R */ + { 0, 4, 2, 0, 8 }, /* G */ + { 0, 4, 1, 0, 8 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_RGB, }, @@ -629,9 +650,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w= 0, .log2_chroma_h= 0, .comp = { - { 0, 4, 2, 0, 8, 3, 7, 3 }, /* R */ - { 0, 4, 1, 0, 8, 3, 7, 2 }, /* G */ - { 0, 4, 0, 0, 8, 3, 7, 1 }, /* B */ + { 0, 4, 2, 0, 8 }, /* R */ + { 0, 4, 1, 0, 8 }, /* G */ + { 0, 4, 0, 0, 8 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_RGB, }, @@ -641,7 +662,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */ + { 0, 2, 0, 0, 9 }, /* Y */ }, .flags = AV_PIX_FMT_FLAG_BE, .alias = "y9be", @@ -652,7 +673,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */ + { 0, 2, 0, 0, 9 }, /* Y */ }, .alias = "y9le", }, @@ -662,7 +683,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ + { 0, 2, 0, 0, 10 }, /* Y */ }, .flags = AV_PIX_FMT_FLAG_BE, .alias = "y10be", @@ -673,7 +694,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ + { 0, 2, 0, 0, 10 }, /* Y */ }, .alias = "y10le", }, @@ -683,7 +704,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */ + { 0, 2, 0, 0, 12 }, /* Y */ }, .flags = AV_PIX_FMT_FLAG_BE, .alias = "y12be", @@ -694,7 +715,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */ + { 0, 2, 0, 0, 12 }, /* Y */ }, .alias = "y12le", }, @@ -704,7 +725,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 14, 1, 13, 1 }, /* Y */ + { 0, 2, 0, 0, 14 }, /* Y */ }, .flags = AV_PIX_FMT_FLAG_BE, .alias = "y14be", @@ -715,7 +736,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 14, 1, 13, 1 }, /* Y */ + { 0, 2, 0, 0, 14 }, /* Y */ }, .alias = "y14le", }, @@ -725,7 +746,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */ + { 0, 2, 0, 0, 16 }, /* Y */ }, .flags = AV_PIX_FMT_FLAG_BE, .alias = "y16be", @@ -736,7 +757,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */ + { 0, 2, 0, 0, 16 }, /* Y */ }, .alias = "y16le", }, @@ -746,9 +767,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 1, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */ - { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 1, 0, 0, 8 }, /* U */ + { 2, 1, 0, 0, 8 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -758,9 +779,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 1, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */ - { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 1, 0, 0, 8 }, /* U */ + { 2, 1, 0, 0, 8 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -770,9 +791,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */ - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */ + { 0, 2, 0, 0, 10 }, /* Y */ + { 1, 2, 0, 0, 10 }, /* U */ + { 2, 2, 0, 0, 10 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -782,9 +803,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */ - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */ + { 0, 2, 0, 0, 10 }, /* Y */ + { 1, 2, 0, 0, 10 }, /* U */ + { 2, 2, 0, 0, 10 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, @@ -794,9 +815,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */ - { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */ - { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */ + { 0, 2, 0, 0, 12 }, /* Y */ + { 1, 2, 0, 0, 12 }, /* U */ + { 2, 2, 0, 0, 12 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -806,9 +827,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */ - { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */ - { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */ + { 0, 2, 0, 0, 12 }, /* Y */ + { 1, 2, 0, 0, 12 }, /* U */ + { 2, 2, 0, 0, 12 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, @@ -818,10 +839,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */ - { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */ - { 3, 1, 0, 0, 8, 0, 7, 1 }, /* A */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 1, 0, 0, 8 }, /* U */ + { 2, 1, 0, 0, 8 }, /* V */ + { 3, 1, 0, 0, 8 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -831,10 +852,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */ - { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */ - { 3, 1, 0, 0, 8, 0, 7, 1 }, /* A */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 1, 0, 0, 8 }, /* U */ + { 2, 1, 0, 0, 8 }, /* V */ + { 3, 1, 0, 0, 8 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -844,10 +865,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 1, 0, 0, 8, 0, 7, 1 }, /* U */ - { 2, 1, 0, 0, 8, 0, 7, 1 }, /* V */ - { 3, 1, 0, 0, 8, 0, 7, 1 }, /* A */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 1, 0, 0, 8 }, /* U */ + { 2, 1, 0, 0, 8 }, /* V */ + { 3, 1, 0, 0, 8 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -857,10 +878,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */ - { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */ - { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */ - { 3, 2, 0, 0, 9, 1, 8, 1 }, /* A */ + { 0, 2, 0, 0, 9 }, /* Y */ + { 1, 2, 0, 0, 9 }, /* U */ + { 2, 2, 0, 0, 9 }, /* V */ + { 3, 2, 0, 0, 9 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -870,10 +891,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */ - { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */ - { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */ - { 3, 2, 0, 0, 9, 1, 8, 1 }, /* A */ + { 0, 2, 0, 0, 9 }, /* Y */ + { 1, 2, 0, 0, 9 }, /* U */ + { 2, 2, 0, 0, 9 }, /* V */ + { 3, 2, 0, 0, 9 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -883,10 +904,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */ - { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */ - { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */ - { 3, 2, 0, 0, 9, 1, 8, 1 }, /* A */ + { 0, 2, 0, 0, 9 }, /* Y */ + { 1, 2, 0, 0, 9 }, /* U */ + { 2, 2, 0, 0, 9 }, /* V */ + { 3, 2, 0, 0, 9 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -896,10 +917,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */ - { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */ - { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */ - { 3, 2, 0, 0, 9, 1, 8, 1 }, /* A */ + { 0, 2, 0, 0, 9 }, /* Y */ + { 1, 2, 0, 0, 9 }, /* U */ + { 2, 2, 0, 0, 9 }, /* V */ + { 3, 2, 0, 0, 9 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -909,10 +930,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */ - { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */ - { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */ - { 3, 2, 0, 0, 9, 1, 8, 1 }, /* A */ + { 0, 2, 0, 0, 9 }, /* Y */ + { 1, 2, 0, 0, 9 }, /* U */ + { 2, 2, 0, 0, 9 }, /* V */ + { 3, 2, 0, 0, 9 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -922,10 +943,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */ - { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */ - { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */ - { 3, 2, 0, 0, 9, 1, 8, 1 }, /* A */ + { 0, 2, 0, 0, 9 }, /* Y */ + { 1, 2, 0, 0, 9 }, /* U */ + { 2, 2, 0, 0, 9 }, /* V */ + { 3, 2, 0, 0, 9 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -935,10 +956,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */ - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */ - { 3, 2, 0, 0, 10, 1, 9, 1 }, /* A */ + { 0, 2, 0, 0, 10 }, /* Y */ + { 1, 2, 0, 0, 10 }, /* U */ + { 2, 2, 0, 0, 10 }, /* V */ + { 3, 2, 0, 0, 10 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -948,10 +969,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */ - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */ - { 3, 2, 0, 0, 10, 1, 9, 1 }, /* A */ + { 0, 2, 0, 0, 10 }, /* Y */ + { 1, 2, 0, 0, 10 }, /* U */ + { 2, 2, 0, 0, 10 }, /* V */ + { 3, 2, 0, 0, 10 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -961,10 +982,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */ - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */ - { 3, 2, 0, 0, 10, 1, 9, 1 }, /* A */ + { 0, 2, 0, 0, 10 }, /* Y */ + { 1, 2, 0, 0, 10 }, /* U */ + { 2, 2, 0, 0, 10 }, /* V */ + { 3, 2, 0, 0, 10 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -974,10 +995,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */ - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */ - { 3, 2, 0, 0, 10, 1, 9, 1 }, /* A */ + { 0, 2, 0, 0, 10 }, /* Y */ + { 1, 2, 0, 0, 10 }, /* U */ + { 2, 2, 0, 0, 10 }, /* V */ + { 3, 2, 0, 0, 10 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -987,10 +1008,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */ - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */ - { 3, 2, 0, 0, 10, 1, 9, 1 }, /* A */ + { 0, 2, 0, 0, 10 }, /* Y */ + { 1, 2, 0, 0, 10 }, /* U */ + { 2, 2, 0, 0, 10 }, /* V */ + { 3, 2, 0, 0, 10 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -1000,10 +1021,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */ - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */ - { 3, 2, 0, 0, 10, 1, 9, 1 }, /* A */ + { 0, 2, 0, 0, 10 }, /* Y */ + { 1, 2, 0, 0, 10 }, /* U */ + { 2, 2, 0, 0, 10 }, /* V */ + { 3, 2, 0, 0, 10 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -1013,10 +1034,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */ - { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */ - { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */ - { 3, 2, 0, 0, 16, 1, 15, 1 }, /* A */ + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 2, 0, 0, 16 }, /* U */ + { 2, 2, 0, 0, 16 }, /* V */ + { 3, 2, 0, 0, 16 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -1026,10 +1047,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */ - { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */ - { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */ - { 3, 2, 0, 0, 16, 1, 15, 1 }, /* A */ + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 2, 0, 0, 16 }, /* U */ + { 2, 2, 0, 0, 16 }, /* V */ + { 3, 2, 0, 0, 16 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -1039,10 +1060,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */ - { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */ - { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */ - { 3, 2, 0, 0, 16, 1, 15, 1 }, /* A */ + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 2, 0, 0, 16 }, /* U */ + { 2, 2, 0, 0, 16 }, /* V */ + { 3, 2, 0, 0, 16 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -1052,10 +1073,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */ - { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */ - { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */ - { 3, 2, 0, 0, 16, 1, 15, 1 }, /* A */ + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 2, 0, 0, 16 }, /* U */ + { 2, 2, 0, 0, 16 }, /* V */ + { 3, 2, 0, 0, 16 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -1065,10 +1086,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */ - { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */ - { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */ - { 3, 2, 0, 0, 16, 1, 15, 1 }, /* A */ + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 2, 0, 0, 16 }, /* U */ + { 2, 2, 0, 0, 16 }, /* V */ + { 3, 2, 0, 0, 16 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -1078,10 +1099,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */ - { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */ - { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */ - { 3, 2, 0, 0, 16, 1, 15, 1 }, /* A */ + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 2, 0, 0, 16 }, /* U */ + { 2, 2, 0, 0, 16 }, /* V */ + { 3, 2, 0, 0, 16 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -1091,9 +1112,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 6, 0, 0, 16, 5, 15, 1 }, /* R */ - { 0, 6, 2, 0, 16, 5, 15, 3 }, /* G */ - { 0, 6, 4, 0, 16, 5, 15, 5 }, /* B */ + { 0, 6, 0, 0, 16 }, /* R */ + { 0, 6, 2, 0, 16 }, /* G */ + { 0, 6, 4, 0, 16 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BE, }, @@ -1103,9 +1124,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 6, 0, 0, 16, 5, 15, 1 }, /* R */ - { 0, 6, 2, 0, 16, 5, 15, 3 }, /* G */ - { 0, 6, 4, 0, 16, 5, 15, 5 }, /* B */ + { 0, 6, 0, 0, 16 }, /* R */ + { 0, 6, 2, 0, 16 }, /* G */ + { 0, 6, 4, 0, 16 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_RGB, }, @@ -1115,10 +1136,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 8, 0, 0, 16, 7, 15, 1 }, /* R */ - { 0, 8, 2, 0, 16, 7, 15, 3 }, /* G */ - { 0, 8, 4, 0, 16, 7, 15, 5 }, /* B */ - { 0, 8, 6, 0, 16, 7, 15, 7 }, /* A */ + { 0, 8, 0, 0, 16 }, /* R */ + { 0, 8, 2, 0, 16 }, /* G */ + { 0, 8, 4, 0, 16 }, /* B */ + { 0, 8, 6, 0, 16 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, }, @@ -1128,10 +1149,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 8, 0, 0, 16, 7, 15, 1 }, /* R */ - { 0, 8, 2, 0, 16, 7, 15, 3 }, /* G */ - { 0, 8, 4, 0, 16, 7, 15, 5 }, /* B */ - { 0, 8, 6, 0, 16, 7, 15, 7 }, /* A */ + { 0, 8, 0, 0, 16 }, /* R */ + { 0, 8, 2, 0, 16 }, /* G */ + { 0, 8, 4, 0, 16 }, /* B */ + { 0, 8, 6, 0, 16 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, }, @@ -1141,9 +1162,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, -1, 3, 5, 1, 4, 0 }, /* R */ - { 0, 2, 0, 5, 6, 1, 5, 1 }, /* G */ - { 0, 2, 0, 0, 5, 1, 4, 1 }, /* B */ + { 0, 2, -1, 3, 5 }, /* R */ + { 0, 2, 0, 5, 6 }, /* G */ + { 0, 2, 0, 0, 5 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB, }, @@ -1153,9 +1174,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 1, 3, 5, 1, 4, 2 }, /* R */ - { 0, 2, 0, 5, 6, 1, 5, 1 }, /* G */ - { 0, 2, 0, 0, 5, 1, 4, 1 }, /* B */ + { 0, 2, 1, 3, 5 }, /* R */ + { 0, 2, 0, 5, 6 }, /* G */ + { 0, 2, 0, 0, 5 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_RGB, }, @@ -1165,9 +1186,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, -1, 2, 5, 1, 4, 0 }, /* R */ - { 0, 2, 0, 5, 5, 1, 4, 1 }, /* G */ - { 0, 2, 0, 0, 5, 1, 4, 1 }, /* B */ + { 0, 2, -1, 2, 5 }, /* R */ + { 0, 2, 0, 5, 5 }, /* G */ + { 0, 2, 0, 0, 5 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB, }, @@ -1177,9 +1198,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 1, 2, 5, 1, 4, 2 }, /* R */ - { 0, 2, 0, 5, 5, 1, 4, 1 }, /* G */ - { 0, 2, 0, 0, 5, 1, 4, 1 }, /* B */ + { 0, 2, 1, 2, 5 }, /* R */ + { 0, 2, 0, 5, 5 }, /* G */ + { 0, 2, 0, 0, 5 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_RGB, }, @@ -1189,9 +1210,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, -1, 0, 4, 1, 3, 0 }, /* R */ - { 0, 2, 0, 4, 4, 1, 3, 1 }, /* G */ - { 0, 2, 0, 0, 4, 1, 3, 1 }, /* B */ + { 0, 2, -1, 0, 4 }, /* R */ + { 0, 2, 0, 4, 4 }, /* G */ + { 0, 2, 0, 0, 4 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB, }, @@ -1201,9 +1222,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 1, 0, 4, 1, 3, 2 }, /* R */ - { 0, 2, 0, 4, 4, 1, 3, 1 }, /* G */ - { 0, 2, 0, 0, 4, 1, 3, 1 }, /* B */ + { 0, 2, 1, 0, 4 }, /* R */ + { 0, 2, 0, 4, 4 }, /* G */ + { 0, 2, 0, 0, 4 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_RGB, }, @@ -1213,9 +1234,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 6, 4, 0, 16, 5, 15, 5 }, /* R */ - { 0, 6, 2, 0, 16, 5, 15, 3 }, /* G */ - { 0, 6, 0, 0, 16, 5, 15, 1 }, /* B */ + { 0, 6, 4, 0, 16 }, /* R */ + { 0, 6, 2, 0, 16 }, /* G */ + { 0, 6, 0, 0, 16 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB, }, @@ -1225,9 +1246,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 6, 4, 0, 16, 5, 15, 5 }, /* R */ - { 0, 6, 2, 0, 16, 5, 15, 3 }, /* G */ - { 0, 6, 0, 0, 16, 5, 15, 1 }, /* B */ + { 0, 6, 4, 0, 16 }, /* R */ + { 0, 6, 2, 0, 16 }, /* G */ + { 0, 6, 0, 0, 16 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_RGB, }, @@ -1237,10 +1258,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 8, 4, 0, 16, 7, 15, 5 }, /* R */ - { 0, 8, 2, 0, 16, 7, 15, 3 }, /* G */ - { 0, 8, 0, 0, 16, 7, 15, 1 }, /* B */ - { 0, 8, 6, 0, 16, 7, 15, 7 }, /* A */ + { 0, 8, 4, 0, 16 }, /* R */ + { 0, 8, 2, 0, 16 }, /* G */ + { 0, 8, 0, 0, 16 }, /* B */ + { 0, 8, 6, 0, 16 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, }, @@ -1250,10 +1271,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 8, 4, 0, 16, 7, 15, 5 }, /* R */ - { 0, 8, 2, 0, 16, 7, 15, 3 }, /* G */ - { 0, 8, 0, 0, 16, 7, 15, 1 }, /* B */ - { 0, 8, 6, 0, 16, 7, 15, 7 }, /* A */ + { 0, 8, 4, 0, 16 }, /* R */ + { 0, 8, 2, 0, 16 }, /* G */ + { 0, 8, 0, 0, 16 }, /* B */ + { 0, 8, 6, 0, 16 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, }, @@ -1263,9 +1284,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 5, 1, 4, 1 }, /* R */ - { 0, 2, 0, 5, 6, 1, 5, 1 }, /* G */ - { 0, 2, -1, 3, 5, 1, 4, 0 }, /* B */ + { 0, 2, 0, 0, 5 }, /* R */ + { 0, 2, 0, 5, 6 }, /* G */ + { 0, 2, -1, 3, 5 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB, }, @@ -1275,9 +1296,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 5, 1, 4, 1 }, /* R */ - { 0, 2, 0, 5, 6, 1, 5, 1 }, /* G */ - { 0, 2, 1, 3, 5, 1, 4, 2 }, /* B */ + { 0, 2, 0, 0, 5 }, /* R */ + { 0, 2, 0, 5, 6 }, /* G */ + { 0, 2, 1, 3, 5 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_RGB, }, @@ -1287,9 +1308,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 5, 1, 4, 1 }, /* R */ - { 0, 2, 0, 5, 5, 1, 4, 1 }, /* G */ - { 0, 2, -1, 2, 5, 1, 4, 0 }, /* B */ + { 0, 2, 0, 0, 5 }, /* R */ + { 0, 2, 0, 5, 5 }, /* G */ + { 0, 2, -1, 2, 5 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB, }, @@ -1299,9 +1320,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 5, 1, 4, 1 }, /* R */ - { 0, 2, 0, 5, 5, 1, 4, 1 }, /* G */ - { 0, 2, 1, 2, 5, 1, 4, 2 }, /* B */ + { 0, 2, 0, 0, 5 }, /* R */ + { 0, 2, 0, 5, 5 }, /* G */ + { 0, 2, 1, 2, 5 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_RGB, }, @@ -1311,9 +1332,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 4, 1, 3, 1 }, /* R */ - { 0, 2, 0, 4, 4, 1, 3, 1 }, /* G */ - { 0, 2, -1, 0, 4, 1, 3, 0 }, /* B */ + { 0, 2, 0, 0, 4 }, /* R */ + { 0, 2, 0, 4, 4 }, /* G */ + { 0, 2, -1, 0, 4 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB, }, @@ -1323,48 +1344,27 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 4, 1, 3, 1 }, /* R */ - { 0, 2, 0, 4, 4, 1, 3, 1 }, /* G */ - { 0, 2, 1, 0, 4, 1, 3, 2 }, /* B */ + { 0, 2, 0, 0, 4 }, /* R */ + { 0, 2, 0, 4, 4 }, /* G */ + { 0, 2, 1, 0, 4 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_RGB, }, -#if FF_API_VAAPI - [AV_PIX_FMT_VAAPI_MOCO] = { - .name = "vaapi_moco", - .log2_chroma_w = 1, - .log2_chroma_h = 1, - .flags = AV_PIX_FMT_FLAG_HWACCEL, - }, - [AV_PIX_FMT_VAAPI_IDCT] = { - .name = "vaapi_idct", - .log2_chroma_w = 1, - .log2_chroma_h = 1, - .flags = AV_PIX_FMT_FLAG_HWACCEL, - }, - [AV_PIX_FMT_VAAPI_VLD] = { - .name = "vaapi_vld", - .log2_chroma_w = 1, - .log2_chroma_h = 1, - .flags = AV_PIX_FMT_FLAG_HWACCEL, - }, -#else [AV_PIX_FMT_VAAPI] = { .name = "vaapi", .log2_chroma_w = 1, .log2_chroma_h = 1, .flags = AV_PIX_FMT_FLAG_HWACCEL, }, -#endif [AV_PIX_FMT_YUV420P9LE] = { .name = "yuv420p9le", .nb_components = 3, .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */ - { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */ - { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */ + { 0, 2, 0, 0, 9 }, /* Y */ + { 1, 2, 0, 0, 9 }, /* U */ + { 2, 2, 0, 0, 9 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -1374,9 +1374,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */ - { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */ - { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */ + { 0, 2, 0, 0, 9 }, /* Y */ + { 1, 2, 0, 0, 9 }, /* U */ + { 2, 2, 0, 0, 9 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, @@ -1386,9 +1386,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */ - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */ + { 0, 2, 0, 0, 10 }, /* Y */ + { 1, 2, 0, 0, 10 }, /* U */ + { 2, 2, 0, 0, 10 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -1398,9 +1398,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */ - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */ + { 0, 2, 0, 0, 10 }, /* Y */ + { 1, 2, 0, 0, 10 }, /* U */ + { 2, 2, 0, 0, 10 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, @@ -1410,9 +1410,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */ - { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */ - { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */ + { 0, 2, 0, 0, 12 }, /* Y */ + { 1, 2, 0, 0, 12 }, /* U */ + { 2, 2, 0, 0, 12 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -1422,9 +1422,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */ - { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */ - { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */ + { 0, 2, 0, 0, 12 }, /* Y */ + { 1, 2, 0, 0, 12 }, /* U */ + { 2, 2, 0, 0, 12 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, @@ -1434,9 +1434,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 14, 1, 13, 1 }, /* Y */ - { 1, 2, 0, 0, 14, 1, 13, 1 }, /* U */ - { 2, 2, 0, 0, 14, 1, 13, 1 }, /* V */ + { 0, 2, 0, 0, 14 }, /* Y */ + { 1, 2, 0, 0, 14 }, /* U */ + { 2, 2, 0, 0, 14 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -1446,9 +1446,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 14, 1, 13, 1 }, /* Y */ - { 1, 2, 0, 0, 14, 1, 13, 1 }, /* U */ - { 2, 2, 0, 0, 14, 1, 13, 1 }, /* V */ + { 0, 2, 0, 0, 14 }, /* Y */ + { 1, 2, 0, 0, 14 }, /* U */ + { 2, 2, 0, 0, 14 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, @@ -1458,9 +1458,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */ - { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */ - { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */ + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 2, 0, 0, 16 }, /* U */ + { 2, 2, 0, 0, 16 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -1470,9 +1470,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */ - { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */ - { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */ + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 2, 0, 0, 16 }, /* U */ + { 2, 2, 0, 0, 16 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, @@ -1482,9 +1482,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */ - { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */ - { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */ + { 0, 2, 0, 0, 9 }, /* Y */ + { 1, 2, 0, 0, 9 }, /* U */ + { 2, 2, 0, 0, 9 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -1494,9 +1494,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */ - { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */ - { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */ + { 0, 2, 0, 0, 9 }, /* Y */ + { 1, 2, 0, 0, 9 }, /* U */ + { 2, 2, 0, 0, 9 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, @@ -1506,9 +1506,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */ - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */ + { 0, 2, 0, 0, 10 }, /* Y */ + { 1, 2, 0, 0, 10 }, /* U */ + { 2, 2, 0, 0, 10 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -1518,9 +1518,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */ - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */ + { 0, 2, 0, 0, 10 }, /* Y */ + { 1, 2, 0, 0, 10 }, /* U */ + { 2, 2, 0, 0, 10 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, @@ -1530,9 +1530,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */ - { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */ - { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */ + { 0, 2, 0, 0, 12 }, /* Y */ + { 1, 2, 0, 0, 12 }, /* U */ + { 2, 2, 0, 0, 12 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -1542,9 +1542,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */ - { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */ - { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */ + { 0, 2, 0, 0, 12 }, /* Y */ + { 1, 2, 0, 0, 12 }, /* U */ + { 2, 2, 0, 0, 12 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, @@ -1554,9 +1554,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 14, 1, 13, 1 }, /* Y */ - { 1, 2, 0, 0, 14, 1, 13, 1 }, /* U */ - { 2, 2, 0, 0, 14, 1, 13, 1 }, /* V */ + { 0, 2, 0, 0, 14 }, /* Y */ + { 1, 2, 0, 0, 14 }, /* U */ + { 2, 2, 0, 0, 14 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -1566,9 +1566,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 14, 1, 13, 1 }, /* Y */ - { 1, 2, 0, 0, 14, 1, 13, 1 }, /* U */ - { 2, 2, 0, 0, 14, 1, 13, 1 }, /* V */ + { 0, 2, 0, 0, 14 }, /* Y */ + { 1, 2, 0, 0, 14 }, /* U */ + { 2, 2, 0, 0, 14 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, @@ -1578,9 +1578,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */ - { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */ - { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */ + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 2, 0, 0, 16 }, /* U */ + { 2, 2, 0, 0, 16 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -1590,9 +1590,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */ - { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */ - { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */ + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 2, 0, 0, 16 }, /* U */ + { 2, 2, 0, 0, 16 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, @@ -1602,9 +1602,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */ - { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */ - { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */ + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 2, 0, 0, 16 }, /* U */ + { 2, 2, 0, 0, 16 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -1614,9 +1614,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */ - { 1, 2, 0, 0, 16, 1, 15, 1 }, /* U */ - { 2, 2, 0, 0, 16, 1, 15, 1 }, /* V */ + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 2, 0, 0, 16 }, /* U */ + { 2, 2, 0, 0, 16 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, @@ -1626,9 +1626,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */ - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */ + { 0, 2, 0, 0, 10 }, /* Y */ + { 1, 2, 0, 0, 10 }, /* U */ + { 2, 2, 0, 0, 10 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -1638,9 +1638,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* U */ - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* V */ + { 0, 2, 0, 0, 10 }, /* Y */ + { 1, 2, 0, 0, 10 }, /* U */ + { 2, 2, 0, 0, 10 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, @@ -1650,9 +1650,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */ - { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */ - { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */ + { 0, 2, 0, 0, 9 }, /* Y */ + { 1, 2, 0, 0, 9 }, /* U */ + { 2, 2, 0, 0, 9 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -1662,9 +1662,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 9, 1, 8, 1 }, /* Y */ - { 1, 2, 0, 0, 9, 1, 8, 1 }, /* U */ - { 2, 2, 0, 0, 9, 1, 8, 1 }, /* V */ + { 0, 2, 0, 0, 9 }, /* Y */ + { 1, 2, 0, 0, 9 }, /* U */ + { 2, 2, 0, 0, 9 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, @@ -1674,9 +1674,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */ - { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */ - { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */ + { 0, 2, 0, 0, 12 }, /* Y */ + { 1, 2, 0, 0, 12 }, /* U */ + { 2, 2, 0, 0, 12 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -1686,9 +1686,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */ - { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */ - { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */ + { 0, 2, 0, 0, 12 }, /* Y */ + { 1, 2, 0, 0, 12 }, /* U */ + { 2, 2, 0, 0, 12 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, @@ -1698,9 +1698,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 14, 1, 13, 1 }, /* Y */ - { 1, 2, 0, 0, 14, 1, 13, 1 }, /* U */ - { 2, 2, 0, 0, 14, 1, 13, 1 }, /* V */ + { 0, 2, 0, 0, 14 }, /* Y */ + { 1, 2, 0, 0, 14 }, /* U */ + { 2, 2, 0, 0, 14 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -1710,9 +1710,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 14, 1, 13, 1 }, /* Y */ - { 1, 2, 0, 0, 14, 1, 13, 1 }, /* U */ - { 2, 2, 0, 0, 14, 1, 13, 1 }, /* V */ + { 0, 2, 0, 0, 14 }, /* Y */ + { 1, 2, 0, 0, 14 }, /* U */ + { 2, 2, 0, 0, 14 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR, }, @@ -1732,8 +1732,8 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .name = "ya8", .nb_components = 2, .comp = { - { 0, 2, 0, 0, 8, 1, 7, 1 }, /* Y */ - { 0, 2, 1, 0, 8, 1, 7, 2 }, /* A */ + { 0, 2, 0, 0, 8 }, /* Y */ + { 0, 2, 1, 0, 8 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_ALPHA, .alias = "gray8a", @@ -1742,8 +1742,8 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .name = "ya16le", .nb_components = 2, .comp = { - { 0, 4, 0, 0, 16, 3, 15, 1 }, /* Y */ - { 0, 4, 2, 0, 16, 3, 15, 3 }, /* A */ + { 0, 4, 0, 0, 16 }, /* Y */ + { 0, 4, 2, 0, 16 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_ALPHA, }, @@ -1751,8 +1751,8 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .name = "ya16be", .nb_components = 2, .comp = { - { 0, 4, 0, 0, 16, 3, 15, 1 }, /* Y */ - { 0, 4, 2, 0, 16, 3, 15, 3 }, /* A */ + { 0, 4, 0, 0, 16 }, /* Y */ + { 0, 4, 2, 0, 16 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_ALPHA, }, @@ -1766,9 +1766,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 1, 0, 0, 8, 0, 7, 1 }, /* R */ - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* G */ - { 1, 1, 0, 0, 8, 0, 7, 1 }, /* B */ + { 2, 1, 0, 0, 8 }, /* R */ + { 0, 1, 0, 0, 8 }, /* G */ + { 1, 1, 0, 0, 8 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB, }, @@ -1778,9 +1778,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 2, 0, 0, 9, 1, 8, 1 }, /* R */ - { 0, 2, 0, 0, 9, 1, 8, 1 }, /* G */ - { 1, 2, 0, 0, 9, 1, 8, 1 }, /* B */ + { 2, 2, 0, 0, 9 }, /* R */ + { 0, 2, 0, 0, 9 }, /* G */ + { 1, 2, 0, 0, 9 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB, }, @@ -1790,9 +1790,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 2, 0, 0, 9, 1, 8, 1 }, /* R */ - { 0, 2, 0, 0, 9, 1, 8, 1 }, /* G */ - { 1, 2, 0, 0, 9, 1, 8, 1 }, /* B */ + { 2, 2, 0, 0, 9 }, /* R */ + { 0, 2, 0, 0, 9 }, /* G */ + { 1, 2, 0, 0, 9 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB, }, @@ -1802,9 +1802,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* R */ - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* G */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* B */ + { 2, 2, 0, 0, 10 }, /* R */ + { 0, 2, 0, 0, 10 }, /* G */ + { 1, 2, 0, 0, 10 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB, }, @@ -1814,9 +1814,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* R */ - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* G */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* B */ + { 2, 2, 0, 0, 10 }, /* R */ + { 0, 2, 0, 0, 10 }, /* G */ + { 1, 2, 0, 0, 10 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB, }, @@ -1826,9 +1826,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 2, 0, 0, 12, 1, 11, 1 }, /* R */ - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* G */ - { 1, 2, 0, 0, 12, 1, 11, 1 }, /* B */ + { 2, 2, 0, 0, 12 }, /* R */ + { 0, 2, 0, 0, 12 }, /* G */ + { 1, 2, 0, 0, 12 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB, }, @@ -1838,9 +1838,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 2, 0, 0, 12, 1, 11, 1 }, /* R */ - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* G */ - { 1, 2, 0, 0, 12, 1, 11, 1 }, /* B */ + { 2, 2, 0, 0, 12 }, /* R */ + { 0, 2, 0, 0, 12 }, /* G */ + { 1, 2, 0, 0, 12 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB, }, @@ -1850,9 +1850,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 2, 0, 0, 14, 1, 13, 1 }, /* R */ - { 0, 2, 0, 0, 14, 1, 13, 1 }, /* G */ - { 1, 2, 0, 0, 14, 1, 13, 1 }, /* B */ + { 2, 2, 0, 0, 14 }, /* R */ + { 0, 2, 0, 0, 14 }, /* G */ + { 1, 2, 0, 0, 14 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB, }, @@ -1862,9 +1862,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 2, 0, 0, 14, 1, 13, 1 }, /* R */ - { 0, 2, 0, 0, 14, 1, 13, 1 }, /* G */ - { 1, 2, 0, 0, 14, 1, 13, 1 }, /* B */ + { 2, 2, 0, 0, 14 }, /* R */ + { 0, 2, 0, 0, 14 }, /* G */ + { 1, 2, 0, 0, 14 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB, }, @@ -1874,9 +1874,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 2, 0, 0, 16, 1, 15, 1 }, /* R */ - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* G */ - { 1, 2, 0, 0, 16, 1, 15, 1 }, /* B */ + { 2, 2, 0, 0, 16 }, /* R */ + { 0, 2, 0, 0, 16 }, /* G */ + { 1, 2, 0, 0, 16 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB, }, @@ -1886,9 +1886,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 2, 0, 0, 16, 1, 15, 1 }, /* R */ - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* G */ - { 1, 2, 0, 0, 16, 1, 15, 1 }, /* B */ + { 2, 2, 0, 0, 16 }, /* R */ + { 0, 2, 0, 0, 16 }, /* G */ + { 1, 2, 0, 0, 16 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB, }, @@ -1898,10 +1898,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 1, 0, 0, 8, 0, 7, 1 }, /* R */ - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* G */ - { 1, 1, 0, 0, 8, 0, 7, 1 }, /* B */ - { 3, 1, 0, 0, 8, 0, 7, 1 }, /* A */ + { 2, 1, 0, 0, 8 }, /* R */ + { 0, 1, 0, 0, 8 }, /* G */ + { 1, 1, 0, 0, 8 }, /* B */ + { 3, 1, 0, 0, 8 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, @@ -1912,10 +1912,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 2, 0, 0, 16, 1, 15, 1 }, /* R */ - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* G */ - { 1, 2, 0, 0, 16, 1, 15, 1 }, /* B */ - { 3, 2, 0, 0, 16, 1, 15, 1 }, /* A */ + { 2, 2, 0, 0, 16 }, /* R */ + { 0, 2, 0, 0, 16 }, /* G */ + { 1, 2, 0, 0, 16 }, /* B */ + { 3, 2, 0, 0, 16 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, @@ -1926,10 +1926,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 2, 0, 0, 16, 1, 15, 1 }, /* R */ - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* G */ - { 1, 2, 0, 0, 16, 1, 15, 1 }, /* B */ - { 3, 2, 0, 0, 16, 1, 15, 1 }, /* A */ + { 2, 2, 0, 0, 16 }, /* R */ + { 0, 2, 0, 0, 16 }, /* G */ + { 1, 2, 0, 0, 16 }, /* B */ + { 3, 2, 0, 0, 16 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, @@ -1946,9 +1946,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 6, 0, 4, 12, 5, 11, 1 }, /* X */ - { 0, 6, 2, 4, 12, 5, 11, 3 }, /* Y */ - { 0, 6, 4, 4, 12, 5, 11, 5 }, /* Z */ + { 0, 6, 0, 4, 12 }, /* X */ + { 0, 6, 2, 4, 12 }, /* Y */ + { 0, 6, 4, 4, 12 }, /* Z */ }, /*.flags = -- not used*/ }, @@ -1958,9 +1958,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 6, 0, 4, 12, 5, 11, 1 }, /* X */ - { 0, 6, 2, 4, 12, 5, 11, 3 }, /* Y */ - { 0, 6, 4, 4, 12, 5, 11, 5 }, /* Z */ + { 0, 6, 0, 4, 12 }, /* X */ + { 0, 6, 2, 4, 12 }, /* Y */ + { 0, 6, 4, 4, 12 }, /* Z */ }, .flags = AV_PIX_FMT_FLAG_BE, }, @@ -1970,9 +1970,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w= 0, \ .log2_chroma_h= 0, \ .comp = { \ - {0,1,0,0,2,0,1,1},\ - {0,1,0,0,4,0,3,1},\ - {0,1,0,0,2,0,1,1},\ + { 0, 1, 0, 0, 2 }, \ + { 0, 1, 0, 0, 4 }, \ + { 0, 1, 0, 0, 2 }, \ }, \ #define BAYER16_DESC_COMMON \ @@ -1980,9 +1980,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w= 0, \ .log2_chroma_h= 0, \ .comp = { \ - {0,2,0,0,4,1,3,1},\ - {0,2,0,0,8,1,7,1},\ - {0,2,0,0,4,1,3,1},\ + { 0, 2, 0, 0, 4 }, \ + { 0, 2, 0, 0, 8 }, \ + { 0, 2, 0, 0, 4 }, \ }, \ [AV_PIX_FMT_BAYER_BGGR8] = { @@ -2051,9 +2051,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 2, 0, 0, 8, 1, 7, 1 }, /* U */ - { 1, 2, 1, 0, 8, 1, 7, 2 }, /* V */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 2, 0, 0, 8 }, /* U */ + { 1, 2, 1, 0, 8 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -2063,9 +2063,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ - { 1, 4, 0, 0, 10, 3, 9, 1 }, /* U */ - { 1, 4, 2, 0, 10, 3, 9, 3 }, /* V */ + { 0, 2, 0, 0, 10 }, /* Y */ + { 1, 4, 0, 0, 10 }, /* U */ + { 1, 4, 2, 0, 10 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -2075,9 +2075,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* Y */ - { 1, 4, 0, 0, 10, 3, 9, 1 }, /* U */ - { 1, 4, 2, 0, 10, 3, 9, 3 }, /* V */ + { 0, 2, 0, 0, 10 }, /* Y */ + { 1, 4, 0, 0, 10 }, /* U */ + { 1, 4, 2, 0, 10 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE, }, @@ -2103,10 +2103,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 8, 2, 0, 16, 7, 15, 3 }, /* Y */ - { 0, 8, 4, 0, 16, 7, 15, 5 }, /* U */ - { 0, 8, 6, 0, 16, 7, 15, 7 }, /* V */ - { 0, 8, 0, 0, 16, 7, 15, 1 }, /* A */ + { 0, 8, 2, 0, 16 }, /* Y */ + { 0, 8, 4, 0, 16 }, /* U */ + { 0, 8, 6, 0, 16 }, /* V */ + { 0, 8, 0, 0, 16 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_ALPHA, }, @@ -2116,10 +2116,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 8, 2, 0, 16, 7, 15, 3 }, /* Y */ - { 0, 8, 4, 0, 16, 7, 15, 5 }, /* U */ - { 0, 8, 6, 0, 16, 7, 15, 7 }, /* V */ - { 0, 8, 0, 0, 16, 7, 15, 1 }, /* A */ + { 0, 8, 2, 0, 16 }, /* Y */ + { 0, 8, 4, 0, 16 }, /* U */ + { 0, 8, 6, 0, 16 }, /* V */ + { 0, 8, 0, 0, 16 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_ALPHA, }, @@ -2129,9 +2129,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 6, 10, 1, 9, 1 }, /* Y */ - { 1, 4, 0, 6, 10, 3, 9, 1 }, /* U */ - { 1, 4, 2, 6, 10, 3, 9, 3 }, /* V */ + { 0, 2, 0, 6, 10 }, /* Y */ + { 1, 4, 0, 6, 10 }, /* U */ + { 1, 4, 2, 6, 10 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -2141,9 +2141,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 6, 10, 1, 9, 1 }, /* Y */ - { 1, 4, 0, 6, 10, 3, 9, 1 }, /* U */ - { 1, 4, 2, 6, 10, 3, 9, 3 }, /* V */ + { 0, 2, 0, 6, 10 }, /* Y */ + { 1, 4, 0, 6, 10 }, /* U */ + { 1, 4, 2, 6, 10 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE, }, @@ -2153,9 +2153,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */ - { 1, 4, 0, 0, 16, 3, 15, 1 }, /* U */ - { 1, 4, 2, 0, 16, 3, 15, 3 }, /* V */ + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 4, 0, 0, 16 }, /* U */ + { 1, 4, 2, 0, 16 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -2165,9 +2165,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 1, .comp = { - { 0, 2, 0, 0, 16, 1, 15, 1 }, /* Y */ - { 1, 4, 0, 0, 16, 3, 15, 1 }, /* U */ - { 1, 4, 2, 0, 16, 3, 15, 3 }, /* V */ + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 4, 0, 0, 16 }, /* U */ + { 1, 4, 2, 0, 16 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE, }, @@ -2177,10 +2177,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 2, 0, 0, 12, 1, 11, 1 }, /* R */ - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* G */ - { 1, 2, 0, 0, 12, 1, 11, 1 }, /* B */ - { 3, 2, 0, 0, 12, 1, 11, 1 }, /* A */ + { 2, 2, 0, 0, 12 }, /* R */ + { 0, 2, 0, 0, 12 }, /* G */ + { 1, 2, 0, 0, 12 }, /* B */ + { 3, 2, 0, 0, 12 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, @@ -2191,10 +2191,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 2, 0, 0, 12, 1, 11, 1 }, /* R */ - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* G */ - { 1, 2, 0, 0, 12, 1, 11, 1 }, /* B */ - { 3, 2, 0, 0, 12, 1, 11, 1 }, /* A */ + { 2, 2, 0, 0, 12 }, /* R */ + { 0, 2, 0, 0, 12 }, /* G */ + { 1, 2, 0, 0, 12 }, /* B */ + { 3, 2, 0, 0, 12 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, @@ -2205,10 +2205,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* R */ - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* G */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* B */ - { 3, 2, 0, 0, 10, 1, 9, 1 }, /* A */ + { 2, 2, 0, 0, 10 }, /* R */ + { 0, 2, 0, 0, 10 }, /* G */ + { 1, 2, 0, 0, 10 }, /* B */ + { 3, 2, 0, 0, 10 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, @@ -2219,10 +2219,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 2, 0, 0, 10, 1, 9, 1 }, /* R */ - { 0, 2, 0, 0, 10, 1, 9, 1 }, /* G */ - { 1, 2, 0, 0, 10, 1, 9, 1 }, /* B */ - { 3, 2, 0, 0, 10, 1, 9, 1 }, /* A */ + { 2, 2, 0, 0, 10 }, /* R */ + { 0, 2, 0, 0, 10 }, /* G */ + { 1, 2, 0, 0, 10 }, /* B */ + { 3, 2, 0, 0, 10 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, @@ -2237,9 +2237,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 4, 0, 0, 32, 3, 31, 1 }, /* R */ - { 0, 4, 0, 0, 32, 3, 31, 1 }, /* G */ - { 1, 4, 0, 0, 32, 3, 31, 1 }, /* B */ + { 2, 4, 0, 0, 32 }, /* R */ + { 0, 4, 0, 0, 32 }, /* G */ + { 1, 4, 0, 0, 32 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_FLOAT, @@ -2250,9 +2250,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 4, 0, 0, 32, 3, 31, 1 }, /* R */ - { 0, 4, 0, 0, 32, 3, 31, 1 }, /* G */ - { 1, 4, 0, 0, 32, 3, 31, 1 }, /* B */ + { 2, 4, 0, 0, 32 }, /* R */ + { 0, 4, 0, 0, 32 }, /* G */ + { 1, 4, 0, 0, 32 }, /* B */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_FLOAT | AV_PIX_FMT_FLAG_RGB, }, @@ -2262,10 +2262,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 4, 0, 0, 32, 3, 31, 1 }, /* R */ - { 0, 4, 0, 0, 32, 3, 31, 1 }, /* G */ - { 1, 4, 0, 0, 32, 3, 31, 1 }, /* B */ - { 3, 4, 0, 0, 32, 3, 31, 1 }, /* A */ + { 2, 4, 0, 0, 32 }, /* R */ + { 0, 4, 0, 0, 32 }, /* G */ + { 1, 4, 0, 0, 32 }, /* B */ + { 3, 4, 0, 0, 32 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA | AV_PIX_FMT_FLAG_RGB | @@ -2277,10 +2277,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 2, 4, 0, 0, 32, 3, 31, 1 }, /* R */ - { 0, 4, 0, 0, 32, 3, 31, 1 }, /* G */ - { 1, 4, 0, 0, 32, 3, 31, 1 }, /* B */ - { 3, 4, 0, 0, 32, 3, 31, 1 }, /* A */ + { 2, 4, 0, 0, 32 }, /* R */ + { 0, 4, 0, 0, 32 }, /* G */ + { 1, 4, 0, 0, 32 }, /* B */ + { 3, 4, 0, 0, 32 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_FLOAT, @@ -2299,7 +2299,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 4, 0, 0, 32, 3, 31, 1 }, /* Y */ + { 0, 4, 0, 0, 32 }, /* Y */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_FLOAT, .alias = "yf32be", @@ -2310,7 +2310,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 4, 0, 0, 32, 3, 31, 1 }, /* Y */ + { 0, 4, 0, 0, 32 }, /* Y */ }, .flags = AV_PIX_FMT_FLAG_FLOAT, .alias = "yf32le", @@ -2321,10 +2321,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */ - { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */ - { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */ - { 3, 2, 0, 0, 12, 1, 11, 1 }, /* A */ + { 0, 2, 0, 0, 12 }, /* Y */ + { 1, 2, 0, 0, 12 }, /* U */ + { 2, 2, 0, 0, 12 }, /* V */ + { 3, 2, 0, 0, 12 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -2334,10 +2334,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 1, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */ - { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */ - { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */ - { 3, 2, 0, 0, 12, 1, 11, 1 }, /* A */ + { 0, 2, 0, 0, 12 }, /* Y */ + { 1, 2, 0, 0, 12 }, /* U */ + { 2, 2, 0, 0, 12 }, /* V */ + { 3, 2, 0, 0, 12 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -2347,10 +2347,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */ - { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */ - { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */ - { 3, 2, 0, 0, 12, 1, 11, 1 }, /* A */ + { 0, 2, 0, 0, 12 }, /* Y */ + { 1, 2, 0, 0, 12 }, /* U */ + { 2, 2, 0, 0, 12 }, /* V */ + { 3, 2, 0, 0, 12 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -2360,10 +2360,10 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 2, 0, 0, 12, 1, 11, 1 }, /* Y */ - { 1, 2, 0, 0, 12, 1, 11, 1 }, /* U */ - { 2, 2, 0, 0, 12, 1, 11, 1 }, /* V */ - { 3, 2, 0, 0, 12, 1, 11, 1 }, /* A */ + { 0, 2, 0, 0, 12 }, /* Y */ + { 1, 2, 0, 0, 12 }, /* U */ + { 2, 2, 0, 0, 12 }, /* V */ + { 3, 2, 0, 0, 12 }, /* A */ }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_ALPHA, }, @@ -2373,9 +2373,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 2, 0, 0, 8, 1, 7, 1 }, /* U */ - { 1, 2, 1, 0, 8, 1, 7, 2 }, /* V */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 2, 0, 0, 8 }, /* U */ + { 1, 2, 1, 0, 8 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -2385,9 +2385,9 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .log2_chroma_w = 0, .log2_chroma_h = 0, .comp = { - { 0, 1, 0, 0, 8, 0, 7, 1 }, /* Y */ - { 1, 2, 1, 0, 8, 1, 7, 2 }, /* U */ - { 1, 2, 0, 0, 8, 1, 7, 1 }, /* V */ + { 0, 1, 0, 0, 8 }, /* Y */ + { 1, 2, 1, 0, 8 }, /* U */ + { 1, 2, 0, 0, 8 }, /* V */ }, .flags = AV_PIX_FMT_FLAG_PLANAR, }, @@ -2395,10 +2395,103 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .name = "vulkan", .flags = AV_PIX_FMT_FLAG_HWACCEL, }, + [AV_PIX_FMT_P210BE] = { + .name = "p210be", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 6, 10 }, /* Y */ + { 1, 4, 0, 6, 10 }, /* U */ + { 1, 4, 2, 6, 10 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE, + }, + [AV_PIX_FMT_P210LE] = { + .name = "p210le", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 6, 10 }, /* Y */ + { 1, 4, 0, 6, 10 }, /* U */ + { 1, 4, 2, 6, 10 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR, + }, + [AV_PIX_FMT_P410BE] = { + .name = "p410be", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 6, 10 }, /* Y */ + { 1, 4, 0, 6, 10 }, /* U */ + { 1, 4, 2, 6, 10 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE, + }, + [AV_PIX_FMT_P410LE] = { + .name = "p410le", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 6, 10 }, /* Y */ + { 1, 4, 0, 6, 10 }, /* U */ + { 1, 4, 2, 6, 10 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR, + }, + [AV_PIX_FMT_P216BE] = { + .name = "p216be", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 4, 0, 0, 16 }, /* U */ + { 1, 4, 2, 0, 16 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE, + }, + [AV_PIX_FMT_P216LE] = { + .name = "p216le", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 4, 0, 0, 16 }, /* U */ + { 1, 4, 2, 0, 16 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR, + }, + [AV_PIX_FMT_P416BE] = { + .name = "p416be", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 4, 0, 0, 16 }, /* U */ + { 1, 4, 2, 0, 16 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE, + }, + [AV_PIX_FMT_P416LE] = { + .name = "p416le", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 4, 0, 0, 16 }, /* U */ + { 1, 4, 2, 0, 16 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR, + }, }; -#if FF_API_PLUS1_MINUS1 -FF_ENABLE_DEPRECATION_WARNINGS -#endif static const char * const color_range_names[] = { [AVCOL_RANGE_UNSPECIFIED] = "unknown", @@ -2515,10 +2608,6 @@ enum AVPixelFormat av_get_pix_fmt(const char *name) pix_fmt = get_pix_fmt_internal(name2); } -#if FF_API_VAAPI - if (pix_fmt == AV_PIX_FMT_NONE && !strcmp(name, "vaapi")) - pix_fmt = AV_PIX_FMT_VAAPI; -#endif return pix_fmt; } diff --git a/media/ffvpx/libavutil/pixdesc.h b/media/ffvpx/libavutil/pixdesc.h index 9b9d386ae96e..f8a195ffcd6e 100644 --- a/media/ffvpx/libavutil/pixdesc.h +++ b/media/ffvpx/libavutil/pixdesc.h @@ -26,7 +26,6 @@ #include "attributes.h" #include "pixfmt.h" -#include "version.h" typedef struct AVComponentDescriptor { /** @@ -56,17 +55,6 @@ typedef struct AVComponentDescriptor { * Number of bits in the component. */ int depth; - -#if FF_API_PLUS1_MINUS1 - /** deprecated, use step instead */ - attribute_deprecated int step_minus1; - - /** deprecated, use depth instead */ - attribute_deprecated int depth_minus1; - - /** deprecated, use offset instead */ - attribute_deprecated int offset_plus1; -#endif } AVComponentDescriptor; /** @@ -147,26 +135,6 @@ typedef struct AVPixFmtDescriptor { */ #define AV_PIX_FMT_FLAG_RGB (1 << 5) -#if FF_API_PSEUDOPAL -/** - * The pixel format is "pseudo-paletted". This means that it contains a - * fixed palette in the 2nd plane but the palette is fixed/constant for each - * PIX_FMT. This allows interpreting the data as if it was PAL8, which can - * in some cases be simpler. Or the data can be interpreted purely based on - * the pixel format without using the palette. - * An example of a pseudo-paletted format is AV_PIX_FMT_GRAY8 - * - * @deprecated This flag is deprecated, and will be removed. When it is removed, - * the extra palette allocation in AVFrame.data[1] is removed as well. Only - * actual paletted formats (as indicated by AV_PIX_FMT_FLAG_PAL) will have a - * palette. Starting with FFmpeg versions which have this flag deprecated, the - * extra "pseudo" palette is already ignored, and API users are not required to - * allocate a palette for AV_PIX_FMT_FLAG_PSEUDOPAL formats (it was required - * before the deprecation, though). - */ -#define AV_PIX_FMT_FLAG_PSEUDOPAL (1 << 6) -#endif - /** * The pixel format has an alpha channel. This is set on all formats that * support alpha in some way, including AV_PIX_FMT_PAL8. The alpha is always diff --git a/media/ffvpx/libavutil/pixelutils.c b/media/ffvpx/libavutil/pixelutils.c index ebee3d6f902f..820889a14372 100644 --- a/media/ffvpx/libavutil/pixelutils.c +++ b/media/ffvpx/libavutil/pixelutils.c @@ -16,12 +16,17 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "config.h" -#include "common.h" #include "pixelutils.h" -#include "internal.h" #if CONFIG_PIXELUTILS +#include +#include + +#include "attributes.h" +#include "macros.h" #include "x86/pixelutils.h" @@ -60,7 +65,8 @@ static const av_pixelutils_sad_fn sad_c[] = { block_sad_16x16_c, block_sad_32x32_c, }; - +#else +#include "log.h" #endif /* CONFIG_PIXELUTILS */ av_pixelutils_sad_fn av_pixelutils_get_sad_fn(int w_bits, int h_bits, int aligned, void *log_ctx) diff --git a/media/ffvpx/libavutil/pixelutils.h b/media/ffvpx/libavutil/pixelutils.h index a8dbc157e105..7a997cde1c8a 100644 --- a/media/ffvpx/libavutil/pixelutils.h +++ b/media/ffvpx/libavutil/pixelutils.h @@ -21,7 +21,6 @@ #include #include -#include "common.h" /** * Sum of abs(src1[x] - src2[x]) diff --git a/media/ffvpx/libavutil/pixfmt.h b/media/ffvpx/libavutil/pixfmt.h index 46ef211add11..2d3927cc3f64 100644 --- a/media/ffvpx/libavutil/pixfmt.h +++ b/media/ffvpx/libavutil/pixfmt.h @@ -112,21 +112,11 @@ enum AVPixelFormat { AV_PIX_FMT_BGR555BE, ///< packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), big-endian , X=unused/undefined AV_PIX_FMT_BGR555LE, ///< packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), little-endian, X=unused/undefined -#if FF_API_VAAPI - /** @name Deprecated pixel formats */ - /**@{*/ - AV_PIX_FMT_VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers - AV_PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers - AV_PIX_FMT_VAAPI_VLD, ///< HW decoding through VA API, Picture.data[3] contains a VASurfaceID - /**@}*/ - AV_PIX_FMT_VAAPI = AV_PIX_FMT_VAAPI_VLD, -#else /** * Hardware acceleration through VA-API, data[3] contains a * VASurfaceID. */ AV_PIX_FMT_VAAPI, -#endif AV_PIX_FMT_YUV420P16LE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian AV_PIX_FMT_YUV420P16BE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian @@ -270,7 +260,9 @@ enum AVPixelFormat { AV_PIX_FMT_BAYER_GRBG16LE, ///< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, little-endian AV_PIX_FMT_BAYER_GRBG16BE, ///< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, big-endian +#if FF_API_XVMC AV_PIX_FMT_XVMC,///< XVideo Motion Acceleration via common packet passing +#endif AV_PIX_FMT_YUV440P10LE, ///< planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian AV_PIX_FMT_YUV440P10BE, ///< planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian @@ -360,6 +352,21 @@ enum AVPixelFormat { AV_PIX_FMT_X2RGB10LE, ///< packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 10B(lsb), little-endian, X=unused/undefined AV_PIX_FMT_X2RGB10BE, ///< packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 10B(lsb), big-endian, X=unused/undefined + AV_PIX_FMT_X2BGR10LE, ///< packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 10R(lsb), little-endian, X=unused/undefined + AV_PIX_FMT_X2BGR10BE, ///< packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 10R(lsb), big-endian, X=unused/undefined + + AV_PIX_FMT_P210BE, ///< interleaved chroma YUV 4:2:2, 20bpp, data in the high bits, big-endian + AV_PIX_FMT_P210LE, ///< interleaved chroma YUV 4:2:2, 20bpp, data in the high bits, little-endian + + AV_PIX_FMT_P410BE, ///< interleaved chroma YUV 4:4:4, 30bpp, data in the high bits, big-endian + AV_PIX_FMT_P410LE, ///< interleaved chroma YUV 4:4:4, 30bpp, data in the high bits, little-endian + + AV_PIX_FMT_P216BE, ///< interleaved chroma YUV 4:2:2, 32bpp, big-endian + AV_PIX_FMT_P216LE, ///< interleaved chroma YUV 4:2:2, 32bpp, little-endian + + AV_PIX_FMT_P416BE, ///< interleaved chroma YUV 4:4:4, 48bpp, big-endian + AV_PIX_FMT_P416LE, ///< interleaved chroma YUV 4:4:4, 48bpp, little-endian + AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; @@ -450,35 +457,41 @@ enum AVPixelFormat { #define AV_PIX_FMT_Y210 AV_PIX_FMT_NE(Y210BE, Y210LE) #define AV_PIX_FMT_X2RGB10 AV_PIX_FMT_NE(X2RGB10BE, X2RGB10LE) +#define AV_PIX_FMT_X2BGR10 AV_PIX_FMT_NE(X2BGR10BE, X2BGR10LE) + +#define AV_PIX_FMT_P210 AV_PIX_FMT_NE(P210BE, P210LE) +#define AV_PIX_FMT_P410 AV_PIX_FMT_NE(P410BE, P410LE) +#define AV_PIX_FMT_P216 AV_PIX_FMT_NE(P216BE, P216LE) +#define AV_PIX_FMT_P416 AV_PIX_FMT_NE(P416BE, P416LE) /** * Chromaticity coordinates of the source primaries. - * These values match the ones defined by ISO/IEC 23001-8_2013 § 7.1. + * These values match the ones defined by ISO/IEC 23091-2_2019 subclause 8.1 and ITU-T H.273. */ enum AVColorPrimaries { AVCOL_PRI_RESERVED0 = 0, - AVCOL_PRI_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B + AVCOL_PRI_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B AVCOL_PRI_UNSPECIFIED = 2, AVCOL_PRI_RESERVED = 3, AVCOL_PRI_BT470M = 4, ///< also FCC Title 47 Code of Federal Regulations 73.682 (a)(20) AVCOL_PRI_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM AVCOL_PRI_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC - AVCOL_PRI_SMPTE240M = 7, ///< functionally identical to above + AVCOL_PRI_SMPTE240M = 7, ///< identical to above, also called "SMPTE C" even though it uses D65 AVCOL_PRI_FILM = 8, ///< colour filters using Illuminant C AVCOL_PRI_BT2020 = 9, ///< ITU-R BT2020 AVCOL_PRI_SMPTE428 = 10, ///< SMPTE ST 428-1 (CIE 1931 XYZ) AVCOL_PRI_SMPTEST428_1 = AVCOL_PRI_SMPTE428, AVCOL_PRI_SMPTE431 = 11, ///< SMPTE ST 431-2 (2011) / DCI P3 AVCOL_PRI_SMPTE432 = 12, ///< SMPTE ST 432-1 (2010) / P3 D65 / Display P3 - AVCOL_PRI_EBU3213 = 22, ///< EBU Tech. 3213-E / JEDEC P22 phosphors + AVCOL_PRI_EBU3213 = 22, ///< EBU Tech. 3213-E (nothing there) / one of JEDEC P22 group phosphors AVCOL_PRI_JEDEC_P22 = AVCOL_PRI_EBU3213, AVCOL_PRI_NB ///< Not part of ABI }; /** * Color Transfer Characteristic. - * These values match the ones defined by ISO/IEC 23001-8_2013 § 7.2. + * These values match the ones defined by ISO/IEC 23091-2_2019 subclause 8.2. */ enum AVColorTransferCharacteristic { AVCOL_TRC_RESERVED0 = 0, @@ -507,18 +520,18 @@ enum AVColorTransferCharacteristic { /** * YUV colorspace type. - * These values match the ones defined by ISO/IEC 23001-8_2013 § 7.3. + * These values match the ones defined by ISO/IEC 23091-2_2019 subclause 8.3. */ enum AVColorSpace { - AVCOL_SPC_RGB = 0, ///< order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB) - AVCOL_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B + AVCOL_SPC_RGB = 0, ///< order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1 + AVCOL_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B AVCOL_SPC_UNSPECIFIED = 2, - AVCOL_SPC_RESERVED = 3, + AVCOL_SPC_RESERVED = 3, ///< reserved for future use by ITU-T and ISO/IEC just like 15-255 are AVCOL_SPC_FCC = 4, ///< FCC Title 47 Code of Federal Regulations 73.682 (a)(20) AVCOL_SPC_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 - AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC - AVCOL_SPC_SMPTE240M = 7, ///< functionally identical to above - AVCOL_SPC_YCGCO = 8, ///< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16 + AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above + AVCOL_SPC_SMPTE240M = 7, ///< derived from 170M primaries and D65 white point, 170M is derived from BT470 System M's primaries + AVCOL_SPC_YCGCO = 8, ///< used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16 AVCOL_SPC_YCOCG = AVCOL_SPC_YCGCO, AVCOL_SPC_BT2020_NCL = 9, ///< ITU-R BT2020 non-constant luminance system AVCOL_SPC_BT2020_CL = 10, ///< ITU-R BT2020 constant luminance system @@ -540,9 +553,9 @@ enum AVColorSpace { * recommended, as it also defines the full range representation. * * Common definitions: - * - For RGB and luminance planes such as Y in YCbCr and I in ICtCp, + * - For RGB and luma planes such as Y in YCbCr and I in ICtCp, * 'E' is the original value in range of 0.0 to 1.0. - * - For chrominance planes such as Cb,Cr and Ct,Cp, 'E' is the original + * - For chroma planes such as Cb,Cr and Ct,Cp, 'E' is the original * value in range of -0.5 to 0.5. * - 'n' is the output bit depth. * - For additional definitions such as rounding and clipping to valid n @@ -554,13 +567,13 @@ enum AVColorRange { /** * Narrow or limited range content. * - * - For luminance planes: + * - For luma planes: * * (219 * E + 16) * 2^(n-8) * * F.ex. the range of 16-235 for 8 bits * - * - For chrominance planes: + * - For chroma planes: * * (224 * E + 128) * 2^(n-8) * @@ -571,13 +584,13 @@ enum AVColorRange { /** * Full range content. * - * - For RGB and luminance planes: + * - For RGB and luma planes: * * (2^n - 1) * E * * F.ex. the range of 0-255 for 8 bits * - * - For chrominance planes: + * - For chroma planes: * * (2^n - 1) * E + 2^(n - 1) * diff --git a/media/ffvpx/libavutil/qsort.h b/media/ffvpx/libavutil/qsort.h index 39b7a088520a..6014f88be320 100644 --- a/media/ffvpx/libavutil/qsort.h +++ b/media/ffvpx/libavutil/qsort.h @@ -21,7 +21,7 @@ #ifndef AVUTIL_QSORT_H #define AVUTIL_QSORT_H -#include "common.h" +#include "macros.h" /** diff --git a/media/ffvpx/libavutil/samplefmt.c b/media/ffvpx/libavutil/samplefmt.c index fc077f644443..6d3ec34dab41 100644 --- a/media/ffvpx/libavutil/samplefmt.c +++ b/media/ffvpx/libavutil/samplefmt.c @@ -16,11 +16,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "common.h" +#include "error.h" +#include "macros.h" +#include "mem.h" #include "samplefmt.h" +#include #include -#include #include typedef struct SampleFmtInfo { @@ -160,13 +162,20 @@ int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, if (buf_size < 0) return buf_size; + if (linesize) + *linesize = line_size; + + memset(audio_data, 0, planar + ? sizeof(*audio_data) * nb_channels + : sizeof(*audio_data)); + + if (!buf) + return buf_size; + audio_data[0] = (uint8_t *)buf; for (ch = 1; planar && ch < nb_channels; ch++) audio_data[ch] = audio_data[ch-1] + line_size; - if (linesize) - *linesize = line_size; - return buf_size; } diff --git a/media/ffvpx/libavutil/samplefmt.h b/media/ffvpx/libavutil/samplefmt.h index 8cd43ae8568a..1999c9bca62d 100644 --- a/media/ffvpx/libavutil/samplefmt.h +++ b/media/ffvpx/libavutil/samplefmt.h @@ -21,9 +21,6 @@ #include -#include "avutil.h" -#include "attributes.h" - /** * @addtogroup lavu_audio * @{ @@ -195,9 +192,8 @@ int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, * @param nb_samples the number of samples in a single channel * @param sample_fmt the sample format * @param align buffer size alignment (0 = default, 1 = no alignment) - * @return >=0 on success or a negative error code on failure - * @todo return minimum size in bytes required for the buffer in case - * of success at the next bump + * @return minimum size in bytes required for the buffer on success, + * or a negative error code on failure */ int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, const uint8_t *buf, diff --git a/media/ffvpx/libavutil/slicethread.c b/media/ffvpx/libavutil/slicethread.c index dfbe551ef206..ea1c9c83111b 100644 --- a/media/ffvpx/libavutil/slicethread.c +++ b/media/ffvpx/libavutil/slicethread.c @@ -17,6 +17,8 @@ */ #include +#include "cpu.h" +#include "internal.h" #include "slicethread.h" #include "mem.h" #include "thread.h" @@ -239,7 +241,7 @@ int avpriv_slicethread_create(AVSliceThread **pctx, void *priv, int nb_threads) { *pctx = NULL; - return AVERROR(EINVAL); + return AVERROR(ENOSYS); } void avpriv_slicethread_execute(AVSliceThread *ctx, int nb_jobs, int execute_main) diff --git a/media/ffvpx/libavutil/thread.h b/media/ffvpx/libavutil/thread.h index be5c4b1340e7..7106fd0d479c 100644 --- a/media/ffvpx/libavutil/thread.h +++ b/media/ffvpx/libavutil/thread.h @@ -31,7 +31,11 @@ #if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1 +#include + +#include "error.h" #include "log.h" +#include "macros.h" #define ASSERT_PTHREAD_ABORT(func, ret) do { \ char errbuf[AV_ERROR_MAX_STRING_SIZE] = ""; \ diff --git a/media/ffvpx/libavutil/threadmessage.c b/media/ffvpx/libavutil/threadmessage.c index 764b7fb8131e..f0e23f28fcc2 100644 --- a/media/ffvpx/libavutil/threadmessage.c +++ b/media/ffvpx/libavutil/threadmessage.c @@ -18,13 +18,15 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include "fifo.h" +#include "mem.h" #include "threadmessage.h" #include "thread.h" struct AVThreadMessageQueue { #if HAVE_THREADS - AVFifoBuffer *fifo; + AVFifo *fifo; pthread_mutex_t lock; pthread_cond_t cond_recv; pthread_cond_t cond_send; @@ -64,7 +66,7 @@ int av_thread_message_queue_alloc(AVThreadMessageQueue **mq, av_free(rmq); return AVERROR(ret); } - if (!(rmq->fifo = av_fifo_alloc(elsize * nelem))) { + if (!(rmq->fifo = av_fifo_alloc2(nelem, elsize, 0))) { pthread_cond_destroy(&rmq->cond_send); pthread_cond_destroy(&rmq->cond_recv); pthread_mutex_destroy(&rmq->lock); @@ -93,7 +95,7 @@ void av_thread_message_queue_free(AVThreadMessageQueue **mq) #if HAVE_THREADS if (*mq) { av_thread_message_flush(*mq); - av_fifo_freep(&(*mq)->fifo); + av_fifo_freep2(&(*mq)->fifo); pthread_cond_destroy(&(*mq)->cond_send); pthread_cond_destroy(&(*mq)->cond_recv); pthread_mutex_destroy(&(*mq)->lock); @@ -107,9 +109,9 @@ int av_thread_message_queue_nb_elems(AVThreadMessageQueue *mq) #if HAVE_THREADS int ret; pthread_mutex_lock(&mq->lock); - ret = av_fifo_size(mq->fifo); + ret = av_fifo_can_read(mq->fifo); pthread_mutex_unlock(&mq->lock); - return ret / mq->elsize; + return ret; #else return AVERROR(ENOSYS); #endif @@ -121,14 +123,14 @@ static int av_thread_message_queue_send_locked(AVThreadMessageQueue *mq, void *msg, unsigned flags) { - while (!mq->err_send && av_fifo_space(mq->fifo) < mq->elsize) { + while (!mq->err_send && !av_fifo_can_write(mq->fifo)) { if ((flags & AV_THREAD_MESSAGE_NONBLOCK)) return AVERROR(EAGAIN); pthread_cond_wait(&mq->cond_send, &mq->lock); } if (mq->err_send) return mq->err_send; - av_fifo_generic_write(mq->fifo, msg, mq->elsize, NULL); + av_fifo_write(mq->fifo, msg, 1); /* one message is sent, signal one receiver */ pthread_cond_signal(&mq->cond_recv); return 0; @@ -138,14 +140,14 @@ static int av_thread_message_queue_recv_locked(AVThreadMessageQueue *mq, void *msg, unsigned flags) { - while (!mq->err_recv && av_fifo_size(mq->fifo) < mq->elsize) { + while (!mq->err_recv && !av_fifo_can_read(mq->fifo)) { if ((flags & AV_THREAD_MESSAGE_NONBLOCK)) return AVERROR(EAGAIN); pthread_cond_wait(&mq->cond_recv, &mq->lock); } - if (av_fifo_size(mq->fifo) < mq->elsize) + if (!av_fifo_can_read(mq->fifo)) return mq->err_recv; - av_fifo_generic_read(mq->fifo, msg, mq->elsize, NULL); + av_fifo_read(mq->fifo, msg, 1); /* one message space appeared, signal one sender */ pthread_cond_signal(&mq->cond_send); return 0; @@ -208,25 +210,25 @@ void av_thread_message_queue_set_err_recv(AVThreadMessageQueue *mq, } #if HAVE_THREADS -static void free_func_wrap(void *arg, void *msg, int size) +static int free_func_wrap(void *arg, void *buf, size_t *nb_elems) { AVThreadMessageQueue *mq = arg; - mq->free_func(msg); + uint8_t *msg = buf; + for (size_t i = 0; i < *nb_elems; i++) + mq->free_func(msg + i * mq->elsize); + return 0; } #endif void av_thread_message_flush(AVThreadMessageQueue *mq) { #if HAVE_THREADS - int used, off; - void *free_func = mq->free_func; + size_t used; pthread_mutex_lock(&mq->lock); - used = av_fifo_size(mq->fifo); - if (free_func) - for (off = 0; off < used; off += mq->elsize) - av_fifo_generic_peek_at(mq->fifo, mq, off, mq->elsize, free_func_wrap); - av_fifo_drain(mq->fifo, used); + used = av_fifo_can_read(mq->fifo); + if (mq->free_func) + av_fifo_read_to_cb(mq->fifo, free_func_wrap, mq, &used); /* only the senders need to be notified since the queue is empty and there * is nothing to read */ pthread_cond_broadcast(&mq->cond_send); diff --git a/media/ffvpx/libavutil/timecode.c b/media/ffvpx/libavutil/timecode.c index 2fc3295e25de..b93f05b4b825 100644 --- a/media/ffvpx/libavutil/timecode.c +++ b/media/ffvpx/libavutil/timecode.c @@ -27,6 +27,7 @@ */ #include +#include "common.h" #include "timecode.h" #include "log.h" #include "error.h" @@ -103,7 +104,7 @@ char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum) { int fps = tc->fps; int drop = tc->flags & AV_TIMECODE_FLAG_DROPFRAME; - int hh, mm, ss, ff, neg = 0; + int hh, mm, ss, ff, ff_len, neg = 0; framenum += tc->start; if (drop) @@ -118,9 +119,10 @@ char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum) hh = framenum / (fps*3600LL); if (tc->flags & AV_TIMECODE_FLAG_24HOURSMAX) hh = hh % 24; - snprintf(buf, AV_TIMECODE_STR_SIZE, "%s%02d:%02d:%02d%c%02d", + ff_len = fps > 10000 ? 5 : fps > 1000 ? 4 : fps > 100 ? 3 : fps > 10 ? 2 : 1; + snprintf(buf, AV_TIMECODE_STR_SIZE, "%s%02d:%02d:%02d%c%0*d", neg ? "-" : "", - hh, mm, ss, drop ? ';' : ':', ff); + hh, mm, ss, drop ? ';' : ':', ff_len, ff); return buf; } diff --git a/media/ffvpx/libavutil/timer.h b/media/ffvpx/libavutil/timer.h index 36f920e96aed..48e576739f51 100644 --- a/media/ffvpx/libavutil/timer.h +++ b/media/ffvpx/libavutil/timer.h @@ -42,10 +42,13 @@ #include #include -#if HAVE_MACH_ABSOLUTE_TIME +#if CONFIG_MACOS_KPERF +#include "macos_kperf.h" +#elif HAVE_MACH_ABSOLUTE_TIME #include #endif +#include "common.h" #include "log.h" #if ARCH_AARCH64 @@ -125,6 +128,16 @@ read(linux_perf_fd, &tperf, sizeof(tperf)); \ TIMER_REPORT(id, tperf) +#elif CONFIG_MACOS_KPERF + +#define START_TIMER \ + uint64_t tperf; \ + ff_kperf_init(); \ + tperf = ff_kperf_cycles(); + +#define STOP_TIMER(id) \ + TIMER_REPORT(id, ff_kperf_cycles() - tperf); + #elif defined(AV_READ_TIME) #define START_TIMER \ uint64_t tend; \ diff --git a/media/ffvpx/libavutil/utils.c b/media/ffvpx/libavutil/utils.c index c1cd452eee51..94d247bbee6e 100644 --- a/media/ffvpx/libavutil/utils.c +++ b/media/ffvpx/libavutil/utils.c @@ -19,60 +19,12 @@ #include "config.h" #include "avutil.h" #include "avassert.h" -#include "samplefmt.h" -#include "internal.h" /** * @file * various utility functions */ -#include "libavutil/ffversion.h" -const char av_util_ffversion[] = "FFmpeg version " FFMPEG_VERSION; - -const char *av_version_info(void) -{ - return FFMPEG_VERSION; -} - -unsigned avutil_version(void) -{ - static int checks_done; - if (checks_done) - return LIBAVUTIL_VERSION_INT; - - av_assert0(AV_SAMPLE_FMT_DBLP == 9); - av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4); - av_assert0(AV_PICTURE_TYPE_BI == 7); - av_assert0(LIBAVUTIL_VERSION_MICRO >= 100); - av_assert0(HAVE_MMX2 == HAVE_MMXEXT); - - av_assert0(((size_t)-1) > 0); // C guarantees this but if false on a platform we care about revert at least b284e1ffe343d6697fb950d1ee517bafda8a9844 - - if (av_sat_dadd32(1, 2) != 5) { - av_log(NULL, AV_LOG_FATAL, "Libavutil has been built with a broken binutils, please upgrade binutils and rebuild\n"); - abort(); - } - - if (llrint(1LL<<60) != 1LL<<60) { - av_log(NULL, AV_LOG_ERROR, "Libavutil has been linked to a broken llrint()\n"); - } - - checks_done = 1; - return LIBAVUTIL_VERSION_INT; -} - -const char *avutil_configuration(void) -{ - return FFMPEG_CONFIGURATION; -} - -const char *avutil_license(void) -{ -#define LICENSE_PREFIX "libavutil license: " - return &LICENSE_PREFIX FFMPEG_LICENSE[sizeof(LICENSE_PREFIX) - 1]; -} - const char *av_get_media_type_string(enum AVMediaType media_type) { switch (media_type) { diff --git a/media/ffvpx/libavutil/version.h b/media/ffvpx/libavutil/version.h index f888dbb2dc12..2e9e02dda85e 100644 --- a/media/ffvpx/libavutil/version.h +++ b/media/ffvpx/libavutil/version.h @@ -78,8 +78,8 @@ * @{ */ -#define LIBAVUTIL_VERSION_MAJOR 56 -#define LIBAVUTIL_VERSION_MINOR 70 +#define LIBAVUTIL_VERSION_MAJOR 57 +#define LIBAVUTIL_VERSION_MINOR 27 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ @@ -105,42 +105,15 @@ * @{ */ -#ifndef FF_API_VAAPI -#define FF_API_VAAPI (LIBAVUTIL_VERSION_MAJOR < 57) -#endif -#ifndef FF_API_FRAME_QP -#define FF_API_FRAME_QP (LIBAVUTIL_VERSION_MAJOR < 57) -#endif -#ifndef FF_API_PLUS1_MINUS1 -#define FF_API_PLUS1_MINUS1 (LIBAVUTIL_VERSION_MAJOR < 57) -#endif -#ifndef FF_API_ERROR_FRAME -#define FF_API_ERROR_FRAME (LIBAVUTIL_VERSION_MAJOR < 57) -#endif -#ifndef FF_API_PKT_PTS -#define FF_API_PKT_PTS (LIBAVUTIL_VERSION_MAJOR < 57) -#endif -#ifndef FF_API_CRYPTO_SIZE_T -#define FF_API_CRYPTO_SIZE_T (LIBAVUTIL_VERSION_MAJOR < 57) -#endif -#ifndef FF_API_FRAME_GET_SET -#define FF_API_FRAME_GET_SET (LIBAVUTIL_VERSION_MAJOR < 57) -#endif -#ifndef FF_API_PSEUDOPAL -#define FF_API_PSEUDOPAL (LIBAVUTIL_VERSION_MAJOR < 57) -#endif -#ifndef FF_API_CHILD_CLASS_NEXT -#define FF_API_CHILD_CLASS_NEXT (LIBAVUTIL_VERSION_MAJOR < 57) -#endif -#ifndef FF_API_BUFFER_SIZE_T -#define FF_API_BUFFER_SIZE_T (LIBAVUTIL_VERSION_MAJOR < 57) -#endif -#ifndef FF_API_D2STR #define FF_API_D2STR (LIBAVUTIL_VERSION_MAJOR < 58) -#endif -#ifndef FF_API_DECLARE_ALIGNED #define FF_API_DECLARE_ALIGNED (LIBAVUTIL_VERSION_MAJOR < 58) -#endif +#define FF_API_COLORSPACE_NAME (LIBAVUTIL_VERSION_MAJOR < 58) +#define FF_API_AV_MALLOCZ_ARRAY (LIBAVUTIL_VERSION_MAJOR < 58) +#define FF_API_FIFO_PEEK2 (LIBAVUTIL_VERSION_MAJOR < 58) +#define FF_API_FIFO_OLD_API (LIBAVUTIL_VERSION_MAJOR < 58) +#define FF_API_XVMC (LIBAVUTIL_VERSION_MAJOR < 58) +#define FF_API_OLD_CHANNEL_LAYOUT (LIBAVUTIL_VERSION_MAJOR < 58) +#define FF_API_AV_FOPEN_UTF8 (LIBAVUTIL_VERSION_MAJOR < 58) /** * @} diff --git a/media/ffvpx/libavutil/video_enc_params.c b/media/ffvpx/libavutil/video_enc_params.c index 635176ab91d0..54bfed0ed979 100644 --- a/media/ffvpx/libavutil/video_enc_params.c +++ b/media/ffvpx/libavutil/video_enc_params.c @@ -16,12 +16,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include #include "buffer.h" -#include "common.h" #include "frame.h" #include "mem.h" #include "video_enc_params.h" @@ -29,10 +27,14 @@ AVVideoEncParams *av_video_enc_params_alloc(enum AVVideoEncParamsType type, unsigned int nb_blocks, size_t *out_size) { + const size_t blocks_offset = offsetof( + struct { + AVVideoEncParams p; + AVVideoBlockParams b; + }, b); + size_t size = blocks_offset; AVVideoEncParams *par; - size_t size; - size = sizeof(*par); if (nb_blocks > (SIZE_MAX - size) / sizeof(AVVideoBlockParams)) return NULL; size += sizeof(AVVideoBlockParams) * nb_blocks; @@ -44,7 +46,7 @@ AVVideoEncParams *av_video_enc_params_alloc(enum AVVideoEncParamsType type, par->type = type; par->nb_blocks = nb_blocks; par->block_size = sizeof(AVVideoBlockParams); - par->blocks_offset = sizeof(*par); + par->blocks_offset = blocks_offset; if (out_size) *out_size = size; @@ -63,10 +65,6 @@ av_video_enc_params_create_side_data(AVFrame *frame, enum AVVideoEncParamsType t par = av_video_enc_params_alloc(type, nb_blocks, &size); if (!par) return NULL; - if (size > INT_MAX) { - av_free(par); - return NULL; - } buf = av_buffer_create((uint8_t *)par, size, NULL, NULL, 0); if (!buf) { av_freep(&par); diff --git a/media/ffvpx/libavutil/x86/cpu.c b/media/ffvpx/libavutil/x86/cpu.c index bcd41a50a232..d6cd4fab9c98 100644 --- a/media/ffvpx/libavutil/x86/cpu.c +++ b/media/ffvpx/libavutil/x86/cpu.c @@ -150,9 +150,13 @@ int ff_get_cpu_flags_x86(void) rval |= AV_CPU_FLAG_AVX2; #if HAVE_AVX512 /* F, CD, BW, DQ, VL */ if ((xcr0_lo & 0xe0) == 0xe0) { /* OPMASK/ZMM state */ - if ((rval & AV_CPU_FLAG_AVX2) && (ebx & 0xd0030000) == 0xd0030000) + if ((rval & AV_CPU_FLAG_AVX2) && (ebx & 0xd0030000) == 0xd0030000) { rval |= AV_CPU_FLAG_AVX512; - +#if HAVE_AVX512ICL + if ((ebx & 0xd0200000) == 0xd0200000 && (ecx & 0x5f42) == 0x5f42) + rval |= AV_CPU_FLAG_AVX512ICL; +#endif /* HAVE_AVX512ICL */ + } } #endif /* HAVE_AVX512 */ #endif /* HAVE_AVX2 */ @@ -196,6 +200,10 @@ int ff_get_cpu_flags_x86(void) used unless explicitly disabled by checking AV_CPU_FLAG_AVXSLOW. */ if ((family == 0x15 || family == 0x16) && (rval & AV_CPU_FLAG_AVX)) rval |= AV_CPU_FLAG_AVXSLOW; + + /* Zen 3 and earlier have slow gather */ + if ((family <= 0x19) && (rval & AV_CPU_FLAG_AVX2)) + rval |= AV_CPU_FLAG_SLOW_GATHER; } /* XOP and FMA4 use the AVX instruction coding scheme, so they can't be @@ -235,6 +243,10 @@ int ff_get_cpu_flags_x86(void) if ((rval & AV_CPU_FLAG_SSSE3) && !(rval & AV_CPU_FLAG_SSE4) && family == 6 && model < 23) rval |= AV_CPU_FLAG_SSSE3SLOW; + + /* Haswell has slow gather */ + if ((rval & AV_CPU_FLAG_AVX2) && family == 6 && model < 70) + rval |= AV_CPU_FLAG_SLOW_GATHER; } #endif /* cpuid */ diff --git a/media/ffvpx/libavutil/x86/cpu.h b/media/ffvpx/libavutil/x86/cpu.h index 937c697fa0ea..40a1eef0abee 100644 --- a/media/ffvpx/libavutil/x86/cpu.h +++ b/media/ffvpx/libavutil/x86/cpu.h @@ -80,6 +80,7 @@ #define EXTERNAL_AVX2_SLOW(flags) CPUEXT_SUFFIX_SLOW2(flags, _EXTERNAL, AVX2, AVX) #define EXTERNAL_AESNI(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AESNI) #define EXTERNAL_AVX512(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX512) +#define EXTERNAL_AVX512ICL(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX512ICL) #define INLINE_AMD3DNOW(flags) CPUEXT_SUFFIX(flags, _INLINE, AMD3DNOW) #define INLINE_AMD3DNOWEXT(flags) CPUEXT_SUFFIX(flags, _INLINE, AMD3DNOWEXT) diff --git a/media/ffvpx/libavutil/x86/cpuid.asm b/media/ffvpx/libavutil/x86/cpuid.asm index c3f7866ec78f..766f77fcdfe2 100644 --- a/media/ffvpx/libavutil/x86/cpuid.asm +++ b/media/ffvpx/libavutil/x86/cpuid.asm @@ -21,7 +21,7 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86util.asm" +%include "libavutil/x86/x86util.asm" SECTION .text diff --git a/media/ffvpx/libavutil/x86/emms.asm b/media/ffvpx/libavutil/x86/emms.asm index 8611762d7374..df84f2221bda 100644 --- a/media/ffvpx/libavutil/x86/emms.asm +++ b/media/ffvpx/libavutil/x86/emms.asm @@ -18,7 +18,7 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86util.asm" +%include "libavutil/x86/x86util.asm" SECTION .text diff --git a/media/ffvpx/libavutil/x86/emms.h b/media/ffvpx/libavutil/x86/emms.h index c21e34b4510a..8ceec110cf65 100644 --- a/media/ffvpx/libavutil/x86/emms.h +++ b/media/ffvpx/libavutil/x86/emms.h @@ -21,11 +21,14 @@ #include "config.h" #include "libavutil/attributes.h" -#include "libavutil/cpu.h" void avpriv_emms_asm(void); #if HAVE_MMX_INLINE +#ifndef __MMX__ +#include "libavutil/cpu.h" +#endif + # define emms_c emms_c /** * Empty mmx state. diff --git a/media/ffvpx/libavutil/x86/fixed_dsp.asm b/media/ffvpx/libavutil/x86/fixed_dsp.asm index 979dd5c33416..2f411850f456 100644 --- a/media/ffvpx/libavutil/x86/fixed_dsp.asm +++ b/media/ffvpx/libavutil/x86/fixed_dsp.asm @@ -20,7 +20,7 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86util.asm" +%include "libavutil/x86/x86util.asm" SECTION .text diff --git a/media/ffvpx/libavutil/x86/float_dsp.asm b/media/ffvpx/libavutil/x86/float_dsp.asm index 517fd63638dd..cca4d019c7e7 100644 --- a/media/ffvpx/libavutil/x86/float_dsp.asm +++ b/media/ffvpx/libavutil/x86/float_dsp.asm @@ -20,7 +20,7 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86util.asm" +%include "libavutil/x86/x86util.asm" SECTION_RODATA 32 pd_reverse: dd 7, 6, 5, 4, 3, 2, 1, 0 @@ -294,7 +294,7 @@ VECTOR_DMUL_SCALAR ; vector_fmul_window(float *dst, const float *src0, ; const float *src1, const float *win, int len); ;----------------------------------------------------------------------------- -%macro VECTOR_FMUL_WINDOW 0 +INIT_XMM sse cglobal vector_fmul_window, 5, 6, 6, dst, src0, src1, win, len, len1 shl lend, 2 lea len1q, [lenq - mmsize] @@ -305,7 +305,6 @@ cglobal vector_fmul_window, 5, 6, 6, dst, src0, src1, win, len, len1 .loop: mova m0, [winq + lenq] mova m4, [src0q + lenq] -%if cpuflag(sse) mova m1, [winq + len1q] mova m5, [src1q + len1q] shufps m1, m1, 0x1b @@ -319,34 +318,12 @@ cglobal vector_fmul_window, 5, 6, 6, dst, src0, src1, win, len, len1 addps m2, m3 subps m1, m0 shufps m2, m2, 0x1b -%else - pswapd m1, [winq + len1q] - pswapd m5, [src1q + len1q] - mova m2, m0 - mova m3, m1 - pfmul m2, m4 - pfmul m3, m5 - pfmul m1, m4 - pfmul m0, m5 - pfadd m2, m3 - pfsub m1, m0 - pswapd m2, m2 -%endif mova [dstq + lenq], m1 mova [dstq + len1q], m2 sub len1q, mmsize add lenq, mmsize jl .loop -%if mmsize == 8 - femms -%endif REP_RET -%endmacro - -INIT_MMX 3dnowext -VECTOR_FMUL_WINDOW -INIT_XMM sse -VECTOR_FMUL_WINDOW ;----------------------------------------------------------------------------- ; vector_fmul_add(float *dst, const float *src0, const float *src1, diff --git a/media/ffvpx/libavutil/x86/float_dsp_init.c b/media/ffvpx/libavutil/x86/float_dsp_init.c index 8826e4e2c985..ad17bc204449 100644 --- a/media/ffvpx/libavutil/x86/float_dsp_init.c +++ b/media/ffvpx/libavutil/x86/float_dsp_init.c @@ -56,8 +56,6 @@ void ff_vector_dmul_scalar_sse2(double *dst, const double *src, void ff_vector_dmul_scalar_avx(double *dst, const double *src, double mul, int len); -void ff_vector_fmul_window_3dnowext(float *dst, const float *src0, - const float *src1, const float *win, int len); void ff_vector_fmul_window_sse(float *dst, const float *src0, const float *src1, const float *win, int len); @@ -83,9 +81,6 @@ av_cold void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp) { int cpu_flags = av_get_cpu_flags(); - if (EXTERNAL_AMD3DNOWEXT(cpu_flags)) { - fdsp->vector_fmul_window = ff_vector_fmul_window_3dnowext; - } if (EXTERNAL_SSE(cpu_flags)) { fdsp->vector_fmul = ff_vector_fmul_sse; fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_sse; diff --git a/media/ffvpx/libavutil/x86/imgutils_init.c b/media/ffvpx/libavutil/x86/imgutils_init.c index 4ea398205e03..91a16cf594b0 100644 --- a/media/ffvpx/libavutil/x86/imgutils_init.c +++ b/media/ffvpx/libavutil/x86/imgutils_init.c @@ -21,9 +21,8 @@ #include "libavutil/cpu.h" #include "libavutil/error.h" -#include "libavutil/imgutils.h" #include "libavutil/imgutils_internal.h" -#include "libavutil/internal.h" +#include "libavutil/macros.h" #include "cpu.h" diff --git a/media/ffvpx/libavutil/x86/intmath.h b/media/ffvpx/libavutil/x86/intmath.h index 40743fd13ef2..8a6b5ae26135 100644 --- a/media/ffvpx/libavutil/x86/intmath.h +++ b/media/ffvpx/libavutil/x86/intmath.h @@ -110,8 +110,8 @@ static av_always_inline av_const double av_clipd_sse2(double a, double amin, dou #if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 if (amin > amax) abort(); #endif - __asm__ ("minsd %2, %0 \n\t" - "maxsd %1, %0 \n\t" + __asm__ ("maxsd %1, %0 \n\t" + "minsd %2, %0 \n\t" : "+&x"(a) : "xm"(amin), "xm"(amax)); return a; } @@ -126,14 +126,44 @@ static av_always_inline av_const float av_clipf_sse(float a, float amin, float a #if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 if (amin > amax) abort(); #endif - __asm__ ("minss %2, %0 \n\t" - "maxss %1, %0 \n\t" + __asm__ ("maxss %1, %0 \n\t" + "minss %2, %0 \n\t" : "+&x"(a) : "xm"(amin), "xm"(amax)); return a; } #endif /* __SSE__ */ +#if defined(__AVX__) && !defined(__INTEL_COMPILER) + +#undef av_clipd +#define av_clipd av_clipd_avx +static av_always_inline av_const double av_clipd_avx(double a, double amin, double amax) +{ +#if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 + if (amin > amax) abort(); +#endif + __asm__ ("vmaxsd %1, %0, %0 \n\t" + "vminsd %2, %0, %0 \n\t" + : "+&x"(a) : "xm"(amin), "xm"(amax)); + return a; +} + +#undef av_clipf +#define av_clipf av_clipf_avx +static av_always_inline av_const float av_clipf_avx(float a, float amin, float amax) +{ +#if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 + if (amin > amax) abort(); +#endif + __asm__ ("vmaxss %1, %0, %0 \n\t" + "vminss %2, %0, %0 \n\t" + : "+&x"(a) : "xm"(amin), "xm"(amax)); + return a; +} + +#endif /* __AVX__ */ + #endif /* __GNUC__ */ #endif /* AVUTIL_X86_INTMATH_H */ diff --git a/media/ffvpx/libavutil/x86/lls.asm b/media/ffvpx/libavutil/x86/lls.asm index 317fba6fca1c..d2526d1ff487 100644 --- a/media/ffvpx/libavutil/x86/lls.asm +++ b/media/ffvpx/libavutil/x86/lls.asm @@ -20,7 +20,7 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86util.asm" +%include "libavutil/x86/x86util.asm" SECTION .text diff --git a/media/ffvpx/libavutil/x86/lls_init.c b/media/ffvpx/libavutil/x86/lls_init.c index 1c5dca42dc08..c786376915dc 100644 --- a/media/ffvpx/libavutil/x86/lls_init.c +++ b/media/ffvpx/libavutil/x86/lls_init.c @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/attributes.h" #include "libavutil/lls.h" #include "libavutil/x86/cpu.h" diff --git a/media/ffvpx/libavutil/x86/pixelutils.asm b/media/ffvpx/libavutil/x86/pixelutils.asm index 36c57c5f7fa9..fbe9b45971bd 100644 --- a/media/ffvpx/libavutil/x86/pixelutils.asm +++ b/media/ffvpx/libavutil/x86/pixelutils.asm @@ -21,48 +21,10 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86util.asm" +%include "libavutil/x86/x86util.asm" SECTION .text -;------------------------------------------------------------------------------- -; int ff_pixelutils_sad_8x8_mmx(const uint8_t *src1, ptrdiff_t stride1, -; const uint8_t *src2, ptrdiff_t stride2); -;------------------------------------------------------------------------------- -INIT_MMX mmx -cglobal pixelutils_sad_8x8, 4,4,0, src1, stride1, src2, stride2 - pxor m7, m7 - pxor m6, m6 -%rep 4 - mova m0, [src1q] - mova m2, [src1q + stride1q] - mova m1, [src2q] - mova m3, [src2q + stride2q] - psubusb m4, m0, m1 - psubusb m5, m2, m3 - psubusb m1, m0 - psubusb m3, m2 - por m1, m4 - por m3, m5 - punpcklbw m0, m1, m7 - punpcklbw m2, m3, m7 - punpckhbw m1, m7 - punpckhbw m3, m7 - paddw m0, m1 - paddw m2, m3 - paddw m0, m2 - paddw m6, m0 - lea src1q, [src1q + 2*stride1q] - lea src2q, [src2q + 2*stride2q] -%endrep - psrlq m0, m6, 32 - paddw m6, m0 - psrlq m0, m6, 16 - paddw m6, m0 - movd eax, m6 - movzx eax, ax - RET - ;------------------------------------------------------------------------------- ; int ff_pixelutils_sad_8x8_mmxext(const uint8_t *src1, ptrdiff_t stride1, ; const uint8_t *src2, ptrdiff_t stride2); @@ -83,26 +45,6 @@ cglobal pixelutils_sad_8x8, 4,4,0, src1, stride1, src2, stride2 movd eax, m2 RET -;------------------------------------------------------------------------------- -; int ff_pixelutils_sad_16x16_mmxext(const uint8_t *src1, ptrdiff_t stride1, -; const uint8_t *src2, ptrdiff_t stride2); -;------------------------------------------------------------------------------- -INIT_MMX mmxext -cglobal pixelutils_sad_16x16, 4,4,0, src1, stride1, src2, stride2 - pxor m2, m2 -%rep 16 - mova m0, [src1q] - mova m1, [src1q + 8] - psadbw m0, [src2q] - psadbw m1, [src2q + 8] - paddw m2, m0 - paddw m2, m1 - add src1q, stride1q - add src2q, stride2q -%endrep - movd eax, m2 - RET - ;------------------------------------------------------------------------------- ; int ff_pixelutils_sad_16x16_sse2(const uint8_t *src1, ptrdiff_t stride1, ; const uint8_t *src2, ptrdiff_t stride2); diff --git a/media/ffvpx/libavutil/x86/pixelutils_init.c b/media/ffvpx/libavutil/x86/pixelutils_init.c index 184a3a4a9fc8..c3c066241413 100644 --- a/media/ffvpx/libavutil/x86/pixelutils_init.c +++ b/media/ffvpx/libavutil/x86/pixelutils_init.c @@ -21,13 +21,9 @@ #include "pixelutils.h" #include "cpu.h" -int ff_pixelutils_sad_8x8_mmx(const uint8_t *src1, ptrdiff_t stride1, - const uint8_t *src2, ptrdiff_t stride2); int ff_pixelutils_sad_8x8_mmxext(const uint8_t *src1, ptrdiff_t stride1, const uint8_t *src2, ptrdiff_t stride2); -int ff_pixelutils_sad_16x16_mmxext(const uint8_t *src1, ptrdiff_t stride1, - const uint8_t *src2, ptrdiff_t stride2); int ff_pixelutils_sad_16x16_sse2(const uint8_t *src1, ptrdiff_t stride1, const uint8_t *src2, ptrdiff_t stride2); int ff_pixelutils_sad_a_16x16_sse2(const uint8_t *src1, ptrdiff_t stride1, @@ -53,10 +49,6 @@ void ff_pixelutils_sad_init_x86(av_pixelutils_sad_fn *sad, int aligned) { int cpu_flags = av_get_cpu_flags(); - if (EXTERNAL_MMX(cpu_flags)) { - sad[2] = ff_pixelutils_sad_8x8_mmx; - } - // The best way to use SSE2 would be to do 2 SADs in parallel, // but we'd have to modify the pixelutils API to return SIMD functions. @@ -65,7 +57,6 @@ void ff_pixelutils_sad_init_x86(av_pixelutils_sad_fn *sad, int aligned) // so just use the MMX 8x8 version even when SSE2 is available. if (EXTERNAL_MMXEXT(cpu_flags)) { sad[2] = ff_pixelutils_sad_8x8_mmxext; - sad[3] = ff_pixelutils_sad_16x16_mmxext; } if (EXTERNAL_SSE2(cpu_flags)) { diff --git a/media/ffvpx/libavutil/x86/x86inc.asm b/media/ffvpx/libavutil/x86/x86inc.asm index 01c35e3a4b00..251ee797decb 100644 --- a/media/ffvpx/libavutil/x86/x86inc.asm +++ b/media/ffvpx/libavutil/x86/x86inc.asm @@ -817,32 +817,33 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, jge, jng, jnge, ja, jae, ; cpuflags -%assign cpuflags_mmx (1<<0) -%assign cpuflags_mmx2 (1<<1) | cpuflags_mmx -%assign cpuflags_3dnow (1<<2) | cpuflags_mmx -%assign cpuflags_3dnowext (1<<3) | cpuflags_3dnow -%assign cpuflags_sse (1<<4) | cpuflags_mmx2 -%assign cpuflags_sse2 (1<<5) | cpuflags_sse -%assign cpuflags_sse2slow (1<<6) | cpuflags_sse2 -%assign cpuflags_lzcnt (1<<7) | cpuflags_sse2 -%assign cpuflags_sse3 (1<<8) | cpuflags_sse2 -%assign cpuflags_ssse3 (1<<9) | cpuflags_sse3 -%assign cpuflags_sse4 (1<<10)| cpuflags_ssse3 -%assign cpuflags_sse42 (1<<11)| cpuflags_sse4 -%assign cpuflags_aesni (1<<12)| cpuflags_sse42 -%assign cpuflags_avx (1<<13)| cpuflags_sse42 -%assign cpuflags_xop (1<<14)| cpuflags_avx -%assign cpuflags_fma4 (1<<15)| cpuflags_avx -%assign cpuflags_fma3 (1<<16)| cpuflags_avx -%assign cpuflags_bmi1 (1<<17)| cpuflags_avx|cpuflags_lzcnt -%assign cpuflags_bmi2 (1<<18)| cpuflags_bmi1 -%assign cpuflags_avx2 (1<<19)| cpuflags_fma3|cpuflags_bmi2 -%assign cpuflags_avx512 (1<<20)| cpuflags_avx2 ; F, CD, BW, DQ, VL +%assign cpuflags_mmx (1<<0) +%assign cpuflags_mmx2 (1<<1) | cpuflags_mmx +%assign cpuflags_3dnow (1<<2) | cpuflags_mmx +%assign cpuflags_3dnowext (1<<3) | cpuflags_3dnow +%assign cpuflags_sse (1<<4) | cpuflags_mmx2 +%assign cpuflags_sse2 (1<<5) | cpuflags_sse +%assign cpuflags_sse2slow (1<<6) | cpuflags_sse2 +%assign cpuflags_lzcnt (1<<7) | cpuflags_sse2 +%assign cpuflags_sse3 (1<<8) | cpuflags_sse2 +%assign cpuflags_ssse3 (1<<9) | cpuflags_sse3 +%assign cpuflags_sse4 (1<<10)| cpuflags_ssse3 +%assign cpuflags_sse42 (1<<11)| cpuflags_sse4 +%assign cpuflags_aesni (1<<12)| cpuflags_sse42 +%assign cpuflags_avx (1<<13)| cpuflags_sse42 +%assign cpuflags_xop (1<<14)| cpuflags_avx +%assign cpuflags_fma4 (1<<15)| cpuflags_avx +%assign cpuflags_fma3 (1<<16)| cpuflags_avx +%assign cpuflags_bmi1 (1<<17)| cpuflags_avx|cpuflags_lzcnt +%assign cpuflags_bmi2 (1<<18)| cpuflags_bmi1 +%assign cpuflags_avx2 (1<<19)| cpuflags_fma3|cpuflags_bmi2 +%assign cpuflags_avx512 (1<<20)| cpuflags_avx2 ; F, CD, BW, DQ, VL +%assign cpuflags_avx512icl (1<<25)| cpuflags_avx512 -%assign cpuflags_cache32 (1<<21) -%assign cpuflags_cache64 (1<<22) -%assign cpuflags_aligned (1<<23) ; not a cpu feature, but a function variant -%assign cpuflags_atom (1<<24) +%assign cpuflags_cache32 (1<<21) +%assign cpuflags_cache64 (1<<22) +%assign cpuflags_aligned (1<<23) ; not a cpu feature, but a function variant +%assign cpuflags_atom (1<<24) ; Returns a boolean value expressing whether or not the specified cpuflag is enabled. %define cpuflag(x) (((((cpuflags & (cpuflags_ %+ x)) ^ (cpuflags_ %+ x)) - 1) >> 31) & 1)