History

avcodec/mpegvideo_enc: Move q_matrix init to init_matrices()

Andreas Rheinhardt committed 1 year ago

Commit 0c4b0911 parent 726adfa1 file · +14 −16Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/mpegvideo_enc.c+14−16
@@ -353,6 +353,7 @@ static av_cold int init_matrices(MpegEncContext *s, AVCodecContext *avctx) · 352 unmodified lines
353353 {
354354 const int nb_matrices = 1 + (s->out_format == FMT_MJPEG) + !s->intra_only;
355355 const uint16_t *intra_matrix, *inter_matrix;
356+ int ret;
356357
357358 if (!ALLOCZ_ARRAYS(s->q_intra_matrix, 32, nb_matrices) ||
358359 !ALLOCZ_ARRAYS(s->q_intra_matrix16, 32, nb_matrices))
@@ -399,6 +400,19 @@ static av_cold int init_matrices(MpegEncContext *s, AVCodecContext *avctx) · 40 unmodified lines
399400 s->inter_matrix[j] = inter_matrix[i];
400401 }
401402
403+ /* precompute matrix */
404+ ret = ff_check_codec_matrices(avctx, FF_MATRIX_TYPE_INTRA | FF_MATRIX_TYPE_INTER, 1, 255);
405+ if (ret < 0)
406+ return ret;
407+
408+ ff_convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16,
409+ s->intra_matrix, s->intra_quant_bias, avctx->qmin,
410+ 31, 1);
411+ if (s->q_inter_matrix)
412+ ff_convert_matrix(s, s->q_inter_matrix, s->q_inter_matrix16,
413+ s->inter_matrix, s->inter_quant_bias, avctx->qmin,
414+ 31, 0);
415+
402416 return 0;
403417 }
404418
@@ -1017,22 +1031,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 612 unmodified lines
10171031 #endif
10181032 }
10191033
1020− /* precompute matrix */
1021− /* for mjpeg, we do include qscale in the matrix */
1022− if (s->out_format != FMT_MJPEG) {
1023− ret = ff_check_codec_matrices(avctx, FF_MATRIX_TYPE_INTRA | FF_MATRIX_TYPE_INTER, 1, 255);
1024− if (ret < 0)
1025− return ret;
1026−
1027− ff_convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16,
1028− s->intra_matrix, s->intra_quant_bias, avctx->qmin,
1029− 31, 1);
1030− if (s->q_inter_matrix)
1031− ff_convert_matrix(s, s->q_inter_matrix, s->q_inter_matrix16,
1032− s->inter_matrix, s->inter_quant_bias, avctx->qmin,
1033− 31, 0);
1034− }
1035−
10361034 if ((ret = ff_rate_control_init(s)) < 0)
10371035 return ret;
10381036

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t