[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

Michael Niedermayer michael at niedermayer.cc
Tue May 16 23:46:58 EEST 2017


On Tue, May 16, 2017 at 03:13:36PM +0300, Ivan Shmakov 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;

Direct access to gb->index is not ok
all code directly accssing GetBitContext internals belongs in the
bitstream / get bits code.
Normally to "unread" we just duplicate the GetBitContext before


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170516/cb449a04/attachment.sig>


More information about the ffmpeg-devel mailing list