Mercurial > libavcodec.hg
comparison mpeg12.c @ 1138:e10e841c9bf0 libavcodec
field pic decoding cleanup
author | michaelni |
---|---|
date | Sun, 16 Mar 2003 20:22:22 +0000 |
parents | 77ccf7fe3bd0 |
children | dde68a430ba9 |
comparison
equal
deleted
inserted
replaced
1137:7fb0b38ab5a3 | 1138:e10e841c9bf0 |
---|---|
227 } | 227 } |
228 } | 228 } |
229 | 229 |
230 put_bits(&s->pb, 4, s->aspect_ratio_info); | 230 put_bits(&s->pb, 4, s->aspect_ratio_info); |
231 put_bits(&s->pb, 4, s->frame_rate_index); | 231 put_bits(&s->pb, 4, s->frame_rate_index); |
232 v = s->bit_rate / 400; | 232 v = (s->bit_rate + 399) / 400; |
233 if (v > 0x3ffff) | 233 if (v > 0x3ffff) |
234 v = 0x3ffff; | 234 v = 0x3ffff; |
235 put_bits(&s->pb, 18, v); | 235 put_bits(&s->pb, 18, v); |
236 put_bits(&s->pb, 1, 1); /* marker */ | 236 put_bits(&s->pb, 1, 1); /* marker */ |
237 | 237 |
1801 s->last_dc[1] = s->last_dc[0]; | 1801 s->last_dc[1] = s->last_dc[0]; |
1802 s->last_dc[2] = s->last_dc[0]; | 1802 s->last_dc[2] = s->last_dc[0]; |
1803 memset(s->last_mv, 0, sizeof(s->last_mv)); | 1803 memset(s->last_mv, 0, sizeof(s->last_mv)); |
1804 | 1804 |
1805 /* start frame decoding */ | 1805 /* start frame decoding */ |
1806 if (s->first_slice && (s->first_field || s->picture_structure==PICT_FRAME)) { | 1806 if (s->first_slice) { |
1807 if(s->first_field || s->picture_structure==PICT_FRAME){ | |
1807 if(MPV_frame_start(s, avctx) < 0) | 1808 if(MPV_frame_start(s, avctx) < 0) |
1808 return DECODE_SLICE_FATAL_ERROR; | 1809 return DECODE_SLICE_FATAL_ERROR; |
1809 /* first check if we must repeat the frame */ | 1810 /* first check if we must repeat the frame */ |
1810 s->current_picture.repeat_pict = 0; | 1811 s->current_picture.repeat_pict = 0; |
1811 | 1812 |
1827 s->pict_type == I_TYPE ? "I" : (s->pict_type == P_TYPE ? "P" : (s->pict_type == B_TYPE ? "B" : "S")), | 1828 s->pict_type == I_TYPE ? "I" : (s->pict_type == P_TYPE ? "P" : (s->pict_type == B_TYPE ? "B" : "S")), |
1828 s->progressive_sequence ? "pro" :"", s->alternate_scan ? "alt" :"", s->top_field_first ? "top" :"", | 1829 s->progressive_sequence ? "pro" :"", s->alternate_scan ? "alt" :"", s->top_field_first ? "top" :"", |
1829 s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors, | 1830 s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors, |
1830 s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" :""); | 1831 s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" :""); |
1831 } | 1832 } |
1833 }else{ //second field | |
1834 int i; | |
1835 for(i=0; i<4; i++){ | |
1836 s->current_picture.data[i] = s->current_picture_ptr->data[i]; | |
1837 if(s->picture_structure == PICT_BOTTOM_FIELD){ | |
1838 s->current_picture.data[i] += s->current_picture_ptr->linesize[i]; | |
1839 } | |
1840 } | |
1841 } | |
1832 } | 1842 } |
1833 s->first_slice = 0; | 1843 s->first_slice = 0; |
1834 | 1844 |
1835 init_get_bits(&s->gb, buf, buf_size*8); | 1845 init_get_bits(&s->gb, buf, buf_size*8); |
1836 | 1846 |
1863 | 1873 |
1864 ret = mpeg_decode_mb(s, s->block); | 1874 ret = mpeg_decode_mb(s, s->block); |
1865 dprintf("ret=%d\n", ret); | 1875 dprintf("ret=%d\n", ret); |
1866 if (ret < 0) | 1876 if (ret < 0) |
1867 return -1; | 1877 return -1; |
1868 //printf("%d %d\n", s->mb_x, s->mb_y); | 1878 |
1869 //FIXME this isnt the most beautifull way to solve the problem ... | |
1870 if(s->picture_structure!=PICT_FRAME){ | |
1871 if(s->picture_structure == PICT_BOTTOM_FIELD){ | |
1872 s->current_picture.data[0] += s->linesize; | |
1873 s->current_picture.data[1] += s->uvlinesize; | |
1874 s->current_picture.data[2] += s->uvlinesize; | |
1875 } | |
1876 s->linesize *= 2; | |
1877 s->uvlinesize *= 2; | |
1878 } | |
1879 MPV_decode_mb(s, s->block); | 1879 MPV_decode_mb(s, s->block); |
1880 if(s->picture_structure!=PICT_FRAME){ | |
1881 s->linesize /= 2; | |
1882 s->uvlinesize /= 2; | |
1883 if(s->picture_structure == PICT_BOTTOM_FIELD){ | |
1884 s->current_picture.data[0] -= s->linesize; | |
1885 s->current_picture.data[1] -= s->uvlinesize; | |
1886 s->current_picture.data[2] -= s->uvlinesize; | |
1887 } | |
1888 } | |
1889 | 1880 |
1890 if (++s->mb_x >= s->mb_width) { | 1881 if (++s->mb_x >= s->mb_width) { |
1891 if(s->picture_structure==PICT_FRAME){ | 1882 if(s->picture_structure==PICT_FRAME){ |
1892 ff_draw_horiz_band(s, 16*s->mb_y, 16); | 1883 ff_draw_horiz_band(s, 16*s->mb_y, 16); |
1893 }else{ | 1884 }else{ |
1943 *pict= *(AVFrame*)&s->current_picture; | 1934 *pict= *(AVFrame*)&s->current_picture; |
1944 } else { | 1935 } else { |
1945 s->picture_number++; | 1936 s->picture_number++; |
1946 /* latency of 1 frame for I and P frames */ | 1937 /* latency of 1 frame for I and P frames */ |
1947 /* XXX: use another variable than picture_number */ | 1938 /* XXX: use another variable than picture_number */ |
1948 if (s->last_picture.data[0] == NULL) { | 1939 if (s->last_picture_ptr == NULL) { |
1949 return DECODE_SLICE_OK; | 1940 return DECODE_SLICE_OK; |
1950 } else { | 1941 } else { |
1951 *pict= *(AVFrame*)&s->last_picture; | 1942 *pict= *(AVFrame*)&s->last_picture; |
1952 } | 1943 } |
1953 } | 1944 } |
2194 default: | 2185 default: |
2195 if (start_code >= SLICE_MIN_START_CODE && | 2186 if (start_code >= SLICE_MIN_START_CODE && |
2196 start_code <= SLICE_MAX_START_CODE) { | 2187 start_code <= SLICE_MAX_START_CODE) { |
2197 | 2188 |
2198 /* skip b frames if we dont have reference frames */ | 2189 /* skip b frames if we dont have reference frames */ |
2199 if(s2->last_picture.data[0]==NULL && s2->pict_type==B_TYPE) break; | 2190 if(s2->last_picture_ptr==NULL && s2->pict_type==B_TYPE) break; |
2200 /* skip b frames if we are in a hurry */ | 2191 /* skip b frames if we are in a hurry */ |
2201 if(avctx->hurry_up && s2->pict_type==B_TYPE) break; | 2192 if(avctx->hurry_up && s2->pict_type==B_TYPE) break; |
2202 /* skip everything if we are in a hurry>=5 */ | 2193 /* skip everything if we are in a hurry>=5 */ |
2203 if(avctx->hurry_up>=5) break; | 2194 if(avctx->hurry_up>=5) break; |
2204 | 2195 |