Mercurial > libavcodec.hg
comparison mpeg12.c @ 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 | 5bf8c18a9907 |
children | 9ea5f2f1874f |
comparison
equal
deleted
inserted
replaced
10603:874e26fe2284 | 10604:ce2cf9e32b09 |
---|---|
1671 const int lowres= s->avctx->lowres; | 1671 const int lowres= s->avctx->lowres; |
1672 | 1672 |
1673 s->resync_mb_x= | 1673 s->resync_mb_x= |
1674 s->resync_mb_y= -1; | 1674 s->resync_mb_y= -1; |
1675 | 1675 |
1676 if (mb_y<<field_pic >= s->mb_height){ | 1676 if (mb_y >= s->mb_height){ |
1677 av_log(s->avctx, AV_LOG_ERROR, "slice below image (%d >= %d)\n", mb_y, s->mb_height); | 1677 av_log(s->avctx, AV_LOG_ERROR, "slice below image (%d >= %d)\n", mb_y, s->mb_height); |
1678 return -1; | 1678 return -1; |
1679 } | 1679 } |
1680 | 1680 |
1681 init_get_bits(&s->gb, *buf, buf_size*8); | 1681 init_get_bits(&s->gb, *buf, buf_size*8); |
1754 | 1754 |
1755 if(mpeg_decode_mb(s, s->block) < 0) | 1755 if(mpeg_decode_mb(s, s->block) < 0) |
1756 return -1; | 1756 return -1; |
1757 | 1757 |
1758 if(s->current_picture.motion_val[0] && !s->encoding){ //note motion_val is normally NULL unless we want to extract the MVs | 1758 if(s->current_picture.motion_val[0] && !s->encoding){ //note motion_val is normally NULL unless we want to extract the MVs |
1759 const int wrap = field_pic ? 2*s->b8_stride : s->b8_stride; | 1759 const int wrap = s->b8_stride; |
1760 int xy = s->mb_x*2 + s->mb_y*2*wrap; | 1760 int xy = s->mb_x*2 + s->mb_y*2*wrap; |
1761 int motion_x, motion_y, dir, i; | 1761 int motion_x, motion_y, dir, i; |
1762 if(field_pic && !s->first_field) | |
1763 xy += wrap/2; | |
1764 | 1762 |
1765 for(i=0; i<2; i++){ | 1763 for(i=0; i<2; i++){ |
1766 for(dir=0; dir<2; dir++){ | 1764 for(dir=0; dir<2; dir++){ |
1767 if (s->mb_intra || (dir==1 && s->pict_type != FF_B_TYPE)) { | 1765 if (s->mb_intra || (dir==1 && s->pict_type != FF_B_TYPE)) { |
1768 motion_x = motion_y = 0; | 1766 motion_x = motion_y = 0; |
1793 MPV_decode_mb(s, s->block); | 1791 MPV_decode_mb(s, s->block); |
1794 | 1792 |
1795 if (++s->mb_x >= s->mb_width) { | 1793 if (++s->mb_x >= s->mb_width) { |
1796 const int mb_size= 16>>s->avctx->lowres; | 1794 const int mb_size= 16>>s->avctx->lowres; |
1797 | 1795 |
1798 ff_draw_horiz_band(s, mb_size*s->mb_y, mb_size); | 1796 ff_draw_horiz_band(s, mb_size*(s->mb_y>>field_pic), mb_size); |
1799 | 1797 |
1800 s->mb_x = 0; | 1798 s->mb_x = 0; |
1801 s->mb_y++; | 1799 s->mb_y += 1<<field_pic; |
1802 | 1800 |
1803 if(s->mb_y<<field_pic >= s->mb_height){ | 1801 if(s->mb_y >= s->mb_height){ |
1804 int left= get_bits_left(&s->gb); | 1802 int left= get_bits_left(&s->gb); |
1805 int is_d10= s->chroma_format==2 && s->pict_type==FF_I_TYPE && avctx->profile==0 && avctx->level==5 | 1803 int is_d10= s->chroma_format==2 && s->pict_type==FF_I_TYPE && avctx->profile==0 && avctx->level==5 |
1806 && s->intra_dc_precision == 2 && s->q_scale_type == 1 && s->alternate_scan == 0 | 1804 && s->intra_dc_precision == 2 && s->q_scale_type == 1 && s->alternate_scan == 0 |
1807 && s->progressive_frame == 0 /* vbv_delay == 0xBBB || 0xE10*/; | 1805 && s->progressive_frame == 0 /* vbv_delay == 0xBBB || 0xE10*/; |
1808 | 1806 |
1883 | 1881 |
1884 static int slice_decode_thread(AVCodecContext *c, void *arg){ | 1882 static int slice_decode_thread(AVCodecContext *c, void *arg){ |
1885 MpegEncContext *s= *(void**)arg; | 1883 MpegEncContext *s= *(void**)arg; |
1886 const uint8_t *buf= s->gb.buffer; | 1884 const uint8_t *buf= s->gb.buffer; |
1887 int mb_y= s->start_mb_y; | 1885 int mb_y= s->start_mb_y; |
1888 | 1886 const int field_pic= s->picture_structure != PICT_FRAME; |
1889 s->error_count= 3*(s->end_mb_y - s->start_mb_y)*s->mb_width; | 1887 |
1888 s->error_count= (3*(s->end_mb_y - s->start_mb_y)*s->mb_width) >> field_pic; | |
1890 | 1889 |
1891 for(;;){ | 1890 for(;;){ |
1892 uint32_t start_code; | 1891 uint32_t start_code; |
1893 int ret; | 1892 int ret; |
1894 | 1893 |
2382 } | 2381 } |
2383 break; | 2382 break; |
2384 default: | 2383 default: |
2385 if (start_code >= SLICE_MIN_START_CODE && | 2384 if (start_code >= SLICE_MIN_START_CODE && |
2386 start_code <= SLICE_MAX_START_CODE && last_code!=0) { | 2385 start_code <= SLICE_MAX_START_CODE && last_code!=0) { |
2387 int mb_y= start_code - SLICE_MIN_START_CODE; | 2386 const int field_pic= s2->picture_structure != PICT_FRAME; |
2387 int mb_y= (start_code - SLICE_MIN_START_CODE) << field_pic; | |
2388 last_code= SLICE_MIN_START_CODE; | 2388 last_code= SLICE_MIN_START_CODE; |
2389 | |
2390 if(s2->picture_structure == PICT_BOTTOM_FIELD) | |
2391 mb_y++; | |
2389 | 2392 |
2390 if(s2->last_picture_ptr==NULL){ | 2393 if(s2->last_picture_ptr==NULL){ |
2391 /* Skip B-frames if we do not have reference frames and gop is not closed */ | 2394 /* Skip B-frames if we do not have reference frames and gop is not closed */ |
2392 if(s2->pict_type==FF_B_TYPE){ | 2395 if(s2->pict_type==FF_B_TYPE){ |
2393 if(!s2->closed_gop) | 2396 if(!s2->closed_gop) |