mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
AC table reset (memset) optimization - patch by Michael Niedermayer <michaelni@gmx.at>
Originally committed as revision 251 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
5a24083859
commit
bff6ecaa9c
@ -180,6 +180,12 @@ int MPV_common_init(MpegEncContext *s)
|
|||||||
s->coded_block = av_mallocz(y_size);
|
s->coded_block = av_mallocz(y_size);
|
||||||
if (!s->coded_block)
|
if (!s->coded_block)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
/* which mb is a intra block */
|
||||||
|
s->mbintra_table = av_mallocz(y_size/4);
|
||||||
|
if (!s->mbintra_table)
|
||||||
|
goto fail;
|
||||||
|
memset(s->mbintra_table, 1, y_size/4);
|
||||||
}
|
}
|
||||||
/* default structure is frame */
|
/* default structure is frame */
|
||||||
s->picture_structure = PICT_FRAME;
|
s->picture_structure = PICT_FRAME;
|
||||||
@ -202,6 +208,8 @@ int MPV_common_init(MpegEncContext *s)
|
|||||||
free(s->ac_val[0]);
|
free(s->ac_val[0]);
|
||||||
if (s->coded_block)
|
if (s->coded_block)
|
||||||
free(s->coded_block);
|
free(s->coded_block);
|
||||||
|
if (s->mbintra_table)
|
||||||
|
free(s->mbintra_table);
|
||||||
if (s->mbskip_table)
|
if (s->mbskip_table)
|
||||||
free(s->mbskip_table);
|
free(s->mbskip_table);
|
||||||
for(i=0;i<3;i++) {
|
for(i=0;i<3;i++) {
|
||||||
@ -226,6 +234,7 @@ void MPV_common_end(MpegEncContext *s)
|
|||||||
free(s->dc_val[0]);
|
free(s->dc_val[0]);
|
||||||
free(s->ac_val[0]);
|
free(s->ac_val[0]);
|
||||||
free(s->coded_block);
|
free(s->coded_block);
|
||||||
|
free(s->mbintra_table);
|
||||||
}
|
}
|
||||||
if (s->mbskip_table)
|
if (s->mbskip_table)
|
||||||
free(s->mbskip_table);
|
free(s->mbskip_table);
|
||||||
@ -697,11 +706,16 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
|
|||||||
/* update DC predictors for P macroblocks */
|
/* update DC predictors for P macroblocks */
|
||||||
if (!s->mb_intra) {
|
if (!s->mb_intra) {
|
||||||
if (s->h263_pred) {
|
if (s->h263_pred) {
|
||||||
|
if(s->mbintra_table[mb_x + mb_y*s->mb_width])
|
||||||
|
{
|
||||||
int wrap, x, y, v;
|
int wrap, x, y, v;
|
||||||
|
s->mbintra_table[mb_x + mb_y*s->mb_width]=0;
|
||||||
|
|
||||||
wrap = 2 * s->mb_width + 2;
|
wrap = 2 * s->mb_width + 2;
|
||||||
v = 1024;
|
v = 1024;
|
||||||
x = 2 * mb_x + 1;
|
x = 2 * mb_x + 1;
|
||||||
y = 2 * mb_y + 1;
|
y = 2 * mb_y + 1;
|
||||||
|
|
||||||
s->dc_val[0][(x) + (y) * wrap] = v;
|
s->dc_val[0][(x) + (y) * wrap] = v;
|
||||||
s->dc_val[0][(x + 1) + (y) * wrap] = v;
|
s->dc_val[0][(x + 1) + (y) * wrap] = v;
|
||||||
s->dc_val[0][(x) + (y + 1) * wrap] = v;
|
s->dc_val[0][(x) + (y + 1) * wrap] = v;
|
||||||
@ -726,13 +740,16 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
|
|||||||
/* ac pred */
|
/* ac pred */
|
||||||
memset(s->ac_val[1][(x) + (y) * wrap], 0, 16 * sizeof(INT16));
|
memset(s->ac_val[1][(x) + (y) * wrap], 0, 16 * sizeof(INT16));
|
||||||
memset(s->ac_val[2][(x) + (y) * wrap], 0, 16 * sizeof(INT16));
|
memset(s->ac_val[2][(x) + (y) * wrap], 0, 16 * sizeof(INT16));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
s->last_dc[0] = 128 << s->intra_dc_precision;
|
s->last_dc[0] = 128 << s->intra_dc_precision;
|
||||||
s->last_dc[1] = 128 << s->intra_dc_precision;
|
s->last_dc[1] = 128 << s->intra_dc_precision;
|
||||||
s->last_dc[2] = 128 << s->intra_dc_precision;
|
s->last_dc[2] = 128 << s->intra_dc_precision;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
s->mbintra_table[mb_x + mb_y*s->mb_width]=1;
|
||||||
|
|
||||||
/* update motion predictor */
|
/* update motion predictor */
|
||||||
if (s->out_format == FMT_H263) {
|
if (s->out_format == FMT_H263) {
|
||||||
int x, y, wrap;
|
int x, y, wrap;
|
||||||
|
@ -75,6 +75,7 @@ typedef struct MpegEncContext {
|
|||||||
int mb_skiped; /* MUST BE SET only during DECODING */
|
int mb_skiped; /* MUST BE SET only during DECODING */
|
||||||
UINT8 *mbskip_table; /* used to avoid copy if macroblock
|
UINT8 *mbskip_table; /* used to avoid copy if macroblock
|
||||||
skipped (for black regions for example) */
|
skipped (for black regions for example) */
|
||||||
|
UINT8 *mbintra_table; /* used to kill a few memsets */
|
||||||
|
|
||||||
int qscale;
|
int qscale;
|
||||||
int pict_type;
|
int pict_type;
|
||||||
|
Loading…
Reference in New Issue
Block a user