summaryrefslogtreecommitdiff
path: root/src/libffmpeg/libavcodec/mpegvideo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libffmpeg/libavcodec/mpegvideo.c')
-rw-r--r--src/libffmpeg/libavcodec/mpegvideo.c195
1 files changed, 110 insertions, 85 deletions
diff --git a/src/libffmpeg/libavcodec/mpegvideo.c b/src/libffmpeg/libavcodec/mpegvideo.c
index 4761b6137..357ab20e4 100644
--- a/src/libffmpeg/libavcodec/mpegvideo.c
+++ b/src/libffmpeg/libavcodec/mpegvideo.c
@@ -57,7 +57,7 @@ static void emulated_edge_mc(MpegEncContext *s, UINT8 *src, int linesize, int bl
/* for jpeg fast DCT */
#define CONST_BITS 14
-static const unsigned short aanscales[64] = {
+static const uint16_t aanscales[64] = {
/* precomputed values scaled up by 14 bits */
16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,
22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270,
@@ -70,7 +70,7 @@ static const unsigned short aanscales[64] = {
};
/* Input permutation for the simple_idct_mmx */
-static const UINT8 simple_mmx_permutation[64]={
+static const uint8_t simple_mmx_permutation[64]={
0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
@@ -81,11 +81,11 @@ static const UINT8 simple_mmx_permutation[64]={
0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
};
-static UINT8 h263_chroma_roundtab[16] = {
+static const uint8_t h263_chroma_roundtab[16] = {
0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
};
-static UINT16 default_mv_penalty[MAX_FCODE+1][MAX_MV*2+1];
+static UINT16 (*default_mv_penalty)[MAX_MV*2+1]=NULL;
static UINT8 default_fcode_tab[MAX_MV*2+1];
/* default motion estimation */
@@ -157,6 +157,9 @@ void ff_init_scantable(MpegEncContext *s, ScanTable *st, const UINT8 *src_scanta
int j;
j = src_scantable[i];
st->permutated[i] = s->idct_permutation[j];
+#ifdef ARCH_POWERPC
+ st->inverse[j] = i;
+#endif
}
end=-1;
@@ -169,16 +172,19 @@ void ff_init_scantable(MpegEncContext *s, ScanTable *st, const UINT8 *src_scanta
}
/* XXX: those functions should be suppressed ASAP when all IDCTs are
- converted */
+ converted */
+// *FIXME* this is ugly hack using local static
+static void (*ff_put_pixels_clamped)(const DCTELEM *block, UINT8 *pixels, int line_size);
+static void (*ff_add_pixels_clamped)(const DCTELEM *block, UINT8 *pixels, int line_size);
static void ff_jref_idct_put(UINT8 *dest, int line_size, DCTELEM *block)
{
j_rev_dct (block);
- put_pixels_clamped(block, dest, line_size);
+ ff_put_pixels_clamped(block, dest, line_size);
}
static void ff_jref_idct_add(UINT8 *dest, int line_size, DCTELEM *block)
{
j_rev_dct (block);
- add_pixels_clamped(block, dest, line_size);
+ ff_add_pixels_clamped(block, dest, line_size);
}
/* init common dct for both encoder and decoder */
@@ -186,6 +192,9 @@ int DCT_common_init(MpegEncContext *s)
{
int i;
+ ff_put_pixels_clamped = s->dsp.put_pixels_clamped;
+ ff_add_pixels_clamped = s->dsp.add_pixels_clamped;
+
s->dct_unquantize_h263 = dct_unquantize_h263_c;
s->dct_unquantize_mpeg1 = dct_unquantize_mpeg1_c;
s->dct_unquantize_mpeg2 = dct_unquantize_mpeg2_c;
@@ -221,6 +230,9 @@ int DCT_common_init(MpegEncContext *s)
#ifdef ARCH_ARMV4L
MPV_common_init_armv4l();
#endif
+#ifdef ARCH_POWERPC
+ MPV_common_init_ppc(s);
+#endif
switch(s->idct_permutation_type){
case FF_NO_IDCT_PERM:
@@ -262,29 +274,30 @@ int MPV_common_init(MpegEncContext *s)
UINT8 *pict;
int y_size, c_size, yc_size, i;
+ dsputil_init(&s->dsp, s->avctx->dsp_mask);
DCT_common_init(s);
-
+
s->flags= s->avctx->flags;
s->mb_width = (s->width + 15) / 16;
s->mb_height = (s->height + 15) / 16;
-
- y_size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2);
- c_size = (s->mb_width + 2) * (s->mb_height + 2);
- yc_size = y_size + 2 * c_size;
-
+
/* set default edge pos, will be overriden in decode_header if needed */
s->h_edge_pos= s->mb_width*16;
s->v_edge_pos= s->mb_height*16;
-
+
+ s->mb_num = s->mb_width * s->mb_height;
+
+ y_size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2);
+ c_size = (s->mb_width + 2) * (s->mb_height + 2);
+ yc_size = y_size + 2 * c_size;
+
/* convert fourcc to upper case */
s->avctx->fourcc= toupper( s->avctx->fourcc &0xFF)
+ (toupper((s->avctx->fourcc>>8 )&0xFF)<<8 )
+ (toupper((s->avctx->fourcc>>16)&0xFF)<<16)
+ (toupper((s->avctx->fourcc>>24)&0xFF)<<24);
- s->mb_num = s->mb_width * s->mb_height;
-
if(!(s->flags&CODEC_FLAG_DR1)){
s->linesize = s->mb_width * 16 + 2 * EDGE_WIDTH;
s->uvlinesize = s->mb_width * 8 + EDGE_WIDTH;
@@ -404,7 +417,7 @@ int MPV_common_init(MpegEncContext *s)
/* divx501 bitstream reorder buffer */
CHECKED_ALLOCZ(s->bitstream_buffer, BITSTREAM_BUFFER_SIZE);
-
+
/* cbp, ac_pred, pred_dir */
CHECKED_ALLOCZ(s->cbp_table , s->mb_num * sizeof(UINT8))
CHECKED_ALLOCZ(s->pred_dir_table, s->mb_num * sizeof(UINT8))
@@ -420,7 +433,11 @@ int MPV_common_init(MpegEncContext *s)
s->dc_val[0][i] = 1024;
}
- CHECKED_ALLOCZ(s->qscale_table , s->mb_num * sizeof(UINT8))
+ CHECKED_ALLOCZ(s->next_qscale_table , s->mb_num * sizeof(UINT8))
+ CHECKED_ALLOCZ(s->last_qscale_table , s->mb_num * sizeof(UINT8))
+ CHECKED_ALLOCZ(s->aux_qscale_table , s->mb_num * sizeof(UINT8))
+ s->qscale_table= s->next_qscale_table;
+ s->avctx->qstride= s->mb_width;
/* which mb is a intra block */
CHECKED_ALLOCZ(s->mbintra_table, s->mb_num);
@@ -435,6 +452,8 @@ int MPV_common_init(MpegEncContext *s)
s->block= s->blocks[0];
+ s->parse_context.state= -1;
+
s->context_initialized = 1;
return 0;
fail:
@@ -469,7 +488,9 @@ void MPV_common_end(MpegEncContext *s)
av_freep(&s->mbintra_table);
av_freep(&s->cbp_table);
av_freep(&s->pred_dir_table);
- av_freep(&s->qscale_table);
+ av_freep(&s->next_qscale_table);
+ av_freep(&s->last_qscale_table);
+ av_freep(&s->aux_qscale_table);
av_freep(&s->me_scratchpad);
av_freep(&s->me_map);
av_freep(&s->me_score_map);
@@ -678,6 +699,8 @@ int MPV_encode_init(AVCodecContext *avctx)
if(!done){
int i;
done=1;
+
+ default_mv_penalty= av_mallocz( sizeof(UINT16)*(MAX_FCODE+1)*(2*MAX_MV+1) );
memset(default_mv_penalty, 0, sizeof(UINT16)*(MAX_FCODE+1)*(2*MAX_MV+1));
memset(default_fcode_tab , 0, sizeof(UINT8)*(2*MAX_MV+1));
@@ -700,12 +723,14 @@ int MPV_encode_init(AVCodecContext *avctx)
if (MPV_common_init(s) < 0)
return -1;
+#ifdef CONFIG_ENCODERS
if (s->out_format == FMT_H263)
h263_encode_init(s);
else if (s->out_format == FMT_MPEG1)
ff_mpeg1_encode_init(s);
if(s->msmpeg4_version)
ff_msmpeg4_encode_init(s);
+#endif
/* init default q matrix */
for(i=0;i<64;i++) {
@@ -824,6 +849,9 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
s->current_picture[i] = s->aux_picture[i];
}
+ s->avctx->display_qscale_table=
+ s->avctx->current_qscale_table=
+ s->qscale_table= s->aux_qscale_table;
} else {
for(i=0;i<3;i++) {
/* swap next and last */
@@ -847,6 +875,9 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
else
avctx->dr_opaque_frame= s->next_dr_opaque;
}
+ s->avctx->current_qscale_table= s->qscale_table = s->last_qscale_table;
+ s->avctx->display_qscale_table= s->last_qscale_table = s->next_qscale_table;
+ s->next_qscale_table= s->qscale_table;
}
/* set dequantizer, we cant do it during init as it might change for mpeg4
and we cant do it in the header decode as init isnt called for mpeg4 there yet */
@@ -972,9 +1003,9 @@ int MPV_encode_picture(AVCodecContext *avctx,
init_put_bits(&s->pb, buf, buf_size, NULL, NULL);
- if(avctx->flags&CODEC_FLAG_TYPE){
+ if(avctx->force_type){
s->input_pict_type=
- s->force_input_type= avctx->key_frame ? I_TYPE : P_TYPE;
+ s->force_input_type= avctx->force_type;
}else if(s->flags&CODEC_FLAG_PASS2){
s->input_pict_type=
s->force_input_type= s->rc_context.entry[s->input_picture_number].new_pict_type;
@@ -1109,17 +1140,17 @@ static inline void gmc1_motion(MpegEncContext *s,
}
if((motion_x|motion_y)&7){
- ff_gmc1(dest_y , ptr , linesize, 16, motion_x&15, motion_y&15, 128 - s->no_rounding);
- ff_gmc1(dest_y+8, ptr+8, linesize, 16, motion_x&15, motion_y&15, 128 - s->no_rounding);
+ s->dsp.gmc1(dest_y , ptr , linesize, 16, motion_x&15, motion_y&15, 128 - s->no_rounding);
+ s->dsp.gmc1(dest_y+8, ptr+8, linesize, 16, motion_x&15, motion_y&15, 128 - s->no_rounding);
}else{
int dxy;
dxy= ((motion_x>>3)&1) | ((motion_y>>2)&2);
if (s->no_rounding){
- put_no_rnd_pixels_tab[0][dxy](dest_y, ptr, linesize, 16);
+ s->dsp.put_no_rnd_pixels_tab[0][dxy](dest_y, ptr, linesize, 16);
}else{
- put_pixels_tab [0][dxy](dest_y, ptr, linesize, 16);
- }
+ s->dsp.put_pixels_tab [0][dxy](dest_y, ptr, linesize, 16);
+ }
}
if(s->flags&CODEC_FLAG_GRAY) return;
@@ -1143,14 +1174,14 @@ static inline void gmc1_motion(MpegEncContext *s,
emulated_edge_mc(s, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
ptr= s->edge_emu_buffer;
}
- ff_gmc1(dest_cb + (dest_offset>>1), ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->no_rounding);
+ s->dsp.gmc1(dest_cb + (dest_offset>>1), ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->no_rounding);
ptr = ref_picture[2] + offset;
if(emu){
emulated_edge_mc(s, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
ptr= s->edge_emu_buffer;
}
- ff_gmc1(dest_cr + (dest_offset>>1), ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->no_rounding);
+ s->dsp.gmc1(dest_cr + (dest_offset>>1), ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->no_rounding);
return;
}
@@ -1175,14 +1206,14 @@ static inline void gmc_motion(MpegEncContext *s,
ox= s->sprite_offset[0][0] + s->sprite_delta[0][0]*s->mb_x*16 + s->sprite_delta[0][1]*s->mb_y*16;
oy= s->sprite_offset[0][1] + s->sprite_delta[1][0]*s->mb_x*16 + s->sprite_delta[1][1]*s->mb_y*16;
- ff_gmc(dest_y, ptr, linesize, 16,
+ s->dsp.gmc(dest_y, ptr, linesize, 16,
ox,
oy,
s->sprite_delta[0][0], s->sprite_delta[0][1],
s->sprite_delta[1][0], s->sprite_delta[1][1],
a+1, (1<<(2*a+1)) - s->no_rounding,
s->h_edge_pos, s->v_edge_pos);
- ff_gmc(dest_y+8, ptr, linesize, 16,
+ s->dsp.gmc(dest_y+8, ptr, linesize, 16,
ox + s->sprite_delta[0][0]*8,
oy + s->sprite_delta[1][0]*8,
s->sprite_delta[0][0], s->sprite_delta[0][1],
@@ -1200,7 +1231,7 @@ static inline void gmc_motion(MpegEncContext *s,
oy= s->sprite_offset[1][1] + s->sprite_delta[1][0]*s->mb_x*8 + s->sprite_delta[1][1]*s->mb_y*8;
ptr = ref_picture[1] + (src_offset>>1);
- ff_gmc(dest_cb, ptr, uvlinesize, 8,
+ s->dsp.gmc(dest_cb, ptr, uvlinesize, 8,
ox,
oy,
s->sprite_delta[0][0], s->sprite_delta[0][1],
@@ -1209,7 +1240,7 @@ static inline void gmc_motion(MpegEncContext *s,
s->h_edge_pos>>1, s->v_edge_pos>>1);
ptr = ref_picture[2] + (src_offset>>1);
- ff_gmc(dest_cr, ptr, uvlinesize, 8,
+ s->dsp.gmc(dest_cr, ptr, uvlinesize, 8,
ox,
oy,
s->sprite_delta[0][0], s->sprite_delta[0][1],
@@ -1224,7 +1255,7 @@ static void emulated_edge_mc(MpegEncContext *s, UINT8 *src, int linesize, int bl
int x, y;
int start_y, start_x, end_y, end_x;
UINT8 *buf= s->edge_emu_buffer;
-
+
if(src_y>= h){
src+= (h-1-src_y)*linesize;
src_y=h-1;
@@ -1240,10 +1271,10 @@ static void emulated_edge_mc(MpegEncContext *s, UINT8 *src, int linesize, int bl
src_x=1-block_w;
}
- start_y= MAX(0, -src_y);
- start_x= MAX(0, -src_x);
- end_y= MIN(block_h, h-src_y);
- end_x= MIN(block_w, w-src_x);
+ start_y= FFMAX(0, -src_y);
+ start_x= FFMAX(0, -src_x);
+ end_y= FFMIN(block_h, h-src_y);
+ end_x= FFMIN(block_w, w-src_x);
// copy existing part
for(y=start_y; y<end_y; y++){
@@ -1728,14 +1759,6 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
mb_x = s->mb_x;
mb_y = s->mb_y;
-#ifdef FF_POSTPROCESS
- /* Obsolete. Exists for compatibility with mplayer only. */
- quant_store[mb_y][mb_x]=s->qscale;
- //printf("[%02d][%02d] %d\n",mb_x,mb_y,s->qscale);
-#else
- /* even more obsolete, exists for mplayer xp only */
- if(s->avctx->quant_store) s->avctx->quant_store[mb_y*s->avctx->qstride+mb_x] = s->qscale;
-#endif
s->qscale_table[mb_xy]= s->qscale;
/* update DC predictors for P macroblocks */
@@ -1815,7 +1838,7 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
/* if previous was skipped too, then nothing to do !
skip only during decoding as we might trash the buffers during encoding a bit */
if (*mbskip_ptr >= s->ip_buffer_count && !s->encoding)
- goto the_end;
+ return;
} else {
*mbskip_ptr = 0; /* not skipped */
}
@@ -1844,17 +1867,17 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
/* decoding or more than one mb_type (MC was allready done otherwise) */
if((!s->encoding) || (s->mb_type[mb_xy]&(s->mb_type[mb_xy]-1))){
if ((!s->no_rounding) || s->pict_type==B_TYPE){
- op_pix = put_pixels_tab;
- op_qpix= put_qpel_pixels_tab;
+ op_pix = s->dsp.put_pixels_tab;
+ op_qpix= s->dsp.put_qpel_pixels_tab;
}else{
- op_pix = put_no_rnd_pixels_tab;
- op_qpix= put_no_rnd_qpel_pixels_tab;
+ op_pix = s->dsp.put_no_rnd_pixels_tab;
+ op_qpix= s->dsp.put_no_rnd_qpel_pixels_tab;
}
if (s->mv_dir & MV_DIR_FORWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture, op_pix, op_qpix);
- op_pix = avg_pixels_tab;
- op_qpix= avg_qpel_pixels_tab;
+ op_pix = s->dsp.avg_pixels_tab;
+ op_qpix= s->dsp.avg_qpel_pixels_tab;
}
if (s->mv_dir & MV_DIR_BACKWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture, op_pix, op_qpix);
@@ -1862,7 +1885,7 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
}
/* skip dequant / idct if we are really late ;) */
- if(s->hurry_up>1) goto the_end;
+ if(s->hurry_up>1) return;
/* add dct residue */
if(s->encoding || !( s->mpeg2 || s->h263_msmpeg4 || s->codec_id==CODEC_ID_MPEG1VIDEO
@@ -1912,8 +1935,6 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
}
}
}
- the_end:
- emms_c(); //FIXME remove
}
static inline void dct_single_coeff_elimination(MpegEncContext *s, int n, int threshold)
@@ -2143,6 +2164,8 @@ void ff_draw_horiz_band(MpegEncContext *s){
src_ptr[1] = s->last_picture[1] + (offset >> 2);
src_ptr[2] = s->last_picture[2] + (offset >> 2);
}
+ emms_c();
+
s->avctx->draw_horiz_band(s->avctx, src_ptr, s->linesize,
y, s->width, h);
}
@@ -2208,10 +2231,10 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
s->interlaced_dct=0;
}
- get_pixels(s->block[0], ptr , wrap_y);
- get_pixels(s->block[1], ptr + 8, wrap_y);
- get_pixels(s->block[2], ptr + dct_offset , wrap_y);
- get_pixels(s->block[3], ptr + dct_offset + 8, wrap_y);
+ s->dsp.get_pixels(s->block[0], ptr , wrap_y);
+ s->dsp.get_pixels(s->block[1], ptr + 8, wrap_y);
+ s->dsp.get_pixels(s->block[2], ptr + dct_offset , wrap_y);
+ s->dsp.get_pixels(s->block[3], ptr + dct_offset + 8, wrap_y);
if(s->flags&CODEC_FLAG_GRAY){
skip_dct[4]= 1;
@@ -2223,14 +2246,14 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
emulated_edge_mc(s, ptr, wrap_c, 8, 8, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
ptr= s->edge_emu_buffer;
}
- get_pixels(s->block[4], ptr, wrap_c);
+ s->dsp.get_pixels(s->block[4], ptr, wrap_c);
ptr = s->new_picture[2] + (mb_y * 8 * wrap_c) + mb_x * 8;
if(emu){
emulated_edge_mc(s, ptr, wrap_c, 8, 8, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
ptr= s->edge_emu_buffer;
}
- get_pixels(s->block[5], ptr, wrap_c);
+ s->dsp.get_pixels(s->block[5], ptr, wrap_c);
}
}else{
op_pixels_func (*op_pix)[4];
@@ -2250,17 +2273,17 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
ptr_cr = s->new_picture[2] + (mb_y * 8 * wrap_c) + mb_x * 8;
if ((!s->no_rounding) || s->pict_type==B_TYPE){
- op_pix = put_pixels_tab;
- op_qpix= put_qpel_pixels_tab;
+ op_pix = s->dsp.put_pixels_tab;
+ op_qpix= s->dsp.put_qpel_pixels_tab;
}else{
- op_pix = put_no_rnd_pixels_tab;
- op_qpix= put_no_rnd_qpel_pixels_tab;
+ op_pix = s->dsp.put_no_rnd_pixels_tab;
+ op_qpix= s->dsp.put_no_rnd_qpel_pixels_tab;
}
if (s->mv_dir & MV_DIR_FORWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture, op_pix, op_qpix);
- op_pix = avg_pixels_tab;
- op_qpix= avg_qpel_pixels_tab;
+ op_pix = s->dsp.avg_pixels_tab;
+ op_qpix= s->dsp.avg_qpel_pixels_tab;
}
if (s->mv_dir & MV_DIR_BACKWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture, op_pix, op_qpix);
@@ -2289,10 +2312,10 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
s->interlaced_dct=0;
}
- diff_pixels(s->block[0], ptr_y , dest_y , wrap_y);
- diff_pixels(s->block[1], ptr_y + 8, dest_y + 8, wrap_y);
- diff_pixels(s->block[2], ptr_y + dct_offset , dest_y + dct_offset , wrap_y);
- diff_pixels(s->block[3], ptr_y + dct_offset + 8, dest_y + dct_offset + 8, wrap_y);
+ s->dsp.diff_pixels(s->block[0], ptr_y , dest_y , wrap_y);
+ s->dsp.diff_pixels(s->block[1], ptr_y + 8, dest_y + 8, wrap_y);
+ s->dsp.diff_pixels(s->block[2], ptr_y + dct_offset , dest_y + dct_offset , wrap_y);
+ s->dsp.diff_pixels(s->block[3], ptr_y + dct_offset + 8, dest_y + dct_offset + 8, wrap_y);
if(s->flags&CODEC_FLAG_GRAY){
skip_dct[4]= 1;
@@ -2302,23 +2325,23 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
emulated_edge_mc(s, ptr_cb, wrap_c, 8, 8, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
ptr_cb= s->edge_emu_buffer;
}
- diff_pixels(s->block[4], ptr_cb, dest_cb, wrap_c);
+ s->dsp.diff_pixels(s->block[4], ptr_cb, dest_cb, wrap_c);
if(emu){
emulated_edge_mc(s, ptr_cr, wrap_c, 8, 8, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
ptr_cr= s->edge_emu_buffer;
}
- diff_pixels(s->block[5], ptr_cr, dest_cr, wrap_c);
+ s->dsp.diff_pixels(s->block[5], ptr_cr, dest_cr, wrap_c);
}
/* pre quantization */
if(s->mc_mb_var[s->mb_width*mb_y+ mb_x]<2*s->qscale*s->qscale){
//FIXME optimize
- if(pix_abs8x8(ptr_y , dest_y , wrap_y) < 20*s->qscale) skip_dct[0]= 1;
- if(pix_abs8x8(ptr_y + 8, dest_y + 8, wrap_y) < 20*s->qscale) skip_dct[1]= 1;
- if(pix_abs8x8(ptr_y +dct_offset , dest_y +dct_offset , wrap_y) < 20*s->qscale) skip_dct[2]= 1;
- if(pix_abs8x8(ptr_y +dct_offset+ 8, dest_y +dct_offset+ 8, wrap_y) < 20*s->qscale) skip_dct[3]= 1;
- if(pix_abs8x8(ptr_cb , dest_cb , wrap_y) < 20*s->qscale) skip_dct[4]= 1;
- if(pix_abs8x8(ptr_cr , dest_cr , wrap_y) < 20*s->qscale) skip_dct[5]= 1;
+ if(s->dsp.pix_abs8x8(ptr_y , dest_y , wrap_y) < 20*s->qscale) skip_dct[0]= 1;
+ if(s->dsp.pix_abs8x8(ptr_y + 8, dest_y + 8, wrap_y) < 20*s->qscale) skip_dct[1]= 1;
+ if(s->dsp.pix_abs8x8(ptr_y +dct_offset , dest_y +dct_offset , wrap_y) < 20*s->qscale) skip_dct[2]= 1;
+ if(s->dsp.pix_abs8x8(ptr_y +dct_offset+ 8, dest_y +dct_offset+ 8, wrap_y) < 20*s->qscale) skip_dct[3]= 1;
+ if(s->dsp.pix_abs8x8(ptr_cb , dest_cb , wrap_y) < 20*s->qscale) skip_dct[4]= 1;
+ if(s->dsp.pix_abs8x8(ptr_cr , dest_cr , wrap_y) < 20*s->qscale) skip_dct[5]= 1;
#if 0
{
static int stat[7];
@@ -2385,6 +2408,7 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
s->block[5][0]= 128;
}
+#ifdef CONFIG_ENCODERS
/* huffman encode */
switch(s->out_format) {
case FMT_MPEG1:
@@ -2402,6 +2426,7 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
mjpeg_encode_mb(s, s->block);
break;
}
+#endif
}
void ff_copy_bits(PutBitContext *pb, UINT8 *src, int length)
@@ -2568,7 +2593,6 @@ static void encode_picture(MpegEncContext *s, int picture_number)
// s->mb_type[mb_y*s->mb_width + mb_x]=MB_TYPE_INTER;
}
}
- emms_c();
}else /* if(s->pict_type == I_TYPE) */{
/* I-Frame */
//FIXME do we need to zero them?
@@ -2584,18 +2608,19 @@ static void encode_picture(MpegEncContext *s, int picture_number)
int yy = mb_y * 16;
uint8_t *pix = s->new_picture[0] + (yy * s->linesize) + xx;
int varc;
- int sum = pix_sum(pix, s->linesize);
+ int sum = s->dsp.pix_sum(pix, s->linesize);
- sum= (sum+8)>>4;
- varc = (pix_norm1(pix, s->linesize) - sum*sum + 500 + 128)>>8;
+ varc = (s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500 + 128)>>8;
s->mb_var [s->mb_width * mb_y + mb_x] = varc;
- s->mb_mean[s->mb_width * mb_y + mb_x] = (sum+7)>>4;
+ s->mb_mean[s->mb_width * mb_y + mb_x] = (sum+128)>>8;
s->mb_var_sum += varc;
}
}
}
}
+ emms_c();
+
if(s->scene_change_score > 0 && s->pict_type == P_TYPE){
s->pict_type= I_TYPE;
memset(s->mb_type , MB_TYPE_INTRA, sizeof(UINT8)*s->mb_width*s->mb_height);
@@ -3001,7 +3026,7 @@ static int dct_quantize_c(MpegEncContext *s,
int bias;
int max=0;
unsigned int threshold1, threshold2;
-
+
s->fdct (block);
if (s->mb_intra) {