* Decode the first and second partition. * @return <0 if error (and sets error type in the error_status_table) */
| 1314 | * @return <0 if error (and sets error type in the error_status_table) |
| 1315 | */ |
| 1316 | int ff_mpeg4_decode_partitions(H263DecContext *const h) |
| 1317 | { |
| 1318 | Mpeg4DecContext *const ctx = h263_to_mpeg4(h); |
| 1319 | int mb_num; |
| 1320 | int ret; |
| 1321 | const int part_a_error = h->c.pict_type == AV_PICTURE_TYPE_I ? (ER_DC_ERROR | ER_MV_ERROR) : ER_MV_ERROR; |
| 1322 | const int part_a_end = h->c.pict_type == AV_PICTURE_TYPE_I ? (ER_DC_END | ER_MV_END) : ER_MV_END; |
| 1323 | |
| 1324 | mb_num = mpeg4_decode_partition_a(ctx); |
| 1325 | if (mb_num <= 0) { |
| 1326 | ff_er_add_slice(&h->c.er, h->c.resync_mb_x, h->c.resync_mb_y, |
| 1327 | h->c.mb_x, h->c.mb_y, part_a_error); |
| 1328 | return mb_num ? mb_num : AVERROR_INVALIDDATA; |
| 1329 | } |
| 1330 | |
| 1331 | if (h->c.resync_mb_x + h->c.resync_mb_y * h->c.mb_width + mb_num > h->c.mb_num) { |
| 1332 | av_log(h->c.avctx, AV_LOG_ERROR, "slice below monitor ...\n"); |
| 1333 | ff_er_add_slice(&h->c.er, h->c.resync_mb_x, h->c.resync_mb_y, |
| 1334 | h->c.mb_x, h->c.mb_y, part_a_error); |
| 1335 | return AVERROR_INVALIDDATA; |
| 1336 | } |
| 1337 | |
| 1338 | h->mb_num_left = mb_num; |
| 1339 | |
| 1340 | if (h->c.pict_type == AV_PICTURE_TYPE_I) { |
| 1341 | while (show_bits(&h->gb, 9) == 1) |
| 1342 | skip_bits(&h->gb, 9); |
| 1343 | if (get_bits(&h->gb, 19) != DC_MARKER) { |
| 1344 | av_log(h->c.avctx, AV_LOG_ERROR, |
| 1345 | "marker missing after first I partition at %d %d\n", |
| 1346 | h->c.mb_x, h->c.mb_y); |
| 1347 | return AVERROR_INVALIDDATA; |
| 1348 | } |
| 1349 | } else { |
| 1350 | while (show_bits(&h->gb, 10) == 1) |
| 1351 | skip_bits(&h->gb, 10); |
| 1352 | if (get_bits(&h->gb, 17) != MOTION_MARKER) { |
| 1353 | av_log(h->c.avctx, AV_LOG_ERROR, |
| 1354 | "marker missing after first P partition at %d %d\n", |
| 1355 | h->c.mb_x, h->c.mb_y); |
| 1356 | return AVERROR_INVALIDDATA; |
| 1357 | } |
| 1358 | } |
| 1359 | ff_er_add_slice(&h->c.er, h->c.resync_mb_x, h->c.resync_mb_y, |
| 1360 | h->c.mb_x - 1, h->c.mb_y, part_a_end); |
| 1361 | |
| 1362 | ret = mpeg4_decode_partition_b(h, mb_num); |
| 1363 | if (ret < 0) { |
| 1364 | if (h->c.pict_type == AV_PICTURE_TYPE_P) |
| 1365 | ff_er_add_slice(&h->c.er, h->c.resync_mb_x, h->c.resync_mb_y, |
| 1366 | h->c.mb_x, h->c.mb_y, ER_DC_ERROR); |
| 1367 | return ret; |
| 1368 | } else { |
| 1369 | if (h->c.pict_type == AV_PICTURE_TYPE_P) |
| 1370 | ff_er_add_slice(&h->c.er, h->c.resync_mb_x, h->c.resync_mb_y, |
| 1371 | h->c.mb_x - 1, h->c.mb_y, ER_DC_END); |
| 1372 | } |
| 1373 |
no test coverage detected