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
848 break;848 break;
849 case AV_CODEC_ID_H263P:849 case AV_CODEC_ID_H263P:
850 if(s->umvplus)850 if(s->umvplus)
851 s->fcode_tab = umv_fcode_tab + MAX_MV;851 m->fcode_tab = umv_fcode_tab + MAX_MV;
852 if(s->modified_quant){852 if(s->modified_quant){
853 s->min_qcoeff= -2047;853 s->min_qcoeff= -2047;
854 s->max_qcoeff= 2047;854 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
1596}1596}
1597 1597
1598/* find best f_code for ME which do unlimited searches */1598/* find best f_code for ME which do unlimited searches */
1599int ff_get_best_fcode(MpegEncContext * s, const int16_t (*mv_table)[2], int type)1599int 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 if (s->motion_est != FF_ME_ZERO) {1603 if (s->motion_est != FF_ME_ZERO) {
1602 int score[8];1604 int score[8];
1603 int i, y, range= s->avctx->me_range ? s->avctx->me_range : (INT_MAX/2);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 int best_fcode=-1;1607 int best_fcode=-1;
1606 int best_score=-10000000;1608 int best_score=-10000000;
1607 1609
libavcodec/motion_est.h+2−1
@@ -29,6 +29,7 @@ · 28 unmodified lines
29#include "qpeldsp.h"29#include "qpeldsp.h"
30 30
31struct MpegEncContext;31struct MpegEncContext;
32typedef struct MPVMainEncContext MPVMainEncContext;
32 33
33#if ARCH_IA64 // Limit static arrays to avoid gcc failing "short data segment overflowed"34#if ARCH_IA64 // Limit static arrays to avoid gcc failing "short data segment overflowed"
34#define MAX_MV 102435#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
136int ff_get_mb_score(struct MpegEncContext *s, int mx, int my, int src_index,137int ff_get_mb_score(struct MpegEncContext *s, int mx, int my, int src_index,
137 int ref_index, int size, int h, int add_rate);138 int ref_index, int size, int h, int add_rate);
138 139
139int ff_get_best_fcode(struct MpegEncContext *s,140int ff_get_best_fcode(MPVMainEncContext *m,
140 const int16_t (*mv_table)[2], int type);141 const int16_t (*mv_table)[2], int type);
141 142
142void ff_fix_long_p_mvs(struct MpegEncContext *s, int type);143void 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
1113 m->encode_picture_header = mpeg1_encode_picture_header;1113 m->encode_picture_header = mpeg1_encode_picture_header;
1114 1114
1115 s->me.mv_penalty = mv_penalty;1115 s->me.mv_penalty = mv_penalty;
1116 s->fcode_tab = fcode_tab + MAX_MV;1116 m->fcode_tab = fcode_tab + MAX_MV;
1117 if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {1117 if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
1118 s->min_qcoeff = -255;1118 s->min_qcoeff = -255;
1119 s->max_qcoeff = 255;1119 s->max_qcoeff = 255;
libavcodec/mpeg4videoenc.c+1−1
@@ -1319,7 +1319,7 @@ static av_cold int encode_init(AVCodecContext *avctx) · 1318 unmodified lines
1319 1319
1320 m4->time_increment_bits = av_log2(avctx->time_base.den - 1) + 1;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 s->min_qcoeff = -2048;1324 s->min_qcoeff = -2048;
1325 s->max_qcoeff = 2047;1325 s->max_qcoeff = 2047;
libavcodec/mpegvideo.h+0−1
@@ -253,7 +253,6 @@ typedef struct MpegEncContext { · 252 unmodified lines
253 int mv[2][4][2];253 int mv[2][4][2];
254 int field_select[2][2];254 int field_select[2][2];
255 int last_mv[2][2][2]; ///< last MV, used for MV prediction in MPEG-1 & B-frame MPEG-4255 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 int16_t direct_scale_mv[2][64]; ///< precomputed to avoid divisions in ff_mpeg4_set_direct_mv256 int16_t direct_scale_mv[2][64]; ///< precomputed to avoid divisions in ff_mpeg4_set_direct_mv
258 257
259 MotionEstContext me;258 MotionEstContext me;
libavcodec/mpegvideo_enc.c+12−11
@@ -278,14 +278,15 @@ static av_cold void mpv_encode_init_static(void) · 277 unmodified lines
278/**278/**
279 * Set the given MpegEncContext to defaults for encoding.279 * Set the given MpegEncContext to defaults for encoding.
280 */280 */
281static av_cold void mpv_encode_defaults(MpegEncContext *s)281static av_cold void mpv_encode_defaults(MPVMainEncContext *const m)
282{282{
283 MpegEncContext *const s = &m->s;
283 static AVOnce init_static_once = AV_ONCE_INIT;284 static AVOnce init_static_once = AV_ONCE_INIT;
284 285
285 ff_mpv_common_defaults(s);286 ff_mpv_common_defaults(s);
286 287
287 if (!s->fcode_tab) {288 if (!m->fcode_tab) {
288 s->fcode_tab = default_fcode_tab + MAX_MV;289 m->fcode_tab = default_fcode_tab + MAX_MV;
289 ff_thread_once(&init_static_once, mpv_encode_init_static);290 ff_thread_once(&init_static_once, mpv_encode_init_static);
290 }291 }
291 if (!s->y_dc_scale_table) {292 if (!s->y_dc_scale_table) {
@@ -429,7 +430,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 137 unmodified lines
429 int i, ret;430 int i, ret;
430 int mb_array_size, mv_table_size;431 int mb_array_size, mv_table_size;
431 432
432 mpv_encode_defaults(s);433 mpv_encode_defaults(m);
433 434
434 switch (avctx->pix_fmt) {435 switch (avctx->pix_fmt) {
435 case AV_PIX_FMT_YUVJ444P: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 if(!s->umvplus){3776 if(!s->umvplus){
3776 if(s->pict_type==AV_PICTURE_TYPE_P || s->pict_type==AV_PICTURE_TYPE_S) {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 if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME) {3780 if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME) {
3780 int a,b;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_select3782 a = ff_get_best_fcode(m, 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);3783 b = ff_get_best_fcode(m, s->p_field_mv_table[1][1], CANDIDATE_MB_TYPE_INTER_I);
3783 s->f_code= FFMAX3(s->f_code, a, b);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 } else if (s->pict_type == AV_PICTURE_TYPE_B) {3797 } else if (s->pict_type == AV_PICTURE_TYPE_B) {
3797 int a, b;3798 int a, b;
3798 3799
3799 a = ff_get_best_fcode(s, s->b_forw_mv_table, CANDIDATE_MB_TYPE_FORWARD);3800 a = ff_get_best_fcode(m, 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);3801 b = ff_get_best_fcode(m, s->b_bidir_forw_mv_table, CANDIDATE_MB_TYPE_BIDIR);
3801 s->f_code = FFMAX(a, b);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 a = ff_get_best_fcode(m, 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);3805 b = ff_get_best_fcode(m, s->b_bidir_back_mv_table, CANDIDATE_MB_TYPE_BIDIR);
3805 s->b_code = FFMAX(a, b);3806 s->b_code = FFMAX(a, b);
3806 3807
3807 ff_fix_long_mvs(s, NULL, 0, s->b_forw_mv_table, s->f_code, CANDIDATE_MB_TYPE_FORWARD, 1);3808 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
67 int lmin, lmax;67 int lmin, lmax;
68 int vbv_ignore_qmax;68 int vbv_ignore_qmax;
69 69
70 const uint8_t *fcode_tab; ///< smallest fcode needed for each MV
71
70 /* frame skip options */72 /* frame skip options */
71 int frame_skip_threshold;73 int frame_skip_threshold;
72 int frame_skip_factor;74 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