mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
* eliminating duplicated code from MPV_common_end
* simplified indexing Originally committed as revision 305 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
3232bc885d
commit
8257bf0534
@ -228,34 +228,7 @@ int MPV_common_init(MpegEncContext *s)
|
|||||||
s->context_initialized = 1;
|
s->context_initialized = 1;
|
||||||
return 0;
|
return 0;
|
||||||
fail:
|
fail:
|
||||||
if (s->mb_type)
|
MPV_common_end(s);
|
||||||
free(s->mb_type);
|
|
||||||
if (s->mb_var)
|
|
||||||
free(s->mb_var);
|
|
||||||
if (s->mv_table[0])
|
|
||||||
free(s->mv_table[0]);
|
|
||||||
if (s->mv_table[1])
|
|
||||||
free(s->mv_table[1]);
|
|
||||||
if (s->motion_val)
|
|
||||||
free(s->motion_val);
|
|
||||||
if (s->dc_val[0])
|
|
||||||
free(s->dc_val[0]);
|
|
||||||
if (s->ac_val[0])
|
|
||||||
free(s->ac_val[0]);
|
|
||||||
if (s->coded_block)
|
|
||||||
free(s->coded_block);
|
|
||||||
if (s->mbintra_table)
|
|
||||||
free(s->mbintra_table);
|
|
||||||
if (s->mbskip_table)
|
|
||||||
free(s->mbskip_table);
|
|
||||||
for(i=0;i<3;i++) {
|
|
||||||
if (s->last_picture_base[i])
|
|
||||||
free(s->last_picture_base[i]);
|
|
||||||
if (s->next_picture_base[i])
|
|
||||||
free(s->next_picture_base[i]);
|
|
||||||
if (s->aux_picture_base[i])
|
|
||||||
free(s->aux_picture_base[i]);
|
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,17 +247,22 @@ void MPV_common_end(MpegEncContext *s)
|
|||||||
free(s->mv_table[1]);
|
free(s->mv_table[1]);
|
||||||
if (s->motion_val)
|
if (s->motion_val)
|
||||||
free(s->motion_val);
|
free(s->motion_val);
|
||||||
if (s->h263_pred) {
|
if (s->dc_val[0])
|
||||||
free(s->dc_val[0]);
|
free(s->dc_val[0]);
|
||||||
|
if (s->ac_val[0])
|
||||||
free(s->ac_val[0]);
|
free(s->ac_val[0]);
|
||||||
|
if (s->coded_block)
|
||||||
free(s->coded_block);
|
free(s->coded_block);
|
||||||
|
if (s->mbintra_table)
|
||||||
free(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++) {
|
||||||
free(s->last_picture_base[i]);
|
if (s->last_picture_base[i])
|
||||||
free(s->next_picture_base[i]);
|
free(s->last_picture_base[i]);
|
||||||
|
if (s->next_picture_base[i])
|
||||||
|
free(s->next_picture_base[i]);
|
||||||
if (s->has_b_frames)
|
if (s->has_b_frames)
|
||||||
free(s->aux_picture_base[i]);
|
free(s->aux_picture_base[i]);
|
||||||
}
|
}
|
||||||
@ -753,7 +731,7 @@ static inline void add_dct(MpegEncContext *s,
|
|||||||
*/
|
*/
|
||||||
void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
|
void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
|
||||||
{
|
{
|
||||||
int mb_x, mb_y, motion_x, motion_y;
|
int mb_x, mb_y;
|
||||||
int dct_linesize, dct_offset;
|
int dct_linesize, dct_offset;
|
||||||
op_pixels_func *op_pix;
|
op_pixels_func *op_pix;
|
||||||
|
|
||||||
@ -770,38 +748,35 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
|
|||||||
if (s->h263_pred) {
|
if (s->h263_pred) {
|
||||||
if(s->mbintra_table[mb_x + mb_y*s->mb_width])
|
if(s->mbintra_table[mb_x + mb_y*s->mb_width])
|
||||||
{
|
{
|
||||||
int wrap, x, y, v;
|
int wrap, xy, v;
|
||||||
s->mbintra_table[mb_x + mb_y*s->mb_width]=0;
|
s->mbintra_table[mb_x + mb_y*s->mb_width]=0;
|
||||||
|
|
||||||
wrap = 2 * s->mb_width + 2;
|
wrap = 2 * s->mb_width + 2;
|
||||||
|
xy = 2 * mb_x + 1 + (2 * mb_y + 1) * wrap;
|
||||||
v = 1024;
|
v = 1024;
|
||||||
x = 2 * mb_x + 1;
|
|
||||||
y = 2 * mb_y + 1;
|
|
||||||
|
|
||||||
s->dc_val[0][(x) + (y) * wrap] = v;
|
s->dc_val[0][xy] = v;
|
||||||
s->dc_val[0][(x + 1) + (y) * wrap] = v;
|
s->dc_val[0][xy + 1] = v;
|
||||||
s->dc_val[0][(x) + (y + 1) * wrap] = v;
|
s->dc_val[0][xy + wrap] = v;
|
||||||
s->dc_val[0][(x + 1) + (y + 1) * wrap] = v;
|
s->dc_val[0][xy + 1 + wrap] = v;
|
||||||
/* ac pred */
|
/* ac pred */
|
||||||
memset(s->ac_val[0][(x) + (y) * wrap], 0, 16 * sizeof(INT16));
|
memset(s->ac_val[0][xy], 0, 16 * sizeof(INT16));
|
||||||
memset(s->ac_val[0][(x + 1) + (y) * wrap], 0, 16 * sizeof(INT16));
|
memset(s->ac_val[0][xy + 1], 0, 16 * sizeof(INT16));
|
||||||
memset(s->ac_val[0][(x) + (y + 1) * wrap], 0, 16 * sizeof(INT16));
|
memset(s->ac_val[0][xy + wrap], 0, 16 * sizeof(INT16));
|
||||||
memset(s->ac_val[0][(x + 1) + (y + 1) * wrap], 0, 16 * sizeof(INT16));
|
memset(s->ac_val[0][xy + 1 + wrap], 0, 16 * sizeof(INT16));
|
||||||
if (s->h263_msmpeg4) {
|
if (s->h263_msmpeg4) {
|
||||||
s->coded_block[(x) + (y) * wrap] = 0;
|
s->coded_block[xy] = 0;
|
||||||
s->coded_block[(x + 1) + (y) * wrap] = 0;
|
s->coded_block[xy + 1] = 0;
|
||||||
s->coded_block[(x) + (y + 1) * wrap] = 0;
|
s->coded_block[xy + wrap] = 0;
|
||||||
s->coded_block[(x + 1) + (y + 1) * wrap] = 0;
|
s->coded_block[xy + 1 + wrap] = 0;
|
||||||
}
|
}
|
||||||
/* chroma */
|
/* chroma */
|
||||||
wrap = s->mb_width + 2;
|
wrap = s->mb_width + 2;
|
||||||
x = mb_x + 1;
|
xy = mb_x + 1 + (mb_y + 1) * wrap;
|
||||||
y = mb_y + 1;
|
s->dc_val[1][xy] = v;
|
||||||
s->dc_val[1][(x) + (y) * wrap] = v;
|
s->dc_val[2][xy] = v;
|
||||||
s->dc_val[2][(x) + (y) * wrap] = v;
|
|
||||||
/* ac pred */
|
/* ac pred */
|
||||||
memset(s->ac_val[1][(x) + (y) * wrap], 0, 16 * sizeof(INT16));
|
memset(s->ac_val[1][xy], 0, 16 * sizeof(INT16));
|
||||||
memset(s->ac_val[2][(x) + (y) * wrap], 0, 16 * sizeof(INT16));
|
memset(s->ac_val[2][xy], 0, 16 * sizeof(INT16));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s->last_dc[0] = 128 << s->intra_dc_precision;
|
s->last_dc[0] = 128 << s->intra_dc_precision;
|
||||||
@ -814,11 +789,10 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
|
|||||||
|
|
||||||
/* update motion predictor */
|
/* update motion predictor */
|
||||||
if (s->out_format == FMT_H263) {
|
if (s->out_format == FMT_H263) {
|
||||||
int x, y, wrap;
|
int xy, wrap, motion_x, motion_y;
|
||||||
|
|
||||||
x = 2 * mb_x + 1;
|
|
||||||
y = 2 * mb_y + 1;
|
|
||||||
wrap = 2 * s->mb_width + 2;
|
wrap = 2 * s->mb_width + 2;
|
||||||
|
xy = 2 * mb_x + 1 + (2 * mb_y + 1) * wrap;
|
||||||
if (s->mb_intra) {
|
if (s->mb_intra) {
|
||||||
motion_x = 0;
|
motion_x = 0;
|
||||||
motion_y = 0;
|
motion_y = 0;
|
||||||
@ -828,14 +802,14 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
|
|||||||
motion_y = s->mv[0][0][1];
|
motion_y = s->mv[0][0][1];
|
||||||
motion_init:
|
motion_init:
|
||||||
/* no update if 8X8 because it has been done during parsing */
|
/* no update if 8X8 because it has been done during parsing */
|
||||||
s->motion_val[(x) + (y) * wrap][0] = motion_x;
|
s->motion_val[xy][0] = motion_x;
|
||||||
s->motion_val[(x) + (y) * wrap][1] = motion_y;
|
s->motion_val[xy][1] = motion_y;
|
||||||
s->motion_val[(x + 1) + (y) * wrap][0] = motion_x;
|
s->motion_val[xy + 1][0] = motion_x;
|
||||||
s->motion_val[(x + 1) + (y) * wrap][1] = motion_y;
|
s->motion_val[xy + 1][1] = motion_y;
|
||||||
s->motion_val[(x) + (y + 1) * wrap][0] = motion_x;
|
s->motion_val[xy + wrap][0] = motion_x;
|
||||||
s->motion_val[(x) + (y + 1) * wrap][1] = motion_y;
|
s->motion_val[xy + wrap][1] = motion_y;
|
||||||
s->motion_val[(x + 1) + (y + 1) * wrap][0] = motion_x;
|
s->motion_val[xy + 1 + wrap][0] = motion_x;
|
||||||
s->motion_val[(x + 1) + (y + 1) * wrap][1] = motion_y;
|
s->motion_val[xy + 1 + wrap][1] = motion_y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user