OLD | NEW |
---|---|
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 "media/ffmpeg/ffmpeg_common.h" | 5 #include "media/ffmpeg/ffmpeg_common.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 coded_size.set_width((coded_size.width() + 1) / 2 * 2); | 404 coded_size.set_width((coded_size.width() + 1) / 2 * 2); |
405 if (format != VideoFrame::YV16) | 405 if (format != VideoFrame::YV16) |
406 coded_size.set_height((coded_size.height() + 1) / 2 * 2); | 406 coded_size.set_height((coded_size.height() + 1) / 2 * 2); |
407 } | 407 } |
408 | 408 |
409 bool is_encrypted = false; | 409 bool is_encrypted = false; |
410 AVDictionaryEntry* key = av_dict_get(stream->metadata, "enc_key_id", NULL, 0); | 410 AVDictionaryEntry* key = av_dict_get(stream->metadata, "enc_key_id", NULL, 0); |
411 if (key) | 411 if (key) |
412 is_encrypted = true; | 412 is_encrypted = true; |
413 | 413 |
414 AVDictionaryEntry* rotation_entry = | |
415 av_dict_get(stream->metadata, "rotate", NULL, 0); | |
416 int rotation = 0; | |
417 if (rotation_entry && rotation_entry->value && rotation_entry->value[0]) | |
418 base::StringToInt(rotation_entry->value, &rotation); | |
419 | |
420 DCHECK(rotation == 0 || rotation == 90 || rotation == 180 || rotation == 270); | |
scherkus (not reviewing)
2014/07/07 20:52:38
are we certain FFmpeg can't spit out values other
| |
421 | |
414 AVDictionaryEntry* webm_alpha = | 422 AVDictionaryEntry* webm_alpha = |
415 av_dict_get(stream->metadata, "alpha_mode", NULL, 0); | 423 av_dict_get(stream->metadata, "alpha_mode", NULL, 0); |
416 if (webm_alpha && !strcmp(webm_alpha->value, "1")) { | 424 if (webm_alpha && !strcmp(webm_alpha->value, "1")) { |
417 format = VideoFrame::YV12A; | 425 format = VideoFrame::YV12A; |
418 } | 426 } |
419 | 427 |
420 config->Initialize(codec, | 428 config->Initialize(codec, |
421 profile, | 429 profile, |
422 format, | 430 format, |
423 coded_size, visible_rect, natural_size, | 431 coded_size, visible_rect, natural_size, |
424 stream->codec->extradata, stream->codec->extradata_size, | 432 stream->codec->extradata, stream->codec->extradata_size, |
425 is_encrypted, | 433 is_encrypted, |
426 record_stats); | 434 record_stats); |
435 | |
436 switch (rotation) { | |
437 case 0: | |
438 config->set_rotation(kRotate0); | |
439 break; | |
440 case 90: | |
441 config->set_rotation(kRotate90); | |
442 break; | |
443 case 180: | |
444 config->set_rotation(kRotate180); | |
445 break; | |
446 case 270: | |
447 config->set_rotation(kRotate270); | |
448 default: | |
449 break; | |
450 } | |
427 } | 451 } |
428 | 452 |
429 void VideoDecoderConfigToAVCodecContext( | 453 void VideoDecoderConfigToAVCodecContext( |
430 const VideoDecoderConfig& config, | 454 const VideoDecoderConfig& config, |
431 AVCodecContext* codec_context) { | 455 AVCodecContext* codec_context) { |
432 codec_context->codec_type = AVMEDIA_TYPE_VIDEO; | 456 codec_context->codec_type = AVMEDIA_TYPE_VIDEO; |
433 codec_context->codec_id = VideoCodecToCodecID(config.codec()); | 457 codec_context->codec_id = VideoCodecToCodecID(config.codec()); |
434 codec_context->profile = VideoCodecProfileToProfileID(config.profile()); | 458 codec_context->profile = VideoCodecProfileToProfileID(config.profile()); |
435 codec_context->coded_width = config.coded_size().width(); | 459 codec_context->coded_width = config.coded_size().width(); |
436 codec_context->coded_height = config.coded_size().height(); | 460 codec_context->coded_height = config.coded_size().height(); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
578 return false; | 602 return false; |
579 | 603 |
580 *out = parsed_time; | 604 *out = parsed_time; |
581 return true; | 605 return true; |
582 } | 606 } |
583 | 607 |
584 return false; | 608 return false; |
585 } | 609 } |
586 | 610 |
587 } // namespace media | 611 } // namespace media |
OLD | NEW |