MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / mpeg_decode_mb

Function mpeg_decode_mb

libavcodec/mpeg12.c:207–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205#define MT_DMV 3
206
207static int mpeg_decode_mb(MpegEncContext *s,
208 DCTELEM block[12][64])
209{
210 int i, j, k, cbp, val, mb_type, motion_type;
211 const int mb_block_count = 4 + (1<< s->chroma_format);
212
213 dprintf(s->avctx, "decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y);
214
215 assert(s->mb_skipped==0);
216
217 if (s->mb_skip_run-- != 0) {
218 if (s->pict_type == FF_P_TYPE) {
219 s->mb_skipped = 1;
220 s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
221 } else {
222 int mb_type;
223
224 if(s->mb_x)
225 mb_type= s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1];
226 else
227 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
228 if(IS_INTRA(mb_type))
229 return -1;
230
231 s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]=
232 mb_type | MB_TYPE_SKIP;
233// assert(s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1]&(MB_TYPE_16x16|MB_TYPE_16x8));
234
235 if((s->mv[0][0][0]|s->mv[0][0][1]|s->mv[1][0][0]|s->mv[1][0][1])==0)
236 s->mb_skipped = 1;
237 }
238
239 return 0;
240 }
241
242 switch(s->pict_type) {
243 default:
244 case FF_I_TYPE:
245 if (get_bits1(&s->gb) == 0) {
246 if (get_bits1(&s->gb) == 0){
247 av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in I Frame at %d %d\n", s->mb_x, s->mb_y);
248 return -1;
249 }
250 mb_type = MB_TYPE_QUANT | MB_TYPE_INTRA;
251 } else {
252 mb_type = MB_TYPE_INTRA;
253 }
254 break;
255 case FF_P_TYPE:
256 mb_type = get_vlc2(&s->gb, mb_ptype_vlc.table, MB_PTYPE_VLC_BITS, 1);
257 if (mb_type < 0){
258 av_log(s->avctx, AV_LOG_ERROR, "invalid mb type in P Frame at %d %d\n", s->mb_x, s->mb_y);
259 return -1;
260 }
261 mb_type = ptype2mb_type[ mb_type ];
262 break;
263 case FF_B_TYPE:
264 mb_type = get_vlc2(&s->gb, mb_btype_vlc.table, MB_BTYPE_VLC_BITS, 1);

Callers 1

mpeg_decode_sliceFunction · 0.85

Calls 15

get_bits1Function · 0.85
av_logFunction · 0.85
get_vlc2Function · 0.85
skip_bits1Function · 0.85
mpeg_decode_motionFunction · 0.85
ff_xvmc_pack_pblocksFunction · 0.85
exchange_uvFunction · 0.85
mpeg2_decode_block_intraFunction · 0.85
mpeg1_decode_block_intraFunction · 0.85
get_bitsFunction · 0.85
get_dmvFunction · 0.85

Tested by

no test coverage detected