* Decode the next video packet. * @return <0 if something went wrong */
| 806 | * @return <0 if something went wrong |
| 807 | */ |
| 808 | int ff_mpeg4_decode_studio_slice_header(H263DecContext *const h) |
| 809 | { |
| 810 | Mpeg4DecContext *const ctx = h263_to_mpeg4(h); |
| 811 | GetBitContext *gb = &h->gb; |
| 812 | unsigned vlc_len; |
| 813 | uint16_t mb_num; |
| 814 | |
| 815 | if (get_bits_left(gb) >= 32 && get_bits_long(gb, 32) == SLICE_STARTCODE) { |
| 816 | vlc_len = av_log2(h->c.mb_width * h->c.mb_height) + 1; |
| 817 | mb_num = get_bits(gb, vlc_len); |
| 818 | |
| 819 | if (mb_num >= h->c.mb_num) |
| 820 | return AVERROR_INVALIDDATA; |
| 821 | |
| 822 | h->c.mb_x = mb_num % h->c.mb_width; |
| 823 | h->c.mb_y = mb_num / h->c.mb_width; |
| 824 | |
| 825 | if (ctx->shape != BIN_ONLY_SHAPE) |
| 826 | h->c.qscale = mpeg_get_qscale(&h->gb, h->c.q_scale_type); |
| 827 | |
| 828 | if (get_bits1(gb)) { /* slice_extension_flag */ |
| 829 | skip_bits1(gb); /* intra_slice */ |
| 830 | skip_bits1(gb); /* slice_VOP_id_enable */ |
| 831 | skip_bits(gb, 6); /* slice_VOP_id */ |
| 832 | while (get_bits1(gb)) /* extra_bit_slice */ |
| 833 | skip_bits(gb, 8); /* extra_information_slice */ |
| 834 | } |
| 835 | |
| 836 | reset_studio_dc_predictors(ctx); |
| 837 | } |
| 838 | else { |
| 839 | return AVERROR_INVALIDDATA; |
| 840 | } |
| 841 | |
| 842 | return 0; |
| 843 | } |
| 844 | |
| 845 | /** |
| 846 | * Get the average motion vector for a GMC MB. |
no test coverage detected