Mercurial > libavcodec.hg
comparison mpeg12.c @ 5432:e0624692025f libavcodec
move some code which was executed for every skipped MB so it is only executed
for the first skipped mb in a run
author | michael |
---|---|
date | Tue, 31 Jul 2007 21:39:09 +0000 |
parents | 192360fa9b06 |
children | 57434d6c8f49 |
comparison
equal
deleted
inserted
replaced
5431:192360fa9b06 | 5432:e0624692025f |
---|---|
219 dprintf(s->avctx, "decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y); | 219 dprintf(s->avctx, "decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y); |
220 | 220 |
221 assert(s->mb_skipped==0); | 221 assert(s->mb_skipped==0); |
222 | 222 |
223 if (s->mb_skip_run-- != 0) { | 223 if (s->mb_skip_run-- != 0) { |
224 if(s->pict_type == I_TYPE){ | |
225 av_log(s->avctx, AV_LOG_ERROR, "skipped MB in I frame at %d %d\n", s->mb_x, s->mb_y); | |
226 return -1; | |
227 } | |
228 | |
229 /* skip mb */ | |
230 s->mb_intra = 0; | |
231 for(i=0;i<12;i++) | |
232 s->block_last_index[i] = -1; | |
233 if(s->picture_structure == PICT_FRAME) | |
234 s->mv_type = MV_TYPE_16X16; | |
235 else | |
236 s->mv_type = MV_TYPE_FIELD; | |
237 if (s->pict_type == P_TYPE) { | 224 if (s->pict_type == P_TYPE) { |
238 /* if P type, zero motion vector is implied */ | |
239 s->mv_dir = MV_DIR_FORWARD; | |
240 s->mv[0][0][0] = s->mv[0][0][1] = 0; | |
241 s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0; | |
242 s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0; | |
243 s->field_select[0][0]= s->picture_structure - 1; | |
244 s->mb_skipped = 1; | 225 s->mb_skipped = 1; |
245 s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16; | 226 s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16; |
246 } else { | 227 } else { |
247 int mb_type; | 228 int mb_type; |
248 | 229 |
250 mb_type= s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1]; | 231 mb_type= s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1]; |
251 else | 232 else |
252 mb_type= s->current_picture.mb_type[ s->mb_width + (s->mb_y-1)*s->mb_stride - 1]; // FIXME not sure if this is allowed in mpeg at all, | 233 mb_type= s->current_picture.mb_type[ s->mb_width + (s->mb_y-1)*s->mb_stride - 1]; // FIXME not sure if this is allowed in mpeg at all, |
253 if(IS_INTRA(mb_type)) | 234 if(IS_INTRA(mb_type)) |
254 return -1; | 235 return -1; |
255 | |
256 /* if B type, reuse previous vectors and directions */ | |
257 s->mv[0][0][0] = s->last_mv[0][0][0]; | |
258 s->mv[0][0][1] = s->last_mv[0][0][1]; | |
259 s->mv[1][0][0] = s->last_mv[1][0][0]; | |
260 s->mv[1][0][1] = s->last_mv[1][0][1]; | |
261 | 236 |
262 s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= | 237 s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= |
263 mb_type | MB_TYPE_SKIP; | 238 mb_type | MB_TYPE_SKIP; |
264 // assert(s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1]&(MB_TYPE_16x16|MB_TYPE_16x8)); | 239 // assert(s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1]&(MB_TYPE_16x16|MB_TYPE_16x8)); |
265 | 240 |
1826 } else { | 1801 } else { |
1827 s->mb_skip_run += code; | 1802 s->mb_skip_run += code; |
1828 break; | 1803 break; |
1829 } | 1804 } |
1830 } | 1805 } |
1806 if(s->mb_skip_run){ | |
1807 int i; | |
1808 if(s->pict_type == I_TYPE){ | |
1809 av_log(s->avctx, AV_LOG_ERROR, "skipped MB in I frame at %d %d\n", s->mb_x, s->mb_y); | |
1810 return -1; | |
1811 } | |
1812 | |
1813 /* skip mb */ | |
1814 s->mb_intra = 0; | |
1815 for(i=0;i<12;i++) | |
1816 s->block_last_index[i] = -1; | |
1817 if(s->picture_structure == PICT_FRAME) | |
1818 s->mv_type = MV_TYPE_16X16; | |
1819 else | |
1820 s->mv_type = MV_TYPE_FIELD; | |
1821 if (s->pict_type == P_TYPE) { | |
1822 /* if P type, zero motion vector is implied */ | |
1823 s->mv_dir = MV_DIR_FORWARD; | |
1824 s->mv[0][0][0] = s->mv[0][0][1] = 0; | |
1825 s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0; | |
1826 s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0; | |
1827 s->field_select[0][0]= s->picture_structure - 1; | |
1828 } else { | |
1829 /* if B type, reuse previous vectors and directions */ | |
1830 s->mv[0][0][0] = s->last_mv[0][0][0]; | |
1831 s->mv[0][0][1] = s->last_mv[0][0][1]; | |
1832 s->mv[1][0][0] = s->last_mv[1][0][0]; | |
1833 s->mv[1][0][1] = s->last_mv[1][0][1]; | |
1834 } | |
1835 } | |
1831 } | 1836 } |
1832 } | 1837 } |
1833 eos: // end of slice | 1838 eos: // end of slice |
1834 *buf += get_bits_count(&s->gb)/8 - 1; | 1839 *buf += get_bits_count(&s->gb)/8 - 1; |
1835 //printf("y %d %d %d %d\n", s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y); | 1840 //printf("y %d %d %d %d\n", s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y); |