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

Side by Side Diff: media/formats/mp2t/es_parser_h264.cc

Issue 1786733004: Revert of media config: expand is_encrypted to a struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « media/formats/mp2t/es_parser_h264.h ('k') | media/formats/mp2t/es_parser_mpeg1audio.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "media/formats/mp2t/es_parser_h264.h" 5 #include "media/formats/mp2t/es_parser_h264.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/numerics/safe_conversions.h" 8 #include "base/numerics/safe_conversions.h"
9 #include "media/base/encryption_scheme.h"
10 #include "media/base/media_util.h"
11 #include "media/base/stream_parser_buffer.h" 9 #include "media/base/stream_parser_buffer.h"
12 #include "media/base/timestamp_constants.h" 10 #include "media/base/timestamp_constants.h"
13 #include "media/base/video_frame.h" 11 #include "media/base/video_frame.h"
14 #include "media/filters/h264_parser.h" 12 #include "media/filters/h264_parser.h"
15 #include "media/formats/common/offset_byte_queue.h" 13 #include "media/formats/common/offset_byte_queue.h"
16 #include "media/formats/mp2t/mp2t_common.h" 14 #include "media/formats/mp2t/mp2t_common.h"
17 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
18 #include "ui/gfx/geometry/size.h" 16 #include "ui/gfx/geometry/size.h"
19 17
20 namespace media { 18 namespace media {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 // does not necessarily start with an SPS/PPS/IDR. 255 // does not necessarily start with an SPS/PPS/IDR.
258 // In this case, the initial frames are conveyed to the upper layer with 256 // In this case, the initial frames are conveyed to the upper layer with
259 // an invalid VideoDecoderConfig and it's up to the upper layer 257 // an invalid VideoDecoderConfig and it's up to the upper layer
260 // to process this kind of frame accordingly. 258 // to process this kind of frame accordingly.
261 if (last_video_decoder_config_.IsValidConfig()) 259 if (last_video_decoder_config_.IsValidConfig())
262 return false; 260 return false;
263 } else { 261 } else {
264 const H264SPS* sps = h264_parser_->GetSPS(pps->seq_parameter_set_id); 262 const H264SPS* sps = h264_parser_->GetSPS(pps->seq_parameter_set_id);
265 if (!sps) 263 if (!sps)
266 return false; 264 return false;
267 RCHECK(UpdateVideoDecoderConfig(sps, Unencrypted())); 265 RCHECK(UpdateVideoDecoderConfig(sps));
268 } 266 }
269 267
270 // Emit a frame. 268 // Emit a frame.
271 DVLOG(LOG_LEVEL_ES) << "Emit frame: stream_pos=" << current_access_unit_pos_ 269 DVLOG(LOG_LEVEL_ES) << "Emit frame: stream_pos=" << current_access_unit_pos_
272 << " size=" << access_unit_size; 270 << " size=" << access_unit_size;
273 int es_size; 271 int es_size;
274 const uint8_t* es; 272 const uint8_t* es;
275 es_queue_->PeekAt(current_access_unit_pos_, &es, &es_size); 273 es_queue_->PeekAt(current_access_unit_pos_, &es, &es_size);
276 CHECK_GE(es_size, access_unit_size); 274 CHECK_GE(es_size, access_unit_size);
277 275
278 // TODO(wolenetz/acolwell): Validate and use a common cross-parser TrackId 276 // TODO(wolenetz/acolwell): Validate and use a common cross-parser TrackId
279 // type and allow multiple video tracks. See https://crbug.com/341581. 277 // type and allow multiple video tracks. See https://crbug.com/341581.
280 scoped_refptr<StreamParserBuffer> stream_parser_buffer = 278 scoped_refptr<StreamParserBuffer> stream_parser_buffer =
281 StreamParserBuffer::CopyFrom( 279 StreamParserBuffer::CopyFrom(
282 es, 280 es,
283 access_unit_size, 281 access_unit_size,
284 is_key_frame, 282 is_key_frame,
285 DemuxerStream::VIDEO, 283 DemuxerStream::VIDEO,
286 0); 284 0);
287 stream_parser_buffer->SetDecodeTimestamp(current_timing_desc.dts); 285 stream_parser_buffer->SetDecodeTimestamp(current_timing_desc.dts);
288 stream_parser_buffer->set_timestamp(current_timing_desc.pts); 286 stream_parser_buffer->set_timestamp(current_timing_desc.pts);
289 return es_adapter_.OnNewBuffer(stream_parser_buffer); 287 return es_adapter_.OnNewBuffer(stream_parser_buffer);
290 } 288 }
291 289
292 bool EsParserH264::UpdateVideoDecoderConfig(const H264SPS* sps, 290 bool EsParserH264::UpdateVideoDecoderConfig(const H264SPS* sps) {
293 const EncryptionScheme& scheme) {
294 // Set the SAR to 1 when not specified in the H264 stream. 291 // Set the SAR to 1 when not specified in the H264 stream.
295 int sar_width = (sps->sar_width == 0) ? 1 : sps->sar_width; 292 int sar_width = (sps->sar_width == 0) ? 1 : sps->sar_width;
296 int sar_height = (sps->sar_height == 0) ? 1 : sps->sar_height; 293 int sar_height = (sps->sar_height == 0) ? 1 : sps->sar_height;
297 294
298 // TODO(damienv): a MAP unit can be either 16 or 32 pixels. 295 // TODO(damienv): a MAP unit can be either 16 or 32 pixels.
299 // although it's 16 pixels for progressive non MBAFF frames. 296 // although it's 16 pixels for progressive non MBAFF frames.
300 gfx::Size coded_size((sps->pic_width_in_mbs_minus1 + 1) * 16, 297 gfx::Size coded_size((sps->pic_width_in_mbs_minus1 + 1) * 16,
301 (sps->pic_height_in_map_units_minus1 + 1) * 16); 298 (sps->pic_height_in_map_units_minus1 + 1) * 16);
302 gfx::Rect visible_rect( 299 gfx::Rect visible_rect(
303 sps->frame_crop_left_offset, 300 sps->frame_crop_left_offset,
304 sps->frame_crop_top_offset, 301 sps->frame_crop_top_offset,
305 (coded_size.width() - sps->frame_crop_right_offset) - 302 (coded_size.width() - sps->frame_crop_right_offset) -
306 sps->frame_crop_left_offset, 303 sps->frame_crop_left_offset,
307 (coded_size.height() - sps->frame_crop_bottom_offset) - 304 (coded_size.height() - sps->frame_crop_bottom_offset) -
308 sps->frame_crop_top_offset); 305 sps->frame_crop_top_offset);
309 if (visible_rect.width() <= 0 || visible_rect.height() <= 0) 306 if (visible_rect.width() <= 0 || visible_rect.height() <= 0)
310 return false; 307 return false;
311 gfx::Size natural_size( 308 gfx::Size natural_size(
312 (visible_rect.width() * sar_width) / sar_height, 309 (visible_rect.width() * sar_width) / sar_height,
313 visible_rect.height()); 310 visible_rect.height());
314 if (natural_size.width() == 0) 311 if (natural_size.width() == 0)
315 return false; 312 return false;
316 313
317 VideoDecoderConfig video_decoder_config( 314 VideoDecoderConfig video_decoder_config(
318 kCodecH264, ProfileIDCToVideoCodecProfile(sps->profile_idc), 315 kCodecH264, ProfileIDCToVideoCodecProfile(sps->profile_idc),
319 PIXEL_FORMAT_YV12, COLOR_SPACE_HD_REC709, coded_size, visible_rect, 316 PIXEL_FORMAT_YV12, COLOR_SPACE_HD_REC709, coded_size, visible_rect,
320 natural_size, EmptyExtraData(), scheme); 317 natural_size, std::vector<uint8_t>(), false);
321 318
322 if (!video_decoder_config.Matches(last_video_decoder_config_)) { 319 if (!video_decoder_config.Matches(last_video_decoder_config_)) {
323 DVLOG(1) << "Profile IDC: " << sps->profile_idc; 320 DVLOG(1) << "Profile IDC: " << sps->profile_idc;
324 DVLOG(1) << "Level IDC: " << sps->level_idc; 321 DVLOG(1) << "Level IDC: " << sps->level_idc;
325 DVLOG(1) << "Pic width: " << coded_size.width(); 322 DVLOG(1) << "Pic width: " << coded_size.width();
326 DVLOG(1) << "Pic height: " << coded_size.height(); 323 DVLOG(1) << "Pic height: " << coded_size.height();
327 DVLOG(1) << "log2_max_frame_num_minus4: " 324 DVLOG(1) << "log2_max_frame_num_minus4: "
328 << sps->log2_max_frame_num_minus4; 325 << sps->log2_max_frame_num_minus4;
329 DVLOG(1) << "SAR: width=" << sps->sar_width 326 DVLOG(1) << "SAR: width=" << sps->sar_width
330 << " height=" << sps->sar_height; 327 << " height=" << sps->sar_height;
331 last_video_decoder_config_ = video_decoder_config; 328 last_video_decoder_config_ = video_decoder_config;
332 es_adapter_.OnConfigChanged(video_decoder_config); 329 es_adapter_.OnConfigChanged(video_decoder_config);
333 } 330 }
334 331
335 return true; 332 return true;
336 } 333 }
337 334
338 } // namespace mp2t 335 } // namespace mp2t
339 } // namespace media 336 } // namespace media
OLDNEW
« no previous file with comments | « media/formats/mp2t/es_parser_h264.h ('k') | media/formats/mp2t/es_parser_mpeg1audio.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698