Only used by the main encoding thread.
Unified · Split
| @@ -848,7 +848,7 @@ av_cold void ff_h263_encode_init(MPVMainEncContext *const m) · 847 unmodified lines | ||
| 848 | 848 | break; |
| 849 | 849 | case AV_CODEC_ID_H263P: |
| 850 | 850 | if(s->umvplus) |
| 851 | − s->fcode_tab = umv_fcode_tab + MAX_MV; | |
| 851 | + m->fcode_tab = umv_fcode_tab + MAX_MV; | |
| 852 | 852 | if(s->modified_quant){ |
| 853 | 853 | s->min_qcoeff= -2047; |
| 854 | 854 | s->max_qcoeff= 2047; |
| @@ -1596,12 +1596,14 @@ void ff_estimate_b_frame_motion(MpegEncContext * s, · 1595 unmodified lines | ||
| 1596 | 1596 | } |
| 1597 | 1597 | |
| 1598 | 1598 | /* 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) | |
| 1600 | 1600 | { |
| 1601 | + MpegEncContext *const s = &m->s; | |
| 1602 | + | |
| 1601 | 1603 | if (s->motion_est != FF_ME_ZERO) { |
| 1602 | 1604 | int score[8]; |
| 1603 | 1605 | 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; | |
| 1605 | 1607 | int best_fcode=-1; |
| 1606 | 1608 | int best_score=-10000000; |
| 1607 | 1609 | |
| @@ -29,6 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | #include "qpeldsp.h" |
| 30 | 30 | |
| 31 | 31 | struct MpegEncContext; |
| 32 | +typedef struct MPVMainEncContext MPVMainEncContext; | |
| 32 | 33 | |
| 33 | 34 | #if ARCH_IA64 // Limit static arrays to avoid gcc failing "short data segment overflowed" |
| 34 | 35 | #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 | ||
| 136 | 137 | int ff_get_mb_score(struct MpegEncContext *s, int mx, int my, int src_index, |
| 137 | 138 | int ref_index, int size, int h, int add_rate); |
| 138 | 139 | |
| 139 | −int ff_get_best_fcode(struct MpegEncContext *s, | |
| 140 | +int ff_get_best_fcode(MPVMainEncContext *m, | |
| 140 | 141 | const int16_t (*mv_table)[2], int type); |
| 141 | 142 | |
| 142 | 143 | void ff_fix_long_p_mvs(struct MpegEncContext *s, int type); |
| @@ -1113,7 +1113,7 @@ static av_cold int encode_init(AVCodecContext *avctx) · 1112 unmodified lines | ||
| 1113 | 1113 | m->encode_picture_header = mpeg1_encode_picture_header; |
| 1114 | 1114 | |
| 1115 | 1115 | s->me.mv_penalty = mv_penalty; |
| 1116 | − s->fcode_tab = fcode_tab + MAX_MV; | |
| 1116 | + m->fcode_tab = fcode_tab + MAX_MV; | |
| 1117 | 1117 | if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) { |
| 1118 | 1118 | s->min_qcoeff = -255; |
| 1119 | 1119 | s->max_qcoeff = 255; |
| @@ -1319,7 +1319,7 @@ static av_cold int encode_init(AVCodecContext *avctx) · 1318 unmodified lines | ||
| 1319 | 1319 | |
| 1320 | 1320 | m4->time_increment_bits = av_log2(avctx->time_base.den - 1) + 1; |
| 1321 | 1321 | |
| 1322 | − s->fcode_tab = fcode_tab + MAX_MV; | |
| 1322 | + m->fcode_tab = fcode_tab + MAX_MV; | |
| 1323 | 1323 | |
| 1324 | 1324 | s->min_qcoeff = -2048; |
| 1325 | 1325 | s->max_qcoeff = 2047; |
| @@ -253,7 +253,6 @@ typedef struct MpegEncContext { · 252 unmodified lines | ||
| 253 | 253 | int mv[2][4][2]; |
| 254 | 254 | int field_select[2][2]; |
| 255 | 255 | 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 | |
| 257 | 256 | int16_t direct_scale_mv[2][64]; ///< precomputed to avoid divisions in ff_mpeg4_set_direct_mv |
| 258 | 257 | |
| 259 | 258 | MotionEstContext me; |
| @@ -278,14 +278,15 @@ static av_cold void mpv_encode_init_static(void) · 277 unmodified lines | ||
| 278 | 278 | /** |
| 279 | 279 | * Set the given MpegEncContext to defaults for encoding. |
| 280 | 280 | */ |
| 281 | −static av_cold void mpv_encode_defaults(MpegEncContext *s) | |
| 281 | +static av_cold void mpv_encode_defaults(MPVMainEncContext *const m) | |
| 282 | 282 | { |
| 283 | + MpegEncContext *const s = &m->s; | |
| 283 | 284 | static AVOnce init_static_once = AV_ONCE_INIT; |
| 284 | 285 | |
| 285 | 286 | ff_mpv_common_defaults(s); |
| 286 | 287 | |
| 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; | |
| 289 | 290 | ff_thread_once(&init_static_once, mpv_encode_init_static); |
| 290 | 291 | } |
| 291 | 292 | if (!s->y_dc_scale_table) { |
| @@ -429,7 +430,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 137 unmodified lines | ||
| 429 | 430 | int i, ret; |
| 430 | 431 | int mb_array_size, mv_table_size; |
| 431 | 432 | |
| 432 | − mpv_encode_defaults(s); | |
| 433 | + mpv_encode_defaults(m); | |
| 433 | 434 | |
| 434 | 435 | switch (avctx->pix_fmt) { |
| 435 | 436 | case AV_PIX_FMT_YUVJ444P: |
| @@ -3774,12 +3775,12 @@ static int encode_picture(MPVMainEncContext *const m, const AVPacket *pkt) · 3338 unmodified lines | ||
| 3774 | 3775 | |
| 3775 | 3776 | if(!s->umvplus){ |
| 3776 | 3777 | 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); | |
| 3778 | 3779 | |
| 3779 | 3780 | if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME) { |
| 3780 | 3781 | 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); | |
| 3783 | 3784 | s->f_code= FFMAX3(s->f_code, a, b); |
| 3784 | 3785 | } |
| 3785 | 3786 | |
| @@ -3796,12 +3797,12 @@ static int encode_picture(MPVMainEncContext *const m, const AVPacket *pkt) · 10 unmodified lines | ||
| 3796 | 3797 | } else if (s->pict_type == AV_PICTURE_TYPE_B) { |
| 3797 | 3798 | int a, b; |
| 3798 | 3799 | |
| 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); | |
| 3801 | 3802 | s->f_code = FFMAX(a, b); |
| 3802 | 3803 | |
| 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); | |
| 3805 | 3806 | s->b_code = FFMAX(a, b); |
| 3806 | 3807 | |
| 3807 | 3808 | ff_fix_long_mvs(s, NULL, 0, s->b_forw_mv_table, s->f_code, CANDIDATE_MB_TYPE_FORWARD, 1); |
| @@ -67,6 +67,8 @@ typedef struct MPVMainEncContext { · 66 unmodified lines | ||
| 67 | 67 | int lmin, lmax; |
| 68 | 68 | int vbv_ignore_qmax; |
| 69 | 69 | |
| 70 | + const uint8_t *fcode_tab; ///< smallest fcode needed for each MV | |
| 71 | + | |
| 70 | 72 | /* frame skip options */ |
| 71 | 73 | int frame_skip_threshold; |
| 72 | 74 | int frame_skip_factor; |