Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Side by Side Diff: libavcodec/h264.c

Issue 9370003: Remove pthreads patch, roll in new patches, disable unchecked bit readers. (Closed) Base URL: ssh://gerrit.chromium.org:29418/chromium/third_party/ffmpeg.git@master
Patch Set: gyp fix. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * H.26L/H.264/AVC/JVT/14496-10/... decoder 2 * H.26L/H.264/AVC/JVT/14496-10/... decoder
3 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> 3 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
4 * 4 *
5 * This file is part of FFmpeg. 5 * This file is part of FFmpeg.
6 * 6 *
7 * FFmpeg is free software; you can redistribute it and/or 7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version. 10 * version 2.1 of the License, or (at your option) any later version.
11 * 11 *
12 * FFmpeg is distributed in the hope that it will be useful, 12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details. 15 * Lesser General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU Lesser General Public 17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software 18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */ 20 */
21 21
22 /** 22 /**
23 * @file 23 * @file
24 * H.264 / AVC / MPEG4 part10 codec. 24 * H.264 / AVC / MPEG4 part10 codec.
25 * @author Michael Niedermayer <michaelni@gmx.at> 25 * @author Michael Niedermayer <michaelni@gmx.at>
26 */ 26 */
27 27
28 #define UNCHECKED_BITSTREAM_READER 1
29
30 #include "libavutil/imgutils.h" 28 #include "libavutil/imgutils.h"
31 #include "libavutil/opt.h" 29 #include "libavutil/opt.h"
32 #include "internal.h" 30 #include "internal.h"
33 #include "cabac.h" 31 #include "cabac.h"
34 #include "cabac_functions.h" 32 #include "cabac_functions.h"
35 #include "dsputil.h" 33 #include "dsputil.h"
36 #include "avcodec.h" 34 #include "avcodec.h"
37 #include "mpegvideo.h" 35 #include "mpegvideo.h"
38 #include "h264.h" 36 #include "h264.h"
39 #include "h264data.h" 37 #include "h264data.h"
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 av_log(avctx, AV_LOG_ERROR, "avcC too short\n"); 1088 av_log(avctx, AV_LOG_ERROR, "avcC too short\n");
1091 return -1; 1089 return -1;
1092 } 1090 }
1093 /* sps and pps in the avcC always have length coded with 2 bytes, 1091 /* sps and pps in the avcC always have length coded with 2 bytes,
1094 so put a fake nal_length_size = 2 while parsing them */ 1092 so put a fake nal_length_size = 2 while parsing them */
1095 h->nal_length_size = 2; 1093 h->nal_length_size = 2;
1096 // Decode sps from avcC 1094 // Decode sps from avcC
1097 cnt = *(p+5) & 0x1f; // Number of sps 1095 cnt = *(p+5) & 0x1f; // Number of sps
1098 p += 6; 1096 p += 6;
1099 for (i = 0; i < cnt; i++) { 1097 for (i = 0; i < cnt; i++) {
1098 if(size - (p-buf) < 2)
1099 return -1;
1100 nalsize = AV_RB16(p) + 2; 1100 nalsize = AV_RB16(p) + 2;
1101 if(nalsize > size - (p-buf)) 1101 if(nalsize > size - (p-buf))
1102 return -1; 1102 return -1;
1103 if(decode_nal_units(h, p, nalsize) < 0) { 1103 if(decode_nal_units(h, p, nalsize) < 0) {
1104 av_log(avctx, AV_LOG_ERROR, "Decoding sps %d from avcC failed\n" , i); 1104 av_log(avctx, AV_LOG_ERROR, "Decoding sps %d from avcC failed\n" , i);
1105 return -1; 1105 return -1;
1106 } 1106 }
1107 p += nalsize; 1107 p += nalsize;
1108 } 1108 }
1109 if(size - (p-buf) <= 0)
1110 return -1;
1109 // Decode pps from avcC 1111 // Decode pps from avcC
1110 cnt = *(p++); // Number of pps 1112 cnt = *(p++); // Number of pps
1111 for (i = 0; i < cnt; i++) { 1113 for (i = 0; i < cnt; i++) {
1114 if(size - (p-buf) < 2)
1115 return -1;
1112 nalsize = AV_RB16(p) + 2; 1116 nalsize = AV_RB16(p) + 2;
1113 if(nalsize > size - (p-buf)) 1117 if(nalsize > size - (p-buf))
1114 return -1; 1118 return -1;
1115 if (decode_nal_units(h, p, nalsize) < 0) { 1119 if (decode_nal_units(h, p, nalsize) < 0) {
1116 av_log(avctx, AV_LOG_ERROR, "Decoding pps %d from avcC failed\n" , i); 1120 av_log(avctx, AV_LOG_ERROR, "Decoding pps %d from avcC failed\n" , i);
1117 return -1; 1121 return -1;
1118 } 1122 }
1119 p += nalsize; 1123 p += nalsize;
1120 } 1124 }
1121 // Now store right nal length size, that will be use to parse all other nals 1125 // Now store right nal length size, that will be use to parse all other nals
(...skipping 3133 matching lines...) Expand 10 before | Expand all | Expand 10 after
4255 .close = ff_h264_decode_end, 4259 .close = ff_h264_decode_end,
4256 .decode = decode_frame, 4260 .decode = decode_frame,
4257 .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, 4261 .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU,
4258 .flush= flush_dpb, 4262 .flush= flush_dpb,
4259 .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (VDPAU acceleration)"), 4263 .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (VDPAU acceleration)"),
4260 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_H264, PIX_FMT_NONE}, 4264 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_H264, PIX_FMT_NONE},
4261 .profiles = NULL_IF_CONFIG_SMALL(profiles), 4265 .profiles = NULL_IF_CONFIG_SMALL(profiles),
4262 .priv_class = &h264_vdpau_class, 4266 .priv_class = &h264_vdpau_class,
4263 }; 4267 };
4264 #endif 4268 #endif
OLDNEW
« configure ('K') | « libavcodec/h263dec.c ('k') | libavcodec/h264_cabac.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698