[FFmpeg-user] Possible bug in h264.c ff_h264_decode_nal

David R Robison drrobison at openroadsconsulting.com
Tue Nov 6 21:20:53 CET 2012


One more thing. It seems that the problem is related to the emulation 
prevention bytes being removed from the data that is copies into the 
media type. Could this be part of the issue? David

David R Robison
Open Roads Consulting, Inc.
103 Watson Road, Chesapeake, VA 23320
phone: (757) 546-3401
e-mail: drrobison at openroadsconsulting.com
web: http://openroadsconsulting.com
blog: http://therobe.blogspot.com
book: http://www.xulonpress.com/bookstore/bookdetail.php?PB_ISBN=9781597816526

On 11/6/2012 2:44 PM, David R Robison wrote:
> I am trying to play video from a Pelco camera and it is not decoding
> right. It appears that the entire SPS is not being parsed. In the h264.c
> file the ff_h264_decode_nal function the following is defined.
>
> #define STARTCODE_TEST \
>           if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) {     \
>               if (src[i + 2] != 3) {                                      \
>                   /* startcode, so we must be past the end */             \
>                   length = i;                                             \
> } \
> break; \
>           }
>
> However, it seems to me from the documentation that the start code will
> either end with a 1 or a 3. If I change the function to
>
> #define STARTCODE_TEST \
>           if (i + 2 < length && src[i + 1] == 0 && (src[i + 2] == 1 ||
> src[i + 2] == 3)) {     \
>               if (src[i + 2] != 3) {                                      \
>                   /* startcode, so we must be past the end */             \
>                   length = i;                                             \
> }                                                           \
> break;                                                      \
>           }
>
> Then my video plays fine. Any thoughts on this? Here is the patch file:
>
> Index: ffmpeg/libavcodec/h264.c
> ===================================================================
> --- ffmpeg/libavcodec/h264.c    (revision 4489)
> +++ ffmpeg/libavcodec/h264.c    (working copy)
> @@ -178,7 +178,7 @@
>        length--;
>
>    #define STARTCODE_TEST                                                  \
> -        if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) {     \
> +        if (i + 2 < length && src[i + 1] == 0 && (src[i + 2] == 1 ||
> src[i + 2] == 3)) {     \
>                if (src[i + 2] != 3) {                                      \
>                    /* startcode, so we must be past the end */             \
>                    length = i;                                             \
>
>
> David
>



This email communication (including any attachments) may contain confidential and/or privileged material intended solely for the individual or entity to which it is addressed.
If you are not the intended recipient, please delete this email immediately.



More information about the ffmpeg-user mailing list