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

Function slice_decode_thread

libavcodec/mpeg12dec.c:1639–1687  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1637}
1638
1639static int slice_decode_thread(AVCodecContext *c, void *arg)
1640{
1641 Mpeg12SliceContext *const s = *(void **) arg;
1642 const uint8_t *buf = s->gb.buffer;
1643 const uint8_t *end = buf + get_bits_bytesize(&s->gb, 0);
1644 int mb_y = s->c.start_mb_y;
1645 const int field_pic = s->c.picture_structure != PICT_FRAME;
1646
1647 s->c.er.error_count = (3 * (s->c.end_mb_y - s->c.start_mb_y) * s->c.mb_width) >> field_pic;
1648
1649 for (;;) {
1650 uint32_t start_code;
1651 int ret;
1652
1653 ret = mpeg_decode_slice(s, mb_y, &buf, end - buf);
1654 emms_c();
1655 ff_dlog(c, "ret:%d resync:%d/%d mb:%d/%d ts:%d/%d ec:%d\n",
1656 ret, s->c.resync_mb_x, s->c.resync_mb_y, s->c.mb_x, s->c.mb_y,
1657 s->c.start_mb_y, s->c.end_mb_y, s->c.er.error_count);
1658 if (ret < 0) {
1659 if (c->err_recognition & AV_EF_EXPLODE)
1660 return ret;
1661 if (s->c.resync_mb_x >= 0 && s->c.resync_mb_y >= 0)
1662 ff_er_add_slice(&s->c.er, s->c.resync_mb_x, s->c.resync_mb_y,
1663 s->c.mb_x, s->c.mb_y,
1664 ER_AC_ERROR | ER_DC_ERROR | ER_MV_ERROR);
1665 } else {
1666 ff_er_add_slice(&s->c.er, s->c.resync_mb_x, s->c.resync_mb_y,
1667 s->c.mb_x - 1, s->c.mb_y,
1668 ER_AC_END | ER_DC_END | ER_MV_END);
1669 }
1670
1671 if (s->c.mb_y == s->c.end_mb_y)
1672 return 0;
1673
1674 start_code = -1;
1675 buf = avpriv_find_start_code(buf, end, &start_code);
1676 if (start_code < SLICE_MIN_START_CODE || start_code > SLICE_MAX_START_CODE)
1677 return AVERROR_INVALIDDATA;
1678 mb_y = start_code - SLICE_MIN_START_CODE;
1679 if (s->c.codec_id != AV_CODEC_ID_MPEG1VIDEO && s->c.mb_height > 2800/16)
1680 mb_y += (*buf&0xE0)<<2;
1681 mb_y <<= field_pic;
1682 if (s->c.picture_structure == PICT_BOTTOM_FIELD)
1683 mb_y++;
1684 if (mb_y >= s->c.end_mb_y)
1685 return AVERROR_INVALIDDATA;
1686 }
1687}
1688
1689/**
1690 * Handle slice ends.

Callers

nothing calls this directly

Calls 5

get_bits_bytesizeFunction · 0.85
mpeg_decode_sliceFunction · 0.85
emms_cFunction · 0.85
ff_er_add_sliceFunction · 0.85
avpriv_find_start_codeFunction · 0.85

Tested by

no test coverage detected