comparison mpegvideo_common.h @ 10604:ce2cf9e32b09 libavcodec

Set mb_y in mpeg2 field pictures like h264 does. This fixes -vismv & -debug 16384 with field pictures.
author michael
date Mon, 30 Nov 2009 19:14:00 +0000
parents 874e26fe2284
children a47f207fe4b5
comparison
equal deleted inserted replaced
10603:874e26fe2284 10604:ce2cf9e32b09
240 static av_always_inline 240 static av_always_inline
241 void mpeg_motion_internal(MpegEncContext *s, 241 void mpeg_motion_internal(MpegEncContext *s,
242 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, 242 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
243 int field_based, int bottom_field, int field_select, 243 int field_based, int bottom_field, int field_select,
244 uint8_t **ref_picture, op_pixels_func (*pix_op)[4], 244 uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
245 int motion_x, int motion_y, int h, int is_mpeg12) 245 int motion_x, int motion_y, int h, int is_mpeg12, int mb_y)
246 { 246 {
247 uint8_t *ptr_y, *ptr_cb, *ptr_cr; 247 uint8_t *ptr_y, *ptr_cb, *ptr_cr;
248 int dxy, uvdxy, mx, my, src_x, src_y, 248 int dxy, uvdxy, mx, my, src_x, src_y,
249 uvsrc_x, uvsrc_y, v_edge_pos, uvlinesize, linesize; 249 uvsrc_x, uvsrc_y, v_edge_pos, uvlinesize, linesize;
250 250
260 linesize = s->current_picture.linesize[0] << field_based; 260 linesize = s->current_picture.linesize[0] << field_based;
261 uvlinesize = s->current_picture.linesize[1] << field_based; 261 uvlinesize = s->current_picture.linesize[1] << field_based;
262 262
263 dxy = ((motion_y & 1) << 1) | (motion_x & 1); 263 dxy = ((motion_y & 1) << 1) | (motion_x & 1);
264 src_x = s->mb_x* 16 + (motion_x >> 1); 264 src_x = s->mb_x* 16 + (motion_x >> 1);
265 src_y =(s->mb_y<<(4-field_based)) + (motion_y >> 1); 265 src_y =( mb_y<<(4-field_based)) + (motion_y >> 1);
266 266
267 if (!is_mpeg12 && s->out_format == FMT_H263) { 267 if (!is_mpeg12 && s->out_format == FMT_H263) {
268 if((s->workaround_bugs & FF_BUG_HPEL_CHROMA) && field_based){ 268 if((s->workaround_bugs & FF_BUG_HPEL_CHROMA) && field_based){
269 mx = (motion_x>>1)|(motion_x&1); 269 mx = (motion_x>>1)|(motion_x&1);
270 my = motion_y >>1; 270 my = motion_y >>1;
271 uvdxy = ((my & 1) << 1) | (mx & 1); 271 uvdxy = ((my & 1) << 1) | (mx & 1);
272 uvsrc_x = s->mb_x* 8 + (mx >> 1); 272 uvsrc_x = s->mb_x* 8 + (mx >> 1);
273 uvsrc_y = (s->mb_y<<(3-field_based)) + (my >> 1); 273 uvsrc_y =( mb_y<<(3-field_based))+ (my >> 1);
274 }else{ 274 }else{
275 uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1); 275 uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
276 uvsrc_x = src_x>>1; 276 uvsrc_x = src_x>>1;
277 uvsrc_y = src_y>>1; 277 uvsrc_y = src_y>>1;
278 } 278 }
279 }else if(!is_mpeg12 && s->out_format == FMT_H261){//even chroma mv's are full pel in H261 279 }else if(!is_mpeg12 && s->out_format == FMT_H261){//even chroma mv's are full pel in H261
280 mx = motion_x / 4; 280 mx = motion_x / 4;
281 my = motion_y / 4; 281 my = motion_y / 4;
282 uvdxy = 0; 282 uvdxy = 0;
283 uvsrc_x = s->mb_x*8 + mx; 283 uvsrc_x = s->mb_x*8 + mx;
284 uvsrc_y = s->mb_y*8 + my; 284 uvsrc_y = mb_y*8 + my;
285 } else { 285 } else {
286 if(s->chroma_y_shift){ 286 if(s->chroma_y_shift){
287 mx = motion_x / 2; 287 mx = motion_x / 2;
288 my = motion_y / 2; 288 my = motion_y / 2;
289 uvdxy = ((my & 1) << 1) | (mx & 1); 289 uvdxy = ((my & 1) << 1) | (mx & 1);
290 uvsrc_x = s->mb_x* 8 + (mx >> 1); 290 uvsrc_x = s->mb_x* 8 + (mx >> 1);
291 uvsrc_y = (s->mb_y<<(3-field_based)) + (my >> 1); 291 uvsrc_y =( mb_y<<(3-field_based))+ (my >> 1);
292 } else { 292 } else {
293 if(s->chroma_x_shift){ 293 if(s->chroma_x_shift){
294 //Chroma422 294 //Chroma422
295 mx = motion_x / 2; 295 mx = motion_x / 2;
296 uvdxy = ((motion_y & 1) << 1) | (mx & 1); 296 uvdxy = ((motion_y & 1) << 1) | (mx & 1);
368 static av_always_inline 368 static av_always_inline
369 void mpeg_motion(MpegEncContext *s, 369 void mpeg_motion(MpegEncContext *s,
370 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, 370 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
371 int field_based, int bottom_field, int field_select, 371 int field_based, int bottom_field, int field_select,
372 uint8_t **ref_picture, op_pixels_func (*pix_op)[4], 372 uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
373 int motion_x, int motion_y, int h) 373 int motion_x, int motion_y, int h, int mb_y)
374 { 374 {
375 #if !CONFIG_SMALL 375 #if !CONFIG_SMALL
376 if(s->out_format == FMT_MPEG1) 376 if(s->out_format == FMT_MPEG1)
377 mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, field_based, 377 mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, field_based,
378 bottom_field, field_select, ref_picture, pix_op, 378 bottom_field, field_select, ref_picture, pix_op,
379 motion_x, motion_y, h, 1); 379 motion_x, motion_y, h, 1, mb_y);
380 else 380 else
381 #endif 381 #endif
382 mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, field_based, 382 mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, field_based,
383 bottom_field, field_select, ref_picture, pix_op, 383 bottom_field, field_select, ref_picture, pix_op,
384 motion_x, motion_y, h, 0); 384 motion_x, motion_y, h, 0, mb_y);
385 } 385 }
386 386
387 //FIXME move to dsputil, avg variant, 16x16 version 387 //FIXME move to dsputil, avg variant, 16x16 version
388 static inline void put_obmc(uint8_t *dst, uint8_t *src[5], int stride){ 388 static inline void put_obmc(uint8_t *dst, uint8_t *src[5], int stride){
389 int x; 389 int x;
734 }else 734 }else
735 { 735 {
736 mpeg_motion(s, dest_y, dest_cb, dest_cr, 736 mpeg_motion(s, dest_y, dest_cb, dest_cr,
737 0, 0, 0, 737 0, 0, 0,
738 ref_picture, pix_op, 738 ref_picture, pix_op,
739 s->mv[dir][0][0], s->mv[dir][0][1], 16); 739 s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y);
740 } 740 }
741 break; 741 break;
742 case MV_TYPE_8X8: 742 case MV_TYPE_8X8:
743 if (!is_mpeg12) { 743 if (!is_mpeg12) {
744 mx = 0; 744 mx = 0;
808 }else{ 808 }else{
809 /* top field */ 809 /* top field */
810 mpeg_motion(s, dest_y, dest_cb, dest_cr, 810 mpeg_motion(s, dest_y, dest_cb, dest_cr,
811 1, 0, s->field_select[dir][0], 811 1, 0, s->field_select[dir][0],
812 ref_picture, pix_op, 812 ref_picture, pix_op,
813 s->mv[dir][0][0], s->mv[dir][0][1], 8); 813 s->mv[dir][0][0], s->mv[dir][0][1], 8, mb_y);
814 /* bottom field */ 814 /* bottom field */
815 mpeg_motion(s, dest_y, dest_cb, dest_cr, 815 mpeg_motion(s, dest_y, dest_cb, dest_cr,
816 1, 1, s->field_select[dir][1], 816 1, 1, s->field_select[dir][1],
817 ref_picture, pix_op, 817 ref_picture, pix_op,
818 s->mv[dir][1][0], s->mv[dir][1][1], 8); 818 s->mv[dir][1][0], s->mv[dir][1][1], 8, mb_y);
819 } 819 }
820 } else { 820 } else {
821 if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != FF_B_TYPE && !s->first_field){ 821 if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != FF_B_TYPE && !s->first_field){
822 ref_picture= s->current_picture_ptr->data; 822 ref_picture= s->current_picture_ptr->data;
823 } 823 }
824 824
825 mpeg_motion(s, dest_y, dest_cb, dest_cr, 825 mpeg_motion(s, dest_y, dest_cb, dest_cr,
826 0, 0, s->field_select[dir][0], 826 0, 0, s->field_select[dir][0],
827 ref_picture, pix_op, 827 ref_picture, pix_op,
828 s->mv[dir][0][0], s->mv[dir][0][1], 16); 828 s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y>>1);
829 } 829 }
830 break; 830 break;
831 case MV_TYPE_16X8: 831 case MV_TYPE_16X8:
832 for(i=0; i<2; i++){ 832 for(i=0; i<2; i++){
833 uint8_t ** ref2picture; 833 uint8_t ** ref2picture;
840 } 840 }
841 841
842 mpeg_motion(s, dest_y, dest_cb, dest_cr, 842 mpeg_motion(s, dest_y, dest_cb, dest_cr,
843 0, 0, s->field_select[dir][i], 843 0, 0, s->field_select[dir][i],
844 ref2picture, pix_op, 844 ref2picture, pix_op,
845 s->mv[dir][i][0], s->mv[dir][i][1] + 16*i, 8); 845 s->mv[dir][i][0], s->mv[dir][i][1] + 16*i, 8, mb_y>>1);
846 846
847 dest_y += 16*s->linesize; 847 dest_y += 16*s->linesize;
848 dest_cb+= (16>>s->chroma_y_shift)*s->uvlinesize; 848 dest_cb+= (16>>s->chroma_y_shift)*s->uvlinesize;
849 dest_cr+= (16>>s->chroma_y_shift)*s->uvlinesize; 849 dest_cr+= (16>>s->chroma_y_shift)*s->uvlinesize;
850 } 850 }
855 int j; 855 int j;
856 for(j=0; j<2; j++){ 856 for(j=0; j<2; j++){
857 mpeg_motion(s, dest_y, dest_cb, dest_cr, 857 mpeg_motion(s, dest_y, dest_cb, dest_cr,
858 1, j, j^i, 858 1, j, j^i,
859 ref_picture, pix_op, 859 ref_picture, pix_op,
860 s->mv[dir][2*i + j][0], s->mv[dir][2*i + j][1], 8); 860 s->mv[dir][2*i + j][0], s->mv[dir][2*i + j][1], 8, mb_y);
861 } 861 }
862 pix_op = s->dsp.avg_pixels_tab; 862 pix_op = s->dsp.avg_pixels_tab;
863 } 863 }
864 }else{ 864 }else{
865 for(i=0; i<2; i++){ 865 for(i=0; i<2; i++){
866 mpeg_motion(s, dest_y, dest_cb, dest_cr, 866 mpeg_motion(s, dest_y, dest_cb, dest_cr,
867 0, 0, s->picture_structure != i+1, 867 0, 0, s->picture_structure != i+1,
868 ref_picture, pix_op, 868 ref_picture, pix_op,
869 s->mv[dir][2*i][0],s->mv[dir][2*i][1],16); 869 s->mv[dir][2*i][0],s->mv[dir][2*i][1],16, mb_y>>1);
870 870
871 // after put we make avg of the same block 871 // after put we make avg of the same block
872 pix_op=s->dsp.avg_pixels_tab; 872 pix_op=s->dsp.avg_pixels_tab;
873 873
874 //opposite parity is always in the same frame if this is second field 874 //opposite parity is always in the same frame if this is second field