[FFmpeg-devel] [PATCH] fix GetBitContext index when SPS bitstream_restriction_flag=1 but can't be parsed, because index is out of bit-stream size. Need return index value continue H.264 parsing
Hendrik Leppkes
h.leppkes at gmail.com
Tue May 16 23:02:56 EEST 2017
On Tue, May 16, 2017 at 2:13 PM, Ivan Shmakov <ishmakov at zingaya.com> wrote:
> ---
> libavcodec/h264_ps.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
> index 7858361..09e2290 100644
> --- a/libavcodec/h264_ps.c
> +++ b/libavcodec/h264_ps.c
> @@ -136,6 +136,7 @@ static inline int decode_vui_parameters(GetBitContext
> *gb, AVCodecContext *avctx
> {
> int aspect_ratio_info_present_flag;
> unsigned int aspect_ratio_idc;
> + int idx;
>
> aspect_ratio_info_present_flag = get_bits1(gb);
>
> @@ -221,8 +222,10 @@ static inline int decode_vui_parameters(GetBitContext
> *gb, AVCodecContext *avctx
> sps->pic_struct_present_flag = get_bits1(gb);
> if (!get_bits_left(gb))
> return 0;
> +
> sps->bitstream_restriction_flag = get_bits1(gb);
> if (sps->bitstream_restriction_flag) {
> + idx = gb->index;
> get_bits1(gb); /* motion_vectors_over_pic_boundaries_flag */
> get_ue_golomb(gb); /* max_bytes_per_pic_denom */
> get_ue_golomb(gb); /* max_bits_per_mb_denom */
> @@ -234,6 +237,7 @@ static inline int decode_vui_parameters(GetBitContext
> *gb, AVCodecContext *avctx
> if (get_bits_left(gb) < 0) {
> sps->num_reorder_frames = 0;
> sps->bitstream_restriction_flag = 0;
> + gb->index = idx;
> }
>
> if (sps->num_reorder_frames > 16U
This doesn't seem right. What guarantees are that when one element
can't be parsed, anything else can?
- Hendrik
More information about the ffmpeg-devel
mailing list