History

avcodec/mpegvideo: Move fcode_tab to MPVMainEncContext

Only used by the main encoding thread.

Andreas Rheinhardt committed 4 years ago

Commit 7751b0c1 parent ecba5838 files · +23 −18Browse files

Showing the changes to libavcodec (8 of 8 files). Show all

Unified · Split

8 files
  1. libavcodec/ituh263enc.c +1 −1
  2. libavcodec/motion_est.c +4 −2
  3. libavcodec/motion_est.h +2 −1
  4. libavcodec/mpeg12enc.c +1 −1
  5. libavcodec/mpeg4videoenc.c +1 −1
  6. libavcodec/mpegvideo.h +0 −1
  7. libavcodec/mpegvideo_enc.c +12 −11
  8. libavcodec/mpegvideoenc.h +2 −0
libavcodec/ituh263enc.c+1−1
@@ -848,7 +848,7 @@ av_cold void ff_h263_encode_init(MPVMainEncContext *const m) · 847 unmodified lines
848848 break;
849849 case AV_CODEC_ID_H263P:
850850 if(s->umvplus)
851− s->fcode_tab = umv_fcode_tab + MAX_MV;
851+ m->fcode_tab = umv_fcode_tab + MAX_MV;
852852 if(s->modified_quant){
853853 s->min_qcoeff= -2047;
854854 s->max_qcoeff= 2047;
libavcodec/motion_est.c+4−2
@@ -1596,12 +1596,14 @@ void ff_estimate_b_frame_motion(MpegEncContext * s, · 1595 unmodified lines
15961596 }
15971597
15981598 /* find best f_code for ME which do unlimited searches */
1599−int ff_get_best_fcode(MpegEncContext * s, const int16_t (*mv_table)[2], int type)
1599+int ff_get_best_fcode(MPVMainEncContext *const m, const int16_t (*mv_table)[2], int type)
16001600 {
1601+ MpegEncContext *const s = &m->s;
1602+
16011603 if (s->motion_est != FF_ME_ZERO) {
16021604 int score[8];
16031605 int i, y, range= s->avctx->me_range ? s->avctx->me_range : (INT_MAX/2);
1604− const uint8_t * fcode_tab = s->fcode_tab;
1606+ const uint8_t * fcode_tab = m->fcode_tab;
16051607 int best_fcode=-1;
16061608 int best_score=-10000000;
16071609
libavcodec/motion_est.h+2−1
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 #include "qpeldsp.h"
3030
3131 struct MpegEncContext;
32+typedef struct MPVMainEncContext MPVMainEncContext;
3233
3334 #if ARCH_IA64 // Limit static arrays to avoid gcc failing "short data segment overflowed"
3435 #define MAX_MV 1024
@@ -136,7 +137,7 @@ int ff_epzs_motion_search(struct MpegEncContext *s, int *mx_ptr, int *my_ptr, · 101 unmodified lines
136137 int ff_get_mb_score(struct MpegEncContext *s, int mx, int my, int src_index,
137138 int ref_index, int size, int h, int add_rate);
138139
139−int ff_get_best_fcode(struct MpegEncContext *s,
140+int ff_get_best_fcode(MPVMainEncContext *m,
140141 const int16_t (*mv_table)[2], int type);
141142
142143 void ff_fix_long_p_mvs(struct MpegEncContext *s, int type);
libavcodec/mpeg12enc.c+1−1
@@ -1113,7 +1113,7 @@ static av_cold int encode_init(AVCodecContext *avctx) · 1112 unmodified lines
11131113 m->encode_picture_header = mpeg1_encode_picture_header;
11141114
11151115 s->me.mv_penalty = mv_penalty;
1116− s->fcode_tab = fcode_tab + MAX_MV;
1116+ m->fcode_tab = fcode_tab + MAX_MV;
11171117 if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
11181118 s->min_qcoeff = -255;
11191119 s->max_qcoeff = 255;
libavcodec/mpeg4videoenc.c+1−1
@@ -1319,7 +1319,7 @@ static av_cold int encode_init(AVCodecContext *avctx) · 1318 unmodified lines
13191319
13201320 m4->time_increment_bits = av_log2(avctx->time_base.den - 1) + 1;
13211321
1322− s->fcode_tab = fcode_tab + MAX_MV;
1322+ m->fcode_tab = fcode_tab + MAX_MV;
13231323
13241324 s->min_qcoeff = -2048;
13251325 s->max_qcoeff = 2047;
libavcodec/mpegvideo.h+0−1
@@ -253,7 +253,6 @@ typedef struct MpegEncContext { · 252 unmodified lines
253253 int mv[2][4][2];
254254 int field_select[2][2];
255255 int last_mv[2][2][2]; ///< last MV, used for MV prediction in MPEG-1 & B-frame MPEG-4
256− const uint8_t *fcode_tab; ///< smallest fcode needed for each MV
257256 int16_t direct_scale_mv[2][64]; ///< precomputed to avoid divisions in ff_mpeg4_set_direct_mv
258257
259258 MotionEstContext me;
libavcodec/mpegvideo_enc.c+12−11
@@ -278,14 +278,15 @@ static av_cold void mpv_encode_init_static(void) · 277 unmodified lines
278278 /**
279279 * Set the given MpegEncContext to defaults for encoding.
280280 */
281−static av_cold void mpv_encode_defaults(MpegEncContext *s)
281+static av_cold void mpv_encode_defaults(MPVMainEncContext *const m)
282282 {
283+ MpegEncContext *const s = &m->s;
283284 static AVOnce init_static_once = AV_ONCE_INIT;
284285
285286 ff_mpv_common_defaults(s);
286287
287− if (!s->fcode_tab) {
288− s->fcode_tab = default_fcode_tab + MAX_MV;
288+ if (!m->fcode_tab) {
289+ m->fcode_tab = default_fcode_tab + MAX_MV;
289290 ff_thread_once(&init_static_once, mpv_encode_init_static);
290291 }
291292 if (!s->y_dc_scale_table) {
@@ -429,7 +430,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 137 unmodified lines
429430 int i, ret;
430431 int mb_array_size, mv_table_size;
431432
432− mpv_encode_defaults(s);
433+ mpv_encode_defaults(m);
433434
434435 switch (avctx->pix_fmt) {
435436 case AV_PIX_FMT_YUVJ444P:
@@ -3774,12 +3775,12 @@ static int encode_picture(MPVMainEncContext *const m, const AVPacket *pkt) · 3338 unmodified lines
37743775
37753776 if(!s->umvplus){
37763777 if(s->pict_type==AV_PICTURE_TYPE_P || s->pict_type==AV_PICTURE_TYPE_S) {
3777− s->f_code= ff_get_best_fcode(s, s->p_mv_table, CANDIDATE_MB_TYPE_INTER);
3778+ s->f_code = ff_get_best_fcode(m, s->p_mv_table, CANDIDATE_MB_TYPE_INTER);
37783779
37793780 if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME) {
37803781 int a,b;
3781− a= ff_get_best_fcode(s, s->p_field_mv_table[0][0], CANDIDATE_MB_TYPE_INTER_I); //FIXME field_select
3782− b= ff_get_best_fcode(s, s->p_field_mv_table[1][1], CANDIDATE_MB_TYPE_INTER_I);
3782+ a = ff_get_best_fcode(m, s->p_field_mv_table[0][0], CANDIDATE_MB_TYPE_INTER_I); //FIXME field_select
3783+ b = ff_get_best_fcode(m, s->p_field_mv_table[1][1], CANDIDATE_MB_TYPE_INTER_I);
37833784 s->f_code= FFMAX3(s->f_code, a, b);
37843785 }
37853786
@@ -3796,12 +3797,12 @@ static int encode_picture(MPVMainEncContext *const m, const AVPacket *pkt) · 10 unmodified lines
37963797 } else if (s->pict_type == AV_PICTURE_TYPE_B) {
37973798 int a, b;
37983799
3799− a = ff_get_best_fcode(s, s->b_forw_mv_table, CANDIDATE_MB_TYPE_FORWARD);
3800− b = ff_get_best_fcode(s, s->b_bidir_forw_mv_table, CANDIDATE_MB_TYPE_BIDIR);
3800+ a = ff_get_best_fcode(m, s->b_forw_mv_table, CANDIDATE_MB_TYPE_FORWARD);
3801+ b = ff_get_best_fcode(m, s->b_bidir_forw_mv_table, CANDIDATE_MB_TYPE_BIDIR);
38013802 s->f_code = FFMAX(a, b);
38023803
3803− a = ff_get_best_fcode(s, s->b_back_mv_table, CANDIDATE_MB_TYPE_BACKWARD);
3804− b = ff_get_best_fcode(s, s->b_bidir_back_mv_table, CANDIDATE_MB_TYPE_BIDIR);
3804+ a = ff_get_best_fcode(m, s->b_back_mv_table, CANDIDATE_MB_TYPE_BACKWARD);
3805+ b = ff_get_best_fcode(m, s->b_bidir_back_mv_table, CANDIDATE_MB_TYPE_BIDIR);
38053806 s->b_code = FFMAX(a, b);
38063807
38073808 ff_fix_long_mvs(s, NULL, 0, s->b_forw_mv_table, s->f_code, CANDIDATE_MB_TYPE_FORWARD, 1);
libavcodec/mpegvideoenc.h+2−0
@@ -67,6 +67,8 @@ typedef struct MPVMainEncContext { · 66 unmodified lines
6767 int lmin, lmax;
6868 int vbv_ignore_qmax;
6969
70+ const uint8_t *fcode_tab; ///< smallest fcode needed for each MV
71+
7072 /* frame skip options */
7173 int frame_skip_threshold;
7274 int frame_skip_factor;

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