comparison mpegvideo.c @ 2256:7e0b2e86afa9 libavcodec

1/2 resolution decoding
author michael
date Sat, 25 Sep 2004 23:18:58 +0000
parents ab849bab3472
children 33835650f5b6
comparison
equal deleted inserted replaced
2255:507690ff49a2 2256:7e0b2e86afa9
2605 if(!(s->flags&CODEC_FLAG_GRAY)){ 2605 if(!(s->flags&CODEC_FLAG_GRAY)){
2606 pix_op[s->chroma_x_shift][uvdxy](dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift); 2606 pix_op[s->chroma_x_shift][uvdxy](dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift);
2607 pix_op[s->chroma_x_shift][uvdxy](dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift); 2607 pix_op[s->chroma_x_shift][uvdxy](dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift);
2608 } 2608 }
2609 } 2609 }
2610
2611 /* apply one mpeg motion vector to the three components */
2612 static always_inline void mpeg_motion_lowres(MpegEncContext *s,
2613 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
2614 int field_based, int bottom_field, int field_select,
2615 uint8_t **ref_picture, h264_chroma_mc_func *pix_op,
2616 int motion_x, int motion_y, int h)
2617 {
2618 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
2619 int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, uvlinesize, linesize, sx, sy, uvsx, uvsy;
2620 const int lowres= s->avctx->lowres;
2621 const int block_s= 8>>lowres;
2622 const int s_mask= (2<<lowres)-1;
2623 const int h_edge_pos = s->h_edge_pos >> lowres;
2624 const int v_edge_pos = s->v_edge_pos >> lowres;
2625 linesize = s->current_picture.linesize[0] << field_based;
2626 uvlinesize = s->current_picture.linesize[1] << field_based;
2627
2628 sx= motion_x & s_mask;
2629 sy= motion_y & s_mask;
2630 src_x = s->mb_x*2*block_s + (motion_x >> (lowres+1));
2631 src_y = s->mb_y*2*block_s + (motion_y >> (lowres+1));
2632
2633 if (s->out_format == FMT_H263) {
2634 uvsx = sx | ((motion_x & 2)>>1);
2635 uvsy = sy | ((motion_y & 2)>>1);
2636 uvsrc_x = src_x>>1;
2637 uvsrc_y = src_y>>1;
2638 }else if(s->out_format == FMT_H261){//even chroma mv's are full pel in H261
2639 mx = motion_x / 4;
2640 my = motion_y / 4;
2641 uvsx = (2*mx) & s_mask;
2642 uvsy = (2*my) & s_mask;
2643 uvsrc_x = s->mb_x*block_s + (mx >> lowres);
2644 uvsrc_y = s->mb_y*block_s + (my >> lowres);
2645 } else {
2646 mx = motion_x / 2;
2647 my = motion_y / 2;
2648 uvsx = mx & s_mask;
2649 uvsy = my & s_mask;
2650 uvsrc_x = s->mb_x*block_s + (mx >> (lowres+1));
2651 uvsrc_y = s->mb_y*block_s + (my >> (lowres+1));
2652 }
2653
2654 ptr_y = ref_picture[0] + src_y * linesize + src_x;
2655 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
2656 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
2657
2658 if( (unsigned)src_x > h_edge_pos - (!!sx) - 2*block_s
2659 || (unsigned)src_y >(v_edge_pos >> field_based) - (!!sy) - h){
2660 ff_emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize, 17, 17+field_based,
2661 src_x, src_y<<field_based, h_edge_pos, v_edge_pos);
2662 ptr_y = s->edge_emu_buffer;
2663 if(!(s->flags&CODEC_FLAG_GRAY)){
2664 uint8_t *uvbuf= s->edge_emu_buffer+18*s->linesize;
2665 ff_emulated_edge_mc(uvbuf , ptr_cb, s->uvlinesize, 9, 9+field_based,
2666 uvsrc_x, uvsrc_y<<field_based, h_edge_pos>>1, v_edge_pos>>1);
2667 ff_emulated_edge_mc(uvbuf+16, ptr_cr, s->uvlinesize, 9, 9+field_based,
2668 uvsrc_x, uvsrc_y<<field_based, h_edge_pos>>1, v_edge_pos>>1);
2669 ptr_cb= uvbuf;
2670 ptr_cr= uvbuf+16;
2671 }
2672 }
2673
2674 sx <<= 2 - lowres;
2675 sy <<= 2 - lowres;
2676 pix_op[lowres-1](dest_y, ptr_y, linesize, h, sx, sy);
2677
2678 if(!(s->flags&CODEC_FLAG_GRAY)){
2679 uvsx <<= 2 - lowres;
2680 uvsy <<= 2 - lowres;
2681 pix_op[lowres](dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy);
2682 pix_op[lowres](dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy);
2683 }
2684 }
2685
2610 //FIXME move to dsputil, avg variant, 16x16 version 2686 //FIXME move to dsputil, avg variant, 16x16 version
2611 static inline void put_obmc(uint8_t *dst, uint8_t *src[5], int stride){ 2687 static inline void put_obmc(uint8_t *dst, uint8_t *src[5], int stride){
2612 int x; 2688 int x;
2613 uint8_t * const top = src[1]; 2689 uint8_t * const top = src[1];
2614 uint8_t * const left = src[2]; 2690 uint8_t * const left = src[2];
3083 break; 3159 break;
3084 default: assert(0); 3160 default: assert(0);
3085 } 3161 }
3086 } 3162 }
3087 3163
3164 /**
3165 * motion compesation of a single macroblock
3166 * @param s context
3167 * @param dest_y luma destination pointer
3168 * @param dest_cb chroma cb/u destination pointer
3169 * @param dest_cr chroma cr/v destination pointer
3170 * @param dir direction (0->forward, 1->backward)
3171 * @param ref_picture array[3] of pointers to the 3 planes of the reference picture
3172 * @param pic_op halfpel motion compensation function (average or put normally)
3173 * the motion vectors are taken from s->mv and the MV type from s->mv_type
3174 */
3175 static inline void MPV_motion_lowres(MpegEncContext *s,
3176 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
3177 int dir, uint8_t **ref_picture,
3178 h264_chroma_mc_func *pix_op)
3179 {
3180 assert(s->mv_type == MV_TYPE_16X16);
3181 mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
3182 0, 0, 0,
3183 ref_picture, pix_op,
3184 s->mv[dir][0][0], s->mv[dir][0][1], 16>>s->avctx->lowres);
3185 }
3088 3186
3089 /* put block[] to dest[] */ 3187 /* put block[] to dest[] */
3090 static inline void put_dct(MpegEncContext *s, 3188 static inline void put_dct(MpegEncContext *s,
3091 DCTELEM *block, int i, uint8_t *dest, int line_size, int qscale) 3189 DCTELEM *block, int i, uint8_t *dest, int line_size, int qscale)
3092 { 3190 {
3154 s->mv_dir : motion vector direction 3252 s->mv_dir : motion vector direction
3155 s->mv_type : motion vector type 3253 s->mv_type : motion vector type
3156 s->mv : motion vector 3254 s->mv : motion vector
3157 s->interlaced_dct : true if interlaced dct used (mpeg2) 3255 s->interlaced_dct : true if interlaced dct used (mpeg2)
3158 */ 3256 */
3159 void MPV_decode_mb(MpegEncContext *s, DCTELEM block[12][64]) 3257 static always_inline void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64], int lowres_flag)
3160 { 3258 {
3161 int mb_x, mb_y; 3259 int mb_x, mb_y;
3162 const int mb_xy = s->mb_y * s->mb_stride + s->mb_x; 3260 const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
3163 #ifdef HAVE_XVMC 3261 #ifdef HAVE_XVMC
3164 if(s->avctx->xvmc_acceleration){ 3262 if(s->avctx->xvmc_acceleration){
3200 int dct_linesize, dct_offset; 3298 int dct_linesize, dct_offset;
3201 op_pixels_func (*op_pix)[4]; 3299 op_pixels_func (*op_pix)[4];
3202 qpel_mc_func (*op_qpix)[16]; 3300 qpel_mc_func (*op_qpix)[16];
3203 const int linesize= s->current_picture.linesize[0]; //not s->linesize as this woulnd be wrong for field pics 3301 const int linesize= s->current_picture.linesize[0]; //not s->linesize as this woulnd be wrong for field pics
3204 const int uvlinesize= s->current_picture.linesize[1]; 3302 const int uvlinesize= s->current_picture.linesize[1];
3205 const int readable= s->pict_type != B_TYPE || s->encoding || s->avctx->draw_horiz_band; 3303 const int readable= s->pict_type != B_TYPE || s->encoding || s->avctx->draw_horiz_band || lowres_flag;
3304 const int block_size= lowres_flag ? 8>>s->avctx->lowres : 8;
3206 3305
3207 /* avoid copy if macroblock skipped in last frame too */ 3306 /* avoid copy if macroblock skipped in last frame too */
3208 /* skip only during decoding as we might trash the buffers during encoding a bit */ 3307 /* skip only during decoding as we might trash the buffers during encoding a bit */
3209 if(!s->encoding){ 3308 if(!s->encoding){
3210 uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy]; 3309 uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
3228 if(*mbskip_ptr >99) *mbskip_ptr= 99; 3327 if(*mbskip_ptr >99) *mbskip_ptr= 99;
3229 } else{ 3328 } else{
3230 *mbskip_ptr = 0; /* not skipped */ 3329 *mbskip_ptr = 0; /* not skipped */
3231 } 3330 }
3232 } 3331 }
3233 3332
3234 dct_linesize = linesize << s->interlaced_dct; 3333 dct_linesize = linesize << s->interlaced_dct;
3235 dct_offset =(s->interlaced_dct)? linesize : linesize*8; 3334 dct_offset =(s->interlaced_dct)? linesize : linesize*block_size;
3236 3335
3237 if(readable){ 3336 if(readable){
3238 dest_y= s->dest[0]; 3337 dest_y= s->dest[0];
3239 dest_cb= s->dest[1]; 3338 dest_cb= s->dest[1];
3240 dest_cr= s->dest[2]; 3339 dest_cr= s->dest[2];
3241 }else{ 3340 }else{
3242 dest_y = s->b_scratchpad; 3341 dest_y = s->b_scratchpad;
3243 dest_cb= s->b_scratchpad+16*linesize; 3342 dest_cb= s->b_scratchpad+16*linesize;
3244 dest_cr= s->b_scratchpad+32*linesize; 3343 dest_cr= s->b_scratchpad+32*linesize;
3245 } 3344 }
3345
3246 if (!s->mb_intra) { 3346 if (!s->mb_intra) {
3247 /* motion handling */ 3347 /* motion handling */
3248 /* decoding or more than one mb_type (MC was allready done otherwise) */ 3348 /* decoding or more than one mb_type (MC was allready done otherwise) */
3249 if(!s->encoding){ 3349 if(!s->encoding){
3250 if ((!s->no_rounding) || s->pict_type==B_TYPE){ 3350 if(lowres_flag){
3251 op_pix = s->dsp.put_pixels_tab; 3351 h264_chroma_mc_func *op_pix = s->dsp.put_h264_chroma_pixels_tab;
3252 op_qpix= s->dsp.put_qpel_pixels_tab; 3352
3353 if (s->mv_dir & MV_DIR_FORWARD) {
3354 MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.data, op_pix);
3355 op_pix = s->dsp.avg_h264_chroma_pixels_tab;
3356 }
3357 if (s->mv_dir & MV_DIR_BACKWARD) {
3358 MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix);
3359 }
3253 }else{ 3360 }else{
3254 op_pix = s->dsp.put_no_rnd_pixels_tab; 3361 if ((!s->no_rounding) || s->pict_type==B_TYPE){
3255 op_qpix= s->dsp.put_no_rnd_qpel_pixels_tab; 3362 op_pix = s->dsp.put_pixels_tab;
3256 } 3363 op_qpix= s->dsp.put_qpel_pixels_tab;
3257 3364 }else{
3258 if (s->mv_dir & MV_DIR_FORWARD) { 3365 op_pix = s->dsp.put_no_rnd_pixels_tab;
3259 MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.data, op_pix, op_qpix); 3366 op_qpix= s->dsp.put_no_rnd_qpel_pixels_tab;
3260 op_pix = s->dsp.avg_pixels_tab; 3367 }
3261 op_qpix= s->dsp.avg_qpel_pixels_tab; 3368 if (s->mv_dir & MV_DIR_FORWARD) {
3262 } 3369 MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.data, op_pix, op_qpix);
3263 if (s->mv_dir & MV_DIR_BACKWARD) { 3370 op_pix = s->dsp.avg_pixels_tab;
3264 MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix, op_qpix); 3371 op_qpix= s->dsp.avg_qpel_pixels_tab;
3372 }
3373 if (s->mv_dir & MV_DIR_BACKWARD) {
3374 MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix, op_qpix);
3375 }
3265 } 3376 }
3266 } 3377 }
3267 3378
3268 /* skip dequant / idct if we are really late ;) */ 3379 /* skip dequant / idct if we are really late ;) */
3269 if(s->hurry_up>1) return; 3380 if(s->hurry_up>1) return;
3270 3381
3271 /* add dct residue */ 3382 /* add dct residue */
3272 if(s->encoding || !( s->h263_msmpeg4 || s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO 3383 if(s->encoding || !( s->h263_msmpeg4 || s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO
3273 || (s->codec_id==CODEC_ID_MPEG4 && !s->mpeg_quant))){ 3384 || (s->codec_id==CODEC_ID_MPEG4 && !s->mpeg_quant))){
3274 add_dequant_dct(s, block[0], 0, dest_y, dct_linesize, s->qscale); 3385 add_dequant_dct(s, block[0], 0, dest_y , dct_linesize, s->qscale);
3275 add_dequant_dct(s, block[1], 1, dest_y + 8, dct_linesize, s->qscale); 3386 add_dequant_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->qscale);
3276 add_dequant_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize, s->qscale); 3387 add_dequant_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->qscale);
3277 add_dequant_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize, s->qscale); 3388 add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
3278 3389
3279 if(!(s->flags&CODEC_FLAG_GRAY)){ 3390 if(!(s->flags&CODEC_FLAG_GRAY)){
3280 add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale); 3391 add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
3281 add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale); 3392 add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
3282 } 3393 }
3283 } else if(s->codec_id != CODEC_ID_WMV2){ 3394 } else if(s->codec_id != CODEC_ID_WMV2){
3284 add_dct(s, block[0], 0, dest_y, dct_linesize); 3395 add_dct(s, block[0], 0, dest_y , dct_linesize);
3285 add_dct(s, block[1], 1, dest_y + 8, dct_linesize); 3396 add_dct(s, block[1], 1, dest_y + block_size, dct_linesize);
3286 add_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize); 3397 add_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize);
3287 add_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize); 3398 add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
3288 3399
3289 if(!(s->flags&CODEC_FLAG_GRAY)){ 3400 if(!(s->flags&CODEC_FLAG_GRAY)){
3290 if(s->chroma_y_shift){//Chroma420 3401 if(s->chroma_y_shift){//Chroma420
3291 add_dct(s, block[4], 4, dest_cb, uvlinesize); 3402 add_dct(s, block[4], 4, dest_cb, uvlinesize);
3292 add_dct(s, block[5], 5, dest_cr, uvlinesize); 3403 add_dct(s, block[5], 5, dest_cr, uvlinesize);
3314 } 3425 }
3315 #endif 3426 #endif
3316 } else { 3427 } else {
3317 /* dct only in intra block */ 3428 /* dct only in intra block */
3318 if(s->encoding || !(s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO)){ 3429 if(s->encoding || !(s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO)){
3319 put_dct(s, block[0], 0, dest_y, dct_linesize, s->qscale); 3430 put_dct(s, block[0], 0, dest_y , dct_linesize, s->qscale);
3320 put_dct(s, block[1], 1, dest_y + 8, dct_linesize, s->qscale); 3431 put_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->qscale);
3321 put_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize, s->qscale); 3432 put_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->qscale);
3322 put_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize, s->qscale); 3433 put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
3323 3434
3324 if(!(s->flags&CODEC_FLAG_GRAY)){ 3435 if(!(s->flags&CODEC_FLAG_GRAY)){
3325 put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale); 3436 put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
3326 put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale); 3437 put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
3327 } 3438 }
3328 }else{ 3439 }else{
3329 s->dsp.idct_put(dest_y , dct_linesize, block[0]); 3440 s->dsp.idct_put(dest_y , dct_linesize, block[0]);
3330 s->dsp.idct_put(dest_y + 8, dct_linesize, block[1]); 3441 s->dsp.idct_put(dest_y + block_size, dct_linesize, block[1]);
3331 s->dsp.idct_put(dest_y + dct_offset , dct_linesize, block[2]); 3442 s->dsp.idct_put(dest_y + dct_offset , dct_linesize, block[2]);
3332 s->dsp.idct_put(dest_y + dct_offset + 8, dct_linesize, block[3]); 3443 s->dsp.idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
3333 3444
3334 if(!(s->flags&CODEC_FLAG_GRAY)){ 3445 if(!(s->flags&CODEC_FLAG_GRAY)){
3335 if(s->chroma_y_shift){ 3446 if(s->chroma_y_shift){
3336 s->dsp.idct_put(dest_cb, uvlinesize, block[4]); 3447 s->dsp.idct_put(dest_cb, uvlinesize, block[4]);
3337 s->dsp.idct_put(dest_cr, uvlinesize, block[5]); 3448 s->dsp.idct_put(dest_cr, uvlinesize, block[5]);
3358 s->dsp.put_pixels_tab[0][0](s->dest[0], dest_y , linesize,16); 3469 s->dsp.put_pixels_tab[0][0](s->dest[0], dest_y , linesize,16);
3359 s->dsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[1], dest_cb, uvlinesize,16 >> s->chroma_y_shift); 3470 s->dsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[1], dest_cb, uvlinesize,16 >> s->chroma_y_shift);
3360 s->dsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[2], dest_cr, uvlinesize,16 >> s->chroma_y_shift); 3471 s->dsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[2], dest_cr, uvlinesize,16 >> s->chroma_y_shift);
3361 } 3472 }
3362 } 3473 }
3474 }
3475
3476 void MPV_decode_mb(MpegEncContext *s, DCTELEM block[12][64]){
3477 if(s->avctx->lowres) MPV_decode_mb_internal(s, block, 1);
3478 else MPV_decode_mb_internal(s, block, 0);
3363 } 3479 }
3364 3480
3365 #ifdef CONFIG_ENCODERS 3481 #ifdef CONFIG_ENCODERS
3366 3482
3367 static inline void dct_single_coeff_elimination(MpegEncContext *s, int n, int threshold) 3483 static inline void dct_single_coeff_elimination(MpegEncContext *s, int n, int threshold)
3490 } 3606 }
3491 3607
3492 void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename 3608 void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename
3493 const int linesize= s->current_picture.linesize[0]; //not s->linesize as this woulnd be wrong for field pics 3609 const int linesize= s->current_picture.linesize[0]; //not s->linesize as this woulnd be wrong for field pics
3494 const int uvlinesize= s->current_picture.linesize[1]; 3610 const int uvlinesize= s->current_picture.linesize[1];
3611 const int mb_size= 4 - s->avctx->lowres;
3495 3612
3496 s->block_index[0]= s->b8_stride*(s->mb_y*2 ) - 2 + s->mb_x*2; 3613 s->block_index[0]= s->b8_stride*(s->mb_y*2 ) - 2 + s->mb_x*2;
3497 s->block_index[1]= s->b8_stride*(s->mb_y*2 ) - 1 + s->mb_x*2; 3614 s->block_index[1]= s->b8_stride*(s->mb_y*2 ) - 1 + s->mb_x*2;
3498 s->block_index[2]= s->b8_stride*(s->mb_y*2 + 1) - 2 + s->mb_x*2; 3615 s->block_index[2]= s->b8_stride*(s->mb_y*2 + 1) - 2 + s->mb_x*2;
3499 s->block_index[3]= s->b8_stride*(s->mb_y*2 + 1) - 1 + s->mb_x*2; 3616 s->block_index[3]= s->b8_stride*(s->mb_y*2 + 1) - 1 + s->mb_x*2;
3500 s->block_index[4]= s->mb_stride*(s->mb_y + 1) + s->b8_stride*s->mb_height*2 + s->mb_x - 1; 3617 s->block_index[4]= s->mb_stride*(s->mb_y + 1) + s->b8_stride*s->mb_height*2 + s->mb_x - 1;
3501 s->block_index[5]= s->mb_stride*(s->mb_y + s->mb_height + 2) + s->b8_stride*s->mb_height*2 + s->mb_x - 1; 3618 s->block_index[5]= s->mb_stride*(s->mb_y + s->mb_height + 2) + s->b8_stride*s->mb_height*2 + s->mb_x - 1;
3502 //block_index is not used by mpeg2, so it is not affected by chroma_format 3619 //block_index is not used by mpeg2, so it is not affected by chroma_format
3503 3620
3504 s->dest[0] = s->current_picture.data[0] + ((s->mb_x - 1) << 4); 3621 s->dest[0] = s->current_picture.data[0] + ((s->mb_x - 1) << mb_size);
3505 s->dest[1] = s->current_picture.data[1] + ((s->mb_x - 1) << (4 - s->chroma_x_shift)); 3622 s->dest[1] = s->current_picture.data[1] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
3506 s->dest[2] = s->current_picture.data[2] + ((s->mb_x - 1) << (4 - s->chroma_x_shift)); 3623 s->dest[2] = s->current_picture.data[2] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
3507 3624
3508 if(!(s->pict_type==B_TYPE && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME)) 3625 if(!(s->pict_type==B_TYPE && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME))
3509 { 3626 {
3510 s->dest[0] += s->mb_y * linesize << 4; 3627 s->dest[0] += s->mb_y * linesize << mb_size;
3511 s->dest[1] += s->mb_y * uvlinesize << (4 - s->chroma_y_shift); 3628 s->dest[1] += s->mb_y * uvlinesize << (mb_size - s->chroma_y_shift);
3512 s->dest[2] += s->mb_y * uvlinesize << (4 - s->chroma_y_shift); 3629 s->dest[2] += s->mb_y * uvlinesize << (mb_size - s->chroma_y_shift);
3513 } 3630 }
3514 } 3631 }
3515 3632
3516 #ifdef CONFIG_ENCODERS 3633 #ifdef CONFIG_ENCODERS
3517 3634