From 434b1cead1897ee79091d621d1ca4240c199c38c Mon Sep 17 00:00:00 2001 From: v0lt Date: Wed, 20 Mar 2024 22:27:51 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20ffmpeg=20git-n6.2-dev-1752-gd7d2213a6b.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/Changelog.Rus.txt | 2 +- docs/Changelog.txt | 2 +- .../ffmpeg/libavcodec/aacpsdsp_template.c | 10 +- src/ExtLib/ffmpeg/libavcodec/ac3tab.h | 16 -- src/ExtLib/ffmpeg/libavcodec/av1dec.c | 12 +- src/ExtLib/ffmpeg/libavcodec/avcodec.h | 13 ++ src/ExtLib/ffmpeg/libavcodec/binkdsp.c | 3 +- src/ExtLib/ffmpeg/libavcodec/binkdsp.h | 4 +- src/ExtLib/ffmpeg/libavcodec/dirac_arith.h | 4 + src/ExtLib/ffmpeg/libavcodec/dvdec.c | 2 +- src/ExtLib/ffmpeg/libavcodec/h2645_sei.c | 10 +- .../ffmpeg/libavcodec/h264qpel_template.c | 82 +++---- src/ExtLib/ffmpeg/libavcodec/idctdsp.c | 14 +- src/ExtLib/ffmpeg/libavcodec/idctdsp.h | 12 +- src/ExtLib/ffmpeg/libavcodec/itut35.h | 30 +++ src/ExtLib/ffmpeg/libavcodec/libdav1d.c | 12 +- src/ExtLib/ffmpeg/libavcodec/mpeg12dec.c | 64 ++++- src/ExtLib/ffmpeg/libavcodec/mpegaudiodata.h | 3 + .../ffmpeg/libavcodec/mpegaudiodec_template.c | 2 +- src/ExtLib/ffmpeg/libavcodec/mpegaudiodsp.h | 3 + src/ExtLib/ffmpeg/libavcodec/options.c | 2 + src/ExtLib/ffmpeg/libavcodec/opus_pvq.c | 2 +- src/ExtLib/ffmpeg/libavcodec/pixblockdsp.c | 6 +- src/ExtLib/ffmpeg/libavcodec/pixblockdsp.h | 10 +- src/ExtLib/ffmpeg/libavcodec/utils.c | 4 +- src/ExtLib/ffmpeg/libavcodec/version.h | 4 +- src/ExtLib/ffmpeg/libavcodec/vorbis_data.h | 3 + src/ExtLib/ffmpeg/libavcodec/vvc/vvc_ctu.c | 2 +- src/ExtLib/ffmpeg/libavutil/channel_layout.c | 220 +++++++++--------- src/ExtLib/ffmpeg/libavutil/channel_layout.h | 15 +- src/ExtLib/ffmpeg/libavutil/fixed_dsp.c | 2 +- src/ExtLib/ffmpeg/libavutil/fixed_dsp.h | 3 +- src/ExtLib/ffmpeg/libavutil/float_dsp.c | 2 +- src/ExtLib/ffmpeg/libavutil/float_dsp.h | 4 +- src/ExtLib/ffmpeg/libavutil/frame.c | 163 ++++++++++--- src/ExtLib/ffmpeg/libavutil/frame.h | 67 ++++++ .../ffmpeg/libavutil/hwcontext_d3d11va.c | 24 +- src/ExtLib/ffmpeg/libavutil/version.h | 2 +- .../ffmpeg/libavutil/x86/fixed_dsp_init.c | 4 +- .../ffmpeg/libavutil/x86/float_dsp_init.c | 5 +- src/ExtLib/ffmpeg/libavutil/x86/x86util.asm | 4 - src/ExtLib/ffmpeg/libswscale/x86/scale.asm | 5 - 42 files changed, 557 insertions(+), 296 deletions(-) create mode 100644 src/ExtLib/ffmpeg/libavcodec/itut35.h diff --git a/docs/Changelog.Rus.txt b/docs/Changelog.Rus.txt index 6b3c4dcdcd..470763fcfd 100644 --- a/docs/Changelog.Rus.txt +++ b/docs/Changelog.Rus.txt @@ -59,7 +59,7 @@ MPC Video Renderer 0.7.3 включен в инсталлятор. Обновлены библиотеки: dav1d git-1.4.0-83-g872e470; fdk-aac git-v2.0.3; - ffmpeg git-n6.2-dev-1636-g53a51e70f2; + ffmpeg git-n6.2-dev-1752-gd7d2213a6b; Little-CMS git-lcms2.16-41-gfcf6792; MediaInfo git-v24.01-19-gb7bb56e8d; nanosvg git-93ce879; diff --git a/docs/Changelog.txt b/docs/Changelog.txt index 051cd96dcd..14f2d76adf 100644 --- a/docs/Changelog.txt +++ b/docs/Changelog.txt @@ -59,7 +59,7 @@ Updated German translation (by Klaus1189). Updated libraries: dav1d git-1.4.0-83-g872e470; fdk-aac git-v2.0.3; - ffmpeg git-n6.2-dev-1636-g53a51e70f2; + ffmpeg git-n6.2-dev-1752-gd7d2213a6b; Little-CMS git-lcms2.16-41-gfcf6792; MediaInfo git-v24.01-19-gb7bb56e8d; nanosvg git-93ce879; diff --git a/src/ExtLib/ffmpeg/libavcodec/aacpsdsp_template.c b/src/ExtLib/ffmpeg/libavcodec/aacpsdsp_template.c index cd718e3a60..8f518e10ff 100644 --- a/src/ExtLib/ffmpeg/libavcodec/aacpsdsp_template.c +++ b/src/ExtLib/ffmpeg/libavcodec/aacpsdsp_template.c @@ -26,14 +26,14 @@ #include "libavutil/attributes.h" #include "aacpsdsp.h" -static void ps_add_squares_c(INTFLOAT *av_restrict dst, +static void ps_add_squares_c(INTFLOAT *restrict dst, const INTFLOAT (*src)[2], int n) { for (int i = 0; i < n; i++) dst[i] += (UINTFLOAT)AAC_MADD28(src[i][0], src[i][0], src[i][1], src[i][1]); } -static void ps_mul_pair_single_c(INTFLOAT (*av_restrict dst)[2], +static void ps_mul_pair_single_c(INTFLOAT (*restrict dst)[2], INTFLOAT (*src0)[2], INTFLOAT *src1, int n) { @@ -43,7 +43,7 @@ static void ps_mul_pair_single_c(INTFLOAT (*av_restrict dst)[2], } } -static void ps_hybrid_analysis_c(INTFLOAT (*av_restrict out)[2], +static void ps_hybrid_analysis_c(INTFLOAT (*restrict out)[2], INTFLOAT (*in)[2], const INTFLOAT (*filter)[8][2], ptrdiff_t stride, int n) @@ -77,7 +77,7 @@ static void ps_hybrid_analysis_c(INTFLOAT (*av_restrict out)[2], } } -static void ps_hybrid_analysis_ileave_c(INTFLOAT (*av_restrict out)[32][2], +static void ps_hybrid_analysis_ileave_c(INTFLOAT (*restrict out)[32][2], INTFLOAT L[2][38][64], int i, int len) { @@ -90,7 +90,7 @@ static void ps_hybrid_analysis_ileave_c(INTFLOAT (*av_restrict out)[32][2], } static void ps_hybrid_synthesis_deint_c(INTFLOAT out[2][38][64], - INTFLOAT (*av_restrict in)[32][2], + INTFLOAT (*restrict in)[32][2], int i, int len) { for (; i < 64; i++) { diff --git a/src/ExtLib/ffmpeg/libavcodec/ac3tab.h b/src/ExtLib/ffmpeg/libavcodec/ac3tab.h index d9d3bef2ef..4ef06de0d3 100644 --- a/src/ExtLib/ffmpeg/libavcodec/ac3tab.h +++ b/src/ExtLib/ffmpeg/libavcodec/ac3tab.h @@ -45,22 +45,6 @@ extern const uint8_t ff_ac3_band_start_tab[AC3_CRITICAL_BANDS+1]; extern const uint8_t ff_ac3_bin_to_band_tab[253]; extern const uint64_t ff_eac3_custom_channel_map_locations[16][2]; - -/** Custom channel map locations bitmask - * Other channels described in documentation: - * Lc/Rc pair, Lrs/Rrs pair, Ts, Lsd/Rsd pair, - * Lw/Rw pair, Lvh/Rvh pair, Cvh, Reserved, LFE2 - */ -enum CustomChannelMapLocation{ - AC3_CHMAP_L= 1<<(15-0), - AC3_CHMAP_C= 1<<(15-1), - AC3_CHMAP_R= 1<<(15-2), - AC3_CHMAP_L_SUR= 1<<(15-3), - AC3_CHMAP_R_SUR = 1<<(15-4), - AC3_CHMAP_C_SUR= 1<<(15-7), - AC3_CHMAP_LFE = 1<<(15-15) -}; - #define COMMON_CHANNEL_MAP \ { { 0, 1, }, { 0, 1, 2, } },\ { { 0, }, { 0, 1, } },\ diff --git a/src/ExtLib/ffmpeg/libavcodec/av1dec.c b/src/ExtLib/ffmpeg/libavcodec/av1dec.c index e6346b51db..4d074c3908 100644 --- a/src/ExtLib/ffmpeg/libavcodec/av1dec.c +++ b/src/ExtLib/ffmpeg/libavcodec/av1dec.c @@ -34,6 +34,7 @@ #include "decode.h" #include "hwaccel_internal.h" #include "internal.h" +#include "itut35.h" #include "hwconfig.h" #include "profiles.h" #include "refstruct.h" @@ -951,7 +952,7 @@ static int export_itut_t35(AVCodecContext *avctx, AVFrame *frame, provider_code = bytestream2_get_be16(&gb); switch (provider_code) { - case 0x31: { // atsc_provider_code + case ITU_T_T35_PROVIDER_CODE_ATSC: { uint32_t user_identifier = bytestream2_get_be32(&gb); switch (user_identifier) { case MKBETAG('G', 'A', '9', '4'): { // closed captions @@ -975,12 +976,12 @@ static int export_itut_t35(AVCodecContext *avctx, AVFrame *frame, } break; } - case 0x3C: { // smpte_provider_code + case ITU_T_T35_PROVIDER_CODE_SMTPE: { AVDynamicHDRPlus *hdrplus; int provider_oriented_code = bytestream2_get_be16(&gb); int application_identifier = bytestream2_get_byte(&gb); - if (itut_t35->itu_t_t35_country_code != 0xB5 || + if (itut_t35->itu_t_t35_country_code != ITU_T_T35_COUNTRY_CODE_US || provider_oriented_code != 1 || application_identifier != 4) break; @@ -994,9 +995,10 @@ static int export_itut_t35(AVCodecContext *avctx, AVFrame *frame, return ret; break; } - case 0x3B: { // dolby_provider_code + case ITU_T_T35_PROVIDER_CODE_DOLBY: { int provider_oriented_code = bytestream2_get_be32(&gb); - if (itut_t35->itu_t_t35_country_code != 0xB5 || provider_oriented_code != 0x800) + if (itut_t35->itu_t_t35_country_code != ITU_T_T35_COUNTRY_CODE_US || + provider_oriented_code != 0x800) break; ret = ff_dovi_rpu_parse(&s->dovi, gb.buffer, gb.buffer_end - gb.buffer); diff --git a/src/ExtLib/ffmpeg/libavcodec/avcodec.h b/src/ExtLib/ffmpeg/libavcodec/avcodec.h index 554501aa44..83dc487251 100644 --- a/src/ExtLib/ffmpeg/libavcodec/avcodec.h +++ b/src/ExtLib/ffmpeg/libavcodec/avcodec.h @@ -2062,6 +2062,19 @@ typedef struct AVCodecContext { * Number of entries in side_data_prefer_packet. */ unsigned nb_side_data_prefer_packet; + + /** + * Array containing static side data, such as HDR10 CLL / MDCV structures. + * Side data entries should be allocated by usage of helpers defined in + * libavutil/frame.h. + * + * - encoding: may be set by user before calling avcodec_open2() for + * encoder configuration. Afterwards owned and freed by the + * encoder. + * - decoding: unused + */ + AVFrameSideData **decoded_side_data; + int nb_decoded_side_data; } AVCodecContext; /** diff --git a/src/ExtLib/ffmpeg/libavcodec/binkdsp.c b/src/ExtLib/ffmpeg/libavcodec/binkdsp.c index a357d31672..166dca1ba1 100644 --- a/src/ExtLib/ffmpeg/libavcodec/binkdsp.c +++ b/src/ExtLib/ffmpeg/libavcodec/binkdsp.c @@ -24,7 +24,6 @@ * Bink DSP routines */ -#include "config.h" #include "libavutil/attributes.h" #include "binkdsp.h" @@ -131,7 +130,7 @@ static void scale_block_c(const uint8_t src[64]/*align 8*/, uint8_t *dst/*align } } -static void add_pixels8_c(uint8_t *av_restrict pixels, int16_t *block, +static void add_pixels8_c(uint8_t *restrict pixels, int16_t *block, int line_size) { int i; diff --git a/src/ExtLib/ffmpeg/libavcodec/binkdsp.h b/src/ExtLib/ffmpeg/libavcodec/binkdsp.h index b089a9863f..8f084ec259 100644 --- a/src/ExtLib/ffmpeg/libavcodec/binkdsp.h +++ b/src/ExtLib/ffmpeg/libavcodec/binkdsp.h @@ -29,13 +29,11 @@ #include -#include "config.h" - typedef struct BinkDSPContext { void (*idct_put)(uint8_t *dest/*align 8*/, int line_size, int32_t *block/*align 16*/); void (*idct_add)(uint8_t *dest/*align 8*/, int line_size, int32_t *block/*align 16*/); void (*scale_block)(const uint8_t src[64]/*align 8*/, uint8_t *dst/*align 8*/, int linesize); - void (*add_pixels8)(uint8_t *av_restrict pixels, int16_t *block, int line_size); + void (*add_pixels8)(uint8_t *restrict pixels, int16_t *block, int line_size); } BinkDSPContext; void ff_binkdsp_init(BinkDSPContext *c); diff --git a/src/ExtLib/ffmpeg/libavcodec/dirac_arith.h b/src/ExtLib/ffmpeg/libavcodec/dirac_arith.h index 350a58fca6..203d481603 100644 --- a/src/ExtLib/ffmpeg/libavcodec/dirac_arith.h +++ b/src/ExtLib/ffmpeg/libavcodec/dirac_arith.h @@ -28,7 +28,11 @@ #ifndef AVCODEC_DIRAC_ARITH_H #define AVCODEC_DIRAC_ARITH_H +#include "config.h" + +#if ARCH_X86 #include "libavutil/x86/asm.h" +#endif #include "bytestream.h" #include "get_bits.h" diff --git a/src/ExtLib/ffmpeg/libavcodec/dvdec.c b/src/ExtLib/ffmpeg/libavcodec/dvdec.c index f66a5f1a05..a06e4807e7 100644 --- a/src/ExtLib/ffmpeg/libavcodec/dvdec.c +++ b/src/ExtLib/ffmpeg/libavcodec/dvdec.c @@ -346,7 +346,7 @@ static inline void bit_copy(PutBitContext *pb, GetBitContext *gb) put_bits(pb, bits_left, get_bits(gb, bits_left)); } -static av_always_inline void put_block_8x4(int16_t *block, uint8_t *av_restrict p, int stride) +static av_always_inline void put_block_8x4(int16_t *block, uint8_t *restrict p, int stride) { int i, j; diff --git a/src/ExtLib/ffmpeg/libavcodec/h2645_sei.c b/src/ExtLib/ffmpeg/libavcodec/h2645_sei.c index e60606f43f..e8eb15524f 100644 --- a/src/ExtLib/ffmpeg/libavcodec/h2645_sei.c +++ b/src/ExtLib/ffmpeg/libavcodec/h2645_sei.c @@ -40,6 +40,7 @@ #include "get_bits.h" #include "golomb.h" #include "h2645_sei.h" +#include "itut35.h" #define IS_H264(codec_id) (CONFIG_H264_SEI && CONFIG_HEVC_SEI ? codec_id == AV_CODEC_ID_H264 : CONFIG_H264_SEI) #define IS_HEVC(codec_id) (CONFIG_H264_SEI && CONFIG_HEVC_SEI ? codec_id == AV_CODEC_ID_HEVC : CONFIG_HEVC_SEI) @@ -140,7 +141,8 @@ static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb, bytestream2_skipu(gb, 1); // itu_t_t35_country_code_extension_byte } - if (country_code != 0xB5 && country_code != 0x26) { // usa_country_code and cn_country_code + if (country_code != ITU_T_T35_COUNTRY_CODE_US && + country_code != ITU_T_T35_COUNTRY_CODE_CN) { av_log(logctx, AV_LOG_VERBOSE, "Unsupported User Data Registered ITU-T T35 SEI message (country_code = %d)\n", country_code); @@ -151,7 +153,7 @@ static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb, provider_code = bytestream2_get_be16u(gb); switch (provider_code) { - case 0x31: { // atsc_provider_code + case ITU_T_T35_PROVIDER_CODE_ATSC: { uint32_t user_identifier; if (bytestream2_get_bytes_left(gb) < 4) @@ -172,7 +174,7 @@ static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb, break; } #if CONFIG_HEVC_SEI - case 0x04: { // cuva_provider_code + case ITU_T_T35_PROVIDER_CODE_CUVA: { const uint16_t cuva_provider_oriented_code = 0x0005; uint16_t provider_oriented_code; @@ -188,7 +190,7 @@ static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb, } break; } - case 0x3C: { // smpte_provider_code + case ITU_T_T35_PROVIDER_CODE_SMTPE: { // A/341 Amendment - 2094-40 const uint16_t smpte2094_40_provider_oriented_code = 0x0001; const uint8_t smpte2094_40_application_identifier = 0x04; diff --git a/src/ExtLib/ffmpeg/libavcodec/h264qpel_template.c b/src/ExtLib/ffmpeg/libavcodec/h264qpel_template.c index 61fa55c689..f7fabe4aaa 100644 --- a/src/ExtLib/ffmpeg/libavcodec/h264qpel_template.c +++ b/src/ExtLib/ffmpeg/libavcodec/h264qpel_template.c @@ -26,7 +26,7 @@ #include "hpel_template.c" #include "pel_template.c" -static inline void FUNC(copy_block2)(uint8_t *dst, const uint8_t *av_restrict src, int dstStride, int srcStride, int h) +static inline void FUNC(copy_block2)(uint8_t *dst, const uint8_t *restrict src, int dstStride, int srcStride, int h) { int i; for(i=0; i>= sizeof(pixel)-1;\ srcStride >>= sizeof(pixel)-1;\ for(i=0; i>= sizeof(pixel)-1;\ srcStride >>= sizeof(pixel)-1;\ for(i=0; i>= sizeof(pixel)-1;\ srcStride >>= sizeof(pixel)-1;\ src -= 2*srcStride;\ @@ -153,13 +153,13 @@ static av_unused void FUNC(OPNAME ## h264_qpel2_hv_lowpass)(uint8_t *_dst, pixel tmp++;\ }\ }\ -static void FUNC(OPNAME ## h264_qpel4_h_lowpass)(uint8_t *_dst, const uint8_t *av_restrict _src, int dstStride, int srcStride)\ +static void FUNC(OPNAME ## h264_qpel4_h_lowpass)(uint8_t *_dst, const uint8_t *restrict _src, int dstStride, int srcStride)\ {\ const int h=4;\ INIT_CLIP\ int i;\ pixel *dst = (pixel*)_dst;\ - const pixel *av_restrict src = (const pixel*)_src;\ + const pixel *restrict src = (const pixel*)_src;\ dstStride >>= sizeof(pixel)-1;\ srcStride >>= sizeof(pixel)-1;\ for(i=0; i>= sizeof(pixel)-1;\ srcStride >>= sizeof(pixel)-1;\ for(i=0; i>= sizeof(pixel)-1;\ srcStride >>= sizeof(pixel)-1;\ src -= 2*srcStride;\ @@ -244,13 +244,13 @@ static void FUNC(OPNAME ## h264_qpel4_hv_lowpass)(uint8_t *_dst, pixeltmp *tmp, }\ }\ \ -static void FUNC(OPNAME ## h264_qpel8_h_lowpass)(uint8_t *_dst, const uint8_t *av_restrict _src, int dstStride, int srcStride)\ +static void FUNC(OPNAME ## h264_qpel8_h_lowpass)(uint8_t *_dst, const uint8_t *restrict _src, int dstStride, int srcStride)\ {\ const int h=8;\ INIT_CLIP\ int i;\ pixel *dst = (pixel*)_dst;\ - const pixel *av_restrict src = (const pixel*)_src;\ + const pixel *restrict src = (const pixel*)_src;\ dstStride >>= sizeof(pixel)-1;\ srcStride >>= sizeof(pixel)-1;\ for(i=0; i>= sizeof(pixel)-1;\ srcStride >>= sizeof(pixel)-1;\ for(i=0; i>= sizeof(pixel)-1;\ srcStride >>= sizeof(pixel)-1;\ src -= 2*srcStride;\ @@ -359,7 +359,7 @@ static void FUNC(OPNAME ## h264_qpel8_hv_lowpass)(uint8_t *_dst, pixeltmp *tmp, }\ }\ \ -static void FUNC(OPNAME ## h264_qpel16_v_lowpass)(uint8_t *dst, const uint8_t *av_restrict src, int dstStride, int srcStride)\ +static void FUNC(OPNAME ## h264_qpel16_v_lowpass)(uint8_t *dst, const uint8_t *restrict src, int dstStride, int srcStride)\ {\ FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst , src , dstStride, srcStride);\ FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\ @@ -369,7 +369,7 @@ static void FUNC(OPNAME ## h264_qpel16_v_lowpass)(uint8_t *dst, const uint8_t *a FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\ }\ \ -static void FUNC(OPNAME ## h264_qpel16_h_lowpass)(uint8_t *dst, const uint8_t *av_restrict src, int dstStride, int srcStride)\ +static void FUNC(OPNAME ## h264_qpel16_h_lowpass)(uint8_t *dst, const uint8_t *restrict src, int dstStride, int srcStride)\ {\ FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst , src , dstStride, srcStride);\ FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\ @@ -379,7 +379,7 @@ static void FUNC(OPNAME ## h264_qpel16_h_lowpass)(uint8_t *dst, const uint8_t *a FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\ }\ \ -static void FUNC(OPNAME ## h264_qpel16_hv_lowpass)(uint8_t *dst, pixeltmp *tmp, const uint8_t *av_restrict src, int dstStride, int tmpStride, int srcStride){\ +static void FUNC(OPNAME ## h264_qpel16_hv_lowpass)(uint8_t *dst, pixeltmp *tmp, const uint8_t *restrict src, int dstStride, int tmpStride, int srcStride){\ FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst , tmp , src , dstStride, tmpStride, srcStride);\ FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst+8*sizeof(pixel), tmp+8, src+8*sizeof(pixel), dstStride, tmpStride, srcStride);\ src += 8*srcStride;\ @@ -389,31 +389,31 @@ static void FUNC(OPNAME ## h264_qpel16_hv_lowpass)(uint8_t *dst, pixeltmp *tmp, }\ #define H264_MC(OPNAME, SIZE) \ -static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc00)(uint8_t *dst, const uint8_t *av_restrict src, ptrdiff_t stride)\ +static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc00)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\ {\ FUNCC(OPNAME ## pixels ## SIZE)(dst, src, stride, SIZE);\ }\ \ -static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc10)(uint8_t *dst, const uint8_t *av_restrict src, ptrdiff_t stride)\ +static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc10)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\ {\ uint8_t half[SIZE*SIZE*sizeof(pixel)];\ FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\ FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src, half, stride, stride, SIZE*sizeof(pixel), SIZE);\ }\ \ -static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc20)(uint8_t *dst, const uint8_t *av_restrict src, ptrdiff_t stride)\ +static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc20)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\ {\ FUNC(OPNAME ## h264_qpel ## SIZE ## _h_lowpass)(dst, src, stride, stride);\ }\ \ -static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc30)(uint8_t *dst, const uint8_t *av_restrict src, ptrdiff_t stride)\ +static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc30)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\ {\ uint8_t half[SIZE*SIZE*sizeof(pixel)];\ FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\ FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src+sizeof(pixel), half, stride, stride, SIZE*sizeof(pixel), SIZE);\ }\ \ -static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc01)(uint8_t *dst, const uint8_t *av_restrict src, ptrdiff_t stride)\ +static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc01)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\ {\ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\ @@ -423,7 +423,7 @@ static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc01)(uint8_t *dst, const uint FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid, half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\ }\ \ -static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc02)(uint8_t *dst, const uint8_t *av_restrict src, ptrdiff_t stride)\ +static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc02)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\ {\ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\ @@ -431,7 +431,7 @@ static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc02)(uint8_t *dst, const uint FUNC(OPNAME ## h264_qpel ## SIZE ## _v_lowpass)(dst, full_mid, stride, SIZE*sizeof(pixel));\ }\ \ -static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc03)(uint8_t *dst, const uint8_t *av_restrict src, ptrdiff_t stride)\ +static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc03)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\ {\ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\ @@ -441,7 +441,7 @@ static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc03)(uint8_t *dst, const uint FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid+SIZE*sizeof(pixel), half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\ }\ \ -static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc11)(uint8_t *dst, const uint8_t *av_restrict src, ptrdiff_t stride)\ +static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc11)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\ {\ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\ @@ -453,7 +453,7 @@ static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc11)(uint8_t *dst, const uint FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\ }\ \ -static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc31)(uint8_t *dst, const uint8_t *av_restrict src, ptrdiff_t stride)\ +static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc31)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\ {\ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\ @@ -465,7 +465,7 @@ static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc31)(uint8_t *dst, const uint FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\ }\ \ -static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc13)(uint8_t *dst, const uint8_t *av_restrict src, ptrdiff_t stride)\ +static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc13)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\ {\ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\ @@ -477,7 +477,7 @@ static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc13)(uint8_t *dst, const uint FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\ }\ \ -static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc33)(uint8_t *dst, const uint8_t *av_restrict src, ptrdiff_t stride)\ +static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc33)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\ {\ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\ @@ -489,13 +489,13 @@ static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc33)(uint8_t *dst, const uint FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\ }\ \ -static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc22)(uint8_t *dst, const uint8_t *av_restrict src, ptrdiff_t stride)\ +static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc22)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\ {\ pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\ FUNC(OPNAME ## h264_qpel ## SIZE ## _hv_lowpass)(dst, tmp, src, stride, SIZE*sizeof(pixel), stride);\ }\ \ -static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc21)(uint8_t *dst, const uint8_t *av_restrict src, ptrdiff_t stride)\ +static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc21)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\ {\ pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\ uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\ @@ -505,7 +505,7 @@ static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc21)(uint8_t *dst, const uint FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\ }\ \ -static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc23)(uint8_t *dst, const uint8_t *av_restrict src, ptrdiff_t stride)\ +static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc23)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\ {\ pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\ uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\ @@ -515,7 +515,7 @@ static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc23)(uint8_t *dst, const uint FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\ }\ \ -static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc12)(uint8_t *dst, const uint8_t *av_restrict src, ptrdiff_t stride)\ +static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc12)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\ {\ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\ @@ -528,7 +528,7 @@ static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc12)(uint8_t *dst, const uint FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\ }\ \ -static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc32)(uint8_t *dst, const uint8_t *av_restrict src, ptrdiff_t stride)\ +static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc32)(uint8_t *dst, const uint8_t *restrict src, ptrdiff_t stride)\ {\ uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\ uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\ diff --git a/src/ExtLib/ffmpeg/libavcodec/idctdsp.c b/src/ExtLib/ffmpeg/libavcodec/idctdsp.c index cdea553fbd..0a6bcfb8d1 100644 --- a/src/ExtLib/ffmpeg/libavcodec/idctdsp.c +++ b/src/ExtLib/ffmpeg/libavcodec/idctdsp.c @@ -70,7 +70,7 @@ av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation, } } -void ff_put_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels, +void ff_put_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels, ptrdiff_t line_size) { int i; @@ -91,7 +91,7 @@ void ff_put_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels, } } -static void put_pixels_clamped4_c(const int16_t *block, uint8_t *av_restrict pixels, +static void put_pixels_clamped4_c(const int16_t *block, uint8_t *restrict pixels, int line_size) { int i; @@ -108,7 +108,7 @@ static void put_pixels_clamped4_c(const int16_t *block, uint8_t *av_restrict pix } } -static void put_pixels_clamped2_c(const int16_t *block, uint8_t *av_restrict pixels, +static void put_pixels_clamped2_c(const int16_t *block, uint8_t *restrict pixels, int line_size) { int i; @@ -124,7 +124,7 @@ static void put_pixels_clamped2_c(const int16_t *block, uint8_t *av_restrict pix } static void put_signed_pixels_clamped_c(const int16_t *block, - uint8_t *av_restrict pixels, + uint8_t *restrict pixels, ptrdiff_t line_size) { int i, j; @@ -144,7 +144,7 @@ static void put_signed_pixels_clamped_c(const int16_t *block, } } -void ff_add_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels, +void ff_add_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels, ptrdiff_t line_size) { int i; @@ -164,7 +164,7 @@ void ff_add_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels, } } -static void add_pixels_clamped4_c(const int16_t *block, uint8_t *av_restrict pixels, +static void add_pixels_clamped4_c(const int16_t *block, uint8_t *restrict pixels, int line_size) { int i; @@ -180,7 +180,7 @@ static void add_pixels_clamped4_c(const int16_t *block, uint8_t *av_restrict pix } } -static void add_pixels_clamped2_c(const int16_t *block, uint8_t *av_restrict pixels, +static void add_pixels_clamped2_c(const int16_t *block, uint8_t *restrict pixels, int line_size) { int i; diff --git a/src/ExtLib/ffmpeg/libavcodec/idctdsp.h b/src/ExtLib/ffmpeg/libavcodec/idctdsp.h index 7d6de1bb9f..72a764d5df 100644 --- a/src/ExtLib/ffmpeg/libavcodec/idctdsp.h +++ b/src/ExtLib/ffmpeg/libavcodec/idctdsp.h @@ -22,8 +22,6 @@ #include #include -#include "config.h" - struct AVCodecContext; enum idct_permutation_type { @@ -45,13 +43,13 @@ int ff_init_scantable_permutation_x86(uint8_t *idct_permutation, typedef struct IDCTDSPContext { /* pixel ops : interface with DCT */ void (*put_pixels_clamped)(const int16_t *block /* align 16 */, - uint8_t *av_restrict pixels /* align 8 */, + uint8_t *restrict pixels /* align 8 */, ptrdiff_t line_size); void (*put_signed_pixels_clamped)(const int16_t *block /* align 16 */, - uint8_t *av_restrict pixels /* align 8 */, + uint8_t *restrict pixels /* align 8 */, ptrdiff_t line_size); void (*add_pixels_clamped)(const int16_t *block /* align 16 */, - uint8_t *av_restrict pixels /* align 8 */, + uint8_t *restrict pixels /* align 8 */, ptrdiff_t line_size); void (*idct)(int16_t *block /* align 16 */); @@ -91,9 +89,9 @@ typedef struct IDCTDSPContext { int mpeg4_studio_profile; } IDCTDSPContext; -void ff_put_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels, +void ff_put_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels, ptrdiff_t line_size); -void ff_add_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels, +void ff_add_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels, ptrdiff_t line_size); void ff_idctdsp_init(IDCTDSPContext *c, struct AVCodecContext *avctx); diff --git a/src/ExtLib/ffmpeg/libavcodec/itut35.h b/src/ExtLib/ffmpeg/libavcodec/itut35.h new file mode 100644 index 0000000000..ffa7024981 --- /dev/null +++ b/src/ExtLib/ffmpeg/libavcodec/itut35.h @@ -0,0 +1,30 @@ +/* + * 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_ITUT35_H +#define AVCODEC_ITUT35_H + +#define ITU_T_T35_COUNTRY_CODE_CN 0x26 +#define ITU_T_T35_COUNTRY_CODE_US 0xB5 + +#define ITU_T_T35_PROVIDER_CODE_ATSC 0x31 +#define ITU_T_T35_PROVIDER_CODE_CUVA 0x04 +#define ITU_T_T35_PROVIDER_CODE_DOLBY 0x3B +#define ITU_T_T35_PROVIDER_CODE_SMTPE 0x3C + +#endif /* AVCODEC_ITUT35_H */ diff --git a/src/ExtLib/ffmpeg/libavcodec/libdav1d.c b/src/ExtLib/ffmpeg/libavcodec/libdav1d.c index 1aa2d1f343..597944d88d 100644 --- a/src/ExtLib/ffmpeg/libavcodec/libdav1d.c +++ b/src/ExtLib/ffmpeg/libavcodec/libdav1d.c @@ -37,6 +37,7 @@ #include "decode.h" #include "dovi_rpu.h" #include "internal.h" +#include "itut35.h" #define FF_DAV1D_VERSION_AT_LEAST(x,y) \ (DAV1D_API_VERSION_MAJOR > (x) || DAV1D_API_VERSION_MAJOR == (x) && DAV1D_API_VERSION_MINOR >= (y)) @@ -542,7 +543,7 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) provider_code = bytestream2_get_be16(&gb); switch (provider_code) { - case 0x31: { // atsc_provider_code + case ITU_T_T35_PROVIDER_CODE_ATSC: { uint32_t user_identifier = bytestream2_get_be32(&gb); switch (user_identifier) { case MKBETAG('G', 'A', '9', '4'): { // closed captions @@ -566,12 +567,12 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) } break; } - case 0x3C: { // smpte_provider_code + case ITU_T_T35_PROVIDER_CODE_SMTPE: { AVDynamicHDRPlus *hdrplus; int provider_oriented_code = bytestream2_get_be16(&gb); int application_identifier = bytestream2_get_byte(&gb); - if (itut_t35->country_code != 0xB5 || + if (itut_t35->country_code != ITU_T_T35_COUNTRY_CODE_US || provider_oriented_code != 1 || application_identifier != 4) break; @@ -587,9 +588,10 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame) goto fail; break; } - case 0x3B: { // dolby_provider_code + case ITU_T_T35_PROVIDER_CODE_DOLBY: { int provider_oriented_code = bytestream2_get_be32(&gb); - if (itut_t35->country_code != 0xB5 || provider_oriented_code != 0x800) + if (itut_t35->country_code != ITU_T_T35_COUNTRY_CODE_US || + provider_oriented_code != 0x800) break; res = ff_dovi_rpu_parse(&dav1d->dovi, gb.buffer, gb.buffer_end - gb.buffer); diff --git a/src/ExtLib/ffmpeg/libavcodec/mpeg12dec.c b/src/ExtLib/ffmpeg/libavcodec/mpeg12dec.c index ebd540bfc7..996b4e7ce2 100644 --- a/src/ExtLib/ffmpeg/libavcodec/mpeg12dec.c +++ b/src/ExtLib/ffmpeg/libavcodec/mpeg12dec.c @@ -62,6 +62,13 @@ #define A53_MAX_CC_COUNT 2000 +enum Mpeg2ClosedCaptionsFormat { + CC_FORMAT_AUTO, + CC_FORMAT_A53_PART4, + CC_FORMAT_SCTE20, + CC_FORMAT_DVD +}; + typedef struct Mpeg1Context { MpegEncContext mpeg_enc_ctx; int mpeg_enc_ctx_allocated; /* true if decoding context allocated */ @@ -70,6 +77,7 @@ typedef struct Mpeg1Context { AVStereo3D stereo3d; int has_stereo3d; AVBufferRef *a53_buf_ref; + enum Mpeg2ClosedCaptionsFormat cc_format; uint8_t afd; int has_afd; int slice_count; @@ -1933,12 +1941,27 @@ static int vcr2_init_sequence(AVCodecContext *avctx) return 0; } +static void mpeg_set_cc_format(AVCodecContext *avctx, enum Mpeg2ClosedCaptionsFormat format, + const char *label) +{ + Mpeg1Context *s1 = avctx->priv_data; + + av_assert2(format != CC_FORMAT_AUTO); + + if (!s1->cc_format) { + s1->cc_format = format; + + av_log(avctx, AV_LOG_DEBUG, "CC: first seen substream is %s format\n", label); + } +} + static int mpeg_decode_a53_cc(AVCodecContext *avctx, const uint8_t *p, int buf_size) { Mpeg1Context *s1 = avctx->priv_data; - if (buf_size >= 6 && + if ((!s1->cc_format || s1->cc_format == CC_FORMAT_A53_PART4) && + buf_size >= 6 && p[0] == 'G' && p[1] == 'A' && p[2] == '9' && p[3] == '4' && p[4] == 3 && (p[5] & 0x40)) { /* extract A53 Part 4 CC data */ @@ -1957,9 +1980,11 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx, memcpy(s1->a53_buf_ref->data + old_size, p + 7, cc_count * UINT64_C(3)); avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; + mpeg_set_cc_format(avctx, CC_FORMAT_A53_PART4, "A/53 Part 4"); } return 1; - } else if (buf_size >= 2 && + } else if ((!s1->cc_format || s1->cc_format == CC_FORMAT_SCTE20) && + buf_size >= 2 && p[0] == 0x03 && (p[1]&0x7f) == 0x01) { /* extract SCTE-20 CC data */ GetBitContext gb; @@ -2003,10 +2028,13 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx, cap += 3; } } + avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; + mpeg_set_cc_format(avctx, CC_FORMAT_SCTE20, "SCTE-20"); } return 1; - } else if (buf_size >= 11 && + } else if ((!s1->cc_format || s1->cc_format == CC_FORMAT_DVD) && + buf_size >= 11 && p[0] == 'C' && p[1] == 'C' && p[2] == 0x01 && p[3] == 0xf8) { /* extract DVD CC data * @@ -2063,7 +2091,9 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx, p += 6; } } + avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; + mpeg_set_cc_format(avctx, CC_FORMAT_DVD, "DVD"); } return 1; } @@ -2630,11 +2660,39 @@ const FFCodec ff_mpeg1video_decoder = { }, }; +#define M2V_OFFSET(x) offsetof(Mpeg1Context, x) +#define M2V_PARAM AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM + +static const AVOption mpeg2video_options[] = { + { "cc_format", "extract a specific Closed Captions format", + M2V_OFFSET(cc_format), AV_OPT_TYPE_INT, { .i64 = CC_FORMAT_AUTO }, + CC_FORMAT_AUTO, CC_FORMAT_DVD, M2V_PARAM, .unit = "cc_format" }, + + { "auto", "pick first seen CC substream", 0, AV_OPT_TYPE_CONST, + { .i64 = CC_FORMAT_AUTO }, .flags = M2V_PARAM, .unit = "cc_format" }, + { "a53", "pick A/53 Part 4 CC substream", 0, AV_OPT_TYPE_CONST, + { .i64 = CC_FORMAT_A53_PART4 }, .flags = M2V_PARAM, .unit = "cc_format" }, + { "scte20", "pick SCTE-20 CC substream", 0, AV_OPT_TYPE_CONST, + { .i64 = CC_FORMAT_SCTE20 }, .flags = M2V_PARAM, .unit = "cc_format" }, + { "dvd", "pick DVD CC substream", 0, AV_OPT_TYPE_CONST, + { .i64 = CC_FORMAT_DVD }, .flags = M2V_PARAM, .unit = "cc_format" }, + { NULL } +}; + +static const AVClass mpeg2video_class = { + .class_name = "MPEG-2 video", + .item_name = av_default_item_name, + .option = mpeg2video_options, + .version = LIBAVUTIL_VERSION_INT, + .category = AV_CLASS_CATEGORY_DECODER, +}; + const FFCodec ff_mpeg2video_decoder = { .p.name = "mpeg2video", CODEC_LONG_NAME("MPEG-2 video"), .p.type = AVMEDIA_TYPE_VIDEO, .p.id = AV_CODEC_ID_MPEG2VIDEO, + .p.priv_class = &mpeg2video_class, .priv_data_size = sizeof(Mpeg1Context), .init = mpeg_decode_init, .close = mpeg_decode_end, diff --git a/src/ExtLib/ffmpeg/libavcodec/mpegaudiodata.h b/src/ExtLib/ffmpeg/libavcodec/mpegaudiodata.h index fbad67a0b3..720c4bee64 100644 --- a/src/ExtLib/ffmpeg/libavcodec/mpegaudiodata.h +++ b/src/ExtLib/ffmpeg/libavcodec/mpegaudiodata.h @@ -31,11 +31,13 @@ #include "config.h" +#include "libavutil/attributes_internal.h" #include "vlc.h" #define MODE_EXT_MS_STEREO 2 #define MODE_EXT_I_STEREO 1 +FF_VISIBILITY_PUSH_HIDDEN 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]; @@ -78,5 +80,6 @@ extern const uint8_t ff_mpa_pretab[2][22]; /* Initialize tables shared between the fixed and * floating point MPEG audio decoders. */ void ff_mpegaudiodec_common_init_static(void); +FF_VISIBILITY_POP_HIDDEN #endif /* AVCODEC_MPEGAUDIODATA_H */ diff --git a/src/ExtLib/ffmpeg/libavcodec/mpegaudiodec_template.c b/src/ExtLib/ffmpeg/libavcodec/mpegaudiodec_template.c index c227604107..2b84e65705 100644 --- a/src/ExtLib/ffmpeg/libavcodec/mpegaudiodec_template.c +++ b/src/ExtLib/ffmpeg/libavcodec/mpegaudiodec_template.c @@ -92,7 +92,7 @@ typedef struct MPADecodeContext { int err_recognition; AVCodecContext* avctx; MPADSPContext mpadsp; - void (*butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len); + void (*butterflies_float)(float *restrict v1, float *restrict v2, int len); AVFrame *frame; uint32_t crc; } MPADecodeContext; diff --git a/src/ExtLib/ffmpeg/libavcodec/mpegaudiodsp.h b/src/ExtLib/ffmpeg/libavcodec/mpegaudiodsp.h index 7ff660373b..59ab26bdc4 100644 --- a/src/ExtLib/ffmpeg/libavcodec/mpegaudiodsp.h +++ b/src/ExtLib/ffmpeg/libavcodec/mpegaudiodsp.h @@ -22,6 +22,7 @@ #include #include +#include "libavutil/attributes_internal.h" #include "libavutil/macros.h" typedef struct MPADSPContext { @@ -40,6 +41,7 @@ typedef struct MPADSPContext { int count, int switch_point, int block_type); } MPADSPContext; +FF_VISIBILITY_PUSH_HIDDEN void ff_mpadsp_init(MPADSPContext *s); extern int32_t ff_mpa_synth_window_fixed[]; @@ -88,5 +90,6 @@ void ff_imdct36_blocks_fixed(int *out, int *buf, int *in, extern int ff_mdct_win_fixed[8][MDCT_BUF_SIZE]; extern float ff_mdct_win_float[8][MDCT_BUF_SIZE]; +FF_VISIBILITY_POP_HIDDEN #endif /* AVCODEC_MPEGAUDIODSP_H */ diff --git a/src/ExtLib/ffmpeg/libavcodec/options.c b/src/ExtLib/ffmpeg/libavcodec/options.c index dcc67e497a..5169f2e476 100644 --- a/src/ExtLib/ffmpeg/libavcodec/options.c +++ b/src/ExtLib/ffmpeg/libavcodec/options.c @@ -176,6 +176,8 @@ void avcodec_free_context(AVCodecContext **pavctx) av_freep(&avctx->inter_matrix); av_freep(&avctx->rc_override); av_channel_layout_uninit(&avctx->ch_layout); + av_frame_side_data_free( + &avctx->decoded_side_data, &avctx->nb_decoded_side_data); av_freep(pavctx); } diff --git a/src/ExtLib/ffmpeg/libavcodec/opus_pvq.c b/src/ExtLib/ffmpeg/libavcodec/opus_pvq.c index d08dcd7413..0a6dc4cdf1 100644 --- a/src/ExtLib/ffmpeg/libavcodec/opus_pvq.c +++ b/src/ExtLib/ffmpeg/libavcodec/opus_pvq.c @@ -80,7 +80,7 @@ static inline int celt_pulses2bits(const uint8_t *cache, int pulses) return (pulses == 0) ? 0 : cache[pulses] + 1; } -static inline void celt_normalize_residual(const int * av_restrict iy, float * av_restrict X, +static inline void celt_normalize_residual(const int * restrict iy, float * restrict X, int N, float g) { int i; diff --git a/src/ExtLib/ffmpeg/libavcodec/pixblockdsp.c b/src/ExtLib/ffmpeg/libavcodec/pixblockdsp.c index a431b93e83..3f2fce19ca 100644 --- a/src/ExtLib/ffmpeg/libavcodec/pixblockdsp.c +++ b/src/ExtLib/ffmpeg/libavcodec/pixblockdsp.c @@ -24,7 +24,7 @@ #include "avcodec.h" #include "pixblockdsp.h" -static void get_pixels_16_c(int16_t *av_restrict block, const uint8_t *pixels, +static void get_pixels_16_c(int16_t *restrict block, const uint8_t *pixels, ptrdiff_t stride) { AV_COPY128U(block + 0 * 8, pixels + 0 * stride); @@ -37,7 +37,7 @@ static void get_pixels_16_c(int16_t *av_restrict block, const uint8_t *pixels, AV_COPY128U(block + 7 * 8, pixels + 7 * stride); } -static void get_pixels_8_c(int16_t *av_restrict block, const uint8_t *pixels, +static void get_pixels_8_c(int16_t *restrict block, const uint8_t *pixels, ptrdiff_t stride) { int i; @@ -57,7 +57,7 @@ static void get_pixels_8_c(int16_t *av_restrict block, const uint8_t *pixels, } } -static void diff_pixels_c(int16_t *av_restrict block, const uint8_t *s1, +static void diff_pixels_c(int16_t *restrict block, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride) { int i; diff --git a/src/ExtLib/ffmpeg/libavcodec/pixblockdsp.h b/src/ExtLib/ffmpeg/libavcodec/pixblockdsp.h index b731df478b..81687bee19 100644 --- a/src/ExtLib/ffmpeg/libavcodec/pixblockdsp.h +++ b/src/ExtLib/ffmpeg/libavcodec/pixblockdsp.h @@ -21,22 +21,20 @@ #include -#include "config.h" - #include "avcodec.h" typedef struct PixblockDSPContext { - void (*get_pixels)(int16_t *av_restrict block /* align 16 */, + void (*get_pixels)(int16_t *restrict block /* align 16 */, const uint8_t *pixels /* align 8 */, ptrdiff_t stride); - void (*get_pixels_unaligned)(int16_t *av_restrict block /* align 16 */, + void (*get_pixels_unaligned)(int16_t *restrict block /* align 16 */, const uint8_t *pixels, ptrdiff_t stride); - void (*diff_pixels)(int16_t *av_restrict block /* align 16 */, + void (*diff_pixels)(int16_t *restrict block /* align 16 */, const uint8_t *s1 /* align 8 */, const uint8_t *s2 /* align 8 */, ptrdiff_t stride); - void (*diff_pixels_unaligned)(int16_t *av_restrict block /* align 16 */, + void (*diff_pixels_unaligned)(int16_t *restrict block /* align 16 */, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride); diff --git a/src/ExtLib/ffmpeg/libavcodec/utils.c b/src/ExtLib/ffmpeg/libavcodec/utils.c index e91a5d6d2e..337c00e789 100644 --- a/src/ExtLib/ffmpeg/libavcodec/utils.c +++ b/src/ExtLib/ffmpeg/libavcodec/utils.c @@ -939,9 +939,9 @@ void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, in #endif -const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p, +const uint8_t *avpriv_find_start_code(const uint8_t *restrict p, const uint8_t *end, - uint32_t *av_restrict state) + uint32_t *restrict state) { int i; diff --git a/src/ExtLib/ffmpeg/libavcodec/version.h b/src/ExtLib/ffmpeg/libavcodec/version.h index b4616ccc27..0550d7b0d8 100644 --- a/src/ExtLib/ffmpeg/libavcodec/version.h +++ b/src/ExtLib/ffmpeg/libavcodec/version.h @@ -29,8 +29,8 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 1 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MINOR 2 +#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/src/ExtLib/ffmpeg/libavcodec/vorbis_data.h b/src/ExtLib/ffmpeg/libavcodec/vorbis_data.h index 51c91c9e04..327e5ab2ef 100644 --- a/src/ExtLib/ffmpeg/libavcodec/vorbis_data.h +++ b/src/ExtLib/ffmpeg/libavcodec/vorbis_data.h @@ -21,11 +21,14 @@ #include +#include "libavutil/attributes_internal.h" #include "libavutil/channel_layout.h" +FF_VISIBILITY_PUSH_HIDDEN extern const float ff_vorbis_floor1_inverse_db_table[256]; extern const float * const ff_vorbis_vwin[8]; extern const uint8_t ff_vorbis_channel_layout_offsets[8][8]; extern const AVChannelLayout ff_vorbis_ch_layouts[9]; +FF_VISIBILITY_POP_HIDDEN #endif /* AVCODEC_VORBIS_DATA_H */ diff --git a/src/ExtLib/ffmpeg/libavcodec/vvc/vvc_ctu.c b/src/ExtLib/ffmpeg/libavcodec/vvc/vvc_ctu.c index 75b9e73ae3..e48ffda938 100644 --- a/src/ExtLib/ffmpeg/libavcodec/vvc/vvc_ctu.c +++ b/src/ExtLib/ffmpeg/libavcodec/vvc/vvc_ctu.c @@ -96,7 +96,7 @@ static int get_qp_y_pred(const VVCLocalContext *lc) if (lc->na.cand_up) { const int first_qg_in_ctu = !(xQg & ctb_size_mask) && !(yQg & ctb_size_mask); const int qPy_up = fc->tab.qp[LUMA][x_cb + (y_cb - 1) * min_cb_width]; - if (first_qg_in_ctu && pps->ctb_to_col_bd[xQg >> ctb_log2_size] == xQg) + if (first_qg_in_ctu && pps->ctb_to_col_bd[xQg >> ctb_log2_size] == xQg >> ctb_log2_size) return qPy_up; } diff --git a/src/ExtLib/ffmpeg/libavutil/channel_layout.c b/src/ExtLib/ffmpeg/libavutil/channel_layout.c index e0a5cc4aa5..8c5c850342 100644 --- a/src/ExtLib/ffmpeg/libavutil/channel_layout.c +++ b/src/ExtLib/ffmpeg/libavutil/channel_layout.c @@ -86,6 +86,10 @@ void av_channel_name_bprint(AVBPrint *bp, enum AVChannel channel_id) av_bprintf(bp, "%s", channel_names[channel_id].name); else if (channel_id == AV_CHAN_NONE) av_bprintf(bp, "NONE"); + else if (channel_id == AV_CHAN_UNKNOWN) + av_bprintf(bp, "UNK"); + else if (channel_id == AV_CHAN_UNUSED) + av_bprintf(bp, "UNSD"); else av_bprintf(bp, "USR%d", channel_id); } @@ -115,6 +119,10 @@ void av_channel_description_bprint(AVBPrint *bp, enum AVChannel channel_id) av_bprintf(bp, "%s", channel_names[channel_id].description); else if (channel_id == AV_CHAN_NONE) av_bprintf(bp, "none"); + else if (channel_id == AV_CHAN_UNKNOWN) + av_bprintf(bp, "unknown"); + else if (channel_id == AV_CHAN_UNUSED) + av_bprintf(bp, "unused"); else av_bprintf(bp, "user %d", channel_id); } @@ -151,6 +159,11 @@ enum AVChannel av_channel_from_string(const char *str) if (channel_names[i].name && !strcmp(str, channel_names[i].name)) return i; } + if (!strcmp(str, "UNK")) + return AV_CHAN_UNKNOWN; + if (!strcmp(str, "UNSD")) + return AV_CHAN_UNUSED; + if (!strncmp(str, "USR", 3)) { const char *p = str + 3; id = strtol(p, &endptr, 0); @@ -239,13 +252,58 @@ int av_channel_layout_from_mask(AVChannelLayout *channel_layout, return 0; } +static int parse_channel_list(AVChannelLayout *ch_layout, const char *str) +{ + int ret; + int nb_channels = 0; + AVChannelCustom *map = NULL; + AVChannelCustom custom = {0}; + + while (*str) { + char *channel, *chname; + int ret = av_opt_get_key_value(&str, "@", "+", AV_OPT_FLAG_IMPLICIT_KEY, &channel, &chname); + if (ret < 0) { + av_freep(&map); + return ret; + } + if (*str) + str++; // skip separator + if (!channel) { + channel = chname; + chname = NULL; + } + av_strlcpy(custom.name, chname ? chname : "", sizeof(custom.name)); + custom.id = av_channel_from_string(channel); + av_free(channel); + av_free(chname); + if (custom.id == AV_CHAN_NONE) { + av_freep(&map); + return AVERROR(EINVAL); + } + + av_dynarray2_add((void **)&map, &nb_channels, sizeof(custom), (void *)&custom); + if (!map) + return AVERROR(ENOMEM); + } + + if (!nb_channels) + return AVERROR(EINVAL); + + ch_layout->order = AV_CHANNEL_ORDER_CUSTOM; + ch_layout->u.map = map; + ch_layout->nb_channels = nb_channels; + + ret = av_channel_layout_retype(ch_layout, 0, AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL); + av_assert0(ret == 0); + + 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; + int i, matches, ret; + int channels = 0, nb_channels = 0; char *chlist, *end; uint64_t mask = 0; @@ -257,6 +315,10 @@ int av_channel_layout_from_string(AVChannelLayout *channel_layout, } } + /* This function is a channel layout initializer, so we have to + * zero-initialize before we start setting fields individually. */ + memset(channel_layout, 0, sizeof(*channel_layout)); + /* ambisonic */ if (!strncmp(str, "ambisonic ", 10)) { const char *p = str + 10; @@ -298,6 +360,7 @@ int av_channel_layout_from_string(AVChannelLayout *channel_layout, 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(channel_layout); av_channel_layout_uninit(&extra); return AVERROR(EINVAL); } @@ -321,121 +384,20 @@ int av_channel_layout_from_string(AVChannelLayout *channel_layout, 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; + matches = av_sscanf(str, "%d channels (%[^)]", &nb_channels, chlist); + ret = parse_channel_list(channel_layout, chlist); + av_freep(&chlist); + if (ret < 0 && ret != AVERROR(EINVAL)) + return ret; - if (nb_channels && ((nb_channels != channels) || (!end || *++end))) { - av_free(chlist); + if (ret >= 0) { + end = strchr(str, ')'); + if (matches == 2 && (nb_channels != channel_layout->nb_channels || !end || *++end)) { + av_channel_layout_uninit(channel_layout); 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); @@ -553,6 +515,33 @@ static int ambisonic_order(const AVChannelLayout *channel_layout) return order; } +static enum AVChannelOrder canonical_order(AVChannelLayout *channel_layout) +{ + int has_known_channel = 0; + int order; + + if (channel_layout->order != AV_CHANNEL_ORDER_CUSTOM) + return channel_layout->order; + + if (has_channel_names(channel_layout)) + return AV_CHANNEL_ORDER_CUSTOM; + + for (int i = 0; i < channel_layout->nb_channels && !has_known_channel; i++) + if (channel_layout->u.map[i].id != AV_CHAN_UNKNOWN) + has_known_channel = 1; + if (!has_known_channel) + return AV_CHANNEL_ORDER_UNSPEC; + + if (masked_description(channel_layout, 0) > 0) + return AV_CHANNEL_ORDER_NATIVE; + + order = ambisonic_order(channel_layout); + if (order >= 0 && masked_description(channel_layout, (order + 1) * (order + 1)) >= 0) + return AV_CHANNEL_ORDER_AMBISONIC; + + return AV_CHANNEL_ORDER_CUSTOM; +} + /** * 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. @@ -892,6 +881,9 @@ int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrde if (!av_channel_layout_check(channel_layout)) return AVERROR(EINVAL); + if (flags & AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL) + order = canonical_order(channel_layout); + if (channel_layout->order == order) return 0; diff --git a/src/ExtLib/ffmpeg/libavutil/channel_layout.h b/src/ExtLib/ffmpeg/libavutil/channel_layout.h index 20cf7222f7..629723531e 100644 --- a/src/ExtLib/ffmpeg/libavutil/channel_layout.h +++ b/src/ExtLib/ffmpeg/libavutil/channel_layout.h @@ -512,10 +512,14 @@ int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask); * - the number of unordered channels (eg. "4C" or "4 channels") * - the ambisonic order followed by optional non-diegetic channels (eg. * "ambisonic 2+stereo") + * On error, the channel layout will remain uninitialized, but not necessarily + * untouched. * - * @param channel_layout input channel layout + * @param channel_layout uninitialized channel layout for the result * @param str string describing the channel layout - * @return 0 channel layout was detected, AVERROR_INVALIDATATA otherwise + * @return 0 on success parsing the channel layout + * AVERROR(EINVAL) if an invalid channel layout string was provided + * AVERROR(ENOMEM) if there was not enough memory */ int av_channel_layout_from_string(AVChannelLayout *channel_layout, const char *str); @@ -680,6 +684,13 @@ int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout */ #define AV_CHANNEL_LAYOUT_RETYPE_FLAG_LOSSLESS (1 << 0) +/** + * The specified retype target order is ignored and the simplest possible + * (canonical) order is used for which the input layout can be losslessy + * represented. + */ +#define AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL (1 << 1) + /** * Change the AVChannelOrder of a channel layout. * diff --git a/src/ExtLib/ffmpeg/libavutil/fixed_dsp.c b/src/ExtLib/ffmpeg/libavutil/fixed_dsp.c index f38082f37a..74b336ad1e 100644 --- a/src/ExtLib/ffmpeg/libavutil/fixed_dsp.c +++ b/src/ExtLib/ffmpeg/libavutil/fixed_dsp.c @@ -135,7 +135,7 @@ static int scalarproduct_fixed_c(const int *v1, const int *v2, int len) return (int)(p >> 31); } -static void butterflies_fixed_c(int *av_restrict v1s, int *av_restrict v2, int len) +static void butterflies_fixed_c(int *restrict v1s, int *restrict v2, int len) { int i; unsigned int *v1 = v1s; diff --git a/src/ExtLib/ffmpeg/libavutil/fixed_dsp.h b/src/ExtLib/ffmpeg/libavutil/fixed_dsp.h index e0a5b5f973..e5f59f1b25 100644 --- a/src/ExtLib/ffmpeg/libavutil/fixed_dsp.h +++ b/src/ExtLib/ffmpeg/libavutil/fixed_dsp.h @@ -49,7 +49,6 @@ #define AVUTIL_FIXED_DSP_H #include -#include "config.h" #include "attributes.h" #include "libavcodec/mathops.h" @@ -150,7 +149,7 @@ typedef struct AVFixedDSPContext { * @param v2 second input vector, difference output, 16-byte aligned * @param len length of vectors, multiple of 4 */ - void (*butterflies_fixed)(int *av_restrict v1, int *av_restrict v2, int len); + void (*butterflies_fixed)(int *restrict v1, int *restrict v2, int len); } AVFixedDSPContext; /** diff --git a/src/ExtLib/ffmpeg/libavutil/float_dsp.c b/src/ExtLib/ffmpeg/libavutil/float_dsp.c index 563957f381..9913921205 100644 --- a/src/ExtLib/ffmpeg/libavutil/float_dsp.c +++ b/src/ExtLib/ffmpeg/libavutil/float_dsp.c @@ -109,7 +109,7 @@ static void vector_fmul_reverse_c(float *dst, const float *src0, dst[i] = src0[i] * src1[-i]; } -static void butterflies_float_c(float *av_restrict v1, float *av_restrict v2, +static void butterflies_float_c(float *restrict v1, float *restrict v2, int len) { int i; diff --git a/src/ExtLib/ffmpeg/libavutil/float_dsp.h b/src/ExtLib/ffmpeg/libavutil/float_dsp.h index 4149a3b57e..fda5be4daf 100644 --- a/src/ExtLib/ffmpeg/libavutil/float_dsp.h +++ b/src/ExtLib/ffmpeg/libavutil/float_dsp.h @@ -19,8 +19,6 @@ #ifndef AVUTIL_FLOAT_DSP_H #define AVUTIL_FLOAT_DSP_H -#include "config.h" - typedef struct AVFloatDSPContext { /** * Calculate the entry wise product of two vectors of floats and store the result in @@ -161,7 +159,7 @@ typedef struct AVFloatDSPContext { * @param v2 second input vector, difference output, 16-byte aligned * @param len length of vectors, multiple of 4 */ - void (*butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len); + void (*butterflies_float)(float *restrict v1, float *restrict v2, int len); /** * Calculate the scalar product of two vectors of floats. diff --git a/src/ExtLib/ffmpeg/libavutil/frame.c b/src/ExtLib/ffmpeg/libavutil/frame.c index 079cf6595b..89db687d9c 100644 --- a/src/ExtLib/ffmpeg/libavutil/frame.c +++ b/src/ExtLib/ffmpeg/libavutil/frame.c @@ -63,14 +63,56 @@ static void free_side_data(AVFrameSideData **ptr_sd) av_freep(ptr_sd); } -static void wipe_side_data(AVFrame *frame) +static void wipe_side_data(AVFrameSideData ***sd, int *nb_side_data) { - for (int i = 0; i < frame->nb_side_data; i++) { - free_side_data(&frame->side_data[i]); + for (int i = 0; i < *nb_side_data; i++) { + free_side_data(&((*sd)[i])); } - frame->nb_side_data = 0; + *nb_side_data = 0; - av_freep(&frame->side_data); + av_freep(sd); +} + +static void frame_side_data_wipe(AVFrame *frame) +{ + wipe_side_data(&frame->side_data, &frame->nb_side_data); +} + +void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd) +{ + wipe_side_data(sd, nb_sd); +} + +static void remove_side_data(AVFrameSideData ***sd, int *nb_side_data, + const enum AVFrameSideDataType type) +{ + for (int i = *nb_side_data - 1; i >= 0; i--) { + AVFrameSideData *entry = ((*sd)[i]); + if (entry->type != type) + continue; + + free_side_data(&entry); + + ((*sd)[i]) = ((*sd)[*nb_side_data - 1]); + (*nb_side_data)--; + } +} + +static void remove_side_data_by_entry(AVFrameSideData ***sd, int *nb_sd, + const AVFrameSideData *target) +{ + for (int i = *nb_sd - 1; i >= 0; i--) { + AVFrameSideData *entry = ((*sd)[i]); + if (entry != target) + continue; + + free_side_data(&entry); + + ((*sd)[i]) = ((*sd)[*nb_sd - 1]); + (*nb_sd)--; + + return; + } } AVFrame *av_frame_alloc(void) @@ -288,7 +330,7 @@ FF_ENABLE_DEPRECATION_WARNINGS sd_dst = av_frame_new_side_data(dst, sd_src->type, sd_src->size); if (!sd_dst) { - wipe_side_data(dst); + frame_side_data_wipe(dst); return AVERROR(ENOMEM); } memcpy(sd_dst->data, sd_src->data, sd_src->size); @@ -297,7 +339,7 @@ FF_ENABLE_DEPRECATION_WARNINGS sd_dst = av_frame_new_side_data_from_buf(dst, sd_src->type, ref); if (!sd_dst) { av_buffer_unref(&ref); - wipe_side_data(dst); + frame_side_data_wipe(dst); return AVERROR(ENOMEM); } } @@ -437,7 +479,7 @@ int av_frame_replace(AVFrame *dst, const AVFrame *src) if (ret < 0) goto fail; - wipe_side_data(dst); + frame_side_data_wipe(dst); av_dict_free(&dst->metadata); ret = frame_copy_props(dst, src, 0); if (ret < 0) @@ -536,7 +578,7 @@ void av_frame_unref(AVFrame *frame) if (!frame) return; - wipe_side_data(frame); + frame_side_data_wipe(frame); for (int i = 0; i < FF_ARRAY_ELEMS(frame->buf); i++) av_buffer_unref(&frame->buf[i]); @@ -669,23 +711,23 @@ AVBufferRef *av_frame_get_plane_buffer(const AVFrame *frame, int plane) return NULL; } -AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, - enum AVFrameSideDataType type, - AVBufferRef *buf) +static AVFrameSideData *add_side_data_from_buf(AVFrameSideData ***sd, + int *nb_sd, + enum AVFrameSideDataType type, + AVBufferRef *buf) { AVFrameSideData *ret, **tmp; if (!buf) return NULL; - if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1) + if (*nb_sd > INT_MAX / sizeof(*sd) - 1) return NULL; - tmp = av_realloc(frame->side_data, - (frame->nb_side_data + 1) * sizeof(*frame->side_data)); + tmp = av_realloc(*sd, (*nb_sd + 1) * sizeof(*sd)); if (!tmp) return NULL; - frame->side_data = tmp; + *sd = tmp; ret = av_mallocz(sizeof(*ret)); if (!ret) @@ -696,11 +738,20 @@ AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, ret->size = buf->size; ret->type = type; - frame->side_data[frame->nb_side_data++] = ret; + (*sd)[(*nb_sd)++] = ret; return ret; } +AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, + enum AVFrameSideDataType type, + AVBufferRef *buf) +{ + return + add_side_data_from_buf( + &frame->side_data, &frame->nb_side_data, type, buf); +} + AVFrameSideData *av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, size_t size) @@ -713,16 +764,75 @@ AVFrameSideData *av_frame_new_side_data(AVFrame *frame, return ret; } -AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, - enum AVFrameSideDataType type) +AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, + enum AVFrameSideDataType type, + size_t size, unsigned int flags) { - for (int i = 0; i < frame->nb_side_data; i++) { - if (frame->side_data[i]->type == type) - return frame->side_data[i]; + AVBufferRef *buf = av_buffer_alloc(size); + AVFrameSideData *ret = NULL; + + if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) + remove_side_data(sd, nb_sd, type); + + ret = add_side_data_from_buf(sd, nb_sd, type, buf); + if (!ret) + av_buffer_unref(&buf); + + return ret; +} + +int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, + const AVFrameSideData *src, unsigned int flags) +{ + AVBufferRef *buf = NULL; + AVFrameSideData *sd_dst = NULL; + int ret = AVERROR_BUG; + + if (!sd || !src || !nb_sd || (*nb_sd && !*sd)) + return AVERROR(EINVAL); + + buf = av_buffer_ref(src->buf); + if (!buf) + return AVERROR(ENOMEM); + + if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) + remove_side_data(sd, nb_sd, src->type); + + sd_dst = add_side_data_from_buf(sd, nb_sd, src->type, buf); + if (!sd_dst) { + av_buffer_unref(&buf); + return AVERROR(ENOMEM); + } + + ret = av_dict_copy(&sd_dst->metadata, src->metadata, 0); + if (ret < 0) { + remove_side_data_by_entry(sd, nb_sd, sd_dst); + return ret; + } + + return 0; +} + +const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd, + const int nb_sd, + enum AVFrameSideDataType type) +{ + for (int i = 0; i < nb_sd; i++) { + if (sd[i]->type == type) + return sd[i]; } return NULL; } +AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, + enum AVFrameSideDataType type) +{ + return (AVFrameSideData *)av_frame_side_data_get( + (const AVFrameSideData **)frame->side_data, frame->nb_side_data, + type + ); +} + static int frame_copy_video(AVFrame *dst, const AVFrame *src) { int planes; @@ -782,14 +892,7 @@ int av_frame_copy(AVFrame *dst, const AVFrame *src) void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type) { - for (int i = frame->nb_side_data - 1; i >= 0; i--) { - AVFrameSideData *sd = frame->side_data[i]; - if (sd->type == type) { - free_side_data(&frame->side_data[i]); - frame->side_data[i] = frame->side_data[frame->nb_side_data - 1]; - frame->nb_side_data--; - } - } + remove_side_data(&frame->side_data, &frame->nb_side_data, type); } const char *av_frame_side_data_name(enum AVFrameSideDataType type) diff --git a/src/ExtLib/ffmpeg/libavutil/frame.h b/src/ExtLib/ffmpeg/libavutil/frame.h index b94687941d..a7fc909ad8 100644 --- a/src/ExtLib/ffmpeg/libavutil/frame.h +++ b/src/ExtLib/ffmpeg/libavutil/frame.h @@ -988,6 +988,73 @@ int av_frame_apply_cropping(AVFrame *frame, int flags); */ const char *av_frame_side_data_name(enum AVFrameSideDataType type); +/** + * Free all side data entries and their contents, then zeroes out the + * values which the pointers are pointing to. + * + * @param sd pointer to array of side data to free. Will be set to NULL + * upon return. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. Will be set to 0 upon return. + */ +void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd); + +#define AV_FRAME_SIDE_DATA_FLAG_UNIQUE (1 << 0) + +/** + * Add new side data entry to an array. + * + * @param sd pointer to array of side data to which to add another entry, + * or to NULL in order to start a new array. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. + * @param type type of the added side data + * @param size size of the side data + * @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0. + * + * @return newly added side data on success, NULL on error. In case of + * AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of matching + * AVFrameSideDataType will be removed before the addition is + * attempted. + */ +AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, + enum AVFrameSideDataType type, + size_t size, unsigned int flags); + +/** + * Add a new side data entry to an array based on existing side data, taking + * a reference towards the contained AVBufferRef. + * + * @param sd pointer to array of side data to which to add another entry, + * or to NULL in order to start a new array. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. + * @param src side data to be cloned, with a new reference utilized + * for the buffer. + * @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0. + * + * @return negative error code on failure, >=0 on success. In case of + * AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of matching + * AVFrameSideDataType will be removed before the addition is + * attempted. + */ +int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, + const AVFrameSideData *src, unsigned int flags); + +/** + * Get a side data entry of a specific type from an array. + * + * @param sd array of side data. + * @param nb_sd integer containing the number of entries in the array. + * @param type type of side data to be queried + * + * @return a pointer to the side data of a given type on success, NULL if there + * is no side data with such type in this set. + */ +const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd, + const int nb_sd, + enum AVFrameSideDataType type); + /** * @} */ diff --git a/src/ExtLib/ffmpeg/libavutil/hwcontext_d3d11va.c b/src/ExtLib/ffmpeg/libavutil/hwcontext_d3d11va.c index 228e7e6b39..aadc872468 100644 --- a/src/ExtLib/ffmpeg/libavutil/hwcontext_d3d11va.c +++ b/src/ExtLib/ffmpeg/libavutil/hwcontext_d3d11va.c @@ -62,7 +62,9 @@ static av_cold void load_functions(void) return; mD3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE) GetProcAddress(d3dlib, "D3D11CreateDevice"); - mCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY) GetProcAddress(dxgilib, "CreateDXGIFactory"); + mCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY) GetProcAddress(dxgilib, "CreateDXGIFactory1"); + if (!mCreateDXGIFactory) + mCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY) GetProcAddress(dxgilib, "CreateDXGIFactory"); #else // In UWP (which lacks LoadLibrary), CreateDXGIFactory isn't available, // only CreateDXGIFactory1 @@ -651,14 +653,10 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device, int ret; int adapter = -1; - // (On UWP we can't check this.) -#if !HAVE_UWP - if (!LoadLibrary("d3d11_1sdklayers.dll")) - is_debug = 0; -#endif - - if (is_debug) + if (is_debug) { creationFlags |= D3D11_CREATE_DEVICE_DEBUG; + av_log(ctx, AV_LOG_INFO, "Enabling d3d11 debugging.\n"); + } if ((ret = ff_thread_once(&functions_loaded, load_functions)) != 0) return AVERROR_UNKNOWN; @@ -734,9 +732,17 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device, if (pf_DXGIGetDebugInterface) { IDXGIDebug *dxgi_debug = NULL; hr = pf_DXGIGetDebugInterface(&IID_IDXGIDebug, (void**)&dxgi_debug); - if (SUCCEEDED(hr) && dxgi_debug) + if (SUCCEEDED(hr) && dxgi_debug) { IDXGIDebug_ReportLiveObjects(dxgi_debug, DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_ALL); + av_log(ctx, AV_LOG_INFO, "Enabled dxgi debugging.\n"); + } else { + av_log(ctx, AV_LOG_WARNING, "Failed enabling dxgi debugging.\n"); + } + } else { + av_log(ctx, AV_LOG_WARNING, "Failed getting dxgi debug interface.\n"); } + } else { + av_log(ctx, AV_LOG_WARNING, "Failed loading dxgi debug library.\n"); } } #endif diff --git a/src/ExtLib/ffmpeg/libavutil/version.h b/src/ExtLib/ffmpeg/libavutil/version.h index 09f8cdc292..5027b025be 100644 --- a/src/ExtLib/ffmpeg/libavutil/version.h +++ b/src/ExtLib/ffmpeg/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 59 -#define LIBAVUTIL_VERSION_MINOR 1 +#define LIBAVUTIL_VERSION_MINOR 3 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ diff --git a/src/ExtLib/ffmpeg/libavutil/x86/fixed_dsp_init.c b/src/ExtLib/ffmpeg/libavutil/x86/fixed_dsp_init.c index d3f4b2e325..3dd508a4f4 100644 --- a/src/ExtLib/ffmpeg/libavutil/x86/fixed_dsp_init.c +++ b/src/ExtLib/ffmpeg/libavutil/x86/fixed_dsp_init.c @@ -16,14 +16,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "config.h" - #include "libavutil/attributes.h" #include "libavutil/cpu.h" #include "libavutil/fixed_dsp.h" #include "cpu.h" -void ff_butterflies_fixed_sse2(int *av_restrict src0, int *av_restrict src1, int len); +void ff_butterflies_fixed_sse2(int *restrict src0, int *restrict src1, int len); av_cold void ff_fixed_dsp_init_x86(AVFixedDSPContext *fdsp) { diff --git a/src/ExtLib/ffmpeg/libavutil/x86/float_dsp_init.c b/src/ExtLib/ffmpeg/libavutil/x86/float_dsp_init.c index ad6b506259..093bce9b94 100644 --- a/src/ExtLib/ffmpeg/libavutil/x86/float_dsp_init.c +++ b/src/ExtLib/ffmpeg/libavutil/x86/float_dsp_init.c @@ -16,13 +16,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "config.h" - #include "libavutil/attributes.h" #include "libavutil/cpu.h" #include "libavutil/float_dsp.h" #include "cpu.h" -#include "asm.h" void ff_vector_fmul_sse(float *dst, const float *src0, const float *src1, int len); @@ -76,7 +73,7 @@ void ff_vector_fmul_reverse_avx2(float *dst, const float *src0, float ff_scalarproduct_float_sse(const float *v1, const float *v2, int order); float ff_scalarproduct_float_fma3(const float *v1, const float *v2, int order); -void ff_butterflies_float_sse(float *av_restrict src0, float *av_restrict src1, int len); +void ff_butterflies_float_sse(float *restrict src0, float *restrict src1, int len); av_cold void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp) { diff --git a/src/ExtLib/ffmpeg/libavutil/x86/x86util.asm b/src/ExtLib/ffmpeg/libavutil/x86/x86util.asm index 84dc18a4f3..886a378f7c 100644 --- a/src/ExtLib/ffmpeg/libavutil/x86/x86util.asm +++ b/src/ExtLib/ffmpeg/libavutil/x86/x86util.asm @@ -802,10 +802,6 @@ %macro PMINSD 3 ; dst, src, tmp/unused %if cpuflag(sse4) pminsd %1, %2 -%elif cpuflag(sse2) - cvtdq2ps %1, %1 - minps %1, %2 - cvtps2dq %1, %1 %else mova %3, %2 pcmpgtd %3, %1 diff --git a/src/ExtLib/ffmpeg/libswscale/x86/scale.asm b/src/ExtLib/ffmpeg/libswscale/x86/scale.asm index 2e14c8c023..baf03d52fa 100644 --- a/src/ExtLib/ffmpeg/libswscale/x86/scale.asm +++ b/src/ExtLib/ffmpeg/libswscale/x86/scale.asm @@ -24,7 +24,6 @@ SECTION_RODATA max_19bit_int: times 4 dd 0x7ffff -max_19bit_flt: times 4 dd 524287.0 minshort: times 8 dw 0x8000 unicoeff: times 4 dd 0x20000000 @@ -61,11 +60,7 @@ cglobal hscale%1to%2_%4, %5, 10, %6, pos0, dst, w, srcmem, filter, fltpos, fltsi %define mov32 mov %endif ; x86-64 %if %2 == 19 -%if cpuflag(sse4) mova m2, [max_19bit_int] -%else ; ssse3/sse2 - mova m2, [max_19bit_flt] -%endif ; sse2/ssse3/sse4 %endif ; %2 == 19 %if %1 == 16 mova m6, [minshort]