[FFmpeg-cvslog] avcodec/mpeg12dec: Use CHROMA_* defines
ffmpeg | branch: master | Andreas Rheinhardt | Tue Mar 4 17:11:32 2025 +0100| [ce1cec673e5366c0ecf8bae970ae84321b92f323] | committer: Andreas Rheinhardt avcodec/mpeg12dec: Use CHROMA_* defines Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ce1cec673e5366c0ecf8bae970ae84321b92f323 --- libavcodec/mpeg12dec.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 7284f2cd5a..ffe0710470 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -780,7 +780,7 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx) ff_mpeg12_init_vlcs(); -s2->chroma_format = 1; +s2->chroma_format = CHROMA_420; avctx->color_range = AVCOL_RANGE_MPEG; return 0; } @@ -864,11 +864,11 @@ static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx) if (CONFIG_GRAY && (avctx->flags & AV_CODEC_FLAG_GRAY)) return AV_PIX_FMT_GRAY8; -if (s->chroma_format < 2) +if (s->chroma_format < CHROMA_422) pix_fmts = avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO ? mpeg1_hwaccel_pixfmt_list_420 : mpeg2_hwaccel_pixfmt_list_420; -else if (s->chroma_format == 2) +else if (s->chroma_format == CHROMA_422) pix_fmts = mpeg12_pixfmt_list_422; else pix_fmts = mpeg12_pixfmt_list_444; @@ -990,9 +990,9 @@ FF_ENABLE_DEPRECATION_WARNINGS #endif switch (s->chroma_format) { -case 1: avctx->chroma_sample_location = AVCHROMA_LOC_LEFT; break; -case 2: -case 3: avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT; break; +case CHROMA_420: avctx->chroma_sample_location = AVCHROMA_LOC_LEFT; break; +case CHROMA_422: +case CHROMA_444: avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT; break; default: av_assert0(0); } } // MPEG-2 @@ -1066,7 +1066,7 @@ static void mpeg_decode_sequence_extension(Mpeg1Context *s1) s->chroma_format= get_bits(&s->gb, 2); /* chroma_format 1=420, 2=422, 3=444 */ if (!s->chroma_format) { -s->chroma_format = 1; +s->chroma_format = CHROMA_420; av_log(s->avctx, AV_LOG_WARNING, "Chroma format invalid\n"); } @@ -1545,7 +1545,7 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y, if (s->mb_y >= s->mb_height) { int left = get_bits_left(&s->gb); -int is_d10 = s->chroma_format == 2 && +int is_d10 = s->chroma_format == CHROMA_422 && s->pict_type == AV_PICTURE_TYPE_I && avctx->profile == 0 && avctx->level == 5 && s->intra_dc_precision == 2 && @@ -1843,7 +1843,7 @@ static int mpeg1_decode_sequence(AVCodecContext *avctx, s->picture_structure= PICT_FRAME; s->first_field = 0; s->frame_pred_frame_dct = 1; -s->chroma_format= 1; +s->chroma_format= CHROMA_420; s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO; if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) @@ -1895,7 +1895,7 @@ static int vcr2_init_sequence(AVCodecContext *avctx) s->picture_structure = PICT_FRAME; s->first_field = 0; s->frame_pred_frame_dct = 1; -s->chroma_format = 1; +s->chroma_format = CHROMA_420; if (s->codec_tag == AV_RL32("BW10")) { s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO; } else { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/rv34: Make ff_rv34_get_start_offset() honor its name
ffmpeg | branch: master | Andreas Rheinhardt | Wed Feb 26 11:13:15 2025 +0100| [3defca7eae025b2566115192af2078e7e780f080] | committer: Andreas Rheinhardt avcodec/rv34: Make ff_rv34_get_start_offset() honor its name Up until now, it only returned the number of bits for the start offset, but not the start offset; the GetBitContext passed to it was unused. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3defca7eae025b2566115192af2078e7e780f080 --- libavcodec/rv30.c | 4 +--- libavcodec/rv34.c | 2 +- libavcodec/rv40.c | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index 5e1dd01aa1..351276995b 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -38,7 +38,6 @@ static int rv30_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceInfo *si) { AVCodecContext *avctx = r->s.avctx; -int mb_bits; int w = r->s.width, h = r->s.height; int mb_size; int rpr; @@ -76,8 +75,7 @@ static int rv30_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceIn si->width = w; si->height = h; mb_size = ((w + 15) >> 4) * ((h + 15) >> 4); -mb_bits = ff_rv34_get_start_offset(gb, mb_size); -si->start = get_bits(gb, mb_bits); +si->start = ff_rv34_get_start_offset(gb, mb_size); skip_bits1(gb); return 0; } diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index d8d307f969..ddc95c3a78 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -342,7 +342,7 @@ int ff_rv34_get_start_offset(GetBitContext *gb, int mb_size) for(i = 0; i < 5; i++) if(rv34_mb_max_sizes[i] >= mb_size - 1) break; -return rv34_mb_bits_sizes[i]; +return get_bits(gb, rv34_mb_bits_sizes[i]); } /** diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index 0a5136d129..d28e02c2d1 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -131,7 +131,6 @@ static void rv40_parse_picture_size(GetBitContext *gb, int *w, int *h) static int rv40_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceInfo *si) { -int mb_bits; int w = r->s.width, h = r->s.height; int mb_size; int ret; @@ -154,8 +153,7 @@ static int rv40_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceIn si->width = w; si->height = h; mb_size = ((w + 15) >> 4) * ((h + 15) >> 4); -mb_bits = ff_rv34_get_start_offset(gb, mb_size); -si->start = get_bits(gb, mb_bits); +si->start = ff_rv34_get_start_offset(gb, mb_size); return 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/aarch64/vvc: Optimize vvc_avg{8, 10, 12}
ffmpeg | branch: master | Krzysztof Pyrkosz | Mon Mar 3 22:18:23 2025 +0100| [f9b8f30680b6107fe5c32f3ba5115359368ec234] | committer: Martin Storsjö avcodec/aarch64/vvc: Optimize vvc_avg{8, 10, 12} This patch replaces integer widening with halving addition, and multi-step "emulated" rounding shift with a single asm instruction doing exactly that. Benchmarks before and after: A78 avg_8_64x64_neon: 2686.2 ( 6.12x) avg_8_128x128_neon: 10734.2 ( 5.88x) avg_10_64x64_neon:2536.8 ( 5.40x) avg_10_128x128_neon: 10079.0 ( 5.22x) avg_12_64x64_neon:2548.2 ( 5.38x) avg_12_128x128_neon: 10133.8 ( 5.19x) avg_8_64x64_neon: 897.8 (18.26x) avg_8_128x128_neon: 3608.5 (17.37x) avg_10_32x32_neon: 444.2 ( 8.51x) avg_10_64x64_neon:1711.8 ( 8.00x) avg_12_64x64_neon:1706.2 ( 8.02x) avg_12_128x128_neon: 7010.0 ( 7.46x) A72 avg_8_64x64_neon: 5823.4 ( 3.88x) avg_8_128x128_neon: 17430.5 ( 4.73x) avg_10_64x64_neon:5228.1 ( 3.71x) avg_10_128x128_neon: 16722.2 ( 4.17x) avg_12_64x64_neon:5379.1 ( 3.51x) avg_12_128x128_neon: 16715.7 ( 4.17x) avg_8_64x64_neon: 2006.5 (10.61x) avg_8_128x128_neon: 9158.7 ( 8.96x) avg_10_64x64_neon:3357.7 ( 5.60x) avg_10_128x128_neon: 12411.7 ( 5.56x) avg_12_64x64_neon:3317.5 ( 5.67x) avg_12_128x128_neon: 12358.5 ( 5.58x) A53 avg_8_64x64_neon: 8327.8 ( 5.18x) avg_8_128x128_neon: 31631.3 ( 5.34x) avg_10_64x64_neon:8783.5 ( 4.98x) avg_10_128x128_neon: 32617.0 ( 5.25x) avg_12_64x64_neon:8686.0 ( 5.06x) avg_12_128x128_neon: 32487.5 ( 5.25x) avg_8_64x64_neon: 6032.3 ( 7.17x) avg_8_128x128_neon: 22008.5 ( 7.69x) avg_10_64x64_neon:7738.0 ( 5.68x) avg_10_128x128_neon: 27813.8 ( 6.14x) avg_12_64x64_neon:7844.5 ( 5.60x) avg_12_128x128_neon: 26999.5 ( 6.34x) Signed-off-by: Martin Storsjö > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f9b8f30680b6107fe5c32f3ba5115359368ec234 --- libavcodec/aarch64/vvc/inter.S | 177 ++--- 1 file changed, 130 insertions(+), 47 deletions(-) diff --git a/libavcodec/aarch64/vvc/inter.S b/libavcodec/aarch64/vvc/inter.S index 967edb7f35..c299e6f68b 100644 --- a/libavcodec/aarch64/vvc/inter.S +++ b/libavcodec/aarch64/vvc/inter.S @@ -24,9 +24,9 @@ #define BDOF_BLOCK_SIZE 16 #define BDOF_MIN_BLOCK_SIZE 4 -.macro vvc_avg type, bit_depth +.macro vvc_w_avg bit_depth -.macro vvc_\type\()_\bit_depth\()_2_4 tap +.macro vvc_w_avg_\bit_depth\()_2_4 tap .if \tap == 2 ldr s0, [src0] ldr s2, [src1] @@ -34,18 +34,11 @@ ldr d0, [src0] ldr d2, [src1] .endif - -.ifc \type, avg -saddl v4.4s, v0.4h, v2.4h -add v4.4s, v4.4s, v16.4s -sqshrun v4.4h, v4.4s, #(15 - \bit_depth) -.else mov v4.16b, v16.16b smlal v4.4s, v0.4h, v19.4h smlal v4.4s, v2.4h, v20.4h sqshl v4.4s, v4.4s, v22.4s sqxtun v4.4h, v4.4s -.endif .if \bit_depth == 8 sqxtun v4.8b, v4.8h @@ -68,7 +61,7 @@ add dst, dst, dst_stride .endm -function ff_vvc_\type\()_\bit_depth\()_neon, export=1 +function ff_vvc_w_avg_\bit_depth\()_neon, export=1 dst .req x0 dst_stride .req x1 src0.req x2 @@ -78,9 +71,6 @@ function ff_vvc_\type\()_\bit_depth\()_neon, export=1 mov x10, #(VVC_MAX_PB_SIZE * 2) cmp width, #8 -.ifc \type, avg -moviv16.4s, #(1 << (14 - \bit_depth)) -.else lsr x11, x6, #32// weight0 mov w12, w6 // weight1 lsr x13, x7, #32// offset @@ -91,9 +81,8 @@ function ff_vvc_\type\()_\bit_depth\()
[FFmpeg-cvslog] avcodec/vc1_block, vc1dec: Don't use c_dc_scale(_table)?
ffmpeg | branch: master | Andreas Rheinhardt | Thu Feb 27 14:15:10 2025 +0100| [8aa08c9fa02ef8d6dc437d452e1c4f7c61624e98] | committer: Andreas Rheinhardt avcodec/vc1_block, vc1dec: Don't use c_dc_scale(_table)? It coincides with the luma values. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8aa08c9fa02ef8d6dc437d452e1c4f7c61624e98 --- libavcodec/vc1_block.c | 43 +++ libavcodec/vc1dec.c| 1 - 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c index 1c422d902f..5dd2083385 100644 --- a/libavcodec/vc1_block.c +++ b/libavcodec/vc1_block.c @@ -354,8 +354,7 @@ static inline int vc1_i_pred_dc(MpegEncContext *s, int overlap, int pq, int n, }; /* find prediction - wmv3_dc_scale always used here in fact */ -if (n < 4) scale = s->y_dc_scale; -else scale = s->c_dc_scale; +scale = s->y_dc_scale; wrap = s->block_wrap[n]; dc_val = s->dc_val[0] + s->block_index[n]; @@ -611,11 +610,7 @@ static int vc1_decode_i_block(VC1Context *v, int16_t block[64], int n, *dc_val = dcdiff; /* Store the quantized DC coeff, used for prediction */ -if (n < 4) -scale = s->y_dc_scale; -else -scale = s->c_dc_scale; -block[0] = dcdiff * scale; +block[0] = dcdiff * s->y_dc_scale; ac_val = s->ac_val[0][s->block_index[n]]; ac_val2 = ac_val; @@ -752,11 +747,7 @@ static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n, *dc_val = dcdiff; /* Store the quantized DC coeff, used for prediction */ -if (n < 4) -scale = s->y_dc_scale; -else -scale = s->c_dc_scale; -block[0] = dcdiff * scale; +block[0] = dcdiff * s->y_dc_scale; /* check if AC is needed at all */ if (!a_avail && !c_avail) @@ -925,9 +916,8 @@ static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n, /* XXX: Guard against dumb values of mquant */ quant = av_clip_uintp2(quant, 5); -/* Set DC scale - y and c use the same */ +/* Set DC scale - y and c use the same so we only set y */ s->y_dc_scale = s->y_dc_scale_table[quant]; -s->c_dc_scale = s->c_dc_scale_table[quant]; /* Get DC differential */ dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_vlc[s->dc_table_index][n >= 4], @@ -949,12 +939,7 @@ static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n, *dc_val = dcdiff; /* Store the quantized DC coeff, used for prediction */ - -if (n < 4) { -block[0] = dcdiff * s->y_dc_scale; -} else { -block[0] = dcdiff * s->c_dc_scale; -} +block[0] = dcdiff * s->y_dc_scale; //AC Decoding i = 1; @@ -1593,9 +1578,8 @@ static int vc1_decode_p_mb_intfr(VC1Context *v) v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); GET_MQUANT(); s->cur_pic.qscale_table[mb_pos] = mquant; -/* Set DC scale - y and c use the same (not sure if necessary here) */ +/* Set DC scale - y and c use the same so we only set y */ s->y_dc_scale = s->y_dc_scale_table[FFABS(mquant)]; -s->c_dc_scale = s->c_dc_scale_table[FFABS(mquant)]; dst_idx = 0; for (i = 0; i < 6; i++) { v->a_avail = v->c_avail = 0; @@ -1756,9 +1740,8 @@ static int vc1_decode_p_mb_intfi(VC1Context *v) s->cur_pic.mb_type[mb_pos + v->mb_off] = MB_TYPE_INTRA; GET_MQUANT(); s->cur_pic.qscale_table[mb_pos] = mquant; -/* Set DC scale - y and c use the same (not sure if necessary here) */ +/* Set DC scale - y and c use the same so we only set y */ s->y_dc_scale = s->y_dc_scale_table[FFABS(mquant)]; -s->c_dc_scale = s->c_dc_scale_table[FFABS(mquant)]; v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); mb_has_coeffs = idx_mbmode & 1; if (mb_has_coeffs) @@ -2044,9 +2027,8 @@ static int vc1_decode_b_mb_intfi(VC1Context *v) s->cur_pic.mb_type[mb_pos + v->mb_off] = MB_TYPE_INTRA; GET_MQUANT(); s->cur_pic.qscale_table[mb_pos] = mquant; -/* Set DC scale - y and c use the same (not sure if necessary here) */ +/* Set DC scale - y and c use the same so we only set y */ s->y_dc_scale = s->y_dc_scale_table[FFABS(mquant)]; -s->c_dc_scale = s->c_dc_scale_table[FFABS(mquant)]; v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); mb_has_coeffs = idx_mbmode & 1; if (mb_has_coeffs) @@ -2245,9 +2227,8 @@ static int vc1_decode_b_mb_intfr(VC1Context *v) v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); GET_MQUANT(); s->cur_pic.qscale_table[mb_pos] = mquant; -/* Set DC scale - y and c use the same (not sure if necessary here) */ +/* Set DC scale - y and c use the same so
[FFmpeg-cvslog] avcodec/mpegvideo: Move ratecontrol-only options to RateControlContext
ffmpeg | branch: master | Andreas Rheinhardt | Fri Feb 28 23:47:52 2025 +0100| [6844e9611683eec24873e2017cfb2602e7fd2dcc] | committer: Andreas Rheinhardt avcodec/mpegvideo: Move ratecontrol-only options to RateControlContext Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6844e9611683eec24873e2017cfb2602e7fd2dcc --- libavcodec/mpegvideo.h| 11 --- libavcodec/mpegvideoenc.h | 13 +++-- libavcodec/ratecontrol.c | 25 + libavcodec/ratecontrol.h | 11 +++ libavcodec/snowenc.c | 2 +- 5 files changed, 32 insertions(+), 30 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index ac38d112f9..5fef008cc5 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -507,21 +507,10 @@ typedef struct MpegEncContext { me_cmp_func sse_cmp[2]; int (*sum_abs_dctelem)(const int16_t *block); -/** - * ratecontrol qmin qmax limiting method - * 0-> clipping, 1-> use a nice continuous function to limit qscale within qmin/qmax. - */ -float rc_qsquish; -float rc_qmod_amp; -int rc_qmod_freq; -float rc_initial_cplx; -float rc_buffer_aggressivity; float border_masking; int lmin, lmax; int vbv_ignore_qmax; -char *rc_eq; - /* temp buffers for rate control */ float *cplx_tab, *bits_tab; diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 2d7f76c57a..6dd382a3c6 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -81,6 +81,7 @@ { "msad", "Sum of absolute differences, median predicted", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_MEDIAN_SAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, .unit = "cmp_func" } #define FF_MPV_OFFSET(x) offsetof(MpegEncContext, x) +#define FF_RC_OFFSET(x) offsetof(MpegEncContext, rc_context.x) #define FF_MPV_OPT_FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) #define FF_MPV_COMMON_OPTS \ FF_MPV_OPT_CMP_FUNC, \ @@ -99,16 +100,16 @@ FF_MPV_OPT_CMP_FUNC, \ { "error_rate", "Simulate errors in the bitstream to test error concealment.", \ FF_MPV_OFFSET(error_rate), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FF_MPV_OPT_FLAGS },\ {"qsquish", "how to keep quantizer between qmin and qmax (0 = clip, 1 = use differentiable function)", \ - FF_MPV_OFFSET(rc_qsquish), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, 0, 99, FF_MPV_OPT_FLAGS},\ -{"rc_qmod_amp", "experimental quantizer modulation", FF_MPV_OFFSET(rc_qmod_amp), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ -{"rc_qmod_freq", "experimental quantizer modulation", FF_MPV_OFFSET(rc_qmod_freq), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS}, \ + FF_RC_OFFSET(qsquish), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, 0, 99, FF_MPV_OPT_FLAGS},\ +{"rc_qmod_amp", "experimental quantizer modulation", FF_RC_OFFSET(qmod_amp), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ +{"rc_qmod_freq", "experimental quantizer modulation", FF_RC_OFFSET(qmod_freq), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS}, \ {"rc_eq", "Set rate control equation. When computing the expression, besides the standard functions " \ "defined in the section 'Expression Evaluation', the following functions are available: " \ "bits2qp(bits), qp2bits(qp). Also the following constants are available: iTex pTex tex mv " \ "fCode iCount mcVar var isI isP isB avgQP qComp avgIITex avgPITex avgPPTex avgBPTex avgTex.", \ - FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING, .flags = FF_MPV_OPT_FLAGS },\ -{"rc_init_cplx", "initial complexity for 1-pass encoding", FF_MPV_OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ -{"rc_buf_aggressivity", "currently useless", FF_MPV_OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ +
[FFmpeg-cvslog] avcodec/mpegvideo_enc: Don't init matrices unnecessarily for MJPEG
ffmpeg | branch: master | Andreas Rheinhardt | Thu Feb 27 22:44:21 2025 +0100| [726adfafc6da9fb1ac2e54a02d9ad3299d2c1f82] | committer: Andreas Rheinhardt avcodec/mpegvideo_enc: Don't init matrices unnecessarily for MJPEG The MJPEG initialization happens later. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=726adfafc6da9fb1ac2e54a02d9ad3299d2c1f82 --- libavcodec/mpegvideo_enc.c | 4 1 file changed, 4 insertions(+) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index e4b89983ad..81e004d1a8 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -361,6 +361,10 @@ static av_cold int init_matrices(MpegEncContext *s, AVCodecContext *avctx) if (s->out_format == FMT_MJPEG) { s->q_chroma_intra_matrix = s->q_intra_matrix + 32; s->q_chroma_intra_matrix16 = s->q_intra_matrix16 + 32; +// No need to set q_inter_matrix +av_assert1(s->intra_only); +// intra_matrix, chroma_intra_matrix will be set later for MJPEG. +return 0; } else { s->q_chroma_intra_matrix = s->q_intra_matrix; s->q_chroma_intra_matrix16 = s->q_intra_matrix16; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mjpegenc: Use forward decl for MpegEncContext, MJpegHuffmanCode
ffmpeg | branch: master | Andreas Rheinhardt | Tue Mar 4 16:44:15 2025 +0100| [455ca92b31bfd68959040220d5c239818dab8680] | committer: Andreas Rheinhardt avcodec/mjpegenc: Use forward decl for MpegEncContext, MJpegHuffmanCode Avoids an indirect inclusion of mpegvideo.h in mjpegenc_common.c. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=455ca92b31bfd68959040220d5c239818dab8680 --- libavcodec/mjpegenc.c | 14 ++ libavcodec/mjpegenc.h | 19 +++ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index cd8eb8f6c1..38d5ad3a11 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -45,6 +45,20 @@ #include "mpegvideoenc.h" #include "profiles.h" +/** + * Buffer of JPEG frame data. + * + * Optimal Huffman table generation requires the frame data to be loaded into + * a buffer so that the tables can be computed. + * There are at most mb_width*mb_height*12*64 of these per frame. + */ +typedef struct MJpegHuffmanCode { +// 0=DC lum, 1=DC chrom, 2=AC lum, 3=AC chrom +uint8_t table_id; ///< The Huffman table id associated with the data. +uint8_t code; ///< The exponent. +uint16_t mant;///< The mantissa. +} MJpegHuffmanCode; + /* The following is the private context of MJPEG/AMV decoder. * Note that when using slice threading only the main thread's * MpegEncContext is followed by a MjpegContext; the other threads diff --git a/libavcodec/mjpegenc.h b/libavcodec/mjpegenc.h index a593b67e96..1ac0d6de7e 100644 --- a/libavcodec/mjpegenc.h +++ b/libavcodec/mjpegenc.h @@ -36,23 +36,8 @@ #include #include "mjpeg.h" -#include "mpegvideo.h" #include "put_bits.h" -/** - * Buffer of JPEG frame data. - * - * Optimal Huffman table generation requires the frame data to be loaded into - * a buffer so that the tables can be computed. - * There are at most mb_width*mb_height*12*64 of these per frame. - */ -typedef struct MJpegHuffmanCode { -// 0=DC lum, 1=DC chrom, 2=AC lum, 3=AC chrom -uint8_t table_id; ///< The Huffman table id associated with the data. -uint8_t code; ///< The exponent. -uint16_t mant;///< The mantissa. -} MJpegHuffmanCode; - /** * Holds JPEG frame data and Huffman table data. */ @@ -89,7 +74,7 @@ typedef struct MJpegContext { uint8_t val_ac_chrominance[256]; ///< AC chrominance Huffman values. size_t huff_ncode; ///< Number of current entries in the buffer. -MJpegHuffmanCode *huff_buffer; ///< Buffer for Huffman code values. +struct MJpegHuffmanCode *huff_buffer; ///< Buffer for Huffman code values. } MJpegContext; /** @@ -107,6 +92,8 @@ static inline void put_marker(PutBitContext *p, enum JpegMarker code) put_bits(p, 8, code); } +typedef struct MpegEncContext MpegEncContext; + int ff_mjpeg_encode_init(MpegEncContext *s); void ff_mjpeg_amv_encode_picture_header(MpegEncContext *s); void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64]); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mjpegenc: Constify parent ctx in encode_block()
ffmpeg | branch: master | Andreas Rheinhardt | Tue Mar 4 18:07:23 2025 +0100| [8940a6153ff60f9649d5bbde021df98bae68d543] | committer: Andreas Rheinhardt avcodec/mjpegenc: Constify parent ctx in encode_block() Said parent is shared between all slice contexts and encode_block() can be run concurrently by slice threads, so the parent context must not be (and is not) modified. So constify the pointers. Reviewed-by: Ramiro Polla Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8940a6153ff60f9649d5bbde021df98bae68d543 --- libavcodec/mjpegenc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 0bd362c3af..bcfc5523fb 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -480,9 +480,9 @@ static void encode_block(MpegEncContext *s, int16_t *block, int n) { int mant, nbits, code, i, j; int component, dc, run, last_index, val; -MJpegContext *m = s->mjpeg_ctx; -uint8_t *huff_size_ac; -uint16_t *huff_code_ac; +const MJpegContext *const m = s->mjpeg_ctx; +const uint16_t *huff_code_ac; +const uint8_t *huff_size_ac; /* DC coef */ component = (n <= 3 ? 0 : (n&1) + 1); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mjpegenc_common: Constify ff_mjpeg_encode_{dc,picture_header}()
ffmpeg | branch: master | Andreas Rheinhardt | Tue Mar 4 17:18:30 2025 +0100| [60cae5019a536fe988e01ea3986f656d109c2e70] | committer: Andreas Rheinhardt avcodec/mjpegenc_common: Constify ff_mjpeg_encode_{dc,picture_header}() Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=60cae5019a536fe988e01ea3986f656d109c2e70 --- libavcodec/mjpegenc_common.c | 16 libavcodec/mjpegenc_common.h | 10 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c index 751e43fd3b..e7a4f8f16a 100644 --- a/libavcodec/mjpegenc_common.c +++ b/libavcodec/mjpegenc_common.c @@ -56,10 +56,10 @@ static int put_huffman_table(PutBitContext *p, int table_class, int table_id, } static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p, - MJpegContext *m, + const MJpegContext *m, const uint8_t intra_matrix_permutation[64], - uint16_t luma_intra_matrix[64], - uint16_t chroma_intra_matrix[64], + const uint16_t luma_intra_matrix[64], + const uint16_t chroma_intra_matrix[64], int hsample[3], int use_slices, int matrices_differ) { int size; @@ -246,7 +246,7 @@ static void jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p, } } -void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[4], int vsample[4]) +void ff_mjpeg_init_hvsample(const AVCodecContext *avctx, int hsample[4], int vsample[4]) { if (avctx->codec_id == AV_CODEC_ID_LJPEG && ( avctx->pix_fmt == AV_PIX_FMT_BGR0 @@ -273,10 +273,10 @@ void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[4], int vsample[4 } void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb, -const AVFrame *frame, struct MJpegContext *m, +const AVFrame *frame, const struct MJpegContext *m, const uint8_t intra_matrix_permutation[64], int pred, -uint16_t luma_intra_matrix[64], -uint16_t chroma_intra_matrix[64], +const uint16_t luma_intra_matrix[64], +const uint16_t chroma_intra_matrix[64], int use_slices) { const int lossless = !m; @@ -465,7 +465,7 @@ void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits) } void ff_mjpeg_encode_dc(PutBitContext *pb, int val, -uint8_t *huff_size, uint16_t *huff_code) +const uint8_t huff_size[], const uint16_t huff_code[]) { int mant, nbits; diff --git a/libavcodec/mjpegenc_common.h b/libavcodec/mjpegenc_common.h index e9f0ea44a0..0cf5a72706 100644 --- a/libavcodec/mjpegenc_common.h +++ b/libavcodec/mjpegenc_common.h @@ -31,21 +31,21 @@ struct MJpegContext; int ff_mjpeg_add_icc_profile_size(AVCodecContext *avctx, const AVFrame *frame, size_t *max_pkt_size); void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb, -const AVFrame *frame, struct MJpegContext *m, +const AVFrame *frame, const struct MJpegContext *m, const uint8_t intra_matrix_permutation[64], int pred, -uint16_t luma_intra_matrix[64], -uint16_t chroma_intra_matrix[64], +const uint16_t luma_intra_matrix[64], +const uint16_t chroma_intra_matrix[64], int use_slices); void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits); void ff_mjpeg_escape_FF(PutBitContext *pb, int start); void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code, const uint8_t *bits_table, const uint8_t *val_table); -void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[4], int vsample[4]); +void ff_mjpeg_init_hvsample(const AVCodecContext *avctx, int hsample[4], int vsample[4]); void ff_mjpeg_encode_dc(PutBitContext *pb, int val, -uint8_t *huff_size, uint16_t *huff_code); +const uint8_t huff_size[], const uint16_t huff_code[]); int ff_mjpeg_encode_check_pix_fmt(AVCodecContext *avctx); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit li
[FFmpeg-cvslog] avcodec/mjpegenc: Don't use ff_ prefix for static functions
ffmpeg | branch: master | Andreas Rheinhardt | Tue Mar 4 16:46:30 2025 +0100| [5689d9c0f44bbf8a65e8f87d9c9da11d13beb372] | committer: Andreas Rheinhardt avcodec/mjpegenc: Don't use ff_ prefix for static functions Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5689d9c0f44bbf8a65e8f87d9c9da11d13beb372 --- libavcodec/mjpegenc.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 38d5ad3a11..0bd362c3af 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -390,7 +390,7 @@ static av_cold int mjpeg_encode_close(AVCodecContext *avctx) * @param table_id Which Huffman table the code belongs to. * @param code The encoded exponent of the coefficients and the run-bits. */ -static inline void ff_mjpeg_encode_code(MJpegContext *s, uint8_t table_id, int code) +static inline void mjpeg_encode_code(MJpegContext *s, uint8_t table_id, int code) { MJpegHuffmanCode *c = &s->huff_buffer[s->huff_ncode++]; c->table_id = table_id; @@ -405,13 +405,13 @@ static inline void ff_mjpeg_encode_code(MJpegContext *s, uint8_t table_id, int c * @param val The coefficient. * @param run The run-bits. */ -static void ff_mjpeg_encode_coef(MJpegContext *s, uint8_t table_id, int val, int run) +static void mjpeg_encode_coef(MJpegContext *s, uint8_t table_id, int val, int run) { int mant, code; if (val == 0) { av_assert0(run == 0); -ff_mjpeg_encode_code(s, table_id, 0); +mjpeg_encode_code(s, table_id, 0); } else { mant = val; if (val < 0) { @@ -422,7 +422,7 @@ static void ff_mjpeg_encode_coef(MJpegContext *s, uint8_t table_id, int val, int code = (run << 4) | (av_log2_16bit(val) + 1); s->huff_buffer[s->huff_ncode].mant = mant; -ff_mjpeg_encode_code(s, table_id, code); +mjpeg_encode_code(s, table_id, code); } } @@ -445,7 +445,7 @@ static void record_block(MpegEncContext *s, int16_t *block, int n) dc = block[0]; /* overflow is impossible */ val = dc - s->last_dc[component]; -ff_mjpeg_encode_coef(m, table_id, val, 0); +mjpeg_encode_coef(m, table_id, val, 0); s->last_dc[component] = dc; @@ -463,17 +463,17 @@ static void record_block(MpegEncContext *s, int16_t *block, int n) run++; } else { while (run >= 16) { -ff_mjpeg_encode_code(m, table_id, 0xf0); +mjpeg_encode_code(m, table_id, 0xf0); run -= 16; } -ff_mjpeg_encode_coef(m, table_id, val, run); +mjpeg_encode_coef(m, table_id, val, run); run = 0; } } /* output EOB only if not already 64 values */ if (last_index < 63 || run != 0) -ff_mjpeg_encode_code(m, table_id, 0); +mjpeg_encode_code(m, table_id, 0); } static void encode_block(MpegEncContext *s, int16_t *block, int n) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpegvideo: Move vbv_delay to Mpeg1Context
ffmpeg | branch: master | Andreas Rheinhardt | Sat Jan 29 06:50:51 2022 +0100| [c709a3d424f3dab4dfd994924112dd7ffa1cacdc] | committer: Andreas Rheinhardt avcodec/mpegvideo: Move vbv_delay to Mpeg1Context Only used there and only by the main thread. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c709a3d424f3dab4dfd994924112dd7ffa1cacdc --- libavcodec/mpeg12dec.c | 5 +++-- libavcodec/mpegvideo.h | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 64f39ea995..7284f2cd5a 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -90,6 +90,7 @@ typedef struct Mpeg1Context { int tmpgexs; int first_slice; int extradata_decoded; +int vbv_delay; int64_t timecode_frame_start; /*< GOP timecode frame start number, in non drop frame format */ } Mpeg1Context; @@ -953,7 +954,7 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) (s->bit_rate != 0x3*400)) { avctx->rc_max_rate = s->bit_rate; } else if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO && s->bit_rate && - (s->bit_rate != 0x3*400 || s->vbv_delay != 0x)) { + (s->bit_rate != 0x3*400 || s1->vbv_delay != 0x)) { avctx->bit_rate = s->bit_rate; } s1->save_aspect = s->avctx->sample_aspect_ratio; @@ -1024,7 +1025,7 @@ static int mpeg1_decode_picture(AVCodecContext *avctx, const uint8_t *buf, return AVERROR_INVALIDDATA; vbv_delay = get_bits(&s->gb, 16); -s->vbv_delay = vbv_delay; +s1->vbv_delay = vbv_delay; if (s->pict_type == AV_PICTURE_TYPE_P || s->pict_type == AV_PICTURE_TYPE_B) { s->full_pel[0] = get_bits1(&s->gb); diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 43d4bbfbcb..10be87450a 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -204,7 +204,6 @@ typedef struct MpegEncContext { int adaptive_quant; ///< use adaptive quantization int dquant; ///< qscale difference to prev qscale int pict_type; ///< AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ... -int vbv_delay; int last_pict_type; //FIXME removes int last_non_b_pict_type; ///< used for MPEG-4 gmc B-frames & ratecontrol int droppable; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mjpegenc: Remove nonsensical AMV options
ffmpeg | branch: master | Andreas Rheinhardt | Mon Mar 3 01:36:39 2025 +0100| [6cdcf15e0a558f82562d290c04aa1de0f3fd7809] | committer: Andreas Rheinhardt avcodec/mjpegenc: Remove nonsensical AMV options Both these options are unsupported and silently ignored for AMV; so it is better to not offer them at all. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6cdcf15e0a558f82562d290c04aa1de0f3fd7809 --- libavcodec/mjpegenc.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index c2e8b93a34..22d2b4816f 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -301,7 +301,7 @@ av_cold int ff_mjpeg_encode_init(MpegEncContext *s) (s->avctx->active_thread_type & FF_THREAD_SLICE) && s->avctx->thread_count > 1; -if (s->codec_id == AV_CODEC_ID_AMV || use_slices) +if (use_slices) m->huffman = HUFFMAN_TABLE_DEFAULT; if (s->mpv_flags & FF_MPV_FLAG_QP_RD) { @@ -624,11 +624,12 @@ static int amv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, #define OFFSET(x) offsetof(MJPEGEncContext, mjpeg.x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { -FF_MPV_COMMON_OPTS +#define AMV_OPTIONS_OFFSET 4 { "huffman", "Huffman table strategy", OFFSET(huffman), AV_OPT_TYPE_INT, { .i64 = HUFFMAN_TABLE_OPTIMAL }, 0, NB_HUFFMAN_TABLE_OPTION - 1, VE, .unit = "huffman" }, { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = HUFFMAN_TABLE_DEFAULT }, INT_MIN, INT_MAX, VE, .unit = "huffman" }, { "optimal", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = HUFFMAN_TABLE_OPTIMAL }, INT_MIN, INT_MAX, VE, .unit = "huffman" }, { "force_duplicated_matrix", "Always write luma and chroma matrix for mjpeg, useful for rtp streaming.", OFFSET(force_duplicated_matrix), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, VE }, +FF_MPV_COMMON_OPTS { NULL}, }; @@ -688,7 +689,7 @@ FFCodec ff_mjpeg_encoder = { static const AVClass amv_class = { .class_name = "amv encoder", .item_name = av_default_item_name, -.option = options, +.option = options + AMV_OPTIONS_OFFSET, .version= LIBAVUTIL_VERSION_INT, }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/speedhqenc: Inline ff_speedhq_mb_y_order_to_mb()
ffmpeg | branch: master | Andreas Rheinhardt | Mon Mar 3 16:27:44 2025 +0100| [fc158f3d40bff59fc79e061c3fb68157acfbee47] | committer: Andreas Rheinhardt avcodec/speedhqenc: Inline ff_speedhq_mb_y_order_to_mb() It is an extremely simple function that is only called once, so it should be inlined. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fc158f3d40bff59fc79e061c3fb68157acfbee47 --- libavcodec/speedhqenc.c | 16 libavcodec/speedhqenc.h | 16 +++- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index dda534..87497f5f85 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -272,22 +272,6 @@ void ff_speedhq_encode_mb(MpegEncContext *s, int16_t block[12][64]) s->i_tex_bits += get_bits_diff(s); } -static int ff_speedhq_mb_rows_in_slice(int slice_num, int mb_height) -{ -return mb_height / 4 + (slice_num < (mb_height % 4)); -} - -int ff_speedhq_mb_y_order_to_mb(int mb_y_order, int mb_height, int *first_in_slice) -{ -int slice_num = 0; -while (mb_y_order >= ff_speedhq_mb_rows_in_slice(slice_num, mb_height)) { - mb_y_order -= ff_speedhq_mb_rows_in_slice(slice_num, mb_height); - slice_num++; -} -*first_in_slice = (mb_y_order == 0); -return mb_y_order * 4 + slice_num; -} - const FFCodec ff_speedhq_encoder = { .p.name = "speedhq", CODEC_LONG_NAME("NewTek SpeedHQ"), diff --git a/libavcodec/speedhqenc.h b/libavcodec/speedhqenc.h index 0c52e6a380..15be9764d7 100644 --- a/libavcodec/speedhqenc.h +++ b/libavcodec/speedhqenc.h @@ -40,6 +40,20 @@ void ff_speedhq_encode_mb(MpegEncContext *s, int16_t block[12][64]); void ff_speedhq_encode_picture_header(MpegEncContext *s); void ff_speedhq_end_slice(MpegEncContext *s); -int ff_speedhq_mb_y_order_to_mb(int mb_y_order, int mb_height, int *first_in_slice); +static inline int ff_speedhq_mb_rows_in_slice(int slice_num, int mb_height) +{ +return mb_height / 4 + (slice_num < (mb_height % 4)); +} + +static inline int ff_speedhq_mb_y_order_to_mb(int mb_y_order, int mb_height, int *first_in_slice) +{ +int slice_num = 0; +while (mb_y_order >= ff_speedhq_mb_rows_in_slice(slice_num, mb_height)) { + mb_y_order -= ff_speedhq_mb_rows_in_slice(slice_num, mb_height); + slice_num++; +} +*first_in_slice = (mb_y_order == 0); +return mb_y_order * 4 + slice_num; +} #endif /* AVCODEC_SPEEDHQENC_H */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mjpegenc: Don't log to private context
ffmpeg | branch: master | Andreas Rheinhardt | Mon Mar 3 01:42:24 2025 +0100| [d5db4ee30c46456d7da2af01bf1f2c070811ff0b] | committer: Andreas Rheinhardt avcodec/mjpegenc: Don't log to private context Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d5db4ee30c46456d7da2af01bf1f2c070811ff0b --- libavcodec/mjpegenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 22d2b4816f..cd8eb8f6c1 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -318,7 +318,7 @@ av_cold int ff_mjpeg_encode_init(MpegEncContext *s) return ret; if (s->width > 65500 || s->height > 65500) { -av_log(s, AV_LOG_ERROR, "JPEG does not support resolutions above 65500x65500\n"); +av_log(s->avctx, AV_LOG_ERROR, "JPEG does not support resolutions above 65500x65500\n"); return AVERROR(EINVAL); } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/speedhqenc: Don't log to the private context
ffmpeg | branch: master | Andreas Rheinhardt | Sun Mar 2 00:12:05 2025 +0100| [49c38761f14b2abcc549bcf658778e0aa5cf890b] | committer: Andreas Rheinhardt avcodec/speedhqenc: Don't log to the private context Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=49c38761f14b2abcc549bcf658778e0aa5cf890b --- libavcodec/speedhqenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index ac40fd6e75..dda534 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -100,13 +100,13 @@ av_cold int ff_speedhq_encode_init(MpegEncContext *s) static AVOnce init_static_once = AV_ONCE_INIT; if (s->width > 65500 || s->height > 65500) { -av_log(s, AV_LOG_ERROR, "SpeedHQ does not support resolutions above 65500x65500\n"); +av_log(s->avctx, AV_LOG_ERROR, "SpeedHQ does not support resolutions above 65500x65500\n"); return AVERROR(EINVAL); } // border is not implemented correctly at the moment, see ticket #10078 if (s->width % 16) { -av_log(s, AV_LOG_ERROR, "width must be a multiple of 16\n"); +av_log(s->avctx, AV_LOG_ERROR, "width must be a multiple of 16\n"); return AVERROR_PATCHWELCOME; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpegvideo_enc, motion_est: Pre-center fcode_tab
ffmpeg | branch: master | Andreas Rheinhardt | Thu Feb 17 16:54:20 2022 +0100| [85138c1434db29e792db7deb63530f72a69d4452] | committer: Andreas Rheinhardt avcodec/mpegvideo_enc, motion_est: Pre-center fcode_tab Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=85138c1434db29e792db7deb63530f72a69d4452 --- libavcodec/ituh263enc.c| 2 +- libavcodec/motion_est.c| 3 +-- libavcodec/mpeg12enc.c | 2 +- libavcodec/mpeg4videoenc.c | 2 +- libavcodec/mpegvideo_enc.c | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 5beb857a6e..188996a4d1 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -843,7 +843,7 @@ av_cold void ff_h263_encode_init(MpegEncContext *s) break; case AV_CODEC_ID_H263P: if(s->umvplus) -s->fcode_tab= umv_fcode_tab; +s->fcode_tab = umv_fcode_tab + MAX_MV; if(s->modified_quant){ s->min_qcoeff= -2047; s->max_qcoeff= 2047; diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 46c4ca2dd9..4940da21f3 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -1619,8 +1619,7 @@ int ff_get_best_fcode(MpegEncContext * s, const int16_t (*mv_table)[2], int type if(s->mb_type[xy] & type){ int mx= mv_table[xy][0]; int my= mv_table[xy][1]; -int fcode= FFMAX(fcode_tab[mx + MAX_MV], - fcode_tab[my + MAX_MV]); +int fcode = FFMAX(fcode_tab[mx], fcode_tab[my]); int j; if (mx >= range || mx < -range || diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index ca51430fce..0586b8cfe2 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -1157,7 +1157,7 @@ av_cold void ff_mpeg1_encode_init(MpegEncContext *s) s->c_dc_scale_table = ff_mpeg12_dc_scale_table[s->intra_dc_precision]; s->me.mv_penalty = mv_penalty; -s->fcode_tab = fcode_tab; +s->fcode_tab = fcode_tab + MAX_MV; if (s->codec_id == AV_CODEC_ID_MPEG1VIDEO) { s->min_qcoeff = -255; s->max_qcoeff = 255; diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 26f9b40ff7..6ce5bc4462 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -1290,7 +1290,7 @@ static av_cold int encode_init(AVCodecContext *avctx) ff_thread_once(&init_static_once, mpeg4_encode_init_static); -s->fcode_tab= fcode_tab; +s->fcode_tab= fcode_tab + MAX_MV; s->min_qcoeff = -2048; s->max_qcoeff = 2047; s->intra_ac_vlc_length = uni_mpeg4_intra_rl_len; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 4e4b4c1ba9..4aeefcaf8d 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -286,7 +286,7 @@ static void mpv_encode_defaults(MpegEncContext *s) ff_thread_once(&init_static_once, mpv_encode_init_static); -s->fcode_tab = default_fcode_tab; +s->fcode_tab = default_fcode_tab + MAX_MV; s->input_picture_number = 0; s->picture_in_gop_number = 0; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpegvideo_enc: Set chroma_intra_matrix for SpeedHQ
ffmpeg | branch: master | Andreas Rheinhardt | Thu Feb 27 21:13:03 2025 +0100| [7223363ccb2c9ac4afe1b9fc824ddabc768a1014] | committer: Andreas Rheinhardt avcodec/mpegvideo_enc: Set chroma_intra_matrix for SpeedHQ Used with trellis; notice that inter_matrix is unused for (intra-only) SpeedHQ, so it is irrelevant that its value changes. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7223363ccb2c9ac4afe1b9fc824ddabc768a1014 --- libavcodec/mpegvideo_enc.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 79d6bfc056..11ebbe6a30 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -992,11 +992,8 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) } else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) { s->intra_matrix[j] = s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i]; -} else if (CONFIG_SPEEDHQ_ENCODER && s->codec_id == AV_CODEC_ID_SPEEDHQ) { -s->intra_matrix[j] = -s->inter_matrix[j] = ff_mpeg1_default_intra_matrix[i]; } else { -/* MPEG-1/2 */ +/* MPEG-1/2, SpeedHQ */ s->chroma_intra_matrix[j] = s->intra_matrix[j] = ff_mpeg1_default_intra_matrix[i]; s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i]; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpegvideo_enc: Only allocate chroma intra matrices when needed
ffmpeg | branch: master | Andreas Rheinhardt | Thu Feb 27 19:01:03 2025 +0100| [daff2df1a0f34ed5a44b48f76c550d22e96604a4] | committer: Andreas Rheinhardt avcodec/mpegvideo_enc: Only allocate chroma intra matrices when needed Also start factoring the matrix-init code out into a function of its own to declutter ff_mpv_encode_init(). Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=daff2df1a0f34ed5a44b48f76c550d22e96604a4 --- libavcodec/mpegvideo_enc.c | 27 ++- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 1fe69f89a6..79d6bfc056 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -348,6 +348,20 @@ static av_cold int me_cmp_init(MpegEncContext *s, AVCodecContext *avctx) return 0; } +static av_cold int init_matrices(MpegEncContext *s, AVCodecContext *avctx) +{ +if (s->out_format == FMT_MJPEG) { +if (!FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix, 32) || +!FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix16, 32)) +return AVERROR(ENOMEM); +} else { +s->q_chroma_intra_matrix = s->q_intra_matrix; +s->q_chroma_intra_matrix16 = s->q_intra_matrix16; +} + +return 0; +} + /* init video encoder */ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) { @@ -866,10 +880,8 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) if (!(avctx->stats_out = av_mallocz(256)) || !FF_ALLOCZ_TYPED_ARRAY(s->q_intra_matrix, 32) || -!FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix, 32) || !FF_ALLOCZ_TYPED_ARRAY(s->q_inter_matrix, 32) || !FF_ALLOCZ_TYPED_ARRAY(s->q_intra_matrix16,32) || -!FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix16, 32) || !FF_ALLOCZ_TYPED_ARRAY(s->q_inter_matrix16,32) || !FF_ALLOCZ_TYPED_ARRAY(s->input_picture, MAX_B_FRAMES + 1) || !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_B_FRAMES + 1) || @@ -877,6 +889,10 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) !(s->picture_pool = ff_mpv_alloc_pic_pool(0))) return AVERROR(ENOMEM); +ret = init_matrices(s, avctx); +if (ret < 0) +return ret; + /* Allocate MV tables; the MV and MB tables will be copied * to slice contexts by ff_update_duplicate_context(). */ mv_table_size = (s->mb_height + 2) * s->mb_stride + 1; @@ -3700,13 +3716,6 @@ static int encode_picture(MpegEncContext *s, const AVPacket *pkt) update_qscale(s); } -if (s->out_format != FMT_MJPEG) { -if(s->q_chroma_intra_matrix != s->q_intra_matrix ) av_freep(&s->q_chroma_intra_matrix); -if(s->q_chroma_intra_matrix16 != s->q_intra_matrix16) av_freep(&s->q_chroma_intra_matrix16); -s->q_chroma_intra_matrix = s->q_intra_matrix; -s->q_chroma_intra_matrix16 = s->q_intra_matrix16; -} - ff_me_init_pic(s); s->mb_intra=0; //for the rate distortion & bit compare functions ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/flvenc: Remove redundant setting of dc_scale_tables
ffmpeg | branch: master | Andreas Rheinhardt | Mon Mar 3 20:09:58 2025 +0100| [17ff442adb385bddc5f2c8967fc581bf833f3e4d] | committer: Andreas Rheinhardt avcodec/flvenc: Remove redundant setting of dc_scale_tables h263_aic is always zero for FLV and ff_mpeg1_dc_scale_table is already the default dc_scale table for both y and c. h263_aic is also always zero for the FLV decoder. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=17ff442adb385bddc5f2c8967fc581bf833f3e4d --- libavcodec/flvenc.c | 10 -- 1 file changed, 10 deletions(-) diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c index cbe3b7f056..192c2a929f 100644 --- a/libavcodec/flvenc.c +++ b/libavcodec/flvenc.c @@ -20,9 +20,7 @@ #include "codec_internal.h" #include "flvenc.h" -#include "h263data.h" #include "mpegvideo.h" -#include "mpegvideodata.h" #include "mpegvideoenc.h" void ff_flv_encode_picture_header(MpegEncContext *s) @@ -63,14 +61,6 @@ void ff_flv_encode_picture_header(MpegEncContext *s) put_bits(&s->pb, 1, 1); /* DeblockingFlag: on */ put_bits(&s->pb, 5, s->qscale); /* Quantizer */ put_bits(&s->pb, 1, 0); /* ExtraInformation */ - -if (s->h263_aic) { -s->y_dc_scale_table = -s->c_dc_scale_table = ff_aic_dc_scale_table; -} else { -s->y_dc_scale_table = -s->c_dc_scale_table = ff_mpeg1_dc_scale_table; -} } void ff_flv2_encode_ac_esc(PutBitContext *pb, int slevel, int level, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpeg4video: Split ff_mpeg4_pred_dc()
ffmpeg | branch: master | Andreas Rheinhardt | Mon Mar 3 00:21:04 2025 +0100| [5df8c86b247f39195d96d7a5b8d0f6c9113a401d] | committer: Andreas Rheinhardt avcodec/mpeg4video: Split ff_mpeg4_pred_dc() It currently does two things: a) Get a prediction for the dc and the dc direction and b) process said prediction. Processing the prediction differs for encoding (getting a diff) and decoding (getting the level via diff+prediction). So having a common function performing b) makes no sense. Even worse, there is a decoding mode where the dc coefficient (diff) is not coded specially and therefore unavailable before entering the block decoding loop, so that one can only perform a). Before this commit, the decoder simply called ff_mpeg4_pred_dc() twice; the results of the b) part of the call before the loop were ignored (but the compiler could not elide them because they involved error messages) and a) was also performed twice. This commit changes this by splitting b) out of ff_mpeg4_pred_dc() and moving this code to decoder and encoder. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5df8c86b247f39195d96d7a5b8d0f6c9113a401d --- libavcodec/mpeg4video.h| 47 - libavcodec/mpeg4videodec.c | 48 +- libavcodec/mpeg4videoenc.c | 10 -- 3 files changed, 55 insertions(+), 50 deletions(-) diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h index 29b11eb92e..9ac18943a2 100644 --- a/libavcodec/mpeg4video.h +++ b/libavcodec/mpeg4video.h @@ -44,24 +44,15 @@ int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my); /** * Predict the dc. - * encoding quantized level -> quantized diff - * decoding quantized diff -> quantized level * @param n block index (0-3 are luma, 4-5 are chroma) * @param dir_ptr pointer to an integer where the prediction direction will be stored */ -static inline int ff_mpeg4_pred_dc(MpegEncContext *s, int n, int level, - int *dir_ptr, int encoding) +static inline int ff_mpeg4_pred_dc(MpegEncContext *s, int n, int *dir_ptr) { -int a, b, c, wrap, pred, scale, ret; -int16_t *dc_val; +int a, b, c, wrap, pred; +const int16_t *dc_val; /* find prediction */ -if (n < 4) -scale = s->y_dc_scale; -else -scale = s->c_dc_scale; -if (IS_3IV1) -scale = 8; wrap = s->block_wrap[n]; dc_val = s->dc_val[0] + s->block_index[n]; @@ -93,37 +84,7 @@ static inline int ff_mpeg4_pred_dc(MpegEncContext *s, int n, int level, pred = a; *dir_ptr = 0; /* left */ } -/* we assume pred is positive */ -pred = FASTDIV((pred + (scale >> 1)), scale); - -if (encoding) { -ret = level - pred; -} else { -level += pred; -ret= level; -} -level *= scale; -if (level & (~2047)) { -if (!s->encoding && (s->avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_AGGRESSIVE))) { -if (level < 0) { -av_log(s->avctx, AV_LOG_ERROR, - "dc<0 at %dx%d\n", s->mb_x, s->mb_y); -return AVERROR_INVALIDDATA; -} -if (level > 2048 + scale) { -av_log(s->avctx, AV_LOG_ERROR, - "dc overflow at %dx%d\n", s->mb_x, s->mb_y); -return AVERROR_INVALIDDATA; -} -} -if (level < 0) -level = 0; -else if (!(s->workaround_bugs & FF_BUG_DC_CLIP)) -level = 2047; -} -dc_val[0] = level; - -return ret; +return pred; } #endif /* AVCODEC_MPEG4VIDEO_H */ diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 2a340ea682..31d00dd0b9 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -880,6 +880,43 @@ static inline int get_amv(Mpeg4DecContext *ctx, int n) return sum; } +static inline int mpeg4_get_level_dc(MpegEncContext *s, int n, int pred, int level) +{ +int scale = n < 4 ? s->y_dc_scale : s->c_dc_scale; +int ret; + +if (IS_3IV1) +scale = 8; + +/* we assume pred is positive */ +pred = FASTDIV((pred + (scale >> 1)), scale); + +level += pred; +ret= level; +level *= scale; +if (level & (~2047)) { +if (s->avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_AGGRESSIVE)) { +if (level < 0) { +av_log(s->avctx, AV_LOG_ERROR, + "dc<0 at %dx%d\n", s->mb_x, s->mb_y); +return AVERROR_INVALIDDATA; +} +if (level > 2048 + scale) { +av_log(s->avctx, AV_LOG_ERROR, + "dc overflow at %dx%d\n", s->mb_x, s->mb_y); +return AVERROR_INVALIDDATA; +} +} +if (level < 0) +level = 0; +else if (!(s->workaround_bugs & FF_BUG_DC_CLIP)) +
[FFmpeg-cvslog] avcodec/mpegvideo_enc: Factor checks out of loop
ffmpeg | branch: master | Andreas Rheinhardt | Thu Feb 27 22:01:12 2025 +0100| [a43124452f8c2ca6d00f3bf61c83fac4cd487a2e] | committer: Andreas Rheinhardt avcodec/mpegvideo_enc: Factor checks out of loop Also move this code to init_matrices(). Reviewed-by: Ramiro Polla Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a43124452f8c2ca6d00f3bf61c83fac4cd487a2e --- libavcodec/mpegvideo_enc.c | 49 +- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 11ebbe6a30..aab82248e0 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -350,6 +350,8 @@ static av_cold int me_cmp_init(MpegEncContext *s, AVCodecContext *avctx) static av_cold int init_matrices(MpegEncContext *s, AVCodecContext *avctx) { +const uint16_t *intra_matrix, *inter_matrix; + if (s->out_format == FMT_MJPEG) { if (!FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix, 32) || !FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix16, 32)) @@ -359,6 +361,31 @@ static av_cold int init_matrices(MpegEncContext *s, AVCodecContext *avctx) s->q_chroma_intra_matrix16 = s->q_intra_matrix16; } +if (CONFIG_MPEG4_ENCODER && s->codec_id == AV_CODEC_ID_MPEG4 && +s->mpeg_quant) { +intra_matrix = ff_mpeg4_default_intra_matrix; +inter_matrix = ff_mpeg4_default_non_intra_matrix; +} else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) { +intra_matrix = +inter_matrix = ff_mpeg1_default_non_intra_matrix; +} else { +/* MPEG-1/2, SpeedHQ */ +intra_matrix = ff_mpeg1_default_intra_matrix; +inter_matrix = ff_mpeg1_default_non_intra_matrix; +} +if (avctx->intra_matrix) +intra_matrix = avctx->intra_matrix; +if (avctx->inter_matrix) +inter_matrix = avctx->inter_matrix; + +/* init q matrix */ +for (int i = 0; i < 64; i++) { +int j = s->idsp.idct_permutation[i]; + +s->intra_matrix[j] = s->chroma_intra_matrix[j] = intra_matrix[i]; +s->inter_matrix[j] = inter_matrix[i]; +} + return 0; } @@ -982,28 +1009,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) #endif } -/* init q matrix */ -for (i = 0; i < 64; i++) { -int j = s->idsp.idct_permutation[i]; -if (CONFIG_MPEG4_ENCODER && s->codec_id == AV_CODEC_ID_MPEG4 && -s->mpeg_quant) { -s->intra_matrix[j] = ff_mpeg4_default_intra_matrix[i]; -s->inter_matrix[j] = ff_mpeg4_default_non_intra_matrix[i]; -} else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) { -s->intra_matrix[j] = -s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i]; -} else { -/* MPEG-1/2, SpeedHQ */ -s->chroma_intra_matrix[j] = -s->intra_matrix[j] = ff_mpeg1_default_intra_matrix[i]; -s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i]; -} -if (avctx->intra_matrix) -s->intra_matrix[j] = avctx->intra_matrix[i]; -if (avctx->inter_matrix) -s->inter_matrix[j] = avctx->inter_matrix[i]; -} - /* precompute matrix */ /* for mjpeg, we do include qscale in the matrix */ if (s->out_format != FMT_MJPEG) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpegvideo_enc: Only allocate inter matrices when needed
ffmpeg | branch: master | Andreas Rheinhardt | Thu Feb 27 22:29:58 2025 +0100| [41451b4eef61a1390e1a25c722ed2d920d6c5e44] | committer: Andreas Rheinhardt avcodec/mpegvideo_enc: Only allocate inter matrices when needed Also allocate them jointly with intra matrices when needed. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=41451b4eef61a1390e1a25c722ed2d920d6c5e44 --- libavcodec/mpegvideo_enc.c | 27 +-- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index aab82248e0..e4b89983ad 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -348,18 +348,27 @@ static av_cold int me_cmp_init(MpegEncContext *s, AVCodecContext *avctx) return 0; } +#define ALLOCZ_ARRAYS(p, mult, numb) ((p) = av_calloc(numb, mult * sizeof(*(p static av_cold int init_matrices(MpegEncContext *s, AVCodecContext *avctx) { +const int nb_matrices = 1 + (s->out_format == FMT_MJPEG) + !s->intra_only; const uint16_t *intra_matrix, *inter_matrix; +if (!ALLOCZ_ARRAYS(s->q_intra_matrix, 32, nb_matrices) || +!ALLOCZ_ARRAYS(s->q_intra_matrix16, 32, nb_matrices)) +return AVERROR(ENOMEM); + if (s->out_format == FMT_MJPEG) { -if (!FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix, 32) || -!FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix16, 32)) -return AVERROR(ENOMEM); +s->q_chroma_intra_matrix = s->q_intra_matrix + 32; +s->q_chroma_intra_matrix16 = s->q_intra_matrix16 + 32; } else { s->q_chroma_intra_matrix = s->q_intra_matrix; s->q_chroma_intra_matrix16 = s->q_intra_matrix16; } +if (!s->intra_only) { +s->q_inter_matrix = s->q_intra_matrix + 32; +s->q_inter_matrix16 = s->q_intra_matrix16 + 32; +} if (CONFIG_MPEG4_ENCODER && s->codec_id == AV_CODEC_ID_MPEG4 && s->mpeg_quant) { @@ -906,10 +915,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) return ret; if (!(avctx->stats_out = av_mallocz(256)) || -!FF_ALLOCZ_TYPED_ARRAY(s->q_intra_matrix, 32) || -!FF_ALLOCZ_TYPED_ARRAY(s->q_inter_matrix, 32) || -!FF_ALLOCZ_TYPED_ARRAY(s->q_intra_matrix16,32) || -!FF_ALLOCZ_TYPED_ARRAY(s->q_inter_matrix16,32) || !FF_ALLOCZ_TYPED_ARRAY(s->input_picture, MAX_B_FRAMES + 1) || !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_B_FRAMES + 1) || !(s->new_pic = av_frame_alloc()) || @@ -948,7 +953,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) !(s->mb_mean = av_mallocz(mb_array_size))) return AVERROR(ENOMEM); -#define ALLOCZ_ARRAYS(p, mult, numb) ((p) = av_calloc(numb, mult * sizeof(*(p if (s->codec_id == AV_CODEC_ID_MPEG4 || (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME)) { int16_t (*tmp1)[2]; @@ -1019,6 +1023,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) ff_convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16, s->intra_matrix, s->intra_quant_bias, avctx->qmin, 31, 1); +if (s->q_inter_matrix) ff_convert_matrix(s, s->q_inter_matrix, s->q_inter_matrix16, s->inter_matrix, s->inter_quant_bias, avctx->qmin, 31, 0); @@ -1093,14 +1098,8 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx) av_freep(&s->cplx_tab); av_freep(&s->bits_tab); -if(s->q_chroma_intra_matrix != s->q_intra_matrix ) av_freep(&s->q_chroma_intra_matrix); -if(s->q_chroma_intra_matrix16 != s->q_intra_matrix16) av_freep(&s->q_chroma_intra_matrix16); -s->q_chroma_intra_matrix= NULL; -s->q_chroma_intra_matrix16= NULL; av_freep(&s->q_intra_matrix); -av_freep(&s->q_inter_matrix); av_freep(&s->q_intra_matrix16); -av_freep(&s->q_inter_matrix16); av_freep(&s->input_picture); av_freep(&s->reordered_input_picture); av_freep(&s->dct_offset); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpeg4video: Move IS_3IV1 macro to mpeg4videodec.c
ffmpeg | branch: master | Andreas Rheinhardt | Mon Mar 3 01:12:02 2025 +0100| [70359de69fe0e800bec2171a703e1ad57b980b1c] | committer: Andreas Rheinhardt avcodec/mpeg4video: Move IS_3IV1 macro to mpeg4videodec.c Also add parentheses around the replacement to make it safer. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=70359de69fe0e800bec2171a703e1ad57b980b1c --- libavcodec/mpeg4video.h| 6 -- libavcodec/mpeg4videodec.c | 6 ++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/mpeg4video.h b/libavcodec/mpeg4video.h index 9ac18943a2..cfc6dcb684 100644 --- a/libavcodec/mpeg4video.h +++ b/libavcodec/mpeg4video.h @@ -36,12 +36,6 @@ void ff_mpeg4_init_direct_mv(MpegEncContext *s); */ int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my); -#if 0 //3IV1 is quite rare and it slows things down a tiny bit -#define IS_3IV1 s->codec_tag == AV_RL32("3IV1") -#else -#define IS_3IV1 0 -#endif - /** * Predict the dc. * @param n block index (0-3 are luma, 4-5 are chroma) diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 31d00dd0b9..139b6d4b08 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -49,6 +49,12 @@ #include "xvididct.h" #include "unary.h" +#if 0 //3IV1 is quite rare and it slows things down a tiny bit +#define IS_3IV1 (s->codec_tag == AV_RL32("3IV1")) +#else +#define IS_3IV1 0 +#endif + /* The defines below define the number of bits that are read at once for * reading vlc values. Changing these may improve speed and data cache needs * be aware though that decreasing them may need the number of stages that is ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpeg12dec: Don't count errors from first thread twice
ffmpeg | branch: master | Andreas Rheinhardt | Sat Mar 1 22:36:35 2025 +0100| [4d8b706b1d33e75eb30b289c152280d4535c40e6] | committer: Andreas Rheinhardt avcodec/mpeg12dec: Don't count errors from first thread twice Compilers can not perform this optimization on their own given that they don't know that the different thread_context pointers don't alias. Also avoid using sequentially consistent operations with atomics when only a single thread accesses them. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4d8b706b1d33e75eb30b289c152280d4535c40e6 --- libavcodec/mpeg12dec.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 14c028379e..92772acf5f 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -29,6 +29,7 @@ #define UNCHECKED_BITSTREAM_READER 1 #include +#include #include "libavutil/attributes.h" #include "libavutil/emms.h" @@ -46,7 +47,6 @@ #include "hwaccel_internal.h" #include "hwconfig.h" #include "idctdsp.h" -#include "internal.h" #include "mpeg_er.h" #include "mpeg12.h" #include "mpeg12codecs.h" @@ -2252,6 +2252,7 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE) && !avctx->hwaccel) { +int error_count = 0; int i; av_assert0(avctx->thread_count > 1); @@ -2259,7 +2260,10 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, &s2->thread_context[0], NULL, s->slice_count, sizeof(void *)); for (i = 0; i < s->slice_count; i++) -s2->er.error_count += s2->thread_context[i]->er.error_count; +error_count += atomic_load_explicit(&s2->thread_context[i]->er.error_count, + memory_order_relaxed); +atomic_store_explicit(&s2->er.error_count, error_count, + memory_order_relaxed); } ret = slice_end(avctx, picture, got_output); @@ -2321,13 +2325,17 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, } if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE) && !avctx->hwaccel && s->slice_count) { +int error_count = 0; int i; avctx->execute(avctx, slice_decode_thread, s2->thread_context, NULL, s->slice_count, sizeof(void *)); for (i = 0; i < s->slice_count; i++) -s2->er.error_count += s2->thread_context[i]->er.error_count; +error_count += atomic_load_explicit(&s2->thread_context[i]->er.error_count, +memory_order_relaxed); +atomic_store_explicit(&s2->er.error_count, error_count, + memory_order_relaxed); s->slice_count = 0; } if (last_code == 0 || last_code == SLICE_MIN_START_CODE) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpeg12dec: Mark flush as cold
ffmpeg | branch: master | Andreas Rheinhardt | Mon Mar 3 03:30:40 2025 +0100| [0c7e34856dcfabdd23bc41ad2a6657e776dcaed8] | committer: Andreas Rheinhardt avcodec/mpeg12dec: Mark flush as cold Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0c7e34856dcfabdd23bc41ad2a6657e776dcaed8 --- libavcodec/mpeg12dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 92772acf5f..64f39ea995 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -2641,7 +2641,7 @@ static int mpeg_decode_frame(AVCodecContext *avctx, AVFrame *picture, return ret; } -static void flush(AVCodecContext *avctx) +static av_cold void flush(AVCodecContext *avctx) { Mpeg1Context *s = avctx->priv_data; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/h261: Use forward-declaration for MpegEncContext
ffmpeg | branch: master | Andreas Rheinhardt | Fri Feb 28 18:13:59 2025 +0100| [a02fb1a4f43dfd2b9e3d83906452a75d2a2b1fa7] | committer: Andreas Rheinhardt avcodec/h261: Use forward-declaration for MpegEncContext Avoids an indirect inclusion of mpegvideo.h in h261data.c. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a02fb1a4f43dfd2b9e3d83906452a75d2a2b1fa7 --- libavcodec/h261.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/h261.h b/libavcodec/h261.h index 4279a12677..fb5fc6f940 100644 --- a/libavcodec/h261.h +++ b/libavcodec/h261.h @@ -29,7 +29,6 @@ #define AVCODEC_H261_H #include "mpegutils.h" -#include "mpegvideo.h" #include "rl.h" /** @@ -54,6 +53,7 @@ extern const uint16_t ff_h261_tcoeff_vlc[65][2]; extern const int8_t ff_h261_tcoeff_level[64]; extern const int8_t ff_h261_tcoeff_run[64]; -void ff_h261_loop_filter(MpegEncContext *s); +struct MpegEncContext; +void ff_h261_loop_filter(struct MpegEncContext *s); #endif /* AVCODEC_H261_H */ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/vc1_block: Inline y_dc_scale_table
ffmpeg | branch: master | Andreas Rheinhardt | Thu Feb 27 14:58:43 2025 +0100| [38e8eefc9c2c6469a5922f41cf9ea5d7baec967d] | committer: Andreas Rheinhardt avcodec/vc1_block: Inline y_dc_scale_table Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=38e8eefc9c2c6469a5922f41cf9ea5d7baec967d --- libavcodec/vc1_block.c | 22 +++--- libavcodec/vc1dec.c| 2 -- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c index 5dd2083385..8babbde38c 100644 --- a/libavcodec/vc1_block.c +++ b/libavcodec/vc1_block.c @@ -417,7 +417,7 @@ static inline int ff_vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n, /* scale predictors if needed */ q1 = FFABS(s->cur_pic.qscale_table[mb_pos]); -dqscale_index = s->y_dc_scale_table[q1] - 1; +dqscale_index = ff_wmv3_dc_scale_table[q1] - 1; if (dqscale_index < 0) return 0; @@ -434,12 +434,12 @@ static inline int ff_vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n, if (c_avail && (n != 1 && n != 3)) { q2 = FFABS(s->cur_pic.qscale_table[mb_pos - 1]); if (q2 && q2 != q1) -c = (int)((unsigned)c * s->y_dc_scale_table[q2] * ff_vc1_dqscale[dqscale_index] + 0x2) >> 18; +c = (int)((unsigned)c * ff_wmv3_dc_scale_table[q2] * ff_vc1_dqscale[dqscale_index] + 0x2) >> 18; } if (a_avail && (n != 2 && n != 3)) { q2 = FFABS(s->cur_pic.qscale_table[mb_pos - s->mb_stride]); if (q2 && q2 != q1) -a = (int)((unsigned)a * s->y_dc_scale_table[q2] * ff_vc1_dqscale[dqscale_index] + 0x2) >> 18; +a = (int)((unsigned)a * ff_wmv3_dc_scale_table[q2] * ff_vc1_dqscale[dqscale_index] + 0x2) >> 18; } if (a_avail && c_avail && (n != 3)) { int off = mb_pos; @@ -449,7 +449,7 @@ static inline int ff_vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n, off -= s->mb_stride; q2 = FFABS(s->cur_pic.qscale_table[off]); if (q2 && q2 != q1) -b = (int)((unsigned)b * s->y_dc_scale_table[q2] * ff_vc1_dqscale[dqscale_index] + 0x2) >> 18; +b = (int)((unsigned)b * ff_wmv3_dc_scale_table[q2] * ff_vc1_dqscale[dqscale_index] + 0x2) >> 18; } if (c_avail && (!a_avail || abs(a - b) <= abs(b - c))) { @@ -917,7 +917,7 @@ static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n, quant = av_clip_uintp2(quant, 5); /* Set DC scale - y and c use the same so we only set y */ -s->y_dc_scale = s->y_dc_scale_table[quant]; +s->y_dc_scale = ff_wmv3_dc_scale_table[quant]; /* Get DC differential */ dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_vlc[s->dc_table_index][n >= 4], @@ -1579,7 +1579,7 @@ static int vc1_decode_p_mb_intfr(VC1Context *v) GET_MQUANT(); s->cur_pic.qscale_table[mb_pos] = mquant; /* Set DC scale - y and c use the same so we only set y */ -s->y_dc_scale = s->y_dc_scale_table[FFABS(mquant)]; +s->y_dc_scale = ff_wmv3_dc_scale_table[FFABS(mquant)]; dst_idx = 0; for (i = 0; i < 6; i++) { v->a_avail = v->c_avail = 0; @@ -1741,7 +1741,7 @@ static int vc1_decode_p_mb_intfi(VC1Context *v) GET_MQUANT(); s->cur_pic.qscale_table[mb_pos] = mquant; /* Set DC scale - y and c use the same so we only set y */ -s->y_dc_scale = s->y_dc_scale_table[FFABS(mquant)]; +s->y_dc_scale = ff_wmv3_dc_scale_table[FFABS(mquant)]; v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); mb_has_coeffs = idx_mbmode & 1; if (mb_has_coeffs) @@ -2028,7 +2028,7 @@ static int vc1_decode_b_mb_intfi(VC1Context *v) GET_MQUANT(); s->cur_pic.qscale_table[mb_pos] = mquant; /* Set DC scale - y and c use the same so we only set y */ -s->y_dc_scale = s->y_dc_scale_table[FFABS(mquant)]; +s->y_dc_scale = ff_wmv3_dc_scale_table[FFABS(mquant)]; v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); mb_has_coeffs = idx_mbmode & 1; if (mb_has_coeffs) @@ -2228,7 +2228,7 @@ static int vc1_decode_b_mb_intfr(VC1Context *v) GET_MQUANT(); s->cur_pic.qscale_table[mb_pos] = mquant; /* Set DC scale - y and c use the same so we only set y */ -s->y_dc_scale = s->y_dc_scale_table[FFABS(mquant)]; +s->y_dc_scale = ff_wmv3_dc_scale_table[FFABS(mquant)]; dst_idx = 0; for (i = 0; i < 6; i++) { v->a_avail = v->c_avail = 0; @@ -2550,7 +2550,7 @@ static void vc1_decode_i_blocks(VC1Context *v) } /* Set DC scale - y and c use the same so we only set y */ -s->y_dc_scale = s->y_dc_scale_table[v->pq]; +s->y_dc_scale = ff_wmv3_dc_scale_table[v->pq]; //do frame decode s->mb_x = s->mb_y = 0; @@ -2719,7 +2719,7 @@ sta
[FFmpeg-cvslog] avcodec/ituh263enc: Move MPEG-4 fcode_tab to mpeg4videoenc.c
ffmpeg | branch: master | Andreas Rheinhardt | Mon Mar 3 21:04:49 2025 +0100| [94f364289b893e660ea2a7e3259db882d54ac508] | committer: Andreas Rheinhardt avcodec/ituh263enc: Move MPEG-4 fcode_tab to mpeg4videoenc.c Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=94f364289b893e660ea2a7e3259db882d54ac508 --- libavcodec/ituh263enc.c| 12 libavcodec/mpeg4videoenc.c | 11 +++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 1ef4a8f88e..2152046b43 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -52,11 +52,6 @@ */ static uint8_t mv_penalty[MAX_FCODE+1][MAX_DMV*2+1]; -/** - * Minimal fcode that a motion vector component would need. - */ -static uint8_t fcode_tab[MAX_MV*2+1]; - /** * Minimal fcode that a motion vector component would need in umv. * All entries in this table are 1. @@ -762,12 +757,6 @@ static av_cold void init_mv_penalty_and_fcode(void) } } -for(f_code=MAX_FCODE; f_code>0; f_code--){ -for(mv=-(16<1 only for MPEG-4 & H.263 & H.263+ FIXME switch(s->codec_id){ case AV_CODEC_ID_MPEG4: -s->fcode_tab= fcode_tab; break; case AV_CODEC_ID_H263P: if(s->umvplus) diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 0b31576dc5..64fb96a0cf 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -37,6 +37,11 @@ #include "profiles.h" #include "version.h" +/** + * Minimal fcode that a motion vector component would need. + */ +static uint8_t fcode_tab[MAX_MV*2+1]; + /* The uni_DCtab_* tables below contain unified bits+length tables to encode DC * differences in MPEG-4. Unified in the sense that the specification specifies * this encoding in several steps. */ @@ -1255,6 +1260,11 @@ static av_cold void mpeg4_encode_init_static(void) init_uni_mpeg4_rl_tab(&ff_mpeg4_rl_intra, uni_mpeg4_intra_rl_bits, uni_mpeg4_intra_rl_len); init_uni_mpeg4_rl_tab(&ff_h263_rl_inter, uni_mpeg4_inter_rl_bits, uni_mpeg4_inter_rl_len); + +for (int f_code = MAX_FCODE; f_code > 0; f_code--) { +for (int mv = -(16 << f_code); mv < (16 << f_code); mv++) +fcode_tab[mv + MAX_MV] = f_code; +} } static av_cold int encode_init(AVCodecContext *avctx) @@ -1274,6 +1284,7 @@ static av_cold int encode_init(AVCodecContext *avctx) ff_thread_once(&init_static_once, mpeg4_encode_init_static); +s->fcode_tab= fcode_tab; s->min_qcoeff = -2048; s->max_qcoeff = 2047; s->intra_ac_vlc_length = uni_mpeg4_intra_rl_len; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/h261dec: Don't call ff_set_qscale()
ffmpeg | branch: master | Andreas Rheinhardt | Sat Mar 1 21:32:51 2025 +0100| [7abc9c5e3d120ffa48d7312e0351cf7627bea9c8] | committer: Andreas Rheinhardt avcodec/h261dec: Don't call ff_set_qscale() Most of what it does is unneeded for H.261. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7abc9c5e3d120ffa48d7312e0351cf7627bea9c8 --- libavcodec/h261dec.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c index 8a2c4d35b4..c32ddd2ddf 100644 --- a/libavcodec/h261dec.c +++ b/libavcodec/h261dec.c @@ -155,6 +155,7 @@ static int h261_decode_gob_header(H261DecContext *h) av_log(s->avctx, AV_LOG_ERROR, "qscale has forbidden 0 value\n"); if (s->avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_COMPLIANT)) return -1; +s->qscale = 1; } /* For the first transmitted macroblock in a GOB, MBA is the absolute @@ -380,8 +381,11 @@ static int h261_decode_mb(H261DecContext *h) } // Read mquant -if (IS_QUANT(com->mtype)) -ff_set_qscale(s, get_bits(&s->gb, 5)); +if (IS_QUANT(com->mtype)) { +s->qscale = get_bits(&s->gb, 5); +if (!s->qscale) +s->qscale = 1; +} s->mb_intra = IS_INTRA4x4(com->mtype); @@ -511,8 +515,6 @@ static int h261_decode_gob(H261DecContext *h) { MpegEncContext *const s = &h->s; -ff_set_qscale(s, s->qscale); - /* decode mb's */ while (h->current_mba <= MBA_STUFFING) { int ret; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/ituh263enc: Use memset where appropriate
ffmpeg | branch: master | Andreas Rheinhardt | Mon Mar 3 22:45:57 2025 +0100| [9e5a1b8693e0bef2b8478f001b89fd19f873d56d] | committer: Andreas Rheinhardt avcodec/ituh263enc: Use memset where appropriate Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9e5a1b8693e0bef2b8478f001b89fd19f873d56d --- libavcodec/ituh263enc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 8313b2c2c1..2d750439d1 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -30,6 +30,7 @@ #include "config_components.h" #include +#include #include "libavutil/attributes.h" #include "libavutil/thread.h" @@ -93,8 +94,7 @@ static av_cold void init_mv_penalty_and_fcode(void) } } -for (int mv = 0; mv < MAX_MV * 2 + 1; mv++) -umv_fcode_tab[mv]= 1; +memset(umv_fcode_tab, 1, sizeof(umv_fcode_tab)); } static av_cold void init_uni_h263_rl_tab(const RLTable *rl, uint8_t *len_tab) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/ituh263dec: Reorder branches
ffmpeg | branch: master | Andreas Rheinhardt | Sun Mar 2 23:02:26 2025 +0100| [f5f2c37a52256589440a50dc43026b577acd6019] | committer: Andreas Rheinhardt avcodec/ituh263dec: Reorder branches (To perform this optimization a compiler would have to look at both ff_rv_decode_dc() and av_log(). The latter seems very unlikely.) Reviewed-by: Ramiro Polla Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f5f2c37a52256589440a50dc43026b577acd6019 --- libavcodec/ituh263dec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index e0f3034e57..9fee33da71 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -541,6 +541,8 @@ static int h263_decode_block(MpegEncContext * s, int16_t * block, scan_table = s->intra_scantable.permutated; if (s->h263_aic && s->mb_intra) { +if (!coded) +goto not_coded; rl = &ff_rl_intra_aic; i = 0; if (s->ac_pred) { @@ -587,8 +589,6 @@ static int h263_decode_block(MpegEncContext * s, int16_t * block, i = 0; } if (!coded) { -if (s->mb_intra && s->h263_aic) -goto not_coded; s->block_last_index[n] = i - 1; return 0; } @@ -669,8 +669,8 @@ retry: block[j] = level; } } -not_coded: if (s->mb_intra && s->h263_aic) { +not_coded: h263_pred_acdc(s, block, n); i = 63; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/ituh263enc: Remove redundant setting of dc_scale_tables
ffmpeg | branch: master | Andreas Rheinhardt | Mon Mar 3 20:32:59 2025 +0100| [f67e5bf2cca57fe0ae077efc55c65662efa1ee07] | committer: Andreas Rheinhardt avcodec/ituh263enc: Remove redundant setting of dc_scale_tables ff_mpeg1_dc_scale_table is already the default dc_scale table for both y and c. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f67e5bf2cca57fe0ae077efc55c65662efa1ee07 --- libavcodec/ituh263enc.c | 4 1 file changed, 4 deletions(-) diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 2152046b43..ba2a373571 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -36,7 +36,6 @@ #include "avcodec.h" #include "codec_internal.h" #include "mpegvideo.h" -#include "mpegvideodata.h" #include "flvenc.h" #include "mpegvideoenc.h" #include "h263.h" @@ -862,9 +861,6 @@ av_cold void ff_h263_encode_init(MpegEncContext *s) if(s->h263_aic){ s->y_dc_scale_table= s->c_dc_scale_table= ff_aic_dc_scale_table; -}else{ -s->y_dc_scale_table= -s->c_dc_scale_table= ff_mpeg1_dc_scale_table; } #if CONFIG_H263_ENCODER // Snow and SVQ1 call this ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpegvideo_enc: Move default_mv_penalty to h261enc.c
ffmpeg | branch: master | Andreas Rheinhardt | Mon Mar 3 20:53:33 2025 +0100| [9479ee50384a98573e25deb9d3ea922952977a9a] | committer: Andreas Rheinhardt avcodec/mpegvideo_enc: Move default_mv_penalty to h261enc.c MPEG-1/2 and the H.263-based encoders overwrite the default later and SpeedHQ and MJPEG-based encoders are intra-only and don't need a mv_penalty table at all. So only H.261 uses this table. Also add a comment to explain why it exists and is non-const. Reviewed-by: Ramiro Polla Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9479ee50384a98573e25deb9d3ea922952977a9a --- libavcodec/h261enc.c | 6 ++ libavcodec/mpegvideo_enc.c | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index dabab9d80a..5253e82129 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -46,6 +46,10 @@ static struct VLCLUT { uint16_t code; } vlc_lut[H261_MAX_RUN + 1][32 /* 0..2 * H261_MAX_LEN are used */]; +// Not const despite never being initialized because doing so would +// put it into .rodata instead of .bss and bloat the binary. +// mv_penalty exists so that the motion estimation code can avoid branches. +static uint8_t mv_penalty[MAX_FCODE + 1][MAX_DMV * 2 + 1]; static uint8_t uni_h261_rl_len [64 * 128]; static uint8_t uni_h261_rl_len_last[64 * 128]; static uint8_t h261_mv_codes[64][2]; @@ -370,6 +374,8 @@ av_cold int ff_h261_encode_init(MpegEncContext *s) s->max_qcoeff = 127; s->ac_esc_length= H261_ESC_LEN; +s->me.mv_penalty = mv_penalty; + s->intra_ac_vlc_length = s->inter_ac_vlc_length = uni_h261_rl_len; s->intra_ac_vlc_last_length = s->inter_ac_vlc_last_length = uni_h261_rl_len_last; ff_thread_once(&init_static_once, h261_encode_init_static); diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 8c22dbb5f5..1fe69f89a6 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -93,7 +93,6 @@ static int dct_quantize_c(MpegEncContext *s, int qscale, int *overflow); static int dct_quantize_trellis_c(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow); -static uint8_t default_mv_penalty[MAX_FCODE + 1][MAX_DMV * 2 + 1]; static uint8_t default_fcode_tab[MAX_MV * 2 + 1]; static const AVOption mpv_generic_options[] = { @@ -287,7 +286,6 @@ static void mpv_encode_defaults(MpegEncContext *s) ff_thread_once(&init_static_once, mpv_encode_init_static); -s->me.mv_penalty = default_mv_penalty; s->fcode_tab = default_fcode_tab; s->input_picture_number = 0; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpegutils: Move MAX_FCODE to mpegvideoenc.h
ffmpeg | branch: master | Andreas Rheinhardt | Mon Mar 3 21:01:31 2025 +0100| [3977abc89fa2e7c1be797bf03402eeb082e74085] | committer: Andreas Rheinhardt avcodec/mpegutils: Move MAX_FCODE to mpegvideoenc.h Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3977abc89fa2e7c1be797bf03402eeb082e74085 --- libavcodec/mpegutils.h| 1 - libavcodec/mpegvideoenc.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mpegutils.h b/libavcodec/mpegutils.h index e4ce26d299..9967762a79 100644 --- a/libavcodec/mpegutils.h +++ b/libavcodec/mpegutils.h @@ -33,7 +33,6 @@ #define PICT_FRAME 3 #define MAX_MB_BYTES(30 * 16 * 16 * 3 / 8 + 120) -#define MAX_FCODE7 /* MB types */ #define MB_TYPE_INTRA4x4 (1 << 0) diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index f5044a0309..2d7f76c57a 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -33,6 +33,7 @@ #include "libavutil/opt.h" #include "mpegvideo.h" +#define MAX_FCODE7 #define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level)) #define INPLACE_OFFSET 16 ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/ituh263enc: Combine branches
ffmpeg | branch: master | Andreas Rheinhardt | Mon Mar 3 21:15:30 2025 +0100| [9ca97756ace14dbbdd5d824b0731000a48cf9bea] | committer: Andreas Rheinhardt avcodec/ituh263enc: Combine branches Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9ca97756ace14dbbdd5d824b0731000a48cf9bea --- libavcodec/ituh263enc.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index ba2a373571..02da090ba4 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -826,6 +826,9 @@ av_cold void ff_h263_encode_init(MpegEncContext *s) if(s->h263_aic){ s->intra_ac_vlc_length = uni_h263_intra_aic_rl_len; s->intra_ac_vlc_last_length= uni_h263_intra_aic_rl_len + 128*64; + +s->y_dc_scale_table = +s->c_dc_scale_table = ff_aic_dc_scale_table; } s->ac_esc_length= 7+1+6+8; @@ -858,10 +861,6 @@ av_cold void ff_h263_encode_init(MpegEncContext *s) s->min_qcoeff= -127; s->max_qcoeff= 127; } -if(s->h263_aic){ - s->y_dc_scale_table= - s->c_dc_scale_table= ff_aic_dc_scale_table; -} #if CONFIG_H263_ENCODER // Snow and SVQ1 call this ff_h263dsp_init(&s->h263dsp); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpegvideo_enc: Move H.263 specific check to ituh263enc.c
ffmpeg | branch: master | Andreas Rheinhardt | Sat Mar 1 21:05:59 2025 +0100| [1ec1f1e236ba2cbb7538c692cd2a4cb7cf906dc7] | committer: Andreas Rheinhardt avcodec/mpegvideo_enc: Move H.263 specific check to ituh263enc.c Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1ec1f1e236ba2cbb7538c692cd2a4cb7cf906dc7 --- libavcodec/ituh263enc.c| 3 +++ libavcodec/mpegvideo_enc.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 2d750439d1..5beb857a6e 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -834,6 +834,9 @@ av_cold void ff_h263_encode_init(MpegEncContext *s) } s->ac_esc_length= 7+1+6+8; +if (s->modified_quant) +s->chroma_qscale_table = ff_h263_chroma_qscale_table; + // use fcodes >1 only for MPEG-4 & H.263 & H.263+ FIXME switch(s->codec_id){ case AV_CODEC_ID_MPEG4: diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index cbfea534d9..656d312d28 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -994,9 +994,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) s->dct_unquantize_inter = s->dct_unquantize_mpeg1_inter; } -if ((CONFIG_H263P_ENCODER || CONFIG_RV20_ENCODER) && s->modified_quant) -s->chroma_qscale_table = ff_h263_chroma_qscale_table; - if (s->slice_context_count > 1) { s->rtp_mode = 1; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpegvideo: Move temp ratecontrol bufs to RateControlContext
ffmpeg | branch: master | Andreas Rheinhardt | Sat Mar 1 00:04:43 2025 +0100| [89a8033fc918b2f0ef435e5a3077455ceb8ff913] | committer: Andreas Rheinhardt avcodec/mpegvideo: Move temp ratecontrol bufs to RateControlContext Also only allocate them when they are needed (namely iff adaptive quant is true) and allocate them jointly. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=89a8033fc918b2f0ef435e5a3077455ceb8ff913 --- libavcodec/mpegvideo.h | 3 --- libavcodec/mpegvideo_enc.c | 5 - libavcodec/ratecontrol.c | 19 +++ libavcodec/ratecontrol.h | 2 ++ 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 5fef008cc5..43d4bbfbcb 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -511,9 +511,6 @@ typedef struct MpegEncContext { int lmin, lmax; int vbv_ignore_qmax; -/* temp buffers for rate control */ -float *cplx_tab, *bits_tab; - /* flag to indicate a reinitialization is required, e.g. after * a frame size change */ int context_reinit; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 656d312d28..4e4b4c1ba9 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -945,8 +945,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) mb_array_size = s->mb_stride * s->mb_height; if (!FF_ALLOCZ_TYPED_ARRAY(s->mb_type, mb_array_size) || !FF_ALLOCZ_TYPED_ARRAY(s->lambda_table, mb_array_size) || -!FF_ALLOC_TYPED_ARRAY (s->cplx_tab, mb_array_size) || -!FF_ALLOC_TYPED_ARRAY (s->bits_tab, mb_array_size) || !FF_ALLOCZ_TYPED_ARRAY(s->mc_mb_var,mb_array_size) || !FF_ALLOCZ_TYPED_ARRAY(s->mb_var, mb_array_size) || !(s->mb_mean = av_mallocz(mb_array_size))) @@ -1075,9 +1073,6 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx) av_freep(&s->mb_type); av_freep(&s->lambda_table); -av_freep(&s->cplx_tab); -av_freep(&s->bits_tab); - av_freep(&s->q_intra_matrix); av_freep(&s->q_intra_matrix16); av_freep(&s->input_picture); diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index f383c433c4..08e8cadacd 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -694,6 +694,15 @@ av_cold int ff_rate_control_init(MpegEncContext *s) } } +if (s->adaptive_quant) { +unsigned mb_array_size = s->mb_stride * s->mb_height; + +rcc->cplx_tab = av_malloc_array(mb_array_size, 2 * sizeof(rcc->cplx_tab)); +if (!rcc->cplx_tab) +return AVERROR(ENOMEM); +rcc->bits_tab = rcc->cplx_tab + mb_array_size; +} + return 0; } @@ -705,6 +714,7 @@ av_cold void ff_rate_control_uninit(RateControlContext *rcc) av_expr_free(rcc->rc_eq_eval); rcc->rc_eq_eval = NULL; av_freep(&rcc->entry); +av_freep(&rcc->cplx_tab); } int ff_vbv_update(MpegEncContext *s, int frame_size) @@ -766,7 +776,8 @@ static void update_predictor(Predictor *p, double q, double var, double size) p->coeff += new_coeff; } -static void adaptive_quantization(MpegEncContext *s, double q) +static void adaptive_quantization(RateControlContext *const rcc, + MpegEncContext *const s, double q) { int i; const float lumi_masking = s->avctx->lumi_masking / (128.0 * 128.0); @@ -777,8 +788,8 @@ static void adaptive_quantization(MpegEncContext *s, double q) const float border_masking = s->border_masking; float bits_sum = 0.0; float cplx_sum = 0.0; -float *cplx_tab = s->cplx_tab; -float *bits_tab = s->bits_tab; +float *cplx_tab = rcc->cplx_tab; +float *bits_tab = rcc->bits_tab; const int qmin = s->avctx->mb_lmin; const int qmax = s->avctx->mb_lmax; const int mb_width = s->mb_width; @@ -1048,7 +1059,7 @@ float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run) q = qmax; if (s->adaptive_quant) -adaptive_quantization(s, q); +adaptive_quantization(rcc, s, q); else q = (int)(q + 0.5); diff --git a/libavcodec/ratecontrol.h b/libavcodec/ratecontrol.h index edeccbc6cd..b889491335 100644 --- a/libavcodec/ratecontrol.h +++ b/libavcodec/ratecontrol.h @@ -89,6 +89,8 @@ typedef struct RateControlContext{ char *rc_eq; struct AVExpr *rc_eq_eval; + +float *cplx_tab, *bits_tab; }RateControlContext; struct MpegEncContext; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpegvideo_enc: Move q_scale_type check to mpeg12enc.c
ffmpeg | branch: master | Andreas Rheinhardt | Fri Feb 28 00:05:28 2025 +0100| [137060d586ab69ed253dbeb13aff33e368172523] | committer: Andreas Rheinhardt avcodec/mpegvideo_enc: Move q_scale_type check to mpeg12enc.c The MPEG-2 encoder is the only encoder supporting q_scale_type. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=137060d586ab69ed253dbeb13aff33e368172523 --- libavcodec/mpeg12enc.c | 8 libavcodec/mpegvideo_enc.c | 8 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 52264ac6a0..90baf1ed95 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -201,6 +201,14 @@ static av_cold int encode_init(AVCodecContext *avctx) } } +if (mpeg12->mpeg.q_scale_type == 1) { +if (avctx->qmax > 28) { +av_log(avctx, AV_LOG_ERROR, + "non linear quant only supports qmax <= 28 currently\n"); +return AVERROR_PATCHWELCOME; +} +} + if (avctx->profile == AV_PROFILE_UNKNOWN) { if (avctx->level != AV_LEVEL_UNKNOWN) { av_log(avctx, AV_LOG_ERROR, "Set profile and level\n"); diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 5eea676dd4..da9247ec25 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -705,14 +705,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) } } -if (s->q_scale_type == 1) { -if (avctx->qmax > 28) { -av_log(avctx, AV_LOG_ERROR, - "non linear quant only supports qmax <= 28 currently\n"); -return AVERROR_PATCHWELCOME; -} -} - if (avctx->slices > 1 && !(avctx->codec->capabilities & AV_CODEC_CAP_SLICE_THREADS)) { av_log(avctx, AV_LOG_ERROR, "Multiple slices are not supported by this codec\n"); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpegvideo_enc: Move vbv_delay warning to mpeg12enc.c
ffmpeg | branch: master | Andreas Rheinhardt | Fri Feb 28 00:46:23 2025 +0100| [c3ab7362dd03fc06823eeb763d9e4976f83cf40c] | committer: Andreas Rheinhardt avcodec/mpegvideo_enc: Move vbv_delay warning to mpeg12enc.c It is MPEG-1/2 only. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c3ab7362dd03fc06823eeb763d9e4976f83cf40c --- libavcodec/mpeg12enc.c | 9 + libavcodec/mpegvideo_enc.c | 11 --- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 90baf1ed95..3f23045afc 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -255,6 +255,15 @@ static av_cold int encode_init(AVCodecContext *avctx) } } +if (avctx->rc_max_rate && +avctx->rc_min_rate == avctx->rc_max_rate && +9LL * (avctx->rc_buffer_size - 1) > +avctx->rc_max_rate * 0xLL) { +av_log(avctx, AV_LOG_INFO, + "Warning vbv_delay will be set to 0x (=VBR) as the " + "specified vbv buffer is too large for the given bitrate!\n"); +} + if (mpeg12->drop_frame_timecode) mpeg12->tc.flags |= AV_TIMECODE_FLAG_DROPFRAME; if (mpeg12->drop_frame_timecode && mpeg12->frame_rate_index != 4) { diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index da9247ec25..cbfea534d9 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -588,17 +588,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) avctx->bit_rate_tolerance = INT_MAX; } -if (avctx->rc_max_rate && -avctx->rc_min_rate == avctx->rc_max_rate && -(s->codec_id == AV_CODEC_ID_MPEG1VIDEO || - s->codec_id == AV_CODEC_ID_MPEG2VIDEO) && -9LL * (avctx->rc_buffer_size - 1) > -avctx->rc_max_rate * 0xLL) { -av_log(avctx, AV_LOG_INFO, - "Warning vbv_delay will be set to 0x (=VBR) as the " - "specified vbv buffer is too large for the given bitrate!\n"); -} - if ((avctx->flags & AV_CODEC_FLAG_4MV) && s->codec_id != AV_CODEC_ID_MPEG4 && s->codec_id != AV_CODEC_ID_H263 && s->codec_id != AV_CODEC_ID_H263P && s->codec_id != AV_CODEC_ID_FLV1) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpeg4videodec: Bail out earlier when parsing
ffmpeg | branch: master | Andreas Rheinhardt | Sun Mar 2 23:09:39 2025 +0100| [c050269edaca7e0b63b59cd214dc32f79b0eef1a] | committer: Andreas Rheinhardt avcodec/mpeg4videodec: Bail out earlier when parsing The scantables are unused for the parser (and in fact the IDCT permutation used has not been initialized at all). Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c050269edaca7e0b63b59cd214dc32f79b0eef1a --- libavcodec/mpeg4videodec.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index eace43b4cb..2a340ea682 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -3250,6 +3250,12 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb, } else s->alternate_scan = 0; } +/* Skip at this point when only parsing since the remaining + * data is not useful for a parser and requires the + * sprite_trajectory VLC to be initialized. */ +if (parse_only) +goto end; + if (s->alternate_scan) { ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_alternate_vertical_scan); ff_permute_scantable(s->permutated_intra_h_scantable, ff_alternate_vertical_scan, @@ -3262,12 +3268,6 @@ static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb, ff_permute_scantable(s->permutated_intra_v_scantable, ff_alternate_vertical_scan, s->idsp.idct_permutation); -/* Skip at this point when only parsing since the remaining - * data is not useful for a parser and requires the - * sprite_trajectory VLC to be initialized. */ -if (parse_only) -goto end; - if (s->pict_type == AV_PICTURE_TYPE_S) { if((ctx->vol_sprite_usage == STATIC_SPRITE || ctx->vol_sprite_usage == GMC_SPRITE)) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/ituh263enc: Make SVQ1+Snowenc stop calling ff_h263_encode_init()
ffmpeg | branch: master | Andreas Rheinhardt | Mon Mar 3 22:32:40 2025 +0100| [607bc17b52d24adb860b2f1d29f87a1a639f56d2] | committer: Andreas Rheinhardt avcodec/ituh263enc: Make SVQ1+Snowenc stop calling ff_h263_encode_init() They only do it for the mv_penalty table. Factor initializating the static tables out into a function of its own; also move everything not needed by SVQ1 or Snow behind #if CONFIG_H263_ENCODER (this involved moving ff_h263_encode_motion() which is used by svq1enc). Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=607bc17b52d24adb860b2f1d29f87a1a639f56d2 --- libavcodec/h263enc.h| 2 + libavcodec/ituh263enc.c | 247 libavcodec/snowenc.c| 2 +- libavcodec/svq1enc.c| 2 +- 4 files changed, 127 insertions(+), 126 deletions(-) diff --git a/libavcodec/h263enc.h b/libavcodec/h263enc.h index 784500ca7a..71e30931aa 100644 --- a/libavcodec/h263enc.h +++ b/libavcodec/h263enc.h @@ -24,6 +24,8 @@ #include "h263data.h" #include "mpegvideoenc.h" +const uint8_t (*ff_h263_get_mv_penalty(void))[MAX_DMV*2+1]; + void ff_h263_encode_init(MpegEncContext *s); void ff_h263_encode_picture_header(MpegEncContext *s); void ff_h263_encode_gob_header(MpegEncContext * s, int mb_line); diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 02da090ba4..8313b2c2c1 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -65,6 +65,127 @@ static uint8_t uni_h263_inter_rl_len [64*64*2*2]; //#define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128*64 + (run) + (level)*64) #define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128*64 + (run)*128 + (level)) +static av_cold void init_mv_penalty_and_fcode(void) +{ +for (int f_code = 1; f_code <= MAX_FCODE; f_code++) { +for (int mv = -MAX_DMV; mv <= MAX_DMV; mv++) { +int len; + +if (mv == 0) len = 1; // ff_mvtab[0][1] +else { +int val, bit_size, code; + +bit_size = f_code - 1; + +val = mv; +if (val < 0) +val = -val; +val--; +code = (val >> bit_size) + 1; +if (code < 33) { +len = ff_mvtab[code][1] + 1 + bit_size; +} else { +len = 12 /* ff_mvtab[32][1] */ + av_log2(code>>5) + 2 + bit_size; +} +} + +mv_penalty[f_code][mv + MAX_DMV] = len; +} +} + +for (int mv = 0; mv < MAX_MV * 2 + 1; mv++) +umv_fcode_tab[mv]= 1; +} + +static av_cold void init_uni_h263_rl_tab(const RLTable *rl, uint8_t *len_tab) +{ +av_assert0(MAX_LEVEL >= 64); +av_assert0(MAX_RUN >= 63); + +for (int slevel = -64; slevel < 64; slevel++) { +if (slevel == 0) continue; +for (int run = 0; run < 64; run++) { +for (int last = 0; last <= 1; last++) { +const int index = UNI_MPEG4_ENC_INDEX(last, run, slevel + 64); +int level = slevel < 0 ? -slevel : slevel; +int sign = slevel < 0 ? 1 : 0; +int bits, len, code; + +len_tab[index] = 100; + +/* ESC0 */ +code = get_rl_index(rl, last, run, level); +bits = rl->table_vlc[code][0]; +len = rl->table_vlc[code][1]; +bits = bits * 2 + sign; +len++; + +if (code != rl->n && len < len_tab[index]) +len_tab[index] = len; + +/* ESC */ +bits = rl->table_vlc[rl->n][0]; +len = rl->table_vlc[rl->n][1]; +bits = bits * 2 + last; len++; +bits = bits * 64 + run; len += 6; +bits = bits * 256 + (level & 0xff); len += 8; + +if (len < len_tab[index]) +len_tab[index] = len; +} +} +} +} + +static av_cold void h263_encode_init_static(void) +{ +static uint8_t rl_intra_table[2][2 * MAX_RUN + MAX_LEVEL + 3]; + +ff_rl_init(&ff_rl_intra_aic, rl_intra_table); +ff_h263_init_rl_inter(); + +init_uni_h263_rl_tab(&ff_rl_intra_aic, uni_h263_intra_aic_rl_len); +init_uni_h263_rl_tab(&ff_h263_rl_inter, uni_h263_inter_rl_len); + +init_mv_penalty_and_fcode(); +} + +av_cold const uint8_t (*ff_h263_get_mv_penalty(void))[MAX_DMV*2+1] +{ +static AVOnce init_static_once = AV_ONCE_INIT; + +ff_thread_once(&init_static_once, h263_encode_init_static); + +return mv_penalty; +} + +void ff_h263_encode_motion(PutBitContext *pb, int val, int f_code) +{ +if (val == 0) { +/* zero vector -- corresponds to ff_mvtab[0] */ +put_bits(pb, 1, 1); +} else { +int sign, code, bits; +int bit_size = f_code - 1; +int range = 1 << bit_size; +/* modulo encoding */ +val = sign_extend(val, 6 +
[FFmpeg-cvslog] avcodec/mpegvideo: Mark ff_mpv_common_defaults() as av_cold
ffmpeg | branch: master | Andreas Rheinhardt | Mon Mar 3 17:39:16 2025 +0100| [e117faddbf5ecd2226bfced49af0bf2425028e53] | committer: Andreas Rheinhardt avcodec/mpegvideo: Mark ff_mpv_common_defaults() as av_cold Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e117faddbf5ecd2226bfced49af0bf2425028e53 --- libavcodec/mpegvideo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 73c513acbd..f114dd8c0c 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -480,7 +480,7 @@ int ff_update_duplicate_context(MpegEncContext *dst, const MpegEncContext *src) * The changed fields will not depend upon the * prior state of the MpegEncContext. */ -void ff_mpv_common_defaults(MpegEncContext *s) +av_cold void ff_mpv_common_defaults(MpegEncContext *s) { s->y_dc_scale_table = s->c_dc_scale_table = ff_mpeg1_dc_scale_table; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpegvideo_enc: Move q_matrix init to init_matrices()
ffmpeg | branch: master | Andreas Rheinhardt | Thu Feb 27 22:56:59 2025 +0100| [0c4b091bd6bbb8ea44ff8a002cb02e20b3ee809d] | committer: Andreas Rheinhardt avcodec/mpegvideo_enc: Move q_matrix init to init_matrices() Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0c4b091bd6bbb8ea44ff8a002cb02e20b3ee809d --- libavcodec/mpegvideo_enc.c | 30 ++ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 81e004d1a8..5eea676dd4 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -353,6 +353,7 @@ static av_cold int init_matrices(MpegEncContext *s, AVCodecContext *avctx) { const int nb_matrices = 1 + (s->out_format == FMT_MJPEG) + !s->intra_only; const uint16_t *intra_matrix, *inter_matrix; +int ret; if (!ALLOCZ_ARRAYS(s->q_intra_matrix, 32, nb_matrices) || !ALLOCZ_ARRAYS(s->q_intra_matrix16, 32, nb_matrices)) @@ -399,6 +400,19 @@ static av_cold int init_matrices(MpegEncContext *s, AVCodecContext *avctx) s->inter_matrix[j] = inter_matrix[i]; } +/* precompute matrix */ +ret = ff_check_codec_matrices(avctx, FF_MATRIX_TYPE_INTRA | FF_MATRIX_TYPE_INTER, 1, 255); +if (ret < 0) +return ret; + +ff_convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16, + s->intra_matrix, s->intra_quant_bias, avctx->qmin, + 31, 1); +if (s->q_inter_matrix) +ff_convert_matrix(s, s->q_inter_matrix, s->q_inter_matrix16, + s->inter_matrix, s->inter_quant_bias, avctx->qmin, + 31, 0); + return 0; } @@ -1017,22 +1031,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) #endif } -/* precompute matrix */ -/* for mjpeg, we do include qscale in the matrix */ -if (s->out_format != FMT_MJPEG) { -ret = ff_check_codec_matrices(avctx, FF_MATRIX_TYPE_INTRA | FF_MATRIX_TYPE_INTER, 1, 255); -if (ret < 0) -return ret; - -ff_convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16, - s->intra_matrix, s->intra_quant_bias, avctx->qmin, - 31, 1); -if (s->q_inter_matrix) -ff_convert_matrix(s, s->q_inter_matrix, s->q_inter_matrix16, - s->inter_matrix, s->inter_quant_bias, avctx->qmin, - 31, 0); -} - if ((ret = ff_rate_control_init(s)) < 0) return ret; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/vc1dec: Don't initialize unused parts of ScanTable
ffmpeg | branch: master | Andreas Rheinhardt | Mon Mar 3 03:36:57 2025 +0100| [094c2e7f5b4bb42a45fe5909446ec179b2aaa568] | committer: Andreas Rheinhardt avcodec/vc1dec: Don't initialize unused parts of ScanTable The VC-1 decoders don't need ScanTable.raster_end as they don't call any of the unquantize functions. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=094c2e7f5b4bb42a45fe5909446ec179b2aaa568 --- libavcodec/vc1dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 7256ad9557..d92a7da8ab 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -471,8 +471,8 @@ av_cold int ff_vc1_decode_init(AVCodecContext *avctx) if (ret < 0) return ret; -ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, - ff_wmv1_scantable[1]); +ff_permute_scantable(s->intra_scantable.permutated, ff_wmv1_scantable[1], + s->idsp.idct_permutation); ret = vc1_decode_init_alloc_tables(v); if (ret < 0) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/mpeg12enc: Simplify writing bits
ffmpeg | branch: master | Andreas Rheinhardt | Mon Mar 3 18:42:13 2025 +0100| [6e225123d8583fdce55037b85eaef5453f201959] | committer: Andreas Rheinhardt avcodec/mpeg12enc: Simplify writing bits Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6e225123d8583fdce55037b85eaef5453f201959 --- libavcodec/mpeg12enc.c | 16 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 3f23045afc..ca51430fce 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -594,10 +594,8 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s) if (fpa_type != 0) { put_header(s, USER_START_CODE); -put_bits(&s->pb, 8, 'J'); // S3D_video_format_signaling_identifier -put_bits(&s->pb, 8, 'P'); -put_bits(&s->pb, 8, '3'); -put_bits(&s->pb, 8, 'D'); +// S3D_video_format_signaling_identifier +put_bits32(&s->pb, MKBETAG('J','P','3','D')); put_bits(&s->pb, 8, 0x03); // S3D_video_format_length put_bits(&s->pb, 1, 1); // reserved_bit @@ -612,21 +610,15 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s) AV_FRAME_DATA_A53_CC); if (side_data) { if (side_data->size <= A53_MAX_CC_COUNT * 3 && side_data->size % 3 == 0) { -int i = 0; - put_header (s, USER_START_CODE); -put_bits(&s->pb, 8, 'G'); // user_identifier -put_bits(&s->pb, 8, 'A'); -put_bits(&s->pb, 8, '9'); -put_bits(&s->pb, 8, '4'); +put_bits32(&s->pb, MKBETAG('G','A','9','4')); // user_identifier put_bits(&s->pb, 8, 3); // user_data_type_code put_bits(&s->pb, 8, (side_data->size / 3 & A53_MAX_CC_COUNT) | 0x40); // flags, cc_count put_bits(&s->pb, 8, 0xff); // em_data -for (i = 0; i < side_data->size; i++) -put_bits(&s->pb, 8, side_data->data[i]); +ff_copy_bits(&s->pb, side_data->data, side_data->size); put_bits(&s->pb, 8, 0xff); // marker_bits } else { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec: Don't log to private context
ffmpeg | branch: master | Andreas Rheinhardt | Wed Mar 5 01:27:29 2025 +0100| [39286d97f259a9b9666520ff1f9bdff6561f7e3c] | committer: Andreas Rheinhardt avcodec: Don't log to private context While it is save for these codecs (they all have private contexts), it is customary to always use the AVCodecContext for logging. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=39286d97f259a9b9666520ff1f9bdff6561f7e3c --- libavcodec/ccaption_dec.c | 21 - libavcodec/dvdsubdec.c | 34 +- libavcodec/h264_refs.c | 2 +- libavcodec/h264_slice.c| 2 +- libavcodec/j2kenc.c| 2 +- libavcodec/motion_est.c| 4 ++-- libavcodec/mpegvideo_enc.c | 2 +- libavcodec/msmpeg4enc.c| 2 +- libavcodec/ratecontrol.c | 12 ++-- libavcodec/x86/mpegvideoenc_template.c | 2 +- 10 files changed, 43 insertions(+), 40 deletions(-) diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c index d8b992bb94..01bdc4d537 100644 --- a/libavcodec/ccaption_dec.c +++ b/libavcodec/ccaption_dec.c @@ -253,6 +253,7 @@ struct Screen { typedef struct CCaptionSubContext { AVClass *class; +void *logctx; int real_time; int real_time_latency_msec; int data_field; @@ -280,6 +281,8 @@ static av_cold int init_decoder(AVCodecContext *avctx) { CCaptionSubContext *ctx = avctx->priv_data; +ctx->logctx = avctx; + av_bprint_init(&ctx->buffer[0], 0, AV_BPRINT_SIZE_UNLIMITED); av_bprint_init(&ctx->buffer[1], 0, AV_BPRINT_SIZE_UNLIMITED); /* taking by default roll up to 2 */ @@ -359,7 +362,7 @@ static void write_char(CCaptionSubContext *ctx, struct Screen *screen, char ch) return; } else { -av_log(ctx, AV_LOG_WARNING, "Data ignored due to columns exceeding screen width\n"); +av_log(ctx->logctx, AV_LOG_WARNING, "Data ignored due to columns exceeding screen width\n"); return; } } @@ -649,7 +652,7 @@ static void handle_pac(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo) int indent, i; if (row_map[index] <= 0) { -av_log(ctx, AV_LOG_DEBUG, "Invalid pac index encountered\n"); +av_log(ctx->logctx, AV_LOG_DEBUG, "Invalid pac index encountered\n"); return; } @@ -749,9 +752,9 @@ static void handle_char(CCaptionSubContext *ctx, char hi, char lo) ctx->screen_touched = 1; if (lo) - ff_dlog(ctx, "(%c,%c)\n", hi, lo); + ff_dlog(ctx->logctx, "(%c,%c)\n", hi, lo); else - ff_dlog(ctx, "(%c)\n", hi); + ff_dlog(ctx->logctx, "(%c)\n", hi); } static int process_cc608(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo) @@ -803,7 +806,7 @@ static int process_cc608(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo) break; case 0x2d: /* carriage return */ -ff_dlog(ctx, "carriage return\n"); +ff_dlog(ctx->logctx, "carriage return\n"); if (!ctx->real_time) ret = capture_screen(ctx); roll_up(ctx); @@ -820,11 +823,11 @@ static int process_cc608(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo) break; case 0x2f: /* end of caption */ -ff_dlog(ctx, "handle_eoc\n"); +ff_dlog(ctx->logctx, "handle_eoc\n"); ret = handle_eoc(ctx); break; default: -ff_dlog(ctx, "Unknown command 0x%hhx 0x%hhx\n", hi, lo); +ff_dlog(ctx->logctx, "Unknown command 0x%hhx 0x%hhx\n", hi, lo); break; } } else if (hi >= 0x11 && hi <= 0x13) { @@ -842,7 +845,7 @@ static int process_cc608(CCaptionSubContext *ctx, uint8_t hi, uint8_t lo) } } else { /* Ignoring all other non data code */ -ff_dlog(ctx, "Unknown command 0x%hhx 0x%hhx\n", hi, lo); +ff_dlog(ctx->logctx, "Unknown command 0x%hhx 0x%hhx\n", hi, lo); } return ret; @@ -888,7 +891,7 @@ static int decode(AVCodecContext *avctx, AVSubtitle *sub, update_time(ctx, in_time); if (ctx->buffer[bidx].str[0] || ctx->real_time) { -ff_dlog(ctx, "cdp writing data (%s)\n", ctx->buffer[bidx].str); +ff_dlog(avctx, "cdp writing data (%s)\n", ctx->buffer[bidx].str); start_time = ctx->buffer_time[0]; sub->pts = start_time; end_time = ctx->buffer_time[1]; diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index f8769353a0..78658f7d2f 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -217,8 +217,8 @@ static void reset_rects(AVSubtitle *sub_header) #define READ_OFFSET(a) (big_offsets ? AV_RB32(a) : AV_RB16(a)) -static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header, -const uint8_t *buf, in
[FFmpeg-cvslog] avcodec/{h263,ituh263,msmpeg4,snow}dec: Use proper logcontext
ffmpeg | branch: master | Andreas Rheinhardt | Wed Mar 5 00:50:49 2025 +0100| [e6d07e45e0dc878889e5452db12f32859a128d22] | committer: Andreas Rheinhardt avcodec/{h263,ituh263,msmpeg4,snow}dec: Use proper logcontext The logging functions here can be reached by codecs without private class, so that the log callback will receive a non-NULL object whose AVClass pointer is NULL. Although the default log callback handles this gracefully, it is probably an API violation. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e6d07e45e0dc878889e5452db12f32859a128d22 --- libavcodec/h263dec.c| 2 +- libavcodec/ituh263dec.c | 2 +- libavcodec/msmpeg4dec.c | 6 +++--- libavcodec/snowdec.c| 6 -- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index 9ccdd914ce..982a56ae05 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -242,7 +242,7 @@ static int decode_slice(MpegEncContext *s) s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; -ff_dlog(s, "%d %06X\n", +ff_dlog(s->avctx, "%d %06X\n", get_bits_count(&s->gb), show_bits(&s->gb, 24)); ff_tlog(NULL, "Decoding MB at %dx%d\n", s->mb_x, s->mb_y); diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 9fee33da71..d451a35da8 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -1264,7 +1264,7 @@ int ff_h263_decode_picture_header(MpegEncContext *s) s->avctx->framerate.den = 1000 + get_bits1(&s->gb); s->avctx->framerate.den *= get_bits(&s->gb, 7); if(s->avctx->framerate.den == 0){ -av_log(s, AV_LOG_ERROR, "zero framerate\n"); +av_log(s->avctx, AV_LOG_ERROR, "zero framerate\n"); return -1; } gcd= av_gcd(s->avctx->framerate.den, s->avctx->framerate.num); diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c index d42219f464..0604dc8963 100644 --- a/libavcodec/msmpeg4dec.c +++ b/libavcodec/msmpeg4dec.c @@ -77,7 +77,7 @@ static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code) int code, val, sign, shift; code = get_vlc2(&s->gb, ff_h263_mv_vlc, H263_MV_VLC_BITS, 2); -ff_dlog(s, "MV code %d at %d %d pred: %d\n", code, s->mb_x,s->mb_y, pred); +ff_dlog(s->avctx, "MV code %d at %d %d pred: %d\n", code, s->mb_x,s->mb_y, pred); if (code < 0) return 0x; @@ -267,14 +267,14 @@ static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64]) s->mv[0][0][1] = my; *mb_type_ptr = MB_TYPE_FORWARD_MV | MB_TYPE_16x16; } else { -ff_dlog(s, "I at %d %d %d %06X\n", s->mb_x, s->mb_y, +ff_dlog(s->avctx, "I at %d %d %d %06X\n", s->mb_x, s->mb_y, ((cbp & 3) ? 1 : 0) +((cbp & 0x3C)? 2 : 0), show_bits(&s->gb, 24)); s->ac_pred = get_bits1(&s->gb); *mb_type_ptr = MB_TYPE_INTRA; if(s->inter_intra_pred){ s->h263_aic_dir= get_vlc2(&s->gb, ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 1); -ff_dlog(s, "%d%d %d %d/", +ff_dlog(s->avctx, "%d%d %d %d/", s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y); } if(s->per_mb_rl_table && cbp){ diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c index 50dcaf8b93..d99da8a4f3 100644 --- a/libavcodec/snowdec.c +++ b/libavcodec/snowdec.c @@ -481,14 +481,16 @@ static int decode_header(SnowContext *s){ }else if(s->chroma_h_shift == 2 && s->chroma_v_shift==2){ s->avctx->pix_fmt= AV_PIX_FMT_YUV410P; } else { -av_log(s, AV_LOG_ERROR, "unsupported color subsample mode %d %d\n", s->chroma_h_shift, s->chroma_v_shift); +av_log(s->avctx, AV_LOG_ERROR, + "unsupported color subsample mode %d %d\n", + s->chroma_h_shift, s->chroma_v_shift); s->chroma_h_shift = s->chroma_v_shift = 1; s->avctx->pix_fmt= AV_PIX_FMT_YUV420P; return AVERROR_INVALIDDATA; } s->nb_planes = 3; } else { -av_log(s, AV_LOG_ERROR, "unsupported color space\n"); +av_log(s->avctx, AV_LOG_ERROR, "unsupported color space\n"); s->chroma_h_shift = s->chroma_v_shift = 1; s->avctx->pix_fmt= AV_PIX_FMT_YUV420P; return AVERROR_INVALIDDATA; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avutil/log: Set AVClass* in av_expr_eval()
ffmpeg | branch: master | Andreas Rheinhardt | Wed Mar 5 03:14:16 2025 +0100| [f641c6846ac419284ae73948b617a250b1a3c22d] | committer: Andreas Rheinhardt avutil/log: Set AVClass* in av_expr_eval() Otherwise it is possible for av_log() to receive a non-NULL object with a NULL AVClass pointer; the default log callback handles it gracefully, yet this is probably an API violation. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f641c6846ac419284ae73948b617a250b1a3c22d --- libavutil/eval.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libavutil/eval.c b/libavutil/eval.c index 298925a6e5..7fa5d5d9d5 100644 --- a/libavutil/eval.c +++ b/libavutil/eval.c @@ -791,12 +791,14 @@ int av_expr_count_func(AVExpr *e, unsigned *counter, int size, int arg) double av_expr_eval(AVExpr *e, const double *const_values, void *opaque) { -Parser p = { 0 }; -p.var= e->var; -p.prng_state= e->prng_state; +Parser p = { +.class= &eval_class, +.const_values = const_values, +.opaque = opaque, +.var = e->var, +.prng_state = e->prng_state, +}; -p.const_values = const_values; -p.opaque = opaque; return eval_expr(&p, e); } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".