From 3819b3a44e2f2fefc32a4379237eed23fa6c9e9d Mon Sep 17 00:00:00 2001 From: v0lt Date: Sat, 16 Nov 2024 07:20:29 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20ffmpeg=20n7.2-dev-615-g7332b1700e.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/Changelog.Rus.txt | 2 +- docs/Changelog.txt | 2 +- src/ExtLib/ffmpeg/libavcodec/aom_film_grain.c | 49 +++++++++++++++---- src/ExtLib/ffmpeg/libavcodec/aom_film_grain.h | 6 ++- .../libavcodec/cbs_h266_syntax_template.c | 12 ++--- src/ExtLib/ffmpeg/libavcodec/codec_desc.c | 2 +- src/ExtLib/ffmpeg/libavcodec/h2645_sei.c | 44 ++++++++++------- src/ExtLib/ffmpeg/libavcodec/h2645_sei.h | 4 +- src/ExtLib/ffmpeg/libavcodec/h264_picture.c | 11 +---- src/ExtLib/ffmpeg/libavcodec/h264_sei.h | 6 --- src/ExtLib/ffmpeg/libavcodec/h264_slice.c | 4 +- src/ExtLib/ffmpeg/libavcodec/h264dec.c | 2 - src/ExtLib/ffmpeg/libavcodec/h264dec.h | 2 +- src/ExtLib/ffmpeg/libavcodec/hevc/hevcdec.c | 18 ++----- src/ExtLib/ffmpeg/libavcodec/hevc/hevcdec.h | 2 +- src/ExtLib/ffmpeg/libavcodec/hevc/sei.h | 5 -- .../ffmpeg/libavcodec/vvc/intra_utils.c | 10 ++-- src/ExtLib/ffmpeg/libavcodec/x86/diracdsp.asm | 27 ++++++++-- .../ffmpeg/libavcodec/x86/diracdsp_init.c | 15 ++---- .../ffmpeg/libavcodec/x86/vvc/vvcdsp_init.c | 25 ++++++++-- src/ExtLib/ffmpeg/libavfilter/framepool.c | 12 +++-- src/ExtLib/ffmpeg/libavutil/channel_layout.c | 3 ++ src/ExtLib/ffmpeg/libavutil/channel_layout.h | 7 +++ src/ExtLib/ffmpeg/libavutil/version.h | 2 +- 24 files changed, 160 insertions(+), 112 deletions(-) diff --git a/docs/Changelog.Rus.txt b/docs/Changelog.Rus.txt index bba8ce191a..ac5cc3b17d 100644 --- a/docs/Changelog.Rus.txt +++ b/docs/Changelog.Rus.txt @@ -7,7 +7,7 @@ Обновлены библиотеки: dav1d git-1.5.0-16-g93f12c1; - ffmpeg n7.2-dev-568-g13129f1af4. + ffmpeg n7.2-dev-615-g7332b1700e. 1.8.1 - 2024-11-07 diff --git a/docs/Changelog.txt b/docs/Changelog.txt index 2ffc265d4e..8b1ea0da68 100644 --- a/docs/Changelog.txt +++ b/docs/Changelog.txt @@ -7,7 +7,7 @@ Added Slovenian translation (by MatjazP72). Updated libraries: dav1d git-1.5.0-16-g93f12c1; - ffmpeg n7.2-dev-568-g13129f1af4. + ffmpeg n7.2-dev-615-g7332b1700e. 1.8.1 - 2024-11-07 diff --git a/src/ExtLib/ffmpeg/libavcodec/aom_film_grain.c b/src/ExtLib/ffmpeg/libavcodec/aom_film_grain.c index e302567ba5..1b1693dcd9 100644 --- a/src/ExtLib/ffmpeg/libavcodec/aom_film_grain.c +++ b/src/ExtLib/ffmpeg/libavcodec/aom_film_grain.c @@ -26,7 +26,9 @@ */ #include "libavutil/avassert.h" +#include "libavutil/buffer.h" #include "libavutil/imgutils.h" +#include "libavutil/mem.h" #include "aom_film_grain.h" #include "get_bits.h" @@ -124,7 +126,7 @@ int ff_aom_parse_film_grain_sets(AVFilmGrainAFGS1Params *s, { GetBitContext gbc, *gb = &gbc; AVFilmGrainAOMParams *aom; - AVFilmGrainParams *fgp, *ref = NULL; + AVFilmGrainParams *fgp = NULL, *ref = NULL; int ret, num_sets, n, i, uv, num_y_coeffs, update_grain, luma_only; ret = init_get_bits8(gb, payload, payload_size); @@ -135,28 +137,38 @@ int ff_aom_parse_film_grain_sets(AVFilmGrainAFGS1Params *s, if (!s->enable) return 0; + for (int i = 0; i < FF_ARRAY_ELEMS(s->sets); i++) + av_buffer_unref(&s->sets[i]); + skip_bits(gb, 4); // reserved num_sets = get_bits(gb, 3) + 1; for (n = 0; n < num_sets; n++) { int payload_4byte, payload_size, set_idx, apply_units_log2, vsc_flag; int predict_scaling, predict_y_scaling, predict_uv_scaling[2]; int payload_bits, start_position; + size_t fgp_size; start_position = get_bits_count(gb); payload_4byte = get_bits1(gb); payload_size = get_bits(gb, payload_4byte ? 2 : 8); set_idx = get_bits(gb, 3); - fgp = &s->sets[set_idx]; + fgp = av_film_grain_params_alloc(&fgp_size); + if (!fgp) + goto error; aom = &fgp->codec.aom; fgp->type = get_bits1(gb) ? AV_FILM_GRAIN_PARAMS_AV1 : AV_FILM_GRAIN_PARAMS_NONE; - if (!fgp->type) + if (!fgp->type) { + av_freep(&fgp); continue; + } fgp->seed = get_bits(gb, 16); update_grain = get_bits1(gb); - if (!update_grain) + if (!update_grain) { + av_freep(&fgp); continue; + } apply_units_log2 = get_bits(gb, 4); fgp->width = get_bits(gb, 12) << apply_units_log2; @@ -330,32 +342,49 @@ int ff_aom_parse_film_grain_sets(AVFilmGrainAFGS1Params *s, if (payload_bits > payload_size * 8) goto error; skip_bits(gb, payload_size * 8 - payload_bits); + + av_buffer_unref(&s->sets[set_idx]); + s->sets[set_idx] = av_buffer_create((uint8_t *)fgp, fgp_size, NULL, NULL, 0); + if (!s->sets[set_idx]) + goto error; } return 0; error: - memset(s, 0, sizeof(*s)); + av_free(fgp); + ff_aom_uninit_film_grain_params(s); return AVERROR_INVALIDDATA; } int ff_aom_attach_film_grain_sets(const AVFilmGrainAFGS1Params *s, AVFrame *frame) { - AVFilmGrainParams *fgp; if (!s->enable) return 0; for (int i = 0; i < FF_ARRAY_ELEMS(s->sets); i++) { - if (s->sets[i].type != AV_FILM_GRAIN_PARAMS_AV1) + AVBufferRef *buf; + + if (!s->sets[i]) continue; - fgp = av_film_grain_params_create_side_data(frame); - if (!fgp) + + buf = av_buffer_ref(s->sets[i]); + if (!buf || !av_frame_new_side_data_from_buf(frame, + AV_FRAME_DATA_FILM_GRAIN_PARAMS, buf)) { + av_buffer_unref(&buf); return AVERROR(ENOMEM); - memcpy(fgp, &s->sets[i], sizeof(*fgp)); + } } return 0; } +void ff_aom_uninit_film_grain_params(AVFilmGrainAFGS1Params *s) +{ + for (int i = 0; i < FF_ARRAY_ELEMS(s->sets); i++) + av_buffer_unref(&s->sets[i]); + s->enable = 0; +} + // Taken from the AV1 spec. Range is [-2048, 2047], mean is 0 and stddev is 512 static const int16_t gaussian_sequence[2048] = { 56, 568, -180, 172, 124, -84, 172, -64, -900, 24, 820, diff --git a/src/ExtLib/ffmpeg/libavcodec/aom_film_grain.h b/src/ExtLib/ffmpeg/libavcodec/aom_film_grain.h index 1f8c78f657..97c33deb47 100644 --- a/src/ExtLib/ffmpeg/libavcodec/aom_film_grain.h +++ b/src/ExtLib/ffmpeg/libavcodec/aom_film_grain.h @@ -28,11 +28,12 @@ #ifndef AVCODEC_AOM_FILM_GRAIN_H #define AVCODEC_AOM_FILM_GRAIN_H +#include "libavutil/buffer.h" #include "libavutil/film_grain_params.h" typedef struct AVFilmGrainAFGS1Params { int enable; - AVFilmGrainParams sets[8]; + AVBufferRef *sets[8]; } AVFilmGrainAFGS1Params; // Synthesizes film grain on top of `in` and stores the result to `out`. `out` @@ -48,4 +49,7 @@ int ff_aom_parse_film_grain_sets(AVFilmGrainAFGS1Params *s, // Attach all valid film grain param sets to `frame`. int ff_aom_attach_film_grain_sets(const AVFilmGrainAFGS1Params *s, AVFrame *frame); +// Free all allocations in `s` and zero the entire struct. +void ff_aom_uninit_film_grain_params(AVFilmGrainAFGS1Params *s); + #endif /* AVCODEC_AOM_FILM_GRAIN_H */ diff --git a/src/ExtLib/ffmpeg/libavcodec/cbs_h266_syntax_template.c b/src/ExtLib/ffmpeg/libavcodec/cbs_h266_syntax_template.c index b21d07491b..6b2d6534ef 100644 --- a/src/ExtLib/ffmpeg/libavcodec/cbs_h266_syntax_template.c +++ b/src/ExtLib/ffmpeg/libavcodec/cbs_h266_syntax_template.c @@ -1162,7 +1162,7 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw, for (i = 1; i <= current->sps_num_subpics_minus1; i++) { if (!current->sps_subpic_same_size_flag) { if (current->sps_pic_width_max_in_luma_samples > ctb_size_y) { - const unsigned int win_right_edge = + const int win_right_edge = current->sps_pic_width_max_in_luma_samples - current->sps_conf_win_right_offset * sub_width_c; us(wlen, sps_subpic_ctu_top_left_x[i], 0, @@ -1172,7 +1172,7 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw, infer(sps_subpic_ctu_top_left_x[i], 0); if (current->sps_pic_height_max_in_luma_samples > ctb_size_y) { - const unsigned int win_bottom_edge = + const int win_bottom_edge = current->sps_pic_height_max_in_luma_samples - current->sps_conf_win_bottom_offset * sub_height_c; us(hlen, sps_subpic_ctu_top_left_y[i], 0, @@ -1183,9 +1183,9 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw, if (i < current->sps_num_subpics_minus1 && current->sps_pic_width_max_in_luma_samples > ctb_size_y) { - const unsigned int win_left_edge = + const int win_left_edge = current->sps_conf_win_left_offset * sub_width_c; - const unsigned int win_left_edge_ctus = + const int win_left_edge_ctus = AV_CEIL_RSHIFT(win_left_edge, ctb_log2_size_y); us(wlen, sps_subpic_width_minus1[i], win_left_edge_ctus > current->sps_subpic_ctu_top_left_x[i] @@ -1200,9 +1200,9 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw, if (i < current->sps_num_subpics_minus1 && current->sps_pic_height_max_in_luma_samples > ctb_size_y) { - const unsigned int win_top_edge = + const int win_top_edge = current->sps_conf_win_top_offset * sub_height_c; - const unsigned int win_top_edge_ctus = + const int win_top_edge_ctus = AV_CEIL_RSHIFT(win_top_edge, ctb_log2_size_y); us(hlen, sps_subpic_height_minus1[i], win_top_edge_ctus > current->sps_subpic_ctu_top_left_y[i] diff --git a/src/ExtLib/ffmpeg/libavcodec/codec_desc.c b/src/ExtLib/ffmpeg/libavcodec/codec_desc.c index 315c758acb..aeac75a6c5 100644 --- a/src/ExtLib/ffmpeg/libavcodec/codec_desc.c +++ b/src/ExtLib/ffmpeg/libavcodec/codec_desc.c @@ -905,7 +905,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .type = AVMEDIA_TYPE_VIDEO, .name = "tgq", .long_name = NULL_IF_CONFIG_SMALL("Electronic Arts TGQ video"), - .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, + .props = AV_CODEC_PROP_LOSSY, }, { .id = AV_CODEC_ID_TQI, diff --git a/src/ExtLib/ffmpeg/libavcodec/h2645_sei.c b/src/ExtLib/ffmpeg/libavcodec/h2645_sei.c index 33551f5406..986d1d250a 100644 --- a/src/ExtLib/ffmpeg/libavcodec/h2645_sei.c +++ b/src/ExtLib/ffmpeg/libavcodec/h2645_sei.c @@ -26,6 +26,7 @@ #include "config_components.h" #include "libavutil/ambient_viewing_environment.h" +#include "libavutil/buffer.h" #include "libavutil/display.h" #include "libavutil/hdr_dynamic_metadata.h" #include "libavutil/film_grain_params.h" @@ -41,6 +42,7 @@ #include "golomb.h" #include "h2645_sei.h" #include "itut35.h" +#include "refstruct.h" #define IS_H264(codec_id) (CONFIG_H264_SEI && CONFIG_HEVC_SEI ? codec_id == AV_CODEC_ID_H264 : CONFIG_H264_SEI) #define IS_HEVC(codec_id) (CONFIG_H264_SEI && CONFIG_HEVC_SEI ? codec_id == AV_CODEC_ID_HEVC : CONFIG_HEVC_SEI) @@ -245,12 +247,7 @@ static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb, provider_oriented_code = bytestream2_get_byteu(gb); if (provider_oriented_code == aom_grain_provider_oriented_code) { - if (!h->aom_film_grain) { - h->aom_film_grain = av_mallocz(sizeof(*h->aom_film_grain)); - if (!h->aom_film_grain) - return AVERROR(ENOMEM); - } - return ff_aom_parse_film_grain_sets(h->aom_film_grain, + return ff_aom_parse_film_grain_sets(&h->aom_film_grain, gb->buffer, bytestream2_get_bytes_left(gb)); } @@ -499,11 +496,10 @@ int ff_h2645_sei_message_decode(H2645SEI *h, enum SEIType type, case SEI_TYPE_DISPLAY_ORIENTATION: return decode_display_orientation(&h->display_orientation, gb); case SEI_TYPE_FILM_GRAIN_CHARACTERISTICS: - if (!h->film_grain_characteristics) { - h->film_grain_characteristics = av_mallocz(sizeof(*h->film_grain_characteristics)); - if (!h->film_grain_characteristics) - return AVERROR(ENOMEM); - } + ff_refstruct_unref(&h->film_grain_characteristics); + h->film_grain_characteristics = ff_refstruct_allocz(sizeof(*h->film_grain_characteristics)); + if (!h->film_grain_characteristics) + return AVERROR(ENOMEM); return decode_film_grain_characteristics(h->film_grain_characteristics, codec_id, gb); case SEI_TYPE_FRAME_PACKING_ARRANGEMENT: return decode_frame_packing_arrangement(&h->frame_packing, gb, codec_id); @@ -552,6 +548,20 @@ int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src) } } + for (unsigned i = 0; i < FF_ARRAY_ELEMS(dst->aom_film_grain.sets); i++) { + ret = av_buffer_replace(&dst->aom_film_grain.sets[i], + src->aom_film_grain.sets[i]); + if (ret < 0) + return ret; + } + dst->aom_film_grain.enable = src->aom_film_grain.enable; + + dst->mastering_display = src->mastering_display; + dst->content_light = src->content_light; + + ff_refstruct_replace(&dst->film_grain_characteristics, + src->film_grain_characteristics); + return 0; } @@ -894,11 +904,9 @@ FF_ENABLE_DEPRECATION_WARNINGS } #if CONFIG_HEVC_SEI - if (sei->aom_film_grain) { - ret = ff_aom_attach_film_grain_sets(sei->aom_film_grain, frame); - if (ret < 0) - return ret; - } + ret = ff_aom_attach_film_grain_sets(&sei->aom_film_grain, frame); + if (ret < 0) + return ret; #endif return 0; @@ -926,6 +934,6 @@ void ff_h2645_sei_reset(H2645SEI *s) s->mastering_display.present = 0; s->content_light.present = 0; - av_freep(&s->film_grain_characteristics); - av_freep(&s->aom_film_grain); + ff_refstruct_unref(&s->film_grain_characteristics); + ff_aom_uninit_film_grain_params(&s->aom_film_grain); } diff --git a/src/ExtLib/ffmpeg/libavcodec/h2645_sei.h b/src/ExtLib/ffmpeg/libavcodec/h2645_sei.h index 8bcdc2bc5f..abc49760d9 100644 --- a/src/ExtLib/ffmpeg/libavcodec/h2645_sei.h +++ b/src/ExtLib/ffmpeg/libavcodec/h2645_sei.h @@ -138,10 +138,10 @@ typedef struct H2645SEI { H2645SEIAmbientViewingEnvironment ambient_viewing_environment; H2645SEIMasteringDisplay mastering_display; H2645SEIContentLight content_light; + AVFilmGrainAFGS1Params aom_film_grain; // Dynamic allocations due to large size. - H2645SEIFilmGrainCharacteristics* film_grain_characteristics; - AVFilmGrainAFGS1Params* aom_film_grain; + H2645SEIFilmGrainCharacteristics *film_grain_characteristics; } H2645SEI; enum { diff --git a/src/ExtLib/ffmpeg/libavcodec/h264_picture.c b/src/ExtLib/ffmpeg/libavcodec/h264_picture.c index c333d94fbb..3055b38194 100644 --- a/src/ExtLib/ffmpeg/libavcodec/h264_picture.c +++ b/src/ExtLib/ffmpeg/libavcodec/h264_picture.c @@ -27,7 +27,6 @@ #include "libavutil/avassert.h" #include "libavutil/emms.h" -#include "libavutil/mem.h" #include "error_resilience.h" #include "avcodec.h" #include "h264dec.h" @@ -213,15 +212,9 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup) const AVFrameSideData *sd = av_frame_get_side_data(cur->f, AV_FRAME_DATA_FILM_GRAIN_PARAMS); err = AVERROR_INVALIDDATA; - if (sd) { // a decoding error may have happened before the side data could be allocated - if (!h->h274db) { - h->h274db = av_mallocz(sizeof(*h->h274db)); - if (!h->h274db) - return AVERROR(ENOMEM); - } - err = ff_h274_apply_film_grain(cur->f_grain, cur->f, h->h274db, + if (sd) // a decoding error may have happened before the side data could be allocated + err = ff_h274_apply_film_grain(cur->f_grain, cur->f, &h->h274db, (AVFilmGrainParams *) sd->data); - } if (err < 0) { av_log(h->avctx, AV_LOG_WARNING, "Failed synthesizing film " "grain, ignoring: %s\n", av_err2str(err)); diff --git a/src/ExtLib/ffmpeg/libavcodec/h264_sei.h b/src/ExtLib/ffmpeg/libavcodec/h264_sei.h index 1d68e31705..110fc0df99 100644 --- a/src/ExtLib/ffmpeg/libavcodec/h264_sei.h +++ b/src/ExtLib/ffmpeg/libavcodec/h264_sei.h @@ -129,12 +129,6 @@ 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. */ diff --git a/src/ExtLib/ffmpeg/libavcodec/h264_slice.c b/src/ExtLib/ffmpeg/libavcodec/h264_slice.c index 0403b79f07..f3299ff3be 100644 --- a/src/ExtLib/ffmpeg/libavcodec/h264_slice.c +++ b/src/ExtLib/ffmpeg/libavcodec/h264_slice.c @@ -437,13 +437,11 @@ int ff_h264_update_thread_context(AVCodecContext *dst, h->frame_recovered = h1->frame_recovered; - ret = ff_h264_sei_ctx_replace(&h->sei, &h1->sei); + ret = ff_h2645_sei_ctx_replace(&h->sei.common, &h1->sei.common); if (ret < 0) return ret; h->sei.common.unregistered.x264_build = h1->sei.common.unregistered.x264_build; - h->sei.common.mastering_display = h1->sei.common.mastering_display; - h->sei.common.content_light = h1->sei.common.content_light; if (!h->cur_pic_ptr) return 0; diff --git a/src/ExtLib/ffmpeg/libavcodec/h264dec.c b/src/ExtLib/ffmpeg/libavcodec/h264dec.c index 623314fc56..ddfeb08f1f 100644 --- a/src/ExtLib/ffmpeg/libavcodec/h264dec.c +++ b/src/ExtLib/ffmpeg/libavcodec/h264dec.c @@ -156,8 +156,6 @@ void ff_h264_free_tables(H264Context *h) av_freep(&h->mb2b_xy); av_freep(&h->mb2br_xy); - av_freep(&h->h274db); - ff_refstruct_pool_uninit(&h->qscale_table_pool); ff_refstruct_pool_uninit(&h->mb_type_pool); ff_refstruct_pool_uninit(&h->motion_val_pool); diff --git a/src/ExtLib/ffmpeg/libavcodec/h264dec.h b/src/ExtLib/ffmpeg/libavcodec/h264dec.h index 9d2580ab61..8d46ffb22b 100644 --- a/src/ExtLib/ffmpeg/libavcodec/h264dec.h +++ b/src/ExtLib/ffmpeg/libavcodec/h264dec.h @@ -346,7 +346,7 @@ typedef struct H264Context { H264DSPContext h264dsp; H264ChromaContext h264chroma; H264QpelContext h264qpel; - H274FilmGrainDatabase* h274db; // Dyanmic allocation due to large size. + H274FilmGrainDatabase h274db; H264Picture DPB[H264_MAX_PICTURE_COUNT]; H264Picture *cur_pic_ptr; diff --git a/src/ExtLib/ffmpeg/libavcodec/hevc/hevcdec.c b/src/ExtLib/ffmpeg/libavcodec/hevc/hevcdec.c index ce234bfeb6..f702d4800d 100644 --- a/src/ExtLib/ffmpeg/libavcodec/hevc/hevcdec.c +++ b/src/ExtLib/ffmpeg/libavcodec/hevc/hevcdec.c @@ -413,7 +413,7 @@ static int export_stream_params_from_sei(HEVCContext *s) } if ((s->sei.common.film_grain_characteristics && s->sei.common.film_grain_characteristics->present) || - (s->sei.common.aom_film_grain && s->sei.common.aom_film_grain->enable)) + s->sei.common.aom_film_grain.enable) avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN; return 0; @@ -3299,8 +3299,9 @@ static int hevc_frame_start(HEVCContext *s, HEVCLayerContext *l, else s->cur_frame->f->flags &= ~AV_FRAME_FLAG_KEY; - s->cur_frame->needs_fg = ((s->sei.common.film_grain_characteristics && s->sei.common.film_grain_characteristics->present) || - (s->sei.common.aom_film_grain && s->sei.common.aom_film_grain->enable)) && + s->cur_frame->needs_fg = ((s->sei.common.film_grain_characteristics && + s->sei.common.film_grain_characteristics->present) || + s->sei.common.aom_film_grain.enable) && !(s->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) && !s->avctx->hwaccel; @@ -3447,13 +3448,8 @@ static int hevc_frame_end(HEVCContext *s, HEVCLayerContext *l) av_assert0(0); return AVERROR_BUG; case AV_FILM_GRAIN_PARAMS_H274: - if (!s->h274db) { - s->h274db = av_mallocz(sizeof(*s->h274db)); - if (!s->h274db) - return AVERROR(ENOMEM); - } ret = ff_h274_apply_film_grain(out->frame_grain, out->f, - s->h274db, fgp); + &s->h274db, fgp); break; case AV_FILM_GRAIN_PARAMS_AV1: ret = ff_aom_apply_film_grain(out->frame_grain, out->f, fgp); @@ -3881,7 +3877,6 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx) av_buffer_unref(&s->rpu_buf); av_freep(&s->md5_ctx); - av_freep(&s->h274db); ff_container_fifo_free(&s->output_fifo); @@ -4040,9 +4035,6 @@ static int hevc_update_thread_context(AVCodecContext *dst, s->sei.common.frame_packing = s0->sei.common.frame_packing; s->sei.common.display_orientation = s0->sei.common.display_orientation; s->sei.common.alternative_transfer = s0->sei.common.alternative_transfer; - s->sei.common.mastering_display = s0->sei.common.mastering_display; - s->sei.common.content_light = s0->sei.common.content_light; - s->sei.common.aom_film_grain = s0->sei.common.aom_film_grain; s->sei.tdrdi = s0->sei.tdrdi; return 0; diff --git a/src/ExtLib/ffmpeg/libavcodec/hevc/hevcdec.h b/src/ExtLib/ffmpeg/libavcodec/hevc/hevcdec.h index 73b792c880..473709b4e8 100644 --- a/src/ExtLib/ffmpeg/libavcodec/hevc/hevcdec.h +++ b/src/ExtLib/ffmpeg/libavcodec/hevc/hevcdec.h @@ -531,7 +531,7 @@ typedef struct HEVCContext { HEVCDSPContext hevcdsp; VideoDSPContext vdsp; BswapDSPContext bdsp; - H274FilmGrainDatabase* h274db; // Dynamically allocated due to large size. + H274FilmGrainDatabase h274db; /** used on BE to byteswap the lines for checksumming */ uint8_t *checksum_buf; diff --git a/src/ExtLib/ffmpeg/libavcodec/hevc/sei.h b/src/ExtLib/ffmpeg/libavcodec/hevc/sei.h index 806540fac6..ee640003bc 100644 --- a/src/ExtLib/ffmpeg/libavcodec/hevc/sei.h +++ b/src/ExtLib/ffmpeg/libavcodec/hevc/sei.h @@ -109,11 +109,6 @@ struct HEVCParamSets; int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s, const struct HEVCParamSets *ps, enum HEVCNALUnitType type); -static inline int ff_hevc_sei_ctx_replace(HEVCSEI *dst, const HEVCSEI *src) -{ - return ff_h2645_sei_ctx_replace(&dst->common, &src->common); -} - /** * Reset SEI values that are stored on the Context. * e.g. Caption data that was extracted during NAL diff --git a/src/ExtLib/ffmpeg/libavcodec/vvc/intra_utils.c b/src/ExtLib/ffmpeg/libavcodec/vvc/intra_utils.c index 8c40eb1b16..7229222b95 100644 --- a/src/ExtLib/ffmpeg/libavcodec/vvc/intra_utils.c +++ b/src/ExtLib/ffmpeg/libavcodec/vvc/intra_utils.c @@ -184,13 +184,13 @@ int ff_vvc_intra_pred_angle_derive(const int pred_mode) return intra_pred_angle; } -#define ROUND(f) (int)(f < 0 ? -(-f + 0.5) : (f + 0.5)) int ff_vvc_intra_inv_angle_derive(const int intra_pred_angle) { - float inv_angle; - av_assert0(intra_pred_angle); - inv_angle = 32 * 512.0 / intra_pred_angle; - return ROUND(inv_angle); + av_assert2(intra_pred_angle != 0); + if (intra_pred_angle > 0) + return ROUNDED_DIV(32*512, intra_pred_angle); + else + return -ROUNDED_DIV(32*512, -intra_pred_angle); } //8.4.5.2.7 Wide angle intra prediction mode mapping proces diff --git a/src/ExtLib/ffmpeg/libavcodec/x86/diracdsp.asm b/src/ExtLib/ffmpeg/libavcodec/x86/diracdsp.asm index e5e2b11846..6ae7f888b3 100644 --- a/src/ExtLib/ffmpeg/libavcodec/x86/diracdsp.asm +++ b/src/ExtLib/ffmpeg/libavcodec/x86/diracdsp.asm @@ -216,8 +216,9 @@ cglobal add_rect_clamped_%1, 7,9,3, dst, src, stride, idwt, idwt_stride, w, h %macro ADD_OBMC 2 ; void add_obmc(uint16_t *dst, uint8_t *src, int stride, uint8_t *obmc_weight, int yblen) -cglobal add_dirac_obmc%1_%2, 6,6,5, dst, src, stride, obmc, yblen +cglobal add_dirac_obmc%1_%2, 5,5,5, dst, src, stride, obmc, yblen pxor m4, m4 + movsxdifnidn strideq, strided .loop: %assign i 0 %rep %1 / mmsize @@ -227,7 +228,7 @@ cglobal add_dirac_obmc%1_%2, 6,6,5, dst, src, stride, obmc, yblen punpckhbw m1, m4 mova m2, [obmcq+i] mova m3, m2 - punpcklbw m2, m4 + punpcklbw m2, m4 punpckhbw m3, m4 pmullw m0, m2 pmullw m1, m3 @@ -247,9 +248,6 @@ cglobal add_dirac_obmc%1_%2, 6,6,5, dst, src, stride, obmc, yblen RET %endm -INIT_MMX -ADD_OBMC 8, mmx - INIT_XMM PUT_RECT sse2 ADD_RECT sse2 @@ -258,6 +256,25 @@ HPEL_FILTER sse2 ADD_OBMC 32, sse2 ADD_OBMC 16, sse2 +cglobal add_dirac_obmc8_sse2, 5,5,4, dst, src, stride, obmc, yblen + pxor m3, m3 + movsxdifnidn strideq, strided +.loop: + movh m0, [srcq] + punpcklbw m0, m3 + movh m1, [obmcq] + punpcklbw m1, m3 + pmullw m0, m1 + movu m1, [dstq] + paddw m0, m1 + movu [dstq], m0 + lea srcq, [srcq+strideq] + lea dstq, [dstq+2*strideq] + add obmcq, 32 + sub yblend, 1 + jg .loop + RET + INIT_XMM sse4 ; void dequant_subband_32(uint8_t *src, uint8_t *dst, ptrdiff_t stride, const int qf, const int qs, int tot_v, int tot_h) diff --git a/src/ExtLib/ffmpeg/libavcodec/x86/diracdsp_init.c b/src/ExtLib/ffmpeg/libavcodec/x86/diracdsp_init.c index f678759dc0..ef01ebdf2e 100644 --- a/src/ExtLib/ffmpeg/libavcodec/x86/diracdsp_init.c +++ b/src/ExtLib/ffmpeg/libavcodec/x86/diracdsp_init.c @@ -24,8 +24,7 @@ void ff_add_rect_clamped_sse2(uint8_t *, const uint16_t *, int, const int16_t *, int, int, int); -void ff_add_dirac_obmc8_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen); - +void ff_add_dirac_obmc8_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen); void ff_add_dirac_obmc16_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen); void ff_add_dirac_obmc32_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen); @@ -57,11 +56,6 @@ void ff_dequant_subband_32_sse4(uint8_t *src, uint8_t *dst, ptrdiff_t stride, co } \ } -#define PIXFUNC(PFX, IDX, EXT) \ - /*MMXDISABLEDc->PFX ## _dirac_pixels_tab[0][IDX] = PFX ## _dirac_pixels8_ ## EXT;*/ \ - c->PFX ## _dirac_pixels_tab[1][IDX] = PFX ## _dirac_pixels16_ ## EXT; \ - c->PFX ## _dirac_pixels_tab[2][IDX] = PFX ## _dirac_pixels32_ ## EXT - #define DIRAC_PIXOP(OPNAME, EXT)\ static void OPNAME ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], \ int stride, int h) \ @@ -94,15 +88,12 @@ void ff_diracdsp_init_x86(DiracDSPContext* c) #if HAVE_X86ASM int mm_flags = av_get_cpu_flags(); - if (EXTERNAL_MMX(mm_flags)) { - c->add_dirac_obmc[0] = ff_add_dirac_obmc8_mmx; - } - if (EXTERNAL_SSE2(mm_flags)) { c->dirac_hpel_filter = dirac_hpel_filter_sse2; c->add_rect_clamped = ff_add_rect_clamped_sse2; c->put_signed_rect_clamped[0] = (void *)ff_put_signed_rect_clamped_sse2; + c->add_dirac_obmc[0] = ff_add_dirac_obmc8_sse2; c->add_dirac_obmc[1] = ff_add_dirac_obmc16_sse2; c->add_dirac_obmc[2] = ff_add_dirac_obmc32_sse2; @@ -116,5 +107,5 @@ void ff_diracdsp_init_x86(DiracDSPContext* c) c->dequant_subband[1] = ff_dequant_subband_32_sse4; c->put_signed_rect_clamped[1] = ff_put_signed_rect_clamped_10_sse4; } -#endif +#endif // HAVE_X86ASM } diff --git a/src/ExtLib/ffmpeg/libavcodec/x86/vvc/vvcdsp_init.c b/src/ExtLib/ffmpeg/libavcodec/x86/vvc/vvcdsp_init.c index f3e2e3a27b..31bb80e109 100644 --- a/src/ExtLib/ffmpeg/libavcodec/x86/vvc/vvcdsp_init.c +++ b/src/ExtLib/ffmpeg/libavcodec/x86/vvc/vvcdsp_init.c @@ -30,6 +30,8 @@ #include "libavcodec/vvc/dsp.h" #include "libavcodec/x86/h26x/h2656dsp.h" +#if ARCH_X86_64 + #define PUT_PROTOTYPE(name, depth, opt) \ void ff_vvc_put_ ## name ## _ ## depth ## _##opt(int16_t *dst, const uint8_t *src, ptrdiff_t srcstride, int height, const int8_t *hf, const int8_t *vf, int width); @@ -102,19 +104,29 @@ DMVR_PROTOTYPES( 8, avx2) DMVR_PROTOTYPES(10, avx2) DMVR_PROTOTYPES(12, avx2) +#define OF_PROTOTYPES(bd, opt) \ +void ff_vvc_apply_bdof_##bd##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \ + const int16_t *src0, const int16_t *src1, int w, int h); \ + +OF_PROTOTYPES( 8, avx2) +OF_PROTOTYPES(10, avx2) +OF_PROTOTYPES(12, avx2) + +#if ARCH_X86_64 && HAVE_AVX2_EXTERNAL void ff_vvc_apply_bdof_avx2(uint8_t *dst, ptrdiff_t dst_stride, \ const int16_t *src0, const int16_t *src1, int w, int h, int pixel_max); \ -#define OF_PROTOTYPES(bd, opt) \ -static void ff_vvc_apply_bdof_##bd##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \ +#define OF_FUNC(bd, opt) \ +void ff_vvc_apply_bdof_##bd##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \ const int16_t *src0, const int16_t *src1, int w, int h) \ { \ ff_vvc_apply_bdof##_##opt(dst, dst_stride, src0, src1, w, h, (1 << bd) - 1); \ } \ -OF_PROTOTYPES( 8, avx2) -OF_PROTOTYPES(10, avx2) -OF_PROTOTYPES(12, avx2) +OF_FUNC( 8, avx2) +OF_FUNC(10, avx2) +OF_FUNC(12, avx2) +#endif #define ALF_BPC_PROTOTYPES(bpc, opt) \ void BF(ff_vvc_alf_filter_luma, bpc, opt)(uint8_t *dst, ptrdiff_t dst_stride, \ @@ -356,6 +368,9 @@ int ff_vvc_sad_avx2(const int16_t *src0, const int16_t *src1, int dx, int dy, in #define SAD_INIT() c->inter.sad = ff_vvc_sad_avx2 #endif + +#endif // ARCH_X86_64 + void ff_vvc_dsp_init_x86(VVCDSPContext *const c, const int bd) { #if ARCH_X86_64 diff --git a/src/ExtLib/ffmpeg/libavfilter/framepool.c b/src/ExtLib/ffmpeg/libavfilter/framepool.c index e8621e07ac..1a1fc0de1e 100644 --- a/src/ExtLib/ffmpeg/libavfilter/framepool.c +++ b/src/ExtLib/ffmpeg/libavfilter/framepool.c @@ -139,7 +139,9 @@ FFFramePool *ff_frame_pool_audio_init(AVBufferRef* (*alloc)(size_t size), if (ret < 0) goto fail; - pool->pools[0] = av_buffer_pool_init(pool->linesize[0], NULL); + if (pool->linesize[0] > SIZE_MAX - align) + goto fail; + pool->pools[0] = av_buffer_pool_init(pool->linesize[0] + align, NULL); if (!pool->pools[0]) goto fail; @@ -219,7 +221,7 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool) if (!frame->buf[i]) goto fail; - frame->data[i] = frame->buf[i]->data; + frame->data[i] = (uint8_t *)FFALIGN((uintptr_t)frame->buf[i]->data, pool->align); } if (desc->flags & AV_PIX_FMT_FLAG_PAL) { @@ -256,13 +258,15 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool) frame->buf[i] = av_buffer_pool_get(pool->pools[0]); if (!frame->buf[i]) goto fail; - frame->extended_data[i] = frame->data[i] = frame->buf[i]->data; + frame->extended_data[i] = frame->data[i] = + (uint8_t *)FFALIGN((uintptr_t)frame->buf[i]->data, pool->align); } for (i = 0; i < frame->nb_extended_buf; i++) { frame->extended_buf[i] = av_buffer_pool_get(pool->pools[0]); if (!frame->extended_buf[i]) goto fail; - frame->extended_data[i + AV_NUM_DATA_POINTERS] = frame->extended_buf[i]->data; + frame->extended_data[i + AV_NUM_DATA_POINTERS] = + (uint8_t *)FFALIGN((uintptr_t)frame->extended_buf[i]->data, pool->align); } break; diff --git a/src/ExtLib/ffmpeg/libavutil/channel_layout.c b/src/ExtLib/ffmpeg/libavutil/channel_layout.c index 34f88290bd..0f320627ae 100644 --- a/src/ExtLib/ffmpeg/libavutil/channel_layout.c +++ b/src/ExtLib/ffmpeg/libavutil/channel_layout.c @@ -79,6 +79,8 @@ static const struct channel_name channel_names[] = { [AV_CHAN_SIDE_SURROUND_RIGHT ] = { "SSR", "side surround right" }, [AV_CHAN_TOP_SURROUND_LEFT ] = { "TTL", "top surround left" }, [AV_CHAN_TOP_SURROUND_RIGHT ] = { "TTR", "top surround right" }, + [AV_CHAN_BINAURAL_LEFT ] = { "BIL", "binaural left" }, + [AV_CHAN_BINAURAL_RIGHT ] = { "BIR", "binaural right" }, }; void av_channel_name_bprint(AVBPrint *bp, enum AVChannel channel_id) @@ -220,6 +222,7 @@ static const struct channel_layout_name channel_layout_map[] = { { "7.2.3", AV_CHANNEL_LAYOUT_7POINT2POINT3 }, { "9.1.4", AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK }, { "hexadecagonal", AV_CHANNEL_LAYOUT_HEXADECAGONAL }, + { "binaural", AV_CHANNEL_LAYOUT_BINAURAL }, { "downmix", AV_CHANNEL_LAYOUT_STEREO_DOWNMIX, }, { "22.2", AV_CHANNEL_LAYOUT_22POINT2, }, }; diff --git a/src/ExtLib/ffmpeg/libavutil/channel_layout.h b/src/ExtLib/ffmpeg/libavutil/channel_layout.h index 3516fa7719..2012a72a53 100644 --- a/src/ExtLib/ffmpeg/libavutil/channel_layout.h +++ b/src/ExtLib/ffmpeg/libavutil/channel_layout.h @@ -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 ) /** * @} @@ -244,6 +249,7 @@ enum AVChannelOrder { #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_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) @@ -418,6 +424,7 @@ typedef struct AVChannelLayout { #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_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/src/ExtLib/ffmpeg/libavutil/version.h b/src/ExtLib/ffmpeg/libavutil/version.h index 84a7cb1c02..c1878a49ad 100644 --- a/src/ExtLib/ffmpeg/libavutil/version.h +++ b/src/ExtLib/ffmpeg/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 59 -#define LIBAVUTIL_VERSION_MINOR 46 +#define LIBAVUTIL_VERSION_MINOR 47 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \