Ticket #3900: 07_fix_avformat_h264_startcode_check.patch

File 07_fix_avformat_h264_startcode_check.patch, 1.2 KB (added by Lastique, 12 years ago)

The patch adds support for 3-byte h264 startcodes.

  • libavformat/mpegtsenc.c

    old new  
    11451145
    11461146int ff_check_h264_startcode(AVFormatContext *s, const AVStream *st, const AVPacket *pkt)
    11471147{
    1148     if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001) {
    1149         if (!st->nb_frames) {
    1150             av_log(s, AV_LOG_ERROR, "H.264 bitstream malformed, "
    1151                    "no startcode found, use the h264_mp4toannexb bitstream filter (-bsf h264_mp4toannexb)\n");
    1152             return AVERROR(EINVAL);
    1153         }
    1154         av_log(s, AV_LOG_WARNING, "H.264 bitstream error, startcode missing\n");
     1148    if ((pkt->size > 4 && AV_RB32(pkt->data) == 0x00000001) || (pkt->size >= 4 && AV_RB24(pkt->data) == 0x000001))
     1149        return 0;
     1150
     1151    if (!st->nb_frames) {
     1152        av_log(s, AV_LOG_ERROR, "H.264 bitstream malformed, "
     1153               "no startcode found, use the h264_mp4toannexb bitstream filter (-bsf h264_mp4toannexb)\n");
     1154        return AVERROR(EINVAL);
    11551155    }
     1156    av_log(s, AV_LOG_WARNING, "H.264 bitstream error, startcode missing\n");
     1157
    11561158    return 0;
    11571159}
    11581160