comparison mpegtsenc.c @ 5786:7d670040187e libavformat

In mpegts muxer, search for h264 aud nal, it might not be the first nal. Improve ther error message when bitstream is malformated and tell user to use the bitstream filter.
author bcoudurier
date Mon, 08 Mar 2010 23:59:05 +0000
parents 28885ab1ef1c
children 667736f463b3
comparison
equal deleted inserted replaced
5785:2e42bb81d80b 5786:7d670040187e
781 return -1; 781 return -1;
782 } 782 }
783 ts_st->first_pts_check = 0; 783 ts_st->first_pts_check = 0;
784 784
785 if (st->codec->codec_id == CODEC_ID_H264) { 785 if (st->codec->codec_id == CODEC_ID_H264) {
786 const uint8_t *p = buf, *buf_end = p+size;
787 uint32_t state = -1;
788
786 if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001) { 789 if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001) {
787 av_log(s, AV_LOG_ERROR, "h264 bitstream malformated\n"); 790 av_log(s, AV_LOG_ERROR, "h264 bitstream malformated, "
791 "no startcode found, use -vbsf h264_mp4toannexb\n");
788 return -1; 792 return -1;
789 } 793 }
790 if (pkt->data[4] != 0x09) { // AUD NAL 794
795 do {
796 p = ff_find_start_code(p, buf_end, &state);
797 //av_log(s, AV_LOG_INFO, "nal %d\n", state & 0x1f);
798 } while (p < buf_end && (state & 0x1f) != 9 &&
799 (state & 0x1f) != 5 && (state & 0x1f) != 1);
800
801 if ((state & 0x1f) != 9) { // AUD NAL
791 data = av_malloc(pkt->size+6); 802 data = av_malloc(pkt->size+6);
792 if (!data) 803 if (!data)
793 return -1; 804 return -1;
794 memcpy(data+6, pkt->data, pkt->size); 805 memcpy(data+6, pkt->data, pkt->size);
795 AV_WB32(data, 0x00000001); 806 AV_WB32(data, 0x00000001);