[FFmpeg-devel] [PATCH 1/2] swscale/output: alpha can become negative after scaling, use multiply
Fixes: left shift of negative value -3245 Fixes: 69047/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-6571511551950848 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libswscale/output.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libswscale/output.c b/libswscale/output.c index b234f9c6b9a..f9ce43dde80 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -1221,8 +1221,8 @@ yuv2rgba64_1_c_template(SwsContext *c, const int32_t *buf0, Y2 += (1 << 13) - (1 << 29); if (hasAlpha) { -A1 = abuf0[i * 2] << 11; -A2 = abuf0[i * 2 + 1] << 11; +A1 = abuf0[i * 2] * (1 << 11); +A2 = abuf0[i * 2 + 1] * (1 << 11); A1 += 1 << 13; A2 += 1 << 13; @@ -1267,8 +1267,8 @@ yuv2rgba64_1_c_template(SwsContext *c, const int32_t *buf0, Y2 += (1 << 13) - (1 << 29); if (hasAlpha) { -A1 = abuf0[i * 2] << 11; -A2 = abuf0[i * 2 + 1] << 11; +A1 = abuf0[i * 2] * (1 << 11); +A2 = abuf0[i * 2 + 1] * (1 << 11); A1 += 1 << 13; A2 += 1 << 13; @@ -1439,7 +1439,7 @@ yuv2rgba64_full_1_c_template(SwsContext *c, const int32_t *buf0, Y += (1 << 13) - (1 << 29); if (hasAlpha) { -A = abuf0[i] << 11; +A = abuf0[i] * (1 << 11); A += 1 << 13; } @@ -1472,7 +1472,7 @@ yuv2rgba64_full_1_c_template(SwsContext *c, const int32_t *buf0, Y += (1 << 13) - (1 << 29); if (hasAlpha) { -A = abuf0[i] << 11; +A = abuf0[i] * (1 << 11); A += 1 << 13; } -- 2.45.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] swscale/output: Avoid undefined overflow in yuv2rgb_write_full()
Fixes: signed integer overflow: -140140 * 16525 cannot be represented in type 'int' Fixes: 68859/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-4516387130245120 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libswscale/output.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libswscale/output.c b/libswscale/output.c index f9ce43dde80..0e6181b3e01 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -1925,9 +1925,9 @@ static av_always_inline void yuv2rgb_write_full(SwsContext *c, Y -= c->yuv2rgb_y_offset; Y *= c->yuv2rgb_y_coeff; Y += 1 << 21; -R = (unsigned)Y + V*c->yuv2rgb_v2r_coeff; -G = (unsigned)Y + V*c->yuv2rgb_v2g_coeff + U*c->yuv2rgb_u2g_coeff; -B = (unsigned)Y + U*c->yuv2rgb_u2b_coeff; +R = (unsigned)Y + V*(unsigned)c->yuv2rgb_v2r_coeff; +G = (unsigned)Y + V*(unsigned)c->yuv2rgb_v2g_coeff + U*(unsigned)c->yuv2rgb_u2g_coeff; +B = (unsigned)Y + U*(unsigned)c->yuv2rgb_u2b_coeff; if ((R | G | B) & 0xC000) { R = av_clip_uintp2(R, 30); G = av_clip_uintp2(G, 30); -- 2.45.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/6] aacdec_usac: apply specification fix M55715
--- libavcodec/aac/aacdec_usac.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index 98e8c1c0bc..065bc869d9 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -835,6 +835,11 @@ static int decode_usac_stereo_info(AACDecContext *ac, AACUSACConfig *usac, tns_active = get_bits1(gb); us->common_window = get_bits1(gb); +if (!us->common_window || indep_flag) { +memset(us->prev_alpha_q_re, 0, sizeof(us->prev_alpha_q_re)); +memset(us->prev_alpha_q_im, 0, sizeof(us->prev_alpha_q_im)); +} + if (us->common_window) { /* ics_info() */ ics1->window_sequence[1] = ics1->window_sequence[0]; @@ -845,6 +850,20 @@ static int decode_usac_stereo_info(AACDecContext *ac, AACUSACConfig *usac, ics2->use_kb_window[1] = ics2->use_kb_window[0]; ics1->use_kb_window[0] = ics2->use_kb_window[0] = get_bits1(gb); +/* If there's a change in the transform sequence, zero out last frame's + * stereo prediction coefficients */ +if ((ics1->window_sequence[0] == EIGHT_SHORT_SEQUENCE && + ics1->window_sequence[1] != EIGHT_SHORT_SEQUENCE) || +(ics1->window_sequence[1] == EIGHT_SHORT_SEQUENCE && + ics1->window_sequence[0] != EIGHT_SHORT_SEQUENCE) || +(ics2->window_sequence[0] == EIGHT_SHORT_SEQUENCE && + ics2->window_sequence[1] != EIGHT_SHORT_SEQUENCE) || +(ics2->window_sequence[1] == EIGHT_SHORT_SEQUENCE && + ics2->window_sequence[0] != EIGHT_SHORT_SEQUENCE)) { +memset(us->prev_alpha_q_re, 0, sizeof(us->prev_alpha_q_re)); +memset(us->prev_alpha_q_im, 0, sizeof(us->prev_alpha_q_im)); +} + if (ics1->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { ics1->max_sfb = ics2->max_sfb = get_bits(gb, 4); ue1->scale_factor_grouping = ue2->scale_factor_grouping = get_bits(gb, 7); -- 2.45.1.288.g0e0cd299f1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/6] aac: expose ff_aac_sample_rate_idx() in aac.h
The rate index is a value important to both encoders and decoders. USAC needs it as well, so put it into the shared main header. --- libavcodec/aac.h| 16 libavcodec/aac/aacdec.c | 18 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/libavcodec/aac.h b/libavcodec/aac.h index fc6d1361b2..78026a5887 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -103,4 +103,20 @@ typedef struct Pulse { int amp[4]; } Pulse; +static inline int ff_aac_sample_rate_idx(int rate) +{ + if (92017 <= rate) return 0; +else if (75132 <= rate) return 1; +else if (55426 <= rate) return 2; +else if (46009 <= rate) return 3; +else if (37566 <= rate) return 4; +else if (27713 <= rate) return 5; +else if (23004 <= rate) return 6; +else if (18783 <= rate) return 7; +else if (13856 <= rate) return 8; +else if (11502 <= rate) return 9; +else if (9391 <= rate) return 10; +elsereturn 11; +} + #endif /* AVCODEC_AAC_H */ diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index eecb6d8f3d..ea2ba84a80 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -1095,22 +1095,6 @@ static int decode_audio_specific_config(AACDecContext *ac, sync_extension); } -static int sample_rate_idx (int rate) -{ - if (92017 <= rate) return 0; -else if (75132 <= rate) return 1; -else if (55426 <= rate) return 2; -else if (46009 <= rate) return 3; -else if (37566 <= rate) return 4; -else if (27713 <= rate) return 5; -else if (23004 <= rate) return 6; -else if (18783 <= rate) return 7; -else if (13856 <= rate) return 8; -else if (11502 <= rate) return 9; -else if (9391 <= rate) return 10; -elsereturn 11; -} - static av_cold int decode_close(AVCodecContext *avctx) { AACDecContext *ac = avctx->priv_data; @@ -1211,7 +1195,7 @@ av_cold int ff_aac_decode_init(AVCodecContext *avctx) uint8_t layout_map[MAX_ELEM_ID*4][3]; int layout_map_tags; -sr = sample_rate_idx(avctx->sample_rate); +sr = ff_aac_sample_rate_idx(avctx->sample_rate); ac->oc[1].m4ac.sampling_index = sr; ac->oc[1].m4ac.channels = avctx->ch_layout.nb_channels; ac->oc[1].m4ac.sbr = -1; -- 2.45.1.288.g0e0cd299f1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/6] aacdec_ac: fix an overread
Fixes reading state->last[i + 1] in ff_aac_ac_get_context for the last array member. --- libavcodec/aac/aacdec_ac.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/aac/aacdec_ac.h b/libavcodec/aac/aacdec_ac.h index 0b98c0f0d9..b8d4ade4c6 100644 --- a/libavcodec/aac/aacdec_ac.h +++ b/libavcodec/aac/aacdec_ac.h @@ -25,7 +25,7 @@ #include "libavcodec/get_bits.h" typedef struct AACArithState { -uint8_t last[512 /* 2048 / 4 */]; +uint8_t last[512 /* 2048 / 4 */ + 1]; int last_len; uint8_t cur[4]; uint16_t state_pre; -- 2.45.1.288.g0e0cd299f1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/6] aacdec_usac: rename noise_scale to noise_bands
This was a typo. --- libavcodec/aac/aacdec.h | 2 +- libavcodec/aac/aacdec_usac.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h index 86faf6454a..d1a80e9ac1 100644 --- a/libavcodec/aac/aacdec.h +++ b/libavcodec/aac/aacdec.h @@ -315,7 +315,7 @@ typedef struct AACUsacElemConfig { uint8_t freq_scale; /* dflt_freq_scale */ uint8_t alter_scale : 1; /* dflt_alter_scale */ -uint8_t noise_scale; /* dflt_noise_scale */ +uint8_t noise_bands; /* dflt_noise_bands */ uint8_t limiter_bands; /* dflt_limiter_bands */ uint8_t limiter_gains; /* dflt_limiter_gains */ diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index 065bc869d9..eb0e7d3659 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -162,11 +162,11 @@ static void decode_usac_sbr_data(AACUsacElemConfig *e, GetBitContext *gb) e->sbr.dflt.freq_scale = 2; e->sbr.dflt.alter_scale = 1; -e->sbr.dflt.noise_scale = 2; +e->sbr.dflt.noise_bands = 2; if (header_extra1) { e->sbr.dflt.freq_scale = get_bits(gb, 2); /* dflt_freq_scale */ e->sbr.dflt.alter_scale = get_bits1(gb); /* dflt_alter_scale */ -e->sbr.dflt.noise_scale = get_bits(gb, 2); /* dflt_noise_scale */ +e->sbr.dflt.noise_bands = get_bits(gb, 2); /* dflt_noise_bands */ } e->sbr.dflt.limiter_bands = 2; -- 2.45.1.288.g0e0cd299f1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 5/6] aacdec_usac: remove custom rate_idx and use standard variable for it
m4ac.sampling_index is what aacdec.c uses. --- libavcodec/aac/aacdec.h | 1 - libavcodec/aac/aacdec_usac.c | 35 ++- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h index d1a80e9ac1..e5a79a7139 100644 --- a/libavcodec/aac/aacdec.h +++ b/libavcodec/aac/aacdec.h @@ -350,7 +350,6 @@ typedef struct AACUsacElemConfig { typedef struct AACUSACConfig { uint8_t core_sbr_frame_len_idx; /* coreSbrFrameLengthIndex */ -uint8_t rate_idx; uint16_t core_frame_len; uint16_t stream_identifier; diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index eb0e7d3659..e5504117d0 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -316,7 +316,7 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, GetBitContext *gb, OutputConfiguration *oc, int channel_config) { -int ret, idx; +int ret; uint8_t freq_idx; uint8_t channel_config_idx; int nb_channels = 0; @@ -334,20 +334,10 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, freq_idx = get_bits(gb, 5); /* usacSamplingFrequencyIndex */ if (freq_idx == 0x1f) { samplerate = get_bits(gb, 24); /* usacSamplingFrequency */ - -/* Try to match up an index for the custom sample rate. - * TODO: not sure if correct */ -for (idx = 0; idx < /* FF_ARRAY_ELEMS(ff_aac_usac_samplerate) */ 32; idx++) { -if (ff_aac_usac_samplerate[idx] >= samplerate) -break; -} -idx = FFMIN(idx, /* FF_ARRAY_ELEMS(ff_aac_usac_samplerate) */ 32 - 1); -usac->rate_idx = idx; } else { samplerate = ff_aac_usac_samplerate[freq_idx]; if (samplerate < 0) return AVERROR(EINVAL); -usac->rate_idx = freq_idx; } m4ac->sample_rate = avctx->sample_rate = samplerate; @@ -364,6 +354,8 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, usac->core_sbr_frame_len_idx == 4 ? 1 : 0; +m4ac->sampling_index = ff_aac_sample_rate_idx(m4ac->sample_rate); + channel_config_idx = get_bits(gb, 5); /* channelConfigurationIndex */ if (!channel_config_idx) { /* UsacChannelConfig() */ @@ -751,18 +743,19 @@ static int setup_sce(AACDecContext *ac, SingleChannelElement *sce, { AACUsacElemData *ue = &sce->ue; IndividualChannelStream *ics = &sce->ics; +const int sampling_index = ac->oc[1].m4ac.sampling_index; /* Setup window parameters */ ics->prev_num_window_groups = FFMAX(ics->num_window_groups, 1); if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { if (usac->core_frame_len == 768) { -ics->swb_offset = ff_swb_offset_96[usac->rate_idx]; -ics->num_swb = ff_aac_num_swb_96[usac->rate_idx]; +ics->swb_offset = ff_swb_offset_96[sampling_index]; +ics->num_swb = ff_aac_num_swb_96[sampling_index]; } else { -ics->swb_offset = ff_swb_offset_128[usac->rate_idx]; -ics->num_swb = ff_aac_num_swb_128[usac->rate_idx]; +ics->swb_offset = ff_swb_offset_128[sampling_index]; +ics->num_swb = ff_aac_num_swb_128[sampling_index]; } -ics->tns_max_bands = ff_tns_max_bands_usac_128[usac->rate_idx]; +ics->tns_max_bands = ff_tns_max_bands_usac_128[sampling_index]; /* Setup scalefactor grouping. 7 bit mask. */ ics->num_window_groups = 0; @@ -779,13 +772,13 @@ static int setup_sce(AACDecContext *ac, SingleChannelElement *sce, ics->num_windows = 8; } else { if (usac->core_frame_len == 768) { -ics->swb_offset = ff_swb_offset_768[usac->rate_idx]; -ics->num_swb = ff_aac_num_swb_768[usac->rate_idx]; +ics->swb_offset = ff_swb_offset_768[sampling_index]; +ics->num_swb = ff_aac_num_swb_768[sampling_index]; } else { -ics->swb_offset = ff_swb_offset_1024[usac->rate_idx]; -ics->num_swb = ff_aac_num_swb_1024[usac->rate_idx]; +ics->swb_offset = ff_swb_offset_1024[sampling_index]; +ics->num_swb = ff_aac_num_swb_1024[sampling_index]; } -ics->tns_max_bands = ff_tns_max_bands_usac_1024[usac->rate_idx]; +ics->tns_max_bands = ff_tns_max_bands_usac_1024[sampling_index]; ics->group_len[0] = 1; ics->num_window_groups = 1; -- 2.45.1.288.g0e0cd299f1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 6/6] aacdec_usac, aacsbr: implement SBR support for USAC
Currently, no eSBR features are supported. Thankfully, no encoders exist for it yet. --- libavcodec/aac/aacdec_usac.c | 119 +++--- libavcodec/aacsbr.h | 11 ++ libavcodec/aacsbr_template.c | 232 --- libavcodec/sbr.h | 32 +++-- 4 files changed, 351 insertions(+), 43 deletions(-) diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index e5504117d0..132ffee9c2 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -23,6 +23,8 @@ #include "aacdec_lpd.h" #include "aacdec_ac.h" +#include "libavcodec/aacsbr.h" + #include "libavcodec/aactab.h" #include "libavutil/mem.h" #include "libavcodec/mpeg4audio.h" @@ -145,7 +147,8 @@ static int decode_loudness_set(AACDecContext *ac, AACUSACConfig *usac, return 0; } -static void decode_usac_sbr_data(AACUsacElemConfig *e, GetBitContext *gb) +static int decode_usac_sbr_data(AACDecContext *ac, +AACUsacElemConfig *e, GetBitContext *gb) { uint8_t header_extra1; uint8_t header_extra2; @@ -153,6 +156,10 @@ static void decode_usac_sbr_data(AACUsacElemConfig *e, GetBitContext *gb) e->sbr.harmonic_sbr = get_bits1(gb); /* harmonicSBR */ e->sbr.bs_intertes = get_bits1(gb); /* bs_interTes */ e->sbr.bs_pvc = get_bits1(gb); /* bs_pvc */ +if (e->sbr.harmonic_sbr || e->sbr.bs_intertes || e->sbr.bs_pvc) { +avpriv_report_missing_feature(ac->avctx, "AAC USAC eSBR"); +return AVERROR_PATCHWELCOME; +} e->sbr.dflt.start_freq = get_bits(gb, 4); /* dflt_start_freq */ e->sbr.dflt.stop_freq = get_bits(gb, 4); /* dflt_stop_freq */ @@ -179,6 +186,8 @@ static void decode_usac_sbr_data(AACUsacElemConfig *e, GetBitContext *gb) e->sbr.dflt.interpol_freq = get_bits1(gb); /* dflt_interpol_freq */ e->sbr.dflt.smoothing_mode = get_bits1(gb); /* dflt_smoothing_mode */ } + +return 0; } static void decode_usac_element_core(AACUsacElemConfig *e, @@ -190,13 +199,17 @@ static void decode_usac_element_core(AACUsacElemConfig *e, e->sbr.ratio = sbr_ratio; } -static void decode_usac_element_pair(AACUsacElemConfig *e, GetBitContext *gb) +static int decode_usac_element_pair(AACDecContext *ac, +AACUsacElemConfig *e, GetBitContext *gb) { e->stereo_config_index = 0; if (e->sbr.ratio) { -decode_usac_sbr_data(e, gb); +int ret = decode_usac_sbr_data(ac, e, gb); +if (ret < 0) +return ret; e->stereo_config_index = get_bits(gb, 2); } + if (e->stereo_config_index) { e->mps.freq_res = get_bits(gb, 3); /* bsFreqRes */ e->mps.fixed_gain = get_bits(gb, 3); /* bsFixedGainDMX */ @@ -216,6 +229,8 @@ static void decode_usac_element_pair(AACUsacElemConfig *e, GetBitContext *gb) if (e->mps.temp_shape_config == 2) e->mps.env_quant_mode = get_bits1(gb); /* bsEnvQuantMode */ } + +return 0; } static int decode_usac_extension(AACDecContext *ac, AACUsacElemConfig *e, @@ -294,6 +309,9 @@ int ff_aac_usac_reset_state(AACDecContext *ac, OutputConfiguration *oc) AACUsacStereo *us = &che->us; memset(us, 0, sizeof(*us)); +if (e->sbr.ratio) +ff_aac_sbr_config_usac(ac, che, e); + for (int j = 0; j < ch; j++) { SingleChannelElement *sce = &che->ch[ch]; AACUsacElemData *ue = &sce->ue; @@ -320,6 +338,7 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, uint8_t freq_idx; uint8_t channel_config_idx; int nb_channels = 0; +int ratio_mult, ratio_dec; int samplerate; int sbr_ratio; MPEG4AudioConfig *m4ac = &oc->m4ac; @@ -340,8 +359,6 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, return AVERROR(EINVAL); } -m4ac->sample_rate = avctx->sample_rate = samplerate; - usac->core_sbr_frame_len_idx = get_bits(gb, 3); /* coreSbrFrameLengthIndex */ m4ac->frame_length_short = usac->core_sbr_frame_len_idx == 0 || usac->core_sbr_frame_len_idx == 2; @@ -354,7 +371,26 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, usac->core_sbr_frame_len_idx == 4 ? 1 : 0; +if (sbr_ratio == 2) { +ratio_mult = 8; +ratio_dec = 3; +} else if (sbr_ratio == 3) { +ratio_mult = 2; +ratio_dec = 1; +} else if (sbr_ratio == 4) { +ratio_mult = 4; +ratio_dec = 1; +} else { +ratio_mult = 1; +ratio_dec = 1; +} + +avctx->sample_rate = samplerate; +m4ac->ext_sample_rate = samplerate; +m4ac->sample_rate = (samplerate * ratio_dec) / ratio_mult; + m4ac->sampling_index = ff_aac_sample_rate_idx(m4ac->sample_rate); +m4ac->sbr = sbr_ratio > 0; channel_config_idx = get_bits(gb, 5
[FFmpeg-devel] [PATCH] avcodec/iirfilter: Move ff_iir_filter() to lavc/tests/iirfilter.c
It is only used by the test. Signed-off-by: Andreas Rheinhardt --- libavcodec/iirfilter.c | 14 -- libavcodec/iirfilter.h | 15 --- libavcodec/tests/iirfilter.c | 17 - 3 files changed, 16 insertions(+), 30 deletions(-) diff --git a/libavcodec/iirfilter.c b/libavcodec/iirfilter.c index 727a370444..cefe35ab6e 100644 --- a/libavcodec/iirfilter.c +++ b/libavcodec/iirfilter.c @@ -277,20 +277,6 @@ av_cold struct FFIIRFilterState *ff_iir_filter_init_state(int order) } \ } -void ff_iir_filter(const struct FFIIRFilterCoeffs *c, - struct FFIIRFilterState *s, int size, - const int16_t *src, ptrdiff_t sstep, - int16_t *dst, ptrdiff_t dstep) -{ -if (c->order == 2) { -FILTER_O2(int16_t, S16) -} else if (c->order == 4) { -FILTER_BW_O4(int16_t, S16) -} else { -FILTER_DIRECT_FORM_II(int16_t, S16) -} -} - /** * Perform IIR filtering on floating-point input samples. * diff --git a/libavcodec/iirfilter.h b/libavcodec/iirfilter.h index d6b8fe2782..8ab8ae68c6 100644 --- a/libavcodec/iirfilter.h +++ b/libavcodec/iirfilter.h @@ -28,7 +28,6 @@ #define AVCODEC_IIRFILTER_H #include -#include struct FFIIRFilterCoeffs; struct FFIIRFilterState; @@ -114,18 +113,4 @@ void ff_iir_filter_free_coeffsp(struct FFIIRFilterCoeffs **coeffs); */ void ff_iir_filter_free_statep(struct FFIIRFilterState **state); -/** - * Perform IIR filtering on signed 16-bit input samples. - * - * @param coeffs pointer to filter coefficients - * @param state pointer to filter state - * @param size input length - * @param srcsource samples - * @param sstep source stride - * @param dstfiltered samples (destination may be the same as input) - * @param dstep destination stride - */ -void ff_iir_filter(const struct FFIIRFilterCoeffs *coeffs, struct FFIIRFilterState *state, - int size, const int16_t *src, ptrdiff_t sstep, int16_t *dst, ptrdiff_t dstep); - #endif /* AVCODEC_IIRFILTER_H */ diff --git a/libavcodec/tests/iirfilter.c b/libavcodec/tests/iirfilter.c index 60cc6fc43d..e03e842b85 100644 --- a/libavcodec/tests/iirfilter.c +++ b/libavcodec/tests/iirfilter.c @@ -23,10 +23,25 @@ #include "libavutil/libm.h" #include "libavcodec/iirfilter.h" +#include "libavcodec/iirfilter.c" #define FILT_ORDER 4 #define SIZE 1024 +static void iir_filter_int16(const struct FFIIRFilterCoeffs *c, + struct FFIIRFilterState *s, int size, + const int16_t *src, ptrdiff_t sstep, + int16_t *dst, ptrdiff_t dstep) +{ +if (c->order == 2) { +FILTER_O2(int16_t, S16) +} else if (c->order == 4) { +FILTER_BW_O4(int16_t, S16) +} else { +FILTER_DIRECT_FORM_II(int16_t, S16) +} +} + int main(void) { struct FFIIRFilterCoeffs *fcoeffs = NULL; @@ -43,7 +58,7 @@ int main(void) for (i = 0; i < SIZE; i++) x[i] = lrint(0.75 * INT16_MAX * sin(0.5 * M_PI * i * i / SIZE)); -ff_iir_filter(fcoeffs, fstate, SIZE, x, 1, y, 1); +iir_filter_int16(fcoeffs, fstate, SIZE, x, 1, y, 1); for (i = 0; i < SIZE; i++) printf("%6d %6d\n", x[i], y[i]); -- 2.40.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] swscale/aarch64: Add argb/abgr to yuv
From: Zhao Zhili Test on Apple M1 with kperf: abgr_to_uv_8_c: 19.4 abgr_to_uv_8_neon: 29.9 abgr_to_uv_128_c: 146.4 abgr_to_uv_128_neon: 85.1 abgr_to_uv_1080_c: 1162.6 abgr_to_uv_1080_neon: 819.6 abgr_to_uv_1920_c: 2063.6 abgr_to_uv_1920_neon: 1435.1 abgr_to_uv_half_8_c: 16.4 abgr_to_uv_half_8_neon: 35.6 abgr_to_uv_half_128_c: 108.6 abgr_to_uv_half_128_neon: 75.4 abgr_to_uv_half_1080_c: 883.4 abgr_to_uv_half_1080_neon: 460.6 abgr_to_uv_half_1920_c: 1553.6 abgr_to_uv_half_1920_neon: 817.6 abgr_to_y_8_c: 6.1 abgr_to_y_8_neon: 40.6 abgr_to_y_128_c: 99.9 abgr_to_y_128_neon: 67.4 abgr_to_y_1080_c: 735.9 abgr_to_y_1080_neon: 534.6 abgr_to_y_1920_c: 1279.4 abgr_to_y_1920_neon: 932.6 Disable vectorization in clang: abgr_to_uv_8_c: 20.9 abgr_to_uv_8_neon: 44.1 abgr_to_uv_128_c: 555.6 abgr_to_uv_128_neon: 105.9 abgr_to_uv_1080_c: 4773.1 abgr_to_uv_1080_neon: 846.1 abgr_to_uv_1920_c: 8499.9 abgr_to_uv_1920_neon: 1436.6 abgr_to_uv_half_8_c: 13.9 abgr_to_uv_half_8_neon: 167.9 abgr_to_uv_half_128_c: 338.9 abgr_to_uv_half_128_neon: 60.6 abgr_to_uv_half_1080_c: 2906.9 abgr_to_uv_half_1080_neon: 466.1 abgr_to_uv_half_1920_c: 5084.4 abgr_to_uv_half_1920_neon: 832.9 abgr_to_y_8_c: 9.6 abgr_to_y_8_neon: 18.6 abgr_to_y_128_c: 372.4 abgr_to_y_128_neon: 61.4 abgr_to_y_1080_c: 3168.9 abgr_to_y_1080_neon: 513.9 abgr_to_y_1920_c: 6187.6 abgr_to_y_1920_neon: 918.9 --- libswscale/aarch64/input.S | 104 --- libswscale/aarch64/swscale.c | 17 ++ 2 files changed, 100 insertions(+), 21 deletions(-) diff --git a/libswscale/aarch64/input.S b/libswscale/aarch64/input.S index 37f1158504..b4e827dd50 100644 --- a/libswscale/aarch64/input.S +++ b/libswscale/aarch64/input.S @@ -34,6 +34,16 @@ uxtl2 v24.8h, v18.16b// v24: b .endm +.macro argb_to_yuv_load_rgb src +ld4 { v16.16b, v17.16b, v18.16b, v19.16b }, [\src] +uxtlv21.8h, v19.8b // v21: b +uxtl2 v24.8h, v19.16b// v24: b +uxtlv19.8h, v17.8b // v19: r +uxtlv20.8h, v18.8b // v20: g +uxtl2 v22.8h, v17.16b// v22: r +uxtl2 v23.8h, v18.16b// v23: g +.endm + .macro rgb_to_yuv_product r, g, b, dst1, dst2, dst, coef0, coef1, coef2, right_shift mov \dst1\().16b, v6.16b// dst1 = const_offset mov \dst2\().16b, v6.16b// dst2 = const_offset @@ -47,7 +57,7 @@ sqshrn2 \dst\().8h, \dst2\().4s, \right_shift // dst_higher_half = dst2 >> right_shift .endm -.macro rgbToY bgr, element=3 +.macro rgbToY bgr, element=3, alpha_first=0 cmp w4, #0 // check width > 0 .if \bgr ldr w12, [x5] // w12: ry @@ -71,7 +81,11 @@ dup v2.8h, w12 b.lt2f 1: +.if \alpha_first +argb_to_yuv_load_rgb x1 +.else rgb_to_yuv_load_rgb x1, \element +.endif rgb_to_yuv_product v19, v20, v21, v25, v26, v16, v0, v1, v2, #9 rgb_to_yuv_product v22, v23, v24, v27, v28, v17, v0, v1, v2, #9 sub w4, w4, #16 // width -= 16 @@ -85,9 +99,15 @@ b.ge1b cbz x4, 3f 2: +.if \alpha_first +ldrbw13, [x1, #1] // w13: r +ldrbw14, [x1, #2] // w14: g +ldrbw15, [x1, #3] // w15: b +.else ldrbw13, [x1] // w13: r ldrbw14, [x1, #1] // w14: g ldrbw15, [x1, #2] // w15: b +.endif smaddl x13, w13, w10, x9 // x13 = ry * r + const_offset smaddl x13, w14, w11, x13 // x13 += gy * g @@ -101,6 +121,14 @@ ret .endm +function ff_argb32ToY_neon, export=1 +rgbToY bgr=0, element=4, alpha_first=1 +endfunc + +function ff_abgr32ToY_neon, export=1 +rgbToY bgr=1, element=4, alpha_first=1 +endfunc + function ff_rgb24ToY_neon, export=1 rgbToY bgr=0 endfunc @@ -146,7 +174,21 @@ endfunc dup v6.4s, w9 .endm -.macro rgbToUV_half bgr, element=3 +.macro rgb_load_add_halfoff_r1, off_r2, off_g1, off_g2, off_b1, off_b2 +ldrbw2, [x3, \off_r1] // w2: r1 +ldrbw4, [x3, \off_r2] // w4: r2 +add w2, w2, w4 // w2 = r1 + r2 + +ldrbw4, [x3, \off_g1] // w4: g1 +ldrbw7, [x3, \off_g2] // w7: g2 +add w4, w4, w7 // w4 = g1 + g2 + +ldrbw7, [x3, \off_b1] // w7: b1 +ldrbw8, [x3, \off_b2] // w8: b2 +add w7, w7, w8 //
Re: [FFmpeg-devel] [PATCH] avcodec/iirfilter: Move ff_iir_filter() to lavc/tests/iirfilter.c
On Sun, Jun 16, 2024 at 2:07 PM Andreas Rheinhardt < andreas.rheinha...@outlook.com> wrote: > It is only used by the test. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/iirfilter.c | 14 -- > libavcodec/iirfilter.h | 15 --- > libavcodec/tests/iirfilter.c | 17 - > 3 files changed, 16 insertions(+), 30 deletions(-) > > diff --git a/libavcodec/iirfilter.c b/libavcodec/iirfilter.c > index 727a370444..cefe35ab6e 100644 > --- a/libavcodec/iirfilter.c > +++ b/libavcodec/iirfilter.c > @@ -277,20 +277,6 @@ av_cold struct FFIIRFilterState > *ff_iir_filter_init_state(int order) > } >\ > } > > -void ff_iir_filter(const struct FFIIRFilterCoeffs *c, > - struct FFIIRFilterState *s, int size, > - const int16_t *src, ptrdiff_t sstep, > - int16_t *dst, ptrdiff_t dstep) > -{ > -if (c->order == 2) { > -FILTER_O2(int16_t, S16) > -} else if (c->order == 4) { > -FILTER_BW_O4(int16_t, S16) > -} else { > -FILTER_DIRECT_FORM_II(int16_t, S16) > -} > -} > - > /** > * Perform IIR filtering on floating-point input samples. > * > diff --git a/libavcodec/iirfilter.h b/libavcodec/iirfilter.h > index d6b8fe2782..8ab8ae68c6 100644 > --- a/libavcodec/iirfilter.h > +++ b/libavcodec/iirfilter.h > @@ -28,7 +28,6 @@ > #define AVCODEC_IIRFILTER_H > > #include > -#include > > struct FFIIRFilterCoeffs; > struct FFIIRFilterState; > @@ -114,18 +113,4 @@ void ff_iir_filter_free_coeffsp(struct > FFIIRFilterCoeffs **coeffs); > */ > void ff_iir_filter_free_statep(struct FFIIRFilterState **state); > > -/** > - * Perform IIR filtering on signed 16-bit input samples. > - * > - * @param coeffs pointer to filter coefficients > - * @param state pointer to filter state > - * @param size input length > - * @param srcsource samples > - * @param sstep source stride > - * @param dstfiltered samples (destination may be the same as input) > - * @param dstep destination stride > - */ > -void ff_iir_filter(const struct FFIIRFilterCoeffs *coeffs, struct > FFIIRFilterState *state, > - int size, const int16_t *src, ptrdiff_t sstep, int16_t > *dst, ptrdiff_t dstep); > - > #endif /* AVCODEC_IIRFILTER_H */ > diff --git a/libavcodec/tests/iirfilter.c b/libavcodec/tests/iirfilter.c > index 60cc6fc43d..e03e842b85 100644 > --- a/libavcodec/tests/iirfilter.c > +++ b/libavcodec/tests/iirfilter.c > @@ -23,10 +23,25 @@ > #include "libavutil/libm.h" > > #include "libavcodec/iirfilter.h" > +#include "libavcodec/iirfilter.c" > > #define FILT_ORDER 4 > #define SIZE 1024 > > +static void iir_filter_int16(const struct FFIIRFilterCoeffs *c, > + struct FFIIRFilterState *s, int size, > + const int16_t *src, ptrdiff_t sstep, > + int16_t *dst, ptrdiff_t dstep) > +{ > +if (c->order == 2) { > +FILTER_O2(int16_t, S16) > +} else if (c->order == 4) { > +FILTER_BW_O4(int16_t, S16) > +} else { > +FILTER_DIRECT_FORM_II(int16_t, S16) > +} > +} > + > int main(void) > { > struct FFIIRFilterCoeffs *fcoeffs = NULL; > @@ -43,7 +58,7 @@ int main(void) > for (i = 0; i < SIZE; i++) > x[i] = lrint(0.75 * INT16_MAX * sin(0.5 * M_PI * i * i / SIZE)); > > -ff_iir_filter(fcoeffs, fstate, SIZE, x, 1, y, 1); > +iir_filter_int16(fcoeffs, fstate, SIZE, x, 1, y, 1); > > for (i = 0; i < SIZE; i++) > printf("%6d %6d\n", x[i], y[i]); > -- > 2.40.1 > > Unrelated to this patch, the iir >=2 order done by Direct II form for fixed point integers is very bad idea. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] FFmpeg 4.2.10 and 4.4.5
Hi On Fri, Jun 14, 2024 at 09:21:21PM +0200, Michael Niedermayer wrote: > On Thu, Jun 13, 2024 at 10:41:19PM +0200, Michael Niedermayer wrote: > > On Thu, Jun 13, 2024 at 12:14:54PM +0200, Michael Niedermayer wrote: > > > Hi all > > > > > > I intend to make 5.1.5 and 4.3.7 releases "soon"(1) for debian > > > > > > If you want something backported, now is your last chance to backport it > > > > > > thx > > > > > > (1) i still have more things to backport and somethings i need to fix in > > > my local setup, so it will take me a few days probably > > > > i intend to do the 5.1.5 release tomorrow > > last chance is now to backport your fixes to 5.1.5 (unless something > unexpected happens) > > i intend to do 4.3.7 tomorrow I intend to do 4.2.10 and 4.4.5 in the next days/week [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Dictatorship naturally arises out of democracy, and the most aggravated form of tyranny and slavery out of the most extreme liberty. -- Plato signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lavc/vvc: Invalidate PPSs which refer to a changed SPS
On Sun, Jun 16, 2024 at 12:38 AM Frank Plowman wrote: > n 15/06/2024 13:24, Nuo Mi wrote: > > On Sat, Jun 15, 2024 at 2:35 PM Christophe Gisquet < > > christophe.gisq...@gmail.com> wrote: > > > >> Le ven. 14 juin 2024, 11:39, Frank Plowman a > >> écrit : > >> > >>> When the SPS associated with a particular SPS ID changes, invalidate > all > >>> the PPSs which use that SPS ID. Fixes crashes with illegal bitstreams. > >>> This is done in the CBS, rather than in libavcodec/vvc/ps.c like the > SPS > >>> ID reuse validation, as parts of the CBS parsing process for PPSs > >>> depend on the SPS being referred to. > >>> > >> > >> I am uncertain about this. I have no definite knowledge nor proof, but I > >> would have thought these are persistent, IE it's legal to update some of > >> them, their validity depending on something else. > >> > > > >> Wondering if the tested streams are thus conformant. > >> > >> But I don't know the actual rule. Maybe finding an EOB/EOS NUT? Related > to > >> some particular shape of a clean random access point, that would require > >> retransmitting VPS/SPS/PPS/APS/... ? > >> > >> Asking Benjamin Bross might be a better option here. > >> > > Hi Chris, > > spec said sps should not change in a CVS. Frank has some patches to fix > a > > similar issue. > > > https://github.com/FFmpeg/FFmpeg/commit/2d79ae3f8a3306d24afe43ba505693a8dbefd21b > > > > > > Hi Frank, > > Did it crash before your error hand code in ps.c? > > Could you send me the clip? > > > > Thank you > > > > Hi both, > > Thank you for your reviews. > > An example of a crashing bitstream which is fixed by this patch is ID > 295 available here: https://github.com/ffvvc/tests/pull/43. The > relevant part of the bitstream is a sequence of NAL units > > AU (decode_order=5) > 18. SPS > sps_seq_parameter_set_id = 0 > sps_ctb_log2_size_y = 5 > 19. PPS > pps_pic_parameter_set_id = 0 > pps_seq_parameter_set_id = 0 > 20. IDR_N_LP > ph_pic_order_cnt_lsb = 0 > NoOutputBeforeRecoveryFlag = 1 > ph_pic_parameter_set_id = 0 > > AU (decode_order=6) > 21. AUD > 22. VPS > 23. SPS > sps_seq_parameter_set_id = 0 > sps_ctb_log2_size_y = 7 > 24. PREFIX_APS > 25. IDR_N_LP > ph_pic_order_cnt_lsb = 0 > NoOutputBeforeRecoveryFlag = 1 > ph_pic_parameter_set_id = 0 > > The layout of SPSs alone is legal (not covered by the checks introduced > in 2d79ae3f8a3306d24afe43ba505693a8dbefd21b) as the second AU is a CLVSS > AU. As a result, the bitstream crashes both before and after > 2d79ae3f8a3306d24afe43ba505693a8dbefd21b. What this patch does is > produce an error when the VCL NAL unit in the second AU (25.) tries to > use PPS ID 0, as the SPS NAL unit that PPS was defined with reference to > (18.) is no longer available. > > Christophe, is my interpretation of your point correct when I say you > are suggesting that the above sequence may be legal, so long as the PPS > still satisfies the new bounds etc. derived from the second SPS? I did > consider this, and I think it may be possible to implement by delaying > CBS element validation and inference until libavcodec/vvc/ps.c. > However, there are no bitstreams in the conformance suite which contain > such a structure and this is different to how the native HEVC decoder > behaves (see libavcodec/hevc/ps.c:72). > Pretty solid analysis, thank you, Frank > > All the best, > -- > Frank > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lavc/vvc: Invalidate PPSs which refer to a changed SPS
On 15/06/2024 17:37, Frank Plowman wrote: > n 15/06/2024 13:24, Nuo Mi wrote: >> On Sat, Jun 15, 2024 at 2:35 PM Christophe Gisquet < >> christophe.gisq...@gmail.com> wrote: >> >>> Le ven. 14 juin 2024, 11:39, Frank Plowman a >>> écrit : >>> When the SPS associated with a particular SPS ID changes, invalidate all the PPSs which use that SPS ID. Fixes crashes with illegal bitstreams. This is done in the CBS, rather than in libavcodec/vvc/ps.c like the SPS ID reuse validation, as parts of the CBS parsing process for PPSs depend on the SPS being referred to. >>> >>> I am uncertain about this. I have no definite knowledge nor proof, but I >>> would have thought these are persistent, IE it's legal to update some of >>> them, their validity depending on something else. >>> >> >>> Wondering if the tested streams are thus conformant. >>> >>> But I don't know the actual rule. Maybe finding an EOB/EOS NUT? Related to >>> some particular shape of a clean random access point, that would require >>> retransmitting VPS/SPS/PPS/APS/... ? >>> >>> Asking Benjamin Bross might be a better option here. >>> >> Hi Chris, >> spec said sps should not change in a CVS. Frank has some patches to fix a >> similar issue. >> https://github.com/FFmpeg/FFmpeg/commit/2d79ae3f8a3306d24afe43ba505693a8dbefd21b >> >> >> Hi Frank, >> Did it crash before your error hand code in ps.c? >> Could you send me the clip? >> >> Thank you >> > > Hi both, > > Thank you for your reviews. > > An example of a crashing bitstream which is fixed by this patch is ID > 295 available here: https://github.com/ffvvc/tests/pull/43. The > relevant part of the bitstream is a sequence of NAL units > > AU (decode_order=5) > 18. SPS > sps_seq_parameter_set_id = 0 > sps_ctb_log2_size_y = 5 > 19. PPS > pps_pic_parameter_set_id = 0 > pps_seq_parameter_set_id = 0 > 20. IDR_N_LP > ph_pic_order_cnt_lsb = 0 > NoOutputBeforeRecoveryFlag = 1 > ph_pic_parameter_set_id = 0 > > AU (decode_order=6) > 21. AUD > 22. VPS > 23. SPS > sps_seq_parameter_set_id = 0 > sps_ctb_log2_size_y = 7 > 24. PREFIX_APS > 25. IDR_N_LP > ph_pic_order_cnt_lsb = 0 > NoOutputBeforeRecoveryFlag = 1 > ph_pic_parameter_set_id = 0 > > The layout of SPSs alone is legal (not covered by the checks introduced > in 2d79ae3f8a3306d24afe43ba505693a8dbefd21b) as the second AU is a CLVSS > AU. As a result, the bitstream crashes both before and after > 2d79ae3f8a3306d24afe43ba505693a8dbefd21b. What this patch does is > produce an error when the VCL NAL unit in the second AU (25.) tries to > use PPS ID 0, as the SPS NAL unit that PPS was defined with reference to > (18.) is no longer available. > > Christophe, is my interpretation of your point correct when I say you > are suggesting that the above sequence may be legal, so long as the PPS > still satisfies the new bounds etc. derived from the second SPS? I did > consider this, and I think it may be possible to implement by delaying > CBS element validation and inference until libavcodec/vvc/ps.c. > However, there are no bitstreams in the conformance suite which contain > such a structure and this is different to how the native HEVC decoder > behaves (see libavcodec/hevc/ps.c:72). Is there some requirement in H.266 that in a single stream the PPS precedes the SPS? Currently we effectively require that for a single stream because we use the SPS to enforce constraints on the PPS in both H.265 and H.266, but I'm not seeing a hard dependency and it looks like it will currently work on later stream starts as long as the parameters don't change too much. In H.264 there is an explicit dependency because you need chroma_format_idc to parse scaling lists, but again this will usually work because it's unlikely to change inline. If that is not required then this will discard the PPS of a stream where the SPS follows the PPS. (Though I admit that before this it was only dubiously working because the bounds checking might be wrong.) Thanks, - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] lavfi: add perlin noise generator
On date Thursday 2024-06-13 16:45:48 +0100, Andrew Sayers wrote: > Some documentation nitpicks. Nothing jumped out about the code, but I don't > know the algorithm well enough to spot anything deep. > > > From 9932cfc19500acbd0685eb2cc8fd88e9af3f5dbd Mon Sep 17 00:00:00 2001 > > From: Stefano Sabatini > > Date: Mon, 27 May 2024 11:19:08 +0200 > > Subject: [PATCH] lavfi: add Perlin noise generator > > > > --- > > Changelog | 1 + > > doc/filters.texi | 100 + > > libavfilter/Makefile | 1 + > > libavfilter/allfilters.c | 1 + > > libavfilter/perlin.c | 224 ++ > > libavfilter/perlin.h | 101 + > > libavfilter/vsrc_perlin.c | 169 > > 7 files changed, 597 insertions(+) > > create mode 100644 libavfilter/perlin.c > > create mode 100644 libavfilter/perlin.h > > create mode 100644 libavfilter/vsrc_perlin.c [...] > > +@item tscale > > +Define a scale factor used to multiple the time coordinate. This can > > +be useful to change the time variation speed. > > + > > +@item random_mode > > +Set random mode used to compute initial pattern. > > + > > +Supported values are: > > +@table @option > > +@item random > > +Compute and use random seed. > > + > > +@item ken > > +Use the predefined initial pattern defined by Ken Perlin in the > > +original article, can be useful to compare the output with other > > +sources. > > + > > +@item seed > > +Use the value specified by @option{random_seed} option. > > +@end table > > Nit: "Define a...", "Use the..." etc. is redundant - remove them to > optimise for reading time. kept current form since the following is a complete sentence > > +@item > > +Chain Perlin noise with the @ref{lutyuv} to generate a black&white > > +effect: > > +@example > > +perlin:octaves=7:tscale=0.3,lutyuv=y='if(lt(val\,128)\,255\,0)' > > +@end example > > + > > +@item > > +Stretch noise along the y axis, and convert gray level to red-only > > I initially thought this was a typo for "read-only" - maybe s/red/blue/? I prefer to keep red, this is a fire approximation [...] > > > +{ "random_mode", "set random mode used to compute initial pattern", > > OFFSET(random_mode), AV_OPT_TYPE_INT, {.i64=FF_PERLIN_RANDOM_MODE_RANDOM}, > > 0, FF_PERLIN_RANDOM_MODE_NB-1, FLAGS, .unit = "random_mode" }, > > +{ "random", "compute and use random seed", 0, AV_OPT_TYPE_CONST, > > {.i64=FF_PERLIN_RANDOM_MODE_RANDOM}, 0, 0, FLAGS, .unit = "random_mode" }, > > +{ "ken", "use the predefined initial pattern defined by Ken Perlin in > > the original article", 0, AV_OPT_TYPE_CONST, > > {.i64=FF_PERLIN_RANDOM_MODE_KEN}, 0, 0, FLAGS, .unit = "random_mode" }, > > +{ "seed", "use the value specified by random_seed", 0, > > AV_OPT_TYPE_CONST, {.i64=FF_PERLIN_RANDOM_MODE_SEED}, 0, 0, FLAGS, .unit = > > "random_mode" }, > > + > > +{ "random_seed", "set the seed for filling the initial grid randomly", > > OFFSET(random_seed), AV_OPT_TYPE_UINT, {.i64=0}, 0, UINT_MAX, FLAGS }, > > +{ "seed","set the seed for filling the initial grid randomly", > > OFFSET(random_seed), AV_OPT_TYPE_UINT, {.i64=0}, 0, UINT_MAX, FLAGS }, > > Nit: "set the seed for filling the initial grid randomly" is ambiguous. > Do you mean: > > a) Set the seed for the RNG to a specified value (value is the seed number) > b) Pick a random number to fill the grid with (value is a boolean yes/no) > > I settled on the former after several reads, but would appreciate clearer > wording. Changed to: set the seed for filling the initial pattern [...] Applied other fixes as well, thanks. >From 7d9ffbdb8e419ca01e60604038d5534a3ca8ae0e Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 27 May 2024 11:19:08 +0200 Subject: [PATCH] lavfi: add Perlin noise generator --- Changelog | 1 + doc/filters.texi | 100 + libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/perlin.c | 224 ++ libavfilter/perlin.h | 101 + libavfilter/vsrc_perlin.c | 169 7 files changed, 597 insertions(+) create mode 100644 libavfilter/perlin.c create mode 100644 libavfilter/perlin.h create mode 100644 libavfilter/vsrc_perlin.c diff --git a/Changelog b/Changelog index 06c00e981a..e6a40b0252 100644 --- a/Changelog +++ b/Changelog @@ -14,6 +14,7 @@ version : - xHE-AAC decoder - removed DEC Alpha DSP and support code - VVC encoding support via libvvenc +- perlin video source version 7.0: diff --git a/doc/filters.texi b/doc/filters.texi index 347103c04f..0ff7c142b6 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -17290,6 +17290,9 @@ The command accepts the same syntax of the corresponding option. If the specified expression is not valid, it is kept at its current value. +@anchor{lutrgb} +@anchor{lutyuv} +@anchor{lut} @se
Re: [FFmpeg-devel] [PATCH v2] lavu/opt: Discuss AV_OPT_FLAG_RUNTIME_PARAM more explicitly
On date Thursday 2024-06-06 17:02:06 +0100, Andrew Sayers wrote: > After a struct is initialized, only options with the > AV_OPT_FLAG_RUNTIME_PARAM flag can be modified. > > Make that clearer, for the sake of readers who would otherwise > assume all options can be modified at any time. > --- > libavutil/opt.h | 26 +- > 1 file changed, 25 insertions(+), 1 deletion(-) > > diff --git a/libavutil/opt.h b/libavutil/opt.h > index 07e27a9208..d23c10bcf5 100644 > --- a/libavutil/opt.h > +++ b/libavutil/opt.h > @@ -53,6 +53,9 @@ > * question is allowed to access the field. This allows us to extend the > * semantics of those fields without breaking API compatibility. > * > + * Note: only options with the AV_OPT_FLAG_RUNTIME_PARAM flag can be > + * modified after the struct is initialized. > + * > * @section avoptions_scope Scope of AVOptions > * > * AVOptions is designed to support any set of multimedia configuration > options > @@ -300,7 +303,7 @@ enum AVOptionType{ > #define AV_OPT_FLAG_BSF_PARAM (1 << 8) > > /** > - * A generic parameter which can be set by the user at runtime. > + * A generic parameter which can be set by the user after initialization. > */ > #define AV_OPT_FLAG_RUNTIME_PARAM (1 << 15) I'm fine with changing the description, but then I wonder if we should also rename the flag accordingly (by adding a new alias and deprecating the old one): AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM ?? > /** > @@ -483,6 +486,9 @@ typedef struct AVOptionRanges { > /** > * Set the values of all AVOption fields to their default values. > * > + * Note: after a struct is initialized, only options with the > + * AV_OPT_FLAG_RUNTIME_PARAM flag can be modified. > + * drop this note and the following ones, this is assumed by the flags so there is no need to repeat this all over ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat: split off generic NAL function helpers into their own file
Signed-off-by: James Almer --- libavformat/Makefile | 2 +- libavformat/avc.c | 164 +--- libavformat/avc.h | 37 --- libavformat/flvenc.c | 3 +- libavformat/hevc.c | 7 +- libavformat/hlsenc.c | 1 + libavformat/matroskaenc.c | 1 + libavformat/movenc.c | 5 +- libavformat/movenccenc.c | 5 +- libavformat/mxfenc.c | 3 +- libavformat/nal.c | 190 + libavformat/nal.h | 66 libavformat/rtpenc_h264_hevc.c | 9 +- libavformat/sdp.c | 5 +- libavformat/vvc.c | 7 +- 15 files changed, 287 insertions(+), 218 deletions(-) create mode 100644 libavformat/nal.c create mode 100644 libavformat/nal.h diff --git a/libavformat/Makefile b/libavformat/Makefile index af31d6f795..7ca68a7036 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -35,7 +35,7 @@ OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o # subsystems OBJS-$(CONFIG_ISO_MEDIA) += isom.o -OBJS-$(CONFIG_ISO_WRITER)+= av1.o avc.o hevc.o vvc.o vpcc.o +OBJS-$(CONFIG_ISO_WRITER)+= av1.o avc.o hevc.o nal.o vvc.o vpcc.o OBJS-$(CONFIG_IAMFDEC) += iamf_reader.o iamf_parse.o iamf.o OBJS-$(CONFIG_IAMFENC) += iamf_writer.o iamf.o OBJS-$(CONFIG_NETWORK) += network.o diff --git a/libavformat/avc.c b/libavformat/avc.c index 047ea88077..e4040928cd 100644 --- a/libavformat/avc.c +++ b/libavformat/avc.c @@ -26,118 +26,7 @@ #include "avio.h" #include "avc.h" #include "avio_internal.h" - -static const uint8_t *avc_find_startcode_internal(const uint8_t *p, const uint8_t *end) -{ -const uint8_t *a = p + 4 - ((intptr_t)p & 3); - -for (end -= 3; p < a && p < end; p++) { -if (p[0] == 0 && p[1] == 0 && p[2] == 1) -return p; -} - -for (end -= 3; p < end; p += 4) { -uint32_t x = *(const uint32_t*)p; -// if ((x - 0x01000100) & (~x) & 0x80008000) // little endian -// if ((x - 0x00010001) & (~x) & 0x00800080) // big endian -if ((x - 0x01010101) & (~x) & 0x80808080) { // generic -if (p[1] == 0) { -if (p[0] == 0 && p[2] == 1) -return p; -if (p[2] == 0 && p[3] == 1) -return p+1; -} -if (p[3] == 0) { -if (p[2] == 0 && p[4] == 1) -return p+2; -if (p[4] == 0 && p[5] == 1) -return p+3; -} -} -} - -for (end += 3; p < end; p++) { -if (p[0] == 0 && p[1] == 0 && p[2] == 1) -return p; -} - -return end + 3; -} - -const uint8_t *ff_avc_find_startcode(const uint8_t *p, const uint8_t *end){ -const uint8_t *out = avc_find_startcode_internal(p, end); -if(pnalus); -while (nal_start < end && !*(nal_start++)); -if (nal_start == end) -break; - -nal_end = ff_avc_find_startcode(nal_start, end); -if (pb) { -avio_wb32(pb, nal_end - nal_start); -avio_write(pb, nal_start, nal_end - nal_start); -} else if (list->nb_nalus >= nalu_limit) { -return AVERROR(ERANGE); -} else { -NALU *tmp = av_fast_realloc(list->nalus, &list->nalus_array_size, -(list->nb_nalus + 1) * sizeof(*list->nalus)); -if (!tmp) -return AVERROR(ENOMEM); -list->nalus = tmp; -tmp[list->nb_nalus++] = (NALU){ .offset = nal_start - p, -.size = nal_end - nal_start }; -} -size += 4 + nal_end - nal_start; -nal_start = nal_end; -} -return size; -} - -int ff_avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size) -{ -return avc_parse_nal_units(pb, NULL, buf_in, size); -} - -int ff_nal_units_create_list(NALUList *list, const uint8_t *buf, int size) -{ -list->nb_nalus = 0; -return avc_parse_nal_units(NULL, list, buf, size); -} - -void ff_nal_units_write_list(const NALUList *list, AVIOContext *pb, - const uint8_t *buf) -{ -for (unsigned i = 0; i < list->nb_nalus; i++) { -avio_wb32(pb, list->nalus[i].size); -avio_write(pb, buf + list->nalus[i].offset, list->nalus[i].size); -} -} - -int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size) -{ -AVIOContext *pb; -int ret = avio_open_dyn_buf(&pb); -if(ret < 0) -return ret; - -ff_avc_parse_nal_units(pb, buf_in, *size); - -*size = avio_close_dyn_buf(pb, buf); -return 0; -} +#include "nal.h" int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len) { @@ -157,7 +46,7 @@ int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *dat
[FFmpeg-devel] [PATCH v3 0/3] s/RUNTIME/POST_INIT_SETTABLE/
AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM is fine by me, here's a patch. I've added a "@deprecated" comment for the old name, but would this need to be queued up for 8.0? Technically this is a backwards-incompatible change to the existing API, even though it doesn't change the ABI or generate warnings when compiling code. My vote is always going to be for putting documentation in the first place people look, even at the expense of redundancy. But I can live without the extra comments so long as the flag is renamed. This patch moves the extra documentation to an optional commit - I'm fine with just applying #1 and #3 if people prefer, but it's there if the conversation goes the other way. Also, I think this is better, but can also live with the v2 patch, so long as the other notes remain in. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 1/3] lavu/opt: Rename AV_OPT_FLAG_RUNTIME_PARAM to ...POST_INIT_SETTABLE_PARAM
The old name could be misread as the opposite of "AV_OPT_FLAG_READONLY" - some things can be set at runtime, others are read-only. Clarify that this refers to options that can be set after the struct is initialized. --- libavutil/opt.h | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libavutil/opt.h b/libavutil/opt.h index 07e27a9208..e050d126ed 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -53,6 +53,9 @@ * question is allowed to access the field. This allows us to extend the * semantics of those fields without breaking API compatibility. * + * Note: only options with the AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM flag can be + * modified after the struct is initialized. + * * @section avoptions_scope Scope of AVOptions * * AVOptions is designed to support any set of multimedia configuration options @@ -300,7 +303,12 @@ enum AVOptionType{ #define AV_OPT_FLAG_BSF_PARAM (1 << 8) /** - * A generic parameter which can be set by the user at runtime. + * A generic parameter which can be set by the user after the struct is initialized. + */ +#define AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM (1 << 15) +/** + * A generic parameter which can be set by the user after the struct is initialized. + * @deprecated Renamed to AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM for clarity */ #define AV_OPT_FLAG_RUNTIME_PARAM (1 << 15) /** -- 2.45.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 2/3] lavu/opt: Mention AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM in more places
An inattentive user might not see the explanation at the top of this file. Paste the explanation to all the places they might see it. --- libavutil/opt.h | 21 + 1 file changed, 21 insertions(+) diff --git a/libavutil/opt.h b/libavutil/opt.h index e050d126ed..06cbe3c336 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -491,6 +491,9 @@ typedef struct AVOptionRanges { /** * Set the values of all AVOption fields to their default values. * + * Note: after a struct is initialized, only options with the + * AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM flag can be modified. + * * @param s an AVOption-enabled struct (its first member must be a pointer to AVClass) */ void av_opt_set_defaults(void *s); @@ -500,6 +503,9 @@ void av_opt_set_defaults(void *s); * AVOption fields for which (opt->flags & mask) == flags will have their * default applied to s. * + * Note: after a struct is initialized, only options with the + * AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM flag can be modified. + * * @param s an AVOption-enabled struct (its first member must be a pointer to AVClass) * @param mask combination of AV_OPT_FLAG_* * @param flags combination of AV_OPT_FLAG_* @@ -669,6 +675,9 @@ enum { * key. ctx must be an AVClass context, storing is done using * AVOptions. * + * Note: after a struct is initialized, only options with the + * AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM flag can be modified. + * * @param opts options string to parse, may be NULL * @param key_val_sep a 0-terminated list of characters used to * separate key from value @@ -687,6 +696,9 @@ int av_set_options_string(void *ctx, const char *opts, * Parse the key-value pairs list in opts. For each key=value pair found, * set the value of the corresponding option in ctx. * + * Note: after a struct is initialized, only options with the + * AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM flag can be modified. + * * @param ctx the AVClass object to set options on * @param opts the options string, key-value pairs separated by a * delimiter @@ -717,6 +729,9 @@ int av_opt_set_from_string(void *ctx, const char *opts, /** * Set all the options from a given dictionary on an object. * + * Note: after a struct is initialized, only options with the + * AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM flag can be modified. + * * @param obj a struct whose first element is a pointer to AVClass * @param options options to process. This dictionary will be freed and replaced *by a new one containing all options not found in obj. @@ -734,6 +749,9 @@ int av_opt_set_dict(void *obj, struct AVDictionary **options); /** * Set all the options from a given dictionary on an object. * + * Note: after a struct is initialized, only options with the + * AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM flag can be modified. + * * @param obj a struct whose first element is a pointer to AVClass * @param options options to process. This dictionary will be freed and replaced *by a new one containing all options not found in obj. @@ -772,6 +790,9 @@ int av_opt_copy(void *dest, const void *src); * @{ * Those functions set the field of obj with the given name to value. * + * Note: after a struct is initialized, only options with the + * AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM flag can be modified. + * * @param[in] obj A struct whose first element is a pointer to an AVClass. * @param[in] name the name of the field to set * @param[in] val The value to set. In case of av_opt_set() if the field is not -- 2.45.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 3/3] all: s/AV_OPT_FLAG_RUNTIME_PARAM/AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM/g
Use the new name for the macro throughout the codebase. Patch generated with the following command: sed -i -e 's/AV_OPT_FLAG_RUNTIME_PARAM/AV_OPT_FLAG_POST_INIT_SETTABLE_PARAM/g' \ $( git grep -l AV_OPT_FLAG_RUNTIME_PARAM | grep -v '^libavutil/opt.h' | grep -v '^doc/APIchanges$' ) --- libavfilter/af_aap.c | 2 +- libavfilter/af_acrusher.c | 2 +- libavfilter/af_adelay.c| 2 +- libavfilter/af_adenorm.c | 2 +- libavfilter/af_adrc.c | 2 +- libavfilter/af_adynamicequalizer.c | 2 +- libavfilter/af_adynamicsmooth.c| 2 +- libavfilter/af_aemphasis.c | 2 +- libavfilter/af_aexciter.c | 2 +- libavfilter/af_afade.c | 2 +- libavfilter/af_afftdn.c| 2 +- libavfilter/af_afir.c | 2 +- libavfilter/af_afreqshift.c| 2 +- libavfilter/af_afwtdn.c| 2 +- libavfilter/af_agate.c | 2 +- libavfilter/af_alimiter.c | 2 +- libavfilter/af_amix.c | 2 +- libavfilter/af_anlmdn.c| 2 +- libavfilter/af_anlms.c | 2 +- libavfilter/af_apsyclip.c | 2 +- libavfilter/af_arls.c | 2 +- libavfilter/af_arnndn.c| 2 +- libavfilter/af_asetnsamples.c | 2 +- libavfilter/af_asoftclip.c | 2 +- libavfilter/af_asubboost.c | 2 +- libavfilter/af_asupercut.c | 2 +- libavfilter/af_atempo.c| 2 +- libavfilter/af_atilt.c | 2 +- libavfilter/af_biquads.c | 2 +- libavfilter/af_compensationdelay.c | 2 +- libavfilter/af_crossfeed.c | 2 +- libavfilter/af_crystalizer.c | 2 +- libavfilter/af_dialoguenhance.c| 2 +- libavfilter/af_dynaudnorm.c| 2 +- libavfilter/af_extrastereo.c | 2 +- libavfilter/af_firequalizer.c | 2 +- libavfilter/af_rubberband.c| 2 +- libavfilter/af_sidechaincompress.c | 2 +- libavfilter/af_silenceremove.c | 2 +- libavfilter/af_speechnorm.c| 2 +- libavfilter/af_stereotools.c | 2 +- libavfilter/af_stereowiden.c | 2 +- libavfilter/af_surround.c | 2 +- libavfilter/af_virtualbass.c | 2 +- libavfilter/af_volume.c| 2 +- libavfilter/avf_a3dscope.c | 2 +- libavfilter/avf_avectorscope.c | 2 +- libavfilter/avfilter.c | 4 ++-- libavfilter/f_graphmonitor.c | 2 +- libavfilter/f_perms.c | 2 +- libavfilter/f_realtime.c | 2 +- libavfilter/f_streamselect.c | 2 +- libavfilter/qrencode.c | 2 +- libavfilter/setpts.c | 2 +- libavfilter/src_avsynctest.c | 2 +- libavfilter/vf_amplify.c | 2 +- libavfilter/vf_atadenoise.c| 2 +- libavfilter/vf_avgblur.c | 2 +- libavfilter/vf_backgroundkey.c | 2 +- libavfilter/vf_bbox.c | 2 +- libavfilter/vf_bilateral.c | 2 +- libavfilter/vf_blend.c | 2 +- libavfilter/vf_cas.c | 2 +- libavfilter/vf_chromakey.c | 2 +- libavfilter/vf_chromanr.c | 2 +- libavfilter/vf_chromashift.c | 2 +- libavfilter/vf_colorbalance.c | 2 +- libavfilter/vf_colorchannelmixer.c | 2 +- libavfilter/vf_colorcontrast.c | 2 +- libavfilter/vf_colorcorrect.c | 2 +- libavfilter/vf_colorize.c | 2 +- libavfilter/vf_colorkey.c | 2 +- libavfilter/vf_colorlevels.c | 2 +- libavfilter/vf_colormap.c | 2 +- libavfilter/vf_colortemperature.c | 2 +- libavfilter/vf_convolution.c | 2 +- libavfilter/vf_crop.c | 2 +- libavfilter/vf_cropdetect.c| 2 +- libavfilter/vf_curves.c| 2 +- libavfilter/vf_datascope.c | 2 +- libavfilter/vf_dblur.c | 2 +- libavfilter/vf_deband.c| 2 +- libavfilter/vf_deblock.c | 2 +- libavfilter/vf_despill.c | 2 +- libavfilter/vf_displace.c | 2 +- libavfilter/vf_drawbox.c | 2 +- libavfilter/vf_drawtext.c | 2 +- libavfilter/vf_eq.c| 2 +- libavfilter/vf_estdif.c| 2 +- libavfilter/vf_exposure.c | 2 +- libavfilter/vf_feedback.c | 2 +- libavfilter/vf_fftdnoiz.c | 2 +- libavfilter/vf_fillborders.c | 2 +- libavfilter/vf_frei0r.c| 2 +- libavfilter/vf_gblur.c | 2 +- libavfilter/vf_guided.c| 2 +- libavfilter/vf_hqdn3d.c| 2 +- libavfilter/vf_hsvkey.c| 2 +- libavfilter/vf_hue.c | 2 +- libavfilter/vf_huesaturation.c | 2 +- libavfilter/vf_il.c| 2 +- libavfilter/vf_lagfun.c| 2 +- libavfilter/vf_lenscorrection.c| 2 +- libavfilter/vf_libplacebo.c| 2 +- libavfilter/vf_limitdiff.c | 2 +- libavfilter/vf_limiter.c | 2 +- libavfilter/vf_lumakey.c | 2 +- libavfilter/vf_lut.c | 2 +- libavfilter/vf_lut2.c | 2 +- libavfilter/vf_l
Re: [FFmpeg-devel] [PATCH v3 0/3] s/RUNTIME/POST_INIT_SETTABLE/
Pointless. Commit log spam. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] Development process for explaining contexts (was Re: [PATCH v6 1/4] doc: Explain what "context" means)
Meta note #1: I've replied in this thread but changed the subject line. That's because it needs to stay focussed on solving this thread's problem, but may be of more general interest. Meta note #2: Stefano, I appreciate your feedback, but would rather wait for [1] to get sorted out, then formulate my thoughts while writing a new version. That way I'll be more focussed on ways to improve things for readers. This thread started with what I thought was a trivia question[1] - what is a context? It's short for "AVClass context structure", which is synonymous with "AVOptions-enabled struct". It turned out to be more complex than that, so I wrote a little patch[3] explaining this piece of jargon. But it turned out to be more complex again, and so on until we got a 430-line document explaining things in voluminous detail. Everyone agrees this isn't ideal, so here are some alternatives. This may also inspire thoughts about FFmpeg development in general. # Alternative: Just give up The argument: We tried something, learnt a lot, but couldn't find a solution we agreed on, so let's come back another day. Obviously this is the easy way out, but essentially means leaving a critical bug in the documentation (misleads the reader about a fundamental concept). Even the most negative take on this document is that it's better than nothing, so I think we can rule this one out. # Err on the side of under-communicating The argument: this document is on the right tracks, but explains too many things the reader can already be assumed to know. This argument is more complex than it appears. To take some silly examples, I'm not going to learn Mandarin just because FFmpeg users can't be assumed to speak English. But I am willing to use American spelling because it's what more readers are used to. This e-mail is plenty long enough already, so I'll stick to some high-level points about this argument. The main risk of cutting documentation is that if someone can't follow a single step, they're lost and don't even know how to express their problem. Imagine teaching maths to children - you need to teach them what numbers are, then how to add them together, then multiplication, then finally exponents. But if you say "we don't need to teach numbers because kids all watch Numberblocks now", you'll cover the majority of kids who could have worked it out anyway, and leave a minority who just give up and say "I guess I must be bad at maths". I'd argue it's better to write more, then get feedback from actual newbies and cut based on the evidence - we'll get it wrong either way, but at least this way the newbies will know what they want us to cut. Incidentally, there's a much stronger argument for *drafting* a long document, even if it gets cut down before it's committed. FFmpeg has lots of undocumented nuances that experts just know and newbies don't know to ask, and this thread is full of instances where writing more detail helped tease out a misunderstanding. [1] is a great example - I had finally written enough detail to uncover my assumption that all AVOptions could be set at any time, then that thread taught me to look for a flag that tells you the options for which that's true. If you assume I'm not the only person who has been subtly misled that way, you could argue it's better to commit the long version. That would give readers more opportunities to confront their own wrong assumptions, instead of reading something that assumed they knew one thing, but let them keep believing another. The obvious counterargument is that we should... # Spread the information across multiple documents The argument: this document puts too much information in one place. We should instead focus on making small patches that put information people need to know where they need to know it. This is where things get more interesting to a general audience. If you have repo commit access, you're probably imagining a workflow like: write a bunch of little commits, send them out for review, then commit them when people stop replying. Your access is evidence that you basically know how things work, and also lets you make plans confident in the knowledge that anything you need committed will make it there in the end. My workflow is nothing like that. This thread has constantly reinforced that I don't understand FFmpeg, so it's better for me not to have commit access. But that means I can only work on one patch at once, because I will probably learn something that invalidates any other work I would have done. It also means a single patch not getting interest is enough to sink the project altogether. I can put up with that when it's one big multi-faceted patch, because I can work on one part while waiting for feedback on another part. But my small patches generally involve a few hours of work, a week of waiting, a ping begging for attention, then often being rejected or ignored. In the real world, the only thing this approach will achieve i
Re: [FFmpeg-devel] Development process for explaining contexts (was Re: [PATCH v6 1/4] doc: Explain what "context" means)
Avoid filling some of bellow points: https://erikbern.com/2023/12/13/simple-sabotage-for-software.html Especially part of rewriting public or internal API just for rewrite. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/6] swscale/yuv2rgb: fix conversion for widths not aligned to 8
The C code for some pixel formats (rgb555, rgb565, rgb444, and monob) was not converting the last pixels on widths not aligned to 8. NOTE: the last pixel for odd widths is still not converted for any of the pixel formats in the C code for yuv2rgb except for monob. --- libswscale/yuv2rgb.c | 101 +++ 1 file changed, 93 insertions(+), 8 deletions(-) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index c1d6236f37..e641c765c7 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -172,10 +172,6 @@ const int *sws_getCoefficients(int colorspace) return srcSliceH; \ } -#define CLOSEYUV2RGBFUNC(dst_delta) \ -ENDYUV2RGBLINE(dst_delta, 0)\ -ENDYUV2RGBFUNC() - YUV2RGBFUNC(yuv2rgb_c_48, uint8_t, 0) LOADCHROMA(0); PUTRGB48(dst_1, py_1, 0); @@ -432,7 +428,27 @@ YUV2RGBFUNC(yuv2rgb_c_16_ordered_dither, uint16_t, 0) LOADCHROMA(3); PUTRGB16(dst_2, py_2, 3, 6 + 8); PUTRGB16(dst_1, py_1, 3, 6); -CLOSEYUV2RGBFUNC(8) +ENDYUV2RGBLINE(8, 0) +const uint8_t *d16 = ff_dither_2x2_8[y & 1]; +const uint8_t *e16 = ff_dither_2x2_4[y & 1]; +const uint8_t *f16 = ff_dither_2x2_8[(y & 1)^1]; + +LOADCHROMA(0); +PUTRGB16(dst_1, py_1, 0, 0); +PUTRGB16(dst_2, py_2, 0, 0 + 8); + +LOADCHROMA(1); +PUTRGB16(dst_2, py_2, 1, 2 + 8); +PUTRGB16(dst_1, py_1, 1, 2); +ENDYUV2RGBLINE(8, 1) +const uint8_t *d16 = ff_dither_2x2_8[y & 1]; +const uint8_t *e16 = ff_dither_2x2_4[y & 1]; +const uint8_t *f16 = ff_dither_2x2_8[(y & 1)^1]; + +LOADCHROMA(0); +PUTRGB16(dst_1, py_1, 0, 0); +PUTRGB16(dst_2, py_2, 0, 0 + 8); +ENDYUV2RGBFUNC() YUV2RGBFUNC(yuv2rgb_c_15_ordered_dither, uint16_t, 0) const uint8_t *d16 = ff_dither_2x2_8[y & 1]; @@ -462,7 +478,25 @@ YUV2RGBFUNC(yuv2rgb_c_15_ordered_dither, uint16_t, 0) LOADCHROMA(3); PUTRGB15(dst_2, py_2, 3, 6 + 8); PUTRGB15(dst_1, py_1, 3, 6); -CLOSEYUV2RGBFUNC(8) +ENDYUV2RGBLINE(8, 0) +const uint8_t *d16 = ff_dither_2x2_8[y & 1]; +const uint8_t *e16 = ff_dither_2x2_8[(y & 1)^1]; + +LOADCHROMA(0); +PUTRGB15(dst_1, py_1, 0, 0); +PUTRGB15(dst_2, py_2, 0, 0 + 8); + +LOADCHROMA(1); +PUTRGB15(dst_2, py_2, 1, 2 + 8); +PUTRGB15(dst_1, py_1, 1, 2); +ENDYUV2RGBLINE(8, 1) +const uint8_t *d16 = ff_dither_2x2_8[y & 1]; +const uint8_t *e16 = ff_dither_2x2_8[(y & 1)^1]; + +LOADCHROMA(0); +PUTRGB15(dst_1, py_1, 0, 0); +PUTRGB15(dst_2, py_2, 0, 0 + 8); +ENDYUV2RGBFUNC() // r, g, b, dst_1, dst_2 YUV2RGBFUNC(yuv2rgb_c_12_ordered_dither, uint16_t, 0) @@ -493,7 +527,23 @@ YUV2RGBFUNC(yuv2rgb_c_12_ordered_dither, uint16_t, 0) LOADCHROMA(3); PUTRGB12(dst_2, py_2, 3, 6 + 8); PUTRGB12(dst_1, py_1, 3, 6); -CLOSEYUV2RGBFUNC(8) +ENDYUV2RGBLINE(8, 0) +const uint8_t *d16 = ff_dither_4x4_16[y & 3]; + +LOADCHROMA(0); +PUTRGB12(dst_1, py_1, 0, 0); +PUTRGB12(dst_2, py_2, 0, 0 + 8); + +LOADCHROMA(1); +PUTRGB12(dst_2, py_2, 1, 2 + 8); +PUTRGB12(dst_1, py_1, 1, 2); +ENDYUV2RGBLINE(8, 1) +const uint8_t *d16 = ff_dither_4x4_16[y & 3]; + +LOADCHROMA(0); +PUTRGB12(dst_1, py_1, 0, 0); +PUTRGB12(dst_2, py_2, 0, 0 + 8); +ENDYUV2RGBFUNC() // r, g, b, dst_1, dst_2 YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0) @@ -672,7 +722,42 @@ YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0) dst_1[0] = out_1; dst_2[0] = out_2; -CLOSEYUV2RGBFUNC(1) + +py_1 += 8; +py_2 += 8; +dst_1 += 1; +dst_2 += 1; +} +if (c->dstW & 7) { +int av_unused Y, U, V; +int pixels_left = c->dstW & 7; +const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; +char out_1 = 0, out_2 = 0; +g = c->table_gU[128 + YUVRGB_TABLE_HEADROOM] + c->table_gV[128 + YUVRGB_TABLE_HEADROOM]; + +#define PUTRGB1_OR00(out, src, i, o)\ +if (pixels_left) { \ +PUTRGB1(out, src, i, o) \ +pixels_left--; \ +} else {\ +out <<= 2; \ +} + +PUTRGB1_OR00(out_1, py_1, 0, 0); +PUTRGB1_OR00(out_2, py_2, 0, 0 + 8); + +PUTRGB1_OR00(out_2, py_2, 1, 2 + 8); +PUTRGB1_OR00(out_1, py_1, 1, 2); + +PUTRGB1_OR00(out_1, py_1, 2, 4); +PUTRGB1_OR00(out_2, py_2, 2, 4 + 8); + +PUTRGB1_OR00(out_2, py_2, 3, 6 + 8); +PUTRGB1_OR00(out_1, py_1, 3, 6); + +dst_1[0] = out_1; +dst_2[0] = out_2; +ENDYUV2RGBFUNC() SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) { -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/6] swscale/yuv2rgb: add macros to simplify code generation
--- libswscale/yuv2rgb.c | 574 +-- 1 file changed, 113 insertions(+), 461 deletions(-) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index e641c765c7..7386d3a2a2 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -72,13 +72,13 @@ const int *sws_getCoefficients(int colorspace) g = (void *)(c->table_gU[U+YUVRGB_TABLE_HEADROOM] + c->table_gV[V+YUVRGB_TABLE_HEADROOM]); \ b = (void *)c->table_bU[U+YUVRGB_TABLE_HEADROOM]; -#define PUTRGB(dst, src, i) \ +#define PUTRGB(dst, src, asrc, i, abase)\ Y = src[2 * i];\ dst[2 * i] = r[Y] + g[Y] + b[Y];\ Y = src[2 * i + 1];\ dst[2 * i + 1] = r[Y] + g[Y] + b[Y]; -#define PUTRGB24(dst, src, i) \ +#define PUTRGB24(dst, src, asrc, i, abase) \ Y = src[2 * i];\ dst[6 * i + 0] = r[Y]; \ dst[6 * i + 1] = g[Y]; \ @@ -88,7 +88,7 @@ const int *sws_getCoefficients(int colorspace) dst[6 * i + 4] = g[Y]; \ dst[6 * i + 5] = b[Y]; -#define PUTBGR24(dst, src, i) \ +#define PUTBGR24(dst, src, asrc, i, abase) \ Y = src[2 * i];\ dst[6 * i + 0] = b[Y]; \ dst[6 * i + 1] = g[Y]; \ @@ -98,13 +98,13 @@ const int *sws_getCoefficients(int colorspace) dst[6 * i + 4] = g[Y]; \ dst[6 * i + 5] = r[Y]; -#define PUTRGBA(dst, ysrc, asrc, i, s) \ +#define PUTRGBA(dst, ysrc, asrc, i, abase) \ Y = ysrc[2 * i]; \ -dst[2 * i] = r[Y] + g[Y] + b[Y] + (asrc[2 * i] << s); \ +dst[2 * i] = r[Y] + g[Y] + b[Y] + (asrc[2 * i] << abase); \ Y = ysrc[2 * i + 1]; \ -dst[2 * i + 1] = r[Y] + g[Y] + b[Y] + (asrc[2 * i + 1] << s); +dst[2 * i + 1] = r[Y] + g[Y] + b[Y] + (asrc[2 * i + 1] << abase); -#define PUTRGB48(dst, src, i) \ +#define PUTRGB48(dst, src, asrc, i, abase) \ Y= src[ 2 * i]; \ dst[12 * i + 0] = dst[12 * i + 1] = r[Y]; \ dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \ @@ -114,7 +114,7 @@ const int *sws_getCoefficients(int colorspace) dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \ dst[12 * i + 10] = dst[12 * i + 11] = b[Y]; -#define PUTBGR48(dst, src, i) \ +#define PUTBGR48(dst, src, asrc, i, abase) \ Y= src[2 * i]; \ dst[12 * i + 0] = dst[12 * i + 1] = b[Y]; \ dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \ @@ -155,11 +155,15 @@ const int *sws_getCoefficients(int colorspace) while (h_size--) { \ int av_unused U, V, Y; \ -#define ENDYUV2RGBLINE(dst_delta, ss) \ +#define ENDYUV2RGBLINE(dst_delta, ss, alpha)\ pu+= 4 >> ss; \ pv+= 4 >> ss; \ py_1 += 8 >> ss; \ py_2 += 8 >> ss; \ +if (alpha) {\ +pa_1 += 8 >> ss;\ +pa_2 += 8 >> ss;\ +} \ dst_1 += dst_delta >> ss; \ dst_2 += dst_delta >> ss; \ } \ @@ -172,236 +176,77 @@ const int *sws_getCoefficients(int colorspace) return srcSliceH; \ } -YUV2RGBFUNC(yuv2rgb_c_48, uint8_t, 0) -LOADCHROMA(0); -PUTRGB48(dst_1, py_1, 0); -PUTRGB48(dst_2, py_2, 0); - -LOADCHROMA(1); -PUTRGB48(dst_2, py_2, 1); -PUTRGB48(dst_1, py_1, 1); - -LOADCHROMA(2); -PUTRGB48(dst_1, py_1, 2); -PUTRGB48(dst_2, py_2, 2); - -LOADCHROMA(3); -PUTRGB48(dst_2, py_2, 3); -PUTRGB48(dst_1, py_1, 3); -ENDYUV2RGBLINE(48, 0) -LOADCHROMA(0); -PUTRGB48(dst_1, py_1, 0); -PUTRGB48(dst_2, py_2, 0); - -LOADCHROMA(1); -PUTRGB48(dst_2, py_2, 1); -PUTRGB48(dst_1, py_1, 1); -ENDYUV2RGBLINE(48, 1) -LOADCHROMA(0); -PUTRGB48(dst_1, py_1, 0); -PUTRGB48(dst_2, py_2, 0); -ENDYUV2RGBFUNC() - -YUV2RGBFUNC(yuv2rgb_c_bgr48, uint8_t, 0) -LOADCHROMA(0); -PUTBGR48(dst_1, py_1, 0); -PUTBGR48(dst_2, py_2, 0); - -LOADCHROMA(1); -PUTBGR48(dst_2, py_2, 1); -PUTBGR48(dst_1, py_1, 1); - -LOADCHROMA(2); -PUTBGR48(dst_1
[FFmpeg-devel] [PATCH 3/6] swscale/yuv2rgb: fix yuv422p input in C code
The C code was silently ignoring the second chroma line on yuv422p input. --- libswscale/yuv2rgb.c | 228 +-- 1 file changed, 196 insertions(+), 32 deletions(-) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index 7386d3a2a2..1ea87ac17a 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -65,7 +65,7 @@ const int *sws_getCoefficients(int colorspace) return ff_yuv2rgb_coeffs[colorspace]; } -#define LOADCHROMA(i) \ +#define LOADCHROMA(pu, pv, i) \ U = pu[i]; \ V = pv[i]; \ r = (void *)c->table_rV[V+YUVRGB_TABLE_HEADROOM]; \ @@ -124,17 +124,13 @@ const int *sws_getCoefficients(int colorspace) dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \ dst[12 * i + 10] = dst[12 * i + 11] = r[Y]; -#define YUV2RGBFUNC(func_name, dst_type, alpha) \ +#define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422) \ static int func_name(SwsContext *c, const uint8_t *src[], \ int srcStride[], int srcSliceY, int srcSliceH, \ uint8_t *dst[], int dstStride[]) \ { \ int y; \ \ -if (!alpha && c->srcFormat == AV_PIX_FMT_YUV422P) { \ -srcStride[1] *= 2; \ -srcStride[2] *= 2; \ -} \ for (y = 0; y < srcSliceH; y += 2) {\ int yd = y + srcSliceY; \ dst_type *dst_1 = \ @@ -144,10 +140,15 @@ const int *sws_getCoefficients(int colorspace) dst_type av_unused *r, *g, *b; \ const uint8_t *py_1 = src[0] + y * srcStride[0]; \ const uint8_t *py_2 = py_1 +srcStride[0]; \ -const uint8_t av_unused *pu = src[1] + (y >> 1) * srcStride[1]; \ -const uint8_t av_unused *pv = src[2] + (y >> 1) * srcStride[2]; \ +const uint8_t av_unused *pu_1 = src[1] + (y >> !yuv422) * srcStride[1]; \ +const uint8_t av_unused *pv_1 = src[2] + (y >> !yuv422) * srcStride[2]; \ +const uint8_t av_unused *pu_2, *pv_2; \ const uint8_t av_unused *pa_1, *pa_2; \ unsigned int h_size = c->dstW >> 3; \ +if (yuv422) { \ +pu_2 = pu_1 + srcStride[1]; \ +pv_2 = pv_1 + srcStride[2]; \ +} \ if (alpha) {\ pa_1 = src[3] + y * srcStride[3]; \ pa_2 = pa_1 + srcStride[3]; \ @@ -155,9 +156,13 @@ const int *sws_getCoefficients(int colorspace) while (h_size--) { \ int av_unused U, V, Y; \ -#define ENDYUV2RGBLINE(dst_delta, ss, alpha)\ -pu+= 4 >> ss; \ -pv+= 4 >> ss; \ +#define ENDYUV2RGBLINE(dst_delta, ss, alpha, yuv422) \ +pu_1 += 4 >> ss; \ +pv_1 += 4 >> ss; \ +if (yuv422) { \ +pu_2 += 4 >> ss;\ +pv_2 += 4 >> ss;\ +} \ py_1 += 8 >> ss; \ py_2 += 8 >> ss; \ if (alpha) {\ @@ -177,73 +182,169 @@ const int *sws_getCoefficients(int colorspace) } #define YUV420FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta) \ -YUV2RGBFUNC(func_name, dst_type, alpha) \ -LOADCHROMA(0); \ +YUV2RGBFUNC(func_name, dst_type, alpha, 0) \ +LOADCHROMA(pu_1, pv_1, 0); \ PUTFUNC(dst_1, py_1, pa_1, 0, abase)
[FFmpeg-devel] [PATCH 4/6] swscale/yuv2rgb: reindent after previous commit
--- libswscale/yuv2rgb.c | 78 ++-- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index 1ea87ac17a..977eb3a7dd 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -593,45 +593,45 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) return yuv2rgb_c_1_ordered_dither; } } else { -switch (c->dstFormat) { -case AV_PIX_FMT_BGR48BE: -case AV_PIX_FMT_BGR48LE: -return yuv2rgb_c_bgr48; -case AV_PIX_FMT_RGB48BE: -case AV_PIX_FMT_RGB48LE: -return yuv2rgb_c_48; -case AV_PIX_FMT_ARGB: -case AV_PIX_FMT_ABGR: -if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) -return yuva2argb_c; -case AV_PIX_FMT_RGBA: -case AV_PIX_FMT_BGRA: -return (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) ? yuva2rgba_c : yuv2rgb_c_32; -case AV_PIX_FMT_RGB24: -return yuv2rgb_c_24_rgb; -case AV_PIX_FMT_BGR24: -return yuv2rgb_c_24_bgr; -case AV_PIX_FMT_RGB565: -case AV_PIX_FMT_BGR565: -return yuv2rgb_c_16_ordered_dither; -case AV_PIX_FMT_RGB555: -case AV_PIX_FMT_BGR555: -return yuv2rgb_c_15_ordered_dither; -case AV_PIX_FMT_RGB444: -case AV_PIX_FMT_BGR444: -return yuv2rgb_c_12_ordered_dither; -case AV_PIX_FMT_RGB8: -case AV_PIX_FMT_BGR8: -return yuv2rgb_c_8_ordered_dither; -case AV_PIX_FMT_RGB4: -case AV_PIX_FMT_BGR4: -return yuv2rgb_c_4_ordered_dither; -case AV_PIX_FMT_RGB4_BYTE: -case AV_PIX_FMT_BGR4_BYTE: -return yuv2rgb_c_4b_ordered_dither; -case AV_PIX_FMT_MONOBLACK: -return yuv2rgb_c_1_ordered_dither; -} +switch (c->dstFormat) { +case AV_PIX_FMT_BGR48BE: +case AV_PIX_FMT_BGR48LE: +return yuv2rgb_c_bgr48; +case AV_PIX_FMT_RGB48BE: +case AV_PIX_FMT_RGB48LE: +return yuv2rgb_c_48; +case AV_PIX_FMT_ARGB: +case AV_PIX_FMT_ABGR: +if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) +return yuva2argb_c; +case AV_PIX_FMT_RGBA: +case AV_PIX_FMT_BGRA: +return (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) ? yuva2rgba_c : yuv2rgb_c_32; +case AV_PIX_FMT_RGB24: +return yuv2rgb_c_24_rgb; +case AV_PIX_FMT_BGR24: +return yuv2rgb_c_24_bgr; +case AV_PIX_FMT_RGB565: +case AV_PIX_FMT_BGR565: +return yuv2rgb_c_16_ordered_dither; +case AV_PIX_FMT_RGB555: +case AV_PIX_FMT_BGR555: +return yuv2rgb_c_15_ordered_dither; +case AV_PIX_FMT_RGB444: +case AV_PIX_FMT_BGR444: +return yuv2rgb_c_12_ordered_dither; +case AV_PIX_FMT_RGB8: +case AV_PIX_FMT_BGR8: +return yuv2rgb_c_8_ordered_dither; +case AV_PIX_FMT_RGB4: +case AV_PIX_FMT_BGR4: +return yuv2rgb_c_4_ordered_dither; +case AV_PIX_FMT_RGB4_BYTE: +case AV_PIX_FMT_BGR4_BYTE: +return yuv2rgb_c_4b_ordered_dither; +case AV_PIX_FMT_MONOBLACK: +return yuv2rgb_c_1_ordered_dither; +} } return NULL; } -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 5/6] checkasm: add tests for yuv2rgb
--- tests/checkasm/Makefile | 2 +- tests/checkasm/checkasm.c | 1 + tests/checkasm/checkasm.h | 1 + tests/checkasm/sw_yuv2rgb.c | 205 tests/fate/checkasm.mak | 1 + 5 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 tests/checkasm/sw_yuv2rgb.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index f20732b37a..3a7670e24b 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -63,7 +63,7 @@ AVFILTEROBJS-$(CONFIG_SOBEL_FILTER) += vf_convolution.o CHECKASMOBJS-$(CONFIG_AVFILTER) += $(AVFILTEROBJS-yes) # swscale tests -SWSCALEOBJS += sw_gbrp.o sw_range_convert.o sw_rgb.o sw_scale.o +SWSCALEOBJS += sw_gbrp.o sw_range_convert.o sw_rgb.o sw_scale.o sw_yuv2rgb.o CHECKASMOBJS-$(CONFIG_SWSCALE) += $(SWSCALEOBJS) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 56232ab1e0..d9ac772a08 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -254,6 +254,7 @@ static const struct { { "sw_range_convert", checkasm_check_sw_range_convert }, { "sw_rgb", checkasm_check_sw_rgb }, { "sw_scale", checkasm_check_sw_scale }, +{ "sw_yuv2rgb", checkasm_check_sw_yuv2rgb }, #endif #if CONFIG_AVUTIL { "fixed_dsp", checkasm_check_fixed_dsp }, diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index e544007b67..4d5f3e387e 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -122,6 +122,7 @@ void checkasm_check_sw_gbrp(void); void checkasm_check_sw_range_convert(void); void checkasm_check_sw_rgb(void); void checkasm_check_sw_scale(void); +void checkasm_check_sw_yuv2rgb(void); void checkasm_check_takdsp(void); void checkasm_check_utvideodsp(void); void checkasm_check_v210dec(void); diff --git a/tests/checkasm/sw_yuv2rgb.c b/tests/checkasm/sw_yuv2rgb.c new file mode 100644 index 00..fbe01a7788 --- /dev/null +++ b/tests/checkasm/sw_yuv2rgb.c @@ -0,0 +1,205 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include + +#include "libavutil/common.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/mem_internal.h" +#include "libavutil/pixdesc.h" + +#include "libswscale/swscale.h" +#include "libswscale/swscale_internal.h" + +#include "checkasm.h" + +#define randomize_buffers(buf, size) \ +do { \ +for (int j = 0; j < size; j += 4) \ +AV_WN32(buf + j, rnd()); \ +} while (0) + +static const int dst_fmts[] = { +// AV_PIX_FMT_BGR48BE, +// AV_PIX_FMT_BGR48LE, +// AV_PIX_FMT_RGB48BE, +// AV_PIX_FMT_RGB48LE, +AV_PIX_FMT_ARGB, +AV_PIX_FMT_ABGR, +AV_PIX_FMT_RGBA, +AV_PIX_FMT_BGRA, +AV_PIX_FMT_RGB24, +AV_PIX_FMT_BGR24, +AV_PIX_FMT_RGB565, +AV_PIX_FMT_BGR565, +AV_PIX_FMT_RGB555, +AV_PIX_FMT_BGR555, +// AV_PIX_FMT_RGB444, +// AV_PIX_FMT_BGR444, +// AV_PIX_FMT_RGB8, +// AV_PIX_FMT_BGR8, +// AV_PIX_FMT_RGB4, +// AV_PIX_FMT_BGR4, +// AV_PIX_FMT_RGB4_BYTE, +// AV_PIX_FMT_BGR4_BYTE, +// AV_PIX_FMT_MONOBLACK, +}; + +static int cmp_off_by_n(const uint8_t *ref, const uint8_t *test, size_t n, int accuracy) +{ +for (size_t i = 0; i < n; i++) { +if (abs(ref[i] - test[i]) > accuracy) +return 1; +} +return 0; +} + +static int cmp_555_by_n(const uint8_t *ref, const uint8_t *test, size_t n, int accuracy) +{ +const uint16_t *ref16 = (const uint16_t *) ref; +const uint16_t *test16 = (const uint16_t *) test; +for (size_t i = 0; i < n; i++) { +if (abs(( ref16[i]& 0x1f) - ( test16[i]& 0x1f)) > accuracy) +return 1; +if (abs(((ref16[i] >> 5) & 0x1f) - ((test16[i] >> 5) & 0x1f)) > accuracy) +return 1; +if (abs(((ref16[i] >> 10) & 0x1f) - ((test16[i] >> 10) & 0x1f)) > accuracy) +return 1; +} +return 0; +} + +static int cmp_565_by_n(const uint8_t *ref, const uint8_t *test, size_t n, int accuracy) +{ +const uint16_t *ref16 = (const uint16_t *) ref; +const uint16_t *test16 = (const uint16_t *) test; +for (size_t i = 0; i < n; i++) { +if (abs(( ref16[i]& 0x
[FFmpeg-devel] [PATCH 6/6] swscale/yuv2rgb/x86: remove mmx/mmxext yuv2rgb functions
These functions are either slower or barely faster than the C LUT yuv2rgb code. --- libswscale/x86/yuv2rgb.c | 51 - libswscale/x86/yuv2rgb_template.c | 4 -- libswscale/x86/yuv_2_rgb.asm | 93 +-- 3 files changed, 3 insertions(+), 145 deletions(-) diff --git a/libswscale/x86/yuv2rgb.c b/libswscale/x86/yuv2rgb.c index 6754062245..41dfa80f33 100644 --- a/libswscale/x86/yuv2rgb.c +++ b/libswscale/x86/yuv2rgb.c @@ -41,25 +41,8 @@ #define DITHER1XBPP // only for MMX -//MMX versions -#if HAVE_MMX -#undef RENAME -#define COMPILE_TEMPLATE_MMX -#define RENAME(a) a ## _mmx -#include "yuv2rgb_template.c" -#undef COMPILE_TEMPLATE_MMX -#endif /* HAVE_MMX */ - -// MMXEXT versions -#undef RENAME -#define COMPILE_TEMPLATE_MMXEXT -#define RENAME(a) a ## _mmxext -#include "yuv2rgb_template.c" -#undef COMPILE_TEMPLATE_MMXEXT - //SSSE3 versions #undef RENAME -#define COMPILE_TEMPLATE_SSSE3 #define RENAME(a) a ## _ssse3 #include "yuv2rgb_template.c" @@ -99,40 +82,6 @@ av_cold SwsFunc ff_yuv2rgb_init_x86(SwsContext *c) } } -if (EXTERNAL_MMXEXT(cpu_flags)) { -switch (c->dstFormat) { -case AV_PIX_FMT_RGB24: -return yuv420_rgb24_mmxext; -case AV_PIX_FMT_BGR24: -return yuv420_bgr24_mmxext; -} -} - -if (EXTERNAL_MMX(cpu_flags)) { -switch (c->dstFormat) { -case AV_PIX_FMT_RGB32: -if (c->srcFormat == AV_PIX_FMT_YUVA420P) { -#if CONFIG_SWSCALE_ALPHA -return yuva420_rgb32_mmx; -#endif -break; -} else -return yuv420_rgb32_mmx; -case AV_PIX_FMT_BGR32: -if (c->srcFormat == AV_PIX_FMT_YUVA420P) { -#if CONFIG_SWSCALE_ALPHA -return yuva420_bgr32_mmx; -#endif -break; -} else -return yuv420_bgr32_mmx; -case AV_PIX_FMT_RGB565: -return yuv420_rgb16_mmx; -case AV_PIX_FMT_RGB555: -return yuv420_rgb15_mmx; -} -} - #endif /* HAVE_X86ASM */ return NULL; } diff --git a/libswscale/x86/yuv2rgb_template.c b/libswscale/x86/yuv2rgb_template.c index 596943bb73..a4741e6873 100644 --- a/libswscale/x86/yuv2rgb_template.c +++ b/libswscale/x86/yuv2rgb_template.c @@ -47,7 +47,6 @@ extern void RENAME(ff_yuv_420_bgr24)(x86_reg index, uint8_t *image, const uint8_ const uint8_t *pv_index, const uint64_t *pointer_c_dither, const uint8_t *py_2index); -#ifndef COMPILE_TEMPLATE_MMXEXT extern void RENAME(ff_yuv_420_rgb15)(x86_reg index, uint8_t *image, const uint8_t *pu_index, const uint8_t *pv_index, const uint64_t *pointer_c_dither, const uint8_t *py_2index); @@ -163,9 +162,7 @@ static inline int RENAME(yuva420_bgr32)(SwsContext *c, const uint8_t *src[], } return srcSliceH; } -#endif -#if !defined(COMPILE_TEMPLATE_MMX) static inline int RENAME(yuv420_rgb24)(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, @@ -193,4 +190,3 @@ static inline int RENAME(yuv420_bgr24)(SwsContext *c, const uint8_t *src[], } return srcSliceH; } -#endif diff --git a/libswscale/x86/yuv_2_rgb.asm b/libswscale/x86/yuv_2_rgb.asm index a1f9134e08..b67ab162d2 100644 --- a/libswscale/x86/yuv_2_rgb.asm +++ b/libswscale/x86/yuv_2_rgb.asm @@ -38,12 +38,6 @@ pb_e0: times 16 db 224 pb_03: times 16 db 3 pb_07: times 16 db 7 -mask_1101: dw -1, -1, 0, -1 -mask_0010: dw 0, 0, -1, 0 -mask_0110: dw 0, -1, -1, 0 -mask_1001: dw -1, 0, 0, -1 -mask_0100: dw 0, -1, 0, 0 - SECTION .text ;- @@ -55,14 +49,6 @@ SECTION .text ; ;- -%macro MOV_H2L 1 -%if mmsize == 8 -psrlq %1, 32 -%else ; mmsize == 16 -psrldq %1, 8 -%endif -%endmacro - %macro yuv2rgb_fn 3 %if %3 == 32 @@ -91,18 +77,6 @@ SECTION .text %define m_blue m1 %endif -%if mmsize == 8 -%define time_num 1 -%define reg_num 8 -%define y_offset [pointer_c_ditherq + 8 * 8] -%define u_offset [pointer_c_ditherq + 9 * 8] -%define v_offset [pointer_c_ditherq + 10 * 8] -%define ug_coff [pointer_c_ditherq + 7 * 8] -%define vg_coff [pointer_c_ditherq + 6 * 8] -%define y_coff [pointer_c_ditherq + 3 * 8] -%define ub_coff [pointer_c_ditherq + 5 * 8] -%define vr_coff [pointer_c_ditherq + 4 * 8] -%elif mmsize == 16 %define time_num 2 %if ARCH_X86_32 %define reg_num 8 @@ -125,13 +99,11 @@ SECTION .text %define ub_coff m14 %define vr_coff m15 %endif ; ARCH_X86_32/64 -%endif ; coeff define mmsize == 8/16 cglobal %1_420_%2%3, GPR_num,
[FFmpeg-devel] [PATCH 2/9] avcodec/mpeg4audio: Check that there is enough space for the first 3 elements in ff_mpeg4audio_get_config_gb()
Fixes: out of array access Fixes: 68863/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-4833546039525376 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/mpeg4audio.c | 4 1 file changed, 4 insertions(+) diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c index fbd2a8f811a..ae18944f0d5 100644 --- a/libavcodec/mpeg4audio.c +++ b/libavcodec/mpeg4audio.c @@ -94,6 +94,10 @@ int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, GetBitContext *gb, { int specific_config_bitindex, ret; int start_bit_index = get_bits_count(gb); + +if (get_bits_left(gb) < 5+4+4) +return AVERROR_INVALIDDATA; + c->object_type = get_object_type(gb); c->sample_rate = get_sample_rate(gb, &c->sampling_index); c->chan_config = get_bits(gb, 4); -- 2.45.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/9] avformat/iamf_parse: Try to use less space after the array
Fixes: out of array access Fixes: 68584/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6256656668229632 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/iamf_parse.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c index 312090b247c..5c2ff6862a7 100644 --- a/libavformat/iamf_parse.c +++ b/libavformat/iamf_parse.c @@ -355,6 +355,9 @@ static int scalable_channel_layout_config(void *s, AVIOContext *pb, substream_count = avio_r8(pb); coupled_substream_count = avio_r8(pb); +if (substream_count + k > audio_element->nb_substreams) +return AVERROR_INVALIDDATA; + audio_element->layers[i].substream_count = substream_count; audio_element->layers[i].coupled_substream_count = coupled_substream_count; if (output_gain_is_present_flag) { -- 2.45.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/9] avformat/iamf_parse: Layer, thou shalt not be 0
Fixes: out of array access Fixes: 68302/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4665793796177920 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/iamf_parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/iamf_parse.c b/libavformat/iamf_parse.c index 5c2ff6862a7..12c2b9533a8 100644 --- a/libavformat/iamf_parse.c +++ b/libavformat/iamf_parse.c @@ -330,7 +330,7 @@ static int scalable_channel_layout_config(void *s, AVIOContext *pb, nb_layers = avio_r8(pb) >> 5; // get_bits(&gb, 3); // skip_bits(&gb, 5); //reserved -if (nb_layers > 6) +if (nb_layers > 6 || nb_layers == 0) return AVERROR_INVALIDDATA; audio_element->layers = av_calloc(nb_layers, sizeof(*audio_element->layers)); -- 2.45.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/9] avcodec/targaenc: Allocate space for the palette
Fixes: out of array access Fixes: 68927/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TARGA_fuzzer-5105665067515904 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/targaenc.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c index d9c500b97de..8f496c62bd9 100644 --- a/libavcodec/targaenc.c +++ b/libavcodec/targaenc.c @@ -21,6 +21,7 @@ #include +#include "libavutil/avassert.h" #include "libavutil/imgutils.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" @@ -89,10 +90,11 @@ static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt, TargaContext *s = avctx->priv_data; int bpp, picsize, datasize = -1, ret, i; uint8_t *out; +int maxpal = 32*32; picsize = av_image_get_buffer_size(avctx->pix_fmt, avctx->width, avctx->height, 1); -if ((ret = ff_alloc_packet(avctx, pkt, picsize + 45)) < 0) +if ((ret = ff_alloc_packet(avctx, pkt, picsize + 45 + maxpal)) < 0) return ret; /* zero out the header and only set applicable fields */ @@ -125,6 +127,7 @@ static int targa_encode_frame(AVCodecContext *avctx, AVPacket *pkt, AV_WL24(pkt->data + 18 + 3 * i, *(uint32_t *)(p->data[1] + i * 4)); } out += 32 * pal_bpp;/* skip past the palette we just output */ +av_assert0(32 * pal_bpp <= maxpal); break; } case AV_PIX_FMT_GRAY8: -- 2.45.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 5/9] avformat/mov: Check extend and base offset
Fixes: signed integer overflow: 2314885530818453536 + 9151314442816847872 cannot be represented in type 'long' Fixes: 68359/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6571950311800832 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/mov.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 9016cd5ad08..46cbce98040 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -8131,7 +8131,9 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) } for (int j = 0; j < extent_count; j++) { if (rb_size(pb, &extent_offset, offset_size) < 0 || -rb_size(pb, &extent_length, length_size) < 0) +rb_size(pb, &extent_length, length_size) < 0 || +base_offset < 0 || extent_offset < 0 || +base_offset + (uint64_t)extent_offset > INT64_MAX) return AVERROR_INVALIDDATA; if (offset_type == 1) c->heif_item[i].is_idat_relative = 1; -- 2.45.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 6/9] avcodec/libvpxenc: Cleanup on error
This or fifo needs to be freed on errors explicitly I have not verified that its always safe to call vpx_free() this needs to be checked before applying this Fixes: memleak Fixes: 68937/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LIBVPX_VP8_fuzzer-4830831016214528 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/libvpxenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 5c7b6e9de73..5490246d9ed 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -2042,6 +2042,7 @@ const FFCodec ff_libvpx_vp8_encoder = { FF_CODEC_ENCODE_CB(vpx_encode), .close = vpx_free, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | + FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS, .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE }, .p.priv_class = &class_vp8, @@ -2118,6 +2119,7 @@ FFCodec ff_libvpx_vp9_encoder = { FF_CODEC_ENCODE_CB(vpx_encode), .close = vpx_free, .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | + FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS, .defaults = defaults, .init_static_data = vp9_init_static, -- 2.45.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 7/9] MAINTAINERS: Update the entries for the release maintainer for FFmpeg
Ive been told that someone at the BCN video tech meetup claimed to be the "release maintainer for FFmpeg". If you have any doubt who maintains releases, just do something like the following and look at the output: VER=5.1 echo commiters ; git shortlog --group=committer -s n$VER..release/$VER -n ;\ echo authors ; git shortlog-s n$VER..release/$VER -n Signed-off-by: Michael Niedermayer --- MAINTAINERS | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 41a98744adf..a82fa58c69f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -536,10 +536,12 @@ wm4 Releases +7.0 Michael Niedermayer +6.1 Michael Niedermayer +5.1 Michael Niedermayer +4.4 Michael Niedermayer +3.4 Michael Niedermayer 2.8 Michael Niedermayer -2.7 Michael Niedermayer -2.6 Michael Niedermayer -2.5 Michael Niedermayer If you want to maintain an older release, please contact us -- 2.45.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 8/9] avcodec/smcenc: width < 4 is unsupported
Fixes: out of array read Fixes: 68939/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMC_fuzzer-587804104884224 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/smcenc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/smcenc.c b/libavcodec/smcenc.c index 789aef4f770..d70cce900ec 100644 --- a/libavcodec/smcenc.c +++ b/libavcodec/smcenc.c @@ -537,6 +537,9 @@ static int smc_encode_frame(AVCodecContext *avctx, AVPacket *pkt, uint8_t *pal; int ret; +if (avctx->width < 4) +return AVERROR_PATCHWELCOME; + ret = ff_alloc_packet(avctx, pkt, 8LL * avctx->height * avctx->width); if (ret < 0) return ret; -- 2.45.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 9/9] avcodec/r210enc: Use av_rescale for bitrate
Fixes: signed integer overflow: 281612954574848 * 65344 cannot be represented in type 'long' Fixes: 68956/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_R210_fuzzer-6459074458746880 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/r210enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/r210enc.c b/libavcodec/r210enc.c index 91e34528741..ec1ebc8d609 100644 --- a/libavcodec/r210enc.c +++ b/libavcodec/r210enc.c @@ -35,7 +35,7 @@ static av_cold int encode_init(AVCodecContext *avctx) avctx->bits_per_coded_sample = 32; if (avctx->width > 0) -avctx->bit_rate = ff_guess_coded_bitrate(avctx) * aligned_width / avctx->width; +avctx->bit_rate = av_rescale(ff_guess_coded_bitrate(avctx), aligned_width, avctx->width); return 0; } -- 2.45.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 6/6] swscale/yuv2rgb/x86: remove mmx/mmxext yuv2rgb functions
On 6/16/2024 7:28 PM, Ramiro Polla wrote: These functions are either slower or barely faster than the C LUT yuv2rgb code. --- libswscale/x86/yuv2rgb.c | 51 - libswscale/x86/yuv2rgb_template.c | 4 -- libswscale/x86/yuv_2_rgb.asm | 93 +-- 3 files changed, 3 insertions(+), 145 deletions(-) diff --git a/libswscale/x86/yuv2rgb.c b/libswscale/x86/yuv2rgb.c index 6754062245..41dfa80f33 100644 --- a/libswscale/x86/yuv2rgb.c +++ b/libswscale/x86/yuv2rgb.c @@ -41,25 +41,8 @@ #define DITHER1XBPP // only for MMX Shouldn't this be removed too? -//MMX versions -#if HAVE_MMX -#undef RENAME -#define COMPILE_TEMPLATE_MMX -#define RENAME(a) a ## _mmx -#include "yuv2rgb_template.c" -#undef COMPILE_TEMPLATE_MMX -#endif /* HAVE_MMX */ - -// MMXEXT versions -#undef RENAME -#define COMPILE_TEMPLATE_MMXEXT -#define RENAME(a) a ## _mmxext -#include "yuv2rgb_template.c" -#undef COMPILE_TEMPLATE_MMXEXT - //SSSE3 versions #undef RENAME -#define COMPILE_TEMPLATE_SSSE3 #define RENAME(a) a ## _ssse3 #include "yuv2rgb_template.c" You could write a seventh patch that moves the template stuff back to this file, now that SSSE3 is the only version. See commit 8b62fb231a78. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] avcodec/jpeg2000dec: Add support for placeholder passes, CAP, and CPF markers
This v2 - fixes the regression indicated in Message-ID: <20240615201144.GB4991@pb2> by counting the number of necessary terminations for non HT code blocks with the existing code. - drops the commit that was recently merged. Signed-off-by: Osamu Watanabe --- libavcodec/jpeg2000.h | 10 + libavcodec/jpeg2000dec.c | 470 ++--- libavcodec/jpeg2000dec.h | 7 + libavcodec/jpeg2000htdec.c | 225 ++ libavcodec/jpeg2000htdec.h | 2 +- 5 files changed, 535 insertions(+), 179 deletions(-) diff --git a/libavcodec/jpeg2000.h b/libavcodec/jpeg2000.h index d004c08f10..93221d90ca 100644 --- a/libavcodec/jpeg2000.h +++ b/libavcodec/jpeg2000.h @@ -37,12 +37,14 @@ enum Jpeg2000Markers { JPEG2000_SOC = 0xff4f, // start of codestream +JPEG2000_CAP = 0xff50, // extended capabilities JPEG2000_SIZ = 0xff51, // image and tile size JPEG2000_COD, // coding style default JPEG2000_COC, // coding style component JPEG2000_TLM = 0xff55, // tile-part length, main header JPEG2000_PLM = 0xff57, // packet length, main header JPEG2000_PLT, // packet length, tile-part header +JPEG2000_CPF, // corresponding profile JPEG2000_QCD = 0xff5c, // quantization default JPEG2000_QCC, // quantization component JPEG2000_RGN, // region of interest @@ -58,6 +60,12 @@ enum Jpeg2000Markers { JPEG2000_EOC = 0xffd9, // end of codestream }; +enum JPEG2000_Ccap15_b14_15_params { +HTJ2K_HTONLY = 0, // HTONLY, bit 14 and 15 are 0 +HTJ2K_HTDECLARED, // HTDECLARED, bit 14 = 1 and bit 15 = 0 +HTJ2K_MIXED = 3, // MIXED, bit 14 and 15 are 1 +}; + #define JPEG2000_SOP_FIXED_BYTES 0xFF910004 #define JPEG2000_SOP_BYTE_LENGTH 6 @@ -192,6 +200,8 @@ typedef struct Jpeg2000Cblk { /* specific to HT code-blocks */ int zbp; int pass_lengths[2]; +uint8_t modes; // copy of SPcod/SPcoc field to parse HT-MIXED mode +uint8_t ht_plhd; // are we looking for HT placeholder passes? } Jpeg2000Cblk; // code block typedef struct Jpeg2000Prec { diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 091931b1ff..2d03107690 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -54,6 +54,15 @@ #define HAD_COC 0x01 #define HAD_QCC 0x02 +// Values of flag for placeholder passes +enum HT_PLHD_STATUS { +HT_PLHD_OFF, +HT_PLHD_ON +}; + +#define HT_MIXED 0x80 // bit 7 of SPcod/SPcoc + + /* get_bits functions for JPEG2000 packet bitstream * It is a get_bit function with a bit-stuffing routine. If the value of the * byte is 0xFF, the next byte includes an extra zero bit stuffed into the MSB. @@ -382,6 +391,9 @@ static int get_siz(Jpeg2000DecoderContext *s) } else if (ncomponents == 1 && s->precision == 8) { s->avctx->pix_fmt = AV_PIX_FMT_GRAY8; i = 0; +} else if (ncomponents == 1 && s->precision == 12) { +s->avctx->pix_fmt = AV_PIX_FMT_GRAY16LE; +i = 0; } } @@ -408,6 +420,73 @@ static int get_siz(Jpeg2000DecoderContext *s) s->avctx->bits_per_raw_sample = s->precision; return 0; } +/* get extended capabilities (CAP) marker segment */ +static int get_cap(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c) +{ +uint32_t Pcap; +uint16_t Ccap_i[32] = { 0 }; +uint16_t Ccap_15; +uint8_t P; + +if (bytestream2_get_bytes_left(&s->g) < 6) { +av_log(s->avctx, AV_LOG_ERROR, "Insufficient space for CAP\n"); +return AVERROR_INVALIDDATA; +} + +Pcap = bytestream2_get_be32u(&s->g); +s->isHT = (Pcap >> (31 - (15 - 1))) & 1; +for (int i = 0; i < 32; i++) { +if ((Pcap >> (31 - i)) & 1) +Ccap_i[i] = bytestream2_get_be16u(&s->g); +} +Ccap_15 = Ccap_i[14]; +if (s->isHT == 1) { +av_log(s->avctx, AV_LOG_INFO, "This is an HTJ2K codestream.\n"); +// Bits 14-15 +switch ((Ccap_15 >> 14) & 0x3) { +case 0x3: +s->Ccap15_b14_15 = HTJ2K_MIXED; +break; +case 0x1: +s->Ccap15_b14_15 = HTJ2K_HTDECLARED; +break; +case 0x0: +s->Ccap15_b14_15 = HTJ2K_HTONLY; +break; +default: +av_log(s->avctx, AV_LOG_ERROR, "Unknown CCap value.\n"); +return AVERROR(EINVAL); +break; +} +// Bit 13 +if ((Ccap_15 >> 13) & 1) { +av_log(s->avctx, AV_LOG_ERROR, "MULTIHT set is not supported.\n"); +return AVERROR_PATCHWELCOME; +} +// Bit 12 +s->Ccap15_b12 = (Ccap_15 >> 12) & 1; +// Bit 11 +s->Ccap15_b11 = (Ccap_15 >> 11) & 1; +// Bit 5 +s->Ccap15_b05 = (Ccap_15 >> 5) & 1; +// Bit 0-4 +P = Ccap_15 & 0x1F; +if (!P) +s->HT_MAGB = 8; +else if (P < 20) +s->HT_MAGB = P + 8; +else if (P < 31) +s->HT_MAGB = 4 * (P - 19) + 27; +else +s->HT_MAGB = 7
[FFmpeg-devel] [PATCH 1/2] avutil/executor: Allowing thread_count be zero
From: Zhao Zhili When thread_count be zero, it will be run on current thread like !HAVE_THREADS. --- libavutil/executor.c | 28 ++-- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/libavutil/executor.c b/libavutil/executor.c index 26691fe157..fb20104b58 100644 --- a/libavutil/executor.c +++ b/libavutil/executor.c @@ -82,9 +82,11 @@ static int run_one_task(AVExecutor *e, void *lc) /* nothing */; if (*prev) { AVTask *t = remove_task(prev, *prev); -ff_mutex_unlock(&e->lock); +if (e->thread_count > 0) +ff_mutex_unlock(&e->lock); cb->run(t, lc, cb->user_data); -ff_mutex_lock(&e->lock); +if (e->thread_count > 0) +ff_mutex_lock(&e->lock); return 1; } return 0; @@ -146,14 +148,17 @@ AVExecutor* av_executor_alloc(const AVTaskCallbacks *cb, int thread_count) return NULL; e->cb = *cb; -e->local_contexts = av_calloc(thread_count, e->cb.local_context_size); +e->local_contexts = av_calloc(FFMAX(thread_count, 1), e->cb.local_context_size); if (!e->local_contexts) goto free_executor; -e->threads = av_calloc(thread_count, sizeof(*e->threads)); +e->threads = av_calloc(FFMAX(thread_count, 1), sizeof(*e->threads)); if (!e->threads) goto free_executor; +if (!thread_count) +return e; + has_lock = !ff_mutex_init(&e->lock, NULL); has_cond = !ff_cond_init(&e->cond, NULL); @@ -175,9 +180,12 @@ free_executor: void av_executor_free(AVExecutor **executor) { +int thread_count; + if (!executor || !*executor) return; -executor_free(*executor, 1, 1); +thread_count = (*executor)->thread_count; +executor_free(*executor, thread_count, thread_count); *executor = NULL; } @@ -195,9 +203,9 @@ void av_executor_execute(AVExecutor *e, AVTask *t) ff_cond_signal(&e->cond); ff_mutex_unlock(&e->lock); -#if !HAVE_THREADS -// We are running in a single-threaded environment, so we must handle all tasks ourselves -while (run_one_task(e, e->local_contexts)) -/* nothing */; -#endif +if (!e->thread_count || !HAVE_THREADS) { +// We are running in a single-threaded environment, so we must handle all tasks ourselves +while (run_one_task(e, e->local_contexts)) +/* nothing */; +} } -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] avcodec/vvc: Don't create new thread when thread_count is 1
From: Zhao Zhili --- libavcodec/vvc/dec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/vvc/dec.c b/libavcodec/vvc/dec.c index f5603306f3..4ce2b1c6bd 100644 --- a/libavcodec/vvc/dec.c +++ b/libavcodec/vvc/dec.c @@ -1024,7 +1024,7 @@ static av_cold int vvc_decode_init(AVCodecContext *avctx) static AVOnce init_static_once = AV_ONCE_INIT; const int cpu_count= av_cpu_count(); const int delayed = FFMIN(cpu_count, VVC_MAX_DELAYED_FRAMES); -const int thread_count = avctx->thread_count ? avctx->thread_count : delayed; +int thread_count = avctx->thread_count ? avctx->thread_count : delayed; int ret; s->avctx = avctx; @@ -1051,6 +1051,8 @@ static av_cold int vvc_decode_init(AVCodecContext *avctx) return ret; } +if (thread_count == 1) +thread_count = 0; s->executor = ff_vvc_executor_alloc(s, thread_count); if (!s->executor) return AVERROR(ENOMEM); -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/9] avcodec/mpeg4audio: Check that there is enough space for the first 3 elements in ff_mpeg4audio_get_config_gb()
Michael Niedermayer: > Fixes: out of array access > Fixes: > 68863/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-4833546039525376 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/mpeg4audio.c | 4 > 1 file changed, 4 insertions(+) > > diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c > index fbd2a8f811a..ae18944f0d5 100644 > --- a/libavcodec/mpeg4audio.c > +++ b/libavcodec/mpeg4audio.c > @@ -94,6 +94,10 @@ int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, > GetBitContext *gb, > { > int specific_config_bitindex, ret; > int start_bit_index = get_bits_count(gb); > + > +if (get_bits_left(gb) < 5+4+4) > +return AVERROR_INVALIDDATA; > + > c->object_type = get_object_type(gb); > c->sample_rate = get_sample_rate(gb, &c->sampling_index); > c->chan_config = get_bits(gb, 4); This is not a proper fix. The real bug seems to be that avpriv_mpeg4audio_get_config2() relies on the buffer to be padded, but iamf_parse.c does not add padding. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/loongarch/Makefile: Fix vc1dsp_lasx.o build criterion
Andreas Rheinhardt: > Fixes ticket #11057. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/loongarch/Makefile | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/loongarch/Makefile b/libavcodec/loongarch/Makefile > index 07da2964e4..92c8b35906 100644 > --- a/libavcodec/loongarch/Makefile > +++ b/libavcodec/loongarch/Makefile > @@ -12,7 +12,7 @@ OBJS-$(CONFIG_HEVC_DECODER) += > loongarch/hevcdsp_init_loongarch.o > LASX-OBJS-$(CONFIG_H264QPEL) += loongarch/h264qpel_lasx.o > LASX-OBJS-$(CONFIG_H264DSP) += loongarch/h264dsp_lasx.o \ > loongarch/h264_deblock_lasx.o > -LASX-OBJS-$(CONFIG_VC1_DECODER) += loongarch/vc1dsp_lasx.o > +LASX-OBJS-$(CONFIG_VC1DSP)+= loongarch/vc1dsp_lasx.o > LASX-OBJS-$(CONFIG_HPELDSP) += loongarch/hpeldsp_lasx.o > LASX-OBJS-$(CONFIG_IDCTDSP) += loongarch/simple_idct_lasx.o \ > loongarch/idctdsp_lasx.o Will apply this patch tomorrow unless there are objections. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".