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

Side by Side Diff: content/common/gpu/media/h264_parser.cc

Issue 10389164: Cleanup: Remove unneeded scoped_ptr.h includes from content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « content/common/gpu/media/h264_parser.h ('k') | content/common/mac/attributed_string_coder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/gpu/media/h264_parser.h"
6
5 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
6 #include "base/stl_util.h" 9 #include "base/stl_util.h"
7 #include "content/common/gpu/media/h264_parser.h"
8 10
9 namespace content { 11 namespace content {
10 12
11 bool H264SliceHeader::IsPSlice() const { 13 bool H264SliceHeader::IsPSlice() const {
12 return (slice_type % 5 == kPSlice); 14 return (slice_type % 5 == kPSlice);
13 } 15 }
14 16
15 bool H264SliceHeader::IsBSlice() const { 17 bool H264SliceHeader::IsBSlice() const {
16 return (slice_type % 5 == kBSlice); 18 return (slice_type % 5 == kBSlice);
17 } 19 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 146 }
145 147
146 #define READ_BITS_OR_RETURN(num_bits, out) \ 148 #define READ_BITS_OR_RETURN(num_bits, out) \
147 do { \ 149 do { \
148 int _out; \ 150 int _out; \
149 if (!br_.ReadBits(num_bits, &_out)) { \ 151 if (!br_.ReadBits(num_bits, &_out)) { \
150 DVLOG(1) << "Error in stream: unexpected EOS while trying to read " #out; \ 152 DVLOG(1) << "Error in stream: unexpected EOS while trying to read " #out; \
151 return kInvalidStream; \ 153 return kInvalidStream; \
152 } \ 154 } \
153 *out = _out; \ 155 *out = _out; \
154 } while(0) 156 } while (0)
155 157
156 #define READ_UE_OR_RETURN(out) \ 158 #define READ_UE_OR_RETURN(out) \
157 do { \ 159 do { \
158 if (ReadUE(out) != kOk) { \ 160 if (ReadUE(out) != kOk) { \
159 DVLOG(1) << "Error in stream: invalid value while trying to read " #out; \ 161 DVLOG(1) << "Error in stream: invalid value while trying to read " #out; \
160 return kInvalidStream; \ 162 return kInvalidStream; \
161 } \ 163 } \
162 } while(0) 164 } while (0)
163 165
164 #define READ_SE_OR_RETURN(out) \ 166 #define READ_SE_OR_RETURN(out) \
165 do { \ 167 do { \
166 if (ReadSE(out) != kOk) { \ 168 if (ReadSE(out) != kOk) { \
167 DVLOG(1) << "Error in stream: invalid value while trying to read " #out; \ 169 DVLOG(1) << "Error in stream: invalid value while trying to read " #out; \
168 return kInvalidStream; \ 170 return kInvalidStream; \
169 } \ 171 } \
170 } while(0) 172 } while (0)
171 173
172 #define IN_RANGE_OR_RETURN(val, min, max) \ 174 #define IN_RANGE_OR_RETURN(val, min, max) \
173 do { \ 175 do { \
174 if ((val) < (min) || (val) > (max)) { \ 176 if ((val) < (min) || (val) > (max)) { \
175 DVLOG(1) << "Error in stream: invalid value, expected " #val " to be" \ 177 DVLOG(1) << "Error in stream: invalid value, expected " #val " to be" \
176 << " in range [" << (min) << ":" << (max) << "]" \ 178 << " in range [" << (min) << ":" << (max) << "]" \
177 << " found " << (val) << " instead"; \ 179 << " found " << (val) << " instead"; \
178 return kInvalidStream; \ 180 return kInvalidStream; \
179 } \ 181 } \
180 } while(0) 182 } while (0)
181 183
182 #define TRUE_OR_RETURN(a) \ 184 #define TRUE_OR_RETURN(a) \
183 do { \ 185 do { \
184 if (!(a)) { \ 186 if (!(a)) { \
185 DVLOG(1) << "Error in stream: invalid value, expected " << #a; \ 187 DVLOG(1) << "Error in stream: invalid value, expected " << #a; \
186 return kInvalidStream; \ 188 return kInvalidStream; \
187 } \ 189 } \
188 } while(0) 190 } while (0)
189 191
190 H264Parser::H264Parser() { 192 H264Parser::H264Parser() {
191 Reset(); 193 Reset();
192 } 194 }
193 195
194 H264Parser::~H264Parser() { 196 H264Parser::~H264Parser() {
195 STLDeleteValues(&active_SPSes_); 197 STLDeleteValues(&active_SPSes_);
196 STLDeleteValues(&active_PPSes_); 198 STLDeleteValues(&active_PPSes_);
197 } 199 }
198 200
(...skipping 19 matching lines...) Expand all
218 } 220 }
219 221
220 static inline bool IsStartCode(const uint8* data) { 222 static inline bool IsStartCode(const uint8* data) {
221 return data[0] == 0x00 && data[1] == 0x00 && data[2] == 0x01; 223 return data[0] == 0x00 && data[1] == 0x00 && data[2] == 0x01;
222 } 224 }
223 225
224 // Find offset from start of data to next NALU start code 226 // Find offset from start of data to next NALU start code
225 // and size of found start code (3 or 4 bytes). 227 // and size of found start code (3 or 4 bytes).
226 static bool FindStartCode(const uint8* data, off_t data_size, 228 static bool FindStartCode(const uint8* data, off_t data_size,
227 off_t* offset, 229 off_t* offset,
228 off_t *start_code_size) { 230 off_t* start_code_size) {
229 off_t bytes_left = data_size; 231 off_t bytes_left = data_size;
230 232
231 while (bytes_left > 3) { 233 while (bytes_left > 3) {
232 if (IsStartCode(data)) { 234 if (IsStartCode(data)) {
233 // Found three-byte start code, set pointer at its beginning. 235 // Found three-byte start code, set pointer at its beginning.
234 *offset = data_size - bytes_left; 236 *offset = data_size - bytes_left;
235 *start_code_size = 3; 237 *start_code_size = 3;
236 238
237 // If there is a zero byte before this start code, 239 // If there is a zero byte before this start code,
238 // then it's actually a four-byte start code, so backtrack one byte. 240 // then it's actually a four-byte start code, so backtrack one byte.
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 *pps_id = pps->pic_parameter_set_id; 818 *pps_id = pps->pic_parameter_set_id;
817 delete active_PPSes_[*pps_id]; 819 delete active_PPSes_[*pps_id];
818 active_PPSes_[*pps_id] = pps.release(); 820 active_PPSes_[*pps_id] = pps.release();
819 821
820 return kOk; 822 return kOk;
821 } 823 }
822 824
823 H264Parser::Result H264Parser::ParseRefPicListModification( 825 H264Parser::Result H264Parser::ParseRefPicListModification(
824 int num_ref_idx_active_minus1, 826 int num_ref_idx_active_minus1,
825 H264ModificationOfPicNum* ref_list_mods) { 827 H264ModificationOfPicNum* ref_list_mods) {
826 H264ModificationOfPicNum *pic_num_mod; 828 H264ModificationOfPicNum* pic_num_mod;
827 829
828 if (num_ref_idx_active_minus1 >= 32) 830 if (num_ref_idx_active_minus1 >= 32)
829 return kInvalidStream; 831 return kInvalidStream;
830 832
831 for (int i = 0; i < 32; ++i) { 833 for (int i = 0; i < 32; ++i) {
832 pic_num_mod = &ref_list_mods[i]; 834 pic_num_mod = &ref_list_mods[i];
833 READ_UE_OR_RETURN(&pic_num_mod->modification_of_pic_nums_idc); 835 READ_UE_OR_RETURN(&pic_num_mod->modification_of_pic_nums_idc);
834 TRUE_OR_RETURN(pic_num_mod->modification_of_pic_nums_idc < 4); 836 TRUE_OR_RETURN(pic_num_mod->modification_of_pic_nums_idc < 4);
835 837
836 switch (pic_num_mod->modification_of_pic_nums_idc) { 838 switch (pic_num_mod->modification_of_pic_nums_idc) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 shdr->chroma_log2_weight_denom, 961 shdr->chroma_log2_weight_denom,
960 &shdr->pred_weight_table_l1); 962 &shdr->pred_weight_table_l1);
961 if (res != kOk) 963 if (res != kOk)
962 return res; 964 return res;
963 } 965 }
964 966
965 return kOk; 967 return kOk;
966 } 968 }
967 969
968 H264Parser::Result H264Parser::ParseDecRefPicMarking(H264SliceHeader *shdr) { 970 H264Parser::Result H264Parser::ParseDecRefPicMarking(H264SliceHeader *shdr) {
969
970 if (shdr->idr_pic_flag) { 971 if (shdr->idr_pic_flag) {
971 READ_BITS_OR_RETURN(1, &shdr->no_output_of_prior_pics_flag); 972 READ_BITS_OR_RETURN(1, &shdr->no_output_of_prior_pics_flag);
972 READ_BITS_OR_RETURN(1, &shdr->long_term_reference_flag); 973 READ_BITS_OR_RETURN(1, &shdr->long_term_reference_flag);
973 } else { 974 } else {
974 READ_BITS_OR_RETURN(1, &shdr->adaptive_ref_pic_marking_mode_flag); 975 READ_BITS_OR_RETURN(1, &shdr->adaptive_ref_pic_marking_mode_flag);
975 976
976 H264DecRefPicMarking* marking; 977 H264DecRefPicMarking* marking;
977 if (shdr->adaptive_ref_pic_marking_mode_flag) { 978 if (shdr->adaptive_ref_pic_marking_mode_flag) {
978 size_t i; 979 size_t i;
979 for (i = 0; i < arraysize(shdr->ref_pic_marking); ++i) { 980 for (i = 0; i < arraysize(shdr->ref_pic_marking); ++i) {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 break; 1189 break;
1189 1190
1190 default: 1191 default:
1191 DVLOG(4) << "Unsupported SEI message"; 1192 DVLOG(4) << "Unsupported SEI message";
1192 break; 1193 break;
1193 } 1194 }
1194 1195
1195 return kOk; 1196 return kOk;
1196 } 1197 }
1197 1198
1198 } // namespace content 1199 } // namespace content
1199
OLDNEW
« no previous file with comments | « content/common/gpu/media/h264_parser.h ('k') | content/common/mac/attributed_string_coder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698