Skip to content

Commit

Permalink
Обновлен ffmpeg n7.2-dev-615-g7332b1700e.
Browse files Browse the repository at this point in the history
  • Loading branch information
v0lt committed Nov 16, 2024
1 parent 77a039b commit 3819b3a
Show file tree
Hide file tree
Showing 24 changed files with 160 additions and 112 deletions.
2 changes: 1 addition & 1 deletion docs/Changelog.Rus.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
49 changes: 39 additions & 10 deletions src/ExtLib/ffmpeg/libavcodec/aom_film_grain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion src/ExtLib/ffmpeg/libavcodec/aom_film_grain.h
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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 */
12 changes: 6 additions & 6 deletions src/ExtLib/ffmpeg/libavcodec/cbs_h266_syntax_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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]
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/ExtLib/ffmpeg/libavcodec/codec_desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
44 changes: 26 additions & 18 deletions src/ExtLib/ffmpeg/libavcodec/h2645_sei.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions src/ExtLib/ffmpeg/libavcodec/h2645_sei.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 2 additions & 9 deletions src/ExtLib/ffmpeg/libavcodec/h264_picture.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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));
Expand Down
6 changes: 0 additions & 6 deletions src/ExtLib/ffmpeg/libavcodec/h264_sei.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
4 changes: 1 addition & 3 deletions src/ExtLib/ffmpeg/libavcodec/h264_slice.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/ExtLib/ffmpeg/libavcodec/h264dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/ExtLib/ffmpeg/libavcodec/h264dec.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 3819b3a

Please sign in to comment.