You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avcodec/mpegvideo: Move fcode_tab to MPVMainEncContext
Only used by the main encoding thread. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -848,7 +848,7 @@ av_cold void ff_h263_encode_init(MPVMainEncContext *const m)
|
|||||||
break;
|
break;
|
||||||
case AV_CODEC_ID_H263P:
|
case AV_CODEC_ID_H263P:
|
||||||
if(s->umvplus)
|
if(s->umvplus)
|
||||||
s->fcode_tab = umv_fcode_tab + MAX_MV;
|
m->fcode_tab = umv_fcode_tab + MAX_MV;
|
||||||
if(s->modified_quant){
|
if(s->modified_quant){
|
||||||
s->min_qcoeff= -2047;
|
s->min_qcoeff= -2047;
|
||||||
s->max_qcoeff= 2047;
|
s->max_qcoeff= 2047;
|
||||||
|
@@ -1596,12 +1596,14 @@ void ff_estimate_b_frame_motion(MpegEncContext * s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* find best f_code for ME which do unlimited searches */
|
/* find best f_code for ME which do unlimited searches */
|
||||||
int ff_get_best_fcode(MpegEncContext * s, const int16_t (*mv_table)[2], int type)
|
int ff_get_best_fcode(MPVMainEncContext *const m, const int16_t (*mv_table)[2], int type)
|
||||||
{
|
{
|
||||||
|
MpegEncContext *const s = &m->s;
|
||||||
|
|
||||||
if (s->motion_est != FF_ME_ZERO) {
|
if (s->motion_est != FF_ME_ZERO) {
|
||||||
int score[8];
|
int score[8];
|
||||||
int i, y, range= s->avctx->me_range ? s->avctx->me_range : (INT_MAX/2);
|
int i, y, range= s->avctx->me_range ? s->avctx->me_range : (INT_MAX/2);
|
||||||
const uint8_t * fcode_tab = s->fcode_tab;
|
const uint8_t * fcode_tab = m->fcode_tab;
|
||||||
int best_fcode=-1;
|
int best_fcode=-1;
|
||||||
int best_score=-10000000;
|
int best_score=-10000000;
|
||||||
|
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include "qpeldsp.h"
|
#include "qpeldsp.h"
|
||||||
|
|
||||||
struct MpegEncContext;
|
struct MpegEncContext;
|
||||||
|
typedef struct MPVMainEncContext MPVMainEncContext;
|
||||||
|
|
||||||
#if ARCH_IA64 // Limit static arrays to avoid gcc failing "short data segment overflowed"
|
#if ARCH_IA64 // Limit static arrays to avoid gcc failing "short data segment overflowed"
|
||||||
#define MAX_MV 1024
|
#define MAX_MV 1024
|
||||||
@@ -136,7 +137,7 @@ int ff_epzs_motion_search(struct MpegEncContext *s, int *mx_ptr, int *my_ptr,
|
|||||||
int ff_get_mb_score(struct MpegEncContext *s, int mx, int my, int src_index,
|
int ff_get_mb_score(struct MpegEncContext *s, int mx, int my, int src_index,
|
||||||
int ref_index, int size, int h, int add_rate);
|
int ref_index, int size, int h, int add_rate);
|
||||||
|
|
||||||
int ff_get_best_fcode(struct MpegEncContext *s,
|
int ff_get_best_fcode(MPVMainEncContext *m,
|
||||||
const int16_t (*mv_table)[2], int type);
|
const int16_t (*mv_table)[2], int type);
|
||||||
|
|
||||||
void ff_fix_long_p_mvs(struct MpegEncContext *s, int type);
|
void ff_fix_long_p_mvs(struct MpegEncContext *s, int type);
|
||||||
|
@@ -1113,7 +1113,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
|
|||||||
m->encode_picture_header = mpeg1_encode_picture_header;
|
m->encode_picture_header = mpeg1_encode_picture_header;
|
||||||
|
|
||||||
s->me.mv_penalty = mv_penalty;
|
s->me.mv_penalty = mv_penalty;
|
||||||
s->fcode_tab = fcode_tab + MAX_MV;
|
m->fcode_tab = fcode_tab + MAX_MV;
|
||||||
if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
|
if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
|
||||||
s->min_qcoeff = -255;
|
s->min_qcoeff = -255;
|
||||||
s->max_qcoeff = 255;
|
s->max_qcoeff = 255;
|
||||||
|
@@ -1319,7 +1319,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
m4->time_increment_bits = av_log2(avctx->time_base.den - 1) + 1;
|
m4->time_increment_bits = av_log2(avctx->time_base.den - 1) + 1;
|
||||||
|
|
||||||
s->fcode_tab = fcode_tab + MAX_MV;
|
m->fcode_tab = fcode_tab + MAX_MV;
|
||||||
|
|
||||||
s->min_qcoeff = -2048;
|
s->min_qcoeff = -2048;
|
||||||
s->max_qcoeff = 2047;
|
s->max_qcoeff = 2047;
|
||||||
|
@@ -253,7 +253,6 @@ typedef struct MpegEncContext {
|
|||||||
int mv[2][4][2];
|
int mv[2][4][2];
|
||||||
int field_select[2][2];
|
int field_select[2][2];
|
||||||
int last_mv[2][2][2]; ///< last MV, used for MV prediction in MPEG-1 & B-frame MPEG-4
|
int last_mv[2][2][2]; ///< last MV, used for MV prediction in MPEG-1 & B-frame MPEG-4
|
||||||
const uint8_t *fcode_tab; ///< smallest fcode needed for each MV
|
|
||||||
int16_t direct_scale_mv[2][64]; ///< precomputed to avoid divisions in ff_mpeg4_set_direct_mv
|
int16_t direct_scale_mv[2][64]; ///< precomputed to avoid divisions in ff_mpeg4_set_direct_mv
|
||||||
|
|
||||||
MotionEstContext me;
|
MotionEstContext me;
|
||||||
|
@@ -278,14 +278,15 @@ static av_cold void mpv_encode_init_static(void)
|
|||||||
/**
|
/**
|
||||||
* Set the given MpegEncContext to defaults for encoding.
|
* Set the given MpegEncContext to defaults for encoding.
|
||||||
*/
|
*/
|
||||||
static av_cold void mpv_encode_defaults(MpegEncContext *s)
|
static av_cold void mpv_encode_defaults(MPVMainEncContext *const m)
|
||||||
{
|
{
|
||||||
|
MpegEncContext *const s = &m->s;
|
||||||
static AVOnce init_static_once = AV_ONCE_INIT;
|
static AVOnce init_static_once = AV_ONCE_INIT;
|
||||||
|
|
||||||
ff_mpv_common_defaults(s);
|
ff_mpv_common_defaults(s);
|
||||||
|
|
||||||
if (!s->fcode_tab) {
|
if (!m->fcode_tab) {
|
||||||
s->fcode_tab = default_fcode_tab + MAX_MV;
|
m->fcode_tab = default_fcode_tab + MAX_MV;
|
||||||
ff_thread_once(&init_static_once, mpv_encode_init_static);
|
ff_thread_once(&init_static_once, mpv_encode_init_static);
|
||||||
}
|
}
|
||||||
if (!s->y_dc_scale_table) {
|
if (!s->y_dc_scale_table) {
|
||||||
@@ -429,7 +430,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
|
|||||||
int i, ret;
|
int i, ret;
|
||||||
int mb_array_size, mv_table_size;
|
int mb_array_size, mv_table_size;
|
||||||
|
|
||||||
mpv_encode_defaults(s);
|
mpv_encode_defaults(m);
|
||||||
|
|
||||||
switch (avctx->pix_fmt) {
|
switch (avctx->pix_fmt) {
|
||||||
case AV_PIX_FMT_YUVJ444P:
|
case AV_PIX_FMT_YUVJ444P:
|
||||||
@@ -3774,12 +3775,12 @@ static int encode_picture(MPVMainEncContext *const m, const AVPacket *pkt)
|
|||||||
|
|
||||||
if(!s->umvplus){
|
if(!s->umvplus){
|
||||||
if(s->pict_type==AV_PICTURE_TYPE_P || s->pict_type==AV_PICTURE_TYPE_S) {
|
if(s->pict_type==AV_PICTURE_TYPE_P || s->pict_type==AV_PICTURE_TYPE_S) {
|
||||||
s->f_code= ff_get_best_fcode(s, s->p_mv_table, CANDIDATE_MB_TYPE_INTER);
|
s->f_code = ff_get_best_fcode(m, s->p_mv_table, CANDIDATE_MB_TYPE_INTER);
|
||||||
|
|
||||||
if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME) {
|
if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_ME) {
|
||||||
int a,b;
|
int a,b;
|
||||||
a= ff_get_best_fcode(s, s->p_field_mv_table[0][0], CANDIDATE_MB_TYPE_INTER_I); //FIXME field_select
|
a = ff_get_best_fcode(m, s->p_field_mv_table[0][0], CANDIDATE_MB_TYPE_INTER_I); //FIXME field_select
|
||||||
b= ff_get_best_fcode(s, s->p_field_mv_table[1][1], CANDIDATE_MB_TYPE_INTER_I);
|
b = ff_get_best_fcode(m, s->p_field_mv_table[1][1], CANDIDATE_MB_TYPE_INTER_I);
|
||||||
s->f_code= FFMAX3(s->f_code, a, b);
|
s->f_code= FFMAX3(s->f_code, a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3796,12 +3797,12 @@ static int encode_picture(MPVMainEncContext *const m, const AVPacket *pkt)
|
|||||||
} else if (s->pict_type == AV_PICTURE_TYPE_B) {
|
} else if (s->pict_type == AV_PICTURE_TYPE_B) {
|
||||||
int a, b;
|
int a, b;
|
||||||
|
|
||||||
a = ff_get_best_fcode(s, s->b_forw_mv_table, CANDIDATE_MB_TYPE_FORWARD);
|
a = ff_get_best_fcode(m, s->b_forw_mv_table, CANDIDATE_MB_TYPE_FORWARD);
|
||||||
b = ff_get_best_fcode(s, s->b_bidir_forw_mv_table, CANDIDATE_MB_TYPE_BIDIR);
|
b = ff_get_best_fcode(m, s->b_bidir_forw_mv_table, CANDIDATE_MB_TYPE_BIDIR);
|
||||||
s->f_code = FFMAX(a, b);
|
s->f_code = FFMAX(a, b);
|
||||||
|
|
||||||
a = ff_get_best_fcode(s, s->b_back_mv_table, CANDIDATE_MB_TYPE_BACKWARD);
|
a = ff_get_best_fcode(m, s->b_back_mv_table, CANDIDATE_MB_TYPE_BACKWARD);
|
||||||
b = ff_get_best_fcode(s, s->b_bidir_back_mv_table, CANDIDATE_MB_TYPE_BIDIR);
|
b = ff_get_best_fcode(m, s->b_bidir_back_mv_table, CANDIDATE_MB_TYPE_BIDIR);
|
||||||
s->b_code = FFMAX(a, b);
|
s->b_code = FFMAX(a, b);
|
||||||
|
|
||||||
ff_fix_long_mvs(s, NULL, 0, s->b_forw_mv_table, s->f_code, CANDIDATE_MB_TYPE_FORWARD, 1);
|
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 {
|
|||||||
int lmin, lmax;
|
int lmin, lmax;
|
||||||
int vbv_ignore_qmax;
|
int vbv_ignore_qmax;
|
||||||
|
|
||||||
|
const uint8_t *fcode_tab; ///< smallest fcode needed for each MV
|
||||||
|
|
||||||
/* frame skip options */
|
/* frame skip options */
|
||||||
int frame_skip_threshold;
|
int frame_skip_threshold;
|
||||||
int frame_skip_factor;
|
int frame_skip_factor;
|
||||||
|
Reference in New Issue
Block a user