OLD | NEW |
(Empty) | |
| 1 diff -wurp -N orig/libavcodec/h264.c ffmpeg/libavcodec/h264.c |
| 2 --- orig/libavcodec/h264.c 2012-02-06 14:02:09.990431439 -0800 |
| 3 +++ ffmpeg/libavcodec/h264.c 2012-02-06 14:06:11.752827405 -0800 |
| 4 @@ -988,12 +988,13 @@ int ff_h264_decode_extradata(H264Context |
| 5 AVCodecContext *avctx = h->s.avctx; |
| 6 |
| 7 if(avctx->extradata[0] == 1){ |
| 8 - int i, cnt, nalsize; |
| 9 + int i, cnt, nalsize, size_left; |
| 10 unsigned char *p = avctx->extradata; |
| 11 + size_left = avctx->extradata_size; |
| 12 |
| 13 h->is_avc = 1; |
| 14 |
| 15 - if(avctx->extradata_size < 7) { |
| 16 + if(size_left < 7) { |
| 17 av_log(avctx, AV_LOG_ERROR, "avcC too short\n"); |
| 18 return -1; |
| 19 } |
| 20 @@ -1003,23 +1004,47 @@ int ff_h264_decode_extradata(H264Context |
| 21 // Decode sps from avcC |
| 22 cnt = *(p+5) & 0x1f; // Number of sps |
| 23 p += 6; |
| 24 + size_left -= 6; |
| 25 for (i = 0; i < cnt; i++) { |
| 26 + if (size_left < 2) { |
| 27 + av_log(avctx, AV_LOG_ERROR, "Cannot read sps nalsize\n"); |
| 28 + return -1; |
| 29 + } |
| 30 nalsize = AV_RB16(p) + 2; |
| 31 + if (size_left < nalsize) { |
| 32 + av_log(avctx, AV_LOG_ERROR, "sps nalsize too big\n"); |
| 33 + return -1; |
| 34 + } |
| 35 if(decode_nal_units(h, p, nalsize) < 0) { |
| 36 av_log(avctx, AV_LOG_ERROR, "Decoding sps %d from avcC failed\n
", i); |
| 37 return -1; |
| 38 } |
| 39 p += nalsize; |
| 40 + size_left -= nalsize; |
| 41 } |
| 42 // Decode pps from avcC |
| 43 + if(!size_left) { |
| 44 + av_log(avctx, AV_LOG_ERROR, "Cannot read pps count\n"); |
| 45 + return -1; |
| 46 + } |
| 47 cnt = *(p++); // Number of pps |
| 48 + --size_left; |
| 49 for (i = 0; i < cnt; i++) { |
| 50 + if (size_left < 2) { |
| 51 + av_log(avctx, AV_LOG_ERROR, "Cannot read pps nalsize\n"); |
| 52 + return -1; |
| 53 + } |
| 54 nalsize = AV_RB16(p) + 2; |
| 55 + if (size_left < nalsize) { |
| 56 + av_log(avctx, AV_LOG_ERROR, "pps nalsize too big\n"); |
| 57 + return -1; |
| 58 + } |
| 59 if (decode_nal_units(h, p, nalsize) < 0) { |
| 60 av_log(avctx, AV_LOG_ERROR, "Decoding pps %d from avcC failed\n
", i); |
| 61 return -1; |
| 62 } |
| 63 p += nalsize; |
| 64 + size_left -= nalsize; |
| 65 } |
| 66 // Now store right nal length size, that will be use to parse all other
nals |
| 67 h->nal_length_size = (avctx->extradata[4] & 0x03) + 1; |
OLD | NEW |