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

Function msmpeg4_decode_picture_header

libavcodec/msmpeg4.c:1382–1546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1380}
1381
1382int msmpeg4_decode_picture_header(MpegEncContext * s)
1383{
1384 int code;
1385
1386#if 0
1387{
1388int i;
1389for(i=0; i<s->gb.size_in_bits; i++)
1390 av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb));
1391// get_bits1(&s->gb);
1392av_log(s->avctx, AV_LOG_DEBUG, "END\n");
1393return -1;
1394}
1395#endif
1396
1397 if(s->msmpeg4_version==1){
1398 int start_code;
1399 start_code = (get_bits(&s->gb, 16)<<16) | get_bits(&s->gb, 16);
1400 if(start_code!=0x00000100){
1401 av_log(s->avctx, AV_LOG_ERROR, "invalid startcode\n");
1402 return -1;
1403 }
1404
1405 skip_bits(&s->gb, 5); // frame number */
1406 }
1407
1408 s->pict_type = get_bits(&s->gb, 2) + 1;
1409 if (s->pict_type != FF_I_TYPE &&
1410 s->pict_type != FF_P_TYPE){
1411 av_log(s->avctx, AV_LOG_ERROR, "invalid picture type\n");
1412 return -1;
1413 }
1414#if 0
1415{
1416 static int had_i=0;
1417 if(s->pict_type == FF_I_TYPE) had_i=1;
1418 if(!had_i) return -1;
1419}
1420#endif
1421 s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
1422 if(s->qscale==0){
1423 av_log(s->avctx, AV_LOG_ERROR, "invalid qscale\n");
1424 return -1;
1425 }
1426
1427 if (s->pict_type == FF_I_TYPE) {
1428 code = get_bits(&s->gb, 5);
1429 if(s->msmpeg4_version==1){
1430 if(code==0 || code>s->mb_height){
1431 av_log(s->avctx, AV_LOG_ERROR, "invalid slice height %d\n", code);
1432 return -1;
1433 }
1434
1435 s->slice_height = code;
1436 }else{
1437 /* 0x17: one slice, 0x18: two slices, ... */
1438 if (code < 0x17){
1439 av_log(s->avctx, AV_LOG_ERROR, "error, slice code was %X\n", code);

Callers 1

ff_h263_decode_frameFunction · 0.85

Calls 6

av_logFunction · 0.85
get_bits1Function · 0.85
get_bitsFunction · 0.85
skip_bitsFunction · 0.85
decode012Function · 0.85

Tested by

no test coverage detected