diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 30ddd52efe..30a0b125ab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -92,7 +92,8 @@ jobs: run: | (cd ${{ matrix.vcpkg-root }} && git fetch origin) (cd ${{ matrix.vcpkg-root }} && git reset --hard) - (cd ${{ matrix.vcpkg-root }} && git checkout tags/2025.12.12) + (cd ${{ matrix.vcpkg-root }} && git checkout tags/2026.05.25) + (cp ${{ github.workspace }}/ffmpeg-add-psmf-support.patch ${{ matrix.vcpkg-root }}/ports/ffmpeg/) (cd ${{ matrix.vcpkg-root }} && git apply --ignore-space-change --ignore-whitespace --3way ${{ github.workspace }}/ffmpeg.patch) - name: Build ffmpeg diff --git a/ffmpeg-add-psmf-support.patch b/ffmpeg-add-psmf-support.patch new file mode 100644 index 0000000000..07622c7b36 --- /dev/null +++ b/ffmpeg-add-psmf-support.patch @@ -0,0 +1,2069 @@ +diff --git a/configure b/configure +index 1759694274..e04aebb864 100755 +--- a/configure ++++ b/configure +@@ -3101,6 +3101,7 @@ asv2_encoder_select="aandcttables bswapdsp fdctdsp pixblockdsp" + atrac1_decoder_select="sinewin" + atrac3p_decoder_select="sinewin" + atrac3pal_decoder_select="sinewin" ++atrac3p_ats_decoder_select="atrac3p_ats_parser atrac3p_decoder" + av1_decoder_select="atsc_a53 cbs_av1 dovi_rpudec" + bink_decoder_select="blockdsp hpeldsp" + binkaudio_dct_decoder_select="wma_freqs" +@@ -3926,6 +3927,7 @@ oga_muxer_select="ogg_muxer" + ogg_demuxer_select="dirac_parse" + ogv_muxer_select="ogg_muxer" + opus_muxer_select="ogg_muxer" ++psmf_demuxer_select="mpeg_demuxer" + psp_muxer_select="mov_muxer" + rtp_demuxer_select="sdp_demuxer" + rtp_muxer_select="iso_writer" +diff --git a/libavcodec/Makefile b/libavcodec/Makefile +index 1410bd8142..c58b824417 100644 +--- a/libavcodec/Makefile ++++ b/libavcodec/Makefile +@@ -910,6 +910,7 @@ OBJS-$(CONFIG_PCM_F64LE_ENCODER) += pcm.o + OBJS-$(CONFIG_PCM_LXF_DECODER) += pcm.o + OBJS-$(CONFIG_PCM_MULAW_DECODER) += pcm.o + OBJS-$(CONFIG_PCM_MULAW_ENCODER) += pcm.o ++OBJS-$(CONFIG_PCM_PAMF_DECODER) += pcm-bluray.o + OBJS-$(CONFIG_PCM_S8_DECODER) += pcm.o + OBJS-$(CONFIG_PCM_S8_ENCODER) += pcm.o + OBJS-$(CONFIG_PCM_S8_PLANAR_DECODER) += pcm.o +@@ -1243,6 +1244,7 @@ OBJS-$(CONFIG_ADX_PARSER) += adx_parser.o + OBJS-$(CONFIG_AHX_PARSER) += ahx_parser.o + OBJS-$(CONFIG_AMR_PARSER) += amr_parser.o + OBJS-$(CONFIG_APV_PARSER) += apv_parser.o ++OBJS-$(CONFIG_ATRAC3P_ATS_PARSER) += atrac3plus_ats_parser.o + OBJS-$(CONFIG_AV1_PARSER) += av1_parser.o av1_parse.o + OBJS-$(CONFIG_AVS2_PARSER) += avs2.o avs2_parser.o + OBJS-$(CONFIG_AVS3_PARSER) += avs3_parser.o +@@ -1287,6 +1289,7 @@ OBJS-$(CONFIG_MPEG4VIDEO_PARSER) += mpeg4video_parser.o h263.o \ + OBJS-$(CONFIG_MPEGAUDIO_PARSER) += mpegaudio_parser.o + OBJS-$(CONFIG_MPEGVIDEO_PARSER) += mpegvideo_parser.o mpeg12data.o + OBJS-$(CONFIG_OPUS_PARSER) += vorbis_data.o ++OBJS-$(CONFIG_PCM_PSMF_PARSER) += pcm_psmf_parser.o + OBJS-$(CONFIG_PNG_PARSER) += png_parser.o + OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o + OBJS-$(CONFIG_PRORES_RAW_PARSER) += prores_raw_parser.o +diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c +index 695214f192..c67505338f 100644 +--- a/libavcodec/allcodecs.c ++++ b/libavcodec/allcodecs.c +@@ -456,6 +456,7 @@ 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_atrac3p_ats_decoder; + extern const FFCodec ff_atrac9_decoder; + extern const FFCodec ff_binkaudio_dct_decoder; + extern const FFCodec ff_binkaudio_rdft_decoder; +@@ -585,6 +586,7 @@ 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_pamf_decoder; + extern const FFCodec ff_pcm_s8_encoder; + extern const FFCodec ff_pcm_s8_decoder; + extern const FFCodec ff_pcm_s8_planar_encoder; +diff --git a/libavcodec/atrac3plus.h b/libavcodec/atrac3plus.h +index aa949a7e4c..adbbce3bd8 100644 +--- a/libavcodec/atrac3plus.h ++++ b/libavcodec/atrac3plus.h +@@ -48,6 +48,10 @@ + /** Global constants */ + #define ATRAC3P_POWER_COMP_OFF 15 ///< disable power compensation + ++/** ATS header constants */ ++#define ATRAC3P_ATS_SYNC_WORD 0x0fd0 ++#define ATRAC3P_ATS_HEADER_SIZE 8 ++ + /** ATRAC3+ channel unit types */ + enum Atrac3pChannelUnitTypes { + CH_UNIT_MONO = 0, ///< unit containing one coded channel +diff --git a/libavcodec/atrac3plus_ats_parser.c b/libavcodec/atrac3plus_ats_parser.c +new file mode 100644 +index 0000000000..cad5145e37 +--- /dev/null ++++ b/libavcodec/atrac3plus_ats_parser.c +@@ -0,0 +1,157 @@ ++/* ++ * ATRAC3+ ATS parser ++ * Copyright (c) 2026 Simon Capriotti ++ * ++ * 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 "atrac3plus.h" ++#include "atrac3plus_ats_parser.h" ++#include "codec_id.h" ++#include "get_bits.h" ++#include "parser.h" ++#include "parser_internal.h" ++ ++int ff_atrac3p_ats_parse_header(const uint8_t *buf, int buf_size, AVCodecContext *avctx, ++ Atrac3pAtsDownmixLevels *downmix_levels) ++{ ++ static const uint16_t ch_layouts_tab[7] = { ++ AV_CH_LAYOUT_MONO, ++ AV_CH_LAYOUT_STEREO, ++ AV_CH_LAYOUT_SURROUND, ++ AV_CH_LAYOUT_4POINT0, ++ AV_CH_LAYOUT_5POINT1_BACK, ++ AV_CH_LAYOUT_6POINT1_BACK, ++ AV_CH_LAYOUT_7POINT1 ++ }; ++ static const uint16_t sample_rate_tab[3] = { 32000, 44100, 48000 }; ++ ++ GetBitContext gb; ++ ++ if (buf_size < ATRAC3P_ATS_HEADER_SIZE) { ++ av_log(avctx, AV_LOG_ERROR, "buf_size is too small\n"); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ const int ret = init_get_bits8(&gb, buf, buf_size); ++ av_assert0(ret == 0); ++ ++ const uint16_t sync_word = get_bits(&gb, 16); ++ if (sync_word != ATRAC3P_ATS_SYNC_WORD) { ++ av_log(avctx, AV_LOG_ERROR, "Invalid sync word in the ATS header (%04X)\n", ++ sync_word); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ const uint8_t sample_rate_idc = get_bits(&gb, 3); ++ if (sample_rate_idc >= FF_ARRAY_ELEMS(sample_rate_tab)) { ++ av_log(avctx, AV_LOG_ERROR, "Invalid sample rate indicator in the ATS header (%d)\n", ++ sample_rate_idc); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ const uint16_t sample_rate = sample_rate_tab[sample_rate_idc]; ++ ++ const uint8_t channel_config_idc = get_bits(&gb, 3); ++ if (channel_config_idc - 1 >= FF_ARRAY_ELEMS(ch_layouts_tab)) { ++ av_log(avctx, AV_LOG_ERROR, "Invalid channel configuration indicator in the ATS header (%d)\n", ++ channel_config_idc); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ const uint16_t ch_layout_mask = ch_layouts_tab[channel_config_idc - 1]; ++ ++ const uint16_t block_align = (get_bits(&gb, 10) + 1) * 8 + ATRAC3P_ATS_HEADER_SIZE; ++ ++ if (downmix_levels) { ++ downmix_levels->front_downmix_level = get_bits(&gb, 3); ++ downmix_levels->center_downmix_level = get_bits(&gb, 3); ++ downmix_levels->back_downmix_level = get_bits(&gb, 3); ++ downmix_levels->lfe_downmix_level = get_bits(&gb, 3); ++ downmix_levels->side_downmix_level = get_bits(&gb, 3); ++ } ++ ++ avctx->sample_rate = sample_rate; ++ av_channel_layout_uninit(&avctx->ch_layout); ++ av_channel_layout_from_mask(&avctx->ch_layout, ch_layout_mask); ++ avctx->block_align = block_align; ++ avctx->frame_size = ATRAC3P_FRAME_SAMPLES; ++ avctx->bit_rate = block_align * CHAR_BIT * sample_rate / ATRAC3P_FRAME_SAMPLES; ++ return 0; ++} ++ ++typedef struct Atrac3pAtsParseContext { ++ ParseContext pc; ++ int remaining_size; ++} Atrac3pAtsParseContext; ++ ++static int parse(AVCodecParserContext *s1, AVCodecContext *avctx, ++ const uint8_t **poutbuf, int *poutbuf_size, ++ const uint8_t *buf, int buf_size) ++{ ++ Atrac3pAtsParseContext *const s = s1->priv_data; ++ int next = END_NOT_FOUND; ++ ++ s1->duration = ATRAC3P_FRAME_SAMPLES; ++ ++ if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES) { ++ (void)ff_atrac3p_ats_parse_header(buf, buf_size, avctx, NULL); ++ next = buf_size; ++ } else { ++ if (!s->pc.frame_start_found) ++ for (int i = 0; i < buf_size; i++) { ++ s->pc.state64 = (s->pc.state64 << 8) | buf[i]; ++ if (s->pc.state64 >> 48 == ATRAC3P_ATS_SYNC_WORD) { ++ uint8_t tmp_buf[ATRAC3P_ATS_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; ++ AV_WB64(tmp_buf, s->pc.state64); ++ if (ff_atrac3p_ats_parse_header(tmp_buf, ATRAC3P_ATS_HEADER_SIZE, avctx, NULL) < 0) ++ continue; ++ ++ s->pc.frame_start_found = 1; ++ s->remaining_size = avctx->block_align + i - 7; ++ break; ++ } ++ } ++ ++ if (s->pc.frame_start_found) ++ if (s->remaining_size <= buf_size) { ++ next = s->remaining_size; ++ s->remaining_size = 0; ++ s->pc.frame_start_found = 0; ++ s->pc.state64 = 0; ++ } else { ++ s->remaining_size -= buf_size; ++ } ++ ++ if (ff_combine_frame(&s->pc, next, &buf, &buf_size) < 0) { ++ *poutbuf = NULL; ++ *poutbuf_size = 0; ++ return buf_size; ++ } ++ } ++ ++ *poutbuf = buf; ++ *poutbuf_size = buf_size; ++ return next; ++} ++ ++const FFCodecParser ff_atrac3p_ats_parser = { ++ .codec_ids = { AV_CODEC_ID_ATRAC3P_ATS }, ++ .priv_data_size = sizeof(Atrac3pAtsParseContext), ++ .parse = parse, ++ .close = ff_parse_close, ++}; +diff --git a/libavcodec/atrac3plus_ats_parser.h b/libavcodec/atrac3plus_ats_parser.h +new file mode 100644 +index 0000000000..e3be20eb45 +--- /dev/null ++++ b/libavcodec/atrac3plus_ats_parser.h +@@ -0,0 +1,55 @@ ++/* ++ * ATRAC3plus ATS parser ++ * ++ * Copyright (c) 2026 Simon Capriotti ++ * ++ * 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_ATRAC3PLUS_ATS_PARSER_H ++#define AVCODEC_ATRAC3PLUS_ATS_PARSER_H ++ ++#include ++ ++/* TODO downmix levels from 0 to 7 are the following: ++ -0dB, -1.5dB, -3dB, -4.5dB, -6dB, -7.5dB, -9dB, -infinity dB */ ++typedef struct Atrac3pAtsDownmixLevels { ++ uint8_t front_downmix_level : 3; ++ uint8_t center_downmix_level : 3; ++ uint8_t back_downmix_level : 3; ++ uint8_t lfe_downmix_level : 3; ++ uint8_t side_downmix_level : 3; ++} Atrac3pAtsDownmixLevels; ++ ++/** ++ * Parses the ATS header and updates the codec context with the values from the ++ * header. ++ * ++ * Optionally retrieves downmix levels from the header. ++ * ++ * @param buf Input buffer containing the header ++ * @param buf_size Input buffer size ++ * @param avctx Codec context to update ++ * @param downmix_levels Will contain the downmix levels after parsing. ++ * Can be NULL ++ * @retval 0 Success ++ * @retval AVERROR_INVALIDDATA The header contained an invalid value ++ */ ++int ff_atrac3p_ats_parse_header(const uint8_t *buf, int buf_size, AVCodecContext *avctx, ++ Atrac3pAtsDownmixLevels *downmix_levels); ++ ++#endif /* AVCODEC_ATRAC3PLUS_ATS_PARSER_H */ +diff --git a/libavcodec/atrac3plusdec.c b/libavcodec/atrac3plusdec.c +index 9696a523be..aa0bc78bc1 100644 +--- a/libavcodec/atrac3plusdec.c ++++ b/libavcodec/atrac3plusdec.c +@@ -2,6 +2,7 @@ + * ATRAC3+ compatible decoder + * + * Copyright (c) 2010-2013 Maxim Poliakovski ++ * Copyright (c) 2026 Simon Capriotti + * + * This file is part of FFmpeg. + * +@@ -25,7 +26,9 @@ + * Sony ATRAC3+ compatible decoder. + * + * Container formats used to store its data: +- * RIFF WAV (.at3) and Sony OpenMG (.oma, .aa3). ++ * RIFF WAV (.at3, .atx), Sony OpenMG (.oma, .aa3), ++ * and MPEG-PS (PSP Movie Format (for UMD Video): .mps, ++ * PSP Movie Format (for games): .pmf, PlayStation Advanced Movie Format: .pam) + * + * Technical description of this codec can be found here: + * http://wiki.multimedia.cx/index.php?title=ATRAC3plus +@@ -34,6 +37,8 @@ + * for their precious technical help! + */ + ++#include "config_components.h" ++ + #include + #include + +@@ -169,16 +174,53 @@ static av_cold void atrac3p_init_static(void) + ff_atrac3p_init_dsp_static(); + } + ++static av_cold int init_ch_units(ATRAC3PContext *ctx, AVCodecContext *avctx) ++{ ++ int i, ch, ret; ++ ++ if ((ret = set_channel_params(ctx, avctx)) < 0) ++ return ret; ++ ++ ctx->ch_units = av_calloc(ctx->num_channel_blocks, sizeof(*ctx->ch_units)); ++ ++ if (!ctx->ch_units) { ++ return AVERROR(ENOMEM); ++ } ++ ++ for (i = 0; i < ctx->num_channel_blocks; i++) { ++ for (ch = 0; ch < 2; ch++) { ++ ctx->ch_units[i].channels[ch].ch_num = ch; ++ ctx->ch_units[i].channels[ch].wnd_shape = &ctx->ch_units[i].channels[ch].wnd_shape_hist[0][0]; ++ ctx->ch_units[i].channels[ch].wnd_shape_prev = &ctx->ch_units[i].channels[ch].wnd_shape_hist[1][0]; ++ ctx->ch_units[i].channels[ch].gain_data = &ctx->ch_units[i].channels[ch].gain_data_hist[0][0]; ++ ctx->ch_units[i].channels[ch].gain_data_prev = &ctx->ch_units[i].channels[ch].gain_data_hist[1][0]; ++ ctx->ch_units[i].channels[ch].tones_info = &ctx->ch_units[i].channels[ch].tones_info_hist[0][0]; ++ ctx->ch_units[i].channels[ch].tones_info_prev = &ctx->ch_units[i].channels[ch].tones_info_hist[1][0]; ++ } ++ ++ ctx->ch_units[i].waves_info = &ctx->ch_units[i].wave_synth_hist[0]; ++ ctx->ch_units[i].waves_info_prev = &ctx->ch_units[i].wave_synth_hist[1]; ++ } ++ ++ return 0; ++} ++ + static av_cold int atrac3p_decode_init(AVCodecContext *avctx) + { + static AVOnce init_static_once = AV_ONCE_INIT; + ATRAC3PContext *ctx = avctx->priv_data; + float scale; +- int i, ch, ret; ++ int ret; ++ ++ if (avctx->codec_id != AV_CODEC_ID_ATRAC3P_ATS) { ++ if (!avctx->block_align) { ++ av_log(avctx, AV_LOG_ERROR, "block_align is not set\n"); ++ return AVERROR(EINVAL); ++ } + +- if (!avctx->block_align) { +- av_log(avctx, AV_LOG_ERROR, "block_align is not set\n"); +- return AVERROR(EINVAL); ++ ret = init_ch_units(ctx, avctx); ++ if (ret < 0) ++ return ret; + } + + /* initialize IPQF */ +@@ -196,30 +238,10 @@ static av_cold int atrac3p_decode_init(AVCodecContext *avctx) + + ff_atrac_init_gain_compensation(&ctx->gainc_ctx, 6, 2); + +- if ((ret = set_channel_params(ctx, avctx)) < 0) +- return ret; +- +- ctx->ch_units = av_calloc(ctx->num_channel_blocks, sizeof(*ctx->ch_units)); + ctx->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); + +- if (!ctx->ch_units || !ctx->fdsp) { ++ if (!ctx->fdsp) + return AVERROR(ENOMEM); +- } +- +- for (i = 0; i < ctx->num_channel_blocks; i++) { +- for (ch = 0; ch < 2; ch++) { +- ctx->ch_units[i].channels[ch].ch_num = ch; +- ctx->ch_units[i].channels[ch].wnd_shape = &ctx->ch_units[i].channels[ch].wnd_shape_hist[0][0]; +- ctx->ch_units[i].channels[ch].wnd_shape_prev = &ctx->ch_units[i].channels[ch].wnd_shape_hist[1][0]; +- ctx->ch_units[i].channels[ch].gain_data = &ctx->ch_units[i].channels[ch].gain_data_hist[0][0]; +- ctx->ch_units[i].channels[ch].gain_data_prev = &ctx->ch_units[i].channels[ch].gain_data_hist[1][0]; +- ctx->ch_units[i].channels[ch].tones_info = &ctx->ch_units[i].channels[ch].tones_info_hist[0][0]; +- ctx->ch_units[i].channels[ch].tones_info_prev = &ctx->ch_units[i].channels[ch].tones_info_hist[1][0]; +- } +- +- ctx->ch_units[i].waves_info = &ctx->ch_units[i].wave_synth_hist[0]; +- ctx->ch_units[i].waves_info_prev = &ctx->ch_units[i].wave_synth_hist[1]; +- } + + avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; + +@@ -414,7 +436,9 @@ static int atrac3p_decode_frame(AVCodecContext *avctx, AVFrame *frame, + + *got_frame_ptr = 1; + +- return avctx->codec_id == AV_CODEC_ID_ATRAC3P ? FFMIN(avctx->block_align, avpkt->size) : avpkt->size; ++ return avctx->codec_id == AV_CODEC_ID_ATRAC3P ? FFMIN(avctx->block_align, avpkt->size) : ++ avctx->codec_id == AV_CODEC_ID_ATRAC3P_ATS ? FFMIN(avctx->block_align - ATRAC3P_ATS_HEADER_SIZE, avpkt->size) : ++ avpkt->size; + } + + const FFCodec ff_atrac3p_decoder = { +@@ -442,3 +466,64 @@ const FFCodec ff_atrac3pal_decoder = { + .close = atrac3p_decode_close, + FF_CODEC_DECODE_CB(atrac3p_decode_frame), + }; ++ ++#if CONFIG_ATRAC3P_ATS_DECODER ++ ++#include "atrac3plus_ats_parser.h" ++ ++typedef struct ATRAC3PATSContext { ++ ATRAC3PContext atrac3p_ctx; ++ uint64_t prev_header; ++} ATRAC3PATSContext; ++ ++static int atrac3p_ats_decode_frame(AVCodecContext *avctx, AVFrame *frame, ++ int *got_frame_ptr, AVPacket *avpkt) ++{ ++ ATRAC3PATSContext *const ctx = avctx->priv_data; ++ ++ if (avpkt->size < ATRAC3P_ATS_HEADER_SIZE) { ++ av_log(avctx, AV_LOG_ERROR, "Packet too small!\n"); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ const uint64_t ats_header = AV_RB64(avpkt->data); ++ if (ats_header != ctx->prev_header) { ++ Atrac3pAtsDownmixLevels downmix_levels; ++ ++ int ret = ff_atrac3p_ats_parse_header(avpkt->data, avpkt->size, avctx, &downmix_levels); ++ if (ret < 0) ++ return ret; ++ ++ av_freep(&ctx->atrac3p_ctx.ch_units); ++ ret = init_ch_units(&ctx->atrac3p_ctx, avctx); ++ if (ret < 0) ++ return ret; ++ ++ if (downmix_levels.front_downmix_level || downmix_levels.center_downmix_level || ++ downmix_levels.back_downmix_level || downmix_levels.lfe_downmix_level || ++ downmix_levels.side_downmix_level) ++ avpriv_report_missing_feature(avctx, "Downmixing"); ++ ++ ctx->prev_header = ats_header; ++ } ++ ++ avpkt->data += ATRAC3P_ATS_HEADER_SIZE; ++ avpkt->size -= ATRAC3P_ATS_HEADER_SIZE; ++ ++ return atrac3p_decode_frame(avctx, frame, got_frame_ptr, avpkt); ++} ++ ++const FFCodec ff_atrac3p_ats_decoder = { ++ .p.name = "atrac3plus_ats", ++ CODEC_LONG_NAME("ATRAC3+ ATS (Adaptive TRansform Acoustic Coding 3+ ATS syntax)"), ++ .p.type = AVMEDIA_TYPE_AUDIO, ++ .p.id = AV_CODEC_ID_ATRAC3P_ATS, ++ .p.capabilities = AV_CODEC_CAP_CHANNEL_CONF | AV_CODEC_CAP_DR1, ++ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, ++ .priv_data_size = sizeof(ATRAC3PATSContext), ++ .init = atrac3p_decode_init, ++ .close = atrac3p_decode_close, ++ FF_CODEC_DECODE_CB(atrac3p_ats_decode_frame), ++}; ++ ++#endif +diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c +index a9f21f8152..aab6c91b4d 100644 +--- a/libavcodec/codec_desc.c ++++ b/libavcodec/codec_desc.c +@@ -2263,6 +2263,13 @@ static const AVCodecDescriptor codec_descriptors[] = { + .long_name = NULL_IF_CONFIG_SMALL("PCM SGA"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, + }, ++ { ++ .id = AV_CODEC_ID_PCM_PAMF, ++ .type = AVMEDIA_TYPE_AUDIO, ++ .name = "pcm_pamf", ++ .long_name = NULL_IF_CONFIG_SMALL("PCM signed 16|24-bit big-endian for PAMF streams"), ++ .props = AV_CODEC_PROP_LOSSLESS, ++ }, + + /* various ADPCM codecs */ + { +@@ -3567,6 +3574,13 @@ static const AVCodecDescriptor codec_descriptors[] = { + .long_name = NULL_IF_CONFIG_SMALL("CRI AHX"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, + }, ++ { ++ .id = AV_CODEC_ID_ATRAC3P_ATS, ++ .type = AVMEDIA_TYPE_AUDIO, ++ .name = "atrac3plus_ats", ++ .long_name = NULL_IF_CONFIG_SMALL("ATRAC3+ ATS (Adaptive TRansform Acoustic Coding 3+ ATS Syntax)"), ++ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, ++ }, + + /* subtitle codecs */ + { +diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h +index 6529f0a6bc..fc2457a3d0 100644 +--- a/libavcodec/codec_id.h ++++ b/libavcodec/codec_id.h +@@ -372,6 +372,7 @@ enum AVCodecID { + AV_CODEC_ID_PCM_F24LE, + AV_CODEC_ID_PCM_VIDC, + AV_CODEC_ID_PCM_SGA, ++ AV_CODEC_ID_PCM_PAMF, + + /* various ADPCM codecs */ + AV_CODEC_ID_ADPCM_IMA_QT = 0x11000, +@@ -566,6 +567,7 @@ enum AVCodecID { + AV_CODEC_ID_LC3, + AV_CODEC_ID_G728, + AV_CODEC_ID_AHX, ++ AV_CODEC_ID_ATRAC3P_ATS, + + /* subtitle codecs */ + AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. +diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c +index 162b96cb69..d210e4ad17 100644 +--- a/libavcodec/parsers.c ++++ b/libavcodec/parsers.c +@@ -44,6 +44,7 @@ extern const FFCodecParser ff_adx_parser; + extern const FFCodecParser ff_ahx_parser; + extern const FFCodecParser ff_amr_parser; + extern const FFCodecParser ff_apv_parser; ++extern const FFCodecParser ff_atrac3p_ats_parser; + extern const FFCodecParser ff_av1_parser; + extern const FFCodecParser ff_avs2_parser; + extern const FFCodecParser ff_avs3_parser; +@@ -86,6 +87,7 @@ extern const FFCodecParser ff_mpeg4video_parser; + extern const FFCodecParser ff_mpegaudio_parser; + extern const FFCodecParser ff_mpegvideo_parser; + extern const FFCodecParser ff_opus_parser; ++extern const FFCodecParser ff_pcm_psmf_parser; + extern const FFCodecParser ff_prores_parser; + extern const FFCodecParser ff_png_parser; + extern const FFCodecParser ff_pnm_parser; +diff --git a/libavcodec/pcm-bluray.c b/libavcodec/pcm-bluray.c +index 194224c67e..e122c27eee 100644 +--- a/libavcodec/pcm-bluray.c ++++ b/libavcodec/pcm-bluray.c +@@ -1,6 +1,7 @@ + /* +- * LPCM codecs for PCM format found in Blu-ray PCM streams ++ * LPCM codecs for PCM format found in Blu-ray and PAMF PCM streams + * Copyright (c) 2009, 2013 Christian Schmidt ++ * Copyright (c) 2026 Simon Capriotti + * + * This file is part of FFmpeg. + * +@@ -21,15 +22,19 @@ + + /** + * @file +- * PCM codec for Blu-ray PCM audio tracks ++ * PCM codec for Blu-ray and PAMF PCM audio tracks + */ + ++#include "config_components.h" ++ + #include "libavutil/channel_layout.h" + #include "avcodec.h" + #include "bytestream.h" + #include "codec_internal.h" + #include "decode.h" + ++#define PCM_BLURAY_FRAMES_PER_SEC 200 ++ + /* + * Channel Mapping according to + * Blu-ray Disc Read-Only Format Version 1 +@@ -122,7 +127,7 @@ static int pcm_bluray_parse_header(AVCodecContext *avctx, + return 0; + } + +-static int pcm_bluray_decode_frame(AVCodecContext *avctx, AVFrame *frame, ++static int decode_frame(AVCodecContext *avctx, AVFrame *frame, + int *got_frame_ptr, AVPacket *avpkt) + { + const uint8_t *src = avpkt->data; +@@ -133,16 +138,6 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, AVFrame *frame, + int16_t *dst16; + int32_t *dst32; + +- if (buf_size < 4) { +- av_log(avctx, AV_LOG_ERROR, "PCM packet too small\n"); +- return AVERROR_INVALIDDATA; +- } +- +- if ((retval = pcm_bluray_parse_header(avctx, src))) +- return retval; +- src += 4; +- buf_size -= 4; +- + bytestream2_init(&gb, src, buf_size); + + /* There's always an even number of channels in the source */ +@@ -297,9 +292,28 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, AVFrame *frame, + if (avctx->debug & FF_DEBUG_BITSTREAM) + ff_dlog(avctx, "pcm_bluray_decode_frame: decoded %d -> %d bytes\n", + retval, buf_size); +- return retval + 4; ++ return retval; ++} ++ ++static int pcm_bluray_decode_frame(AVCodecContext *avctx, AVFrame *frame, ++ int *got_frame_ptr, AVPacket *avpkt) ++{ ++ int retval; ++ ++ if (avpkt->size < 4) { ++ av_log(avctx, AV_LOG_ERROR, "PCM packet too small\n"); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ if ((retval = pcm_bluray_parse_header(avctx, avpkt->data))) ++ return retval; ++ ++ avpkt->data += 4; ++ avpkt->size -= 4; ++ return decode_frame(avctx, frame, got_frame_ptr, avpkt); + } + ++#if CONFIG_PCM_BLURAY_DECODER + const FFCodec ff_pcm_bluray_decoder = { + .p.name = "pcm_bluray", + CODEC_LONG_NAME("PCM signed 16|20|24-bit big-endian for Blu-ray media"), +@@ -308,3 +322,71 @@ const FFCodec ff_pcm_bluray_decoder = { + FF_CODEC_DECODE_CB(pcm_bluray_decode_frame), + .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, + }; ++#endif ++ ++#if CONFIG_PCM_PAMF_DECODER ++ ++static int pcm_pamf_init_decode(AVCodecContext *avctx) ++{ ++ int ch_layout_mask; ++ ++ if (avctx->sample_rate != 48000) { ++ av_log(avctx, AV_LOG_FATAL, "Invalid sample rate (%d)\n", ++ avctx->sample_rate); ++ return AVERROR(EINVAL); ++ } ++ ++ switch (avctx->bits_per_coded_sample) { ++ case 16: ++ avctx->bits_per_raw_sample = 16; ++ avctx->sample_fmt = AV_SAMPLE_FMT_S16; ++ break; ++ case 24: ++ avctx->bits_per_raw_sample = 24; ++ avctx->sample_fmt = AV_SAMPLE_FMT_S32; ++ break; ++ default: ++ av_log(avctx, AV_LOG_FATAL, "Invalid sample depth (%d)\n", ++ avctx->bits_per_coded_sample); ++ return AVERROR(EINVAL); ++ } ++ ++ switch (avctx->ch_layout.nb_channels) { ++ case 1: ++ ch_layout_mask = AV_CH_LAYOUT_MONO; ++ break; ++ case 2: ++ ch_layout_mask = AV_CH_LAYOUT_STEREO; ++ break; ++ case 6: ++ ch_layout_mask = AV_CH_LAYOUT_5POINT1; ++ break; ++ case 8: ++ ch_layout_mask = AV_CH_LAYOUT_7POINT1; ++ break; ++ default: ++ av_log(avctx, AV_LOG_FATAL, "Invalid channel count (%d)\n", ++ avctx->ch_layout.nb_channels); ++ return AVERROR(EINVAL); ++ } ++ ++ av_channel_layout_uninit(&avctx->ch_layout); ++ av_channel_layout_from_mask(&avctx->ch_layout, ch_layout_mask); ++ ++ avctx->bit_rate = FFALIGN(avctx->ch_layout.nb_channels, 2) * avctx->sample_rate * ++ avctx->bits_per_coded_sample; ++ avctx->frame_size = avctx->sample_rate / PCM_BLURAY_FRAMES_PER_SEC; ++ return 0; ++} ++ ++const FFCodec ff_pcm_pamf_decoder = { ++ .p.name = "pcm_pamf", ++ CODEC_LONG_NAME("PCM signed 16|24-bit big-endian for PAMF streams"), ++ .p.type = AVMEDIA_TYPE_AUDIO, ++ .p.id = AV_CODEC_ID_PCM_PAMF, ++ .init = pcm_pamf_init_decode, ++ FF_CODEC_DECODE_CB(decode_frame), ++ .p.capabilities = AV_CODEC_CAP_DR1, ++}; ++ ++#endif +diff --git a/libavcodec/pcm_psmf_parser.c b/libavcodec/pcm_psmf_parser.c +new file mode 100644 +index 0000000000..57af69551c +--- /dev/null ++++ b/libavcodec/pcm_psmf_parser.c +@@ -0,0 +1,57 @@ ++/* ++ * PCM PSMF packetizer ++ * Copyright (c) 2026 Simon Capriotti ++ * ++ * 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 "codec_id.h" ++#include "parser.h" ++#include "parser_internal.h" ++ ++static int parse(AVCodecParserContext *s, AVCodecContext *avctx, ++ const uint8_t **poutbuf, int *poutbuf_size, ++ const uint8_t *buf, int buf_size) ++{ ++ ParseContext *const pc = s->priv_data; ++ ++ *poutbuf = NULL; ++ *poutbuf_size = 0; ++ ++ if (!avctx->block_align) { ++ av_log(avctx, AV_LOG_FATAL, "The container must set AVCodecContext.block_align!\n"); ++ return buf_size; ++ } ++ ++ const int remaining_size = avctx->block_align - pc->index; ++ ++ const int next = remaining_size <= buf_size ? remaining_size : END_NOT_FOUND; ++ ++ if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) ++ return buf_size; ++ ++ *poutbuf = buf; ++ *poutbuf_size = buf_size; ++ return next; ++} ++ ++const FFCodecParser ff_pcm_psmf_parser = { ++ .codec_ids = { AV_CODEC_ID_PCM_S16LE, AV_CODEC_ID_PCM_PAMF }, ++ .priv_data_size = sizeof(ParseContext), ++ .parse = parse, ++ .close = ff_parse_close, ++}; +diff --git a/libavcodec/utils.c b/libavcodec/utils.c +index 615d60cd58..759a7d2780 100644 +--- a/libavcodec/utils.c ++++ b/libavcodec/utils.c +@@ -599,6 +599,7 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, + if (framecount > INT_MAX/1024) + return 0; + return 1024 * framecount; ++ case AV_CODEC_ID_ATRAC3P_ATS: + case AV_CODEC_ID_ATRAC3P: return 2048; + case AV_CODEC_ID_MP2: + case AV_CODEC_ID_MUSEPACK7: return 1152; +diff --git a/libavformat/allformats.c b/libavformat/allformats.c +index 6ec361fb7b..4636020bdc 100644 +--- a/libavformat/allformats.c ++++ b/libavformat/allformats.c +@@ -389,6 +389,7 @@ extern const FFInputFormat ff_pdv_demuxer; + extern const FFInputFormat ff_pjs_demuxer; + extern const FFInputFormat ff_pmp_demuxer; + extern const FFInputFormat ff_pp_bnk_demuxer; ++extern const FFInputFormat ff_psmf_demuxer; + extern const FFOutputFormat ff_psp_muxer; + extern const FFInputFormat ff_pva_demuxer; + extern const FFInputFormat ff_pvf_demuxer; +diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c +index a7a2ef78e6..089c8f70e0 100644 +--- a/libavformat/mpeg.c ++++ b/libavformat/mpeg.c +@@ -33,6 +33,7 @@ + /* demux code */ + + #define MAX_SYNC_SIZE 100000 ++#define PSMF_PACK_SIZE_ALIGN 0x800 + + static int check_pes(const uint8_t *p, const uint8_t *end) + { +@@ -129,8 +130,18 @@ typedef struct MpegDemuxContext { + int dvd; + int imkh_cctv; + int raw_ac3; ++ int psmf; + } MpegDemuxContext; + ++typedef struct PsmfVideoStreamContext { ++ uint8_t keyframe; ++ int keyframs_size; ++} PsmfVideoStreamContext; ++ ++typedef struct PsmfAudioStreamContext { ++ uint8_t continuity; ++} PsmfAudioStreamContext; ++ + static int mpegps_read_header(AVFormatContext *s) + { + MpegDemuxContext *m = s->priv_data; +@@ -267,6 +278,59 @@ redo: + goto redo; + } + if (startcode == PRIVATE_STREAM_2) { ++ if (m->psmf) { ++ // private stream 2 is used as random access point information in PSMF streams ++ ++ // uint16_t: stream id ++ // uint16_t * 4: offsets to the next four reference pictures (can be -1 if there are less than four ref pics in this GOP or 0 in unknown cases) ++ // uint8_t * 4: unknown ++ // uint16_t: size of following fields ++ // uint16_t: number of pictures in this GOP ++ // for each picture: ++ // 1st to 8th bits: unknown ++ // 9th bit: reference picture indicator ++ // 10th to 32nd bits: coded picture size (max should be 0x12a800 for M2V, 0xcc000 for AVC) ++ ++ unsigned int len = avio_rb16(s->pb); ++ if (len < 22) { ++ av_log(s, AV_LOG_ERROR, "Invalid random access point info packet length\n"); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ const unsigned int stream_id = avio_rb16(s->pb); ++ len -= 2; ++ ++ if ((stream_id & PACKET_START_CODE_MASK) != PACKET_START_CODE_PREFIX || ++ (stream_id & 0xf0) != VIDEO_ID) { ++ av_log(s, AV_LOG_ERROR, "Invalid stream id in random access point info packet (%X)\n", ++ stream_id); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ avio_skip(s->pb, 16); ++ const int keyframe_size = avio_rb32(s->pb) & 0x7fffff; ++ len -= 20; ++ ++ unsigned int i; ++ for (i = 0; i < s->nb_streams; i++) ++ if (stream_id == (unsigned int)s->streams[i]->id) ++ break; ++ ++ if (i >= s->nb_streams) { ++ av_log(s, AV_LOG_ERROR, "Invalid stream id in random access point info packet (%X)\n", ++ stream_id); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ if (s->streams[i]->discard < AVDISCARD_ALL) { ++ PsmfVideoStreamContext *const ctx = s->streams[i]->priv_data; ++ ctx->keyframe = 1; ++ ctx->keyframs_size = keyframe_size; ++ } ++ ++ avio_skip(s->pb, len); ++ goto redo; ++ } + if (!m->sofdec) { + /* Need to detect whether this from a DVD or a 'Sofdec' stream */ + int len = avio_rb16(s->pb); +@@ -462,7 +526,7 @@ redo: + } + if (len < 0) + goto error_redo; +- if (dts != AV_NOPTS_VALUE && ppos) { ++ if (dts != AV_NOPTS_VALUE && ppos && !m->psmf) { + int i; + for (i = 0; i < s->nb_streams; i++) { + if (startcode == s->streams[i]->id && +@@ -527,6 +591,11 @@ redo: + goto found; + } + ++ if (m->psmf) { ++ av_log(s, AV_LOG_ERROR, "Unknown stream found (%X)\n", startcode); ++ goto redo; ++ } ++ + es_type = m->psm_es_type[startcode & 0xff]; + if (es_type == STREAM_TYPE_VIDEO_MPEG1) { + codec_id = AV_CODEC_ID_MPEG2VIDEO; +@@ -656,6 +725,64 @@ found: + len -=6; + } + } ++ ++ if (m->psmf) { ++ dummy_pos &= ~(PSMF_PACK_SIZE_ALIGN - 1); ++ ++ switch (st->codecpar->codec_type) { ++ case AVMEDIA_TYPE_VIDEO: { ++ PsmfVideoStreamContext *const ctx = st->priv_data; ++ ++ if (ctx->keyframe) { ++ if (dts == AV_NOPTS_VALUE || pts == AV_NOPTS_VALUE) { ++ av_log(s, AV_LOG_ERROR, "Random access info packet wasn't" ++ " immediately followed by the start of a new frame\n"); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ ff_reduce_index(s, st->index); ++ av_add_index_entry(st, dummy_pos, pts, ctx->keyframs_size, 0, AVINDEX_KEYFRAME); ++ ctx->keyframe = 0; ++ } ++ break; ++ } ++ case AVMEDIA_TYPE_AUDIO: { ++ PsmfAudioStreamContext *const ctx = st->priv_data; ++ const uint16_t next_frame_offset_mask = ++ st->codecpar->codec_id == AV_CODEC_ID_PCM_PAMF ? 0x7ff : 0xffff; ++ const uint16_t next_frame_offset = ++ avio_rb24(s->pb) & next_frame_offset_mask; ++ ++ len -= 3; ++ ++ if (!ctx->continuity) { ++ if (next_frame_offset == next_frame_offset_mask) ++ goto skip; ++ ++ if (next_frame_offset > len) { ++ av_log(s, AV_LOG_ERROR, "Invalid next frame offset!\n"); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ avio_skip(s->pb, next_frame_offset); ++ len -= next_frame_offset; ++ ctx->continuity = 1; ++ } ++ break; ++ } ++ case AVMEDIA_TYPE_DATA: ++ avpriv_report_missing_feature(s, "User data stream demuxing"); ++ avio_skip(s->pb, 1); ++ len--; ++ ++ if (pts != AV_NOPTS_VALUE) { // start of new frame ++ avio_rb32(s->pb); // size of this frame in bytes ++ avio_skip(s->pb, 4); ++ len -= 8; ++ } ++ } ++ } ++ + ret = av_get_packet(s->pb, pkt, len); + + pkt->pts = pts; +@@ -1072,3 +1199,7 @@ const FFInputFormat ff_vobsub_demuxer = { + .read_close = vobsub_read_close, + }; + #endif ++ ++#if CONFIG_PSMF_DEMUXER ++#include "psmf.h" ++#endif +diff --git a/libavformat/mpeg.h b/libavformat/mpeg.h +index 20592eb184..b42e7c858f 100644 +--- a/libavformat/mpeg.h ++++ b/libavformat/mpeg.h +@@ -61,6 +61,10 @@ + + #define STREAM_TYPE_AUDIO_AC3 0x81 + ++#define STREAM_TYPE_PSMF_AUDIO_PCM 0x80 ++#define STREAM_TYPE_PSMF_AUDIO_ATRAC3P 0xdc ++#define STREAM_TYPE_PSMF_USER_DATA 0xdd ++ + static const int lpcm_freq_tab[4] = { 48000, 96000, 44100, 32000 }; + + /** +diff --git a/libavformat/psmf.h b/libavformat/psmf.h +new file mode 100644 +index 0000000000..6bd0a8c592 +--- /dev/null ++++ b/libavformat/psmf.h +@@ -0,0 +1,1011 @@ ++/* ++ * PSMF/PAMF demuxer ++ * Copyright (c) 2026 Simon Capriotti ++ * ++ * 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 AVFORMAT_PSMF_H ++#define AVFORMAT_PSMF_H ++ ++#include "libavcodec/avcodec.h" ++#include "libavutil/avassert.h" ++ ++#define PSMF_MAGIC "PSMF" ++#define PSMF_VERSION_12 "0012" ++#define PSMF_VERSION_13 "0013" ++#define PSMF_VERSION_14 "0014" ++#define PSMF_VERSION_15 "0015" ++#define PAMF_MAGIC "PAMF" ++#define PAMF_VERSION_40 "0040" ++#define PAMF_VERSION_41 "0041" ++#define PSMF_PCM_FRAME_SIZE 80 ++ ++typedef struct PsmfContext { ++ MpegDemuxContext mpeg; ++ int64_t prev_position; ++} PsmfContext; ++ ++static int psmf_probe(const AVProbeData *p) ++{ ++ if (memcmp(p->buf, PSMF_MAGIC, strlen(PSMF_MAGIC)) == 0 && ++ (memcmp(p->buf + 4, PSMF_VERSION_12, strlen(PSMF_VERSION_12)) == 0 || ++ memcmp(p->buf + 4, PSMF_VERSION_13, strlen(PSMF_VERSION_13)) == 0 || ++ memcmp(p->buf + 4, PSMF_VERSION_14, strlen(PSMF_VERSION_14)) == 0 || ++ memcmp(p->buf + 4, PSMF_VERSION_15, strlen(PSMF_VERSION_15)) == 0)) ++ return AVPROBE_SCORE_MAX; ++ if (memcmp(p->buf, PAMF_MAGIC, strlen(PAMF_MAGIC)) == 0 && ++ (memcmp(p->buf + 4, PAMF_VERSION_40, strlen(PAMF_VERSION_40)) == 0 || ++ memcmp(p->buf + 4, PAMF_VERSION_41, strlen(PAMF_VERSION_41)) == 0)) ++ return AVPROBE_SCORE_MAX; ++ return 0; ++} ++ ++static int psmf_set_stream_aspect_ratio(uint8_t aspect_ratio_idc, ++ uint16_t sar_width, ++ uint16_t sar_height, AVStream *s) ++{ ++ switch (aspect_ratio_idc) { ++ case 1: ++ s->codecpar->sample_aspect_ratio.num = 1; ++ s->codecpar->sample_aspect_ratio.den = 1; ++ s->sample_aspect_ratio.num = 1; ++ s->sample_aspect_ratio.den = 1; ++ return 0; ++ case 2: ++ s->codecpar->sample_aspect_ratio.num = 12; ++ s->codecpar->sample_aspect_ratio.den = 11; ++ s->sample_aspect_ratio.num = 12; ++ s->sample_aspect_ratio.den = 11; ++ return 0; ++ case 3: ++ s->codecpar->sample_aspect_ratio.num = 10; ++ s->codecpar->sample_aspect_ratio.den = 11; ++ s->sample_aspect_ratio.num = 10; ++ s->sample_aspect_ratio.den = 11; ++ return 0; ++ case 4: ++ s->codecpar->sample_aspect_ratio.num = 16; ++ s->codecpar->sample_aspect_ratio.den = 11; ++ s->sample_aspect_ratio.num = 16; ++ s->sample_aspect_ratio.den = 11; ++ return 0; ++ case 5: ++ s->codecpar->sample_aspect_ratio.num = 40; ++ s->codecpar->sample_aspect_ratio.den = 33; ++ s->sample_aspect_ratio.num = 40; ++ s->sample_aspect_ratio.den = 33; ++ return 0; ++ case 14: ++ s->codecpar->sample_aspect_ratio.num = 4; ++ s->codecpar->sample_aspect_ratio.den = 3; ++ s->sample_aspect_ratio.num = 4; ++ s->sample_aspect_ratio.den = 3; ++ return 0; ++ case 0xff: ++ s->codecpar->sample_aspect_ratio.num = sar_width; ++ s->codecpar->sample_aspect_ratio.den = sar_height; ++ s->sample_aspect_ratio.num = sar_width; ++ s->sample_aspect_ratio.den = sar_height; ++ return 0; ++ default: ++ av_log(s, AV_LOG_FATAL, "Invalid aspect ratio indicator (%d)\n", ++ aspect_ratio_idc); ++ return AVERROR_INVALIDDATA; ++ } ++} ++ ++static int psmf_set_stream_frame_rate(uint8_t frame_rate_info, AVStream *s) ++{ ++ switch (frame_rate_info) { ++ case 0: ++ s->codecpar->framerate.num = 24000; ++ s->codecpar->framerate.den = 1001; ++ s->avg_frame_rate.num = 24000; ++ s->avg_frame_rate.den = 1001; ++ s->r_frame_rate.num = 24000; ++ s->r_frame_rate.den = 1001; ++ return 0; ++ case 1: ++ s->codecpar->framerate.num = 24; ++ s->codecpar->framerate.den = 1; ++ s->avg_frame_rate.num = 24; ++ s->avg_frame_rate.den = 1; ++ s->r_frame_rate.num = 24; ++ s->r_frame_rate.den = 1; ++ return 0; ++ case 2: ++ s->codecpar->framerate.num = 25; ++ s->codecpar->framerate.den = 1; ++ s->avg_frame_rate.num = 25; ++ s->avg_frame_rate.den = 1; ++ s->r_frame_rate.num = 25; ++ s->r_frame_rate.den = 1; ++ return 0; ++ case 3: ++ s->codecpar->framerate.num = 30000; ++ s->codecpar->framerate.den = 1001; ++ s->avg_frame_rate.num = 30000; ++ s->avg_frame_rate.den = 1001; ++ s->r_frame_rate.num = 30000; ++ s->r_frame_rate.den = 1001; ++ return 0; ++ case 4: ++ s->codecpar->framerate.num = 30; ++ s->codecpar->framerate.den = 1; ++ s->avg_frame_rate.num = 30; ++ s->avg_frame_rate.den = 1; ++ s->r_frame_rate.num = 30; ++ s->r_frame_rate.den = 1; ++ return 0; ++ case 5: ++ s->codecpar->framerate.num = 50; ++ s->codecpar->framerate.den = 1; ++ s->avg_frame_rate.num = 50; ++ s->avg_frame_rate.den = 1; ++ s->r_frame_rate.num = 50; ++ s->r_frame_rate.den = 1; ++ return 0; ++ case 6: ++ s->codecpar->framerate.num = 60000; ++ s->codecpar->framerate.den = 1001; ++ s->avg_frame_rate.num = 60000; ++ s->avg_frame_rate.den = 1001; ++ s->r_frame_rate.num = 60000; ++ s->r_frame_rate.den = 1001; ++ return 0; ++ default: ++ av_log(s, AV_LOG_FATAL, "Invalid frame rate indicator (%d)\n", ++ frame_rate_info); ++ return AVERROR_INVALIDDATA; ++ } ++} ++ ++static int pamf_parse_avc_info(AVStream *s, AVIOContext *pb) ++{ ++ const uint8_t profile_idc = avio_r8(pb); ++ const uint8_t level_idc = avio_r8(pb); ++ const uint8_t flags_1 = avio_r8(pb); ++ const uint8_t frame_mbs_only_flag = flags_1 >> 7; ++ const uint8_t video_signal_info_flag = flags_1 >> 6 & 1; ++ const uint8_t frame_rate_info = (flags_1 & 0xf) - 1; ++ const uint8_t aspect_ratio_idc = avio_r8(pb); ++ const uint16_t sar_width = avio_rb16(pb); ++ const uint16_t sar_height = avio_rb16(pb); ++ const uint16_t horizontal_size = (avio_r8(pb), avio_r8(pb) * 0x10); ++ const uint16_t vertical_size = (avio_r8(pb), avio_r8(pb) * 0x10); ++ av_unused const uint16_t frame_crop_left_offset = avio_rb16(pb); ++ av_unused const uint16_t frame_crop_right_offset = avio_rb16(pb); ++ av_unused const uint16_t frame_crop_top_offset = avio_rb16(pb); ++ av_unused const uint16_t frame_crop_bottom_offset = avio_rb16(pb); ++ const uint8_t flags_2 = avio_r8(pb); ++ av_unused const uint8_t video_format = flags_2 >> 5; ++ const uint8_t video_full_range_flag = flags_2 >> 4 & 1; ++ const uint8_t color_primaries = avio_r8(pb); ++ const uint8_t transfer_characteristics = avio_r8(pb); ++ const uint8_t matrix_coefficients = avio_r8(pb); ++ const uint8_t flags_3 = avio_r8(pb); ++ av_unused const uint8_t entropy_coding_mode_flag = flags_3 >> 7; ++ av_unused const uint8_t deblocking_filter_flag = flags_3 >> 6 & 1; ++ av_unused const uint8_t min_num_slice_per_picture_idx = flags_3 >> 4 & 3; ++ av_unused const uint8_t nfw_idc = flags_3 & 3; ++ av_unused const uint8_t max_mean_bitrate = avio_r8(pb); ++ ++ avio_skip(pb, 6); // Unused ++ ++ s->codecpar->profile = profile_idc; ++ s->codecpar->level = level_idc; ++ ++ if (frame_mbs_only_flag) ++ s->codecpar->field_order = AV_FIELD_PROGRESSIVE; ++ ++ if (video_signal_info_flag) { ++ s->codecpar->color_range = video_full_range_flag + 1; ++ s->codecpar->color_primaries = color_primaries; ++ s->codecpar->color_trc = transfer_characteristics; ++ s->codecpar->color_space = matrix_coefficients; ++ } ++ ++ s->codecpar->format = AV_PIX_FMT_YUV420P; ++ ++ int ret = psmf_set_stream_aspect_ratio(aspect_ratio_idc, sar_width, sar_height, s); ++ if (ret != 0) ++ return ret; ++ ++ s->codecpar->width = horizontal_size; ++ s->codecpar->height = vertical_size; ++ ++ ret = psmf_set_stream_frame_rate(frame_rate_info, s); ++ if (ret != 0) ++ return ret; ++ ++ return 0; ++} ++ ++static int pamf_parse_m2v_info(AVStream *s, AVIOContext *pb) ++{ ++ const uint8_t profile_and_level_idc = avio_r8(pb); ++ const uint8_t profile_idc = profile_and_level_idc >> 4 & 3; ++ const uint8_t level_idc = profile_and_level_idc & 7; ++ avio_skip(pb, 1); // Unused ++ const uint8_t flags_1 = avio_r8(pb); ++ const uint8_t progressive_sequence = flags_1 >> 7; ++ const uint8_t video_signal_info_flag = flags_1 >> 6 & 1; ++ const uint8_t frame_rate_info = flags_1 & 0xf; ++ const uint8_t aspect_ratio_idc = avio_r8(pb); ++ const uint16_t sar_width = avio_rb16(pb); ++ const uint16_t sar_height = avio_rb16(pb); ++ avio_skip(pb, 1); // Unused ++ av_unused const uint16_t horizontal_size = avio_r8(pb) * 0x10; ++ avio_skip(pb, 1); // Unused ++ av_unused const uint16_t vertical_size = avio_r8(pb) * 0x10; ++ const uint16_t horizontal_size_value = avio_rb16(pb); ++ const uint16_t vertical_size_value = avio_rb16(pb); ++ avio_skip(pb, 4); // Unused ++ const uint8_t flags_2 = avio_r8(pb); ++ av_unused const uint8_t video_format = flags_2 >> 5; ++ const uint8_t video_full_range_flag = flags_2 >> 4 & 1; ++ const uint8_t color_primaries = avio_r8(pb); ++ const uint8_t transfer_characteristics = avio_r8(pb); ++ const uint8_t matrix_coefficients = avio_r8(pb); ++ ++ if (profile_and_level_idc != 0xff) { ++ if (profile_idc != 0) { ++ av_log(s, AV_LOG_FATAL, "Invalid profile indicator (%d)\n", ++ profile_idc); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ s->codecpar->profile = AV_PROFILE_MPEG2_MAIN; ++ s->codecpar->level = level_idc; ++ } ++ ++ if (progressive_sequence) ++ s->codecpar->field_order = AV_FIELD_PROGRESSIVE; ++ ++ if (video_signal_info_flag) { ++ s->codecpar->color_range = video_full_range_flag + 1; ++ s->codecpar->color_primaries = color_primaries; ++ s->codecpar->color_trc = transfer_characteristics; ++ s->codecpar->color_space = matrix_coefficients; ++ } ++ ++ s->codecpar->format = AV_PIX_FMT_YUV420P; ++ ++ int ret = psmf_set_stream_aspect_ratio(aspect_ratio_idc, sar_width, sar_height, s); ++ if (ret != 0) ++ return ret; ++ ++ s->codecpar->width = horizontal_size_value; ++ s->codecpar->height = vertical_size_value; ++ ++ ret = psmf_set_stream_frame_rate(frame_rate_info - 1, s); ++ if (ret != 0) ++ return ret; ++ ++ avio_skip(pb, 8); // Unused ++ ++ return 0; ++} ++ ++static int psmf_parse_audio_info(AVStream *s, AVIOContext *pb) ++{ ++ avio_skip(pb, 2); // Unused ++ const uint8_t nb_channels = avio_r8(pb); ++ const uint8_t sample_rate_idx = avio_r8(pb) & 0xf; ++ ++ int ch_layout_mask; ++ switch (nb_channels) { ++ case 1: ++ ch_layout_mask = AV_CH_LAYOUT_MONO; ++ break; ++ case 2: ++ ch_layout_mask = AV_CH_LAYOUT_STEREO; ++ break; ++ default: ++ av_log(s, AV_LOG_FATAL, "Invalid number of channels (%d)\n", nb_channels); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ av_channel_layout_from_mask(&s->codecpar->ch_layout, ch_layout_mask); ++ ++ if (sample_rate_idx != 2) { ++ av_log(s, AV_LOG_FATAL, "Invalid sample rate indicator (%d)\n", ++ sample_rate_idx); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ s->codecpar->sample_rate = 44100; ++ ++ if (s->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE) ++ s->codecpar->block_align = PSMF_PCM_FRAME_SIZE * nb_channels * sizeof(int16_t); ++ ++ return 0; ++} ++ ++static int pamf_parse_audio_info(AVStream *s, AVIOContext *pb) ++{ ++ avio_skip(pb, 2); // Unused ++ const uint8_t nb_channels = avio_r8(pb) & 0xf; ++ const uint8_t sample_rate_idx = avio_r8(pb) & 0xf; ++ const uint8_t bits_per_sample_idx = avio_r8(pb) >> 6; ++ avio_skip(pb, 27); // Unused ++ ++ int ch_layout_mask; ++ switch (nb_channels) { ++ case 1: ++ ch_layout_mask = AV_CH_LAYOUT_MONO; ++ break; ++ case 2: ++ ch_layout_mask = AV_CH_LAYOUT_STEREO; ++ break; ++ case 6: ++ ch_layout_mask = AV_CH_LAYOUT_5POINT1; ++ break; ++ case 8: ++ ch_layout_mask = AV_CH_LAYOUT_7POINT1; ++ break; ++ default: ++ av_log(s, AV_LOG_FATAL, "Invalid number of channels (%d)\n", nb_channels); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ av_channel_layout_from_mask(&s->codecpar->ch_layout, ch_layout_mask); ++ ++ if (sample_rate_idx != 1) { ++ av_log(s, AV_LOG_FATAL, "Invalid sample rate indicator (%d)\n", ++ sample_rate_idx); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ s->codecpar->sample_rate = 48000; ++ ++ if (s->codecpar->codec_id == AV_CODEC_ID_PCM_PAMF) { ++ switch (bits_per_sample_idx) { ++ case 1: ++ s->codecpar->bits_per_coded_sample = ++ s->codecpar->bits_per_raw_sample = 16; ++ s->codecpar->format = AV_SAMPLE_FMT_S16; ++ break; ++ case 3: ++ s->codecpar->bits_per_coded_sample = ++ s->codecpar->bits_per_raw_sample = 24; ++ s->codecpar->format = AV_SAMPLE_FMT_S32; ++ break; ++ default: ++ av_log(s, AV_LOG_FATAL, "Invalid bits per sample indicator (%d)\n", ++ bits_per_sample_idx); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ s->codecpar->bit_rate = FFALIGN(s->codecpar->ch_layout.nb_channels, 2) * ++ s->codecpar->sample_rate * s->codecpar->bits_per_coded_sample; ++ s->codecpar->frame_size = s->codecpar->sample_rate / 200; ++ s->codecpar->block_align = s->codecpar->bit_rate / CHAR_BIT / 200; ++ } else { ++ s->codecpar->format = AV_SAMPLE_FMT_FLT; ++ } ++ ++ return 0; ++} ++ ++static int psmf_parse_entry_point_table(AVFormatContext *s, AVStream *st, ++ uint32_t entry_point_table_offset, ++ uint32_t nb_entry_points, ++ uint64_t header_size, ++ uint64_t stream_size, ++ unsigned int *ep_tables_start_pos, ++ unsigned int *ep_tables_end_pos, int is_pamf) ++{ ++ av_assert0(ep_tables_start_pos && ep_tables_end_pos); ++ ++ const uint32_t ep_size = is_pamf ? 12 : 10; ++ ++ if (nb_entry_points == 0 && entry_point_table_offset != 0 || ++ nb_entry_points != 0 && entry_point_table_offset == 0 || ++ entry_point_table_offset + ++ nb_entry_points * ep_size > header_size) { ++ av_log(s, AV_LOG_FATAL, "Invalid entry point table offset (%X)" ++ " or number of entry points (%d)\n", ++ entry_point_table_offset, nb_entry_points); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ if (entry_point_table_offset == 0) ++ return 0; ++ ++ if (*ep_tables_start_pos == 0) { ++ *ep_tables_end_pos = *ep_tables_start_pos = entry_point_table_offset; ++ } else if (*ep_tables_end_pos != entry_point_table_offset) { ++ av_log(s, AV_LOG_FATAL, "Invalid entry point table offset (%X)\n", ++ entry_point_table_offset); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ *ep_tables_end_pos += nb_entry_points * ep_size; ++ ++ const int64_t pos = avio_tell(s->pb); ++ avio_seek(s->pb, entry_point_table_offset, SEEK_SET); ++ ++ uint64_t prev_offset = 0; ++ for (unsigned int i = 0; i < nb_entry_points; i++) { ++ int64_t pts; ++ if (is_pamf) { ++ avio_skip(s->pb, 2); // 2 bits: indexN, 1 bit: unused, 13 bits: nThRefPictureOffset ++ pts = (int64_t)avio_rb16(s->pb) << 32 | avio_rb32(s->pb); ++ } else { ++ // 2 bits: indexN, 2 bit: unused, 11 bits: nThRefPictureOffset ++ pts = ((int64_t)avio_rb16(s->pb) & 1) << 32 | avio_rb32(s->pb); ++ } ++ ++ if (pts > UINT32_MAX) { ++ av_log(s, AV_LOG_FATAL, "Invalid entry point pts (%lld)\n", pts); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ const uint64_t offset = (uint64_t)avio_rb32(s->pb) * PSMF_PACK_SIZE_ALIGN; // From the start of the MPEG-PS stream ++ if (offset > stream_size || offset < prev_offset) { ++ av_log(s, AV_LOG_FATAL, "Invalid entry point offset (%lld)\n", offset); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ ff_reduce_index(s, st->index); ++ av_add_index_entry(st, offset + header_size, pts, 0, offset - prev_offset, AVINDEX_KEYFRAME); ++ prev_offset = offset; ++ } ++ ++ avio_seek(s->pb, pos, SEEK_SET); ++ return 0; ++} ++ ++static int psmf_parse_stream_info(AVFormatContext *s, uint64_t header_size, ++ uint64_t stream_size, ++ unsigned int *ep_tables_start_pos, ++ unsigned int *ep_tables_end_pos) ++{ ++ MpegDemuxContext *m = s->priv_data; ++ ++ const uint8_t stream_id = avio_r8(s->pb); ++ const uint8_t private_stream_id = avio_r8(s->pb); ++ ++ uint8_t type; ++ if ((stream_id & 0xf0) == VIDEO_ID) { ++ if (m->psm_es_type[stream_id] != 0) { ++ av_log(s, AV_LOG_FATAL, "Stream id %X already in use\n", stream_id); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ m->psm_es_type[stream_id] = ++ type = STREAM_TYPE_VIDEO_H264; ++ } else if (stream_id == (PRIVATE_STREAM_1 & 0xff)) { ++ if (m->psm_es_type[private_stream_id] != 0) { ++ av_log(s, AV_LOG_FATAL, "Private stream id %X already in use\n", ++ private_stream_id); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ switch (private_stream_id & 0xf0) { ++ case 0x00: ++ m->psm_es_type[private_stream_id] = ++ type = STREAM_TYPE_PSMF_AUDIO_ATRAC3P; ++ break; ++ case 0x10: ++ m->psm_es_type[private_stream_id] = ++ type = STREAM_TYPE_PSMF_AUDIO_PCM; ++ break; ++ case 0x20: ++ m->psm_es_type[private_stream_id] = ++ type = STREAM_TYPE_PSMF_USER_DATA; ++ break; ++ default: ++ av_log(s, AV_LOG_FATAL, "Invalid private stream id (%X)\n", stream_id); ++ return AVERROR_INVALIDDATA; ++ } ++ } else { ++ av_log(s, AV_LOG_FATAL, "Invalid stream id (%X)\n", stream_id); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ AVStream *const st = avformat_new_stream(s, NULL); ++ if (!st) ++ return AVERROR(ENOMEM); ++ ++ st->time_base = (AVRational){ 1, 90000 }; ++ avpriv_stream_set_need_parsing(st, AVSTREAM_PARSE_FULL); ++ ++ avio_skip(s->pb, 2); // 2 bits: unused, 1 bit: P_STD_buffer_scale, 13 bits: P_STD_buffer_size ++ ++ const uint32_t entry_point_table_offset = avio_rb32(s->pb); ++ const uint32_t nb_entry_points = avio_rb32(s->pb); ++ int ret = psmf_parse_entry_point_table(s, st, entry_point_table_offset, ++ nb_entry_points, header_size, ++ stream_size, ep_tables_start_pos, ++ ep_tables_end_pos, 0); ++ if (ret < 0) ++ return ret; ++ ++ ret = 0; ++ switch (type) { ++ case STREAM_TYPE_VIDEO_H264: ++ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; ++ st->codecpar->codec_id = AV_CODEC_ID_H264; ++ st->id = 1 << 8 | stream_id; ++ ++ st->codecpar->profile = AV_PROFILE_H264_MAIN; ++ st->codecpar->level = 21; ++ st->codecpar->field_order = AV_FIELD_PROGRESSIVE; ++ st->codecpar->format = AV_PIX_FMT_YUV420P; ++ st->codecpar->sample_aspect_ratio.num = 1; ++ st->codecpar->sample_aspect_ratio.den = 1; ++ st->sample_aspect_ratio.num = 1; ++ st->sample_aspect_ratio.den = 1; ++ st->codecpar->framerate.num = 30000; ++ st->codecpar->framerate.den = 1001; ++ st->avg_frame_rate.num = 30000; ++ st->avg_frame_rate.den = 1001; ++ st->r_frame_rate.num = 30000; ++ st->r_frame_rate.den = 1001; ++ ++ st->codecpar->width = avio_r8(s->pb) * 16; ++ st->codecpar->height = avio_r8(s->pb) * 16; ++ ++ avio_skip(s->pb, 2); // Unused ++ break; ++ case STREAM_TYPE_PSMF_AUDIO_PCM: ++ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; ++ st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; ++ st->id = private_stream_id; ++ st->codecpar->format = AV_SAMPLE_FMT_S16; ++ st->codecpar->frame_size = PSMF_PCM_FRAME_SIZE; ++ ret = psmf_parse_audio_info(st, s->pb); ++ break; ++ case STREAM_TYPE_PSMF_AUDIO_ATRAC3P: ++ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; ++ st->codecpar->codec_id = AV_CODEC_ID_ATRAC3P_ATS; ++ st->id = private_stream_id; ++ st->codecpar->format = AV_SAMPLE_FMT_FLT; ++ ret = psmf_parse_audio_info(st, s->pb); ++ break; ++ case STREAM_TYPE_PSMF_USER_DATA: ++ st->codecpar->codec_type = AVMEDIA_TYPE_DATA; ++ st->codecpar->codec_id = AV_CODEC_ID_BIN_DATA; ++ st->id = private_stream_id; ++ avio_skip(s->pb, 4); // Unused ++ break; ++ default: ++ av_unreachable("The stream type wasn't set properly"); ++ } ++ ++ return ret; ++} ++ ++static int pamf_parse_stream_info(AVFormatContext *s, uint64_t header_size, ++ uint64_t stream_size, ++ unsigned int *ep_tables_start_pos, ++ unsigned int *ep_tables_end_pos) ++{ ++ MpegDemuxContext *m = s->priv_data; ++ ++ const uint8_t type = avio_r8(s->pb); ++ avio_skip(s->pb, 3); // Unused ++ const uint8_t stream_id = avio_r8(s->pb); ++ const uint8_t private_stream_id = avio_r8(s->pb); ++ ++ switch (type) { ++ case STREAM_TYPE_VIDEO_MPEG2: ++ case STREAM_TYPE_VIDEO_H264: ++ if ((stream_id & 0xf0) != VIDEO_ID) { ++ av_log(s, AV_LOG_FATAL, "Invalid stream id (%X)\n", stream_id); ++ return AVERROR_INVALIDDATA; ++ } ++ if (m->psm_es_type[stream_id] != 0) { ++ av_log(s, AV_LOG_FATAL, "Stream id %X already in use\n", stream_id); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ m->psm_es_type[stream_id] = type; ++ break; ++ ++ case STREAM_TYPE_PSMF_AUDIO_PCM: ++ case STREAM_TYPE_AUDIO_AC3: ++ case STREAM_TYPE_PSMF_AUDIO_ATRAC3P: ++ case STREAM_TYPE_PSMF_USER_DATA: ++ if (stream_id != (PRIVATE_STREAM_1 & 0xff)) { ++ av_log(s, AV_LOG_FATAL, "Invalid stream id (%X)\n", stream_id); ++ return AVERROR_INVALIDDATA; ++ } ++ if (private_stream_id >> 4 == 1 || ++ private_stream_id >> 4 > 4) { ++ av_log(s, AV_LOG_FATAL, "Invalid private stream id (%X)\n", stream_id); ++ return AVERROR_INVALIDDATA; ++ } ++ if (m->psm_es_type[private_stream_id] != 0) { ++ av_log(s, AV_LOG_FATAL, "Private stream id %X already in use\n", ++ private_stream_id); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ m->psm_es_type[private_stream_id] = type; ++ break; ++ ++ default: ++ av_log(s, AV_LOG_FATAL, "Invalid stream type (%X)\n", type); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ AVStream *const st = avformat_new_stream(s, NULL); ++ if (!st) ++ return AVERROR(ENOMEM); ++ ++ st->time_base = (AVRational){ 1, 90000 }; ++ avpriv_stream_set_need_parsing(st, AVSTREAM_PARSE_FULL); ++ ++ avio_skip(s->pb, 2); // 2 bits: unused, 1 bit: P_STD_buffer_scale, 13 bits: P_STD_buffer_size ++ ++ const uint32_t entry_point_table_offset = avio_rb32(s->pb); ++ const uint32_t nb_entry_points = avio_rb32(s->pb); ++ int ret = psmf_parse_entry_point_table(s, st, entry_point_table_offset, ++ nb_entry_points, header_size, ++ stream_size, ep_tables_start_pos, ++ ep_tables_end_pos, 1); ++ if (ret < 0) ++ return ret; ++ ++ ret = 0; ++ switch (type) { ++ case STREAM_TYPE_VIDEO_MPEG2: ++ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; ++ st->codecpar->codec_id = AV_CODEC_ID_MPEG2VIDEO; ++ st->id = 1 << 8 | stream_id; ++ ret = pamf_parse_m2v_info(st, s->pb); ++ break; ++ case STREAM_TYPE_VIDEO_H264: ++ st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; ++ st->codecpar->codec_id = AV_CODEC_ID_H264; ++ st->id = 1 << 8 | stream_id; ++ ret = pamf_parse_avc_info(st, s->pb); ++ break; ++ case STREAM_TYPE_PSMF_AUDIO_PCM: ++ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; ++ st->codecpar->codec_id = AV_CODEC_ID_PCM_PAMF; ++ st->id = private_stream_id; ++ ret = pamf_parse_audio_info(st, s->pb); ++ break; ++ case STREAM_TYPE_AUDIO_AC3: ++ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; ++ st->codecpar->codec_id = AV_CODEC_ID_AC3; ++ st->id = private_stream_id; ++ ret = pamf_parse_audio_info(st, s->pb); ++ break; ++ case STREAM_TYPE_PSMF_AUDIO_ATRAC3P: ++ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; ++ st->codecpar->codec_id = AV_CODEC_ID_ATRAC3P_ATS; ++ st->id = private_stream_id; ++ ret = pamf_parse_audio_info(st, s->pb); ++ break; ++ case STREAM_TYPE_PSMF_USER_DATA: ++ st->codecpar->codec_type = AVMEDIA_TYPE_DATA; ++ st->codecpar->codec_id = AV_CODEC_ID_BIN_DATA; ++ st->id = private_stream_id; ++ break; ++ default: ++ av_unreachable("The stream type should have been checked above"); ++ } ++ ++ return ret; ++} ++ ++static int psmf_read_header(AVFormatContext *const s) ++{ ++ PsmfContext *const ctx = s->priv_data; ++ int is_pamf = 0; ++ ++ ctx->mpeg.psmf = 1; ++ s->packet_size = PSMF_PACK_SIZE_ALIGN; ++ ++ uint8_t magic[4] = { 0 }; ++ avio_read(s->pb, magic, sizeof(magic)); ++ ++ if (memcmp(magic, PAMF_MAGIC, strlen(PAMF_MAGIC)) == 0) { ++ is_pamf = 1; ++ } else if (memcmp(magic, PSMF_MAGIC, strlen(PSMF_MAGIC)) != 0) { ++ av_log(s, AV_LOG_FATAL, "Invalid magic string (%c%c%c%c)\n", ++ magic[0], magic[1], magic[2], magic[3]); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ uint8_t version[4] = { 0 }; ++ avio_read(s->pb, version, sizeof(version)); ++ ++ if (is_pamf && ++ memcmp(version, PAMF_VERSION_40, strlen(PAMF_VERSION_40)) != 0 && ++ memcmp(version, PAMF_VERSION_41, strlen(PAMF_VERSION_41)) != 0 || ++ !is_pamf && ++ memcmp(version, PSMF_VERSION_12, strlen(PSMF_VERSION_12)) != 0 && ++ memcmp(version, PSMF_VERSION_13, strlen(PSMF_VERSION_13)) != 0 && ++ memcmp(version, PSMF_VERSION_14, strlen(PSMF_VERSION_14)) != 0 && ++ memcmp(version, PSMF_VERSION_15, strlen(PSMF_VERSION_15)) != 0) { ++ av_log(s, AV_LOG_FATAL, "Invalid version (%c%c%c%c)\n", ++ version[0], version[1], version[2], version[3]); ++ return AVERROR_INVALIDDATA; ++ ++ } ++ ++ const uint64_t header_size = (uint64_t)avio_rb32(s->pb) * ++ (is_pamf ? PSMF_PACK_SIZE_ALIGN : 1); ++ const uint64_t stream_size = (uint64_t)avio_rb32(s->pb) * ++ (is_pamf ? PSMF_PACK_SIZE_ALIGN : 1); ++ ++ if (header_size == 0 || stream_size == 0 || ++ header_size + stream_size > (uint64_t)avio_size(s->pb)) { ++ av_log(s, AV_LOG_FATAL, "Invalid header size (%lld) or stream size (%lld)\n", ++ header_size, stream_size); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ const uint32_t psmf_marks_offset = avio_rb32(s->pb); ++ const uint32_t psmf_marks_size = avio_rb32(s->pb); ++ const uint32_t unk_offset = avio_rb32(s->pb); ++ const uint32_t unk_size = avio_rb32(s->pb); ++ ++ if (psmf_marks_offset == 0 && psmf_marks_size != 0 || ++ psmf_marks_offset != 0 && psmf_marks_size == 0 || ++ psmf_marks_offset + psmf_marks_size > header_size) { ++ av_log(s, AV_LOG_FATAL, "Invalid PSMF marks table offset (%X) or size (%d)\n", ++ psmf_marks_offset, psmf_marks_size); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ if (unk_offset != 0 || unk_size != 0) ++ return AVERROR_INVALIDDATA; ++ ++ avio_skip(s->pb, 0x30); // Unused ++ ++ const uint64_t seq_info_offset = avio_tell(s->pb); ++ ++ const uint32_t seq_info_size = avio_rb32(s->pb); ++ ++ if (seq_info_offset + sizeof(uint32_t) + seq_info_size > header_size) { ++ av_log(s, AV_LOG_FATAL, "Invalid sequence info size (%d)\n", ++ seq_info_size); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ if (is_pamf) ++ avio_rb16(s->pb); // Unused ++ ++ const int64_t start_pts = (int64_t)avio_rb16(s->pb) << 32 | avio_rb32(s->pb); ++ const int64_t end_pts = (int64_t)avio_rb16(s->pb) << 32 | avio_rb32(s->pb); ++ ++ if (end_pts >= UINT32_MAX || start_pts >= end_pts) { ++ av_log(s, AV_LOG_FATAL, "Invalid start time stamp (%lld) or end time stamp (%lld)\n", ++ start_pts, end_pts); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ s->duration = (end_pts - start_pts) * AV_TIME_BASE / 90000; ++ ++ av_unused const uint32_t mux_rate_bound = avio_rb32(s->pb); ++ av_unused const uint32_t std_delay = avio_rb32(s->pb); ++ ++ av_unused const uint32_t nb_streams = is_pamf ? avio_rb32(s->pb) : avio_r8(s->pb); ++ ++ if (is_pamf) ++ avio_skip(s->pb, 1); // Unused ++ ++ const uint8_t nb_grp_periods = avio_r8(s->pb); ++ ++ if (nb_grp_periods != 1) { ++ av_log(s, AV_LOG_FATAL, "Invalid number of grouping periods (%d)\n", ++ nb_grp_periods); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ const uint64_t grp_period_offset = avio_tell(s->pb); ++ ++ const uint32_t grp_period_size = avio_rb32(s->pb); ++ ++ if (grp_period_offset + sizeof(uint32_t) + grp_period_size > header_size) { ++ av_log(s, AV_LOG_FATAL, "Invalid grouping period size (%d)\n", ++ grp_period_size); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ const int64_t grp_period_start_pts = (int64_t)avio_rb16(s->pb) << 32 | avio_rb32(s->pb); ++ const int64_t grp_period_end_pts = (int64_t)avio_rb16(s->pb) << 32 | avio_rb32(s->pb); ++ ++ if (grp_period_end_pts >= UINT32_MAX || ++ grp_period_start_pts >= grp_period_end_pts || ++ grp_period_start_pts != start_pts) { ++ av_log(s, AV_LOG_FATAL, "Invalid grouping period start time stamp (%lld)" ++ " or end time stamp (%lld)\n", ++ grp_period_start_pts, grp_period_end_pts); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ avio_skip(s->pb, 1); // Unused ++ ++ const uint8_t nb_grps = avio_r8(s->pb); ++ ++ if (nb_grps != 1) { ++ av_log(s, AV_LOG_FATAL, "Invalid number of groups (%d)\n", nb_grps); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ const uint64_t grp_offset = avio_tell(s->pb); ++ ++ const uint32_t grp_size = avio_rb32(s->pb); ++ ++ if (grp_offset + sizeof(uint32_t) + grp_size > header_size) { ++ av_log(s, AV_LOG_FATAL, "Invalid group size (%d)\n", grp_size); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ avio_skip(s->pb, 1); // Unused ++ ++ const uint8_t grp_nb_streams = avio_r8(s->pb); ++ ++ if (grp_nb_streams == 0 || grp_nb_streams != nb_streams) { ++ av_log(s, AV_LOG_FATAL, "Invalid number of streams in the group (%d)\n", ++ grp_nb_streams); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ unsigned int ep_tables_start_pos = 0; ++ unsigned int ep_tables_end_pos = 0; ++ for (int i = 0; i < grp_nb_streams; i++) { ++ const int ret = is_pamf ++ ? pamf_parse_stream_info(s, header_size, stream_size, ++ &ep_tables_start_pos, &ep_tables_end_pos) ++ : psmf_parse_stream_info(s, header_size, stream_size, ++ &ep_tables_start_pos, &ep_tables_end_pos); ++ if (ret < 0) ++ return ret; ++ ++ AVStream *const st = s->streams[i]; ++ switch (st->codecpar->codec_type) { ++ case AVMEDIA_TYPE_VIDEO: ++ st->priv_data = av_mallocz(sizeof(PsmfVideoStreamContext)); ++ if (!st->priv_data) ++ return AVERROR(ENOMEM); ++ break; ++ case AVMEDIA_TYPE_AUDIO: ++ st->priv_data = av_mallocz(sizeof(PsmfAudioStreamContext)); ++ if (!st->priv_data) ++ return AVERROR(ENOMEM); ++ } ++ } ++ ++ if (ep_tables_start_pos != 0) { ++ if (avio_tell(s->pb) != ep_tables_start_pos) { ++ av_log(s, AV_LOG_FATAL, "Entry point table not immediately after stream info\n"); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ avio_seek(s->pb, ep_tables_end_pos, SEEK_SET); ++ } ++ ++ if (psmf_marks_offset) { ++ if (psmf_marks_offset != avio_tell(s->pb)) { ++ av_log(s, AV_LOG_FATAL, "Invalid PSMF marks offset (%X)\n", ++ psmf_marks_offset); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ const uint32_t psmf_marks_size2 = avio_rb32(s->pb); ++ if (psmf_marks_size2 + sizeof(uint32_t) != psmf_marks_size) { ++ av_log(s, AV_LOG_FATAL, "Invalid PSMF marks size (%d)\n", ++ psmf_marks_size2); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ const uint16_t nb_psmf_marks = avio_rb16(s->pb); ++ if (nb_psmf_marks * 0x28 + sizeof(uint16_t) != psmf_marks_size2) { ++ av_log(s, AV_LOG_FATAL, "Invalid number of PSMF marks (%d)\n", ++ nb_psmf_marks); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ for (int i = 0; i < nb_psmf_marks; i++) { ++ const AVRational time_base = { 1, 90000 }; ++ const uint8_t type = avio_r8(s->pb); ++ const uint8_t name_length = avio_r8(s->pb); ++ if (name_length > 24) { ++ av_log(s, AV_LOG_FATAL, "Inavlid PSMF mark name length (%d)", ++ name_length); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ const uint64_t pts = avio_rb64(s->pb); ++ if (pts >= UINT32_MAX || pts < (uint64_t)start_pts || ++ pts > (uint64_t)end_pts) { ++ av_log(s, AV_LOG_FATAL, "Invalid PSMF mark time stamp (%lld)", pts); ++ return AVERROR_INVALIDDATA; ++ } ++ ++ av_unused const uint8_t stream_id = avio_r8(s->pb); ++ av_unused const uint8_t private_stream_id = avio_r8(s->pb); ++ uint8_t mark_data[4]; ++ avio_read(s->pb, mark_data, 4); ++ ++ char name[25]; ++ avio_read(s->pb, name, 24); ++ name[24] = '\0'; ++ ++ if (type == 5) ++ if (!avpriv_new_chapter(s, i, time_base, pts, AV_NOPTS_VALUE, name)) ++ return AVERROR_INVALIDDATA; ++ } ++ } ++ ++ avio_seek(s->pb, header_size, SEEK_SET); ++ ctx->prev_position = avio_tell(s->pb); ++ ++ return 0; ++} ++ ++static int psmf_read_packet(AVFormatContext *s, AVPacket *pkt) ++{ ++ PsmfContext *const ctx = s->priv_data; ++ ++ const int discontinuity = avio_tell(s->pb) != ctx->prev_position || ++ s->io_repositioned; ++ ++ // Make sure to always start demuxing at the start of a pack since ++ // startcodes can appear in the middle of PES packets ++ if (discontinuity) ++ avio_seek(s->pb, avio_tell(s->pb) & ~(PSMF_PACK_SIZE_ALIGN - 1), SEEK_SET); ++ ++ for (unsigned int i = 0; i < s->nb_streams; i++) { ++ AVStream *const st = s->streams[i]; ++ AVCodecParserContext **const parser = &ffstream(st)->parser; ++ ++ if (st->discard >= AVDISCARD_ALL || discontinuity) { ++ switch (st->codecpar->codec_type) { ++ case AVMEDIA_TYPE_VIDEO: ++ ((PsmfVideoStreamContext *)st->priv_data)->keyframe = 0; ++ break; ++ case AVMEDIA_TYPE_AUDIO: ++ ((PsmfAudioStreamContext *)st->priv_data)->continuity = 0; ++ } ++ ++ if (*parser) { ++ av_parser_close(*parser); ++ *parser = NULL; ++ } ++ } ++ } ++ ++ const int ret = mpegps_read_packet(s, pkt); ++ ++ ctx->prev_position = avio_tell(s->pb); ++ ++ return ret; ++} ++ ++const FFInputFormat ff_psmf_demuxer = { ++ .p.name = "psmf", ++ .p.long_name = NULL_IF_CONFIG_SMALL("PSP/PlayStation Advanced Movie Format"), ++ .priv_data_size = sizeof(PsmfContext), ++ .flags_internal = FF_INFMT_FLAG_INIT_CLEANUP, ++ .read_probe = psmf_probe, ++ .read_header = psmf_read_header, ++ .read_packet = psmf_read_packet, ++ .read_timestamp = mpegps_read_dts ++}; ++ ++#endif /* AVFORMAT_PSMF_H */ +diff --git a/libavformat/riff.c b/libavformat/riff.c +index fc79d0ac21..f655cea131 100644 +--- a/libavformat/riff.c ++++ b/libavformat/riff.c +@@ -664,6 +664,7 @@ const struct AVCodecTag *avformat_get_riff_audio_tags(void) + const AVCodecGuid ff_codec_wav_guids[] = { + { AV_CODEC_ID_AC3, { 0x2C, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB, 0xEA } }, + { AV_CODEC_ID_ATRAC3P, { 0xBF, 0xAA, 0x23, 0xE9, 0x58, 0xCB, 0x71, 0x44, 0xA1, 0x19, 0xFF, 0xFA, 0x01, 0xE4, 0xCE, 0x62 } }, ++ { AV_CODEC_ID_ATRAC3P_ATS, { 0x0D, 0x5C, 0x13, 0x50, 0x1B, 0xA2, 0xEC, 0x4B, 0x91, 0xED, 0x6E, 0xDD, 0xB8, 0x3C, 0x8C, 0x66 } }, + { AV_CODEC_ID_ATRAC9, { 0xD2, 0x42, 0xE1, 0x47, 0xBA, 0x36, 0x8D, 0x4D, 0x88, 0xFC, 0x61, 0x65, 0x4F, 0x8C, 0x83, 0x6C } }, + { AV_CODEC_ID_EAC3, { 0xAF, 0x87, 0xFB, 0xA7, 0x02, 0x2D, 0xFB, 0x42, 0xA4, 0xD4, 0x05, 0xCD, 0x93, 0x84, 0x3B, 0xDD } }, + { AV_CODEC_ID_MP2, { 0x2B, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB, 0xEA } }, +diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c +index 30835d5f36..c01c644ff0 100644 +--- a/libavformat/riffdec.c ++++ b/libavformat/riffdec.c +@@ -207,6 +207,9 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, + /* override bits_per_coded_sample for G.726 */ + if (par->codec_id == AV_CODEC_ID_ADPCM_G726 && par->sample_rate) + par->bits_per_coded_sample = par->bit_rate / par->sample_rate; ++ /* add the size of the ATS header for ATRAC3+ ATS */ ++ if (par->codec_id == AV_CODEC_ID_ATRAC3P_ATS) ++ par->block_align += 8; + + /* ignore WAVEFORMATEXTENSIBLE layout if different from channel count */ + if (channels != par->ch_layout.nb_channels) { diff --git a/ffmpeg.patch b/ffmpeg.patch index 7b91d9dbfb..635e94c7fe 100644 --- a/ffmpeg.patch +++ b/ffmpeg.patch @@ -1,46 +1,56 @@ diff --git a/ports/ffmpeg/portfile.cmake b/ports/ffmpeg/portfile.cmake -index 519b343af0..7740bd7c5a 100644 +index 6835d95c0c..e0060572b9 100644 --- a/ports/ffmpeg/portfile.cmake +++ b/ports/ffmpeg/portfile.cmake -@@ -29,7 +29,20 @@ if (VCPKG_TARGET_ARCHITECTURE STREQUAL "x86" OR VCPKG_TARGET_ARCHITECTURE STREQU - vcpkg_add_to_path("${NASM_EXE_PATH}") - endif() - --set(OPTIONS "--enable-pic --disable-doc --enable-debug --enable-runtime-cpudetect --disable-autodetect") -+set(OPTIONS "--enable-pic --disable-doc --enable-runtime-cpudetect --disable-autodetect") -+ -+# Only enable what is used by Vita3K -+string(APPEND OPTIONS " --disable-everything") -+string(APPEND OPTIONS " --enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=atrac3 --enable-decoder=atrac3p --enable-decoder=atrac9 --enable-decoder=mp3 --enable-decoder=pcm_s16le --enable-decoder=pcm_s8") +@@ -17,6 +17,7 @@ vcpkg_from_github( + 0046-fix-msvc-detection.patch + 0047-fix-msvc-utf8.patch + 0048-backport-23039.patch ++ ffmpeg-add-psmf-support.patch + ) + + if(SOURCE_PATH MATCHES " ") +@@ -33,6 +34,19 @@ endif() + + set(OPTIONS "--enable-pic --disable-doc --enable-runtime-cpudetect --disable-autodetect") + ++# Only enable what is used by RPCS3 ++string(APPEND OPTIONS " --disable-everything --disable-network") ++string(APPEND OPTIONS " --enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=ac3 --enable-decoder=atrac3 --enable-decoder=atrac3p --enable-decoder=atrac3p_ats --enable-decoder=atrac9 --enable-decoder=mp3 --enable-decoder=pcm_pamf --enable-decoder=pcm_s16le --enable-decoder=pcm_s8") +string(APPEND OPTIONS " --enable-decoder=mov --enable-decoder=h264 --enable-decoder=mpeg4 --enable-decoder=mpeg2video --enable-decoder=mjpeg --enable-decoder=mjpegb") -+string(APPEND OPTIONS " --enable-encoder=pcm_s16le") -+string(APPEND OPTIONS " --enable-encoder=ffv1 --enable-encoder=mpeg4 --enable-encoder=mjpeg") -+string(APPEND OPTIONS " --enable-muxer=avi") -+string(APPEND OPTIONS " --enable-demuxer=h264 --enable-demuxer=m4v --enable-demuxer=mp3 --enable-demuxer=mpegvideo --enable-demuxer=mpegps --enable-demuxer=mjpeg --enable-demuxer=mov --enable-demuxer=avi --enable-demuxer=aac --enable-demuxer=pmp --enable-demuxer=oma --enable-demuxer=pcm_s16le --enable-demuxer=pcm_s8 --enable-demuxer=wav") -+string(APPEND OPTIONS " --enable-parser=h264 --enable-parser=mpeg4video --enable-parser=mpegaudio --enable-parser=mpegvideo --enable-parser=mjpeg --enable-parser=aac --enable-parser=aac_latm") ++string(APPEND OPTIONS " --enable-encoder=pcm_s16le --enable-encoder=mp3 --enable-encoder=ac3 --enable-encoder=aac") ++string(APPEND OPTIONS " --enable-encoder=ffv1 --enable-encoder=mpeg4 --enable-encoder=mjpeg --enable-encoder=h264") ++string(APPEND OPTIONS " --enable-muxer=avi --enable-muxer=h264 --enable-muxer=mjpeg --enable-muxer=mp4") ++string(APPEND OPTIONS " --enable-demuxer=h264 --enable-demuxer=m4v --enable-demuxer=mp3 --enable-demuxer=mpegvideo --enable-demuxer=mpegps --enable-demuxer=mjpeg --enable-demuxer=mov --enable-demuxer=psmf --enable-demuxer=avi --enable-demuxer=aac --enable-demuxer=pmp --enable-demuxer=oma --enable-demuxer=pcm_s16le --enable-demuxer=pcm_s8 --enable-demuxer=wav") ++string(APPEND OPTIONS " --enable-parser=h264 --enable-parser=mpeg4video --enable-parser=mpegaudio --enable-parser=mpegvideo --enable-parser=mjpeg --enable-parser=aac --enable-parser=aac_latm --enable-parser=pcm_psmf") +string(APPEND OPTIONS " --enable-protocol=file") +string(APPEND OPTIONS " --enable-bsf=mjpeg2jpeg") +string(APPEND OPTIONS " --enable-indev=dshow") - ++ if(VCPKG_TARGET_IS_MINGW) if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") -@@ -61,7 +74,7 @@ endif() - vcpkg_cmake_get_vars(cmake_vars_file) - include("${cmake_vars_file}") - if(VCPKG_DETECTED_MSVC) -- string(APPEND OPTIONS " --disable-inline-asm") # clang-cl has inline assembly but this leads to undefined symbols. -+ # string(APPEND OPTIONS " --disable-inline-asm") # clang-cl has inline assembly but this leads to undefined symbols. - set(OPTIONS "--toolchain=msvc ${OPTIONS}") - # This is required because ffmpeg depends upon optimizations to link correctly - string(APPEND VCPKG_COMBINED_C_FLAGS_DEBUG " -O2") -@@ -713,6 +726,11 @@ if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") + string(APPEND OPTIONS " --target-os=mingw32") +@@ -426,11 +440,7 @@ if("openssl" IN_LIST FEATURES) + set(OPTIONS "${OPTIONS} --enable-openssl") + set(WITH_OPENSSL ON) + else() +- set(OPTIONS "${OPTIONS} --disable-openssl") +- if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_UWP) +- string(APPEND OPTIONS " --enable-schannel") +- set(WITH_SCHANNEL ON) +- endif() ++ set(OPTIONS "${OPTIONS} --disable-openssl --disable-schannel") + endif() + + if("opus" IN_LIST FEATURES) +@@ -749,6 +759,11 @@ if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") # We use response files here as the only known way to handle spaces in paths set(crsp "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/cflags.rsp") string(REGEX REPLACE "-arch [A-Za-z0-9_]+" "" VCPKG_COMBINED_C_FLAGS_RELEASE_SANITIZED "${VCPKG_COMBINED_C_FLAGS_RELEASE}") + if(VCPKG_TARGET_IS_OSX) -+ # macosx-version-min version is set with current macOS version. So replace them to 11.0 ++ # macosx-version-min version is set with current macOS version. So replace them to 14.0 + string(REGEX REPLACE "-mmacosx-version-min=[0-9]+.[0-9]+" "" VCPKG_COMBINED_C_FLAGS_RELEASE_SANITIZED "${VCPKG_COMBINED_C_FLAGS_RELEASE_SANITIZED}") -+ string(APPEND VCPKG_COMBINED_C_FLAGS_RELEASE_SANITIZED " -mmacosx-version-min=11.0") ++ string(APPEND VCPKG_COMBINED_C_FLAGS_RELEASE_SANITIZED " -mmacosx-version-min=14.0") + endif() file(WRITE "${crsp}" "${VCPKG_COMBINED_C_FLAGS_RELEASE_SANITIZED}") set(ldrsp "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/ldflags.rsp") diff --git a/include/libavcodec/avcodec.h b/include/libavcodec/avcodec.h index 77ca8dee1f..6824bfc9a6 100755 --- a/include/libavcodec/avcodec.h +++ b/include/libavcodec/avcodec.h @@ -187,17 +187,6 @@ struct AVCodecParameters; * @{ */ -#if FF_API_BUFFER_MIN_SIZE -/** - * @ingroup lavc_encoding - * minimum encoding buffer size - * Used to avoid some checks during header writing. - * @deprecated Unused: avcodec_receive_packet() does not work - * with preallocated packet buffers. - */ -#define AV_INPUT_BUFFER_MIN_SIZE 16384 -#endif - /** * @ingroup lavc_encoding */ @@ -234,18 +223,9 @@ typedef struct RcOverride{ * Use qpel MC. */ #define AV_CODEC_FLAG_QPEL (1 << 4) -#if FF_API_DROPCHANGED -/** - * Don't output frames whose parameters differ from first - * decoded frame in stream. - * - * @deprecated callers should implement this functionality in their own code - */ -#define AV_CODEC_FLAG_DROPCHANGED (1 << 5) -#endif /** * Request the encoder to output reconstructed frames, i.e.\ frames that would - * be produced by decoding the encoded bistream. These frames may be retrieved + * be produced by decoding the encoded bitstream. These frames may be retrieved * by calling avcodec_receive_frame() immediately after a successful call to * avcodec_receive_packet(). * @@ -435,6 +415,14 @@ typedef struct RcOverride{ */ #define AV_GET_ENCODE_BUFFER_FLAG_REF (1 << 0) +/** + * The decoder will bypass frame threading and return the next frame as soon as + * possible. Note that this may deliver frames earlier than the advertised + * `AVCodecContext.delay`. No effect when frame threading is disabled, or on + * encoding. + */ +#define AV_CODEC_RECEIVE_FRAME_FLAG_SYNCHRONOUS (1 << 0) + /** * main external API structure. * New fields can be added to the end with minor version bumps. @@ -515,16 +503,21 @@ typedef struct AVCodecContext { int flags2; /** - * some codecs need / can use extradata like Huffman tables. - * MJPEG: Huffman tables - * rv10: additional flags - * MPEG-4: global headers (they can be in the bitstream or here) - * The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger - * than extradata_size to avoid problems if it is read with the bitstream reader. - * The bytewise contents of extradata must not depend on the architecture or CPU endianness. - * Must be allocated with the av_malloc() family of functions. - * - encoding: Set/allocated/freed by libavcodec. - * - decoding: Set/allocated/freed by user. + * Out-of-band global headers that may be used by some codecs. + * + * - decoding: Should be set by the caller when available (typically from a + * demuxer) before opening the decoder; some decoders require this to be + * set and will fail to initialize otherwise. + * + * The array must be allocated with the av_malloc() family of functions; + * allocated size must be at least AV_INPUT_BUFFER_PADDING_SIZE bytes + * larger than extradata_size. + * + * - encoding: May be set by the encoder in avcodec_open2() (possibly + * depending on whether the AV_CODEC_FLAG_GLOBAL_HEADER flag is set). + * + * After being set, the array is owned by the codec and freed in + * avcodec_free_context(). */ uint8_t *extradata; int extradata_size; @@ -565,23 +558,6 @@ typedef struct AVCodecContext { */ AVRational framerate; -#if FF_API_TICKS_PER_FRAME - /** - * For some codecs, the time base is closer to the field rate than the frame rate. - * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration - * if no telecine is used ... - * - * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2. - * - * @deprecated - * - decoding: Use AVCodecDescriptor.props & AV_CODEC_PROP_FIELDS - * - encoding: Set AVCodecContext.framerate instead - * - */ - attribute_deprecated - int ticks_per_frame; -#endif - /** * Codec delay. * @@ -995,12 +971,16 @@ typedef struct AVCodecContext { */ uint16_t *chroma_intra_matrix; +#if FF_API_INTRA_DC_PRECISION /** * precision of the intra DC coefficient - 8 * - encoding: Set by user. * - decoding: Set by libavcodec + * @deprecated Use the MPEG-2 encoder's private option "intra_dc_precision" instead. */ + attribute_deprecated int intra_dc_precision; +#endif /** * minimum MB Lagrange multiplier @@ -1648,165 +1628,29 @@ typedef struct AVCodecContext { * See the AV_PROFILE_* defines in defs.h. */ int profile; -#if FF_API_FF_PROFILE_LEVEL - /** @deprecated The following defines are deprecated; use AV_PROFILE_* - * in defs.h instead. */ -#define FF_PROFILE_UNKNOWN -99 -#define FF_PROFILE_RESERVED -100 - -#define FF_PROFILE_AAC_MAIN 0 -#define FF_PROFILE_AAC_LOW 1 -#define FF_PROFILE_AAC_SSR 2 -#define FF_PROFILE_AAC_LTP 3 -#define FF_PROFILE_AAC_HE 4 -#define FF_PROFILE_AAC_HE_V2 28 -#define FF_PROFILE_AAC_LD 22 -#define FF_PROFILE_AAC_ELD 38 -#define FF_PROFILE_MPEG2_AAC_LOW 128 -#define FF_PROFILE_MPEG2_AAC_HE 131 - -#define FF_PROFILE_DNXHD 0 -#define FF_PROFILE_DNXHR_LB 1 -#define FF_PROFILE_DNXHR_SQ 2 -#define FF_PROFILE_DNXHR_HQ 3 -#define FF_PROFILE_DNXHR_HQX 4 -#define FF_PROFILE_DNXHR_444 5 - -#define FF_PROFILE_DTS 20 -#define FF_PROFILE_DTS_ES 30 -#define FF_PROFILE_DTS_96_24 40 -#define FF_PROFILE_DTS_HD_HRA 50 -#define FF_PROFILE_DTS_HD_MA 60 -#define FF_PROFILE_DTS_EXPRESS 70 -#define FF_PROFILE_DTS_HD_MA_X 61 -#define FF_PROFILE_DTS_HD_MA_X_IMAX 62 - - -#define FF_PROFILE_EAC3_DDP_ATMOS 30 - -#define FF_PROFILE_TRUEHD_ATMOS 30 - -#define FF_PROFILE_MPEG2_422 0 -#define FF_PROFILE_MPEG2_HIGH 1 -#define FF_PROFILE_MPEG2_SS 2 -#define FF_PROFILE_MPEG2_SNR_SCALABLE 3 -#define FF_PROFILE_MPEG2_MAIN 4 -#define FF_PROFILE_MPEG2_SIMPLE 5 - -#define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag -#define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag - -#define FF_PROFILE_H264_BASELINE 66 -#define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED) -#define FF_PROFILE_H264_MAIN 77 -#define FF_PROFILE_H264_EXTENDED 88 -#define FF_PROFILE_H264_HIGH 100 -#define FF_PROFILE_H264_HIGH_10 110 -#define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA) -#define FF_PROFILE_H264_MULTIVIEW_HIGH 118 -#define FF_PROFILE_H264_HIGH_422 122 -#define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA) -#define FF_PROFILE_H264_STEREO_HIGH 128 -#define FF_PROFILE_H264_HIGH_444 144 -#define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244 -#define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA) -#define FF_PROFILE_H264_CAVLC_444 44 - -#define FF_PROFILE_VC1_SIMPLE 0 -#define FF_PROFILE_VC1_MAIN 1 -#define FF_PROFILE_VC1_COMPLEX 2 -#define FF_PROFILE_VC1_ADVANCED 3 - -#define FF_PROFILE_MPEG4_SIMPLE 0 -#define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1 -#define FF_PROFILE_MPEG4_CORE 2 -#define FF_PROFILE_MPEG4_MAIN 3 -#define FF_PROFILE_MPEG4_N_BIT 4 -#define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5 -#define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6 -#define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7 -#define FF_PROFILE_MPEG4_HYBRID 8 -#define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9 -#define FF_PROFILE_MPEG4_CORE_SCALABLE 10 -#define FF_PROFILE_MPEG4_ADVANCED_CODING 11 -#define FF_PROFILE_MPEG4_ADVANCED_CORE 12 -#define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13 -#define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14 -#define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15 - -#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 1 -#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 2 -#define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 32768 -#define FF_PROFILE_JPEG2000_DCINEMA_2K 3 -#define FF_PROFILE_JPEG2000_DCINEMA_4K 4 - -#define FF_PROFILE_VP9_0 0 -#define FF_PROFILE_VP9_1 1 -#define FF_PROFILE_VP9_2 2 -#define FF_PROFILE_VP9_3 3 - -#define FF_PROFILE_HEVC_MAIN 1 -#define FF_PROFILE_HEVC_MAIN_10 2 -#define FF_PROFILE_HEVC_MAIN_STILL_PICTURE 3 -#define FF_PROFILE_HEVC_REXT 4 -#define FF_PROFILE_HEVC_SCC 9 - -#define FF_PROFILE_VVC_MAIN_10 1 -#define FF_PROFILE_VVC_MAIN_10_444 33 - -#define FF_PROFILE_AV1_MAIN 0 -#define FF_PROFILE_AV1_HIGH 1 -#define FF_PROFILE_AV1_PROFESSIONAL 2 - -#define FF_PROFILE_MJPEG_HUFFMAN_BASELINE_DCT 0xc0 -#define FF_PROFILE_MJPEG_HUFFMAN_EXTENDED_SEQUENTIAL_DCT 0xc1 -#define FF_PROFILE_MJPEG_HUFFMAN_PROGRESSIVE_DCT 0xc2 -#define FF_PROFILE_MJPEG_HUFFMAN_LOSSLESS 0xc3 -#define FF_PROFILE_MJPEG_JPEG_LS 0xf7 - -#define FF_PROFILE_SBC_MSBC 1 - -#define FF_PROFILE_PRORES_PROXY 0 -#define FF_PROFILE_PRORES_LT 1 -#define FF_PROFILE_PRORES_STANDARD 2 -#define FF_PROFILE_PRORES_HQ 3 -#define FF_PROFILE_PRORES_4444 4 -#define FF_PROFILE_PRORES_XQ 5 - -#define FF_PROFILE_ARIB_PROFILE_A 0 -#define FF_PROFILE_ARIB_PROFILE_C 1 - -#define FF_PROFILE_KLVA_SYNC 0 -#define FF_PROFILE_KLVA_ASYNC 1 - -#define FF_PROFILE_EVC_BASELINE 0 -#define FF_PROFILE_EVC_MAIN 1 -#endif /** * Encoding level descriptor. * - encoding: Set by user, corresponds to a specific level defined by the * codec, usually corresponding to the profile level, if not specified it - * is set to FF_LEVEL_UNKNOWN. + * is set to AV_LEVEL_UNKNOWN. * - decoding: Set by libavcodec. * See AV_LEVEL_* in defs.h. */ int level; -#if FF_API_FF_PROFILE_LEVEL - /** @deprecated The following define is deprecated; use AV_LEVEL_UNKOWN - * in defs.h instead. */ -#define FF_LEVEL_UNKNOWN -99 -#endif +#if FF_API_CODEC_PROPS /** * Properties of the stream that gets decoded * - encoding: unused * - decoding: set by libavcodec */ + attribute_deprecated unsigned properties; #define FF_CODEC_PROPERTY_LOSSLESS 0x00000001 #define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x00000002 #define FF_CODEC_PROPERTY_FILM_GRAIN 0x00000004 +#endif /** * Skip loop filtering for selected frames. @@ -1895,8 +1739,13 @@ typedef struct AVCodecContext { * For SUBTITLE_ASS subtitle type, it should contain the whole ASS * [Script Info] and [V4+ Styles] section, plus the [Events] line and * the Format line following. It shouldn't include any Dialogue line. - * - encoding: Set/allocated/freed by user (before avcodec_open2()) - * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2()) + * + * - encoding: May be set by the caller before avcodec_open2() to an array + * allocated with the av_malloc() family of functions. + * - decoding: May be set by libavcodec in avcodec_open2(). + * + * After being set, the array is owned by the codec and freed in + * avcodec_free_context(). */ int subtitle_header_size; uint8_t *subtitle_header; @@ -2086,6 +1935,13 @@ typedef struct AVCodecContext { */ AVFrameSideData **decoded_side_data; int nb_decoded_side_data; + + /** + * Indicates how the alpha channel of the video is represented. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVAlphaMode alpha_mode; } AVCodecContext; /** @@ -2380,24 +2236,6 @@ int avcodec_parameters_to_context(AVCodecContext *codec, */ int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options); -#if FF_API_AVCODEC_CLOSE -/** - * Close a given AVCodecContext and free all the data associated with it - * (but not the AVCodecContext itself). - * - * Calling this function on an AVCodecContext that hasn't been opened will free - * the codec-specific data allocated in avcodec_alloc_context3() with a non-NULL - * codec. Subsequent calls will do nothing. - * - * @deprecated Do not use this function. Use avcodec_free_context() to destroy a - * codec context (either open or closed). Opening and closing a codec context - * multiple times is not supported anymore -- use multiple codec contexts - * instead. - */ -attribute_deprecated -int avcodec_close(AVCodecContext *avctx); -#endif - /** * Free all allocated data in the given subtitle struct. * @@ -2534,6 +2372,7 @@ int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt); * frame (depending on the decoder type) allocated by the * codec. Note that the function will always call * av_frame_unref(frame) before doing anything else. + * @param flags Combination of AV_CODEC_RECEIVE_FRAME_FLAG_* flags. * * @retval 0 success, a frame was returned * @retval AVERROR(EAGAIN) output is not available in this state - user must @@ -2544,6 +2383,11 @@ int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt); * @ref AV_CODEC_FLAG_RECON_FRAME flag enabled * @retval "other negative error code" legitimate decoding errors */ +int avcodec_receive_frame_flags(AVCodecContext *avctx, AVFrame *frame, unsigned flags); + +/** + * Alias for `avcodec_receive_frame_flags(avctx, frame, 0)`. + */ int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame); /** @@ -2709,6 +2553,7 @@ enum AVCodecConfig { AV_CODEC_CONFIG_CHANNEL_LAYOUT, ///< AVChannelLayout, terminated by {0} AV_CODEC_CONFIG_COLOR_RANGE, ///< AVColorRange, terminated by AVCOL_RANGE_UNSPECIFIED AV_CODEC_CONFIG_COLOR_SPACE, ///< AVColorSpace, terminated by AVCOL_SPC_UNSPECIFIED + AV_CODEC_CONFIG_ALPHA_MODE, ///< AVAlphaMode, terminated by AVALPHA_MODE_UNSPECIFIED }; /** @@ -2905,17 +2750,35 @@ typedef struct AVCodecParserContext { } AVCodecParserContext; typedef struct AVCodecParser { +#if FF_API_PARSER_CODECID int codec_ids[7]; /* several codec IDs are permitted */ +#else + enum AVCodecID codec_ids[7]; /* several codec IDs are permitted */ +#endif +#if FF_API_PARSER_PRIVATE + /***************************************************************** + * All fields below this line are not 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. + ***************************************************************** + */ + attribute_deprecated int priv_data_size; + attribute_deprecated int (*parser_init)(AVCodecParserContext *s); /* This callback never returns an error, a negative value means that * the frame start was in a previous packet. */ + attribute_deprecated int (*parser_parse)(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size); + attribute_deprecated void (*parser_close)(AVCodecParserContext *s); + attribute_deprecated int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size); +#endif } AVCodecParser; /** @@ -2929,7 +2792,11 @@ typedef struct AVCodecParser { */ const AVCodecParser *av_parser_iterate(void **opaque); +#if FF_API_PARSER_CODECID AVCodecParserContext *av_parser_init(int codec_id); +#else +AVCodecParserContext *av_parser_init(enum AVCodecID codec_id); +#endif /** * Parse a packet. @@ -3081,7 +2948,7 @@ int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, * * @note for encoders, this function will only do something if the encoder * declares support for AV_CODEC_CAP_ENCODER_FLUSH. When called, the encoder - * will drain any remaining packets, and can then be re-used for a different + * will drain any remaining packets, and can then be reused for a different * stream (as opposed to sending a null frame which will leave the encoder * in a permanent EOF state after draining). This can be desirable if the * cost of tearing down and replacing the encoder instance is high. @@ -3116,8 +2983,8 @@ 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); /** - * @return a positive value if s is open (i.e. avcodec_open2() was called on it - * with no corresponding avcodec_close()), 0 otherwise. + * @return a positive value if s is open (i.e. avcodec_open2() was called on it), + * 0 otherwise. */ int avcodec_is_open(AVCodecContext *s); diff --git a/include/libavcodec/avfft.h b/include/libavcodec/avfft.h deleted file mode 100755 index e3a0da1eb9..0000000000 --- a/include/libavcodec/avfft.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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_AVFFT_H -#define AVCODEC_AVFFT_H - -#include "libavutil/attributes.h" -#include "version_major.h" -#if FF_API_AVFFT - -/** - * @file - * @ingroup lavc_fft - * FFT functions - */ - -/** - * @defgroup lavc_fft FFT functions - * @ingroup lavc_misc - * - * @{ - */ - -typedef float FFTSample; - -typedef struct FFTComplex { - FFTSample re, im; -} FFTComplex; - -typedef struct FFTContext FFTContext; - -/** - * Set up a complex FFT. - * @param nbits log2 of the length of the input array - * @param inverse if 0 perform the forward transform, if 1 perform the inverse - * @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_FFT - */ -attribute_deprecated -FFTContext *av_fft_init(int nbits, int inverse); - -/** - * Do the permutation needed BEFORE calling ff_fft_calc(). - * @deprecated without replacement - */ -attribute_deprecated -void av_fft_permute(FFTContext *s, FFTComplex *z); - -/** - * Do a complex FFT with the parameters defined in av_fft_init(). The - * input data must be permuted before. No 1.0/sqrt(n) normalization is done. - * @deprecated use the av_tx_fn value returned by av_tx_init, which also does permutation - */ -attribute_deprecated -void av_fft_calc(FFTContext *s, FFTComplex *z); - -attribute_deprecated -void av_fft_end(FFTContext *s); - -/** - * @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_MDCT, - * with a flag of AV_TX_FULL_IMDCT for a replacement to av_imdct_calc. - */ -attribute_deprecated -FFTContext *av_mdct_init(int nbits, int inverse, double scale); -attribute_deprecated -void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); -attribute_deprecated -void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input); -attribute_deprecated -void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); -attribute_deprecated -void av_mdct_end(FFTContext *s); - -/* Real Discrete Fourier Transform */ - -enum RDFTransformType { - DFT_R2C, - IDFT_C2R, - IDFT_R2C, - DFT_C2R, -}; - -typedef struct RDFTContext RDFTContext; - -/** - * Set up a real FFT. - * @param nbits log2 of the length of the input array - * @param trans the type of transform - * - * @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_RDFT - */ -attribute_deprecated -RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans); -attribute_deprecated -void av_rdft_calc(RDFTContext *s, FFTSample *data); -attribute_deprecated -void av_rdft_end(RDFTContext *s); - -/* Discrete Cosine Transform */ - -typedef struct DCTContext DCTContext; - -enum DCTTransformType { - DCT_II = 0, - DCT_III, - DCT_I, - DST_I, -}; - -/** - * Set up DCT. - * - * @param nbits size of the input array: - * (1 << nbits) for DCT-II, DCT-III and DST-I - * (1 << nbits) + 1 for DCT-I - * @param type the type of transform - * - * @note the first element of the input of DST-I is ignored - * - * @deprecated use av_tx_init from libavutil/tx.h with an appropriate type of AV_TX_FLOAT_DCT - */ -attribute_deprecated -DCTContext *av_dct_init(int nbits, enum DCTTransformType type); -attribute_deprecated -void av_dct_calc(DCTContext *s, FFTSample *data); -attribute_deprecated -void av_dct_end (DCTContext *s); - -/** - * @} - */ - -#endif /* FF_API_AVFFT */ -#endif /* AVCODEC_AVFFT_H */ diff --git a/include/libavcodec/cabac.h b/include/libavcodec/cabac.h deleted file mode 100644 index 38d06b2842..0000000000 --- a/include/libavcodec/cabac.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder - * Copyright (c) 2003 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 - */ - -/** - * @file - * Context Adaptive Binary Arithmetic Coder. - */ - -#ifndef AVCODEC_CABAC_H -#define AVCODEC_CABAC_H - -#include - -extern const uint8_t ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63]; -#define H264_NORM_SHIFT_OFFSET 0 -#define H264_LPS_RANGE_OFFSET 512 -#define H264_MLPS_STATE_OFFSET 1024 -#define H264_LAST_COEFF_FLAG_OFFSET_8x8_OFFSET 1280 - -#define CABAC_BITS 16 -#define CABAC_MASK ((1<pict field. diff --git a/include/libavcodec/codec_id.h b/include/libavcodec/codec_id.h index 0a8d3bed1e..6529f0a6bc 100644 --- a/include/libavcodec/codec_id.h +++ b/include/libavcodec/codec_id.h @@ -206,7 +206,9 @@ enum AVCodecID { AV_CODEC_ID_BMV_VIDEO, AV_CODEC_ID_VBLE, AV_CODEC_ID_DXTORY, +#if FF_API_V408_CODECID AV_CODEC_ID_V410, +#endif AV_CODEC_ID_XWD, AV_CODEC_ID_CDXL, AV_CODEC_ID_XBM, @@ -254,8 +256,10 @@ enum AVCodecID { AV_CODEC_ID_012V, AV_CODEC_ID_AVUI, AV_CODEC_ID_TARGA_Y216, +#if FF_API_V408_CODECID AV_CODEC_ID_V308, AV_CODEC_ID_V408, +#endif AV_CODEC_ID_YUV4, AV_CODEC_ID_AVRN, AV_CODEC_ID_CPIA, @@ -322,6 +326,12 @@ enum AVCodecID { AV_CODEC_ID_RTV1, AV_CODEC_ID_VMIX, AV_CODEC_ID_LEAD, + AV_CODEC_ID_DNXUC, + AV_CODEC_ID_RV60, + AV_CODEC_ID_JPEGXL_ANIM, + AV_CODEC_ID_APV, + AV_CODEC_ID_PRORES_RAW, + AV_CODEC_ID_JPEGXS, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs @@ -416,6 +426,16 @@ enum AVCodecID { AV_CODEC_ID_ADPCM_IMA_MOFLEX, AV_CODEC_ID_ADPCM_IMA_ACORN, AV_CODEC_ID_ADPCM_XMD, + AV_CODEC_ID_ADPCM_IMA_XBOX, + AV_CODEC_ID_ADPCM_SANYO, + AV_CODEC_ID_ADPCM_IMA_HVQM4, + AV_CODEC_ID_ADPCM_IMA_PDA, + AV_CODEC_ID_ADPCM_N64, + AV_CODEC_ID_ADPCM_IMA_HVQM2, + AV_CODEC_ID_ADPCM_IMA_MAGIX, + AV_CODEC_ID_ADPCM_PSXC, + AV_CODEC_ID_ADPCM_CIRCUS, + AV_CODEC_ID_ADPCM_IMA_ESCAPE, /* AMR */ AV_CODEC_ID_AMR_NB = 0x12000, @@ -544,6 +564,8 @@ enum AVCodecID { AV_CODEC_ID_OSQ, AV_CODEC_ID_QOA, AV_CODEC_ID_LC3, + AV_CODEC_ID_G728, + AV_CODEC_ID_AHX, /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. @@ -573,6 +595,7 @@ enum AVCodecID { AV_CODEC_ID_HDMV_TEXT_SUBTITLE, AV_CODEC_ID_TTML, AV_CODEC_ID_ARIB_CAPTION, + AV_CODEC_ID_IVTV_VBI, /* other specific kind of codecs (generally used for attachments) */ AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs. @@ -590,6 +613,7 @@ enum AVCodecID { AV_CODEC_ID_BIN_DATA, AV_CODEC_ID_SMPTE_2038, AV_CODEC_ID_LCEVC, + AV_CODEC_ID_SMPTE_436M_ANC, AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it diff --git a/include/libavcodec/codec_internal.h b/include/libavcodec/codec_internal.h deleted file mode 100644 index ef27936653..0000000000 --- a/include/libavcodec/codec_internal.h +++ /dev/null @@ -1,328 +0,0 @@ -/* - * 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 "avcodec.h" -#include "codec.h" - -/** - * The codec is not known to be init-threadsafe (i.e. it might be unsafe - * to initialize this codec and another codec concurrently, typically because - * the codec calls external APIs that are not known to be thread-safe). - * Therefore calling the codec's init function needs to be guarded with a lock. - */ -#define FF_CODEC_CAP_NOT_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 decoder might make use of the ProgressFrame API. - */ -#define FF_CODEC_CAP_USES_PROGRESSFRAMES (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) -/** - * Codec supports embedded ICC profiles (AV_FRAME_DATA_ICC_PROFILE). - */ -#define FF_CODEC_CAP_ICC_PROFILES (1 << 9) -/** - * The encoder has AV_CODEC_CAP_DELAY set, but does not actually have delay - it - * only wants to be flushed at the end to update some context variables (e.g. - * 2pass stats) or produce a trailing packet. Besides that it immediately - * produces exactly one output packet per each input frame, just as no-delay - * encoders do. - */ -#define FF_CODEC_CAP_EOF_FLUSH (1 << 10) - -/** - * 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:27; - - /** - * This field determines the video color ranges supported by an encoder. - * Should be set to a bitmask of AVCOL_RANGE_MPEG and AVCOL_RANGE_JPEG. - */ - unsigned color_ranges:2; - - /** - * 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; - - 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; - - /** - * Custom callback for avcodec_get_supported_config(). If absent, - * ff_default_get_supported_config() will be used. `out_num_configs` will - * always be set to a valid pointer. - */ - int (*get_supported_config)(const AVCodecContext *avctx, - const AVCodec *codec, - enum AVCodecConfig config, - unsigned flags, - const void **out_configs, - int *out_num_configs); -} FFCodec; - -/** - * Default implementation for avcodec_get_supported_config(). Will return the - * relevant fields from AVCodec if present, or NULL otherwise. - * - * For AVCODEC_CONFIG_COLOR_RANGE, the output will depend on the bitmask in - * FFCodec.color_ranges, with a value of 0 returning NULL. - */ -int ff_default_get_supported_config(const AVCodecContext *avctx, - const AVCodec *codec, - enum AVCodecConfig config, - unsigned flags, - const void **out_configs, - int *out_num_configs); - -#if HAVE_THREADS -#define UPDATE_THREAD_CONTEXT(func) \ - .update_thread_context = (func) -#define UPDATE_THREAD_CONTEXT_FOR_USER(func) \ - .update_thread_context_for_user = (func) -#else -#define UPDATE_THREAD_CONTEXT(func) \ - .update_thread_context = NULL -#define UPDATE_THREAD_CONTEXT_FOR_USER(func) \ - .update_thread_context_for_user = NULL -#endif - -#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/include/libavcodec/codec_par.h b/include/libavcodec/codec_par.h index f4b9bb5c06..2697605d4d 100644 --- a/include/libavcodec/codec_par.h +++ b/include/libavcodec/codec_par.h @@ -148,7 +148,7 @@ typedef struct AVCodecParameters { * durations. Should be set to { 0, 1 } when some frames have differing * durations or if the value is not known. * - * @note This field correponds to values that are stored in codec-level + * @note This field corresponds to values that are stored in codec-level * headers and is typically overridden by container/transport-layer * timestamps, when available. It should thus be used only as a last resort, * when no higher-level timing information is available. @@ -212,6 +212,11 @@ typedef struct AVCodecParameters { * Audio only. Number of samples to skip after a discontinuity. */ int seek_preroll; + + /** + * Video with alpha channel only. Alpha channel handling + */ + enum AVAlphaMode alpha_mode; } AVCodecParameters; /** diff --git a/include/libavcodec/defs.h b/include/libavcodec/defs.h index 24250f8af5..b13e983b13 100644 --- a/include/libavcodec/defs.h +++ b/include/libavcodec/defs.h @@ -185,6 +185,9 @@ #define AV_PROFILE_PRORES_4444 4 #define AV_PROFILE_PRORES_XQ 5 +#define AV_PROFILE_PRORES_RAW 0 +#define AV_PROFILE_PRORES_RAW_HQ 1 + #define AV_PROFILE_ARIB_PROFILE_A 0 #define AV_PROFILE_ARIB_PROFILE_C 1 @@ -194,6 +197,14 @@ #define AV_PROFILE_EVC_BASELINE 0 #define AV_PROFILE_EVC_MAIN 1 +#define AV_PROFILE_APV_422_10 33 +#define AV_PROFILE_APV_422_12 44 +#define AV_PROFILE_APV_444_10 55 +#define AV_PROFILE_APV_444_12 66 +#define AV_PROFILE_APV_4444_10 77 +#define AV_PROFILE_APV_4444_12 88 +#define AV_PROFILE_APV_400_10 99 + #define AV_LEVEL_UNKNOWN -99 @@ -325,6 +336,20 @@ typedef struct AVProducerReferenceTime { int flags; } AVProducerReferenceTime; +/** + * RTCP SR (Sender Report) information + * + * The received sender report information for an RTSP + * stream, exposed as AV_PKT_DATA_RTCP_SR side data. + */ +typedef struct AVRTCPSenderReport { + uint32_t ssrc; ///< Synchronization source identifier + uint64_t ntp_timestamp; ///< NTP time when the report was sent + uint32_t rtp_timestamp; ///< RTP time when the report was sent + uint32_t sender_nb_packets; ///< Total number of packets sent + uint32_t sender_nb_bytes; ///< Total number of bytes sent (excluding headers or padding) +} AVRTCPSenderReport; + /** * Encode extradata length to a buffer. Used by xiph codecs. * diff --git a/include/libavcodec/error_resilience.h b/include/libavcodec/error_resilience.h deleted file mode 100644 index 1346639c3c..0000000000 --- a/include/libavcodec/error_resilience.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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_ERROR_RESILIENCE_H -#define AVCODEC_ERROR_RESILIENCE_H - -#include -#include - -#include "avcodec.h" -#include "me_cmp.h" - -///< current MB is the first after a resync marker -#define VP_START 1 -#define ER_AC_ERROR 2 -#define ER_DC_ERROR 4 -#define ER_MV_ERROR 8 -#define ER_AC_END 16 -#define ER_DC_END 32 -#define ER_MV_END 64 - -#define ER_MB_ERROR (ER_AC_ERROR|ER_DC_ERROR|ER_MV_ERROR) -#define ER_MB_END (ER_AC_END|ER_DC_END|ER_MV_END) - -typedef struct ERPicture { - AVFrame *f; - const struct ThreadFrame *tf; - - // it is the caller's responsibility to allocate these buffers - int16_t (*motion_val[2])[2]; - int8_t *ref_index[2]; - - uint32_t *mb_type; - int field_picture; -} ERPicture; - -typedef struct ERContext { - AVCodecContext *avctx; - - me_cmp_func sad; - int mecc_inited; - - int *mb_index2xy; - int mb_num; - int mb_width, mb_height; - ptrdiff_t mb_stride; - ptrdiff_t b8_stride; - - atomic_int error_count; - int error_occurred; - uint8_t *error_status_table; - uint8_t *er_temp_buffer; - int16_t *dc_val[3]; - uint8_t *mbskip_table; - uint8_t *mbintra_table; - int mv[2][4][2]; - - ERPicture cur_pic; - ERPicture last_pic; - ERPicture next_pic; - - int8_t *ref_index[2]; - int16_t (*motion_val_base[2])[2]; - - uint16_t pp_time; - uint16_t pb_time; - int quarter_sample; - int partitioned_frame; - - void (*decode_mb)(void *opaque, int ref, int mv_dir, int mv_type, - int (*mv)[2][4][2], - int mb_x, int mb_y, int mb_intra, int mb_skipped); - void *opaque; -} ERContext; - -void ff_er_frame_start(ERContext *s); - -/** - * Indicate that a frame has finished decoding and perform error concealment - * in case it has been enabled and is necessary and supported. - * - * @param s ERContext in use - * @param decode_error_flags pointer where updated decode_error_flags are written - * if supplied; if not, the new flags are directly - * applied to the AVFrame whose errors are concealed - */ -void ff_er_frame_end(ERContext *s, int *decode_error_flags); -void ff_er_add_slice(ERContext *s, int startx, int starty, int endx, int endy, - int status); - -#endif /* AVCODEC_ERROR_RESILIENCE_H */ diff --git a/include/libavcodec/exif.h b/include/libavcodec/exif.h new file mode 100644 index 0000000000..1824a38d1c --- /dev/null +++ b/include/libavcodec/exif.h @@ -0,0 +1,229 @@ +/* + * EXIF metadata parser + * Copyright (c) 2013 Thilo Borgmann + * Copyright (c) 2024-2025 Leo Izen + * + * 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 + * EXIF metadata parser + * @author Thilo Borgmann + * @author Leo Izen + */ + +#ifndef AVCODEC_EXIF_H +#define AVCODEC_EXIF_H + +#include +#include + +#include "libavutil/buffer.h" +#include "libavutil/dict.h" +#include "libavutil/rational.h" +#include "version_major.h" + +/** Data type identifiers for TIFF tags */ +enum AVTiffDataType { + AV_TIFF_BYTE = 1, + AV_TIFF_STRING, + AV_TIFF_SHORT, + AV_TIFF_LONG, + AV_TIFF_RATIONAL, + AV_TIFF_SBYTE, + AV_TIFF_UNDEFINED, + AV_TIFF_SSHORT, + AV_TIFF_SLONG, + AV_TIFF_SRATIONAL, + AV_TIFF_FLOAT, + AV_TIFF_DOUBLE, + AV_TIFF_IFD, +}; + +enum AVExifHeaderMode { + /** + * The TIFF header starts with 0x49492a00, or 0x4d4d002a. + * This one is used internally by FFmpeg. + */ + AV_EXIF_TIFF_HEADER, + /** skip the TIFF header, assume little endian */ + AV_EXIF_ASSUME_LE, + /** skip the TIFF header, assume big endian */ + AV_EXIF_ASSUME_BE, + /** The first four bytes point to the actual start, then it's AV_EXIF_TIFF_HEADER */ + AV_EXIF_T_OFF, + /** The first six bytes contain "Exif\0\0", then it's AV_EXIF_TIFF_HEADER */ + AV_EXIF_EXIF00, +}; + +typedef struct AVExifEntry AVExifEntry; + +typedef struct AVExifMetadata { + /* array of EXIF metadata entries */ + AVExifEntry *entries; + /* number of entries in this array */ + unsigned int count; + /* size of the buffer, used for av_fast_realloc */ + unsigned int size; +} AVExifMetadata; + +struct AVExifEntry { + uint16_t id; + enum AVTiffDataType type; + uint32_t count; + + /* + * These are for IFD-style MakerNote + * entries which occur after a fixed + * offset rather than at the start of + * the entry. The ifd_lead field contains + * the leading bytes which typically + * identify the type of MakerNote. + */ + uint32_t ifd_offset; + uint8_t *ifd_lead; + + /* + * An array of entries of size count + * Unless it's an IFD, in which case + * it's not an array and count = 1 + */ + union { + void *ptr; + int64_t *sint; + uint64_t *uint; + double *dbl; + char *str; + uint8_t *ubytes; + int8_t *sbytes; + AVRational *rat; + AVExifMetadata ifd; + } value; +}; + +/** + * Retrieves the tag name associated with the provided tag ID. + * If the tag ID is unknown, NULL is returned. + * + * For example, av_exif_get_tag_name(0x112) returns "Orientation". + */ +const char *av_exif_get_tag_name(uint16_t id); + +/** + * Retrieves the tag ID associated with the provided tag string name. + * If the tag name is unknown, a negative number is returned. Otherwise + * it always fits inside a uint16_t integer. + * + * For example, av_exif_get_tag_id("Orientation") returns 274 (0x0112). + */ +int32_t av_exif_get_tag_id(const char *name); + +/** + * Add an entry to the provided EXIF metadata struct. If one already exists with the provided + * ID, it will set the existing one to have the other information provided. Otherwise, it + * will allocate a new entry. + * + * This function reallocates ifd->entries using av_realloc and allocates (using av_malloc) + * a new value member of the entry, then copies the contents of value into that buffer. + */ +int av_exif_set_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, enum AVTiffDataType type, + uint32_t count, const uint8_t *ifd_lead, uint32_t ifd_offset, const void *value); + +/** + * Also check subdirectories. + */ +#define AV_EXIF_FLAG_RECURSIVE (1 << 0) + +/** + * Get an entry with the tagged ID from the EXIF metadata struct. A pointer to the entry + * will be written into *value. + * + * If the entry was present and returned successfully, a positive number is returned. + * If the entry was not found, *value is left untouched and zero is returned. + * If an error occurred, a negative number is returned. + */ +int av_exif_get_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, int flags, AVExifEntry **value); + +/** + * Remove an entry from the provided EXIF metadata struct. + * + * If the entry was present and removed successfully, a positive number is returned. + * If the entry was not found, zero is returned. + * If an error occurred, a negative number is returned. + */ +int av_exif_remove_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, int flags); + +/** + * Decodes the EXIF data provided in the buffer and writes it into the + * struct *ifd. If this function succeeds, the IFD is owned by the caller + * and must be cleared after use by calling av_exif_free(); If this function + * fails and returns a negative value, it will call av_exif_free(ifd) before + * returning. + */ +int av_exif_parse_buffer(void *logctx, const uint8_t *data, size_t size, + AVExifMetadata *ifd, enum AVExifHeaderMode header_mode); + +/** + * Allocates a buffer using av_malloc of an appropriate size and writes the + * EXIF data represented by ifd into that buffer. + * + * Upon error, *buffer will be NULL. The buffer becomes owned by the caller upon + * success. The *buffer argument must be NULL before calling. + */ +int av_exif_write(void *logctx, const AVExifMetadata *ifd, AVBufferRef **buffer, enum AVExifHeaderMode header_mode); + +/** + * Frees all resources associated with the given EXIF metadata struct. + * Does not free the pointer passed itself, in case it is stack-allocated. + * The pointer passed to this function must be freed by the caller, + * if it is heap-allocated. Passing NULL is permitted. + */ +void av_exif_free(AVExifMetadata *ifd); + +/** + * Recursively reads all tags from the IFD and stores them in the + * provided metadata dictionary. + */ +int av_exif_ifd_to_dict(void *logctx, const AVExifMetadata *ifd, AVDictionary **metadata); + +/** + * Allocates a duplicate of the provided EXIF metadata struct. The caller owns + * the duplicate and must free it with av_exif_free. Returns NULL if the duplication + * process failed. + */ +AVExifMetadata *av_exif_clone_ifd(const AVExifMetadata *ifd); + +/** + * Convert a display matrix used by AV_FRAME_DATA_DISPLAYMATRIX + * into an orientation constant used by EXIF's orientation tag. + * + * Returns an EXIF orientation between 1 and 8 (inclusive) depending + * on the rotation and flip factors. Returns 0 if the matrix is singular. + */ +int av_exif_matrix_to_orientation(const int32_t *matrix); + +/** + * Convert an orientation constant used by EXIF's orientation tag + * into a display matrix used by AV_FRAME_DATA_DISPLAYMATRIX. + * + * Returns 0 on success and negative if the orientation is invalid, + * i.e. not between 1 and 8 (inclusive). + */ +int av_exif_orientation_to_matrix(int32_t *matrix, int orientation); + +#endif /* AVCODEC_EXIF_H */ diff --git a/include/libavcodec/h264.h b/include/libavcodec/h264.h deleted file mode 100644 index 7a1fb6d687..0000000000 --- a/include/libavcodec/h264.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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 - * H.264 common definitions - */ - -#ifndef AVCODEC_H264_H -#define AVCODEC_H264_H - -#define QP_MAX_NUM (51 + 6*6) // The maximum supported qp - -/* - * Table 7-1 – NAL unit type codes, syntax element categories, and NAL unit type classes in - * T-REC-H.264-201704 - */ -enum { - H264_NAL_UNSPECIFIED = 0, - H264_NAL_SLICE = 1, - H264_NAL_DPA = 2, - H264_NAL_DPB = 3, - H264_NAL_DPC = 4, - H264_NAL_IDR_SLICE = 5, - H264_NAL_SEI = 6, - H264_NAL_SPS = 7, - H264_NAL_PPS = 8, - H264_NAL_AUD = 9, - H264_NAL_END_SEQUENCE = 10, - H264_NAL_END_STREAM = 11, - H264_NAL_FILLER_DATA = 12, - H264_NAL_SPS_EXT = 13, - H264_NAL_PREFIX = 14, - H264_NAL_SUB_SPS = 15, - H264_NAL_DPS = 16, - H264_NAL_RESERVED17 = 17, - H264_NAL_RESERVED18 = 18, - H264_NAL_AUXILIARY_SLICE = 19, - H264_NAL_EXTEN_SLICE = 20, - H264_NAL_DEPTH_EXTEN_SLICE = 21, - H264_NAL_RESERVED22 = 22, - H264_NAL_RESERVED23 = 23, - H264_NAL_UNSPECIFIED24 = 24, - H264_NAL_UNSPECIFIED25 = 25, - H264_NAL_UNSPECIFIED26 = 26, - H264_NAL_UNSPECIFIED27 = 27, - H264_NAL_UNSPECIFIED28 = 28, - H264_NAL_UNSPECIFIED29 = 29, - H264_NAL_UNSPECIFIED30 = 30, - H264_NAL_UNSPECIFIED31 = 31, -}; - - -enum { - // 7.4.2.1.1: seq_parameter_set_id is in [0, 31]. - H264_MAX_SPS_COUNT = 32, - // 7.4.2.2: pic_parameter_set_id is in [0, 255]. - H264_MAX_PPS_COUNT = 256, - - // A.3: MaxDpbFrames is bounded above by 16. - H264_MAX_DPB_FRAMES = 16, - // 7.4.2.1.1: max_num_ref_frames is in [0, MaxDpbFrames], and - // each reference frame can have two fields. - H264_MAX_REFS = 2 * H264_MAX_DPB_FRAMES, - - // 7.4.3.1: modification_of_pic_nums_idc is not equal to 3 at most - // num_ref_idx_lN_active_minus1 + 1 times (that is, once for each - // possible reference), then equal to 3 once. - H264_MAX_RPLM_COUNT = H264_MAX_REFS + 1, - - // 7.4.3.3: in the worst case, we begin with a full short-term - // reference picture list. Each picture in turn is moved to the - // long-term list (type 3) and then discarded from there (type 2). - // Then, we set the length of the long-term list (type 4), mark - // the current picture as long-term (type 6) and terminate the - // process (type 0). - H264_MAX_MMCO_COUNT = H264_MAX_REFS * 2 + 3, - - // A.2.1, A.2.3: profiles supporting FMO constrain - // num_slice_groups_minus1 to be in [0, 7]. - H264_MAX_SLICE_GROUPS = 8, - - // E.2.2: cpb_cnt_minus1 is in [0, 31]. - H264_MAX_CPB_CNT = 32, - - // A.3: in table A-1 the highest level allows a MaxFS of 139264. - H264_MAX_MB_PIC_SIZE = 139264, - // A.3.1, A.3.2: PicWidthInMbs and PicHeightInMbs are constrained - // to be not greater than sqrt(MaxFS * 8). Hence height/width are - // bounded above by sqrt(139264 * 8) = 1055.5 macroblocks. - H264_MAX_MB_WIDTH = 1055, - H264_MAX_MB_HEIGHT = 1055, - H264_MAX_WIDTH = H264_MAX_MB_WIDTH * 16, - H264_MAX_HEIGHT = H264_MAX_MB_HEIGHT * 16, -}; - - -#endif /* AVCODEC_H264_H */ diff --git a/include/libavcodec/h264_levels.h b/include/libavcodec/h264_levels.h deleted file mode 100644 index 310d79e51a..0000000000 --- a/include/libavcodec/h264_levels.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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_H264_LEVELS_H -#define AVCODEC_H264_LEVELS_H - - -#include - -typedef struct H264LevelDescriptor { - char name[4]; // Large enough for all current levels like "4.1" - uint8_t level_idc; - uint8_t constraint_set3_flag; - uint32_t max_mbps; - uint32_t max_fs; - uint32_t max_dpb_mbs; - uint32_t max_br; - uint32_t max_cpb; - uint16_t max_v_mv_r; - uint8_t min_cr; - uint8_t max_mvs_per_2mb; -} H264LevelDescriptor; - -/** - * Guess the level of a stream from some parameters. - * - * Unknown parameters may be zero, in which case they are ignored. - */ -const H264LevelDescriptor *ff_h264_guess_level(int profile_idc, - int64_t bitrate, - int framerate, - int width, int height, - int max_dec_frame_buffering); - - -#endif /* AVCODEC_H264_LEVELS_H */ diff --git a/include/libavcodec/h264_mvpred.h b/include/libavcodec/h264_mvpred.h deleted file mode 100644 index bc9fef50e4..0000000000 --- a/include/libavcodec/h264_mvpred.h +++ /dev/null @@ -1,967 +0,0 @@ -/* - * H.26L/H.264/AVC/JVT/14496-10/... motion vector prediction - * Copyright (c) 2003 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 - */ - -/** - * @file - * H.264 / AVC / MPEG-4 part10 motion vector prediction. - * @author Michael Niedermayer - */ - -#ifndef AVCODEC_H264_MVPRED_H -#define AVCODEC_H264_MVPRED_H - -#include "h264dec.h" -#include "mpegutils.h" -#include "rectangle.h" - -#include "libavutil/avassert.h" -#include "libavutil/mem_internal.h" - - -/** - * Get the predicted intra4x4 prediction mode. - */ -static av_always_inline int pred_intra_mode(const H264Context *h, - H264SliceContext *sl, int n) -{ - const int index8 = scan8[n]; - const int left = sl->intra4x4_pred_mode_cache[index8 - 1]; - const int top = sl->intra4x4_pred_mode_cache[index8 - 8]; - const int min = FFMIN(left, top); - - ff_tlog(h->avctx, "mode:%d %d min:%d\n", left, top, min); - - if (min < 0) - return DC_PRED; - else - return min; -} - -static av_always_inline void write_back_intra_pred_mode(const H264Context *h, - H264SliceContext *sl) -{ - int8_t *i4x4 = sl->intra4x4_pred_mode + h->mb2br_xy[sl->mb_xy]; - int8_t *i4x4_cache = sl->intra4x4_pred_mode_cache; - - AV_COPY32(i4x4, i4x4_cache + 4 + 8 * 4); - i4x4[4] = i4x4_cache[7 + 8 * 3]; - i4x4[5] = i4x4_cache[7 + 8 * 2]; - i4x4[6] = i4x4_cache[7 + 8 * 1]; -} - -static av_always_inline void write_back_non_zero_count(const H264Context *h, - H264SliceContext *sl) -{ - const int mb_xy = sl->mb_xy; - uint8_t *nnz = h->non_zero_count[mb_xy]; - uint8_t *nnz_cache = sl->non_zero_count_cache; - - AV_COPY32(&nnz[ 0], &nnz_cache[4 + 8 * 1]); - AV_COPY32(&nnz[ 4], &nnz_cache[4 + 8 * 2]); - AV_COPY32(&nnz[ 8], &nnz_cache[4 + 8 * 3]); - AV_COPY32(&nnz[12], &nnz_cache[4 + 8 * 4]); - AV_COPY32(&nnz[16], &nnz_cache[4 + 8 * 6]); - AV_COPY32(&nnz[20], &nnz_cache[4 + 8 * 7]); - AV_COPY32(&nnz[32], &nnz_cache[4 + 8 * 11]); - AV_COPY32(&nnz[36], &nnz_cache[4 + 8 * 12]); - - if (!h->chroma_y_shift) { - AV_COPY32(&nnz[24], &nnz_cache[4 + 8 * 8]); - AV_COPY32(&nnz[28], &nnz_cache[4 + 8 * 9]); - AV_COPY32(&nnz[40], &nnz_cache[4 + 8 * 13]); - AV_COPY32(&nnz[44], &nnz_cache[4 + 8 * 14]); - } -} - -static av_always_inline void write_back_motion_list(const H264Context *h, - H264SliceContext *sl, - int b_stride, - int b_xy, int b8_xy, - int mb_type, int list) -{ - int16_t(*mv_dst)[2] = &h->cur_pic.motion_val[list][b_xy]; - int16_t(*mv_src)[2] = &sl->mv_cache[list][scan8[0]]; - AV_COPY128(mv_dst + 0 * b_stride, mv_src + 8 * 0); - AV_COPY128(mv_dst + 1 * b_stride, mv_src + 8 * 1); - AV_COPY128(mv_dst + 2 * b_stride, mv_src + 8 * 2); - AV_COPY128(mv_dst + 3 * b_stride, mv_src + 8 * 3); - if (CABAC(h)) { - uint8_t (*mvd_dst)[2] = &sl->mvd_table[list][FMO ? 8 * sl->mb_xy - : h->mb2br_xy[sl->mb_xy]]; - uint8_t(*mvd_src)[2] = &sl->mvd_cache[list][scan8[0]]; - if (IS_SKIP(mb_type)) { - AV_ZERO128(mvd_dst); - } else { - AV_COPY64(mvd_dst, mvd_src + 8 * 3); - AV_COPY16(mvd_dst + 3 + 3, mvd_src + 3 + 8 * 0); - AV_COPY16(mvd_dst + 3 + 2, mvd_src + 3 + 8 * 1); - AV_COPY16(mvd_dst + 3 + 1, mvd_src + 3 + 8 * 2); - } - } - - { - int8_t *ref_index = &h->cur_pic.ref_index[list][b8_xy]; - int8_t *ref_cache = sl->ref_cache[list]; - ref_index[0 + 0 * 2] = ref_cache[scan8[0]]; - ref_index[1 + 0 * 2] = ref_cache[scan8[4]]; - ref_index[0 + 1 * 2] = ref_cache[scan8[8]]; - ref_index[1 + 1 * 2] = ref_cache[scan8[12]]; - } -} - -static av_always_inline void write_back_motion(const H264Context *h, - H264SliceContext *sl, - int mb_type) -{ - const int b_stride = h->b_stride; - const int b_xy = 4 * sl->mb_x + 4 * sl->mb_y * h->b_stride; // try mb2b(8)_xy - const int b8_xy = 4 * sl->mb_xy; - - if (USES_LIST(mb_type, 0)) { - write_back_motion_list(h, sl, b_stride, b_xy, b8_xy, mb_type, 0); - } else { - fill_rectangle(&h->cur_pic.ref_index[0][b8_xy], - 2, 2, 2, (uint8_t)LIST_NOT_USED, 1); - } - if (USES_LIST(mb_type, 1)) - write_back_motion_list(h, sl, b_stride, b_xy, b8_xy, mb_type, 1); - - if (sl->slice_type_nos == AV_PICTURE_TYPE_B && CABAC(h)) { - if (IS_8X8(mb_type)) { - uint8_t *direct_table = &h->direct_table[4 * sl->mb_xy]; - direct_table[1] = sl->sub_mb_type[1] >> 1; - direct_table[2] = sl->sub_mb_type[2] >> 1; - direct_table[3] = sl->sub_mb_type[3] >> 1; - } - } -} - -static av_always_inline int get_dct8x8_allowed(const H264Context *h, H264SliceContext *sl) -{ - if (h->ps.sps->direct_8x8_inference_flag) - return !(AV_RN64A(sl->sub_mb_type) & - ((MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8) * - 0x0001000100010001ULL)); - else - return !(AV_RN64A(sl->sub_mb_type) & - ((MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8 | MB_TYPE_DIRECT2) * - 0x0001000100010001ULL)); -} - -static av_always_inline int fetch_diagonal_mv(const H264Context *h, H264SliceContext *sl, - const int16_t **C, - int i, int list, int part_width) -{ - const int topright_ref = sl->ref_cache[list][i - 8 + part_width]; - - /* there is no consistent mapping of mvs to neighboring locations that will - * make mbaff happy, so we can't move all this logic to fill_caches */ - if (FRAME_MBAFF(h)) { -#define SET_DIAG_MV(MV_OP, REF_OP, XY, Y4) \ - const int xy = XY, y4 = Y4; \ - const int mb_type = mb_types[xy + (y4 >> 2) * h->mb_stride]; \ - if (!USES_LIST(mb_type, list)) \ - return LIST_NOT_USED; \ - mv = h->cur_pic_ptr->motion_val[list][h->mb2b_xy[xy] + 3 + y4 * h->b_stride]; \ - sl->mv_cache[list][scan8[0] - 2][0] = mv[0]; \ - sl->mv_cache[list][scan8[0] - 2][1] = mv[1] MV_OP; \ - return h->cur_pic_ptr->ref_index[list][4 * xy + 1 + (y4 & ~1)] REF_OP; - - if (topright_ref == PART_NOT_AVAILABLE - && i >= scan8[0] + 8 && (i & 7) == 4 - && sl->ref_cache[list][scan8[0] - 1] != PART_NOT_AVAILABLE) { - const uint32_t *mb_types = h->cur_pic_ptr->mb_type; - const int16_t *mv; - AV_ZERO32(sl->mv_cache[list][scan8[0] - 2]); - *C = sl->mv_cache[list][scan8[0] - 2]; - - if (!MB_FIELD(sl) && IS_INTERLACED(sl->left_type[0])) { - SET_DIAG_MV(* 2, >> 1, sl->left_mb_xy[0] + h->mb_stride, - (sl->mb_y & 1) * 2 + (i >> 5)); - } - if (MB_FIELD(sl) && !IS_INTERLACED(sl->left_type[0])) { - // left shift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, but that's OK. - SET_DIAG_MV(/ 2, *2, sl->left_mb_xy[i >= 36], ((i >> 2)) & 3); - } - } -#undef SET_DIAG_MV - } - - if (topright_ref != PART_NOT_AVAILABLE) { - *C = sl->mv_cache[list][i - 8 + part_width]; - return topright_ref; - } else { - ff_tlog(h->avctx, "topright MV not available\n"); - - *C = sl->mv_cache[list][i - 8 - 1]; - return sl->ref_cache[list][i - 8 - 1]; - } -} - -/** - * Get the predicted MV. - * @param n the block index - * @param part_width the width of the partition (4, 8,16) -> (1, 2, 4) - * @param mx the x component of the predicted motion vector - * @param my the y component of the predicted motion vector - */ -static av_always_inline void pred_motion(const H264Context *const h, - H264SliceContext *sl, - int n, - int part_width, int list, int ref, - int *const mx, int *const my) -{ - const int index8 = scan8[n]; - const int top_ref = sl->ref_cache[list][index8 - 8]; - const int left_ref = sl->ref_cache[list][index8 - 1]; - const int16_t *const A = sl->mv_cache[list][index8 - 1]; - const int16_t *const B = sl->mv_cache[list][index8 - 8]; - const int16_t *C; - int diagonal_ref, match_count; - - av_assert2(part_width == 1 || part_width == 2 || part_width == 4); - -/* mv_cache - * B . . A T T T T - * U . . L . . , . - * U . . L . . . . - * U . . L . . , . - * . . . L . . . . - */ - - diagonal_ref = fetch_diagonal_mv(h, sl, &C, index8, list, part_width); - match_count = (diagonal_ref == ref) + (top_ref == ref) + (left_ref == ref); - ff_tlog(h->avctx, "pred_motion match_count=%d\n", match_count); - if (match_count > 1) { //most common - *mx = mid_pred(A[0], B[0], C[0]); - *my = mid_pred(A[1], B[1], C[1]); - } else if (match_count == 1) { - if (left_ref == ref) { - *mx = A[0]; - *my = A[1]; - } else if (top_ref == ref) { - *mx = B[0]; - *my = B[1]; - } else { - *mx = C[0]; - *my = C[1]; - } - } else { - if (top_ref == PART_NOT_AVAILABLE && - diagonal_ref == PART_NOT_AVAILABLE && - left_ref != PART_NOT_AVAILABLE) { - *mx = A[0]; - *my = A[1]; - } else { - *mx = mid_pred(A[0], B[0], C[0]); - *my = mid_pred(A[1], B[1], C[1]); - } - } - - ff_tlog(h->avctx, - "pred_motion (%2d %2d %2d) (%2d %2d %2d) (%2d %2d %2d) -> (%2d %2d %2d) at %2d %2d %d list %d\n", - top_ref, B[0], B[1], diagonal_ref, C[0], C[1], left_ref, - A[0], A[1], ref, *mx, *my, sl->mb_x, sl->mb_y, n, list); -} - -/** - * Get the directionally predicted 16x8 MV. - * @param n the block index - * @param mx the x component of the predicted motion vector - * @param my the y component of the predicted motion vector - */ -static av_always_inline void pred_16x8_motion(const H264Context *const h, - H264SliceContext *sl, - int n, int list, int ref, - int *const mx, int *const my) -{ - if (n == 0) { - const int top_ref = sl->ref_cache[list][scan8[0] - 8]; - const int16_t *const B = sl->mv_cache[list][scan8[0] - 8]; - - ff_tlog(h->avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", - top_ref, B[0], B[1], sl->mb_x, sl->mb_y, n, list); - - if (top_ref == ref) { - *mx = B[0]; - *my = B[1]; - return; - } - } else { - const int left_ref = sl->ref_cache[list][scan8[8] - 1]; - const int16_t *const A = sl->mv_cache[list][scan8[8] - 1]; - - ff_tlog(h->avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", - left_ref, A[0], A[1], sl->mb_x, sl->mb_y, n, list); - - if (left_ref == ref) { - *mx = A[0]; - *my = A[1]; - return; - } - } - - //RARE - pred_motion(h, sl, n, 4, list, ref, mx, my); -} - -/** - * Get the directionally predicted 8x16 MV. - * @param n the block index - * @param mx the x component of the predicted motion vector - * @param my the y component of the predicted motion vector - */ -static av_always_inline void pred_8x16_motion(const H264Context *const h, - H264SliceContext *sl, - int n, int list, int ref, - int *const mx, int *const my) -{ - if (n == 0) { - const int left_ref = sl->ref_cache[list][scan8[0] - 1]; - const int16_t *const A = sl->mv_cache[list][scan8[0] - 1]; - - ff_tlog(h->avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", - left_ref, A[0], A[1], sl->mb_x, sl->mb_y, n, list); - - if (left_ref == ref) { - *mx = A[0]; - *my = A[1]; - return; - } - } else { - const int16_t *C; - int diagonal_ref; - - diagonal_ref = fetch_diagonal_mv(h, sl, &C, scan8[4], list, 2); - - ff_tlog(h->avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", - diagonal_ref, C[0], C[1], sl->mb_x, sl->mb_y, n, list); - - if (diagonal_ref == ref) { - *mx = C[0]; - *my = C[1]; - return; - } - } - - //RARE - pred_motion(h, sl, n, 2, list, ref, mx, my); -} - -#define FIX_MV_MBAFF(type, refn, mvn, idx) \ - if (FRAME_MBAFF(h)) { \ - if (MB_FIELD(sl)) { \ - if (!IS_INTERLACED(type)) { \ - refn <<= 1; \ - AV_COPY32(mvbuf[idx], mvn); \ - mvbuf[idx][1] /= 2; \ - mvn = mvbuf[idx]; \ - } \ - } else { \ - if (IS_INTERLACED(type)) { \ - refn >>= 1; \ - AV_COPY32(mvbuf[idx], mvn); \ - mvbuf[idx][1] *= 2; \ - mvn = mvbuf[idx]; \ - } \ - } \ - } - -static av_always_inline void pred_pskip_motion(const H264Context *const h, - H264SliceContext *sl) -{ - DECLARE_ALIGNED(4, static const int16_t, zeromv)[2] = { 0 }; - DECLARE_ALIGNED(4, int16_t, mvbuf)[3][2]; - int8_t *ref = h->cur_pic.ref_index[0]; - int16_t(*mv)[2] = h->cur_pic.motion_val[0]; - int top_ref, left_ref, diagonal_ref, match_count, mx, my; - const int16_t *A, *B, *C; - int b_stride = h->b_stride; - - fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1); - - /* To avoid doing an entire fill_decode_caches, we inline the relevant - * parts here. - * FIXME: this is a partial duplicate of the logic in fill_decode_caches, - * but it's faster this way. Is there a way to avoid this duplication? - */ - if (USES_LIST(sl->left_type[LTOP], 0)) { - left_ref = ref[4 * sl->left_mb_xy[LTOP] + 1 + (sl->left_block[0] & ~1)]; - A = mv[h->mb2b_xy[sl->left_mb_xy[LTOP]] + 3 + b_stride * sl->left_block[0]]; - FIX_MV_MBAFF(sl->left_type[LTOP], left_ref, A, 0); - if (!(left_ref | AV_RN32A(A))) - goto zeromv; - } else if (sl->left_type[LTOP]) { - left_ref = LIST_NOT_USED; - A = zeromv; - } else { - goto zeromv; - } - - if (USES_LIST(sl->top_type, 0)) { - top_ref = ref[4 * sl->top_mb_xy + 2]; - B = mv[h->mb2b_xy[sl->top_mb_xy] + 3 * b_stride]; - FIX_MV_MBAFF(sl->top_type, top_ref, B, 1); - if (!(top_ref | AV_RN32A(B))) - goto zeromv; - } else if (sl->top_type) { - top_ref = LIST_NOT_USED; - B = zeromv; - } else { - goto zeromv; - } - - ff_tlog(h->avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", - top_ref, left_ref, sl->mb_x, sl->mb_y); - - if (USES_LIST(sl->topright_type, 0)) { - diagonal_ref = ref[4 * sl->topright_mb_xy + 2]; - C = mv[h->mb2b_xy[sl->topright_mb_xy] + 3 * b_stride]; - FIX_MV_MBAFF(sl->topright_type, diagonal_ref, C, 2); - } else if (sl->topright_type) { - diagonal_ref = LIST_NOT_USED; - C = zeromv; - } else { - if (USES_LIST(sl->topleft_type, 0)) { - diagonal_ref = ref[4 * sl->topleft_mb_xy + 1 + - (sl->topleft_partition & 2)]; - C = mv[h->mb2b_xy[sl->topleft_mb_xy] + 3 + b_stride + - (sl->topleft_partition & 2 * b_stride)]; - FIX_MV_MBAFF(sl->topleft_type, diagonal_ref, C, 2); - } else if (sl->topleft_type) { - diagonal_ref = LIST_NOT_USED; - C = zeromv; - } else { - diagonal_ref = PART_NOT_AVAILABLE; - C = zeromv; - } - } - - match_count = !diagonal_ref + !top_ref + !left_ref; - ff_tlog(h->avctx, "pred_pskip_motion match_count=%d\n", match_count); - if (match_count > 1) { - mx = mid_pred(A[0], B[0], C[0]); - my = mid_pred(A[1], B[1], C[1]); - } else if (match_count == 1) { - if (!left_ref) { - mx = A[0]; - my = A[1]; - } else if (!top_ref) { - mx = B[0]; - my = B[1]; - } else { - mx = C[0]; - my = C[1]; - } - } else { - mx = mid_pred(A[0], B[0], C[0]); - my = mid_pred(A[1], B[1], C[1]); - } - - fill_rectangle(sl->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx, my), 4); - return; - -zeromv: - fill_rectangle(sl->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4); - return; -} - -static void fill_decode_neighbors(const H264Context *h, H264SliceContext *sl, int mb_type) -{ - const int mb_xy = sl->mb_xy; - int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS]; - static const uint8_t left_block_options[4][32] = { - { 0, 1, 2, 3, 7, 10, 8, 11, 3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 5 * 4, 1 + 9 * 4 }, - { 2, 2, 3, 3, 8, 11, 8, 11, 3 + 2 * 4, 3 + 2 * 4, 3 + 3 * 4, 3 + 3 * 4, 1 + 5 * 4, 1 + 9 * 4, 1 + 5 * 4, 1 + 9 * 4 }, - { 0, 0, 1, 1, 7, 10, 7, 10, 3 + 0 * 4, 3 + 0 * 4, 3 + 1 * 4, 3 + 1 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 4 * 4, 1 + 8 * 4 }, - { 0, 2, 0, 2, 7, 10, 7, 10, 3 + 0 * 4, 3 + 2 * 4, 3 + 0 * 4, 3 + 2 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 4 * 4, 1 + 8 * 4 } - }; - - sl->topleft_partition = -1; - - top_xy = mb_xy - (h->mb_stride << MB_FIELD(sl)); - - /* Wow, what a mess, why didn't they simplify the interlacing & intra - * stuff, I can't imagine that these complex rules are worth it. */ - - topleft_xy = top_xy - 1; - topright_xy = top_xy + 1; - left_xy[LBOT] = left_xy[LTOP] = mb_xy - 1; - sl->left_block = left_block_options[0]; - if (FRAME_MBAFF(h)) { - const int left_mb_field_flag = IS_INTERLACED(h->cur_pic.mb_type[mb_xy - 1]); - const int curr_mb_field_flag = IS_INTERLACED(mb_type); - if (sl->mb_y & 1) { - if (left_mb_field_flag != curr_mb_field_flag) { - left_xy[LBOT] = left_xy[LTOP] = mb_xy - h->mb_stride - 1; - if (curr_mb_field_flag) { - left_xy[LBOT] += h->mb_stride; - sl->left_block = left_block_options[3]; - } else { - topleft_xy += h->mb_stride; - /* take top left mv from the middle of the mb, as opposed - * to all other modes which use the bottom right partition */ - sl->topleft_partition = 0; - sl->left_block = left_block_options[1]; - } - } - } else { - if (curr_mb_field_flag) { - topleft_xy += h->mb_stride & (((h->cur_pic.mb_type[top_xy - 1] >> 7) & 1) - 1); - topright_xy += h->mb_stride & (((h->cur_pic.mb_type[top_xy + 1] >> 7) & 1) - 1); - top_xy += h->mb_stride & (((h->cur_pic.mb_type[top_xy] >> 7) & 1) - 1); - } - if (left_mb_field_flag != curr_mb_field_flag) { - if (curr_mb_field_flag) { - left_xy[LBOT] += h->mb_stride; - sl->left_block = left_block_options[3]; - } else { - sl->left_block = left_block_options[2]; - } - } - } - } - - sl->topleft_mb_xy = topleft_xy; - sl->top_mb_xy = top_xy; - sl->topright_mb_xy = topright_xy; - sl->left_mb_xy[LTOP] = left_xy[LTOP]; - sl->left_mb_xy[LBOT] = left_xy[LBOT]; - //FIXME do we need all in the context? - - sl->topleft_type = h->cur_pic.mb_type[topleft_xy]; - sl->top_type = h->cur_pic.mb_type[top_xy]; - sl->topright_type = h->cur_pic.mb_type[topright_xy]; - sl->left_type[LTOP] = h->cur_pic.mb_type[left_xy[LTOP]]; - sl->left_type[LBOT] = h->cur_pic.mb_type[left_xy[LBOT]]; - - if (FMO) { - if (h->slice_table[topleft_xy] != sl->slice_num) - sl->topleft_type = 0; - if (h->slice_table[top_xy] != sl->slice_num) - sl->top_type = 0; - if (h->slice_table[left_xy[LTOP]] != sl->slice_num) - sl->left_type[LTOP] = sl->left_type[LBOT] = 0; - } else { - if (h->slice_table[topleft_xy] != sl->slice_num) { - sl->topleft_type = 0; - if (h->slice_table[top_xy] != sl->slice_num) - sl->top_type = 0; - if (h->slice_table[left_xy[LTOP]] != sl->slice_num) - sl->left_type[LTOP] = sl->left_type[LBOT] = 0; - } - } - if (h->slice_table[topright_xy] != sl->slice_num) - sl->topright_type = 0; -} - -static void fill_decode_caches(const H264Context *h, H264SliceContext *sl, int mb_type) -{ - int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS]; - int topleft_type, top_type, topright_type, left_type[LEFT_MBS]; - const uint8_t *left_block = sl->left_block; - int i; - uint8_t *nnz; - uint8_t *nnz_cache; - - topleft_xy = sl->topleft_mb_xy; - top_xy = sl->top_mb_xy; - topright_xy = sl->topright_mb_xy; - left_xy[LTOP] = sl->left_mb_xy[LTOP]; - left_xy[LBOT] = sl->left_mb_xy[LBOT]; - topleft_type = sl->topleft_type; - top_type = sl->top_type; - topright_type = sl->topright_type; - left_type[LTOP] = sl->left_type[LTOP]; - left_type[LBOT] = sl->left_type[LBOT]; - - if (!IS_SKIP(mb_type)) { - if (IS_INTRA(mb_type)) { - int type_mask = h->ps.pps->constrained_intra_pred ? IS_INTRA(-1) : -1; - sl->topleft_samples_available = - sl->top_samples_available = - sl->left_samples_available = 0xFFFF; - sl->topright_samples_available = 0xEEEA; - - if (!(top_type & type_mask)) { - sl->topleft_samples_available = 0xB3FF; - sl->top_samples_available = 0x33FF; - sl->topright_samples_available = 0x26EA; - } - if (IS_INTERLACED(mb_type) != IS_INTERLACED(left_type[LTOP])) { - if (IS_INTERLACED(mb_type)) { - if (!(left_type[LTOP] & type_mask)) { - sl->topleft_samples_available &= 0xDFFF; - sl->left_samples_available &= 0x5FFF; - } - if (!(left_type[LBOT] & type_mask)) { - sl->topleft_samples_available &= 0xFF5F; - sl->left_samples_available &= 0xFF5F; - } - } else { - int left_typei = h->cur_pic.mb_type[left_xy[LTOP] + h->mb_stride]; - - av_assert2(left_xy[LTOP] == left_xy[LBOT]); - if (!((left_typei & type_mask) && (left_type[LTOP] & type_mask))) { - sl->topleft_samples_available &= 0xDF5F; - sl->left_samples_available &= 0x5F5F; - } - } - } else { - if (!(left_type[LTOP] & type_mask)) { - sl->topleft_samples_available &= 0xDF5F; - sl->left_samples_available &= 0x5F5F; - } - } - - if (!(topleft_type & type_mask)) - sl->topleft_samples_available &= 0x7FFF; - - if (!(topright_type & type_mask)) - sl->topright_samples_available &= 0xFBFF; - - if (IS_INTRA4x4(mb_type)) { - if (IS_INTRA4x4(top_type)) { - AV_COPY32(sl->intra4x4_pred_mode_cache + 4 + 8 * 0, sl->intra4x4_pred_mode + h->mb2br_xy[top_xy]); - } else { - sl->intra4x4_pred_mode_cache[4 + 8 * 0] = - sl->intra4x4_pred_mode_cache[5 + 8 * 0] = - sl->intra4x4_pred_mode_cache[6 + 8 * 0] = - sl->intra4x4_pred_mode_cache[7 + 8 * 0] = 2 - 3 * !(top_type & type_mask); - } - for (i = 0; i < 2; i++) { - if (IS_INTRA4x4(left_type[LEFT(i)])) { - int8_t *mode = sl->intra4x4_pred_mode + h->mb2br_xy[left_xy[LEFT(i)]]; - sl->intra4x4_pred_mode_cache[3 + 8 * 1 + 2 * 8 * i] = mode[6 - left_block[0 + 2 * i]]; - sl->intra4x4_pred_mode_cache[3 + 8 * 2 + 2 * 8 * i] = mode[6 - left_block[1 + 2 * i]]; - } else { - sl->intra4x4_pred_mode_cache[3 + 8 * 1 + 2 * 8 * i] = - sl->intra4x4_pred_mode_cache[3 + 8 * 2 + 2 * 8 * i] = 2 - 3 * !(left_type[LEFT(i)] & type_mask); - } - } - } - } - - /* - * 0 . T T. T T T T - * 1 L . .L . . . . - * 2 L . .L . . . . - * 3 . T TL . . . . - * 4 L . .L . . . . - * 5 L . .. . . . . - */ - /* FIXME: constraint_intra_pred & partitioning & nnz - * (let us hope this is just a typo in the spec) */ - nnz_cache = sl->non_zero_count_cache; - if (top_type) { - nnz = h->non_zero_count[top_xy]; - AV_COPY32(&nnz_cache[4 + 8 * 0], &nnz[4 * 3]); - if (!h->chroma_y_shift) { - AV_COPY32(&nnz_cache[4 + 8 * 5], &nnz[4 * 7]); - AV_COPY32(&nnz_cache[4 + 8 * 10], &nnz[4 * 11]); - } else { - AV_COPY32(&nnz_cache[4 + 8 * 5], &nnz[4 * 5]); - AV_COPY32(&nnz_cache[4 + 8 * 10], &nnz[4 * 9]); - } - } else { - uint32_t top_empty = CABAC(h) && !IS_INTRA(mb_type) ? 0 : 0x40404040; - AV_WN32A(&nnz_cache[4 + 8 * 0], top_empty); - AV_WN32A(&nnz_cache[4 + 8 * 5], top_empty); - AV_WN32A(&nnz_cache[4 + 8 * 10], top_empty); - } - - for (i = 0; i < 2; i++) { - if (left_type[LEFT(i)]) { - nnz = h->non_zero_count[left_xy[LEFT(i)]]; - nnz_cache[3 + 8 * 1 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i]]; - nnz_cache[3 + 8 * 2 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i]]; - if (CHROMA444(h)) { - nnz_cache[3 + 8 * 6 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] + 4 * 4]; - nnz_cache[3 + 8 * 7 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] + 4 * 4]; - nnz_cache[3 + 8 * 11 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] + 8 * 4]; - nnz_cache[3 + 8 * 12 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] + 8 * 4]; - } else if (CHROMA422(h)) { - nnz_cache[3 + 8 * 6 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] - 2 + 4 * 4]; - nnz_cache[3 + 8 * 7 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] - 2 + 4 * 4]; - nnz_cache[3 + 8 * 11 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] - 2 + 8 * 4]; - nnz_cache[3 + 8 * 12 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] - 2 + 8 * 4]; - } else { - nnz_cache[3 + 8 * 6 + 8 * i] = nnz[left_block[8 + 4 + 2 * i]]; - nnz_cache[3 + 8 * 11 + 8 * i] = nnz[left_block[8 + 5 + 2 * i]]; - } - } else { - nnz_cache[3 + 8 * 1 + 2 * 8 * i] = - nnz_cache[3 + 8 * 2 + 2 * 8 * i] = - nnz_cache[3 + 8 * 6 + 2 * 8 * i] = - nnz_cache[3 + 8 * 7 + 2 * 8 * i] = - nnz_cache[3 + 8 * 11 + 2 * 8 * i] = - nnz_cache[3 + 8 * 12 + 2 * 8 * i] = CABAC(h) && !IS_INTRA(mb_type) ? 0 : 64; - } - } - - if (CABAC(h)) { - // top_cbp - if (top_type) - sl->top_cbp = h->cbp_table[top_xy]; - else - sl->top_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F; - // left_cbp - if (left_type[LTOP]) { - sl->left_cbp = (h->cbp_table[left_xy[LTOP]] & 0x7F0) | - ((h->cbp_table[left_xy[LTOP]] >> (left_block[0] & (~1))) & 2) | - (((h->cbp_table[left_xy[LBOT]] >> (left_block[2] & (~1))) & 2) << 2); - } else { - sl->left_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F; - } - } - } - - if (IS_INTER(mb_type) || (IS_DIRECT(mb_type) && sl->direct_spatial_mv_pred)) { - int list; - int b_stride = h->b_stride; - for (list = 0; list < sl->list_count; list++) { - int8_t *ref_cache = &sl->ref_cache[list][scan8[0]]; - int8_t *ref = h->cur_pic.ref_index[list]; - int16_t(*mv_cache)[2] = &sl->mv_cache[list][scan8[0]]; - int16_t(*mv)[2] = h->cur_pic.motion_val[list]; - if (!USES_LIST(mb_type, list)) - continue; - av_assert2(!(IS_DIRECT(mb_type) && !sl->direct_spatial_mv_pred)); - - if (USES_LIST(top_type, list)) { - const int b_xy = h->mb2b_xy[top_xy] + 3 * b_stride; - AV_COPY128(mv_cache[0 - 1 * 8], mv[b_xy + 0]); - ref_cache[0 - 1 * 8] = - ref_cache[1 - 1 * 8] = ref[4 * top_xy + 2]; - ref_cache[2 - 1 * 8] = - ref_cache[3 - 1 * 8] = ref[4 * top_xy + 3]; - } else { - AV_ZERO128(mv_cache[0 - 1 * 8]); - AV_WN32A(&ref_cache[0 - 1 * 8], - ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE) & 0xFF) * 0x01010101u); - } - - if (mb_type & (MB_TYPE_16x8 | MB_TYPE_8x8)) { - for (i = 0; i < 2; i++) { - int cache_idx = -1 + i * 2 * 8; - if (USES_LIST(left_type[LEFT(i)], list)) { - const int b_xy = h->mb2b_xy[left_xy[LEFT(i)]] + 3; - const int b8_xy = 4 * left_xy[LEFT(i)] + 1; - AV_COPY32(mv_cache[cache_idx], - mv[b_xy + b_stride * left_block[0 + i * 2]]); - AV_COPY32(mv_cache[cache_idx + 8], - mv[b_xy + b_stride * left_block[1 + i * 2]]); - ref_cache[cache_idx] = ref[b8_xy + (left_block[0 + i * 2] & ~1)]; - ref_cache[cache_idx + 8] = ref[b8_xy + (left_block[1 + i * 2] & ~1)]; - } else { - AV_ZERO32(mv_cache[cache_idx]); - AV_ZERO32(mv_cache[cache_idx + 8]); - ref_cache[cache_idx] = - ref_cache[cache_idx + 8] = (left_type[LEFT(i)]) ? LIST_NOT_USED - : PART_NOT_AVAILABLE; - } - } - } else { - if (USES_LIST(left_type[LTOP], list)) { - const int b_xy = h->mb2b_xy[left_xy[LTOP]] + 3; - const int b8_xy = 4 * left_xy[LTOP] + 1; - AV_COPY32(mv_cache[-1], mv[b_xy + b_stride * left_block[0]]); - ref_cache[-1] = ref[b8_xy + (left_block[0] & ~1)]; - } else { - AV_ZERO32(mv_cache[-1]); - ref_cache[-1] = left_type[LTOP] ? LIST_NOT_USED - : PART_NOT_AVAILABLE; - } - } - - if (USES_LIST(topright_type, list)) { - const int b_xy = h->mb2b_xy[topright_xy] + 3 * b_stride; - AV_COPY32(mv_cache[4 - 1 * 8], mv[b_xy]); - ref_cache[4 - 1 * 8] = ref[4 * topright_xy + 2]; - } else { - AV_ZERO32(mv_cache[4 - 1 * 8]); - ref_cache[4 - 1 * 8] = topright_type ? LIST_NOT_USED - : PART_NOT_AVAILABLE; - } - if(ref_cache[2 - 1*8] < 0 || ref_cache[4 - 1 * 8] < 0) { - if (USES_LIST(topleft_type, list)) { - const int b_xy = h->mb2b_xy[topleft_xy] + 3 + b_stride + - (sl->topleft_partition & 2 * b_stride); - const int b8_xy = 4 * topleft_xy + 1 + (sl->topleft_partition & 2); - AV_COPY32(mv_cache[-1 - 1 * 8], mv[b_xy]); - ref_cache[-1 - 1 * 8] = ref[b8_xy]; - } else { - AV_ZERO32(mv_cache[-1 - 1 * 8]); - ref_cache[-1 - 1 * 8] = topleft_type ? LIST_NOT_USED - : PART_NOT_AVAILABLE; - } - } - - if ((mb_type & (MB_TYPE_SKIP | MB_TYPE_DIRECT2)) && !FRAME_MBAFF(h)) - continue; - - if (!(mb_type & (MB_TYPE_SKIP | MB_TYPE_DIRECT2))) { - uint8_t(*mvd_cache)[2] = &sl->mvd_cache[list][scan8[0]]; - uint8_t(*mvd)[2] = sl->mvd_table[list]; - ref_cache[2 + 8 * 0] = - ref_cache[2 + 8 * 2] = PART_NOT_AVAILABLE; - AV_ZERO32(mv_cache[2 + 8 * 0]); - AV_ZERO32(mv_cache[2 + 8 * 2]); - - if (CABAC(h)) { - if (USES_LIST(top_type, list)) { - const int b_xy = h->mb2br_xy[top_xy]; - AV_COPY64(mvd_cache[0 - 1 * 8], mvd[b_xy + 0]); - } else { - AV_ZERO64(mvd_cache[0 - 1 * 8]); - } - if (USES_LIST(left_type[LTOP], list)) { - const int b_xy = h->mb2br_xy[left_xy[LTOP]] + 6; - AV_COPY16(mvd_cache[-1 + 0 * 8], mvd[b_xy - left_block[0]]); - AV_COPY16(mvd_cache[-1 + 1 * 8], mvd[b_xy - left_block[1]]); - } else { - AV_ZERO16(mvd_cache[-1 + 0 * 8]); - AV_ZERO16(mvd_cache[-1 + 1 * 8]); - } - if (USES_LIST(left_type[LBOT], list)) { - const int b_xy = h->mb2br_xy[left_xy[LBOT]] + 6; - AV_COPY16(mvd_cache[-1 + 2 * 8], mvd[b_xy - left_block[2]]); - AV_COPY16(mvd_cache[-1 + 3 * 8], mvd[b_xy - left_block[3]]); - } else { - AV_ZERO16(mvd_cache[-1 + 2 * 8]); - AV_ZERO16(mvd_cache[-1 + 3 * 8]); - } - AV_ZERO16(mvd_cache[2 + 8 * 0]); - AV_ZERO16(mvd_cache[2 + 8 * 2]); - if (sl->slice_type_nos == AV_PICTURE_TYPE_B) { - uint8_t *direct_cache = &sl->direct_cache[scan8[0]]; - uint8_t *direct_table = h->direct_table; - fill_rectangle(direct_cache, 4, 4, 8, MB_TYPE_16x16 >> 1, 1); - - if (IS_DIRECT(top_type)) { - AV_WN32A(&direct_cache[-1 * 8], - 0x01010101u * (MB_TYPE_DIRECT2 >> 1)); - } else if (IS_8X8(top_type)) { - int b8_xy = 4 * top_xy; - direct_cache[0 - 1 * 8] = direct_table[b8_xy + 2]; - direct_cache[2 - 1 * 8] = direct_table[b8_xy + 3]; - } else { - AV_WN32A(&direct_cache[-1 * 8], - 0x01010101 * (MB_TYPE_16x16 >> 1)); - } - - if (IS_DIRECT(left_type[LTOP])) - direct_cache[-1 + 0 * 8] = MB_TYPE_DIRECT2 >> 1; - else if (IS_8X8(left_type[LTOP])) - direct_cache[-1 + 0 * 8] = direct_table[4 * left_xy[LTOP] + 1 + (left_block[0] & ~1)]; - else - direct_cache[-1 + 0 * 8] = MB_TYPE_16x16 >> 1; - - if (IS_DIRECT(left_type[LBOT])) - direct_cache[-1 + 2 * 8] = MB_TYPE_DIRECT2 >> 1; - else if (IS_8X8(left_type[LBOT])) - direct_cache[-1 + 2 * 8] = direct_table[4 * left_xy[LBOT] + 1 + (left_block[2] & ~1)]; - else - direct_cache[-1 + 2 * 8] = MB_TYPE_16x16 >> 1; - } - } - } - -#define MAP_MVS \ - MAP_F2F(scan8[0] - 1 - 1 * 8, topleft_type) \ - MAP_F2F(scan8[0] + 0 - 1 * 8, top_type) \ - MAP_F2F(scan8[0] + 1 - 1 * 8, top_type) \ - MAP_F2F(scan8[0] + 2 - 1 * 8, top_type) \ - MAP_F2F(scan8[0] + 3 - 1 * 8, top_type) \ - MAP_F2F(scan8[0] + 4 - 1 * 8, topright_type) \ - MAP_F2F(scan8[0] - 1 + 0 * 8, left_type[LTOP]) \ - MAP_F2F(scan8[0] - 1 + 1 * 8, left_type[LTOP]) \ - MAP_F2F(scan8[0] - 1 + 2 * 8, left_type[LBOT]) \ - MAP_F2F(scan8[0] - 1 + 3 * 8, left_type[LBOT]) - - if (FRAME_MBAFF(h)) { - if (MB_FIELD(sl)) { - -#define MAP_F2F(idx, mb_type) \ - if (!IS_INTERLACED(mb_type) && sl->ref_cache[list][idx] >= 0) { \ - sl->ref_cache[list][idx] *= 2; \ - sl->mv_cache[list][idx][1] /= 2; \ - sl->mvd_cache[list][idx][1] >>= 1; \ - } - - MAP_MVS - } else { - -#undef MAP_F2F -#define MAP_F2F(idx, mb_type) \ - if (IS_INTERLACED(mb_type) && sl->ref_cache[list][idx] >= 0) { \ - sl->ref_cache[list][idx] >>= 1; \ - sl->mv_cache[list][idx][1] *= 2; \ - sl->mvd_cache[list][idx][1] <<= 1; \ - } - - MAP_MVS -#undef MAP_F2F - } - } - } - } - - sl->neighbor_transform_size = !!IS_8x8DCT(top_type) + !!IS_8x8DCT(left_type[LTOP]); -} - -/** - * decodes a P_SKIP or B_SKIP macroblock - */ -static void av_unused decode_mb_skip(const H264Context *h, H264SliceContext *sl) -{ - const int mb_xy = sl->mb_xy; - int mb_type = 0; - - memset(h->non_zero_count[mb_xy], 0, 48); - - if (MB_FIELD(sl)) - mb_type |= MB_TYPE_INTERLACED; - - if (sl->slice_type_nos == AV_PICTURE_TYPE_B) { - // just for fill_caches. pred_direct_motion will set the real mb_type - mb_type |= MB_TYPE_L0L1 | MB_TYPE_DIRECT2 | MB_TYPE_SKIP; - if (sl->direct_spatial_mv_pred) { - fill_decode_neighbors(h, sl, mb_type); - fill_decode_caches(h, sl, mb_type); //FIXME check what is needed and what not ... - } - ff_h264_pred_direct_motion(h, sl, &mb_type); - mb_type |= MB_TYPE_SKIP; - } else { - mb_type |= MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_SKIP; - - fill_decode_neighbors(h, sl, mb_type); - pred_pskip_motion(h, sl); - } - - write_back_motion(h, sl, mb_type); - h->cur_pic.mb_type[mb_xy] = mb_type; - h->cur_pic.qscale_table[mb_xy] = sl->qscale; - h->slice_table[mb_xy] = sl->slice_num; - sl->prev_mb_skipped = 1; -} - -#endif /* AVCODEC_H264_MVPRED_H */ diff --git a/include/libavcodec/h264_parse.h b/include/libavcodec/h264_parse.h deleted file mode 100644 index 4ee863df66..0000000000 --- a/include/libavcodec/h264_parse.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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 - * H.264 decoder/parser shared code - */ - -#ifndef AVCODEC_H264_PARSE_H -#define AVCODEC_H264_PARSE_H - -#include "config.h" - -#include - -#include "libavutil/attributes.h" - -#include "get_bits.h" -#include "h264_ps.h" - -#define MB_TYPE_REF0 MB_TYPE_ACPRED // dirty but it fits in 16 bit -#define MB_TYPE_8x8DCT 0x01000000 - -// This table must be here because scan8[constant] must be known at compiletime -static const uint8_t scan8[16 * 3 + 3] = { - 4 + 1 * 8, 5 + 1 * 8, 4 + 2 * 8, 5 + 2 * 8, - 6 + 1 * 8, 7 + 1 * 8, 6 + 2 * 8, 7 + 2 * 8, - 4 + 3 * 8, 5 + 3 * 8, 4 + 4 * 8, 5 + 4 * 8, - 6 + 3 * 8, 7 + 3 * 8, 6 + 4 * 8, 7 + 4 * 8, - 4 + 6 * 8, 5 + 6 * 8, 4 + 7 * 8, 5 + 7 * 8, - 6 + 6 * 8, 7 + 6 * 8, 6 + 7 * 8, 7 + 7 * 8, - 4 + 8 * 8, 5 + 8 * 8, 4 + 9 * 8, 5 + 9 * 8, - 6 + 8 * 8, 7 + 8 * 8, 6 + 9 * 8, 7 + 9 * 8, - 4 + 11 * 8, 5 + 11 * 8, 4 + 12 * 8, 5 + 12 * 8, - 6 + 11 * 8, 7 + 11 * 8, 6 + 12 * 8, 7 + 12 * 8, - 4 + 13 * 8, 5 + 13 * 8, 4 + 14 * 8, 5 + 14 * 8, - 6 + 13 * 8, 7 + 13 * 8, 6 + 14 * 8, 7 + 14 * 8, - 0 + 0 * 8, 0 + 5 * 8, 0 + 10 * 8 -}; - -/** - * Memory management control operation opcode. - */ -typedef enum MMCOOpcode { - MMCO_END = 0, - MMCO_SHORT2UNUSED, - MMCO_LONG2UNUSED, - MMCO_SHORT2LONG, - MMCO_SET_MAX_LONG, - MMCO_RESET, - MMCO_LONG, -} MMCOOpcode; - -typedef struct H264PredWeightTable { - int use_weight; - int use_weight_chroma; - int luma_log2_weight_denom; - int chroma_log2_weight_denom; - int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag - int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag - // The following 2 can be changed to int8_t but that causes a 10 CPU cycles speed loss - int luma_weight[48][2][2]; - int chroma_weight[48][2][2][2]; - int implicit_weight[48][48][2]; -} H264PredWeightTable; - -typedef struct H264POCContext { - int poc_lsb; - int poc_msb; - int delta_poc_bottom; - int delta_poc[2]; - int frame_num; - int prev_poc_msb; ///< poc_msb of the last reference pic for POC type 0 - int prev_poc_lsb; ///< poc_lsb of the last reference pic for POC type 0 - int frame_num_offset; ///< for POC type 2 - int prev_frame_num_offset; ///< for POC type 2 - int prev_frame_num; ///< frame_num of the last pic for POC type 1/2 -} H264POCContext; - -int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps, - const int *ref_count, int slice_type_nos, - H264PredWeightTable *pwt, - int picture_structure, void *logctx); - -/** - * Check if the top & left blocks are available if needed & change the - * dc mode so it only uses the available blocks. - */ -int ff_h264_check_intra4x4_pred_mode(int8_t *pred_mode_cache, void *logctx, - int top_samples_available, int left_samples_available); - -/** - * Check if the top & left blocks are available if needed & change the - * dc mode so it only uses the available blocks. - */ -int ff_h264_check_intra_pred_mode(void *logctx, int top_samples_available, - int left_samples_available, - int mode, int is_chroma); - -int ff_h264_parse_ref_count(int *plist_count, int ref_count[2], - GetBitContext *gb, const PPS *pps, - int slice_type_nos, int picture_structure, void *logctx); - -int ff_h264_init_poc(int pic_field_poc[2], int *pic_poc, - const SPS *sps, H264POCContext *poc, - int picture_structure, int nal_ref_idc); - -int ff_h264_decode_extradata(const uint8_t *data, int size, H264ParamSets *ps, - int *is_avc, int *nal_length_size, - int err_recognition, void *logctx); - -static av_always_inline uint32_t pack16to32(unsigned a, unsigned b) -{ -#if HAVE_BIGENDIAN - return (b & 0xFFFF) + (a << 16); -#else - return (a & 0xFFFF) + (b << 16); -#endif -} - -#endif /* AVCODEC_H264_PARSE_H */ diff --git a/include/libavcodec/h264_ps.h b/include/libavcodec/h264_ps.h deleted file mode 100644 index 80af4832fe..0000000000 --- a/include/libavcodec/h264_ps.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * 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 - * H.264 parameter set handling - */ - -#ifndef AVCODEC_H264_PS_H -#define AVCODEC_H264_PS_H - -#include - -#include "libavutil/pixfmt.h" -#include "libavutil/rational.h" - -#include "avcodec.h" -#include "get_bits.h" -#include "h264.h" -#include "h2645_vui.h" - -#define MAX_SPS_COUNT 32 -#define MAX_PPS_COUNT 256 -#define MAX_LOG2_MAX_FRAME_NUM (12 + 4) - -/** - * Sequence parameter set - */ -typedef struct SPS { - unsigned int sps_id; - int profile_idc; - int level_idc; - int chroma_format_idc; - int transform_bypass; ///< qpprime_y_zero_transform_bypass_flag - int log2_max_frame_num; ///< log2_max_frame_num_minus4 + 4 - int poc_type; ///< pic_order_cnt_type - int log2_max_poc_lsb; ///< log2_max_pic_order_cnt_lsb_minus4 - int delta_pic_order_always_zero_flag; - int offset_for_non_ref_pic; - int offset_for_top_to_bottom_field; - int poc_cycle_length; ///< num_ref_frames_in_pic_order_cnt_cycle - int ref_frame_count; ///< num_ref_frames - int gaps_in_frame_num_allowed_flag; - int mb_width; ///< pic_width_in_mbs_minus1 + 1 - ///< (pic_height_in_map_units_minus1 + 1) * (2 - frame_mbs_only_flag) - int mb_height; - int frame_mbs_only_flag; - int mb_aff; ///< mb_adaptive_frame_field_flag - int direct_8x8_inference_flag; - int crop; ///< frame_cropping_flag - - /* those 4 are already in luma samples */ - unsigned int crop_left; ///< frame_cropping_rect_left_offset - unsigned int crop_right; ///< frame_cropping_rect_right_offset - unsigned int crop_top; ///< frame_cropping_rect_top_offset - unsigned int crop_bottom; ///< frame_cropping_rect_bottom_offset - int vui_parameters_present_flag; - H2645VUI vui; - - int timing_info_present_flag; - uint32_t num_units_in_tick; - uint32_t time_scale; - int fixed_frame_rate_flag; - int32_t offset_for_ref_frame[256]; - int bitstream_restriction_flag; - int num_reorder_frames; - int max_dec_frame_buffering; - int scaling_matrix_present; - uint16_t scaling_matrix_present_mask; - uint8_t scaling_matrix4[6][16]; - uint8_t scaling_matrix8[6][64]; - int nal_hrd_parameters_present_flag; - int vcl_hrd_parameters_present_flag; - int pic_struct_present_flag; - int time_offset_length; - int cpb_cnt; ///< See H.264 E.1.2 - int bit_rate_scale; - uint32_t bit_rate_value[32]; ///< bit_rate_value_minus1 + 1 - uint32_t cpb_size_value[32]; ///< cpb_size_value_minus1 + 1 - uint32_t cpr_flag; - int initial_cpb_removal_delay_length; ///< initial_cpb_removal_delay_length_minus1 + 1 - int cpb_removal_delay_length; ///< cpb_removal_delay_length_minus1 + 1 - int dpb_output_delay_length; ///< dpb_output_delay_length_minus1 + 1 - int bit_depth_luma; ///< bit_depth_luma_minus8 + 8 - int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8 - int residual_color_transform_flag; ///< residual_colour_transform_flag - int constraint_set_flags; ///< constraint_set[0-3]_flag - uint8_t data[4096]; - size_t data_size; -} SPS; - -/** - * Picture parameter set - */ -typedef struct PPS { - unsigned int pps_id; - unsigned int sps_id; - int cabac; ///< entropy_coding_mode_flag - int pic_order_present; ///< bottom_field_pic_order_in_frame_present_flag - int slice_group_count; ///< num_slice_groups_minus1 + 1 - int mb_slice_group_map_type; - unsigned int ref_count[2]; ///< num_ref_idx_l0/1_active_minus1 + 1 - int weighted_pred; ///< weighted_pred_flag - int weighted_bipred_idc; - int init_qp; ///< pic_init_qp_minus26 + 26 - int init_qs; ///< pic_init_qs_minus26 + 26 - int chroma_qp_index_offset[2]; - int deblocking_filter_parameters_present; ///< deblocking_filter_parameters_present_flag - int constrained_intra_pred; ///< constrained_intra_pred_flag - int redundant_pic_cnt_present; ///< redundant_pic_cnt_present_flag - int transform_8x8_mode; ///< transform_8x8_mode_flag - int pic_scaling_matrix_present_flag; - uint16_t pic_scaling_matrix_present_mask; - uint8_t scaling_matrix4[6][16]; - uint8_t scaling_matrix8[6][64]; - uint8_t chroma_qp_table[2][QP_MAX_NUM+1]; ///< pre-scaled (with chroma_qp_index_offset) version of qp_table - int chroma_qp_diff; - uint8_t data[4096]; - size_t data_size; - - uint32_t dequant4_buffer[6][QP_MAX_NUM + 1][16]; - uint32_t dequant8_buffer[6][QP_MAX_NUM + 1][64]; - uint32_t(*dequant4_coeff[6])[16]; - uint32_t(*dequant8_coeff[6])[64]; - - const SPS *sps; ///< RefStruct reference -} PPS; - -typedef struct H264ParamSets { - const SPS *sps_list[MAX_SPS_COUNT]; ///< RefStruct references - const PPS *pps_list[MAX_PPS_COUNT]; ///< RefStruct references - - /* currently active parameters sets */ - const PPS *pps; ///< RefStruct reference - const SPS *sps; ///< ordinary pointer, no RefStruct reference - - int overread_warning_printed[2]; -} H264ParamSets; - -/** - * compute profile from sps - */ -int ff_h264_get_profile(const SPS *sps); - -/** - * Decode SPS - */ -int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, - H264ParamSets *ps, int ignore_truncation); - -/** - * Decode PPS - */ -int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avctx, - H264ParamSets *ps, int bit_length); - -/** - * Uninit H264 param sets structure. - */ -void ff_h264_ps_uninit(H264ParamSets *ps); - -#endif /* AVCODEC_H264_PS_H */ diff --git a/include/libavcodec/h264_sei.h b/include/libavcodec/h264_sei.h deleted file mode 100644 index bb9275e569..0000000000 --- a/include/libavcodec/h264_sei.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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_H264_SEI_H -#define AVCODEC_H264_SEI_H - -#include "get_bits.h" -#include "h2645_sei.h" -#include "h264_ps.h" -#include "sei.h" - - -/** - * pic_struct in picture timing SEI message - */ -typedef enum { - H264_SEI_PIC_STRUCT_FRAME = 0, ///< 0: %frame - H264_SEI_PIC_STRUCT_TOP_FIELD = 1, ///< 1: top field - H264_SEI_PIC_STRUCT_BOTTOM_FIELD = 2, ///< 2: bottom field - H264_SEI_PIC_STRUCT_TOP_BOTTOM = 3, ///< 3: top field, bottom field, in that order - H264_SEI_PIC_STRUCT_BOTTOM_TOP = 4, ///< 4: bottom field, top field, in that order - H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP = 5, ///< 5: top field, bottom field, top field repeated, in that order - H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM = 6, ///< 6: bottom field, top field, bottom field repeated, in that order - H264_SEI_PIC_STRUCT_FRAME_DOUBLING = 7, ///< 7: %frame doubling - H264_SEI_PIC_STRUCT_FRAME_TRIPLING = 8 ///< 8: %frame tripling -} H264_SEI_PicStructType; - -typedef struct H264SEITimeCode { - /* When not continuously receiving full timecodes, we have to reference - the previous timecode received */ - int full; - int frame; - int seconds; - int minutes; - int hours; - int dropframe; -} H264SEITimeCode; - -typedef struct H264SEIPictureTiming { - // maximum size of pic_timing according to the spec should be 274 bits - uint8_t payload[40]; - int payload_size_bytes; - - int present; - H264_SEI_PicStructType pic_struct; - - /** - * Bit set of clock types for fields/frames in picture timing SEI message. - * For each found ct_type, appropriate bit is set (e.g., bit 1 for - * interlaced). - */ - int ct_type; - - /** - * dpb_output_delay in picture timing SEI message, see H.264 C.2.2 - */ - int dpb_output_delay; - - /** - * cpb_removal_delay in picture timing SEI message, see H.264 C.1.2 - */ - int cpb_removal_delay; - - /** - * Maximum three timecodes in a pic_timing SEI. - */ - H264SEITimeCode timecode[3]; - - /** - * Number of timecode in use - */ - int timecode_cnt; -} H264SEIPictureTiming; - -typedef struct H264SEIRecoveryPoint { - /** - * recovery_frame_cnt - * - * Set to -1 if no recovery point SEI message found or to number of frames - * before playback synchronizes. Frames having recovery point are key - * frames. - */ - int recovery_frame_cnt; -} H264SEIRecoveryPoint; - -typedef struct H264SEIBufferingPeriod { - int present; ///< Buffering period SEI flag - int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs -} H264SEIBufferingPeriod; - -typedef struct H264SEIGreenMetaData { - uint8_t green_metadata_type; - uint8_t period_type; - uint16_t num_seconds; - uint16_t num_pictures; - uint8_t percent_non_zero_macroblocks; - uint8_t percent_intra_coded_macroblocks; - uint8_t percent_six_tap_filtering; - uint8_t percent_alpha_point_deblocking_instance; - uint8_t xsd_metric_type; - uint16_t xsd_metric_value; -} H264SEIGreenMetaData; - -typedef struct H264SEIContext { - H2645SEI common; - H264SEIPictureTiming picture_timing; - H264SEIRecoveryPoint recovery_point; - H264SEIBufferingPeriod buffering_period; - H264SEIGreenMetaData green_metadata; -} H264SEIContext; - -struct H264ParamSets; - -int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb, - const struct H264ParamSets *ps, void *logctx); - -static inline int ff_h264_sei_ctx_replace(H264SEIContext *dst, - const H264SEIContext *src) -{ - return ff_h2645_sei_ctx_replace(&dst->common, &src->common); -} - -/** - * Reset SEI values at the beginning of the frame. - */ -void ff_h264_sei_uninit(H264SEIContext *h); - -/** - * Get stereo_mode string from the h264 frame_packing_arrangement - */ -const char *ff_h264_sei_stereo_mode(const H2645SEIFramePacking *h); - -/** - * Parse the contents of a picture timing message given an active SPS. - */ -int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS *sps, - void *logctx); - -#endif /* AVCODEC_H264_SEI_H */ diff --git a/include/libavcodec/h264chroma.h b/include/libavcodec/h264chroma.h deleted file mode 100644 index 9c81c18a76..0000000000 --- a/include/libavcodec/h264chroma.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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_H264CHROMA_H -#define AVCODEC_H264CHROMA_H - -#include -#include - -typedef void (*h264_chroma_mc_func)(uint8_t *dst /*align 8*/, const uint8_t *src /*align 1*/, ptrdiff_t srcStride, int h, int x, int y); - -typedef struct H264ChromaContext { - h264_chroma_mc_func put_h264_chroma_pixels_tab[4]; - h264_chroma_mc_func avg_h264_chroma_pixels_tab[4]; -} H264ChromaContext; - -void ff_h264chroma_init(H264ChromaContext *c, int bit_depth); - -void ff_h264chroma_init_aarch64(H264ChromaContext *c, int bit_depth); -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); -void ff_h264chroma_init_riscv(H264ChromaContext *c, int bit_depth); - -#endif /* AVCODEC_H264CHROMA_H */ diff --git a/include/libavcodec/h264data.h b/include/libavcodec/h264data.h deleted file mode 100644 index f809886ae6..0000000000 --- a/include/libavcodec/h264data.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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_H264DATA_H -#define AVCODEC_H264DATA_H - -#include - -#include "libavutil/rational.h" -#include "h264.h" - -extern const uint8_t ff_h264_golomb_to_pict_type[5]; -extern const uint8_t ff_h264_golomb_to_intra4x4_cbp[48]; -extern const uint8_t ff_h264_golomb_to_inter_cbp[48]; - -extern const uint8_t ff_h264_chroma_dc_scan[4]; -extern const uint8_t ff_h264_chroma422_dc_scan[8]; - -typedef struct IMbInfo { - uint16_t type; - uint8_t pred_mode; - uint8_t cbp; -} IMbInfo; - -extern const IMbInfo ff_h264_i_mb_type_info[26]; - -typedef struct PMbInfo { - uint16_t type; - uint8_t partition_count; -} PMbInfo; - -extern const PMbInfo ff_h264_p_mb_type_info[5]; -extern const PMbInfo ff_h264_p_sub_mb_type_info[4]; -extern const PMbInfo ff_h264_b_mb_type_info[23]; -extern const PMbInfo ff_h264_b_sub_mb_type_info[13]; - -extern const uint8_t ff_h264_dequant4_coeff_init[6][3]; -extern const uint8_t ff_h264_dequant8_coeff_init_scan[16]; -extern const uint8_t ff_h264_dequant8_coeff_init[6][6]; -extern const uint8_t ff_h264_quant_rem6[QP_MAX_NUM + 1]; -extern const uint8_t ff_h264_quant_div6[QP_MAX_NUM + 1]; - -extern const uint8_t ff_h264_chroma_qp[7][QP_MAX_NUM + 1]; - -#endif /* AVCODEC_H264DATA_H */ diff --git a/include/libavcodec/h264dec.h b/include/libavcodec/h264dec.h deleted file mode 100644 index 447c2499d9..0000000000 --- a/include/libavcodec/h264dec.h +++ /dev/null @@ -1,702 +0,0 @@ -/* - * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder - * Copyright (c) 2003 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 - */ - -/** - * @file - * H.264 / AVC / MPEG-4 part10 codec. - * @author Michael Niedermayer - */ - -#ifndef AVCODEC_H264DEC_H -#define AVCODEC_H264DEC_H - -#include "libavutil/buffer.h" -#include "libavutil/mem_internal.h" - -#include "cabac.h" -#include "error_resilience.h" -#include "h264_parse.h" -#include "h264_ps.h" -#include "h264_sei.h" -#include "h2645_parse.h" -#include "h264chroma.h" -#include "h264dsp.h" -#include "h264pred.h" -#include "h264qpel.h" -#include "h274.h" -#include "mpegutils.h" -#include "threadframe.h" -#include "videodsp.h" - -#define H264_MAX_PICTURE_COUNT 36 - -/* Compiling in interlaced support reduces the speed - * of progressive decoding by about 2%. */ -#define ALLOW_INTERLACE - -#define FMO 0 - -/** - * The maximum number of slices supported by the decoder. - * must be a power of 2 - */ -#define MAX_SLICES 32 - -#ifdef ALLOW_INTERLACE -#define MB_MBAFF(h) (h)->mb_mbaff -#define MB_FIELD(sl) (sl)->mb_field_decoding_flag -#define FRAME_MBAFF(h) (h)->mb_aff_frame -#define FIELD_PICTURE(h) ((h)->picture_structure != PICT_FRAME) -#define LEFT_MBS 2 -#define LTOP 0 -#define LBOT 1 -#define LEFT(i) (i) -#else -#define MB_MBAFF(h) 0 -#define MB_FIELD(sl) 0 -#define FRAME_MBAFF(h) 0 -#define FIELD_PICTURE(h) 0 -#undef IS_INTERLACED -#define IS_INTERLACED(mb_type) 0 -#define LEFT_MBS 1 -#define LTOP 0 -#define LBOT 0 -#define LEFT(i) 0 -#endif -#define FIELD_OR_MBAFF_PICTURE(h) (FRAME_MBAFF(h) || FIELD_PICTURE(h)) - -#ifndef CABAC -#define CABAC(h) (h)->ps.pps->cabac -#endif - -#define CHROMA(h) ((h)->ps.sps->chroma_format_idc) -#define CHROMA422(h) ((h)->ps.sps->chroma_format_idc == 2) -#define CHROMA444(h) ((h)->ps.sps->chroma_format_idc == 3) - -#define IS_REF0(a) ((a) & MB_TYPE_REF0) -#define IS_8x8DCT(a) ((a) & MB_TYPE_8x8DCT) - -/** - * Memory management control operation. - */ -typedef struct MMCO { - MMCOOpcode opcode; - int short_pic_num; ///< pic_num without wrapping (pic_num & max_pic_num) - int long_arg; ///< index, pic_num, or num long refs depending on opcode -} MMCO; - -typedef struct H264Picture { - AVFrame *f; - ThreadFrame tf; - - AVFrame *f_grain; - - int8_t *qscale_table_base; ///< RefStruct reference - int8_t *qscale_table; - - int16_t (*motion_val_base[2])[2]; ///< RefStruct reference - int16_t (*motion_val[2])[2]; - - uint32_t *mb_type_base; ///< RefStruct reference - uint32_t *mb_type; - - /// RefStruct reference for hardware accelerator private data - void *hwaccel_picture_private; - - int8_t *ref_index[2]; ///< RefStruct reference - - int field_poc[2]; ///< top/bottom POC - int poc; ///< frame POC - int frame_num; ///< frame_num (raw frame_num from slice header) - int mmco_reset; /**< MMCO_RESET set this 1. Reordering code must - not mix pictures before and after MMCO_RESET. */ - int pic_id; /**< pic_num (short -> no wrap version of pic_num, - pic_num & max_pic_num; long -> long_pic_num) */ - int long_ref; ///< 1->long term reference 0->short term reference - int ref_poc[2][2][32]; ///< POCs of the frames/fields used as reference (FIXME need per slice) - int ref_count[2][2]; ///< number of entries in ref_poc (FIXME need per slice) - int mbaff; ///< 1 -> MBAFF frame 0-> not MBAFF - int field_picture; ///< whether or not picture was encoded in separate fields - -/** - * H264Picture.reference has this flag set, - * when the picture is held for delayed output. - */ -#define DELAYED_PIC_REF (1 << 2) - int reference; - int recovered; ///< picture at IDR or recovery point + recovery count - int invalid_gap; - int sei_recovery_frame_cnt; - int needs_fg; ///< whether picture needs film grain synthesis (see `f_grain`) - - const PPS *pps; - - int mb_width, mb_height; - int mb_stride; - - /// RefStruct reference; its pointee is shared between decoding threads. - atomic_int *decode_error_flags; - - int gray; -} H264Picture; - -typedef struct H264Ref { - uint8_t *data[3]; - int linesize[3]; - - int reference; - int poc; - int pic_id; - - const H264Picture *parent; -} H264Ref; - -typedef struct H264SliceContext { - const struct H264Context *h264; - GetBitContext gb; - ERContext *er; - - int slice_num; - int slice_type; - int slice_type_nos; ///< S free slice type (SI/SP are remapped to I/P) - int slice_type_fixed; - - int qscale; - int chroma_qp[2]; // QPc - int qp_thresh; ///< QP threshold to skip loopfilter - int last_qscale_diff; - - // deblock - int deblocking_filter; ///< disable_deblocking_filter_idc with 1 <-> 0 - int slice_alpha_c0_offset; - int slice_beta_offset; - - H264PredWeightTable pwt; - - int prev_mb_skipped; - int next_mb_skipped; - - int chroma_pred_mode; - int intra16x16_pred_mode; - - int8_t intra4x4_pred_mode_cache[5 * 8]; - int8_t(*intra4x4_pred_mode); - - int topleft_mb_xy; - int top_mb_xy; - int topright_mb_xy; - int left_mb_xy[LEFT_MBS]; - - int topleft_type; - int top_type; - int topright_type; - int left_type[LEFT_MBS]; - - const uint8_t *left_block; - int topleft_partition; - - unsigned int topleft_samples_available; - unsigned int top_samples_available; - unsigned int topright_samples_available; - unsigned int left_samples_available; - - ptrdiff_t linesize, uvlinesize; - ptrdiff_t mb_linesize; ///< may be equal to s->linesize or s->linesize * 2, for mbaff - ptrdiff_t mb_uvlinesize; - - int mb_x, mb_y; - int mb_xy; - int resync_mb_x; - int resync_mb_y; - unsigned int first_mb_addr; - // index of the first MB of the next slice - int next_slice_idx; - int mb_skip_run; - int is_complex; - - int picture_structure; - int mb_field_decoding_flag; - int mb_mbaff; ///< mb_aff_frame && mb_field_decoding_flag - - int redundant_pic_count; - - /** - * number of neighbors (top and/or left) that used 8x8 dct - */ - int neighbor_transform_size; - - int direct_spatial_mv_pred; - int col_parity; - int col_fieldoff; - - int cbp; - int top_cbp; - int left_cbp; - - int dist_scale_factor[32]; - int dist_scale_factor_field[2][32]; - int map_col_to_list0[2][16 + 32]; - int map_col_to_list0_field[2][2][16 + 32]; - - /** - * num_ref_idx_l0/1_active_minus1 + 1 - */ - unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode - unsigned int list_count; - H264Ref ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs. - * Reordered version of default_ref_list - * according to picture reordering in slice header */ - struct { - uint8_t op; - uint32_t val; - } ref_modifications[2][32]; - int nb_ref_modifications[2]; - - unsigned int pps_id; - - const uint8_t *intra_pcm_ptr; - - uint8_t *bipred_scratchpad; - uint8_t *edge_emu_buffer; - uint8_t (*top_borders[2])[(16 * 3) * 2]; - int bipred_scratchpad_allocated; - int edge_emu_buffer_allocated; - int top_borders_allocated[2]; - - /** - * non zero coeff count cache. - * is 64 if not available. - */ - DECLARE_ALIGNED(8, uint8_t, non_zero_count_cache)[15 * 8]; - - /** - * Motion vector cache. - */ - DECLARE_ALIGNED(16, int16_t, mv_cache)[2][5 * 8][2]; - DECLARE_ALIGNED(8, int8_t, ref_cache)[2][5 * 8]; - DECLARE_ALIGNED(16, uint8_t, mvd_cache)[2][5 * 8][2]; - uint8_t direct_cache[5 * 8]; - - DECLARE_ALIGNED(8, uint16_t, sub_mb_type)[4]; - - ///< as a DCT coefficient is int32_t in high depth, we need to reserve twice the space. - DECLARE_ALIGNED(16, int16_t, mb)[16 * 48 * 2]; - DECLARE_ALIGNED(16, int16_t, mb_luma_dc)[3][16 * 2]; - ///< as mb is addressed by scantable[i] and scantable is uint8_t we can either - ///< check that i is not too large or ensure that there is some unused stuff after mb - int16_t mb_padding[256 * 2]; - - uint8_t (*mvd_table[2])[2]; - - /** - * Cabac - */ - CABACContext cabac; - uint8_t cabac_state[1024]; - int cabac_init_idc; - - MMCO mmco[H264_MAX_MMCO_COUNT]; - int nb_mmco; - int explicit_ref_marking; - - int frame_num; - int idr_pic_id; - int poc_lsb; - int delta_poc_bottom; - int delta_poc[2]; - int curr_pic_num; - int max_pic_num; -} H264SliceContext; - -/** - * H264Context - */ -typedef struct H264Context { - const AVClass *class; - AVCodecContext *avctx; - VideoDSPContext vdsp; - H264DSPContext h264dsp; - H264ChromaContext h264chroma; - H264QpelContext h264qpel; - H274FilmGrainDatabase h274db; - - H264Picture DPB[H264_MAX_PICTURE_COUNT]; - H264Picture *cur_pic_ptr; - H264Picture cur_pic; - H264Picture last_pic_for_ec; - - H264SliceContext *slice_ctx; - int nb_slice_ctx; - int nb_slice_ctx_queued; - - H2645Packet pkt; - - int pixel_shift; ///< 0 for 8-bit H.264, 1 for high-bit-depth H.264 - - /* coded dimensions -- 16 * mb w/h */ - int width, height; - int chroma_x_shift, chroma_y_shift; - - int droppable; - int coded_picture_number; - - int context_initialized; - int flags; - int workaround_bugs; - int x264_build; - /* Set when slice threading is used and at least one slice uses deblocking - * mode 1 (i.e. across slice boundaries). Then we disable the loop filter - * during normal MB decoding and execute it serially at the end. - */ - int postpone_filter; - - /* - * Set to 1 when the current picture is IDR, 0 otherwise. - */ - int picture_idr; - - /* - * Set to 1 when the current picture contains only I slices, 0 otherwise. - */ - int picture_intra_only; - - int crop_left; - int crop_right; - int crop_top; - int crop_bottom; - - int8_t(*intra4x4_pred_mode); - H264PredContext hpc; - - uint8_t (*non_zero_count)[48]; - -#define LIST_NOT_USED -1 // FIXME rename? - - /** - * block_offset[ 0..23] for frame macroblocks - * block_offset[24..47] for field macroblocks - */ - int block_offset[2 * (16 * 3)]; - - uint32_t *mb2b_xy; // FIXME are these 4 a good idea? - uint32_t *mb2br_xy; - int b_stride; // FIXME use s->b4_stride - - uint16_t *slice_table; ///< slice_table_base + 2*mb_stride + 1 - - // interlacing specific flags - int mb_aff_frame; - int picture_structure; - int first_field; - - uint8_t *list_counts; ///< Array of list_count per MB specifying the slice type - - /* 0x100 -> non null luma_dc, 0x80/0x40 -> non null chroma_dc (cb/cr), 0x?0 -> chroma_cbp(0, 1, 2), 0x0? luma_cbp */ - uint16_t *cbp_table; - - /* chroma_pred_mode for i4x4 or i16x16, else 0 */ - uint8_t *chroma_pred_mode_table; - uint8_t (*mvd_table[2])[2]; - uint8_t *direct_table; - - uint8_t scan_padding[16]; - uint8_t zigzag_scan[16]; - uint8_t zigzag_scan8x8[64]; - uint8_t zigzag_scan8x8_cavlc[64]; - uint8_t field_scan[16]; - uint8_t field_scan8x8[64]; - uint8_t field_scan8x8_cavlc[64]; - uint8_t zigzag_scan_q0[16]; - uint8_t zigzag_scan8x8_q0[64]; - uint8_t zigzag_scan8x8_cavlc_q0[64]; - uint8_t field_scan_q0[16]; - uint8_t field_scan8x8_q0[64]; - uint8_t field_scan8x8_cavlc_q0[64]; - - int mb_y; - int mb_height, mb_width; - int mb_stride; - int mb_num; - - // ============================================================= - // Things below are not used in the MB or more inner code - - int nal_ref_idc; - int nal_unit_type; - - int has_slice; ///< slice NAL is found in the packet, set by decode_nal_units, its state does not need to be preserved outside h264_decode_frame() - - /** - * Used to parse AVC variant of H.264 - */ - int is_avc; ///< this flag is != 0 if codec is avc1 - int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4) - - int bit_depth_luma; ///< luma bit depth from sps to detect changes - int chroma_format_idc; ///< chroma format from sps to detect changes - - H264ParamSets ps; - - uint16_t *slice_table_base; - - H264POCContext poc; - - H264Ref default_ref[2]; - H264Picture *short_ref[32]; - H264Picture *long_ref[32]; - H264Picture *delayed_pic[H264_MAX_DPB_FRAMES + 2]; // FIXME size? - int last_pocs[H264_MAX_DPB_FRAMES]; - H264Picture *next_output_pic; - int next_outputed_poc; - int poc_offset; ///< PicOrderCnt_offset from SMPTE RDD-2006 - - /** - * memory management control operations buffer. - */ - MMCO mmco[H264_MAX_MMCO_COUNT]; - int nb_mmco; - int mmco_reset; - int explicit_ref_marking; - - int long_ref_count; ///< number of actual long term references - int short_ref_count; ///< number of actual short term references - - /** - * @name Members for slice based multithreading - * @{ - */ - /** - * current slice number, used to initialize slice_num of each thread/context - */ - int current_slice; - - /** @} */ - - /** - * Complement sei_pic_struct - * SEI_PIC_STRUCT_TOP_BOTTOM and SEI_PIC_STRUCT_BOTTOM_TOP indicate interlaced frames. - * However, soft telecined frames may have these values. - * This is used in an attempt to flag soft telecine progressive. - */ - int prev_interlaced_frame; - - /** - * Are the SEI recovery points looking valid. - */ - int valid_recovery_point; - - /** - * recovery_frame is the frame_num at which the next frame should - * be fully constructed. - * - * Set to -1 when not expecting a recovery point. - */ - int recovery_frame; - -/** - * We have seen an IDR, so all the following frames in coded order are correctly - * decodable. - */ -#define FRAME_RECOVERED_IDR (1 << 0) -/** - * Sufficient number of frames have been decoded since a SEI recovery point, - * so all the following frames in presentation order are correct. - */ -#define FRAME_RECOVERED_SEI (1 << 1) -/** - * Recovery point detected by heuristic - */ -#define FRAME_RECOVERED_HEURISTIC (1 << 2) - - /** - * Initial frame has been completely recovered. - * - * Once this is set, all following decoded as well as displayed frames will be marked as recovered - * If a frame is marked as recovered frame_recovered will be set once this frame is output and thus - * all subsequently output fraames are also marked as recovered - * - * In effect, if you want all subsequent DECODED frames marked as recovered, set frame_recovered - * If you want all subsequent DISPAYED frames marked as recovered, set the frame->recovered - */ - int frame_recovered; - - int has_recovery_point; - - int missing_fields; - - /* for frame threading, this is set to 1 - * after finish_setup() has been called, so we cannot modify - * some context properties (which are supposed to stay constant between - * slices) anymore */ - int setup_finished; - - int cur_chroma_format_idc; - int cur_bit_depth_luma; - int16_t slice_row[MAX_SLICES]; ///< to detect when MAX_SLICES is too low - - /* original AVCodecContext dimensions, used to handle container - * cropping */ - int width_from_caller; - int height_from_caller; - - int enable_er; - ERContext er; - int16_t *dc_val_base; - - H264SEIContext sei; - - struct FFRefStructPool *qscale_table_pool; - struct FFRefStructPool *mb_type_pool; - struct FFRefStructPool *motion_val_pool; - struct FFRefStructPool *ref_index_pool; - struct FFRefStructPool *decode_error_flags_pool; - int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1 - - int non_gray; ///< Did we encounter a intra frame after a gray gap frame - int noref_gray; - int skip_gray; -} H264Context; - -extern const uint16_t ff_h264_mb_sizes[4]; - -/** - * Reconstruct bitstream slice_type. - */ -int ff_h264_get_slice_type(const H264SliceContext *sl); - -/** - * Allocate tables. - * needs width/height - */ -int ff_h264_alloc_tables(H264Context *h); - -int ff_h264_decode_ref_pic_list_reordering(H264SliceContext *sl, void *logctx); -int ff_h264_build_ref_list(H264Context *h, H264SliceContext *sl); -void ff_h264_remove_all_refs(H264Context *h); - -/** - * Execute the reference picture marking (memory management control operations). - */ -int ff_h264_execute_ref_pic_marking(H264Context *h); - -int ff_h264_decode_ref_pic_marking(H264SliceContext *sl, GetBitContext *gb, - const H2645NAL *nal, void *logctx); - -void ff_h264_hl_decode_mb(const H264Context *h, H264SliceContext *sl); -void ff_h264_decode_init_vlc(void); - -/** - * Decode a macroblock - * @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR on error - */ -int ff_h264_decode_mb_cavlc(const H264Context *h, H264SliceContext *sl); - -/** - * Decode a CABAC coded macroblock - * @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR on error - */ -int ff_h264_decode_mb_cabac(const H264Context *h, H264SliceContext *sl); - -void ff_h264_init_cabac_states(const H264Context *h, H264SliceContext *sl); - -void ff_h264_direct_dist_scale_factor(const H264Context *const h, H264SliceContext *sl); -void ff_h264_direct_ref_list_init(const H264Context *const h, H264SliceContext *sl); -void ff_h264_pred_direct_motion(const H264Context *const h, H264SliceContext *sl, - int *mb_type); - -void ff_h264_filter_mb_fast(const H264Context *h, H264SliceContext *sl, int mb_x, int mb_y, - uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, - unsigned int linesize, unsigned int uvlinesize); -void ff_h264_filter_mb(const H264Context *h, H264SliceContext *sl, int mb_x, int mb_y, - uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, - unsigned int linesize, unsigned int uvlinesize); - -/* - * o-o o-o - * / / / - * o-o o-o - * ,---' - * o-o o-o - * / / / - * o-o o-o - */ - -/* Scan8 organization: - * 0 1 2 3 4 5 6 7 - * 0 DY y y y y y - * 1 y Y Y Y Y - * 2 y Y Y Y Y - * 3 y Y Y Y Y - * 4 y Y Y Y Y - * 5 DU u u u u u - * 6 u U U U U - * 7 u U U U U - * 8 u U U U U - * 9 u U U U U - * 10 DV v v v v v - * 11 v V V V V - * 12 v V V V V - * 13 v V V V V - * 14 v V V V V - * DY/DU/DV are for luma/chroma DC. - */ - -#define LUMA_DC_BLOCK_INDEX 48 -#define CHROMA_DC_BLOCK_INDEX 49 - -/** - * Get the chroma qp. - */ -static av_always_inline int get_chroma_qp(const PPS *pps, int t, int qscale) -{ - return pps->chroma_qp_table[t][qscale]; -} - -int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup); - -int ff_h264_ref_picture(H264Picture *dst, const H264Picture *src); -int ff_h264_replace_picture(H264Picture *dst, const H264Picture *src); -void ff_h264_unref_picture(H264Picture *pic); - -void ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl); - -void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl, int y, int height); - -/** - * Submit a slice for decoding. - * - * Parse the slice header, starting a new field/frame if necessary. If any - * slices are queued for the previous field, they are decoded. - */ -int ff_h264_queue_decode_slice(H264Context *h, const H2645NAL *nal); -int ff_h264_execute_decode_slices(H264Context *h); -int ff_h264_update_thread_context(AVCodecContext *dst, - const AVCodecContext *src); -int ff_h264_update_thread_context_for_user(AVCodecContext *dst, - const AVCodecContext *src); - -void ff_h264_flush_change(H264Context *h); - -void ff_h264_free_tables(H264Context *h); - -void ff_h264_set_erpic(ERPicture *dst, const H264Picture *src); - -#endif /* AVCODEC_H264DEC_H */ diff --git a/include/libavcodec/h264dsp.h b/include/libavcodec/h264dsp.h deleted file mode 100644 index e0880c4d88..0000000000 --- a/include/libavcodec/h264dsp.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2003-2010 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 - */ - -/** - * @file - * H.264 DSP functions. - * @author Michael Niedermayer - */ - -#ifndef AVCODEC_H264DSP_H -#define AVCODEC_H264DSP_H - -#include -#include - -typedef void (*h264_weight_func)(uint8_t *block, ptrdiff_t stride, int height, - int log2_denom, int weight, int offset); -typedef void (*h264_biweight_func)(uint8_t *dst, uint8_t *src, - ptrdiff_t stride, int height, int log2_denom, - int weightd, int weights, int offset); - -/** - * Context for storing H.264 DSP functions - */ -typedef struct H264DSPContext { - /* weighted MC */ - h264_weight_func weight_h264_pixels_tab[4]; - h264_biweight_func biweight_h264_pixels_tab[4]; - - /* loop filter */ - void (*h264_v_loop_filter_luma)(uint8_t *pix /*align 16*/, ptrdiff_t stride, - int alpha, int beta, int8_t *tc0); - void (*h264_h_loop_filter_luma)(uint8_t *pix /*align 4 */, ptrdiff_t stride, - int alpha, int beta, int8_t *tc0); - void (*h264_h_loop_filter_luma_mbaff)(uint8_t *pix /*align 16*/, ptrdiff_t stride, - int alpha, int beta, int8_t *tc0); - /* v/h_loop_filter_luma_intra: align 16 */ - void (*h264_v_loop_filter_luma_intra)(uint8_t *pix, ptrdiff_t stride, - int alpha, int beta); - void (*h264_h_loop_filter_luma_intra)(uint8_t *pix, ptrdiff_t stride, - int alpha, int beta); - void (*h264_h_loop_filter_luma_mbaff_intra)(uint8_t *pix /*align 16*/, - ptrdiff_t stride, int alpha, int beta); - void (*h264_v_loop_filter_chroma)(uint8_t *pix /*align 8*/, ptrdiff_t stride, - int alpha, int beta, int8_t *tc0); - void (*h264_h_loop_filter_chroma)(uint8_t *pix /*align 4*/, ptrdiff_t stride, - int alpha, int beta, int8_t *tc0); - void (*h264_h_loop_filter_chroma_mbaff)(uint8_t *pix /*align 8*/, - ptrdiff_t stride, int alpha, int beta, - int8_t *tc0); - void (*h264_v_loop_filter_chroma_intra)(uint8_t *pix /*align 8*/, - ptrdiff_t stride, int alpha, int beta); - void (*h264_h_loop_filter_chroma_intra)(uint8_t *pix /*align 8*/, - ptrdiff_t stride, int alpha, int beta); - void (*h264_h_loop_filter_chroma_mbaff_intra)(uint8_t *pix /*align 8*/, - ptrdiff_t stride, int alpha, int beta); - // h264_loop_filter_strength: simd only. the C version is inlined in h264_loopfilter.c - void (*h264_loop_filter_strength)(int16_t bS[2][4][4], uint8_t nnz[40], - int8_t ref[2][40], int16_t mv[2][40][2], - int bidir, int edges, int step, - int mask_mv0, int mask_mv1, int field); - - /* IDCT */ - void (*h264_idct_add)(uint8_t *dst /*align 4*/, - int16_t *block /*align 16*/, int stride); - void (*h264_idct8_add)(uint8_t *dst /*align 8*/, - int16_t *block /*align 16*/, int stride); - void (*h264_idct_dc_add)(uint8_t *dst /*align 4*/, - int16_t *block /*align 16*/, int stride); - void (*h264_idct8_dc_add)(uint8_t *dst /*align 8*/, - int16_t *block /*align 16*/, int stride); - - void (*h264_idct_add16)(uint8_t *dst /*align 16*/, const int *blockoffset, - int16_t *block /*align 16*/, int stride, - 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[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[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); - - /* bypass-transform */ - void (*h264_add_pixels8_clear)(uint8_t *dst, int16_t *block, int stride); - void (*h264_add_pixels4_clear)(uint8_t *dst, int16_t *block, int stride); - - /** - * Search buf from the start for up to size bytes. Return the index - * of a zero byte, or >= size if not found. Ideally, use lookahead - * to filter out any zero bytes that are known to not be followed by - * one or more further zero bytes and a one byte. Better still, filter - * out any bytes that form the trailing_zero_8bits syntax element too. - */ - int (*startcode_find_candidate)(const uint8_t *buf, int size); -} H264DSPContext; - -void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, - const int chroma_format_idc); -void ff_h264dsp_init_aarch64(H264DSPContext *c, const int bit_depth, - const int chroma_format_idc); -void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth, - const int chroma_format_idc); -void ff_h264dsp_init_ppc(H264DSPContext *c, const int bit_depth, - const int chroma_format_idc); -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/include/libavcodec/h264idct.h b/include/libavcodec/h264idct.h deleted file mode 100644 index 6f18df9e5f..0000000000 --- a/include/libavcodec/h264idct.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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_H264IDCT_H -#define AVCODEC_H264IDCT_H - -#include - -#define H264_IDCT(depth) \ -void ff_h264_idct8_add_ ## depth ## _c(uint8_t *dst, int16_t *block, int stride);\ -void ff_h264_idct_add_ ## depth ## _c(uint8_t *dst, int16_t *block, int stride);\ -void ff_h264_idct8_dc_add_ ## depth ## _c(uint8_t *dst, int16_t *block, int stride);\ -void ff_h264_idct_dc_add_ ## depth ## _c(uint8_t *dst, int16_t *block, int stride);\ -void ff_h264_idct_add16_ ## depth ## _c(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[5 * 8]);\ -void ff_h264_idct_add16intra_ ## depth ## _c(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[5 * 8]);\ -void ff_h264_idct8_add4_ ## depth ## _c(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[5 * 8]);\ -void ff_h264_idct_add8_422_ ## depth ## _c(uint8_t **dest, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[15 * 8]);\ -void ff_h264_idct_add8_ ## depth ## _c(uint8_t **dest, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[15 * 8]);\ -void ff_h264_luma_dc_dequant_idct_ ## depth ## _c(int16_t *output, int16_t *input, int qmul);\ -void ff_h264_chroma422_dc_dequant_idct_ ## depth ## _c(int16_t *block, int qmul);\ -void ff_h264_chroma_dc_dequant_idct_ ## depth ## _c(int16_t *block, int qmul); - -H264_IDCT( 8) -H264_IDCT( 9) -H264_IDCT(10) -H264_IDCT(12) -H264_IDCT(14) - -#endif /* AVCODEC_H264IDCT_H */ diff --git a/include/libavcodec/h264pred.h b/include/libavcodec/h264pred.h deleted file mode 100644 index cb008548fc..0000000000 --- a/include/libavcodec/h264pred.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder - * Copyright (c) 2003 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 - */ - -/** - * @file - * H.264 / AVC / MPEG-4 prediction functions. - * @author Michael Niedermayer - */ - -#ifndef AVCODEC_H264PRED_H -#define AVCODEC_H264PRED_H - -#include -#include - -/** - * Prediction types - */ -//@{ -#define VERT_PRED 0 -#define HOR_PRED 1 -#define DC_PRED 2 -#define DIAG_DOWN_LEFT_PRED 3 -#define DIAG_DOWN_RIGHT_PRED 4 -#define VERT_RIGHT_PRED 5 -#define HOR_DOWN_PRED 6 -#define VERT_LEFT_PRED 7 -#define HOR_UP_PRED 8 - -// DC edge (not for VP8) -#define LEFT_DC_PRED 9 -#define TOP_DC_PRED 10 -#define DC_128_PRED 11 - -// RV40 specific -#define DIAG_DOWN_LEFT_PRED_RV40_NODOWN 12 -#define HOR_UP_PRED_RV40_NODOWN 13 -#define VERT_LEFT_PRED_RV40_NODOWN 14 - -// VP8 specific -#define TM_VP8_PRED 9 ///< "True Motion", used instead of plane -#define VERT_VP8_PRED 10 ///< for VP8, #VERT_PRED is the average of - ///< (left col+cur col x2+right col) / 4; - ///< this is the "unaveraged" one -#define HOR_VP8_PRED 14 ///< unaveraged version of #HOR_PRED, see - ///< #VERT_VP8_PRED for details -#define DC_127_PRED 12 -#define DC_129_PRED 13 - -#define DC_PRED8x8 0 -#define HOR_PRED8x8 1 -#define VERT_PRED8x8 2 -#define PLANE_PRED8x8 3 - -// DC edge -#define LEFT_DC_PRED8x8 4 -#define TOP_DC_PRED8x8 5 -#define DC_128_PRED8x8 6 - -// H.264/SVQ3 (8x8) specific -#define ALZHEIMER_DC_L0T_PRED8x8 7 -#define ALZHEIMER_DC_0LT_PRED8x8 8 -#define ALZHEIMER_DC_L00_PRED8x8 9 -#define ALZHEIMER_DC_0L0_PRED8x8 10 - -// VP8 specific -#define DC_127_PRED8x8 7 -#define DC_129_PRED8x8 8 -//@} - -#define PART_NOT_AVAILABLE -2 - -/** - * Context for storing H.264 prediction functions - */ -typedef struct H264PredContext { - void(*pred4x4[9 + 3 + 3])(uint8_t *src, const uint8_t *topright, - ptrdiff_t stride); - void(*pred8x8l[9 + 3])(uint8_t *src, int topleft, int topright, - ptrdiff_t stride); - void(*pred8x8[4 + 3 + 4])(uint8_t *src, ptrdiff_t stride); - void(*pred16x16[4 + 3 + 2])(uint8_t *src, ptrdiff_t stride); - - void(*pred4x4_add[2])(uint8_t *pix /*align 4*/, - int16_t *block /*align 16*/, ptrdiff_t stride); - void(*pred8x8l_add[2])(uint8_t *pix /*align 8*/, - int16_t *block /*align 16*/, ptrdiff_t stride); - void(*pred8x8l_filter_add[2])(uint8_t *pix /*align 8*/, - int16_t *block /*align 16*/, int topleft, int topright, ptrdiff_t stride); - void(*pred8x8_add[3])(uint8_t *pix /*align 8*/, - const int *block_offset, - int16_t *block /*align 16*/, ptrdiff_t stride); - void(*pred16x16_add[3])(uint8_t *pix /*align 16*/, - const int *block_offset, - int16_t *block /*align 16*/, ptrdiff_t stride); -} H264PredContext; - -void ff_h264_pred_init(H264PredContext *h, int codec_id, - const int bit_depth, const int chroma_format_idc); -void ff_h264_pred_init_aarch64(H264PredContext *h, int codec_id, - const int bit_depth, - const int chroma_format_idc); -void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, - const int bit_depth, const int chroma_format_idc); -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/include/libavcodec/h264qpel.h b/include/libavcodec/h264qpel.h deleted file mode 100644 index 0259e8de23..0000000000 --- a/include/libavcodec/h264qpel.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder - * Copyright (c) 2003-2010 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 - */ - -#ifndef AVCODEC_H264QPEL_H -#define AVCODEC_H264QPEL_H - -#include "qpeldsp.h" - -typedef struct H264QpelContext { - qpel_mc_func put_h264_qpel_pixels_tab[4][16]; - qpel_mc_func avg_h264_qpel_pixels_tab[4][16]; -} H264QpelContext; - -void ff_h264qpel_init(H264QpelContext *c, int bit_depth); - -void ff_h264qpel_init_aarch64(H264QpelContext *c, int bit_depth); -void ff_h264qpel_init_arm(H264QpelContext *c, int bit_depth); -void ff_h264qpel_init_ppc(H264QpelContext *c, int bit_depth); -void ff_h264qpel_init_x86(H264QpelContext *c, int bit_depth); -void ff_h264qpel_init_mips(H264QpelContext *c, int bit_depth); -void ff_h264qpel_init_loongarch(H264QpelContext *c, int bit_depth); - -#endif /* AVCODEC_H264QPEL_H */ diff --git a/include/libavcodec/me_cmp.h b/include/libavcodec/me_cmp.h deleted file mode 100644 index fee0ecb28e..0000000000 --- a/include/libavcodec/me_cmp.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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_ME_CMP_H -#define AVCODEC_ME_CMP_H - -#include - -#include "libavutil/attributes_internal.h" - -#include "avcodec.h" - -extern const uint32_t attribute_visibility_hidden ff_square_tab[512]; - - -/* minimum alignment rules ;) - * If you notice errors in the align stuff, need more alignment for some ASM code - * for some CPU or need to use a function with less aligned data then send a mail - * to the ffmpeg-devel mailing list, ... - * - * !warning These alignments might not match reality, (missing attribute((align)) - * stuff somewhere possible). - * I (Michael) did not check them, these are just the alignments which I think - * could be reached easily ... - * - * !future video codecs might need functions with less strict alignment - */ - -struct MpegEncContext; -/* Motion estimation: - * h is limited to { width / 2, width, 2 * width }, - * but never larger than 16 and never smaller than 2. - * Although currently h < 4 is not used as functions with - * width < 8 are neither used nor implemented. */ -typedef int (*me_cmp_func)(struct MpegEncContext *c, - const uint8_t *blk1 /* align width (8 or 16) */, - const uint8_t *blk2 /* align 1 */, ptrdiff_t stride, - int h); - -typedef struct MECmpContext { - int (*sum_abs_dctelem)(const int16_t *block /* align 16 */); - - me_cmp_func sad[6]; /* identical to pix_absAxA except additional void * */ - me_cmp_func sse[6]; - me_cmp_func hadamard8_diff[6]; - me_cmp_func dct_sad[6]; - me_cmp_func quant_psnr[6]; - me_cmp_func bit[6]; - me_cmp_func rd[6]; - me_cmp_func vsad[6]; - me_cmp_func vsse[6]; - me_cmp_func nsse[6]; - me_cmp_func w53[6]; - me_cmp_func w97[6]; - me_cmp_func dct_max[6]; - me_cmp_func dct264_sad[6]; - - me_cmp_func me_pre_cmp[6]; - me_cmp_func me_cmp[6]; - me_cmp_func me_sub_cmp[6]; - me_cmp_func mb_cmp[6]; - me_cmp_func ildct_cmp[6]; // only width 16 used - me_cmp_func frame_skip_cmp[6]; // only width 8 used - - me_cmp_func pix_abs[2][4]; - me_cmp_func median_sad[6]; -} MECmpContext; - -void ff_me_cmp_init(MECmpContext *c, AVCodecContext *avctx); -void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx); -void ff_me_cmp_init_alpha(MECmpContext *c, AVCodecContext *avctx); -void ff_me_cmp_init_arm(MECmpContext *c, AVCodecContext *avctx); -void ff_me_cmp_init_ppc(MECmpContext *c, AVCodecContext *avctx); -void ff_me_cmp_init_riscv(MECmpContext *c, AVCodecContext *avctx); -void ff_me_cmp_init_x86(MECmpContext *c, AVCodecContext *avctx); -void ff_me_cmp_init_mips(MECmpContext *c, AVCodecContext *avctx); - -int ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type); - -void ff_dsputil_init_dwt(MECmpContext *c); - -#endif /* AVCODEC_ME_CMP_H */ diff --git a/include/libavcodec/packet.h b/include/libavcodec/packet.h index 0a28010542..59bfddf4cc 100644 --- a/include/libavcodec/packet.h +++ b/include/libavcodec/packet.h @@ -142,7 +142,7 @@ enum AVPacketSideDataType { AV_PKT_DATA_CPB_PROPERTIES, /** - * Recommmends skipping the specified number of samples + * Recommends skipping the specified number of samples * @code * u32le number of samples to skip from start of this packet * u32le number of samples to skip from end of this packet @@ -345,6 +345,29 @@ enum AVPacketSideDataType { */ AV_PKT_DATA_LCEVC, + /** + * This side data contains information about the reference display width(s) + * and reference viewing distance(s) as well as information about the + * corresponding reference stereo pair(s), i.e., the pair(s) of views to be + * displayed for the viewer's left and right eyes on the reference display + * at the reference viewing distance. + * The payload is the AV3DReferenceDisplaysInfo struct defined in + * libavutil/tdrdi.h. + */ + AV_PKT_DATA_3D_REFERENCE_DISPLAYS, + + /** + * Contains the last received RTCP SR (Sender Report) information + * in the form of the AVRTCPSenderReport struct. + */ + AV_PKT_DATA_RTCP_SR, + + /** + * Extensible image file format metadata. The payload is a buffer containing + * EXIF metadata, starting with either 49 49 2a 00, or 4d 4d 00 2a. + */ + AV_PKT_DATA_EXIF, + /** * The number of side data types. * This is not part of the public API/ABI in the sense that it may @@ -356,10 +379,6 @@ enum AVPacketSideDataType { AV_PKT_DATA_NB }; -#if FF_API_QUALITY_FACTOR -#define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED -#endif - /** * This structure stores auxiliary information for decoding, presenting, or * otherwise processing the coded stream. It is typically exported by demuxers @@ -368,11 +387,11 @@ enum AVPacketSideDataType { * * Global side data is handled as follows: * - During demuxing, it may be exported through - * @ref AVStream.codecpar.side_data "AVStream's codec parameters", which can + * @ref AVCodecParameters.coded_side_data "AVStream's codec parameters", which can * then be passed as input to decoders through the * @ref AVCodecContext.coded_side_data "decoder context's side data", for * initialization. - * - For muxing, it can be fed through @ref AVStream.codecpar.side_data + * - For muxing, it can be fed through @ref AVCodecParameters.coded_side_data * "AVStream's codec parameters", typically the output of encoders through * the @ref AVCodecContext.coded_side_data "encoder context's side data", for * initialization. @@ -470,6 +489,36 @@ void av_packet_side_data_remove(AVPacketSideData *sd, int *nb_sd, */ void av_packet_side_data_free(AVPacketSideData **sd, int *nb_sd); +struct AVFrameSideData; + +/** + * Add a new packet side data entry to an array based on existing frame + * side data, if a matching type exists for packet side data. + * + * @param flags Currently unused. Must be 0. + * @retval >= 0 Success + * @retval AVERROR(EINVAL) The frame side data type does not have a matching + * packet side data type. + * @retval AVERROR(ENOMEM) Failed to add a side data entry to the array, or + * similar. + */ +int av_packet_side_data_from_frame(AVPacketSideData **sd, int *nb_sd, + const struct AVFrameSideData *src, unsigned int flags); +/** + * Add a new frame side data entry to an array based on existing packet + * side data, if a matching type exists for frame side data. + * + * @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, + * or 0. + * @retval >= 0 Success + * @retval AVERROR(EINVAL) The packet side data type does not have a matching + * frame side data type. + * @retval AVERROR(ENOMEM) Failed to add a side data entry to the array, or + * similar. + */ +int av_packet_side_data_to_frame(struct AVFrameSideData ***sd, int *nb_sd, + const AVPacketSideData *src, unsigned int flags); + const char *av_packet_side_data_name(enum AVPacketSideDataType type); /** @@ -880,6 +929,13 @@ int av_packet_make_writable(AVPacket *pkt); */ void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst); +/** + * Allocate an AVContainerFifo instance for AVPacket. + * + * @param flags currently unused + */ +struct AVContainerFifo *av_container_fifo_alloc_avpacket(unsigned flags); + /** * @} */ diff --git a/include/libavcodec/smpte_436m.h b/include/libavcodec/smpte_436m.h new file mode 100644 index 0000000000..9c0e2a5a05 --- /dev/null +++ b/include/libavcodec/smpte_436m.h @@ -0,0 +1,254 @@ +/* + * MXF SMPTE-436M VBI/ANC parsing functions + * Copyright (c) 2025 Jacob Lifshay + * + * 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_SMPTE_436M_H +#define AVCODEC_SMPTE_436M_H + +#include + +/** + * Iterator over the ANC packets in a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data + */ +typedef struct AVSmpte436mAncIterator { + uint16_t anc_packets_left; + int size_left; + const uint8_t *data_left; +} AVSmpte436mAncIterator; + +/** + * Wrapping Type from Table 7 (page 13) of: + * https://pub.smpte.org/latest/st436/s436m-2006.pdf + */ +typedef enum AVSmpte436mWrappingType +{ + AV_SMPTE_436M_WRAPPING_TYPE_VANC_FRAME = 1, + AV_SMPTE_436M_WRAPPING_TYPE_VANC_FIELD_1 = 2, + AV_SMPTE_436M_WRAPPING_TYPE_VANC_FIELD_2 = 3, + AV_SMPTE_436M_WRAPPING_TYPE_VANC_PROGRESSIVE_FRAME = 4, + AV_SMPTE_436M_WRAPPING_TYPE_HANC_FRAME = 0x11, + AV_SMPTE_436M_WRAPPING_TYPE_HANC_FIELD_1 = 0x12, + AV_SMPTE_436M_WRAPPING_TYPE_HANC_FIELD_2 = 0x13, + AV_SMPTE_436M_WRAPPING_TYPE_HANC_PROGRESSIVE_FRAME = 0x14, + /** not a real wrapping type, just here to guarantee the enum is big enough */ + AV_SMPTE_436M_WRAPPING_TYPE_MAX = 0xFF, +} AVSmpte436mWrappingType; + +/** + * Payload Sample Coding from Table 4 (page 10) and Table 7 (page 13) of: + * https://pub.smpte.org/latest/st436/s436m-2006.pdf + */ +typedef enum AVSmpte436mPayloadSampleCoding +{ + /** only used for VBI */ + AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_1BIT_LUMA = 1, + /** only used for VBI */ + AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_1BIT_COLOR_DIFF = 2, + /** only used for VBI */ + AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_1BIT_LUMA_AND_COLOR_DIFF = 3, + /** used for VBI and ANC */ + AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA = 4, + /** used for VBI and ANC */ + AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_COLOR_DIFF = 5, + /** used for VBI and ANC */ + AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA_AND_COLOR_DIFF = 6, + /** used for VBI and ANC */ + AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_10BIT_LUMA = 7, + /** used for VBI and ANC */ + AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_10BIT_COLOR_DIFF = 8, + /** used for VBI and ANC */ + AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_10BIT_LUMA_AND_COLOR_DIFF = 9, + /** only used for ANC */ + AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA_WITH_PARITY_ERROR = 10, + /** only used for ANC */ + AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_COLOR_DIFF_WITH_PARITY_ERROR = 11, + /** only used for ANC */ + AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_8BIT_LUMA_AND_COLOR_DIFF_WITH_PARITY_ERROR = 12, + /** not a real sample coding, just here to guarantee the enum is big enough */ + AV_SMPTE_436M_PAYLOAD_SAMPLE_CODING_MAX = 0xFF, +} AVSmpte436mPayloadSampleCoding; + +/** the payload capacity of AVSmpte291mAnc8bit (and of AVSmpte291mAnc10bit when that gets added) */ +#define AV_SMPTE_291M_ANC_PAYLOAD_CAPACITY 0xFF + +/** + * An ANC packet with an 8-bit payload. + * This can be decoded from AVSmpte436mCodedAnc::payload. + * + * Note: Some ANC packets need a 10-bit payload, if stored in this struct, + * the most-significant 2 bits of each sample are discarded. + */ +typedef struct AVSmpte291mAnc8bit { + uint8_t did; + uint8_t sdid_or_dbn; + uint8_t data_count; + uint8_t payload[AV_SMPTE_291M_ANC_PAYLOAD_CAPACITY]; + uint8_t checksum; +} AVSmpte291mAnc8bit; + +/** max number of samples that can be stored in the payload of AVSmpte436mCodedAnc */ +#define AV_SMPTE_436M_CODED_ANC_SAMPLE_CAPACITY \ + (AV_SMPTE_291M_ANC_PAYLOAD_CAPACITY + 4) /* 4 for did, sdid_or_dbn, data_count, and checksum */ +/** max number of bytes that can be stored in the payload of AVSmpte436mCodedAnc */ +#define AV_SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY (((AV_SMPTE_436M_CODED_ANC_SAMPLE_CAPACITY + 2) / 3) * 4) + +/** + * An encoded ANC packet within a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data. + * The repeated section of Table 7 (page 13) of: + * https://pub.smpte.org/latest/st436/s436m-2006.pdf + */ +typedef struct AVSmpte436mCodedAnc { + uint16_t line_number; + AVSmpte436mWrappingType wrapping_type; + AVSmpte436mPayloadSampleCoding payload_sample_coding; + uint16_t payload_sample_count; + uint32_t payload_array_length; + /** the payload, has size payload_array_length. + * can be decoded into AVSmpte291mAnc8bit + */ + uint8_t payload[AV_SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY]; +} AVSmpte436mCodedAnc; + +/** + * Validate a AVSmpte436mCodedAnc structure. Doesn't check if the payload is valid. + * @param[in] anc ANC packet to validate + * @return 0 on success, AVERROR codes otherwise. + */ +int av_smpte_436m_coded_anc_validate(const AVSmpte436mCodedAnc *anc); + +/** + * Encode ANC packets into a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data. + * @param[in] anc_packet_count number of ANC packets to encode + * @param[in] anc_packets the ANC packets to encode + * @param[in] size the size of out. ignored if out is NULL. + * @param[out] out Output bytes. Doesn't write anything if out is NULL. + * @return the number of bytes written on success, AVERROR codes otherwise. + * If out is NULL, returns the number of bytes it would have written. + */ +int av_smpte_436m_anc_encode(uint8_t *out, int size, int anc_packet_count, const AVSmpte436mCodedAnc *anc_packets); + +struct AVPacket; + +/** + * Append more ANC packets to a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data. + * @param[in] anc_packet_count number of ANC packets to encode + * @param[in] anc_packets the ANC packets to encode + * @param pkt the AVPacket to append to. + * it must either be size 0 or contain valid SMPTE_436M_ANC data. + * @return 0 on success, AVERROR codes otherwise. + */ +int av_smpte_436m_anc_append(struct AVPacket *pkt, int anc_packet_count, const AVSmpte436mCodedAnc *anc_packets); + +/** + * Set up iteration over the ANC packets in a single AV_CODEC_ID_SMPTE_436M_ANC AVPacket's data. + * @param[in] buf Pointer to the data from a AV_CODEC_ID_SMPTE_436M_ANC AVPacket. + * @param[in] buf_size Size of the data from a AV_CODEC_ID_SMPTE_436M_ANC AVPacket. + * @param[out] iter Pointer to the iterator. + * @return 0 on success, AVERROR codes otherwise. + */ +int av_smpte_436m_anc_iter_init(AVSmpte436mAncIterator *iter, const uint8_t *buf, int buf_size); + +/** + * Get the next ANC packet from the iterator, advancing the iterator. + * @param[in,out] iter Pointer to the iterator. + * @param[out] anc The returned ANC packet. + * @return 0 on success, AVERROR_EOF when the iterator has reached the end, AVERROR codes otherwise. + */ +int av_smpte_436m_anc_iter_next(AVSmpte436mAncIterator *iter, AVSmpte436mCodedAnc *anc); + +/** + * Get the minimum number of bytes needed to store a AVSmpte436mCodedAnc payload. + * @param sample_coding the payload sample coding + * @param sample_count the number of samples stored in the payload + * @return returns the minimum number of bytes needed, on error returns < 0. + * always <= SMPTE_436M_CODED_ANC_PAYLOAD_CAPACITY + */ +int av_smpte_436m_coded_anc_payload_size(AVSmpte436mPayloadSampleCoding sample_coding, uint16_t sample_count); + +/** + * Decode a AVSmpte436mCodedAnc payload into AVSmpte291mAnc8bit + * @param[in] sample_coding the payload sample coding + * @param[in] sample_count the number of samples stored in the payload + * @param[in] payload the bytes storing the payload, + * the needed size can be obtained from + avpriv_smpte_436m_coded_anc_payload_size + * @param[in] log_ctx context pointer for av_log + * @param[out] out The decoded ANC packet. + * @return returns 0 on success, otherwise < 0. + */ +int av_smpte_291m_anc_8bit_decode(AVSmpte291mAnc8bit *out, + AVSmpte436mPayloadSampleCoding sample_coding, + uint16_t sample_count, + const uint8_t *payload, + void *log_ctx); + +/** + * Fill in the correct checksum for a AVSmpte291mAnc8bit + * @param[in,out] anc The ANC packet. + */ +void av_smpte_291m_anc_8bit_fill_checksum(AVSmpte291mAnc8bit *anc); + +/** + * Compute the sample count needed to encode a AVSmpte291mAnc8bit into a AVSmpte436mCodedAnc payload + * @param[in] anc The ANC packet. + * @param[in] sample_coding The sample coding. + * @param[in] log_ctx context pointer for av_log + * @return returns the sample count on success, otherwise < 0. + */ +int av_smpte_291m_anc_8bit_get_sample_count(const AVSmpte291mAnc8bit *anc, + AVSmpte436mPayloadSampleCoding sample_coding, + void *log_ctx); + +/** + * Encode a AVSmpte291mAnc8bit into a AVSmpte436mCodedAnc + * @param[in] line_number the line number the ANC packet is on + * @param[in] wrapping_type the wrapping type + * @param[in] sample_coding the payload sample coding + * @param[in] payload the ANC packet to encode. + * @param[in] log_ctx context pointer for av_log + * @param[out] out The encoded ANC packet. + * @return returns 0 on success, otherwise < 0. + */ +int av_smpte_291m_anc_8bit_encode(AVSmpte436mCodedAnc *out, + uint16_t line_number, + AVSmpte436mWrappingType wrapping_type, + AVSmpte436mPayloadSampleCoding sample_coding, + const AVSmpte291mAnc8bit *payload, + void *log_ctx); + +/** AVSmpte291mAnc8bit::did when carrying CTA-708 data (for AV_CODEC_ID_EIA_608) */ +#define AV_SMPTE_291M_ANC_DID_CTA_708 0x61 + +/** AVSmpte291mAnc8bit::sdid_or_dbn when carrying CTA-708 data (for AV_CODEC_ID_EIA_608) */ +#define AV_SMPTE_291M_ANC_SDID_CTA_708 0x1 + +/** + * Try to decode an ANC packet into EIA-608/CTA-708 data (AV_CODEC_ID_EIA_608). This + * @param[in] anc The ANC packet. + * @param[in] log_ctx Context pointer for av_log + * @param[out] cc_data the buffer to store the extracted EIA-608/CTA-708 data, + * you can pass NULL to not store the data. + * the required size is 3 * cc_count bytes. + * SMPTE_291M_ANC_PAYLOAD_CAPACITY is always enough size. + * @return returns cc_count (>= 0) on success, AVERROR(EAGAIN) if it wasn't a CTA-708 ANC packet, < 0 on error. + */ +int av_smpte_291m_anc_8bit_extract_cta_708(const AVSmpte291mAnc8bit *anc, uint8_t *cc_data, void *log_ctx); + +#endif /* AVCODEC_SMPTE_436M_H */ diff --git a/include/libavcodec/vdpau.h b/include/libavcodec/vdpau.h index 8021c25761..da77c5daed 100755 --- a/include/libavcodec/vdpau.h +++ b/include/libavcodec/vdpau.h @@ -93,28 +93,6 @@ typedef struct AVVDPAUContext { AVVDPAU_Render2 render2; } AVVDPAUContext; -#if FF_API_VDPAU_ALLOC_GET_SET -/** - * @brief allocation function for AVVDPAUContext - * - * Allows extending the struct without breaking API/ABI - * @deprecated use av_vdpau_bind_context() instead - */ -attribute_deprecated -AVVDPAUContext *av_alloc_vdpaucontext(void); - -/** - * @deprecated render2 is public and can be accessed directly - */ -attribute_deprecated -AVVDPAU_Render2 av_vdpau_hwaccel_get_render2(const AVVDPAUContext *); -/** - * @deprecated render2 is public and can be accessed directly - */ -attribute_deprecated -void av_vdpau_hwaccel_set_render2(AVVDPAUContext *, AVVDPAU_Render2); -#endif - /** * Associate a VDPAU device with a codec context for hardware acceleration. * This function is meant to be called from the get_format() codec callback, @@ -155,17 +133,6 @@ int av_vdpau_bind_context(AVCodecContext *avctx, VdpDevice device, int av_vdpau_get_surface_parameters(AVCodecContext *avctx, VdpChromaType *type, uint32_t *width, uint32_t *height); -#if FF_API_VDPAU_ALLOC_GET_SET -/** - * Allocate an AVVDPAUContext. - * - * @return Newly-allocated AVVDPAUContext or NULL on failure. - * @deprecated use av_vdpau_bind_context() instead - */ -attribute_deprecated -AVVDPAUContext *av_vdpau_alloc_context(void); -#endif - /** @} */ #endif /* AVCODEC_VDPAU_H */ diff --git a/include/libavcodec/version.h b/include/libavcodec/version.h index b6ca025fae..b564e2d849 100755 --- a/include/libavcodec/version.h +++ b/include/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 19 +#define LIBAVCODEC_VERSION_MINOR 28 #define LIBAVCODEC_VERSION_MICRO 101 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ diff --git a/include/libavcodec/version_major.h b/include/libavcodec/version_major.h index 63df40e9dd..6c652374dd 100644 --- a/include/libavcodec/version_major.h +++ b/include/libavcodec/version_major.h @@ -25,7 +25,7 @@ * Libavcodec version macros. */ -#define LIBAVCODEC_VERSION_MAJOR 61 +#define LIBAVCODEC_VERSION_MAJOR 62 /** * FF_API_* defines may be placed below to indicate public API that will be @@ -37,16 +37,23 @@ * at once through the bump. This improves the git bisect-ability of the change. */ -#define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 62) -#define FF_API_SUBFRAMES (LIBAVCODEC_VERSION_MAJOR < 62) -#define FF_API_TICKS_PER_FRAME (LIBAVCODEC_VERSION_MAJOR < 62) -#define FF_API_DROPCHANGED (LIBAVCODEC_VERSION_MAJOR < 62) - -#define FF_API_AVFFT (LIBAVCODEC_VERSION_MAJOR < 62) -#define FF_API_FF_PROFILE_LEVEL (LIBAVCODEC_VERSION_MAJOR < 62) -#define FF_API_AVCODEC_CLOSE (LIBAVCODEC_VERSION_MAJOR < 62) -#define FF_API_BUFFER_MIN_SIZE (LIBAVCODEC_VERSION_MAJOR < 62) -#define FF_API_VDPAU_ALLOC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 62) -#define FF_API_QUALITY_FACTOR (LIBAVCODEC_VERSION_MAJOR < 62) +#define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 63) + +#define FF_API_V408_CODECID (LIBAVCODEC_VERSION_MAJOR < 63) +#define FF_API_CODEC_PROPS (LIBAVCODEC_VERSION_MAJOR < 63) +#define FF_API_EXR_GAMMA (LIBAVCODEC_VERSION_MAJOR < 63) +#define FF_API_INTRA_DC_PRECISION (LIBAVCODEC_VERSION_MAJOR < 63) + +#define FF_API_NVDEC_OLD_PIX_FMTS (LIBAVCODEC_VERSION_MAJOR < 63) + +#define FF_API_PARSER_PRIVATE (LIBAVCODEC_VERSION_MAJOR < 63) +#define FF_API_PARSER_CODECID (LIBAVCODEC_VERSION_MAJOR < 63) + +// reminder to remove the OMX encoder on next major bump +#define FF_CODEC_OMX (LIBAVCODEC_VERSION_MAJOR < 63) +// reminder to remove Sonic Lossy/Lossless encoders on next major bump +#define FF_CODEC_SONIC_ENC (LIBAVCODEC_VERSION_MAJOR < 63) +// reminder to remove Sonic decoder on next-next major bump +#define FF_CODEC_SONIC_DEC (LIBAVCODEC_VERSION_MAJOR < 63) #endif /* AVCODEC_VERSION_MAJOR_H */ diff --git a/include/libavdevice/avdevice.h b/include/libavdevice/avdevice.h index 887fd5e3c8..10ffaf4c5f 100644 --- a/include/libavdevice/avdevice.h +++ b/include/libavdevice/avdevice.h @@ -372,7 +372,7 @@ void avdevice_free_list_devices(AVDeviceInfoList **device_list); * List devices. * * Returns available device names and their parameters. - * These are convinient wrappers for avdevice_list_devices(). + * These are convenient wrappers for avdevice_list_devices(). * Device context is allocated and deallocated internally. * * @param device device format. May be NULL if device name is set. diff --git a/include/libavdevice/version.h b/include/libavdevice/version.h index 7608a8602c..6db29e7d40 100644 --- a/include/libavdevice/version.h +++ b/include/libavdevice/version.h @@ -30,7 +30,7 @@ #include "version_major.h" #define LIBAVDEVICE_VERSION_MINOR 3 -#define LIBAVDEVICE_VERSION_MICRO 100 +#define LIBAVDEVICE_VERSION_MICRO 101 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ LIBAVDEVICE_VERSION_MINOR, \ diff --git a/include/libavdevice/version_major.h b/include/libavdevice/version_major.h index f16abb6909..191511cdcc 100644 --- a/include/libavdevice/version_major.h +++ b/include/libavdevice/version_major.h @@ -25,7 +25,7 @@ * Libavdevice version macros */ -#define LIBAVDEVICE_VERSION_MAJOR 61 +#define LIBAVDEVICE_VERSION_MAJOR 62 /** * FF_API_* defines may be placed below to indicate public API that will be @@ -33,11 +33,6 @@ * the public API and may change, break or disappear at any time. */ -// reminder to remove the bktr device on next major bump -#define FF_API_BKTR_DEVICE (LIBAVDEVICE_VERSION_MAJOR < 62) -// reminder to remove the opengl device on next major bump -#define FF_API_OPENGL_DEVICE (LIBAVDEVICE_VERSION_MAJOR < 62) -// reminder to remove the sdl2 device on next major bump -#define FF_API_SDL2_DEVICE (LIBAVDEVICE_VERSION_MAJOR < 62) +#define FF_API_ALSA_CHANNELS (LIBAVDEVICE_VERSION_MAJOR < 63) #endif /* AVDEVICE_VERSION_MAJOR_H */ diff --git a/include/libavfilter/avfilter.h b/include/libavfilter/avfilter.h index 1401577c50..02b58c42c2 100644 --- a/include/libavfilter/avfilter.h +++ b/include/libavfilter/avfilter.h @@ -43,7 +43,6 @@ #include "libavutil/dict.h" #include "libavutil/frame.h" #include "libavutil/log.h" -#include "libavutil/samplefmt.h" #include "libavutil/pixfmt.h" #include "libavutil/rational.h" @@ -70,7 +69,6 @@ const char *avfilter_configuration(void); */ const char *avfilter_license(void); -typedef struct AVFilterContext AVFilterContext; typedef struct AVFilterLink AVFilterLink; typedef struct AVFilterPad AVFilterPad; typedef struct AVFilterFormats AVFilterFormats; @@ -98,6 +96,18 @@ const char *avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx); */ enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx); +/** + * Get the hardware frames context of a filter link. + * + * @param link an AVFilterLink + * + * @return a ref-counted copy of the link's hw_frames_ctx field if there is + * a hardware frames context associated with the link or NULL otherwise. + * The returned AVBufferRef needs to be released with av_buffer_unref() + * when it is no longer used. + */ +AVBufferRef* avfilter_link_get_hw_frames_ctx(AVFilterLink *link); + /** * Lists of formats / etc. supported by an end of a link. * @@ -131,6 +141,11 @@ typedef struct AVFilterFormatsConfig { AVFilterFormats *color_spaces; ///< AVColorSpace AVFilterFormats *color_ranges; ///< AVColorRange + /** + * List of supported alpha modes, only for video with an alpha channel. + */ + AVFilterFormats *alpha_modes; ///< AVAlphaMode + } AVFilterFormatsConfig; /** @@ -243,204 +258,6 @@ typedef struct AVFilter { * A combination of AVFILTER_FLAG_* */ int flags; - - /***************************************************************** - * All fields below this line are not part of the public API. They - * may not be used outside of libavfilter and can be changed and - * removed at will. - * New public fields should be added right above. - ***************************************************************** - */ - - /** - * The number of entries in the list of inputs. - */ - uint8_t nb_inputs; - - /** - * The number of entries in the list of outputs. - */ - uint8_t nb_outputs; - - /** - * This field determines the state of the formats union. - * It is an enum FilterFormatsState value. - */ - uint8_t formats_state; - - /** - * Filter pre-initialization function - * - * This callback will be called immediately after the filter context is - * allocated, to allow allocating and initing sub-objects. - * - * If this callback is not NULL, the uninit callback will be called on - * allocation failure. - * - * @return 0 on success, - * AVERROR code on failure (but the code will be - * dropped and treated as ENOMEM by the calling code) - */ - int (*preinit)(AVFilterContext *ctx); - - /** - * Filter initialization function. - * - * This callback will be called only once during the filter lifetime, after - * all the options have been set, but before links between filters are - * established and format negotiation is done. - * - * Basic filter initialization should be done here. Filters with dynamic - * inputs and/or outputs should create those inputs/outputs here based on - * provided options. No more changes to this filter's inputs/outputs can be - * done after this callback. - * - * This callback must not assume that the filter links exist or frame - * parameters are known. - * - * @ref AVFilter.uninit "uninit" is guaranteed to be called even if - * initialization fails, so this callback does not have to clean up on - * failure. - * - * @return 0 on success, a negative AVERROR on failure - */ - int (*init)(AVFilterContext *ctx); - - /** - * Filter uninitialization function. - * - * Called only once right before the filter is freed. Should deallocate any - * memory held by the filter, release any buffer references, etc. It does - * not need to deallocate the AVFilterContext.priv memory itself. - * - * This callback may be called even if @ref AVFilter.init "init" was not - * called or failed, so it must be prepared to handle such a situation. - */ - void (*uninit)(AVFilterContext *ctx); - - /** - * The state of the following union is determined by formats_state. - * See the documentation of enum FilterFormatsState in internal.h. - */ - union { - /** - * Query formats supported by the filter on its inputs and outputs. - * - * This callback is called after the filter is initialized (so the inputs - * and outputs are fixed), shortly before the format negotiation. This - * callback may be called more than once. - * - * This callback must set ::AVFilterLink's - * @ref AVFilterFormatsConfig.formats "outcfg.formats" - * on every input link and - * @ref AVFilterFormatsConfig.formats "incfg.formats" - * on every output link to a list of pixel/sample formats that the filter - * supports on that link. - * For video links, this filter may also set - * @ref AVFilterFormatsConfig.color_spaces "incfg.color_spaces" - * / - * @ref AVFilterFormatsConfig.color_spaces "outcfg.color_spaces" - * and @ref AVFilterFormatsConfig.color_ranges "incfg.color_ranges" - * / - * @ref AVFilterFormatsConfig.color_ranges "outcfg.color_ranges" - * analogously. - * For audio links, this filter must also set - * @ref AVFilterFormatsConfig.samplerates "incfg.samplerates" - * / - * @ref AVFilterFormatsConfig.samplerates "outcfg.samplerates" - * and @ref AVFilterFormatsConfig.channel_layouts "incfg.channel_layouts" - * / - * @ref AVFilterFormatsConfig.channel_layouts "outcfg.channel_layouts" - * analogously. - * - * This callback must never be NULL if the union is in this state. - * - * @return zero on success, a negative value corresponding to an - * AVERROR code otherwise - */ - int (*query_func)(AVFilterContext *); - - /** - * Same as query_func(), except this function writes the results into - * provided arrays. - * - * @param cfg_in array of input format configurations with as many - * members as the filters has inputs (NULL when there are - * no inputs); - * @param cfg_out array of output format configurations with as many - * members as the filters has outputs (NULL when there - * are no outputs); - */ - int (*query_func2)(const AVFilterContext *, - struct AVFilterFormatsConfig **cfg_in, - struct AVFilterFormatsConfig **cfg_out); - /** - * A pointer to an array of admissible pixel formats delimited - * by AV_PIX_FMT_NONE. The generic code will use this list - * to indicate that this filter supports each of these pixel formats, - * provided that all inputs and outputs use the same pixel format. - * - * In addition to that the generic code will mark all inputs - * and all outputs as supporting all color spaces and ranges, as - * long as all inputs and outputs use the same color space/range. - * - * This list must never be NULL if the union is in this state. - * The type of all inputs and outputs of filters using this must - * be AVMEDIA_TYPE_VIDEO. - */ - const enum AVPixelFormat *pixels_list; - /** - * Analogous to pixels, but delimited by AV_SAMPLE_FMT_NONE - * and restricted to filters that only have AVMEDIA_TYPE_AUDIO - * inputs and outputs. - * - * In addition to that the generic code will mark all inputs - * and all outputs as supporting all sample rates and every - * channel count and channel layout, as long as all inputs - * and outputs use the same sample rate and channel count/layout. - */ - const enum AVSampleFormat *samples_list; - /** - * Equivalent to { pix_fmt, AV_PIX_FMT_NONE } as pixels_list. - */ - enum AVPixelFormat pix_fmt; - /** - * Equivalent to { sample_fmt, AV_SAMPLE_FMT_NONE } as samples_list. - */ - enum AVSampleFormat sample_fmt; - } formats; - - int priv_size; ///< size of private data to allocate for the filter - - int flags_internal; ///< Additional flags for avfilter internal use only. - - /** - * Make the filter instance process a command. - * - * @param cmd the command to process, for handling simplicity all commands must be alphanumeric only - * @param arg the argument for the command - * @param res a buffer with size res_size where the filter(s) can return a response. This must not change when the command is not supported. - * @param flags if AVFILTER_CMD_FLAG_FAST is set and the command would be - * time consuming then a filter should treat it like an unsupported command - * - * @returns >=0 on success otherwise an error code. - * AVERROR(ENOSYS) on unsupported commands - */ - int (*process_command)(AVFilterContext *, const char *cmd, const char *arg, char *res, int res_len, int flags); - - /** - * Filter activation function. - * - * Called when any processing is needed from the filter, instead of any - * filter_frame and request_frame on pads. - * - * The function must examine inlinks and outlinks and perform a single - * step of processing. If there is nothing to do, the function must do - * nothing and not return an error. If more steps are or may be - * possible, it must use ff_filter_set_ready() to schedule another - * activation. - */ - int (*activate)(AVFilterContext *ctx); } AVFilter; /** @@ -454,7 +271,7 @@ unsigned avfilter_filter_pad_count(const AVFilter *filter, int is_output); #define AVFILTER_THREAD_SLICE (1 << 0) /** An instance of a filter */ -struct AVFilterContext { +typedef struct AVFilterContext { const AVClass *av_class; ///< needed for av_log() and filters common options const AVFilter *filter; ///< the AVFilter of which this is an instance @@ -498,12 +315,32 @@ struct AVFilterContext { */ int nb_threads; +#if FF_API_CONTEXT_PUBLIC + /** + * @deprecated unused + */ + attribute_deprecated struct AVFilterCommand *command_queue; +#endif char *enable_str; ///< enable expression string - void *enable; ///< parsed expression (AVExpr*) - double *var_values; ///< variable values for the enable expression - int is_disabled; ///< the enabled state from the last expression evaluation +#if FF_API_CONTEXT_PUBLIC + /** + * @deprecated unused + */ + attribute_deprecated + void *enable; + /** + * @deprecated unused + */ + double *var_values; +#endif + /** + * MUST NOT be accessed from outside avfilter. + * + * the enabled state from the last expression evaluation + */ + int is_disabled; /** * For filters which will create hardware frames, sets the device the @@ -518,12 +355,13 @@ struct AVFilterContext { */ AVBufferRef *hw_device_ctx; +#if FF_API_CONTEXT_PUBLIC /** - * Ready status of the filter. - * A non-0 value means that the filter needs activating; - * a higher value suggests a more urgent activation. + * @deprecated this field should never have been accessed by callers */ + attribute_deprecated unsigned ready; +#endif /** * Sets the number of extra hardware frames which the filter will @@ -540,7 +378,7 @@ struct AVFilterContext { * configured. */ int extra_hw_frames; -}; +} AVFilterContext; /** * A link between two filters. This contains pointers to the source and @@ -592,6 +430,11 @@ struct AVFilterLink { */ AVRational time_base; + AVFrameSideData **side_data; + int nb_side_data; + + enum AVAlphaMode alpha_mode; ///< alpha mode (for videos with an alpha channel) + /***************************************************************** * All fields below this line are not part of the public API. They * may not be used outside of libavfilter and can be changed and @@ -623,20 +466,6 @@ struct AVFilterLink { int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad); -#if FF_API_LINK_PUBLIC -/** - * @deprecated this function should never be called by users - */ -attribute_deprecated -void avfilter_link_free(AVFilterLink **link); - -/** - * @deprecated this function should never be called by users - */ -attribute_deprecated -int avfilter_config_links(AVFilterContext *filter); -#endif - #define AVFILTER_CMD_FLAG_ONE 1 ///< Stop once a filter understood the command (for target=all for example), fast filters are favored automatically #define AVFILTER_CMD_FLAG_FAST 2 ///< Only execute command when its fast (like a video out that supports contrast adjustment in hw) @@ -807,6 +636,14 @@ typedef struct AVFilterGraph { avfilter_execute_func *execute; char *aresample_swr_opts; ///< swr options to use for the auto-inserted aresample filters, Access ONLY through AVOptions + + /** + * Sets the maximum number of buffered frames in the filtergraph combined. + * + * Zero means no limit. This field must be set before calling + * avfilter_graph_config(). + */ + unsigned max_buffered_frames; } AVFilterGraph; /** @@ -845,9 +682,9 @@ AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph, AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, const char *name); /** - * Create and add a filter instance into an existing graph. - * The filter instance is created from the filter filt and inited - * with the parameter args. opaque is currently ignored. + * A convenience wrapper that allocates and initializes a filter in a single + * step. The filter instance is created from the filter filt and inited with the + * parameter args. opaque is currently ignored. * * In case of success put in *filt_ctx the pointer to the created * filter instance, otherwise set *filt_ctx to NULL. @@ -856,6 +693,12 @@ AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, const char *nam * @param graph_ctx the filter graph * @return a negative AVERROR error code in case of failure, a non * negative value otherwise + * + * @warning Since the filter is initialized after this function successfully + * returns, you MUST NOT set any further options on it. If you need to + * do that, call ::avfilter_graph_alloc_filter(), followed by setting + * the options, followed by ::avfilter_init_dict() instead of this + * function. */ int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *filt, const char *name, const char *args, void *opaque, @@ -1062,7 +905,7 @@ typedef struct AVFilterParams { char *instance_name; /** - * Options to be apllied to the filter. + * Options to be applied to the filter. * * Filled by avfilter_graph_segment_parse(). Afterwards may be freely * modified by the caller. @@ -1245,7 +1088,7 @@ int avfilter_graph_segment_init(AVFilterGraphSegment *seg, int flags); * Unlabeled outputs are * - linked to the first unlinked unlabeled input in the next non-disabled * filter in the chain, if one exists - * - exported in the ouputs linked list otherwise, with NULL label + * - exported in the outputs linked list otherwise, with NULL label * * Similarly, unlinked input pads are exported in the inputs linked list. * diff --git a/include/libavfilter/buffersink.h b/include/libavfilter/buffersink.h index 361d603679..4e658a9795 100644 --- a/include/libavfilter/buffersink.h +++ b/include/libavfilter/buffersink.h @@ -48,26 +48,21 @@ * - av_buffersink_get_channels(), * - av_buffersink_get_ch_layout(), * - av_buffersink_get_sample_rate(). + * - av_buffersink_get_side_data(). * * The layout returned by av_buffersink_get_ch_layout() must de uninitialized * by the caller. * * The format can be constrained by setting options, using av_opt_set() and * related functions with the AV_OPT_SEARCH_CHILDREN flag. - * - pix_fmts (int list), - * - color_spaces (int list), - * - color_ranges (int list), - * - sample_fmts (int list), - * - sample_rates (int list), - * - ch_layouts (string), - * - channel_counts (int list), - * - all_channel_counts (bool). - * Most of these options are of type binary, and should be set using - * av_opt_set_int_list() or av_opt_set_bin(). If they are not set, all - * corresponding formats are accepted. - * - * As a special case, if ch_layouts is not set, all valid channel layouts are - * accepted except for UNSPEC layouts, unless all_channel_counts is set. + * - pixel_formats (array of pixel formats), + * - colorspaces (array of int), + * - colorranges (array of int), + * - alphamodes (array of int), + * - sample_formats (array of sample formats), + * - samplerates (array of int), + * - channel_layouts (array of channel layouts) + * If an option is not set, all corresponding formats are accepted. */ /** @@ -121,6 +116,7 @@ int av_buffersink_get_h (const AVFilterContext *c AVRational av_buffersink_get_sample_aspect_ratio (const AVFilterContext *ctx); enum AVColorSpace av_buffersink_get_colorspace (const AVFilterContext *ctx); enum AVColorRange av_buffersink_get_color_range (const AVFilterContext *ctx); +enum AVAlphaMode av_buffersink_get_alpha_mode (const AVFilterContext *ctx); int av_buffersink_get_channels (const AVFilterContext *ctx); int av_buffersink_get_ch_layout (const AVFilterContext *ctx, @@ -129,6 +125,9 @@ int av_buffersink_get_sample_rate (const AVFilterContext *c AVBufferRef * av_buffersink_get_hw_frames_ctx (const AVFilterContext *ctx); +const AVFrameSideData *const *av_buffersink_get_side_data(const AVFilterContext *ctx, + int *nb_side_data); + /** @} */ /** diff --git a/include/libavfilter/buffersrc.h b/include/libavfilter/buffersrc.h index 6f3344f445..c7225b6752 100644 --- a/include/libavfilter/buffersrc.h +++ b/include/libavfilter/buffersrc.h @@ -120,6 +120,14 @@ typedef struct AVBufferSrcParameters { */ enum AVColorSpace color_space; enum AVColorRange color_range; + + AVFrameSideData **side_data; + int nb_side_data; + + /** + * Video only, the alpha mode. + */ + enum AVAlphaMode alpha_mode; } AVBufferSrcParameters; /** @@ -208,6 +216,14 @@ int av_buffersrc_add_frame_flags(AVFilterContext *buffer_src, */ int av_buffersrc_close(AVFilterContext *ctx, int64_t pts, unsigned flags); +/** + * Returns 0 or a negative AVERROR code. Currently, this will only ever + * return AVERROR(EOF), to indicate that the buffer source has been closed, + * either as a result of av_buffersrc_close(), or because the downstream + * filter is no longer accepting new data. + */ +int av_buffersrc_get_status(AVFilterContext *ctx); + /** * @} */ diff --git a/include/libavfilter/version.h b/include/libavfilter/version.h index 4d8f28e512..83931e11dd 100644 --- a/include/libavfilter/version.h +++ b/include/libavfilter/version.h @@ -31,8 +31,8 @@ #include "version_major.h" -#define LIBAVFILTER_VERSION_MINOR 4 -#define LIBAVFILTER_VERSION_MICRO 100 +#define LIBAVFILTER_VERSION_MINOR 14 +#define LIBAVFILTER_VERSION_MICRO 101 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/include/libavfilter/version_major.h b/include/libavfilter/version_major.h index c5e660eeda..539d5caa3d 100644 --- a/include/libavfilter/version_major.h +++ b/include/libavfilter/version_major.h @@ -27,7 +27,7 @@ * Libavfilter version macros */ -#define LIBAVFILTER_VERSION_MAJOR 10 +#define LIBAVFILTER_VERSION_MAJOR 11 /** * FF_API_* defines may be placed below to indicate public API that will be @@ -35,6 +35,8 @@ * the public API and may change, break or disappear at any time. */ -#define FF_API_LINK_PUBLIC (LIBAVFILTER_VERSION_MAJOR < 11) +#define FF_API_BUFFERSINK_OPTS (LIBAVFILTER_VERSION_MAJOR < 12) +#define FF_API_CONTEXT_PUBLIC (LIBAVFILTER_VERSION_MAJOR < 12) +#define FF_API_LIBNPP_SUPPORT (LIBAVFILTER_VERSION_MAJOR < 12) #endif /* AVFILTER_VERSION_MAJOR_H */ diff --git a/include/libavformat/avformat.h b/include/libavformat/avformat.h index 75221d9d1a..6e9953cbb6 100755 --- a/include/libavformat/avformat.h +++ b/include/libavformat/avformat.h @@ -146,8 +146,8 @@ * consumed). The calling program can handle such unrecognized options as it * wishes, e.g. * @code - * AVDictionaryEntry *e; - * if (e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX)) { + * const AVDictionaryEntry *e; + * if ((e = av_dict_iterate(options, NULL))) { * fprintf(stderr, "Option %s not recognized by the demuxer.\n", e->key); * abort(); * } @@ -459,7 +459,7 @@ typedef struct AVProbeData { #define AVPROBE_SCORE_STREAM_RETRY (AVPROBE_SCORE_MAX/4-1) #define AVPROBE_SCORE_EXTENSION 50 ///< score for file extension -#define AVPROBE_SCORE_MIME 75 ///< score for file mime type +#define AVPROBE_SCORE_MIME_BONUS 30 ///< score added for matching mime type #define AVPROBE_SCORE_MAX 100 ///< maximum score #define AVPROBE_PADDING_SIZE 32 ///< extra allocated bytes at the end of the probe buffer @@ -470,8 +470,7 @@ typedef struct AVProbeData { /** * The muxer/demuxer is experimental and should be used with caution. * - * - demuxers: will not be selected automatically by probing, must be specified - * explicitly. + * It will not be selected automatically, and must be specified explicitly. */ #define AVFMT_EXPERIMENTAL 0x0004 #define AVFMT_SHOW_IDS 0x0008 /**< Show format stream IDs numbers. */ @@ -485,9 +484,6 @@ typedef struct AVProbeData { #define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fall back on binary search via read_timestamp */ #define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fall back on generic search */ #define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */ -#if FF_API_ALLOW_FLUSH -#define AVFMT_ALLOW_FLUSH 0x10000 /**< @deprecated: Just send a NULL packet if you want to flush a muxer. */ -#endif #define AVFMT_TS_NONSTRICT 0x20000 /**< Format does not require strictly increasing timestamps, but they must still be monotonic */ @@ -847,38 +843,6 @@ typedef struct AVStream { */ AVPacket attached_pic; -#if FF_API_AVSTREAM_SIDE_DATA - /** - * An array of side data that applies to the whole stream (i.e. the - * container does not allow it to change between packets). - * - * There may be no overlap between the side data in this array and side data - * in the packets. I.e. a given side data is either exported by the muxer - * (demuxing) / set by the caller (muxing) in this array, then it never - * appears in the packets, or the side data is exported / sent through - * the packets (always in the first packet where the value becomes known or - * changes), then it does not appear in this array. - * - * - demuxing: Set by libavformat when the stream is created. - * - muxing: May be set by the caller before avformat_write_header(). - * - * Freed by libavformat in avformat_free_context(). - * - * @deprecated use AVStream's @ref AVCodecParameters.coded_side_data - * "codecpar side data". - */ - attribute_deprecated - AVPacketSideData *side_data; - /** - * The number of elements in the AVStream.side_data array. - * - * @deprecated use AVStream's @ref AVCodecParameters.nb_coded_side_data - * "codecpar side data". - */ - attribute_deprecated - int nb_side_data; -#endif - /** * Flags indicating events happening on the stream, a combination of * AVSTREAM_EVENT_FLAG_*. @@ -962,7 +926,7 @@ typedef struct AVStream { * the sixth @ref AVStreamGroup.streams "stream" in the group is "512,512", * etc. * - * The following is an example of a canvas with overlaping tiles: + * The following is an example of a canvas with overlapping tiles: * * +-----------+ * | %%%%% | @@ -1082,15 +1046,27 @@ typedef struct AVStreamGroupTileGrid { * final image before presentation. */ int height; + + /** + * Additional data associated with the grid. + * + * Should be allocated with av_packet_side_data_new() or + * av_packet_side_data_add(), and will be freed by avformat_free_context(). + */ + AVPacketSideData *coded_side_data; + + /** + * Amount of entries in @ref coded_side_data. + */ + int nb_coded_side_data; } AVStreamGroupTileGrid; /** * AVStreamGroupLCEVC is meant to define the relation between video streams * and a data stream containing LCEVC enhancement layer NALUs. * - * No more than one stream of @ref AVCodecParameters.codec_type "codec_type" - * AVMEDIA_TYPE_DATA shall be present, and it must be of - * @ref AVCodecParameters.codec_id "codec_id" AV_CODEC_ID_LCEVC. + * No more than one stream of + * @ref AVCodecParameters.codec_id "codec_id" AV_CODEC_ID_LCEVC shall be present. */ typedef struct AVStreamGroupLCEVC { const AVClass *av_class; @@ -1447,7 +1423,7 @@ typedef struct AVFormatContext { #define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input. #define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS #define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container -#define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled +#define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the filling code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled #define AVFMT_FLAG_NOBUFFER 0x0040 ///< Do not buffer frames when possible #define AVFMT_FLAG_CUSTOM_IO 0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it. #define AVFMT_FLAG_DISCARD_CORRUPT 0x0100 ///< Discard frames marked corrupted @@ -1461,9 +1437,6 @@ typedef struct AVFormatContext { #define AVFMT_FLAG_BITEXACT 0x0400 #define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down) #define AVFMT_FLAG_FAST_SEEK 0x80000 ///< Enable fast, but inaccurate seeks for some formats -#if FF_API_LAVF_SHORTEST -#define AVFMT_FLAG_SHORTEST 0x100000 ///< Stop muxing when the shortest stream stops. -#endif #define AVFMT_FLAG_AUTO_BSF 0x200000 ///< Add bitstream filters as requested by the muxer /** @@ -1700,7 +1673,7 @@ typedef struct AVFormatContext { int use_wallclock_as_timestamps; /** - * Skip duration calcuation in estimate_timings_from_pts. + * Skip duration calculation in estimate_timings_from_pts. * - encoding: unused * - decoding: set by user * @@ -1803,7 +1776,7 @@ typedef struct AVFormatContext { /** * IO repositioned flag. - * This is set by avformat when the underlaying IO context read pointer + * This is set by avformat when the underlying IO context read pointer * is repositioned, for example when doing byte based seeking. * Demuxers can use the flag to detect such changes. */ @@ -1899,10 +1872,6 @@ typedef struct AVFormatContext { /** * A callback for closing the streams opened with AVFormatContext.io_open(). * - * Using this is preferred over io_close, because this can return an error. - * Therefore this callback is used instead of io_close by the generic - * libavformat code if io_close is NULL or the default. - * * @param s the format context * @param pb IO context to be closed and freed * @return 0 on success, a negative AVERROR code on failure @@ -1918,30 +1887,12 @@ typedef struct AVFormatContext { * @see skip_estimate_duration_from_pts */ int64_t duration_probesize; -} AVFormatContext; -/** - * This function will cause global side data to be injected in the next packet - * of each stream as well as after any subsequent seek. - * - * @note global side data is always available in every AVStream's - * @ref AVCodecParameters.coded_side_data "codecpar side data" array, and - * in a @ref AVCodecContext.coded_side_data "decoder's side data" array if - * initialized with said stream's codecpar. - * @see av_packet_side_data_get() - */ -void av_format_inject_global_side_data(AVFormatContext *s); - -#if FF_API_GET_DUR_ESTIMATE_METHOD -/** - * Returns the method used to set ctx->duration. - * - * @return AVFMT_DURATION_FROM_PTS, AVFMT_DURATION_FROM_STREAM, or AVFMT_DURATION_FROM_BITRATE. - * @deprecated duration_estimation_method is public and can be read directly. - */ -attribute_deprecated -enum AVDurationEstimationMethod av_fmt_ctx_get_duration_estimation_method(const AVFormatContext* ctx); -#endif + /** + * Name of this format context, only used for logging purposes. + */ + char *name; +} AVFormatContext; /** * @defgroup lavf_core Core functions @@ -2120,57 +2071,6 @@ AVStream *avformat_new_stream(AVFormatContext *s, const struct AVCodec *c); */ int avformat_stream_group_add_stream(AVStreamGroup *stg, AVStream *st); -#if FF_API_AVSTREAM_SIDE_DATA -/** - * Wrap an existing array as stream side data. - * - * @param st stream - * @param type side information type - * @param data the side data array. It must be allocated with the av_malloc() - * family of functions. The ownership of the data is transferred to - * st. - * @param size side information size - * - * @return zero on success, a negative AVERROR code on failure. On failure, - * the stream is unchanged and the data remains owned by the caller. - * @deprecated use av_packet_side_data_add() with the stream's - * @ref AVCodecParameters.coded_side_data "codecpar side data" - */ -attribute_deprecated -int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type, - uint8_t *data, size_t size); - -/** - * Allocate new information from stream. - * - * @param stream stream - * @param type desired side information type - * @param size side information size - * - * @return pointer to fresh allocated data or NULL otherwise - * @deprecated use av_packet_side_data_new() with the stream's - * @ref AVCodecParameters.coded_side_data "codecpar side data" - */ -attribute_deprecated -uint8_t *av_stream_new_side_data(AVStream *stream, - enum AVPacketSideDataType type, size_t size); -/** - * Get side information from stream. - * - * @param stream stream - * @param type desired side information type - * @param size If supplied, *size will be set to the size of the side data - * or to zero if the desired side data is not present. - * - * @return pointer to data if present or NULL otherwise - * @deprecated use av_packet_side_data_get() with the stream's - * @ref AVCodecParameters.coded_side_data "codecpar side data" - */ -attribute_deprecated -uint8_t *av_stream_get_side_data(const AVStream *stream, - enum AVPacketSideDataType type, size_t *size); -#endif - AVProgram *av_new_program(AVFormatContext *s, int id); /** @@ -2279,7 +2179,7 @@ int av_probe_input_buffer(AVIOContext *pb, const AVInputFormat **fmt, * which case an AVFormatContext is allocated by this * function and written into ps. * Note that a user-supplied AVFormatContext will be freed - * on failure. + * on failure and its pointer set to NULL. * @param url URL of the stream to open. * @param fmt If non-NULL, this parameter forces a specific input format. * Otherwise the format is autodetected. @@ -2288,7 +2188,8 @@ int av_probe_input_buffer(AVIOContext *pb, const AVInputFormat **fmt, * On return this parameter will be destroyed and replaced with * a dict containing options that were not found. May be NULL. * - * @return 0 on success, a negative AVERROR on failure. + * @return 0 on success; on failure: frees ps, sets its pointer to NULL, + * and returns a negative AVERROR. * * @note If you want to use custom IO, preallocate the format context and set its pb field. */ @@ -2471,6 +2372,101 @@ int av_read_play(AVFormatContext *s); */ int av_read_pause(AVFormatContext *s); +/** + * Command IDs that can be sent to the demuxer + * + * The following commands can be sent to a demuxer + * using ::avformat_send_command. + */ +enum AVFormatCommandID { + /** + * Send a RTSP `SET_PARAMETER` request to the server + * + * Sends an SET_PARAMETER RTSP command to the server, + * with a data payload of type ::AVRTSPCommandRequest, + * ownership of it and its data remains with the caller. + * + * A reply retrieved is of type ::AVRTSPResponse and it + * and its contents must be freed by the caller. + */ + AVFORMAT_COMMAND_RTSP_SET_PARAMETER, +}; + +typedef struct AVRTSPCommandRequest { + /** + * Headers sent in the request to the server + */ + AVDictionary *headers; + + /** + * Body payload size + */ + size_t body_len; + + /** + * Body payload + */ + char *body; +} AVRTSPCommandRequest; + +typedef struct AVRTSPResponse { + /** + * Response status code from server + */ + int status_code; + + /** + * Reason phrase from the server, describing the + * status in a human-readable way. + */ + char *reason; + + /** + * Body payload size + */ + size_t body_len; + + /** + * Body payload + */ + unsigned char *body; +} AVRTSPResponse; + +/** + * Send a command to the demuxer + * + * Sends the specified command and (depending on the command) + * optionally a command-specific payload to the demuxer to handle. + * + * @param s Format context, must be allocated with + * ::avformat_alloc_context. + * @param id Identifier of type ::AVFormatCommandID, + * indicating the command to send. + * @param data Command-specific data, allocated by the caller + * and ownership remains with the caller. + * For details what is expected here, consult the + * documentation of the respective ::AVFormatCommandID. + */ +int avformat_send_command(AVFormatContext *s, enum AVFormatCommandID id, void *data); + +/** + * Receive a command reply from the demuxer + * + * Retrieves a reply for a previously sent command from the muxer. + * + * @param s Format context, must be allocated with + * ::avformat_alloc_context. + * @param id Identifier of type ::AVFormatCommandID, + * indicating the command for which to retrieve + * the reply. + * @param data_out Pointee is set to the command reply, the actual + * type depends on the command. This is allocated by + * the muxer and must be freed with ::av_free. + * For details on the actual data set here, consult the + * documentation of the respective ::AVFormatCommandID. + */ +int avformat_receive_command_reply(AVFormatContext *s, enum AVFormatCommandID id, void **data_out); + /** * Close an opened input AVFormatContext. Free it and all its contents * and set *s to NULL. @@ -2926,7 +2922,8 @@ void av_dump_format(AVFormatContext *ic, int is_output); -#define AV_FRAME_FILENAME_FLAGS_MULTIPLE 1 ///< Allow multiple %d +#define AV_FRAME_FILENAME_FLAGS_MULTIPLE 1 ///< Allow multiple %d +#define AV_FRAME_FILENAME_FLAGS_IGNORE_TRUNCATION 2 ///< Ignore truncated output instead of returning an error /** * Return in 'buf' the path with '%d' replaced by a number. @@ -2996,6 +2993,20 @@ int av_match_ext(const char *filename, const char *extensions); int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance); +struct AVBPrint; +/** + * Make a RFC 4281/6381 like string describing a codec for MIME types. + * + * @param par pointer to an AVCodecParameters struct describing the codec + * @param frame_rate an AVRational for the frame rate, for deciding the + * right profile for video codecs. Pass an invalid + * AVRational (1/0) to indicate that it is unknown. + * @param out the AVBPrint to write the output to + * @return <0 on error + */ +int av_mime_codec_str(const AVCodecParameters *par, + AVRational frame_rate, struct AVBPrint *out); + /** * @defgroup riff_fourcc RIFF FourCCs * @{ diff --git a/include/libavformat/avio.h b/include/libavformat/avio.h index ebf611187d..fbcb7dbfc3 100755 --- a/include/libavformat/avio.h +++ b/include/libavformat/avio.h @@ -461,17 +461,17 @@ int avio_put_str16be(AVIOContext *s, const char *str); void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type); /** - * ORing this as the "whence" parameter to a seek function causes it to + * Passing this as the "whence" parameter to a seek function causes it to * return the filesize without seeking anywhere. Supporting this is optional. * If it is not supported then the seek function will return <0. */ #define AVSEEK_SIZE 0x10000 /** - * Passing this flag as the "whence" parameter to a seek function causes it to + * OR'ing this flag into the "whence" parameter to a seek function causes it to * seek by any means (like reopening and linear reading) or other normally unreasonable * means that can be extremely slow. - * This may be ignored by the seek code. + * This is the default and therefore ignored by the seek code since 2010. */ #define AVSEEK_FORCE 0x20000 diff --git a/include/libavformat/version.h b/include/libavformat/version.h index 70c554c19c..e41362ac9d 100755 --- a/include/libavformat/version.h +++ b/include/libavformat/version.h @@ -31,8 +31,8 @@ #include "version_major.h" -#define LIBAVFORMAT_VERSION_MINOR 7 -#define LIBAVFORMAT_VERSION_MICRO 100 +#define LIBAVFORMAT_VERSION_MINOR 12 +#define LIBAVFORMAT_VERSION_MICRO 101 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ diff --git a/include/libavformat/version_major.h b/include/libavformat/version_major.h index 7a9b06703d..c2f6e1616b 100644 --- a/include/libavformat/version_major.h +++ b/include/libavformat/version_major.h @@ -29,7 +29,7 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here -#define LIBAVFORMAT_VERSION_MAJOR 61 +#define LIBAVFORMAT_VERSION_MAJOR 62 /** * FF_API_* defines may be placed below to indicate public API that will be @@ -41,13 +41,11 @@ * at once through the bump. This improves the git bisect-ability of the change. * */ -#define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 62) -#define FF_API_LAVF_SHORTEST (LIBAVFORMAT_VERSION_MAJOR < 62) -#define FF_API_ALLOW_FLUSH (LIBAVFORMAT_VERSION_MAJOR < 62) -#define FF_API_AVSTREAM_SIDE_DATA (LIBAVFORMAT_VERSION_MAJOR < 62) +#define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 63) -#define FF_API_GET_DUR_ESTIMATE_METHOD (LIBAVFORMAT_VERSION_MAJOR < 62) -#define FF_API_INTERNAL_TIMING (LIBAVFORMAT_VERSION_MAJOR < 62) +#define FF_API_INTERNAL_TIMING (LIBAVFORMAT_VERSION_MAJOR < 63) + +#define FF_API_NO_DEFAULT_TLS_VERIFY (LIBAVFORMAT_VERSION_MAJOR < 63) #define FF_API_R_FRAME_RATE 1 diff --git a/include/libavutil/attributes.h b/include/libavutil/attributes.h index 04c615c952..0e49b22b9d 100755 --- a/include/libavutil/attributes.h +++ b/include/libavutil/attributes.h @@ -40,8 +40,27 @@ # define AV_HAS_BUILTIN(x) 0 #endif +#ifdef __has_attribute +# define AV_HAS_ATTRIBUTE(x) __has_attribute(x) +#else +# define AV_HAS_ATTRIBUTE(x) 0 +#endif + +#if defined(__cplusplus) && \ + defined(__has_cpp_attribute) && \ + __cplusplus >= 201103L +# define AV_HAS_STD_ATTRIBUTE(x) __has_cpp_attribute(x) +#elif !defined(__cplusplus) && \ + defined(__has_c_attribute) && \ + defined(__STDC_VERSION__) && \ + __STDC_VERSION__ >= 202311L +# define AV_HAS_STD_ATTRIBUTE(x) __has_c_attribute(x) +#else +# define AV_HAS_STD_ATTRIBUTE(x) 0 +#endif + #ifndef av_always_inline -#if AV_GCC_VERSION_AT_LEAST(3,1) +#if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__) # define av_always_inline __attribute__((always_inline)) inline #elif defined(_MSC_VER) # define av_always_inline __forceinline @@ -58,13 +77,15 @@ #endif #endif -#if AV_GCC_VERSION_AT_LEAST(3,4) +#if AV_HAS_STD_ATTRIBUTE(nodiscard) +# define av_warn_unused_result [[nodiscard]] +#elif AV_GCC_VERSION_AT_LEAST(3,4) || defined(__clang__) # define av_warn_unused_result __attribute__((warn_unused_result)) #else # define av_warn_unused_result #endif -#if AV_GCC_VERSION_AT_LEAST(3,1) +#if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__) # define av_noinline __attribute__((noinline)) #elif defined(_MSC_VER) # define av_noinline __declspec(noinline) @@ -96,7 +117,9 @@ # define av_flatten #endif -#if AV_GCC_VERSION_AT_LEAST(3,1) +#if AV_HAS_STD_ATTRIBUTE(deprecated) +# define attribute_deprecated [[deprecated]] +#elif AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__) # define attribute_deprecated __attribute__((deprecated)) #elif defined(_MSC_VER) # define attribute_deprecated __declspec(deprecated) @@ -127,7 +150,9 @@ #endif #endif -#if defined(__GNUC__) || defined(__clang__) +#if AV_HAS_STD_ATTRIBUTE(maybe_unused) +# define av_unused [[maybe_unused]] +#elif defined(__GNUC__) || defined(__clang__) # define av_unused __attribute__((unused)) #else # define av_unused @@ -158,13 +183,42 @@ #if defined(__GNUC__) || defined(__clang__) # define av_builtin_constant_p __builtin_constant_p -# define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos))) #else # define av_builtin_constant_p(x) 0 +#endif + +// for __MINGW_PRINTF_FORMAT and __MINGW_SCANF_FORMAT +#ifdef __MINGW32__ +# include +#endif + +#ifdef __MINGW_PRINTF_FORMAT +# define AV_PRINTF_FMT __MINGW_PRINTF_FORMAT +#elif AV_HAS_ATTRIBUTE(format) +# define AV_PRINTF_FMT __printf__ +#endif + +#ifdef __MINGW_SCANF_FORMAT +# define AV_SCANF_FMT __MINGW_SCANF_FORMAT +#elif AV_HAS_ATTRIBUTE(format) +# define AV_SCANF_FMT __scanf__ +#endif + +#ifdef AV_PRINTF_FMT +# define av_printf_format(fmtpos, attrpos) __attribute__((format(AV_PRINTF_FMT, fmtpos, attrpos))) +#else # define av_printf_format(fmtpos, attrpos) #endif -#if AV_GCC_VERSION_AT_LEAST(2,5) || defined(__clang__) +#ifdef AV_SCANF_FMT +# define av_scanf_format(fmtpos, attrpos) __attribute__((format(AV_SCANF_FMT, fmtpos, attrpos))) +#else +# define av_scanf_format(fmtpos, attrpos) +#endif + +#if AV_HAS_STD_ATTRIBUTE(noreturn) +# define av_noreturn [[noreturn]] +#elif AV_GCC_VERSION_AT_LEAST(2,5) || defined(__clang__) # define av_noreturn __attribute__((noreturn)) #else # define av_noreturn diff --git a/include/libavutil/avassert.h b/include/libavutil/avassert.h index 1895fb7551..e316a3c90d 100755 --- a/include/libavutil/avassert.h +++ b/include/libavutil/avassert.h @@ -31,8 +31,10 @@ #ifdef HAVE_AV_CONFIG_H # include "config.h" #endif +#include "attributes.h" #include "log.h" #include "macros.h" +#include "version.h" /** * assert() equivalent, that is always enabled. @@ -62,17 +64,62 @@ */ #if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1 #define av_assert2(cond) av_assert0(cond) -#define av_assert2_fpu() av_assert0_fpu() #else #define av_assert2(cond) ((void)0) -#define av_assert2_fpu() ((void)0) #endif +#if FF_API_ASSERT_FPU +#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1 +#define av_assert2_fpu() av_assert0_fpu() +#else +#define av_assert2_fpu() ((void)0) +#endif /** * Assert that floating point operations can be executed. * * This will av_assert0() that the cpu is not in MMX state on X86 + * @deprecated without replacement */ +attribute_deprecated void av_assert0_fpu(void); +#endif + +/** + * Asserts that are used as compiler optimization hints depending + * upon ASSERT_LEVEL and NBDEBUG. + * + * Undefined behaviour occurs if execution reaches a point marked + * with av_unreachable() or if a condition used with av_assume() + * is false. + * + * The condition used with av_assume() should not have side-effects + * and should be visible to the compiler. + */ +#if defined(ASSERT_LEVEL) ? ASSERT_LEVEL > 0 : !defined(HAVE_AV_CONFIG_H) && !defined(NDEBUG) +#define av_unreachable(msg) \ +do { \ + av_log(NULL, AV_LOG_PANIC, \ + "Reached supposedly unreachable code at %s:%d: %s\n", \ + __FILE__, __LINE__, msg); \ + abort(); \ +} while (0) +#define av_assume(cond) av_assert0(cond) +#else +#if AV_GCC_VERSION_AT_LEAST(4, 5) || AV_HAS_BUILTIN(__builtin_unreachable) +#define av_unreachable(msg) __builtin_unreachable() +#elif defined(_MSC_VER) +#define av_unreachable(msg) __assume(0) +#elif __STDC_VERSION__ >= 202311L +#include +#define av_unreachable(msg) unreachable() +#else +#define av_unreachable(msg) ((void)0) +#endif + +#define av_assume(cond) do { \ + if (!(cond)) \ + av_unreachable(); \ +} while (0) +#endif #endif /* AVUTIL_AVASSERT_H */ diff --git a/include/libavutil/avstring.h b/include/libavutil/avstring.h index fc095349d2..17f7b03db5 100755 --- a/include/libavutil/avstring.h +++ b/include/libavutil/avstring.h @@ -419,7 +419,7 @@ int av_match_list(const char *name, const char *list, char separator); * See libc sscanf manual for more information. * Locale-independent sscanf implementation. */ -int av_sscanf(const char *string, const char *format, ...); +int av_sscanf(const char *string, const char *format, ...) av_scanf_format(2, 3); /** * @} diff --git a/include/libavutil/avutil.h b/include/libavutil/avutil.h index d2900dcb48..c8ae114ab6 100755 --- a/include/libavutil/avutil.h +++ b/include/libavutil/avutil.h @@ -41,7 +41,6 @@ * @li @ref lavd "libavdevice" special devices muxing/demuxing library * @li @ref lavu "libavutil" common utility library * @li @ref lswr "libswresample" audio resampling, format conversion and mixing - * @li @ref lpp "libpostproc" post processing library * @li @ref libsws "libswscale" color conversion and scaling library * * @section ffmpeg_versioning Versioning and compatibility @@ -314,6 +313,7 @@ static inline void *av_x_if_null(const void *p, const void *x) return (void *)(intptr_t)(p ? p : x); } +#if FF_API_OPT_INT_LIST /** * Compute the length of an integer list. * @@ -322,6 +322,7 @@ static inline void *av_x_if_null(const void *p, const void *x) * @param list pointer to the list * @return length of the list, in elements, not counting the terminator */ +attribute_deprecated unsigned av_int_list_length_for_size(unsigned elsize, const void *list, uint64_t term) av_pure; @@ -334,6 +335,7 @@ 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) +#endif /** * Return the fractional representation of the internal time base. diff --git a/include/libavutil/bswap.h b/include/libavutil/bswap.h index f53e5768ad..c1e6591ce0 100755 --- a/include/libavutil/bswap.h +++ b/include/libavutil/bswap.h @@ -68,7 +68,7 @@ static av_always_inline av_const uint32_t av_bswap32(uint32_t x) #ifndef av_bswap64 static inline uint64_t av_const av_bswap64(uint64_t x) { - return (uint64_t)av_bswap32(x) << 32 | av_bswap32(x >> 32); + return (uint64_t)av_bswap32((uint32_t)x) << 32 | av_bswap32((uint32_t)(x >> 32)); } #endif diff --git a/include/libavutil/channel_layout.h b/include/libavutil/channel_layout.h index 3a96c2d9b8..5ad2d5ed98 100755 --- a/include/libavutil/channel_layout.h +++ b/include/libavutil/channel_layout.h @@ -45,7 +45,7 @@ */ enum AVChannel { - ///< Invalid channel index + /// Invalid channel index AV_CHAN_NONE = -1, AV_CHAN_FRONT_LEFT, AV_CHAN_FRONT_RIGHT, @@ -84,6 +84,9 @@ enum AVChannel { AV_CHAN_TOP_SURROUND_LEFT, ///< +110 degrees, Lvs, TpLS AV_CHAN_TOP_SURROUND_RIGHT, ///< -110 degrees, Rvs, TpRS + AV_CHAN_BINAURAL_LEFT = 61, + AV_CHAN_BINAURAL_RIGHT, + /** Channel is empty can be safely skipped. */ AV_CHAN_UNUSED = 0x200, @@ -203,6 +206,8 @@ enum AVChannelOrder { #define AV_CH_SIDE_SURROUND_RIGHT (1ULL << AV_CHAN_SIDE_SURROUND_RIGHT ) #define AV_CH_TOP_SURROUND_LEFT (1ULL << AV_CHAN_TOP_SURROUND_LEFT ) #define AV_CH_TOP_SURROUND_RIGHT (1ULL << AV_CHAN_TOP_SURROUND_RIGHT ) +#define AV_CH_BINAURAL_LEFT (1ULL << AV_CHAN_BINAURAL_LEFT ) +#define AV_CH_BINAURAL_RIGHT (1ULL << AV_CHAN_BINAURAL_RIGHT ) /** * @} @@ -235,17 +240,20 @@ enum AVChannelOrder { #define AV_CH_LAYOUT_7POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) #define AV_CH_LAYOUT_7POINT1_WIDE (AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) #define AV_CH_LAYOUT_7POINT1_WIDE_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) +#define AV_CH_LAYOUT_5POINT1POINT2 (AV_CH_LAYOUT_5POINT1|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT) #define AV_CH_LAYOUT_5POINT1POINT2_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT) #define AV_CH_LAYOUT_OCTAGONAL (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT) #define AV_CH_LAYOUT_CUBE (AV_CH_LAYOUT_QUAD|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT) -#define AV_CH_LAYOUT_5POINT1POINT4_BACK (AV_CH_LAYOUT_5POINT1POINT2_BACK|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT) +#define AV_CH_LAYOUT_5POINT1POINT4_BACK (AV_CH_LAYOUT_5POINT1POINT2|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT) #define AV_CH_LAYOUT_7POINT1POINT2 (AV_CH_LAYOUT_7POINT1|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT) #define AV_CH_LAYOUT_7POINT1POINT4_BACK (AV_CH_LAYOUT_7POINT1POINT2|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT) #define AV_CH_LAYOUT_7POINT2POINT3 (AV_CH_LAYOUT_7POINT1POINT2|AV_CH_TOP_BACK_CENTER|AV_CH_LOW_FREQUENCY_2) #define AV_CH_LAYOUT_9POINT1POINT4_BACK (AV_CH_LAYOUT_7POINT1POINT4_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) +#define AV_CH_LAYOUT_9POINT1POINT6 (AV_CH_LAYOUT_9POINT1POINT4_BACK|AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT) #define AV_CH_LAYOUT_HEXADECAGONAL (AV_CH_LAYOUT_OCTAGONAL|AV_CH_WIDE_LEFT|AV_CH_WIDE_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT) +#define AV_CH_LAYOUT_BINAURAL (AV_CH_BINAURAL_LEFT|AV_CH_BINAURAL_RIGHT) #define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT) -#define AV_CH_LAYOUT_22POINT2 (AV_CH_LAYOUT_7POINT1POINT4_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_BACK_CENTER|AV_CH_LOW_FREQUENCY_2|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_CENTER|AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_BOTTOM_FRONT_CENTER|AV_CH_BOTTOM_FRONT_LEFT|AV_CH_BOTTOM_FRONT_RIGHT) +#define AV_CH_LAYOUT_22POINT2 (AV_CH_LAYOUT_9POINT1POINT6|AV_CH_BACK_CENTER|AV_CH_LOW_FREQUENCY_2|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_CENTER|AV_CH_TOP_BACK_CENTER|AV_CH_BOTTOM_FRONT_CENTER|AV_CH_BOTTOM_FRONT_LEFT|AV_CH_BOTTOM_FRONT_RIGHT) #define AV_CH_LAYOUT_7POINT1_TOP_BACK AV_CH_LAYOUT_5POINT1POINT2_BACK @@ -299,7 +307,7 @@ typedef struct AVChannelCustom { * - 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() + * The channel layout must be uninitialized 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 @@ -357,7 +365,7 @@ typedef struct AVChannelLayout { * * 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. + * convenience functions below. Otherwise it must be zeroed. */ AVChannelCustom *map; } u; @@ -409,6 +417,7 @@ typedef struct AVChannelLayout { #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_5POINT1POINT2 AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_5POINT1POINT2) #define AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_5POINT1POINT2_BACK) #define AV_CHANNEL_LAYOUT_OCTAGONAL AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_OCTAGONAL) #define AV_CHANNEL_LAYOUT_CUBE AV_CHANNEL_LAYOUT_MASK(8, AV_CH_LAYOUT_CUBE) @@ -417,7 +426,9 @@ typedef struct AVChannelLayout { #define AV_CHANNEL_LAYOUT_7POINT1POINT4_BACK AV_CHANNEL_LAYOUT_MASK(12, AV_CH_LAYOUT_7POINT1POINT4_BACK) #define AV_CHANNEL_LAYOUT_7POINT2POINT3 AV_CHANNEL_LAYOUT_MASK(12, AV_CH_LAYOUT_7POINT2POINT3) #define AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK AV_CHANNEL_LAYOUT_MASK(14, AV_CH_LAYOUT_9POINT1POINT4_BACK) +#define AV_CHANNEL_LAYOUT_9POINT1POINT6 AV_CHANNEL_LAYOUT_MASK(16, AV_CH_LAYOUT_9POINT1POINT6) #define AV_CHANNEL_LAYOUT_HEXADECAGONAL AV_CHANNEL_LAYOUT_MASK(16, AV_CH_LAYOUT_HEXADECAGONAL) +#define AV_CHANNEL_LAYOUT_BINAURAL AV_CHANNEL_LAYOUT_MASK(2, AV_CH_LAYOUT_BINAURAL) #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) diff --git a/include/libavutil/common.h b/include/libavutil/common.h index 3b830daf30..bf23aa50b0 100755 --- a/include/libavutil/common.h +++ b/include/libavutil/common.h @@ -486,13 +486,13 @@ static av_always_inline av_const int av_parity_c(uint32_t v) * to prevent undefined results. */ #define GET_UTF8(val, GET_BYTE, ERROR)\ - val= (GET_BYTE);\ + val= (uint8_t)(GET_BYTE);\ {\ uint32_t top = (val & 128) >> 1;\ if ((val & 0xc0) == 0x80 || val >= 0xFE)\ {ERROR}\ while (val & top) {\ - unsigned int tmp = (GET_BYTE) - 128;\ + unsigned int tmp = (uint8_t)(GET_BYTE) - 128;\ if(tmp>>6)\ {ERROR}\ val= (val<<6) + tmp;\ @@ -511,11 +511,11 @@ static av_always_inline av_const int av_parity_c(uint32_t v) * typically a goto statement. */ #define GET_UTF16(val, GET_16BIT, ERROR)\ - val = (GET_16BIT);\ + val = (uint16_t)(GET_16BIT);\ {\ unsigned int hi = val - 0xD800;\ if (hi < 0x800) {\ - val = (GET_16BIT) - 0xDC00;\ + val = (uint16_t)(GET_16BIT) - 0xDC00;\ if (val > 0x3FFU || hi > 0x3FFU)\ {ERROR}\ val += (hi<<10) + 0x10000;\ diff --git a/include/libavutil/container_fifo.h b/include/libavutil/container_fifo.h new file mode 100644 index 0000000000..ff9249311f --- /dev/null +++ b/include/libavutil/container_fifo.h @@ -0,0 +1,130 @@ +/* + * 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_CONTAINER_FIFO_H +#define AVUTIL_CONTAINER_FIFO_H + +#include + +/** + * AVContainerFifo is a FIFO for "containers" - dynamically allocated reusable + * structs (e.g. AVFrame or AVPacket). AVContainerFifo uses an internal pool of + * such containers to avoid allocating and freeing them repeatedly. + */ +typedef struct AVContainerFifo AVContainerFifo; + +enum AVContainerFifoFlags { + /** + * Signal to av_container_fifo_write() that it should make a new reference + * to data in src rather than consume its contents. + * + * @note you must handle this flag manually in your own fifo_transfer() + * callback + */ + AV_CONTAINER_FIFO_FLAG_REF = (1 << 0), + + /** + * This and all higher bits in flags may be set to any value by the caller + * and are guaranteed to be passed through to the fifo_transfer() callback + * and not be interpreted by AVContainerFifo code. + */ + AV_CONTAINER_FIFO_FLAG_USER = (1 << 16), +}; + +/** + * Allocate a new AVContainerFifo for the container type defined by provided + * callbacks. + * + * @param opaque user data that will be passed to the callbacks provided to this + * function + * @param container_alloc allocate a new container instance and return a pointer + * to it, or NULL on failure + * @param container_reset reset the provided container instance to a clean state + * @param container_free free the provided container instance + * @param fifo_transfer Transfer the contents of container src to dst. + * @param flags currently unused + * + * @return newly allocated AVContainerFifo, or NULL on failure + */ +AVContainerFifo* +av_container_fifo_alloc(void *opaque, + void* (*container_alloc)(void *opaque), + void (*container_reset)(void *opaque, void *obj), + void (*container_free) (void *opaque, void *obj), + int (*fifo_transfer) (void *opaque, void *dst, void *src, unsigned flags), + unsigned flags); + +/** + * Allocate an AVContainerFifo instance for AVFrames. + * + * @param flags currently unused + */ +AVContainerFifo *av_container_fifo_alloc_avframe(unsigned flags); + +/** + * Free a AVContainerFifo and everything in it. + */ +void av_container_fifo_free(AVContainerFifo **cf); + +/** + * Write the contents of obj to the FIFO. + * + * The fifo_transfer() callback previously provided to av_container_fifo_alloc() + * will be called with obj as src in order to perform the actual transfer. + */ +int av_container_fifo_write(AVContainerFifo *cf, void *obj, unsigned flags); + +/** + * Read the next available object from the FIFO into obj. + * + * The fifo_read() callback previously provided to av_container_fifo_alloc() + * will be called with obj as dst in order to perform the actual transfer. + */ +int av_container_fifo_read(AVContainerFifo *cf, void *obj, unsigned flags); + +/** + * Access objects stored in the FIFO without retrieving them. The + * fifo_transfer() callback will NOT be invoked and the FIFO state will not be + * modified. + * + * @param pobj Pointer to the object stored in the FIFO will be written here on + * success. The object remains owned by the FIFO and the caller may + * only access it as long as the FIFO is not modified. + * @param offset Position of the object to retrieve - 0 is the next item that + * would be read, 1 the one after, etc. Must be smaller than + * av_container_fifo_can_read(). + * + * @retval 0 success, a pointer was written into pobj + * @retval AVERROR(EINVAL) invalid offset value + */ +int av_container_fifo_peek(AVContainerFifo *cf, void **pobj, size_t offset); + +/** + * Discard the specified number of elements from the FIFO. + * + * @param nb_elems number of elements to discard, MUST NOT be larger than + * av_fifo_can_read(f) + */ +void av_container_fifo_drain(AVContainerFifo *cf, size_t nb_elems); + +/** + * @return number of objects available for reading + */ +size_t av_container_fifo_can_read(const AVContainerFifo *cf); + +#endif // AVCODEC_CONTAINER_FIFO_H diff --git a/include/libavutil/cpu.h b/include/libavutil/cpu.h index ba6c234e04..464d4cd5df 100755 --- a/include/libavutil/cpu.h +++ b/include/libavutil/cpu.h @@ -24,7 +24,9 @@ #include #include "version.h" -#define AV_CPU_FLAG_FORCE 0x80000000 /* force usage of selected flags (OR) */ +#if FF_API_CPU_FLAG_FORCE +#define AV_CPU_FLAG_FORCE 0x80000000 /* @deprecated, should not be used */ +#endif /* lower 16 bits - CPU features */ #define AV_CPU_FLAG_MMX 0x0001 ///< standard MMX @@ -45,6 +47,7 @@ #define AV_CPU_FLAG_SSE4 0x0100 ///< Penryn SSE4.1 functions #define AV_CPU_FLAG_SSE42 0x0200 ///< Nehalem SSE4.2 functions #define AV_CPU_FLAG_AESNI 0x80000 ///< Advanced Encryption Standard functions +#define AV_CPU_FLAG_CLMUL 0x400000 ///< Carry-less Multiplication instruction #define AV_CPU_FLAG_AVX 0x4000 ///< AVX functions: requires OS support even if YMM registers aren't used #define AV_CPU_FLAG_AVXSLOW 0x8000000 ///< AVX supported, but slow when using YMM registers (e.g. Bulldozer) #define AV_CPU_FLAG_XOP 0x0400 ///< Bulldozer XOP functions @@ -72,6 +75,12 @@ #define AV_CPU_FLAG_VFP_VM (1 << 7) ///< VFPv2 vector mode, deprecated in ARMv7-A and unavailable in various CPUs implementations #define AV_CPU_FLAG_DOTPROD (1 << 8) #define AV_CPU_FLAG_I8MM (1 << 9) +#define AV_CPU_FLAG_SVE (1 <<10) +#define AV_CPU_FLAG_SVE2 (1 <<11) +#define AV_CPU_FLAG_SME (1 <<12) +#define AV_CPU_FLAG_ARM_CRC (1 <<13) +#define AV_CPU_FLAG_SME2 (1 <<14) +#define AV_CPU_FLAG_SME_I16I64 (1 <<15) #define AV_CPU_FLAG_SETEND (1 <<16) #define AV_CPU_FLAG_MMI (1 << 0) @@ -99,6 +108,9 @@ #define AV_CPU_FLAG_RV_MISALIGNED (1 <<10) ///< Fast misaligned accesses #define AV_CPU_FLAG_RVB (1 <<11) ///< B (bit manipulations) +// WASM extensions +#define AV_CPU_FLAG_SIMD128 (1 << 0) + /** * Return the flags which specify extensions supported by the CPU. * The returned value is affected by av_force_cpu_flags() if that was used diff --git a/include/libavutil/csp.h b/include/libavutil/csp.h index 73bce52bc0..9d75ccbb64 100644 --- a/include/libavutil/csp.h +++ b/include/libavutil/csp.h @@ -81,8 +81,12 @@ typedef struct AVColorPrimariesDesc { } AVColorPrimariesDesc; /** - * Function pointer representing a double -> double transfer function that performs - * an EOTF transfer inversion. This function outputs linear light. + * Function pointer representing a double -> double transfer function that + * performs either an OETF transfer function, or alternatively an inverse EOTF + * function (in particular, for SMPTE ST 2084 / PQ). This function inputs + * linear light, and outputs gamma encoded light. + * + * See ITU-T H.273 for more information. */ typedef double (*av_csp_trc_function)(double); @@ -110,7 +114,7 @@ const AVColorPrimariesDesc *av_csp_primaries_desc_from_id(enum AVColorPrimaries * @see enum AVColorPrimaries * @param prm A description of the colorspace gamut * @return The enum constant associated with this gamut, or - * AVCOL_PRI_UNSPECIFIED if no clear match can be idenitified. + * AVCOL_PRI_UNSPECIFIED if no clear match can be identified. */ enum AVColorPrimaries av_csp_primaries_id_from_desc(const AVColorPrimariesDesc *prm); @@ -129,6 +133,22 @@ enum AVColorPrimaries av_csp_primaries_id_from_desc(const AVColorPrimariesDesc * */ double av_csp_approximate_trc_gamma(enum AVColorTransferCharacteristic trc); +/** + * Determine a suitable EOTF 'gamma' value to match the supplied + * AVColorTransferCharacteristic. + * + * This function returns the gamma value (exponent) for a simple pure power + * function approximation of the supplied AVColorTransferCharacteristic, or 0. + * if no reasonable approximation exists. + * + * EOTF(v) = (L_w - L_b) * v^gamma + L_b + * + * @return Will return an approximation to the simple gamma function matching + * the supplied Transfer Characteristic EOTF, Will return 0.0 for any + * we cannot reasonably match against. + */ +double av_csp_approximate_eotf_gamma(enum AVColorTransferCharacteristic trc); + /** * Determine the function needed to apply the given * AVColorTransferCharacteristic to linear input. @@ -143,6 +163,44 @@ double av_csp_approximate_trc_gamma(enum AVColorTransferCharacteristic trc); */ av_csp_trc_function av_csp_trc_func_from_id(enum AVColorTransferCharacteristic trc); +/** + * Returns the mathematical inverse of the corresponding TRC function. + */ +av_csp_trc_function av_csp_trc_func_inv_from_id(enum AVColorTransferCharacteristic trc); + +/** + * Function pointer representing an ITU EOTF transfer for a given reference + * display configuration. + * + * @param Lw The white point luminance of the display, in nits (cd/m^2). + * @param Lb The black point luminance of the display, in nits (cd/m^2). + */ +typedef void (*av_csp_eotf_function)(double Lw, double Lb, double c[3]); + +/** + * Returns the ITU EOTF corresponding to a given TRC. This converts from the + * signal level [0,1] to the raw output display luminance in nits (cd/m^2). + * This is done per channel in RGB space, except for AVCOL_TRC_SMPTE428, which + * assumes CIE XYZ in- and output. + * + * @return A pointer to the function implementing the given TRC, or NULL if no + * such function is defined. + * + * @note In general, the resulting function is defined (wherever possible) for + * out-of-range values, even though these values do not have a physical + * meaning on the given display. Users should clamp inputs (or outputs) + * if this behavior is not desired. + * + * This is also the case for functions like PQ, which are defined over an + * absolute signal range independent of the target display capabilities. + */ +av_csp_eotf_function av_csp_itu_eotf(enum AVColorTransferCharacteristic trc); + +/** + * Returns the mathematical inverse of the corresponding EOTF. + */ +av_csp_eotf_function av_csp_itu_eotf_inv(enum AVColorTransferCharacteristic trc); + /** * @} */ diff --git a/include/libavutil/dict.h b/include/libavutil/dict.h index 713c9e361a..93c7cbf128 100755 --- a/include/libavutil/dict.h +++ b/include/libavutil/dict.h @@ -82,6 +82,7 @@ #define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no delimiter is added, the strings are simply concatenated. */ #define AV_DICT_MULTIKEY 64 /**< Allow to store several equal keys in the dictionary */ +#define AV_DICT_DEDUP 128 /**< If inserting a value that already exists for a key, do nothing. Only relevant with AV_DICT_MULTIKEY. */ /** * @} */ @@ -224,7 +225,7 @@ void av_dict_free(AVDictionary **m); * @warning Separators cannot be neither '\\' nor '\0'. They also cannot be the same. * * @param[in] m The dictionary - * @param[out] buffer Pointer to buffer that will be allocated with string containg entries. + * @param[out] buffer Pointer to buffer that will be allocated with string containing entries. * Buffer must be freed by the caller when is no longer needed. * @param[in] key_val_sep Character used to separate key from value * @param[in] pairs_sep Character used to separate two pairs from each other diff --git a/include/libavutil/dovi_meta.h b/include/libavutil/dovi_meta.h index 5e8a1e43d7..c102bf384f 100644 --- a/include/libavutil/dovi_meta.h +++ b/include/libavutil/dovi_meta.h @@ -279,12 +279,20 @@ typedef struct AVDOVIDmLevel11 { uint8_t content_type; uint8_t whitepoint; uint8_t reference_mode_flag; +#if FF_API_DOVI_L11_INVALID_PROPS + attribute_deprecated uint8_t sharpness; + attribute_deprecated uint8_t noise_reduction; + attribute_deprecated uint8_t mpeg_noise_reduction; + attribute_deprecated uint8_t frame_rate_conversion; + attribute_deprecated uint8_t brightness; + attribute_deprecated uint8_t color; +#endif } AVDOVIDmLevel11; typedef struct AVDOVIDmLevel254 { @@ -369,6 +377,10 @@ av_dovi_get_color(const AVDOVIMetadata *data) return (AVDOVIColorMetadata *)((uint8_t *) data + data->color_offset); } +/** + * Gets the specified Dolby Vision Display Management (DM) metadata + * @param index must be non negative and below data->num_ext_blocks + */ static av_always_inline AVDOVIDmData * av_dovi_get_ext(const AVDOVIMetadata *data, int index) { diff --git a/include/libavutil/ffversion.h b/include/libavutil/ffversion.h index 48f04a6aad..c1a8d885e8 100755 --- a/include/libavutil/ffversion.h +++ b/include/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 "7.1.1" +#define FFMPEG_VERSION "8.1.1" #endif /* AVUTIL_FFVERSION_H */ diff --git a/include/libavutil/film_grain_params.h b/include/libavutil/film_grain_params.h index ccacab88fe..2915611c9c 100644 --- a/include/libavutil/film_grain_params.h +++ b/include/libavutil/film_grain_params.h @@ -124,7 +124,7 @@ typedef struct AVFilmGrainAOMParams { /** * This structure describes how to handle film grain synthesis for codecs using - * the ITU-T H.274 Versatile suplemental enhancement information message. + * the ITU-T H.274 Versatile supplemental 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. @@ -136,43 +136,6 @@ typedef struct AVFilmGrainH274Params { */ int model_id; -#if FF_API_H274_FILM_GRAIN_VCS - /** - * TODO: On this ABI bump, please also re-order the fields in - * AVFilmGrainParams (see below) - */ - - /** - * Specifies the bit depth used for the luma component. - * - * @deprecated use AVFilmGrainParams.bit_depth_luma. - */ - attribute_deprecated - int bit_depth_luma; - - /** - * Specifies the bit depth used for the chroma components. - * - * @deprecated use AVFilmGrainParams.bit_depth_chroma. - */ - attribute_deprecated - int bit_depth_chroma; - - /** - * Specifies the video signal characteristics. - * - * @deprecated use AVFilmGrainParams.color_{range,primaries,trc,space}. - */ - attribute_deprecated - enum AVColorRange color_range; - attribute_deprecated - enum AVColorPrimaries color_primaries; - attribute_deprecated - enum AVColorTransferCharacteristic color_trc; - attribute_deprecated - enum AVColorSpace color_space; -#endif - /** * Specifies the blending mode used to blend the simulated film grain * with the decoded images. @@ -249,18 +212,6 @@ typedef struct AVFilmGrainParams { */ uint64_t seed; - /** - * Additional fields may be added both here and in any structure included. - * If a codec's film grain structure differs slightly over another - * codec's, fields within may change meaning depending on the type. - * - * TODO: Move this to the end of the structure, at the next ABI bump. - */ - union { - AVFilmGrainAOMParams aom; - AVFilmGrainH274Params h274; - } codec; - /** * Intended display resolution. May be 0 if the codec does not specify * any restrictions. @@ -287,6 +238,15 @@ typedef struct AVFilmGrainParams { int bit_depth_luma; int bit_depth_chroma; + /** + * Additional fields may be added both here and in any structure included. + * If a codec's film grain structure differs slightly over another + * codec's, fields within may change meaning depending on the type. + */ + union { + AVFilmGrainAOMParams aom; + AVFilmGrainH274Params h274; + } codec; } AVFilmGrainParams; /** diff --git a/include/libavutil/frame.h b/include/libavutil/frame.h index f7806566d5..771c9ce453 100755 --- a/include/libavutil/frame.h +++ b/include/libavutil/frame.h @@ -96,7 +96,7 @@ enum AVFrameSideDataType { */ AV_FRAME_DATA_MOTION_VECTORS, /** - * Recommmends skipping the specified number of samples. This is exported + * Recommends skipping the specified number of samples. This is exported * only if the "skip_manual" AVOption is set in libavcodec. * This has the same format as AV_PKT_DATA_SKIP_SAMPLES. * @code @@ -243,6 +243,23 @@ enum AVFrameSideDataType { * The data is an int storing the view ID. */ AV_FRAME_DATA_VIEW_ID, + + /** + * This side data contains information about the reference display width(s) + * and reference viewing distance(s) as well as information about the + * corresponding reference stereo pair(s), i.e., the pair(s) of views to be + * displayed for the viewer's left and right eyes on the reference display + * at the reference viewing distance. + * The payload is the AV3DReferenceDisplaysInfo struct defined in + * libavutil/tdrdi.h. + */ + AV_FRAME_DATA_3D_REFERENCE_DISPLAYS, + + /** + * Extensible image file format metadata. The payload is a buffer containing + * EXIF metadata, starting with either 49 49 2a 00, or 4d 4d 00 2a. + */ + AV_FRAME_DATA_EXIF, }; enum AVActiveFormatDescription { @@ -283,6 +300,27 @@ enum AVSideDataProps { * a single side data array. */ AV_SIDE_DATA_PROP_MULTI = (1 << 1), + + /** + * Side data depends on the video dimensions. Side data with this property + * loses its meaning when rescaling or cropping the image, unless + * either recomputed or adjusted to the new resolution. + */ + AV_SIDE_DATA_PROP_SIZE_DEPENDENT = (1 << 2), + + /** + * Side data depends on the video color space. Side data with this property + * loses its meaning when changing the video color encoding, e.g. by + * adapting to a different set of primaries or transfer characteristics. + */ + AV_SIDE_DATA_PROP_COLOR_DEPENDENT = (1 << 3), + + /** + * Side data depends on the channel layout. Side data with this property + * loses its meaning when downmixing or upmixing, unless either recomputed + * or adjusted to the new layout. + */ + AV_SIDE_DATA_PROP_CHANNEL_DEPENDENT = (1 << 4), }; /** @@ -475,16 +513,6 @@ typedef struct AVFrame { */ int format; -#if FF_API_FRAME_KEY - /** - * 1 -> keyframe, 0-> not - * - * @deprecated Use AV_FRAME_FLAG_KEY instead - */ - attribute_deprecated - int key_frame; -#endif - /** * Picture type of the frame. */ @@ -556,32 +584,6 @@ typedef struct AVFrame { */ int repeat_pict; -#if FF_API_INTERLACED_FRAME - /** - * The content of the picture is interlaced. - * - * @deprecated Use AV_FRAME_FLAG_INTERLACED instead - */ - attribute_deprecated - int interlaced_frame; - - /** - * If the content is interlaced, is top field displayed first. - * - * @deprecated Use AV_FRAME_FLAG_TOP_FIELD_FIRST instead - */ - attribute_deprecated - int top_field_first; -#endif - -#if FF_API_PALETTE_HAS_CHANGED - /** - * Tell user application that palette has changed from previous frame. - */ - attribute_deprecated - int palette_has_changed; -#endif - /** * Sample rate of the audio data. */ @@ -651,6 +653,14 @@ typedef struct AVFrame { * is interlaced. */ #define AV_FRAME_FLAG_TOP_FIELD_FIRST (1 << 4) +/** + * A decoder can use this flag to mark frames which were originally encoded losslessly. + * + * For coding bitstream formats which support both lossless and lossy + * encoding, it is sometimes possible for a decoder to determine which method + * was used when the bitstream was encoded. + */ +#define AV_FRAME_FLAG_LOSSLESS (1 << 5) /** * @} */ @@ -687,18 +697,6 @@ typedef struct AVFrame { */ int64_t best_effort_timestamp; -#if FF_API_FRAME_PKT - /** - * reordered pos from the last AVPacket that has been input into the decoder - * - encoding: unused - * - decoding: Read by user. - * @deprecated use AV_CODEC_FLAG_COPY_OPAQUE to pass through arbitrary user - * data from packets to frames - */ - attribute_deprecated - int64_t pkt_pos; -#endif - /** * metadata. * - encoding: Set by user. @@ -719,20 +717,6 @@ typedef struct AVFrame { #define FF_DECODE_ERROR_CONCEALMENT_ACTIVE 4 #define FF_DECODE_ERROR_DECODE_SLICES 8 -#if FF_API_FRAME_PKT - /** - * size of the corresponding packet containing the compressed - * frame. - * It is set to a negative value if unknown. - * - encoding: unused - * - decoding: set by libavcodec, read by user. - * @deprecated use AV_CODEC_FLAG_COPY_OPAQUE to pass through arbitrary user - * data from packets to frames - */ - attribute_deprecated - int pkt_size; -#endif - /** * For hwaccel-format frames, this should be a reference to the * AVHWFramesContext describing the frame. @@ -758,7 +742,7 @@ typedef struct AVFrame { /** * @anchor cropping * @name Cropping - * Video frames only. The number of pixels to discard from the the + * Video frames only. The number of pixels to discard from the * top/bottom/left/right border of the frame to obtain the sub-rectangle of * the frame intended for presentation. * @{ @@ -772,17 +756,13 @@ typedef struct AVFrame { */ /** - * AVBufferRef for internal use by a single libav* library. + * RefStruct reference for internal use by a single libav* library. * Must not be used to transfer data between libraries. * Has to be NULL when ownership of the frame leaves the respective library. * - * Code outside the FFmpeg libs should never check or change the contents of the buffer ref. - * - * FFmpeg calls av_buffer_unref() on it when the frame is unreferenced. - * av_frame_copy_props() calls create a new reference with av_buffer_ref() - * for the target frame's private_ref field. + * Code outside the FFmpeg libs must never check or change private_ref. */ - AVBufferRef *private_ref; + void *private_ref; /** * Channel layout of the audio data. @@ -793,6 +773,13 @@ typedef struct AVFrame { * Duration of the frame, in the same units as pts. 0 if unknown. */ int64_t duration; + + /** + * Indicates how the alpha channel of the video is to be handled. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVAlphaMode alpha_mode; } AVFrame; @@ -838,7 +825,7 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src); * Ensure the destination frame refers to the same data described by the source * frame, either by creating a new reference for each AVBufferRef from src if * they differ from those in dst, by allocating new buffers and copying data if - * src is not reference counted, or by unrefencing it if src is empty. + * src is not reference counted, or by unreferencing it if src is empty. * * Frame properties on dst will be replaced by those from src. * @@ -887,9 +874,10 @@ void av_frame_move_ref(AVFrame *dst, AVFrame *src); * cases. * * @param frame frame in which to store the new buffers. - * @param align Required buffer size alignment. If equal to 0, alignment will be - * chosen automatically for the current CPU. It is highly - * recommended to pass 0 here unless you know what you are doing. + * @param align Required buffer size and data pointer alignment. If equal to 0, + * alignment will be chosen automatically for the current CPU. + * It is highly recommended to pass 0 here unless you know what + * you are doing. * * @return 0 on success, a negative AVERROR on error. */ @@ -1063,6 +1051,11 @@ void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd); * Applies only for side data types without the AV_SIDE_DATA_PROP_MULTI prop. */ #define AV_FRAME_SIDE_DATA_FLAG_REPLACE (1 << 1) +/** + * Create a new reference to the passed in buffer instead of taking ownership + * of it. + */ +#define AV_FRAME_SIDE_DATA_FLAG_NEW_REF (1 << 2) /** * Add new side data entry to an array. @@ -1168,6 +1161,14 @@ const AVFrameSideData *av_frame_side_data_get(AVFrameSideData * const *sd, */ void av_frame_side_data_remove(AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type); + +/** + * Remove and free all side data instances that match any of the given + * side data properties. (See enum AVSideDataProps) + */ +void av_frame_side_data_remove_by_props(AVFrameSideData ***sd, int *nb_sd, + int props); + /** * @} */ diff --git a/include/libavutil/hdr_dynamic_vivid_metadata.h b/include/libavutil/hdr_dynamic_vivid_metadata.h index 4524a81557..d45b4a0f65 100644 --- a/include/libavutil/hdr_dynamic_vivid_metadata.h +++ b/include/libavutil/hdr_dynamic_vivid_metadata.h @@ -83,7 +83,7 @@ typedef struct AVHDRVividColorToneMappingParams { AVRational targeted_system_display_maximum_luminance; /** - * This flag indicates that transfer the base paramter(for value of 1) + * This flag indicates that transfer the base parameter(for value of 1) */ int base_enable_flag; @@ -145,7 +145,7 @@ typedef struct AVHDRVividColorToneMappingParams { int base_param_k3; /** - * This flag indicates that delta mode of base paramter(for value of 1) + * This flag indicates that delta mode of base parameter(for value of 1) */ int base_param_Delta_enable_mode; @@ -158,7 +158,7 @@ typedef struct AVHDRVividColorToneMappingParams { /** * indicates 3Spline_enable_flag in the base parameter, - * This flag indicates that transfer three Spline of base paramter(for value of 1) + * This flag indicates that transfer three Spline of base parameter(for value of 1) */ int three_Spline_enable_flag; @@ -168,60 +168,6 @@ typedef struct AVHDRVividColorToneMappingParams { */ int three_Spline_num; -#if FF_API_HDR_VIVID_THREE_SPLINE - /** - * The mode of three Spline. the value shall be in the range - * of 0 to 3, inclusive. - * @deprecated Use three_spline instead - */ - attribute_deprecated - int three_Spline_TH_mode; - - /** - * three_Spline_TH_enable_MB is in the range of 0.0 to 1.0, inclusive - * and in multiples of 1.0/255. - * @deprecated Use three_spline instead - */ - attribute_deprecated - AVRational three_Spline_TH_enable_MB; - - /** - * 3Spline_TH_enable of three Spline. - * The value shall be in the range of 0.0 to 1.0, inclusive. - * and in multiples of 1.0/4095. - * @deprecated Use three_spline instead - */ - attribute_deprecated - AVRational three_Spline_TH_enable; - - /** - * 3Spline_TH_Delta1 of three Spline. - * The value shall be in the range of 0.0 to 0.25, inclusive, - * and in multiples of 0.25/1023. - * @deprecated Use three_spline instead - */ - attribute_deprecated - AVRational three_Spline_TH_Delta1; - - /** - * 3Spline_TH_Delta2 of three Spline. - * The value shall be in the range of 0.0 to 0.25, inclusive, - * and in multiples of 0.25/1023. - * @deprecated Use three_spline instead - */ - attribute_deprecated - AVRational three_Spline_TH_Delta2; - - /** - * 3Spline_enable_Strength of three Spline. - * The value shall be in the range of 0.0 to 1.0, inclusive, - * and in multiples of 1.0/255. - * @deprecated Use three_spline instead - */ - attribute_deprecated - AVRational three_Spline_enable_Strength; -#endif - AVHDRVivid3SplineParams three_spline[2]; } AVHDRVividColorToneMappingParams; diff --git a/include/libavutil/hwcontext.h b/include/libavutil/hwcontext.h index bac30debae..29374cf0a7 100755 --- a/include/libavutil/hwcontext.h +++ b/include/libavutil/hwcontext.h @@ -38,6 +38,9 @@ enum AVHWDeviceType { AV_HWDEVICE_TYPE_MEDIACODEC, AV_HWDEVICE_TYPE_VULKAN, AV_HWDEVICE_TYPE_D3D12VA, + AV_HWDEVICE_TYPE_AMF, + /* OpenHarmony Codec device */ + AV_HWDEVICE_TYPE_OHCODEC, }; /** @@ -560,7 +563,7 @@ enum { * 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 + * hw_frames_ctx/format fields they may have been set by the caller - those will * be preserved as they were. * * @param dst Destination frame, to contain the mapping. diff --git a/include/libavutil/hwcontext_amf.h b/include/libavutil/hwcontext_amf.h new file mode 100644 index 0000000000..6f2cabc878 --- /dev/null +++ b/include/libavutil/hwcontext_amf.h @@ -0,0 +1,50 @@ +/* + * 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_AMF_H +#define AVUTIL_HWCONTEXT_AMF_H + +#include "pixfmt.h" +#include "hwcontext.h" +#include +#include +#include +#include + +/** + * This struct is allocated as AVHWDeviceContext.hwctx + */ +typedef struct AVAMFDeviceContext { + void * library; + AMFFactory *factory; + void *trace_writer; + + int64_t version; ///< version of AMF runtime + AMFContext *context; + AMF_MEMORY_TYPE memory_type; + + void (*lock)(void *lock_ctx); + void (*unlock)(void *lock_ctx); + void *lock_ctx; +} AVAMFDeviceContext; + +enum AMF_SURFACE_FORMAT av_av_to_amf_format(enum AVPixelFormat fmt); +enum AVPixelFormat av_amf_to_av_format(enum AMF_SURFACE_FORMAT fmt); + +#endif /* AVUTIL_HWCONTEXT_AMF_H */ diff --git a/include/libavutil/hwcontext_d3d11va.h b/include/libavutil/hwcontext_d3d11va.h index 77d2d72f1b..b87b1e8fa2 100644 --- a/include/libavutil/hwcontext_d3d11va.h +++ b/include/libavutil/hwcontext_d3d11va.h @@ -94,6 +94,20 @@ typedef struct AVD3D11VADeviceContext { void (*lock)(void *lock_ctx); void (*unlock)(void *lock_ctx); void *lock_ctx; + /** + * D3D11_TEXTURE2D_DESC.BindFlags to be applied to D3D11 resources allocated + * for frames using this device context. + * + * It applies globally to all AVD3D11VAFramesContext allocated from this device context. + */ + UINT BindFlags; + /** + * D3D11_TEXTURE2D_DESC.MiscFlags to be applied to D3D11 resources allocated + * for frames using this device context. + * + * It applies globally to all AVD3D11VAFramesContext allocated from this device context. + */ + UINT MiscFlags; } AVD3D11VADeviceContext; /** diff --git a/include/libavutil/hwcontext_d3d12va.h b/include/libavutil/hwcontext_d3d12va.h index 212a6a6146..adbec88173 100644 --- a/include/libavutil/hwcontext_d3d12va.h +++ b/include/libavutil/hwcontext_d3d12va.h @@ -75,6 +75,26 @@ typedef struct AVD3D12VADeviceContext { void (*lock)(void *lock_ctx); void (*unlock)(void *lock_ctx); void *lock_ctx; + + /** + * Resource flags to be applied to D3D12 resources allocated + * for frames using this device context. + * + * If unset, this will be D3D12_RESOURCE_FLAG_NONE. + * + * It applies globally to all AVD3D12VAFramesContext allocated from this device context. + */ + D3D12_RESOURCE_FLAGS resource_flags; + + /** + * Heap flags to be applied to D3D12 resources allocated + * for frames using this device context. + * + * If unset, this will be D3D12_HEAP_FLAG_NONE. + * + * It applies globally to all AVD3D12VAFramesContext allocated from this device context. + */ + D3D12_HEAP_FLAGS heap_flags; } AVD3D12VADeviceContext; /** @@ -99,6 +119,18 @@ typedef struct AVD3D12VASyncContext { uint64_t fence_value; } AVD3D12VASyncContext; +/** + * Define the behaviours of frame allocation. + */ +typedef enum AVD3D12VAFrameFlags { + AV_D3D12VA_FRAME_FLAG_NONE = 0, + + /** + * Indicates that frame data should be allocated using a texture array resource. + */ + AV_D3D12VA_FRAME_FLAG_TEXTURE_ARRAY = (1 << 1), +} AVD3D12VAFrameFlags; + /** * @brief D3D12VA frame descriptor for pool allocation. * @@ -111,12 +143,26 @@ typedef struct AVD3D12VAFrame { */ ID3D12Resource *texture; + /** + * Index of the subresource within the texture. + * + * In texture array mode, this specifies the array slice index. + * When texture array mode is not used, this value is always 0. + */ + int subresource_index; + /** * The sync context for the texture * * @see: https://learn.microsoft.com/en-us/windows/win32/medfound/direct3d-12-video-overview#directx-12-fences */ AVD3D12VASyncContext sync_ctx; + + /** + * A combination of AVD3D12VAFrameFlags. + * Set by AVD3D12VAFramesContext. + */ + AVD3D12VAFrameFlags flags; } AVD3D12VAFrame; /** @@ -136,7 +182,28 @@ typedef struct AVD3D12VAFramesContext { * * @see https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_resource_flags */ - D3D12_RESOURCE_FLAGS flags; + D3D12_RESOURCE_FLAGS resource_flags; + + /** + * Options for working with heaps allocation when creating resources. + * If unset, this will be D3D12_HEAP_FLAG_NONE. + * + * @see https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_heap_flags + */ + D3D12_HEAP_FLAGS heap_flags; + + /** + * In texture array mode, the D3D12 uses the same texture array (resource)for all + * pictures. + */ + ID3D12Resource *texture_array; + + /** + * A combination of AVD3D12VAFrameFlags. Unless AV_D3D12VA_FRAME_FLAG_NONE is set, + * autodetected flags will be OR'd based on the device and frame features during + * av_hwframe_ctx_init(). + */ + AVD3D12VAFrameFlags flags; } AVD3D12VAFramesContext; #endif /* AVUTIL_HWCONTEXT_D3D12VA_H */ diff --git a/include/libavutil/attributes_internal.h b/include/libavutil/hwcontext_oh.h similarity index 56% rename from include/libavutil/attributes_internal.h rename to include/libavutil/hwcontext_oh.h index 3df1ee6af3..2794f85b7d 100644 --- a/include/libavutil/attributes_internal.h +++ b/include/libavutil/hwcontext_oh.h @@ -1,6 +1,8 @@ /* * This file is part of FFmpeg. * + * Copyright (c) 2025 Zhao Zhili + * * 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 @@ -16,19 +18,17 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef AVUTIL_ATTRIBUTES_INTERNAL_H -#define AVUTIL_ATTRIBUTES_INTERNAL_H - -#include "attributes.h" +#ifndef AVUTIL_HWCONTEXT_OH_H +#define AVUTIL_HWCONTEXT_OH_H -#if (AV_GCC_VERSION_AT_LEAST(4,0) || defined(__clang__)) && (defined(__ELF__) || defined(__MACH__)) -# define attribute_visibility_hidden __attribute__((visibility("hidden"))) -# define FF_VISIBILITY_PUSH_HIDDEN _Pragma("GCC visibility push(hidden)") -# define FF_VISIBILITY_POP_HIDDEN _Pragma("GCC visibility pop") -#else -# define attribute_visibility_hidden -# define FF_VISIBILITY_PUSH_HIDDEN -# define FF_VISIBILITY_POP_HIDDEN -#endif +/** + * OpenHarmony codec device + */ +typedef struct AVOHCodecDeviceContext { + /** + * Pointer to OHNativeWindow + */ + void *native_window; +} AVOHCodecDeviceContext; -#endif /* AVUTIL_ATTRIBUTES_INTERNAL_H */ +#endif /* AVUTIL_HWCONTEXT_OH_H */ diff --git a/include/libavutil/hwcontext_opencl.h b/include/libavutil/hwcontext_opencl.h index ef54486c95..22702300ad 100644 --- a/include/libavutil/hwcontext_opencl.h +++ b/include/libavutil/hwcontext_opencl.h @@ -75,7 +75,7 @@ typedef struct AVOpenCLDeviceContext { /** * The default command queue for this device, which will be used by all * frames contexts which do not have their own command queue. If not - * intialised by the user, a default queue will be created on the + * initialised by the user, a default queue will be created on the * primary device. */ cl_command_queue command_queue; diff --git a/include/libavutil/hwcontext_qsv.h b/include/libavutil/hwcontext_qsv.h index 35530e4e93..3c16a8ab98 100644 --- a/include/libavutil/hwcontext_qsv.h +++ b/include/libavutil/hwcontext_qsv.h @@ -84,4 +84,3 @@ typedef struct AVQSVFramesContext { } AVQSVFramesContext; #endif /* AVUTIL_HWCONTEXT_QSV_H */ - diff --git a/include/libavutil/hwcontext_vaapi.h b/include/libavutil/hwcontext_vaapi.h index 0b2e071cb3..82e4194a92 100644 --- a/include/libavutil/hwcontext_vaapi.h +++ b/include/libavutil/hwcontext_vaapi.h @@ -26,7 +26,7 @@ * API-specific header for AV_HWDEVICE_TYPE_VAAPI. * * Dynamic frame pools are supported, but note that any pool used as a render - * target is required to be of fixed size in order to be be usable as an + * target is required to be of fixed size in order to be usable as an * argument to vaCreateContext(). * * For user-allocated pools, AVHWFramesContext.pool must return AVBufferRefs diff --git a/include/libavutil/hwcontext_vulkan.h b/include/libavutil/hwcontext_vulkan.h index 2688a4757b..b9a841a197 100644 --- a/include/libavutil/hwcontext_vulkan.h +++ b/include/libavutil/hwcontext_vulkan.h @@ -97,6 +97,8 @@ typedef struct AVVulkanDeviceContext { * each entry containing the specified Vulkan extension string to enable. * Duplicates are possible and accepted. * If no extensions are enabled, set these fields to NULL, and 0 respectively. + * av_vk_get_optional_instance_extensions() can be used to enumerate extensions + * that FFmpeg may use if enabled. */ const char * const *enabled_inst_extensions; int nb_enabled_inst_extensions; @@ -108,6 +110,8 @@ typedef struct AVVulkanDeviceContext { * If supplying your own device context, these fields takes the same format as * the above fields, with the same conditions that duplicates are possible * and accepted, and that NULL and 0 respectively means no extensions are enabled. + * av_vk_get_optional_device_extensions() can be used to enumerate extensions + * that FFmpeg may use if enabled. */ const char * const *enabled_dev_extensions; int nb_enabled_dev_extensions; @@ -115,7 +119,7 @@ typedef struct AVVulkanDeviceContext { #if FF_API_VULKAN_FIXED_QUEUES /** * Queue family index for graphics operations, and the number of queues - * enabled for it. If unavaiable, will be set to -1. Not required. + * enabled for it. If unavailable, will be set to -1. Not required. * av_hwdevice_create() will attempt to find a dedicated queue for each * queue family, or pick the one with the least unrelated flags set. * Queue indices here may overlap if a queue has to share capabilities. @@ -164,18 +168,26 @@ typedef struct AVVulkanDeviceContext { int nb_decode_queues; #endif +#if FF_API_VULKAN_SYNC_QUEUES /** * Locks a queue, preventing other threads from submitting any command * buffers to this queue. * If set to NULL, will be set to lavu-internal functions that utilize a * mutex. + * + * Deprecated: use VK_KHR_internally_synchronized_queues. */ + attribute_deprecated void (*lock_queue)(struct AVHWDeviceContext *ctx, uint32_t queue_family, uint32_t index); /** * Similar to lock_queue(), unlocks a queue. Must only be called after locking. + * + * Deprecated: use VK_KHR_internally_synchronized_queues. */ + attribute_deprecated void (*unlock_queue)(struct AVHWDeviceContext *ctx, uint32_t queue_family, uint32_t index); +#endif /** * Queue families used. Must be preferentially ordered. List may contain @@ -197,11 +209,6 @@ typedef enum AVVkFrameFlags { * device and tiling during av_hwframe_ctx_init(). */ AV_VK_FRAME_FLAG_NONE = (1ULL << 0), -#if FF_API_VULKAN_CONTIGUOUS_MEMORY - /* DEPRECATED: does nothing. Replaced by multiplane images. */ - AV_VK_FRAME_FLAG_CONTIGUOUS_MEMORY = (1ULL << 1), -#endif - /* Disables multiplane images. * This is required to export/import images from CUDA. */ AV_VK_FRAME_FLAG_DISABLE_MULTIPLANE = (1ULL << 2), @@ -223,7 +230,8 @@ typedef struct AVVulkanFramesContext { /** * Defines extra usage of output frames. If non-zero, all flags MUST be - * supported by the VkFormat. Otherwise, will use supported flags amongst: + * supported by the VkFormat. Regardless, frames will always have the + * following usage flags enabled, if supported by the format: * - VK_IMAGE_USAGE_SAMPLED_BIT * - VK_IMAGE_USAGE_STORAGE_BIT * - VK_IMAGE_USAGE_TRANSFER_SRC_BIT @@ -379,4 +387,18 @@ AVVkFrame *av_vk_frame_alloc(void); */ const VkFormat *av_vkfmt_from_pixfmt(enum AVPixelFormat p); +/** + * Returns an array of optional Vulkan instance extensions that FFmpeg + * may use if enabled. + * @note Must be freed via av_free() + */ +const char **av_vk_get_optional_instance_extensions(int *count); + +/** + * Returns an array of optional Vulkan device extensions that FFmpeg + * may use if enabled. + * @note Must be freed via av_free() + */ +const char **av_vk_get_optional_device_extensions(int *count); + #endif /* AVUTIL_HWCONTEXT_VULKAN_H */ diff --git a/include/libavutil/iamf.h b/include/libavutil/iamf.h index 1fa73893cd..a755e7d682 100644 --- a/include/libavutil/iamf.h +++ b/include/libavutil/iamf.h @@ -213,11 +213,11 @@ typedef struct AVIAMFParamDefinition { enum AVIAMFParamDefinitionType type; /** - * Identifier for the paremeter substream. + * Identifier for the parameter substream. */ unsigned int parameter_id; /** - * Sample rate for the paremeter substream. It must not be 0. + * Sample rate for the parameter substream. It must not be 0. */ unsigned int parameter_rate; @@ -330,14 +330,17 @@ typedef struct AVIAMFLayer { /** * Demixing matrix as defined in section 3.6.3 of IAMF. * - * The length of the array is ch_layout.nb_channels multiplied by the sum of - * the amount of streams in the group plus the amount of streams in the group - * that are stereo. - * * May be set only if @ref ambisonics_mode == AV_IAMF_AMBISONICS_MODE_PROJECTION, * must be NULL otherwise. */ AVRational *demixing_matrix; + + /** + * The length of the Demixing matrix array. Must be ch_layout.nb_channels multiplied + * by the sum of the amount of streams in the group plus the amount of streams in + * the group that are stereo. + */ + unsigned int nb_demixing_matrix; } AVIAMFLayer; @@ -493,10 +496,14 @@ typedef struct AVIAMFSubmixElement { enum AVIAMFSubmixLayoutType { /** * The layout follows the loudspeaker sound system convention of ITU-2051-3. + * @ref AVIAMFSubmixLayout.sound_system must be set. */ AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS = 2, /** * The layout is binaural. + * + * @note @ref AVIAMFSubmixLayout.sound_system may be set to + * AV_CHANNEL_LAYOUT_BINAURAL to simplify API usage, but it's not mandatory. */ AV_IAMF_SUBMIX_LAYOUT_TYPE_BINAURAL = 3, }; @@ -514,9 +521,9 @@ typedef struct AVIAMFSubmixLayout { /** * Channel layout matching one of Sound Systems A to J of ITU-2051-3, plus - * 7.1.2ch and 3.1.2ch - * If layout_type is not AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS, this field - * is undefined. + * 7.1.2ch, 3.1.2ch, and binaural. + * If layout_type is not AV_IAMF_SUBMIX_LAYOUT_TYPE_LOUDSPEAKERS or + * AV_IAMF_SUBMIX_LAYOUT_TYPE_BINAURAL, this field is undefined. */ AVChannelLayout sound_system; /** diff --git a/include/libavutil/lfg.h b/include/libavutil/lfg.h index e75a986f12..043d0ab343 100755 --- a/include/libavutil/lfg.h +++ b/include/libavutil/lfg.h @@ -28,7 +28,7 @@ * Context structure for the Lagged Fibonacci PRNG. * The exact layout, types and content of this struct may change and should * not be accessed directly. Only its `sizeof()` is guaranteed to stay the same - * to allow easy instanciation. + * to allow easy instantiation. */ typedef struct AVLFG { unsigned int state[64]; @@ -73,7 +73,7 @@ static inline unsigned int av_mlfg_get(AVLFG *c){ * Get the next two numbers generated by a Box-Muller Gaussian * generator using the random numbers issued by lfg. * - * @param lfg pointer to the contex structure + * @param lfg pointer to the context structure * @param out array where the two generated numbers are placed */ void av_bmg_get(AVLFG *lfg, double out[2]); diff --git a/include/libavutil/log.h b/include/libavutil/log.h index ab7ceabe22..4a111ca9a5 100755 --- a/include/libavutil/log.h +++ b/include/libavutil/log.h @@ -37,6 +37,7 @@ typedef enum { AV_CLASS_CATEGORY_BITSTREAM_FILTER, AV_CLASS_CATEGORY_SWSCALER, AV_CLASS_CATEGORY_SWRESAMPLER, + AV_CLASS_CATEGORY_HWDEVICE, AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT = 40, AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT, AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT, @@ -46,6 +47,15 @@ typedef enum { AV_CLASS_CATEGORY_NB ///< not part of ABI/API }AVClassCategory; +enum AVClassStateFlags { + /** + * Object initialization has finished and it is now in the 'runtime' stage. + * This affects e.g. what options can be set on the object (only + * AV_OPT_FLAG_RUNTIME_PARAM options can be set on initialized objects). + */ + AV_CLASS_STATE_INITIALIZED = (1 << 0), +}; + #define AV_IS_INPUT_DEVICE(category) \ (((category) == AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT) || \ ((category) == AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT) || \ @@ -77,7 +87,9 @@ typedef struct AVClass { const char* (*item_name)(void* ctx); /** - * a pointer to the first option specified in the class if any or NULL + * An array of options for the structure or NULL. + * When non-NULL, the array must be terminated by an option with a NULL + * name. * * @see av_set_default_options() */ @@ -85,43 +97,50 @@ typedef struct AVClass { /** * LIBAVUTIL_VERSION with which this structure was created. - * This is used to allow fields to be added without requiring major - * version bumps everywhere. + * This is used to allow fields to be added to AVClass without requiring + * major version bumps everywhere. */ int version; /** - * Offset in the structure where log_level_offset is stored. - * 0 means there is no such variable + * Offset in the structure where the log level offset is stored. The log + * level offset is an int added to the log level for logging with this + * object as the context. + * + * 0 means there is no such variable. */ int log_level_offset_offset; /** * Offset in the structure where a pointer to the parent context for * logging is stored. For example a decoder could pass its AVCodecContext - * to eval as such a parent context, which an av_log() implementation + * to eval as such a parent context, which an ::av_log() implementation * could then leverage to display the parent context. - * The offset can be NULL. + * + * When the pointer is NULL, or this offset is zero, the object is assumed + * to have no parent. */ int parent_log_context_offset; /** - * Category used for visualization (like color) - * This is only set if the category is equal for all objects using this class. - * available since version (51 << 16 | 56 << 8 | 100) + * Category used for visualization (like color). + * + * Only used when ::get_category() is NULL. Use this field when all + * instances of this class have the same category, use ::get_category() + * otherwise. */ AVClassCategory category; /** - * Callback to return the category. - * available since version (51 << 16 | 59 << 8 | 100) + * Callback to return the instance category. Use this callback when + * different instances of this class may have different categories, + * ::category otherwise. */ AVClassCategory (*get_category)(void* ctx); /** * Callback to return the supported/allowed ranges. - * available since version (52.12) */ int (*query_ranges)(struct AVOptionRanges **, void *obj, const char *key, int flags); @@ -139,11 +158,22 @@ typedef struct AVClass { * @return AVClass for the next AVOptions-enabled child or NULL if there are * no more such children. * - * @note The difference between child_next and this is that child_next - * iterates over _already existing_ objects, while child_class_iterate - * iterates over _all possible_ children. + * @note The difference between ::child_next() and ::child_class_iterate() + * is that ::child_next() iterates over _actual_ children of an + * _existing_ object instance, while ::child_class_iterate() iterates + * over the classes of all _potential_ children of any possible + * instance of this class. */ const struct AVClass* (*child_class_iterate)(void **iter); + + /** + * When non-zero, offset in the object to an unsigned int holding object + * state flags, a combination of AVClassStateFlags values. The flags are + * updated by the object to signal its state to the generic code. + * + * Added in version 59.41.100. + */ + int state_flags_offset; } AVClass; /** @@ -247,9 +277,9 @@ void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4); * @param avcl A pointer to an arbitrary struct of which the first field is a * pointer to an AVClass struct or NULL if general log. * @param initial_level importance level of the message expressed using a @ref - * lavu_log_constants "Logging Constant" for the first occurance. + * lavu_log_constants "Logging Constant" for the first occurrence. * @param subsequent_level importance level of the message expressed using a @ref - * lavu_log_constants "Logging Constant" after the first occurance. + * lavu_log_constants "Logging Constant" after the first occurrence. * @param fmt The format string (printf-compatible) that specifies how * subsequent arguments are converted to output. * @param state a variable to keep trak of if a message has already been printed @@ -377,6 +407,16 @@ int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl, */ #define AV_LOG_PRINT_LEVEL 2 +/** + * Include system time in log output. + */ +#define AV_LOG_PRINT_TIME 4 + +/** + * Include system date and time in log output. + */ +#define AV_LOG_PRINT_DATETIME 8 + void av_log_set_flags(int arg); int av_log_get_flags(void); diff --git a/include/libavutil/mathematics.h b/include/libavutil/mathematics.h index e213bab68c..486de530f2 100755 --- a/include/libavutil/mathematics.h +++ b/include/libavutil/mathematics.h @@ -278,7 +278,7 @@ int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int /** * Add a value to a timestamp. * - * This function guarantees that when the same value is repeatly added that + * This function guarantees that when the same value is repeatedly added that * no accumulation of rounding errors occurs. * * @param[in] ts Input timestamp diff --git a/include/libavutil/mem_internal.h b/include/libavutil/mem_internal.h deleted file mode 100644 index 20f9b3e3f2..0000000000 --- a/include/libavutil/mem_internal.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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 AVUTIL_MEM_INTERNAL_H -#define AVUTIL_MEM_INTERNAL_H - -#include "config.h" - -#include - -#include "attributes.h" -#include "macros.h" - -/** - * @def DECLARE_ALIGNED(n,t,v) - * Declare a variable that is aligned in memory. - * - * @code{.c} - * DECLARE_ALIGNED(16, uint16_t, aligned_int) = 42; - * DECLARE_ALIGNED(32, uint8_t, aligned_array)[128]; - * - * // The default-alignment equivalent would be - * uint16_t aligned_int = 42; - * uint8_t aligned_array[128]; - * @endcode - * - * @param n Minimum alignment in bytes - * @param t Type of the variable (or array element) - * @param v Name of the variable - */ - -/** - * @def DECLARE_ASM_ALIGNED(n,t,v) - * Declare an aligned variable appropriate for use in inline assembly code. - * - * @code{.c} - * DECLARE_ASM_ALIGNED(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008); - * @endcode - * - * @param n Minimum alignment in bytes - * @param t Type of the variable (or array element) - * @param v Name of the variable - */ - -/** - * @def DECLARE_ASM_CONST(n,t,v) - * Declare a static constant aligned variable appropriate for use in inline - * assembly code. - * - * @code{.c} - * DECLARE_ASM_CONST(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008); - * @endcode - * - * @param n Minimum alignment in bytes - * @param t Type of the variable (or array element) - * @param v Name of the variable - */ - -#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C) - #define DECLARE_ALIGNED_T(n,t,v) t __attribute__ ((aligned (n))) v - #define DECLARE_ASM_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v - #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v -#elif defined(__DJGPP__) - #define DECLARE_ALIGNED_T(n,t,v) t __attribute__ ((aligned (FFMIN(n, 16)))) v - #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v - #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v -#elif defined(__GNUC__) || defined(__clang__) - #define DECLARE_ALIGNED_T(n,t,v) t __attribute__ ((aligned (n))) v - #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (n))) v - #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v -#elif defined(_MSC_VER) - #define DECLARE_ALIGNED_T(n,t,v) __declspec(align(n)) t v - #define DECLARE_ASM_ALIGNED(n,t,v) __declspec(align(n)) t v - #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v -#else - #define DECLARE_ALIGNED_T(n,t,v) t v - #define DECLARE_ASM_ALIGNED(n,t,v) t v - #define DECLARE_ASM_CONST(n,t,v) static const t v -#endif - -#if HAVE_SIMD_ALIGN_64 - #define ALIGN_64 64 - #define ALIGN_32 32 -#elif HAVE_SIMD_ALIGN_32 - #define ALIGN_64 32 - #define ALIGN_32 32 -#else - #define ALIGN_64 16 - #define ALIGN_32 16 -#endif - -#define DECLARE_ALIGNED(n,t,v) DECLARE_ALIGNED_V(n,t,v) - -// Macro needs to be double-wrapped in order to expand -// possible other macros being passed for n. -#define DECLARE_ALIGNED_V(n,t,v) DECLARE_ALIGNED_##n(t,v) - -#define DECLARE_ALIGNED_4(t,v) DECLARE_ALIGNED_T( 4, t, v) -#define DECLARE_ALIGNED_8(t,v) DECLARE_ALIGNED_T( 8, t, v) -#define DECLARE_ALIGNED_16(t,v) DECLARE_ALIGNED_T( 16, t, v) -#define DECLARE_ALIGNED_32(t,v) DECLARE_ALIGNED_T(ALIGN_32, t, v) -#define DECLARE_ALIGNED_64(t,v) DECLARE_ALIGNED_T(ALIGN_64, t, v) - -// Some broken preprocessors need a second expansion -// to be forced to tokenize __VA_ARGS__ -#define E1(x) x - -#define LOCAL_ALIGNED_A(a, t, v, s, o, ...) \ - uint8_t la_##v[sizeof(t s o) + (a)]; \ - t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a) - -#define LOCAL_ALIGNED_D(a, t, v, s, o, ...) \ - DECLARE_ALIGNED(a, t, la_##v) s o; \ - t (*v) o = la_##v - -#define LOCAL_ALIGNED(a, t, v, ...) LOCAL_ALIGNED_##a(t, v, __VA_ARGS__) - -#if HAVE_LOCAL_ALIGNED -# define LOCAL_ALIGNED_4(t, v, ...) E1(LOCAL_ALIGNED_D(4, t, v, __VA_ARGS__,,)) -#else -# define LOCAL_ALIGNED_4(t, v, ...) E1(LOCAL_ALIGNED_A(4, t, v, __VA_ARGS__,,)) -#endif - -#if HAVE_LOCAL_ALIGNED -# define LOCAL_ALIGNED_8(t, v, ...) E1(LOCAL_ALIGNED_D(8, t, v, __VA_ARGS__,,)) -#else -# define LOCAL_ALIGNED_8(t, v, ...) E1(LOCAL_ALIGNED_A(8, t, v, __VA_ARGS__,,)) -#endif - -#if HAVE_LOCAL_ALIGNED -# define LOCAL_ALIGNED_16(t, v, ...) E1(LOCAL_ALIGNED_D(16, t, v, __VA_ARGS__,,)) -#else -# define LOCAL_ALIGNED_16(t, v, ...) E1(LOCAL_ALIGNED_A(16, t, v, __VA_ARGS__,,)) -#endif - -#if HAVE_LOCAL_ALIGNED -# define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_D(32, t, v, __VA_ARGS__,,)) -#else -# define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_A(32, t, v, __VA_ARGS__,,)) -#endif - -#endif /* AVUTIL_MEM_INTERNAL_H */ diff --git a/include/libavutil/opt.h b/include/libavutil/opt.h index be189f7653..ab24fae777 100755 --- a/include/libavutil/opt.h +++ b/include/libavutil/opt.h @@ -542,7 +542,7 @@ typedef struct AVOptionRanges { */ int nb_ranges; /** - * Number of componentes. + * Number of components. */ int nb_components; } AVOptionRanges; @@ -886,6 +886,7 @@ int av_opt_set_chlayout(void *obj, const char *name, const AVChannelLayout *layo */ int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags); +#if FF_API_OPT_INT_LIST /** * Set a binary option to an integer list. * @@ -901,6 +902,7 @@ int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, in AVERROR(EINVAL) : \ av_opt_set_bin(obj, name, (const uint8_t *)(val), \ av_int_list_length(val, term) * sizeof(*(val)), flags)) +#endif /** * Add, replace, or remove elements for an array option. Which of these @@ -1069,6 +1071,7 @@ int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational * @} */ +#if FF_API_OPT_PTR /** * Gets a pointer to the requested field in a struct. * This function allows accessing a struct even when its fields are moved or @@ -1076,8 +1079,12 @@ int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational * * @returns a pointer to the field, it can be cast to the correct type and read * or written to. + * + * @deprecated direct access to AVOption-exported fields is not supported */ +attribute_deprecated void *av_opt_ptr(const AVClass *avclass, void *obj, const char *name); +#endif /** * Check if given option is set to its default value. @@ -1130,7 +1137,7 @@ int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name) * @param[in] obj AVClass object to serialize * @param[in] opt_flags serialize options with all the specified flags set (AV_OPT_FLAG) * @param[in] flags combination of AV_OPT_SERIALIZE_* flags - * @param[out] buffer Pointer to buffer that will be allocated with string containg serialized options. + * @param[out] buffer Pointer to buffer that will be allocated with string containing serialized options. * Buffer must be freed by the caller when is no longer needed. * @param[in] key_val_sep character used to separate key from value * @param[in] pairs_sep character used to separate two pairs from each other @@ -1160,7 +1167,7 @@ void av_opt_freep_ranges(AVOptionRanges **ranges); * * The result must be freed with av_opt_freep_ranges. * - * @return number of compontents returned on success, a negative errro code otherwise + * @return number of components returned on success, a negative error code otherwise */ int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags); @@ -1176,7 +1183,7 @@ int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags * * The result must be freed with av_opt_free_ranges. * - * @return number of compontents returned on success, a negative errro code otherwise + * @return number of components returned on success, a negative error code otherwise */ int av_opt_query_ranges_default(AVOptionRanges **, void *obj, const char *key, int flags); diff --git a/include/libavutil/pixdesc.h b/include/libavutil/pixdesc.h index ba2f632814..0cc70eb64c 100755 --- a/include/libavutil/pixdesc.h +++ b/include/libavutil/pixdesc.h @@ -291,6 +291,16 @@ int av_chroma_location_enum_to_pos(int *xpos, int *ypos, enum AVChromaLocation p */ enum AVChromaLocation av_chroma_location_pos_to_enum(int xpos, int ypos); +/** + * @return the name for provided alpha mode or NULL if unknown. + */ +const char *av_alpha_mode_name(enum AVAlphaMode mode); + +/** + * @return the AVAlphaMode value for name or an AVError if not found. + */ +enum AVAlphaMode av_alpha_mode_from_name(const char *name); + /** * Return the pixel format corresponding to name. * diff --git a/include/libavutil/pixfmt.h b/include/libavutil/pixfmt.h index a7f50e1690..2e7b6457e0 100755 --- a/include/libavutil/pixfmt.h +++ b/include/libavutil/pixfmt.h @@ -398,12 +398,12 @@ enum AVPixelFormat { 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_VUYA, ///< packed VUYA 4:4:4, 32bpp, VUYAVUYA... + AV_PIX_FMT_VUYA, ///< packed VUYA 4:4:4:4, 32bpp (1 Cr & Cb sample per 1x1 Y & A samples), VUYAVUYA... AV_PIX_FMT_RGBAF16BE, ///< IEEE-754 half precision packed RGBA 16:16:16:16, 64bpp, RGBARGBA..., big-endian AV_PIX_FMT_RGBAF16LE, ///< IEEE-754 half precision packed RGBA 16:16:16:16, 64bpp, RGBARGBA..., little-endian - AV_PIX_FMT_VUYX, ///< packed VUYX 4:4:4, 32bpp, Variant of VUYA where alpha channel is left undefined + AV_PIX_FMT_VUYX, ///< packed VUYX 4:4:4:4, 32bpp, Variant of VUYA where alpha channel is left undefined AV_PIX_FMT_P012LE, ///< like NV12, with 12bpp per component, data in the high bits, zeros in the low bits, little-endian AV_PIX_FMT_P012BE, ///< like NV12, with 12bpp per component, data in the high bits, zeros in the low bits, big-endian @@ -439,6 +439,66 @@ enum AVPixelFormat { */ AV_PIX_FMT_D3D12, + AV_PIX_FMT_AYUV, ///< packed AYUV 4:4:4:4, 32bpp (1 Cr & Cb sample per 1x1 Y & A samples), AYUVAYUV... + + AV_PIX_FMT_UYVA, ///< packed UYVA 4:4:4:4, 32bpp (1 Cr & Cb sample per 1x1 Y & A samples), UYVAUYVA... + + AV_PIX_FMT_VYU444, ///< packed VYU 4:4:4, 24bpp (1 Cr & Cb sample per 1x1 Y), VYUVYU... + + AV_PIX_FMT_V30XBE, ///< packed VYUX 4:4:4 like XV30, 32bpp, (msb)10V 10Y 10U 2X(lsb), big-endian + AV_PIX_FMT_V30XLE, ///< packed VYUX 4:4:4 like XV30, 32bpp, (msb)10V 10Y 10U 2X(lsb), little-endian + + AV_PIX_FMT_RGBF16BE, ///< IEEE-754 half precision packed RGB 16:16:16, 48bpp, RGBRGB..., big-endian + AV_PIX_FMT_RGBF16LE, ///< IEEE-754 half precision packed RGB 16:16:16, 48bpp, RGBRGB..., little-endian + + AV_PIX_FMT_RGBA128BE, ///< packed RGBA 32:32:32:32, 128bpp, RGBARGBA..., big-endian + AV_PIX_FMT_RGBA128LE, ///< packed RGBA 32:32:32:32, 128bpp, RGBARGBA..., little-endian + + AV_PIX_FMT_RGB96BE, ///< packed RGBA 32:32:32, 96bpp, RGBRGB..., big-endian + AV_PIX_FMT_RGB96LE, ///< packed RGBA 32:32:32, 96bpp, RGBRGB..., little-endian + + AV_PIX_FMT_Y216BE, ///< packed YUV 4:2:2 like YUYV422, 32bpp, big-endian + AV_PIX_FMT_Y216LE, ///< packed YUV 4:2:2 like YUYV422, 32bpp, little-endian + + AV_PIX_FMT_XV48BE, ///< packed XVYU 4:4:4, 64bpp, big-endian, variant of Y416 where alpha channel is left undefined + AV_PIX_FMT_XV48LE, ///< packed XVYU 4:4:4, 64bpp, little-endian, variant of Y416 where alpha channel is left undefined + + AV_PIX_FMT_GBRPF16BE, ///< IEEE-754 half precision planer GBR 4:4:4, 48bpp, big-endian + AV_PIX_FMT_GBRPF16LE, ///< IEEE-754 half precision planer GBR 4:4:4, 48bpp, little-endian + AV_PIX_FMT_GBRAPF16BE, ///< IEEE-754 half precision planar GBRA 4:4:4:4, 64bpp, big-endian + AV_PIX_FMT_GBRAPF16LE, ///< IEEE-754 half precision planar GBRA 4:4:4:4, 64bpp, little-endian + + AV_PIX_FMT_GRAYF16BE, ///< IEEE-754 half precision Y, 16bpp, big-endian + AV_PIX_FMT_GRAYF16LE, ///< IEEE-754 half precision Y, 16bpp, little-endian + + /** + * HW acceleration through AMF. data[0] contain AMFSurface pointer + */ + AV_PIX_FMT_AMF_SURFACE, + + AV_PIX_FMT_GRAY32BE, ///< Y , 32bpp, big-endian + AV_PIX_FMT_GRAY32LE, ///< Y , 32bpp, little-endian + + AV_PIX_FMT_YAF32BE, ///< IEEE-754 single precision packed YA, 32 bits gray, 32 bits alpha, 64bpp, big-endian + AV_PIX_FMT_YAF32LE, ///< IEEE-754 single precision packed YA, 32 bits gray, 32 bits alpha, 64bpp, little-endian + + AV_PIX_FMT_YAF16BE, ///< IEEE-754 half precision packed YA, 16 bits gray, 16 bits alpha, 32bpp, big-endian + AV_PIX_FMT_YAF16LE, ///< IEEE-754 half precision packed YA, 16 bits gray, 16 bits alpha, 32bpp, little-endian + + AV_PIX_FMT_GBRAP32BE, ///< planar GBRA 4:4:4:4 128bpp, big-endian + AV_PIX_FMT_GBRAP32LE, ///< planar GBRA 4:4:4:4 128bpp, little-endian + + AV_PIX_FMT_YUV444P10MSBBE, ///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), lowest bits zero, big-endian + AV_PIX_FMT_YUV444P10MSBLE, ///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), lowest bits zero, little-endian + AV_PIX_FMT_YUV444P12MSBBE, ///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), lowest bits zero, big-endian + AV_PIX_FMT_YUV444P12MSBLE, ///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), lowest bits zero, little-endian + AV_PIX_FMT_GBRP10MSBBE, ///< planar GBR 4:4:4 30bpp, lowest bits zero, big-endian + AV_PIX_FMT_GBRP10MSBLE, ///< planar GBR 4:4:4 30bpp, lowest bits zero, little-endian + AV_PIX_FMT_GBRP12MSBBE, ///< planar GBR 4:4:4 36bpp, lowest bits zero, big-endian + AV_PIX_FMT_GBRP12MSBLE, ///< planar GBR 4:4:4 36bpp, lowest bits zero, little-endian + + AV_PIX_FMT_OHCODEC, /// hardware decoding through openharmony + 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 }; @@ -460,6 +520,7 @@ enum AVPixelFormat { #define AV_PIX_FMT_GRAY12 AV_PIX_FMT_NE(GRAY12BE, GRAY12LE) #define AV_PIX_FMT_GRAY14 AV_PIX_FMT_NE(GRAY14BE, GRAY14LE) #define AV_PIX_FMT_GRAY16 AV_PIX_FMT_NE(GRAY16BE, GRAY16LE) +#define AV_PIX_FMT_GRAY32 AV_PIX_FMT_NE(GRAY32BE, GRAY32LE) #define AV_PIX_FMT_YA16 AV_PIX_FMT_NE(YA16BE, YA16LE) #define AV_PIX_FMT_RGB48 AV_PIX_FMT_NE(RGB48BE, RGB48LE) #define AV_PIX_FMT_RGB565 AV_PIX_FMT_NE(RGB565BE, RGB565LE) @@ -490,6 +551,9 @@ enum AVPixelFormat { #define AV_PIX_FMT_YUV422P16 AV_PIX_FMT_NE(YUV422P16BE, YUV422P16LE) #define AV_PIX_FMT_YUV444P16 AV_PIX_FMT_NE(YUV444P16BE, YUV444P16LE) +#define AV_PIX_FMT_YUV444P10MSB AV_PIX_FMT_NE(YUV444P10MSBBE, YUV444P10MSBLE) +#define AV_PIX_FMT_YUV444P12MSB AV_PIX_FMT_NE(YUV444P12MSBBE, YUV444P12MSBLE) + #define AV_PIX_FMT_GBRP9 AV_PIX_FMT_NE(GBRP9BE , GBRP9LE) #define AV_PIX_FMT_GBRP10 AV_PIX_FMT_NE(GBRP10BE, GBRP10LE) #define AV_PIX_FMT_GBRP12 AV_PIX_FMT_NE(GBRP12BE, GBRP12LE) @@ -499,17 +563,27 @@ enum AVPixelFormat { #define AV_PIX_FMT_GBRAP12 AV_PIX_FMT_NE(GBRAP12BE, GBRAP12LE) #define AV_PIX_FMT_GBRAP14 AV_PIX_FMT_NE(GBRAP14BE, GBRAP14LE) #define AV_PIX_FMT_GBRAP16 AV_PIX_FMT_NE(GBRAP16BE, GBRAP16LE) +#define AV_PIX_FMT_GBRAP32 AV_PIX_FMT_NE(GBRAP32BE, GBRAP32LE) + +#define AV_PIX_FMT_GBRP10MSB AV_PIX_FMT_NE(GBRP10MSBBE, GBRP10MSBLE) +#define AV_PIX_FMT_GBRP12MSB AV_PIX_FMT_NE(GBRP12MSBBE, GBRP12MSBLE) #define AV_PIX_FMT_BAYER_BGGR16 AV_PIX_FMT_NE(BAYER_BGGR16BE, BAYER_BGGR16LE) #define AV_PIX_FMT_BAYER_RGGB16 AV_PIX_FMT_NE(BAYER_RGGB16BE, BAYER_RGGB16LE) #define AV_PIX_FMT_BAYER_GBRG16 AV_PIX_FMT_NE(BAYER_GBRG16BE, BAYER_GBRG16LE) #define AV_PIX_FMT_BAYER_GRBG16 AV_PIX_FMT_NE(BAYER_GRBG16BE, BAYER_GRBG16LE) +#define AV_PIX_FMT_GBRPF16 AV_PIX_FMT_NE(GBRPF16BE, GBRPF16LE) +#define AV_PIX_FMT_GBRAPF16 AV_PIX_FMT_NE(GBRAPF16BE, GBRAPF16LE) #define AV_PIX_FMT_GBRPF32 AV_PIX_FMT_NE(GBRPF32BE, GBRPF32LE) #define AV_PIX_FMT_GBRAPF32 AV_PIX_FMT_NE(GBRAPF32BE, GBRAPF32LE) +#define AV_PIX_FMT_GRAYF16 AV_PIX_FMT_NE(GRAYF16BE, GRAYF16LE) #define AV_PIX_FMT_GRAYF32 AV_PIX_FMT_NE(GRAYF32BE, GRAYF32LE) +#define AV_PIX_FMT_YAF16 AV_PIX_FMT_NE(YAF16BE, YAF16LE) +#define AV_PIX_FMT_YAF32 AV_PIX_FMT_NE(YAF32BE, YAF32LE) + #define AV_PIX_FMT_YUVA420P9 AV_PIX_FMT_NE(YUVA420P9BE , YUVA420P9LE) #define AV_PIX_FMT_YUVA422P9 AV_PIX_FMT_NE(YUVA422P9BE , YUVA422P9LE) #define AV_PIX_FMT_YUVA444P9 AV_PIX_FMT_NE(YUVA444P9BE , YUVA444P9LE) @@ -531,8 +605,11 @@ enum AVPixelFormat { #define AV_PIX_FMT_Y210 AV_PIX_FMT_NE(Y210BE, Y210LE) #define AV_PIX_FMT_Y212 AV_PIX_FMT_NE(Y212BE, Y212LE) +#define AV_PIX_FMT_Y216 AV_PIX_FMT_NE(Y216BE, Y216LE) #define AV_PIX_FMT_XV30 AV_PIX_FMT_NE(XV30BE, XV30LE) #define AV_PIX_FMT_XV36 AV_PIX_FMT_NE(XV36BE, XV36LE) +#define AV_PIX_FMT_XV48 AV_PIX_FMT_NE(XV48BE, XV48LE) +#define AV_PIX_FMT_V30X AV_PIX_FMT_NE(V30XBE, V30XLE) #define AV_PIX_FMT_X2RGB10 AV_PIX_FMT_NE(X2RGB10BE, X2RGB10LE) #define AV_PIX_FMT_X2BGR10 AV_PIX_FMT_NE(X2BGR10BE, X2BGR10LE) @@ -543,11 +620,15 @@ enum AVPixelFormat { #define AV_PIX_FMT_P216 AV_PIX_FMT_NE(P216BE, P216LE) #define AV_PIX_FMT_P416 AV_PIX_FMT_NE(P416BE, P416LE) +#define AV_PIX_FMT_RGBF16 AV_PIX_FMT_NE(RGBF16BE, RGBF16LE) #define AV_PIX_FMT_RGBAF16 AV_PIX_FMT_NE(RGBAF16BE, RGBAF16LE) #define AV_PIX_FMT_RGBF32 AV_PIX_FMT_NE(RGBF32BE, RGBF32LE) #define AV_PIX_FMT_RGBAF32 AV_PIX_FMT_NE(RGBAF32BE, RGBAF32LE) +#define AV_PIX_FMT_RGB96 AV_PIX_FMT_NE(RGB96BE, RGB96LE) +#define AV_PIX_FMT_RGBA128 AV_PIX_FMT_NE(RGBA128BE, RGBA128LE) + /** * Chromaticity coordinates of the source primaries. * These values match the ones defined by ISO/IEC 23091-2_2019 subclause 8.1 and ITU-T H.273. @@ -570,7 +651,12 @@ enum AVColorPrimaries { AVCOL_PRI_SMPTE432 = 12, ///< SMPTE ST 432-1 (2010) / P3 D65 / Display P3 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 + AVCOL_PRI_NB, ///< Not part of ABI + + /* The following entries are not part of H.273, but custom extensions */ + AVCOL_PRI_EXT_BASE = 256, + AVCOL_PRI_V_GAMUT = AVCOL_PRI_EXT_BASE, + AVCOL_PRI_EXT_NB ///< Not part of ABI }; /** @@ -599,7 +685,12 @@ enum AVColorTransferCharacteristic { AVCOL_TRC_SMPTE428 = 17, ///< SMPTE ST 428-1 AVCOL_TRC_SMPTEST428_1 = AVCOL_TRC_SMPTE428, AVCOL_TRC_ARIB_STD_B67 = 18, ///< ARIB STD-B67, known as "Hybrid log-gamma" - AVCOL_TRC_NB ///< Not part of ABI + AVCOL_TRC_NB, ///< Not part of ABI + + /* The following entries are not part of H.273, but custom extensions */ + AVCOL_TRC_EXT_BASE = 256, + AVCOL_TRC_V_LOG = AVCOL_TRC_EXT_BASE, + AVCOL_TRC_EXT_NB ///< Not part of ABI }; /** @@ -713,4 +804,14 @@ enum AVChromaLocation { AVCHROMA_LOC_NB ///< Not part of ABI }; +/** + * Correlation between the alpha channel and color values. + */ +enum AVAlphaMode { + AVALPHA_MODE_UNSPECIFIED = 0, ///< Unknown alpha handling, or no alpha channel + AVALPHA_MODE_PREMULTIPLIED = 1, ///< Alpha channel is multiplied into color values + AVALPHA_MODE_STRAIGHT = 2, ///< Alpha channel is independent of color values + AVALPHA_MODE_NB ///< Not part of ABI +}; + #endif /* AVUTIL_PIXFMT_H */ diff --git a/include/libavutil/rational.h b/include/libavutil/rational.h index 849f47f38d..30ac2aced7 100755 --- a/include/libavutil/rational.h +++ b/include/libavutil/rational.h @@ -22,7 +22,7 @@ /** * @file * @ingroup lavu_math_rational - * Utilties for rational number calculation. + * Utilities for rational number calculation. * @author Michael Niedermayer */ diff --git a/include/libavutil/rc4.h b/include/libavutil/rc4.h index bf0ca6e942..0c72a88ecd 100755 --- a/include/libavutil/rc4.h +++ b/include/libavutil/rc4.h @@ -43,7 +43,7 @@ AVRC4 *av_rc4_alloc(void); * @brief Initializes an AVRC4 context. * * @param d pointer to the AVRC4 context - * @param key buffer containig the key + * @param key buffer containing the key * @param key_bits must be a multiple of 8 * @param decrypt 0 for encryption, 1 for decryption, currently has no effect * @return zero on success, negative value otherwise diff --git a/include/libavutil/refstruct.h b/include/libavutil/refstruct.h new file mode 100644 index 0000000000..4e9d78eb0a --- /dev/null +++ b/include/libavutil/refstruct.h @@ -0,0 +1,297 @@ +/* + * 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_REFSTRUCT_H +#define AVUTIL_REFSTRUCT_H + +#include + +/** + * RefStruct is an API for creating reference-counted objects + * with minimal overhead. The API is designed for objects, + * not buffers like the AVBuffer API. The main differences + * to the AVBuffer API are as follows: + * + * - It uses void* instead of uint8_t* as its base type due to + * its focus on objects. + * - There are no equivalents of AVBuffer and AVBufferRef. + * E.g. there is no way to get the usable size of the object: + * The user is supposed to know what is at the other end of + * the pointer. It also avoids one level of indirection. + * - Custom allocators are not supported. This allows to simplify + * the implementation and reduce the amount of allocations. + * - It also has the advantage that the user's free callback need + * only free the resources owned by the object, but not the + * object itself. + * - Because referencing (and replacing) an object managed by the + * RefStruct API does not involve allocations, they can not fail + * and therefore need not be checked. + * + * @note Referencing and unreferencing the buffers is thread-safe and thus + * may be done from multiple threads simultaneously without any need for + * additional locking. + */ + +/** + * This union is used for all opaque parameters in this API to spare the user + * to cast const away in case the opaque to use is const-qualified. + * + * The functions provided by this API with an AVRefStructOpaque come in pairs + * named foo_c and foo. The foo function accepts void* as opaque and is just + * a wrapper around the foo_c function; "_c" means "(potentially) const". + */ +typedef union { + void *nc; + const void *c; +} AVRefStructOpaque; + +/** + * If this flag is set in av_refstruct_alloc_ext_c(), the object will not + * be initially zeroed. + */ +#define AV_REFSTRUCT_FLAG_NO_ZEROING (1 << 0) + +/** + * Allocate a refcounted object of usable size `size` managed via + * the RefStruct API. + * + * By default (in the absence of flags to the contrary), + * the returned object is initially zeroed. + * + * @param size Desired usable size of the returned object. + * @param flags A bitwise combination of AV_REFSTRUCT_FLAG_* flags. + * @param opaque A pointer that will be passed to the free_cb callback. + * @param free_cb A callback for freeing this object's content + * when its reference count reaches zero; + * it must not free the object itself. + * @return A pointer to an object of the desired size or NULL on failure. + */ +void *av_refstruct_alloc_ext_c(size_t size, unsigned flags, AVRefStructOpaque opaque, + void (*free_cb)(AVRefStructOpaque opaque, void *obj)); + +/** + * A wrapper around av_refstruct_alloc_ext_c() for the common case + * of a non-const qualified opaque. + * + * @see av_refstruct_alloc_ext_c() + */ +static inline +void *av_refstruct_alloc_ext(size_t size, unsigned flags, void *opaque, + void (*free_cb)(AVRefStructOpaque opaque, void *obj)) +{ + return av_refstruct_alloc_ext_c(size, flags, (AVRefStructOpaque){.nc = opaque}, + free_cb); +} + +/** + * Equivalent to av_refstruct_alloc_ext(size, 0, NULL, NULL) + */ +static inline +void *av_refstruct_allocz(size_t size) +{ + return av_refstruct_alloc_ext(size, 0, NULL, NULL); +} + +/** + * Decrement the reference count of the underlying object and automatically + * free the object if there are no more references to it. + * + * `*objp == NULL` is legal and a no-op. + * + * @param objp Pointer to a pointer that is either NULL or points to an object + * managed via this API. `*objp` is set to NULL on return. + */ +void av_refstruct_unref(void *objp); + +/** + * Create a new reference to an object managed via this API, + * i.e. increment the reference count of the underlying object + * and return obj. + * @return a pointer equal to obj. + */ +void *av_refstruct_ref(void *obj); + +/** + * Analog of av_refstruct_ref(), but for constant objects. + * @see av_refstruct_ref() + */ +const void *av_refstruct_ref_c(const void *obj); + +/** + * Ensure `*dstp` refers to the same object as src. + * + * If `*dstp` is already equal to src, do nothing. Otherwise unreference `*dstp` + * and replace it with a new reference to src in case `src != NULL` (this + * involves incrementing the reference count of src's underlying object) or + * with NULL otherwise. + * + * @param dstp Pointer to a pointer that is either NULL or points to an object + * managed via this API. + * @param src A pointer to an object managed via this API or NULL. + */ +void av_refstruct_replace(void *dstp, const void *src); + +/** + * Check whether the reference count of an object managed + * via this API is 1. + * + * @param obj A pointer to an object managed via this API. + * @return 1 if the reference count of obj is 1; 0 otherwise. + */ +int av_refstruct_exclusive(const void *obj); + +/** + * AVRefStructPool is an API for a thread-safe pool of objects managed + * via the RefStruct API. + * + * Frequently allocating and freeing large or complicated objects may be slow + * and wasteful. This API is meant to solve this in cases when the caller + * needs a set of interchangeable objects. + * + * At the beginning, the user must call allocate the pool via + * av_refstruct_pool_alloc() or its analogue av_refstruct_pool_alloc_ext(). + * Then whenever an object is needed, call av_refstruct_pool_get() to + * get a new or reused object from the pool. This new object works in all + * aspects the same way as the ones created by av_refstruct_alloc_ext(). + * However, when the last reference to this object is unreferenced, it is + * (optionally) reset and returned to the pool instead of being freed and + * will be reused for subsequent av_refstruct_pool_get() calls. + * + * When the caller is done with the pool and no longer needs to create any new + * objects, av_refstruct_pool_uninit() must be called to mark the pool as + * freeable. Then entries returned to the pool will then be freed. + * Once all the entries are freed, the pool will automatically be freed. + * + * Allocating and releasing objects with this API is thread-safe as long as + * the user-supplied callbacks (if provided) are thread-safe. + */ + +/** + * The buffer pool. This structure is opaque and not meant to be accessed + * directly. It is allocated with the allocators below and freed with + * av_refstruct_pool_uninit(). + */ +typedef struct AVRefStructPool AVRefStructPool; + +/** + * If this flag is not set, every object in the pool will be zeroed before + * the init callback is called or before it is turned over to the user + * for the first time if no init callback has been provided. + */ +#define AV_REFSTRUCT_POOL_FLAG_NO_ZEROING AV_REFSTRUCT_FLAG_NO_ZEROING +/** + * If this flag is set and both init_cb and reset_cb callbacks are provided, + * then reset_cb will be called if init_cb fails. + * The object passed to reset_cb will be in the state left by init_cb. + */ +#define AV_REFSTRUCT_POOL_FLAG_RESET_ON_INIT_ERROR (1 << 16) +/** + * If this flag is set and both init_cb and free_entry_cb callbacks are + * provided, then free_cb will be called if init_cb fails. + * + * It will be called after reset_cb in case reset_cb and the + * AV_REFSTRUCT_POOL_FLAG_RESET_ON_INIT_ERROR flag are also set. + * + * The object passed to free_cb will be in the state left by + * the callbacks applied earlier (init_cb potentially followed by reset_cb). + */ +#define AV_REFSTRUCT_POOL_FLAG_FREE_ON_INIT_ERROR (1 << 17) +/** + * If this flag is set, the entries will be zeroed before + * being returned to the user (after the init or reset callbacks + * have been called (if provided)). Furthermore, to avoid zeroing twice + * it also makes the pool behave as if the AV_REFSTRUCT_POOL_FLAG_NO_ZEROING + * flag had been provided. + */ +#define AV_REFSTRUCT_POOL_FLAG_ZERO_EVERY_TIME (1 << 18) + +/** + * Equivalent to av_refstruct_pool_alloc(size, flags, NULL, NULL, NULL, NULL, NULL) + */ +AVRefStructPool *av_refstruct_pool_alloc(size_t size, unsigned flags); + +/** + * Allocate an AVRefStructPool, potentially using complex callbacks. + * + * @param size size of the entries of the pool + * @param flags a bitwise combination of AV_REFSTRUCT_POOL_FLAG_* flags + * @param opaque A pointer that will be passed to the callbacks below. + * @param init A callback that will be called directly after a new entry + * has been allocated. obj has already been zeroed unless + * the AV_REFSTRUCT_POOL_FLAG_NO_ZEROING flag is in use. + * @param reset A callback that will be called after an entry has been + * returned to the pool and before it is reused. + * @param free_entry A callback that will be called when an entry is freed + * after the pool has been marked as to be uninitialized. + * @param free A callback that will be called when the pool itself is + * freed (after the last entry has been returned and freed). + */ +AVRefStructPool *av_refstruct_pool_alloc_ext_c(size_t size, unsigned flags, + AVRefStructOpaque opaque, + int (*init_cb)(AVRefStructOpaque opaque, void *obj), + void (*reset_cb)(AVRefStructOpaque opaque, void *obj), + void (*free_entry_cb)(AVRefStructOpaque opaque, void *obj), + void (*free_cb)(AVRefStructOpaque opaque)); + +/** + * A wrapper around av_refstruct_pool_alloc_ext_c() for the common case + * of a non-const qualified opaque. + * + * @see av_refstruct_pool_alloc_ext_c() + */ +static inline +AVRefStructPool *av_refstruct_pool_alloc_ext(size_t size, unsigned flags, + void *opaque, + int (*init_cb)(AVRefStructOpaque opaque, void *obj), + void (*reset_cb)(AVRefStructOpaque opaque, void *obj), + void (*free_entry_cb)(AVRefStructOpaque opaque, void *obj), + void (*free_cb)(AVRefStructOpaque opaque)) +{ + return av_refstruct_pool_alloc_ext_c(size, flags, (AVRefStructOpaque){.nc = opaque}, + init_cb, reset_cb, free_entry_cb, free_cb); +} + +/** + * Get an object from the pool, reusing an old one from the pool when + * available. + * + * Every call to this function must happen before av_refstruct_pool_uninit(). + * Otherwise undefined behaviour may occur. + * + * @param pool the pool from which to get the object + * @return a reference to the object on success, NULL on error. + */ +void *av_refstruct_pool_get(AVRefStructPool *pool); + +/** + * Mark the pool as being available for freeing. It will actually be freed + * only once all the allocated buffers associated with the pool are released. + * Thus it is safe to call this function while some of the allocated buffers + * are still in use. + * + * It is illegal to try to get a new entry after this function has been called. + * + * @param poolp pointer to a pointer to either NULL or a pool to be freed. + * `*poolp` will be set to NULL. + */ +static inline void av_refstruct_pool_uninit(AVRefStructPool **poolp) +{ + av_refstruct_unref(poolp); +} + +#endif /* AVUTIL_REFSTRUCT_H */ diff --git a/include/libavutil/samplefmt.h b/include/libavutil/samplefmt.h index 43a57a422c..6e55d71140 100755 --- a/include/libavutil/samplefmt.h +++ b/include/libavutil/samplefmt.h @@ -122,8 +122,7 @@ enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt); * @param sample_fmt the number of the sample format to print the * corresponding info string, or a negative value to print the * corresponding header. - * @return the pointer to the filled buffer or NULL if sample_fmt is - * unknown or in case of other errors + * @return the pointer to the filled buffer or NULL in case of other errors */ char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt); diff --git a/include/libavutil/spherical.h b/include/libavutil/spherical.h index 2e90f7752d..4b78978eb9 100644 --- a/include/libavutil/spherical.h +++ b/include/libavutil/spherical.h @@ -82,6 +82,12 @@ enum AVSphericalProjection { * See: https://developer.apple.com/documentation/coremedia/cmprojectiontype/fisheye */ AV_SPHERICAL_FISHEYE, + + /** + * Parametric Immersive projection (Apple). + * See: https://developer.apple.com/documentation/coremedia/cmprojectiontype/parametricimmersive + */ + AV_SPHERICAL_PARAMETRIC_IMMERSIVE, }; /** diff --git a/include/libavutil/tdrdi.h b/include/libavutil/tdrdi.h new file mode 100644 index 0000000000..8629775a2b --- /dev/null +++ b/include/libavutil/tdrdi.h @@ -0,0 +1,164 @@ +/* + * 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 + * @ingroup lavu_video_3d_reference_displays_info + * Spherical video + */ + +#ifndef AVUTIL_TDRDI_H +#define AVUTIL_TDRDI_H + +#include +#include + +#include "libavutil/avassert.h" + +/** + * @defgroup lavu_video_3d_reference_displays_info 3D Reference Displays Information + * @ingroup lavu_video + * + * The 3D Reference Displays Information describes information about the reference display + * width(s) and reference viewing distance(s) as well as information about the corresponding + * reference stereo pair(s). + * @{ + */ + +#define AV_TDRDI_MAX_NUM_REF_DISPLAY 32 + +/** + * This structure describes information about the reference display width(s) and reference + * viewing distance(s) as well as information about the corresponding reference stereo pair(s). + * See section G.14.3.2.3 of ITU-T H.265 for more information. + * + * @note The struct must be allocated with av_tdrdi_alloc() and + * its size is not a part of the public ABI. + */ +typedef struct AV3DReferenceDisplaysInfo { + /** + * The exponent of the maximum allowable truncation error for + * {exponent,mantissa}_ref_display_width as given by 2(-prec_ref_display_width). + */ + uint8_t prec_ref_display_width; + + /** + * A flag to indicate the presence of reference viewing distance. + * If false, the values of prec_ref_viewing_dist, exponent_ref_viewing_distance, + * and mantissa_ref_viewing_distance are undefined. + */ + uint8_t ref_viewing_distance_flag; + + /** + * The exponent of the maximum allowable truncation error for + * {exponent,mantissa}_ref_viewing_distance as given by 2^(-prec_ref_viewing_dist). + * The value of prec_ref_viewing_dist shall be in the range of 0 to 31, inclusive. + */ + uint8_t prec_ref_viewing_dist; + + /** + * The number of reference displays that are signalled in this struct. + * Allowed range is 1 to 32, inclusive. + */ + uint8_t num_ref_displays; + + /** + * Offset in bytes from the beginning of this structure at which the array + * of reference displays starts. + */ + size_t entries_offset; + + /** + * Size of each entry in bytes. May not match sizeof(AV3DReferenceDisplay). + */ + size_t entry_size; +} AV3DReferenceDisplaysInfo; + +/** + * Data structure for single deference display information. + * It is allocated as a part of AV3DReferenceDisplaysInfo and should be retrieved with + * av_tdrdi_get_display(). + * + * sizeof(AV3DReferenceDisplay) is not a part of the ABI and new fields may be + * added to it. +*/ +typedef struct AV3DReferenceDisplay { + /** + * The ViewId of the left view of a stereo pair corresponding to the n-th reference display. + */ + uint16_t left_view_id; + + /** + * The ViewId of the left view of a stereo pair corresponding to the n-th reference display. + */ + uint16_t right_view_id; + + /** + * The exponent part of the reference display width of the n-th reference display. + */ + uint8_t exponent_ref_display_width; + + /** + * The mantissa part of the reference display width of the n-th reference display. + */ + uint8_t mantissa_ref_display_width; + + /** + * The exponent part of the reference viewing distance of the n-th reference display. + */ + uint8_t exponent_ref_viewing_distance; + + /** + * The mantissa part of the reference viewing distance of the n-th reference display. + */ + uint8_t mantissa_ref_viewing_distance; + + /** + * An array of flags to indicates that the information about additional horizontal shift of + * the left and right views for the n-th reference display is present. + */ + uint8_t additional_shift_present_flag; + + /** + * The recommended additional horizontal shift for a stereo pair corresponding to the n-th + * reference baseline and the n-th reference display. + */ + int16_t num_sample_shift; +} AV3DReferenceDisplay; + +static av_always_inline AV3DReferenceDisplay* +av_tdrdi_get_display(AV3DReferenceDisplaysInfo *tdrdi, unsigned int idx) +{ + av_assert0(idx < tdrdi->num_ref_displays); + return (AV3DReferenceDisplay *)((uint8_t *)tdrdi + tdrdi->entries_offset + + idx * tdrdi->entry_size); +} + +/** + * Allocate a AV3DReferenceDisplaysInfo structure and initialize its fields to default + * values. + * + * @return the newly allocated struct or NULL on failure + */ +AV3DReferenceDisplaysInfo *av_tdrdi_alloc(unsigned int nb_displays, size_t *size); + +/** + * @} + */ + +#endif /* AVUTIL_TDRDI_H */ diff --git a/include/libavutil/tx.h b/include/libavutil/tx.h index 4696988cae..c950095735 100644 --- a/include/libavutil/tx.h +++ b/include/libavutil/tx.h @@ -50,7 +50,7 @@ enum AVTXType { /** * Standard MDCT with a sample data type of float, double or int32_t, - * respecively. For the float and int32 variants, the scale type is + * respectively. For the float and int32 variants, the scale type is * 'float', while for the double variant, it's 'double'. * If scale is NULL, 1.0 will be used as a default. * diff --git a/include/libavutil/version.h b/include/libavutil/version.h index 753f85b91c..c61f6b0e9c 100755 --- a/include/libavutil/version.h +++ b/include/libavutil/version.h @@ -35,7 +35,7 @@ * Useful to check and match library version in order to maintain * backward compatibility. * - * The FFmpeg libraries follow a versioning sheme very similar to + * The FFmpeg libraries follow a versioning scheme very similar to * Semantic Versioning (http://semver.org/) * The difference is that the component called PATCH is called MICRO in FFmpeg * and its value is reset to 100 instead of 0 to keep it above or equal to 100. @@ -72,15 +72,15 @@ /** * @defgroup lavu_ver Version and Build diagnostics * - * Macros and function useful to check at compiletime and at runtime + * Macros and function useful to check at compile time and at runtime * which version of libavutil is in use. * * @{ */ -#define LIBAVUTIL_VERSION_MAJOR 59 -#define LIBAVUTIL_VERSION_MINOR 39 -#define LIBAVUTIL_VERSION_MICRO 100 +#define LIBAVUTIL_VERSION_MAJOR 60 +#define LIBAVUTIL_VERSION_MINOR 26 +#define LIBAVUTIL_VERSION_MICRO 101 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ @@ -105,16 +105,15 @@ * @{ */ -#define FF_API_HDR_VIVID_THREE_SPLINE (LIBAVUTIL_VERSION_MAJOR < 60) -#define FF_API_FRAME_PKT (LIBAVUTIL_VERSION_MAJOR < 60) -#define FF_API_INTERLACED_FRAME (LIBAVUTIL_VERSION_MAJOR < 60) -#define FF_API_FRAME_KEY (LIBAVUTIL_VERSION_MAJOR < 60) -#define FF_API_PALETTE_HAS_CHANGED (LIBAVUTIL_VERSION_MAJOR < 60) -#define FF_API_VULKAN_CONTIGUOUS_MEMORY (LIBAVUTIL_VERSION_MAJOR < 60) -#define FF_API_H274_FILM_GRAIN_VCS (LIBAVUTIL_VERSION_MAJOR < 60) -#define FF_API_MOD_UINTP2 (LIBAVUTIL_VERSION_MAJOR < 60) -#define FF_API_RISCV_FD_ZBA (LIBAVUTIL_VERSION_MAJOR < 60) -#define FF_API_VULKAN_FIXED_QUEUES (LIBAVUTIL_VERSION_MAJOR < 60) +#define FF_API_MOD_UINTP2 (LIBAVUTIL_VERSION_MAJOR < 61) +#define FF_API_RISCV_FD_ZBA (LIBAVUTIL_VERSION_MAJOR < 61) +#define FF_API_VULKAN_FIXED_QUEUES (LIBAVUTIL_VERSION_MAJOR < 61) +#define FF_API_OPT_INT_LIST (LIBAVUTIL_VERSION_MAJOR < 61) +#define FF_API_OPT_PTR (LIBAVUTIL_VERSION_MAJOR < 61) +#define FF_API_CPU_FLAG_FORCE (LIBAVUTIL_VERSION_MAJOR < 61) +#define FF_API_DOVI_L11_INVALID_PROPS (LIBAVUTIL_VERSION_MAJOR < 61) +#define FF_API_ASSERT_FPU (LIBAVUTIL_VERSION_MAJOR < 61) +#define FF_API_VULKAN_SYNC_QUEUES (LIBAVUTIL_VERSION_MAJOR < 62) /** * @} diff --git a/include/libavutil/video_hint.h b/include/libavutil/video_hint.h index 1b2196093b..8e8af0ae90 100644 --- a/include/libavutil/video_hint.h +++ b/include/libavutil/video_hint.h @@ -80,7 +80,7 @@ av_video_hint_get_rect(const AVVideoHint *hints, size_t idx) { * The side data contains a list of rectangles for the portions of the frame * which changed from the last encoded one (and the remainder are assumed to be * changed), or, alternately (depending on the type parameter) the unchanged - * ones (and the remanining ones are those which changed). + * ones (and the remaining ones are those which changed). * Macroblocks will thus be hinted either to be P_SKIP-ped or go through the * regular encoding procedure. * diff --git a/include/libswresample/swresample.h b/include/libswresample/swresample.h index 0e1929b3ed..052089acca 100644 --- a/include/libswresample/swresample.h +++ b/include/libswresample/swresample.h @@ -337,7 +337,7 @@ int64_t swr_next_pts(struct SwrContext *s, int64_t pts); * @} * * @name Low-level option setting functions - * These functons provide a means to set low-level options that is not possible + * These functions provide a means to set low-level options that is not possible * with the AVOption API. * @{ */ diff --git a/include/libswresample/version.h b/include/libswresample/version.h index d1795b5545..403be6227a 100644 --- a/include/libswresample/version.h +++ b/include/libswresample/version.h @@ -31,7 +31,7 @@ #include "version_major.h" #define LIBSWRESAMPLE_VERSION_MINOR 3 -#define LIBSWRESAMPLE_VERSION_MICRO 100 +#define LIBSWRESAMPLE_VERSION_MICRO 101 #define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \ LIBSWRESAMPLE_VERSION_MINOR, \ diff --git a/include/libswresample/version_major.h b/include/libswresample/version_major.h index dd13f2bbe3..4e0bc0ab19 100644 --- a/include/libswresample/version_major.h +++ b/include/libswresample/version_major.h @@ -26,6 +26,6 @@ * Libswresample version macros */ -#define LIBSWRESAMPLE_VERSION_MAJOR 5 +#define LIBSWRESAMPLE_VERSION_MAJOR 6 #endif /* SWRESAMPLE_VERSION_MAJOR_H */ diff --git a/include/libswscale/swscale.h b/include/libswscale/swscale.h index e575695c05..1cfd4068f9 100644 --- a/include/libswscale/swscale.h +++ b/include/libswscale/swscale.h @@ -1,4 +1,5 @@ /* + * Copyright (C) 2024 Niklas Haas * Copyright (C) 2001-2011 Michael Niedermayer * * This file is part of FFmpeg. @@ -61,59 +62,325 @@ const char *swscale_configuration(void); */ const char *swscale_license(void); -/* values for the flags, the stuff on the command line is different */ -#define SWS_FAST_BILINEAR 1 -#define SWS_BILINEAR 2 -#define SWS_BICUBIC 4 -#define SWS_X 8 -#define SWS_POINT 0x10 -#define SWS_AREA 0x20 -#define SWS_BICUBLIN 0x40 -#define SWS_GAUSS 0x80 -#define SWS_SINC 0x100 -#define SWS_LANCZOS 0x200 -#define SWS_SPLINE 0x400 +/** + * Get the AVClass for SwsContext. It can be used in combination with + * AV_OPT_SEARCH_FAKE_OBJ for examining options. + * + * @see av_opt_find(). + */ +const AVClass *sws_get_class(void); -#define SWS_SRC_V_CHR_DROP_MASK 0x30000 -#define SWS_SRC_V_CHR_DROP_SHIFT 16 +/****************************** + * Flags and quality settings * + ******************************/ + +typedef enum SwsDither { + SWS_DITHER_NONE = 0, /* disable dithering */ + SWS_DITHER_AUTO, /* auto-select from preset */ + SWS_DITHER_BAYER, /* ordered dither matrix */ + SWS_DITHER_ED, /* error diffusion */ + SWS_DITHER_A_DITHER, /* arithmetic addition */ + SWS_DITHER_X_DITHER, /* arithmetic xor */ + SWS_DITHER_NB, /* not part of the ABI */ + SWS_DITHER_MAX_ENUM = 0x7FFFFFFF, /* force size to 32 bits, not a valid dither type */ +} SwsDither; + +typedef enum SwsAlphaBlend { + SWS_ALPHA_BLEND_NONE = 0, + SWS_ALPHA_BLEND_UNIFORM, + SWS_ALPHA_BLEND_CHECKERBOARD, + SWS_ALPHA_BLEND_NB, /* not part of the ABI */ + SWS_ALPHA_BLEND_MAX_ENUM = 0x7FFFFFFF, /* force size to 32 bits, not a valid blend mode */ +} SwsAlphaBlend; + +typedef enum SwsFlags { + /** + * Scaler selection options. Only one may be active at a time. + */ + SWS_FAST_BILINEAR = 1 << 0, ///< fast bilinear filtering + SWS_BILINEAR = 1 << 1, ///< bilinear filtering + SWS_BICUBIC = 1 << 2, ///< 2-tap cubic B-spline + SWS_X = 1 << 3, ///< experimental + SWS_POINT = 1 << 4, ///< nearest neighbor + SWS_AREA = 1 << 5, ///< area averaging + SWS_BICUBLIN = 1 << 6, ///< bicubic luma, bilinear chroma + SWS_GAUSS = 1 << 7, ///< gaussian approximation + SWS_SINC = 1 << 8, ///< unwindowed sinc + SWS_LANCZOS = 1 << 9, ///< 3-tap sinc/sinc + SWS_SPLINE = 1 << 10, ///< cubic Keys spline + + /** + * Return an error on underspecified conversions. Without this flag, + * unspecified fields are defaulted to sensible values. + */ + SWS_STRICT = 1 << 11, + + /** + * Emit verbose log of scaling parameters. + */ + SWS_PRINT_INFO = 1 << 12, + + /** + * Perform full chroma upsampling when upscaling to RGB. + * + * For example, when converting 50x50 yuv420p to 100x100 rgba, setting this flag + * will scale the chroma plane from 25x25 to 100x100 (4:4:4), and then convert + * the 100x100 yuv444p image to rgba in the final output step. + * + * Without this flag, the chroma plane is instead scaled to 50x100 (4:2:2), + * with a single chroma sample being reused for both of the horizontally + * adjacent RGBA output pixels. + */ + SWS_FULL_CHR_H_INT = 1 << 13, + + /** + * Perform full chroma interpolation when downscaling RGB sources. + * + * For example, when converting a 100x100 rgba source to 50x50 yuv444p, setting + * this flag will generate a 100x100 (4:4:4) chroma plane, which is then + * downscaled to the required 50x50. + * + * Without this flag, the chroma plane is instead generated at 50x100 (dropping + * every other pixel), before then being downscaled to the required 50x50 + * resolution. + */ + SWS_FULL_CHR_H_INP = 1 << 14, + + /** + * Force bit-exact output. This will prevent the use of platform-specific + * optimizations that may lead to slight difference in rounding, in favor + * of always maintaining exact bit output compatibility with the reference + * C code. + * + * Note: It is recommended to set both of these flags simultaneously. + */ + SWS_ACCURATE_RND = 1 << 18, + SWS_BITEXACT = 1 << 19, + + /** + * Allow using experimental new code paths. This may be faster, slower, + * or produce different output, with semantics subject to change at any + * point in time. For testing and debugging purposes only. + */ + SWS_UNSTABLE = 1 << 20, + + /** + * Deprecated flags. + */ + SWS_DIRECT_BGR = 1 << 15, ///< This flag has no effect + SWS_ERROR_DIFFUSION = 1 << 23, ///< Set `SwsContext.dither` instead +} SwsFlags; + +typedef enum SwsIntent { + SWS_INTENT_PERCEPTUAL = 0, ///< Perceptual tone mapping + SWS_INTENT_RELATIVE_COLORIMETRIC = 1, ///< Relative colorimetric clipping + SWS_INTENT_SATURATION = 2, ///< Saturation mapping + SWS_INTENT_ABSOLUTE_COLORIMETRIC = 3, ///< Absolute colorimetric clipping + SWS_INTENT_NB, ///< not part of the ABI +} SwsIntent; + +/*********************************** + * Context creation and management * + ***********************************/ + +/** + * Main external API structure. New fields can be added to the end with + * minor version bumps. Removal, reordering and changes to existing fields + * require a major version bump. sizeof(SwsContext) is not part of the ABI. + */ +typedef struct SwsContext { + const AVClass *av_class; + + /** + * Private data of the user, can be used to carry app specific stuff. + */ + void *opaque; + + /** + * Bitmask of SWS_*. See `SwsFlags` for details. + */ + unsigned flags; + + /** + * Extra parameters for fine-tuning certain scalers. + */ + double scaler_params[2]; + + /** + * How many threads to use for processing, or 0 for automatic selection. + */ + int threads; -#define SWS_PARAM_DEFAULT 123456 + /** + * Dither mode. + */ + SwsDither dither; + + /** + * Alpha blending mode. See `SwsAlphaBlend` for details. + */ + SwsAlphaBlend alpha_blend; + + /** + * Use gamma correct scaling. + */ + int gamma_flag; + + /** + * Deprecated frame property overrides, for the legacy API only. + * + * Ignored by sws_scale_frame() when used in dynamic mode, in which + * case all properties are instead taken from the frame directly. + */ + int src_w, src_h; ///< Width and height of the source frame + int dst_w, dst_h; ///< Width and height of the destination frame + int src_format; ///< Source pixel format + int dst_format; ///< Destination pixel format + int src_range; ///< Source is full range + int dst_range; ///< Destination is full range + int src_v_chr_pos; ///< Source vertical chroma position in luma grid / 256 + int src_h_chr_pos; ///< Source horizontal chroma position + int dst_v_chr_pos; ///< Destination vertical chroma position + int dst_h_chr_pos; ///< Destination horizontal chroma position + + /** + * Desired ICC intent for color space conversions. + */ + int intent; + + /* Remember to add new fields to graph.c:opts_equal() */ +} SwsContext; + +/** + * Allocate an empty SwsContext and set its fields to default values. + */ +SwsContext *sws_alloc_context(void); + +/** + * Free the context and everything associated with it, and write NULL + * to the provided pointer. + */ +void sws_free_context(SwsContext **ctx); -#define SWS_PRINT_INFO 0x1000 +/*************************** + * Supported frame formats * + ***************************/ -//the following 3 flags are not completely implemented +/** + * Test if a given (software) pixel format is supported. + * + * @param output If 0, test if compatible with the source/input frame; + * otherwise, with the destination/output frame. + * @param format The format to check. + * + * @return A positive integer if supported, 0 otherwise. + */ +int sws_test_format(enum AVPixelFormat format, int output); /** - * Perform full chroma upsampling when upscaling to RGB. + * Test if a given hardware pixel format is supported. * - * For example, when converting 50x50 yuv420p to 100x100 rgba, setting this flag - * will scale the chroma plane from 25x25 to 100x100 (4:4:4), and then convert - * the 100x100 yuv444p image to rgba in the final output step. + * @param format The hardware format to check, or AV_PIX_FMT_NONE. * - * Without this flag, the chroma plane is instead scaled to 50x100 (4:2:2), - * with a single chroma sample being re-used for both of the horizontally - * adjacent RGBA output pixels. + * @return A positive integer if supported or AV_PIX_FMT_NONE, 0 otherwise. */ -#define SWS_FULL_CHR_H_INT 0x2000 +int sws_test_hw_format(enum AVPixelFormat format); /** - * Perform full chroma interpolation when downscaling RGB sources. + * Test if a given color space is supported. * - * For example, when converting a 100x100 rgba source to 50x50 yuv444p, setting - * this flag will generate a 100x100 (4:4:4) chroma plane, which is then - * downscaled to the required 50x50. + * @param output If 0, test if compatible with the source/input frame; + * otherwise, with the destination/output frame. + * @param colorspace The colorspace to check. * - * Without this flag, the chroma plane is instead generated at 50x100 (dropping - * every other pixel), before then being downscaled to the required 50x50 - * resolution. + * @return A positive integer if supported, 0 otherwise. */ -#define SWS_FULL_CHR_H_INP 0x4000 +int sws_test_colorspace(enum AVColorSpace colorspace, int output); -#define SWS_DIRECT_BGR 0x8000 +/** + * Test if a given set of color primaries is supported. + * + * @param output If 0, test if compatible with the source/input frame; + * otherwise, with the destination/output frame. + * @param primaries The color primaries to check. + * + * @return A positive integer if supported, 0 otherwise. + */ +int sws_test_primaries(enum AVColorPrimaries primaries, int output); -#define SWS_ACCURATE_RND 0x40000 -#define SWS_BITEXACT 0x80000 -#define SWS_ERROR_DIFFUSION 0x800000 +/** + * Test if a given color transfer function is supported. + * + * @param output If 0, test if compatible with the source/input frame; + * otherwise, with the destination/output frame. + * @param trc The color transfer function to check. + * + * @return A positive integer if supported, 0 otherwise. + */ +int sws_test_transfer(enum AVColorTransferCharacteristic trc, int output); + +/** + * Helper function to run all sws_test_* against a frame, as well as testing + * the basic frame properties for sanity. Ignores irrelevant properties - for + * example, AVColorSpace is not checked for RGB frames. + */ +int sws_test_frame(const AVFrame *frame, int output); + +/** + * Like `sws_scale_frame`, but without actually scaling. It will instead + * merely initialize internal state that *would* be required to perform the + * operation, as well as returning the correct error code for unsupported + * frame combinations. + * + * @param ctx The scaling context. + * @param dst The destination frame to consider. + * @param src The source frame to consider. + * @return 0 on success, a negative AVERROR code on failure. + */ +int sws_frame_setup(SwsContext *ctx, const AVFrame *dst, const AVFrame *src); + +/******************** + * Main scaling API * + ********************/ + +/** + * Check if a given conversion is a noop. Returns a positive integer if + * no operation needs to be performed, 0 otherwise. + */ +int sws_is_noop(const AVFrame *dst, const AVFrame *src); + +/** + * Scale source data from `src` and write the output to `dst`. + * + * This function can be used directly on an allocated context, without setting + * up any frame properties or calling `sws_init_context()`. Such usage is fully + * dynamic and does not require reallocation if the frame properties change. + * + * Alternatively, this function can be called on a context that has been + * explicitly initialized. However, this is provided only for backwards + * compatibility. In this usage mode, all frame properties must be correctly + * set at init time, and may no longer change after initialization. + * + * @param ctx The scaling context. + * @param dst The destination frame. The data buffers may either be already + * allocated by the caller or left clear, in which case they will + * be allocated by the scaler. The latter may have performance + * advantages - e.g. in certain cases some (or all) output planes + * may be references to input planes, rather than copies. + * @param src The source frame. If the data buffers are set to NULL, then + * this function behaves identically to `sws_frame_setup`. + * @return >= 0 on success, a negative AVERROR code on failure. + */ +int sws_scale_frame(SwsContext *c, AVFrame *dst, const AVFrame *src); + +/************************* + * Legacy (stateful) API * + *************************/ + +#define SWS_SRC_V_CHR_DROP_MASK 0x30000 +#define SWS_SRC_V_CHR_DROP_SHIFT 16 + +#define SWS_PARAM_DEFAULT 123456 #define SWS_MAX_REDUCE_CUTOFF 0.002 @@ -150,8 +417,6 @@ typedef struct SwsFilter { SwsVector *chrV; } SwsFilter; -struct SwsContext; - /** * Return a positive value if pix_fmt is a supported input format, 0 * otherwise. @@ -171,27 +436,25 @@ int sws_isSupportedOutput(enum AVPixelFormat pix_fmt); */ int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt); -/** - * Allocate an empty SwsContext. This must be filled and passed to - * sws_init_context(). For filling see AVOptions, options.c and - * sws_setColorspaceDetails(). - */ -struct SwsContext *sws_alloc_context(void); - /** * Initialize the swscaler context sws_context. * + * This function is considered deprecated, and provided only for backwards + * compatibility with sws_scale() and sws_frame_start(). The preferred way to + * use libswscale is to set all frame properties correctly and call + * sws_scale_frame() directly, without explicitly initializing the context. + * * @return zero or positive value on success, a negative value on * error */ av_warn_unused_result -int sws_init_context(struct SwsContext *sws_context, SwsFilter *srcFilter, SwsFilter *dstFilter); +int sws_init_context(SwsContext *sws_context, SwsFilter *srcFilter, SwsFilter *dstFilter); /** * Free the swscaler context swsContext. * If swsContext is NULL, then does nothing. */ -void sws_freeContext(struct SwsContext *swsContext); +void sws_freeContext(SwsContext *swsContext); /** * Allocate and return an SwsContext. You need it to perform @@ -214,15 +477,16 @@ void sws_freeContext(struct SwsContext *swsContext); * @note this function is to be removed after a saner alternative is * written */ -struct SwsContext *sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat, - int dstW, int dstH, enum AVPixelFormat dstFormat, - int flags, SwsFilter *srcFilter, - SwsFilter *dstFilter, const double *param); +SwsContext *sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat, + int dstW, int dstH, enum AVPixelFormat dstFormat, + int flags, SwsFilter *srcFilter, + SwsFilter *dstFilter, const double *param); /** * Scale the image slice in srcSlice and put the resulting scaled * slice in the image in dst. A slice is a sequence of consecutive - * rows in an image. + * rows in an image. Requires a context that has previously been + * initialized with sws_init_context(). * * Slices have to be provided in sequential order, either in * top-bottom or bottom-top order. If slices are provided in @@ -245,31 +509,14 @@ struct SwsContext *sws_getContext(int srcW, int srcH, enum AVPixelFormat srcForm * the destination image * @return the height of the output slice */ -int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[], +int sws_scale(SwsContext *c, const uint8_t *const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[]); -/** - * Scale source data from src and write the output to dst. - * - * This is merely a convenience wrapper around - * - sws_frame_start() - * - sws_send_slice(0, src->height) - * - sws_receive_slice(0, dst->height) - * - sws_frame_end() - * - * @param c The scaling context - * @param dst The destination frame. See documentation for sws_frame_start() for - * more details. - * @param src The source frame. - * - * @return 0 on success, a negative AVERROR code on failure - */ -int sws_scale_frame(struct SwsContext *c, AVFrame *dst, const AVFrame *src); - /** * Initialize the scaling process for a given pair of source/destination frames. * Must be called before any calls to sws_send_slice() and sws_receive_slice(). + * Requires a context that has previously been initialized with sws_init_context(). * * This function will retain references to src and dst, so they must both use * refcounted buffers (if allocated by the caller, in case of dst). @@ -292,7 +539,7 @@ int sws_scale_frame(struct SwsContext *c, AVFrame *dst, const AVFrame *src); * * @see sws_frame_end() */ -int sws_frame_start(struct SwsContext *c, AVFrame *dst, const AVFrame *src); +int sws_frame_start(SwsContext *c, AVFrame *dst, const AVFrame *src); /** * Finish the scaling process for a pair of source/destination frames previously @@ -302,7 +549,7 @@ int sws_frame_start(struct SwsContext *c, AVFrame *dst, const AVFrame *src); * * @param c The scaling context */ -void sws_frame_end(struct SwsContext *c); +void sws_frame_end(SwsContext *c); /** * Indicate that a horizontal slice of input data is available in the source @@ -316,7 +563,7 @@ void sws_frame_end(struct SwsContext *c); * * @return a non-negative number on success, a negative AVERROR code on failure. */ -int sws_send_slice(struct SwsContext *c, unsigned int slice_start, +int sws_send_slice(SwsContext *c, unsigned int slice_start, unsigned int slice_height); /** @@ -336,23 +583,24 @@ int sws_send_slice(struct SwsContext *c, unsigned int slice_start, * output can be produced * another negative AVERROR code on other kinds of scaling failure */ -int sws_receive_slice(struct SwsContext *c, unsigned int slice_start, +int sws_receive_slice(SwsContext *c, unsigned int slice_start, unsigned int slice_height); /** - * Get the alignment required for slices + * Get the alignment required for slices. Requires a context that has + * previously been initialized with sws_init_context(). * * @param c The scaling context * @return alignment required for output slices requested with sws_receive_slice(). * Slice offsets and sizes passed to sws_receive_slice() must be * multiples of the value returned from this function. */ -unsigned int sws_receive_slice_alignment(const struct SwsContext *c); +unsigned int sws_receive_slice_alignment(const SwsContext *c); /** * @param c the scaling context - * @param dstRange flag indicating the while-black range of the output (1=jpeg / 0=mpeg) - * @param srcRange flag indicating the while-black range of the input (1=jpeg / 0=mpeg) + * @param dstRange flag indicating the white-black range of the output (1=jpeg / 0=mpeg) + * @param srcRange flag indicating the white-black range of the input (1=jpeg / 0=mpeg) * @param table the yuv2rgb coefficients describing the output yuv space, normally ff_yuv2rgb_coeffs[x] * @param inv_table the yuv2rgb coefficients describing the input yuv space, normally ff_yuv2rgb_coeffs[x] * @param brightness 16.16 fixed point brightness correction @@ -362,7 +610,7 @@ unsigned int sws_receive_slice_alignment(const struct SwsContext *c); * @return A negative error code on error, non negative otherwise. * If `LIBSWSCALE_VERSION_MAJOR < 7`, returns -1 if not supported. */ -int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], +int sws_setColorspaceDetails(SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation); @@ -370,7 +618,7 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], * @return A negative error code on error, non negative otherwise. * If `LIBSWSCALE_VERSION_MAJOR < 7`, returns -1 if not supported. */ -int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table, +int sws_getColorspaceDetails(SwsContext *c, int **inv_table, int *srcRange, int **table, int *dstRange, int *brightness, int *contrast, int *saturation); @@ -415,11 +663,11 @@ void sws_freeFilter(SwsFilter *filter); * Be warned that srcFilter and dstFilter are not checked, they * are assumed to remain the same. */ -struct SwsContext *sws_getCachedContext(struct SwsContext *context, - int srcW, int srcH, enum AVPixelFormat srcFormat, - int dstW, int dstH, enum AVPixelFormat dstFormat, - int flags, SwsFilter *srcFilter, - SwsFilter *dstFilter, const double *param); +SwsContext *sws_getCachedContext(SwsContext *context, int srcW, int srcH, + enum AVPixelFormat srcFormat, int dstW, int dstH, + enum AVPixelFormat dstFormat, int flags, + SwsFilter *srcFilter, SwsFilter *dstFilter, + const double *param); /** * Convert an 8-bit paletted frame into a frame with a color depth of 32 bits. @@ -445,14 +693,6 @@ void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst, int num_pix */ void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette); -/** - * Get the AVClass for swsContext. It can be used in combination with - * AV_OPT_SEARCH_FAKE_OBJ for examining options. - * - * @see av_opt_find(). - */ -const AVClass *sws_get_class(void); - /** * @} */ diff --git a/include/libswscale/version.h b/include/libswscale/version.h index 51eb013a29..0129e16854 100644 --- a/include/libswscale/version.h +++ b/include/libswscale/version.h @@ -28,8 +28,8 @@ #include "version_major.h" -#define LIBSWSCALE_VERSION_MINOR 3 -#define LIBSWSCALE_VERSION_MICRO 100 +#define LIBSWSCALE_VERSION_MINOR 5 +#define LIBSWSCALE_VERSION_MICRO 101 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ LIBSWSCALE_VERSION_MINOR, \ diff --git a/include/libswscale/version_major.h b/include/libswscale/version_major.h index fd259f959d..0dc507921e 100644 --- a/include/libswscale/version_major.h +++ b/include/libswscale/version_major.h @@ -24,7 +24,7 @@ * swscale version macros */ -#define LIBSWSCALE_VERSION_MAJOR 8 +#define LIBSWSCALE_VERSION_MAJOR 9 /** * FF_API_* defines may be placed below to indicate public API that will be diff --git a/lib/windows/x86_64/avcodec.lib b/lib/windows/x86_64/avcodec.lib new file mode 100644 index 0000000000..92c684ff74 Binary files /dev/null and b/lib/windows/x86_64/avcodec.lib differ diff --git a/lib/windows/x86_64/avdevice.lib b/lib/windows/x86_64/avdevice.lib new file mode 100644 index 0000000000..fd301aba25 Binary files /dev/null and b/lib/windows/x86_64/avdevice.lib differ diff --git a/lib/windows/x86_64/avfilter.lib b/lib/windows/x86_64/avfilter.lib new file mode 100644 index 0000000000..b4de5f0628 Binary files /dev/null and b/lib/windows/x86_64/avfilter.lib differ diff --git a/lib/windows/x86_64/avformat.lib b/lib/windows/x86_64/avformat.lib new file mode 100644 index 0000000000..fd6509c1ff Binary files /dev/null and b/lib/windows/x86_64/avformat.lib differ diff --git a/lib/windows/x86_64/avutil.lib b/lib/windows/x86_64/avutil.lib new file mode 100644 index 0000000000..b4e10bcfa7 Binary files /dev/null and b/lib/windows/x86_64/avutil.lib differ diff --git a/lib/windows/x86_64/swresample.lib b/lib/windows/x86_64/swresample.lib new file mode 100644 index 0000000000..fef31d2878 Binary files /dev/null and b/lib/windows/x86_64/swresample.lib differ diff --git a/lib/windows/x86_64/swscale.lib b/lib/windows/x86_64/swscale.lib new file mode 100644 index 0000000000..1fe79e5e60 Binary files /dev/null and b/lib/windows/x86_64/swscale.lib differ