* decodes a slice. MpegEncContext.mb_y must be set to the MB row from the startcode * @return DECODE_SLICE_ERROR if the slice is damaged * DECODE_SLICE_OK if this slice is ok */
| 1663 | * DECODE_SLICE_OK if this slice is ok<br> |
| 1664 | */ |
| 1665 | static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y, |
| 1666 | const uint8_t **buf, int buf_size) |
| 1667 | { |
| 1668 | MpegEncContext *s = &s1->mpeg_enc_ctx; |
| 1669 | AVCodecContext *avctx= s->avctx; |
| 1670 | const int field_pic= s->picture_structure != PICT_FRAME; |
| 1671 | const int lowres= s->avctx->lowres; |
| 1672 | |
| 1673 | s->resync_mb_x= |
| 1674 | s->resync_mb_y= -1; |
| 1675 | |
| 1676 | assert(mb_y < s->mb_height); |
| 1677 | |
| 1678 | init_get_bits(&s->gb, *buf, buf_size*8); |
| 1679 | |
| 1680 | ff_mpeg1_clean_buffers(s); |
| 1681 | s->interlaced_dct = 0; |
| 1682 | |
| 1683 | s->qscale = get_qscale(s); |
| 1684 | |
| 1685 | if(s->qscale == 0){ |
| 1686 | av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n"); |
| 1687 | return -1; |
| 1688 | } |
| 1689 | |
| 1690 | /* extra slice info */ |
| 1691 | while (get_bits1(&s->gb) != 0) { |
| 1692 | skip_bits(&s->gb, 8); |
| 1693 | } |
| 1694 | |
| 1695 | s->mb_x=0; |
| 1696 | |
| 1697 | if(mb_y==0 && s->codec_tag == AV_RL32("SLIF")){ |
| 1698 | skip_bits1(&s->gb); |
| 1699 | }else{ |
| 1700 | for(;;) { |
| 1701 | int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2); |
| 1702 | if (code < 0){ |
| 1703 | av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n"); |
| 1704 | return -1; |
| 1705 | } |
| 1706 | if (code >= 33) { |
| 1707 | if (code == 33) { |
| 1708 | s->mb_x += 33; |
| 1709 | } |
| 1710 | /* otherwise, stuffing, nothing to do */ |
| 1711 | } else { |
| 1712 | s->mb_x += code; |
| 1713 | break; |
| 1714 | } |
| 1715 | } |
| 1716 | } |
| 1717 | |
| 1718 | if(s->mb_x >= (unsigned)s->mb_width){ |
| 1719 | av_log(s->avctx, AV_LOG_ERROR, "initial skip overflow\n"); |
| 1720 | return -1; |
| 1721 | } |
| 1722 |
no test coverage detected