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 "media/base/decoder_buffer.h" | 9 #include "media/base/decoder_buffer.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 // TODO(tomfinegan): libavcodec doesn't know about VP9. | 375 // TODO(tomfinegan): libavcodec doesn't know about VP9. |
376 format = VideoFrame::YV12; | 376 format = VideoFrame::YV12; |
377 coded_size = natural_size; | 377 coded_size = natural_size; |
378 } | 378 } |
379 | 379 |
380 bool is_encrypted = false; | 380 bool is_encrypted = false; |
381 AVDictionaryEntry* key = av_dict_get(stream->metadata, "enc_key_id", NULL, 0); | 381 AVDictionaryEntry* key = av_dict_get(stream->metadata, "enc_key_id", NULL, 0); |
382 if (key) | 382 if (key) |
383 is_encrypted = true; | 383 is_encrypted = true; |
384 | 384 |
385 AVDictionaryEntry* webm_alpha = | |
386 av_dict_get(stream->metadata, "alpha_mode", NULL, 0); | |
387 if (webm_alpha && !strcmp(webm_alpha->value, "1")) { | |
388 format = VideoFrame::YV12A; | |
389 } | |
390 | |
391 config->Initialize(codec, | 385 config->Initialize(codec, |
392 profile, | 386 profile, |
393 format, | 387 format, |
394 coded_size, visible_rect, natural_size, | 388 coded_size, visible_rect, natural_size, |
395 stream->codec->extradata, stream->codec->extradata_size, | 389 stream->codec->extradata, stream->codec->extradata_size, |
396 is_encrypted, | 390 is_encrypted, |
397 true); | 391 true); |
398 } | 392 } |
399 | 393 |
400 void VideoDecoderConfigToAVCodecContext( | 394 void VideoDecoderConfigToAVCodecContext( |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 VideoFrame::Format PixelFormatToVideoFormat(PixelFormat pixel_format) { | 483 VideoFrame::Format PixelFormatToVideoFormat(PixelFormat pixel_format) { |
490 switch (pixel_format) { | 484 switch (pixel_format) { |
491 case PIX_FMT_YUV422P: | 485 case PIX_FMT_YUV422P: |
492 return VideoFrame::YV16; | 486 return VideoFrame::YV16; |
493 // TODO(scherkus): We should be paying attention to the color range of each | 487 // TODO(scherkus): We should be paying attention to the color range of each |
494 // format and scaling as appropriate when rendering. Regular YUV has a range | 488 // format and scaling as appropriate when rendering. Regular YUV has a range |
495 // of 16-239 where as YUVJ has a range of 0-255. | 489 // of 16-239 where as YUVJ has a range of 0-255. |
496 case PIX_FMT_YUV420P: | 490 case PIX_FMT_YUV420P: |
497 case PIX_FMT_YUVJ420P: | 491 case PIX_FMT_YUVJ420P: |
498 return VideoFrame::YV12; | 492 return VideoFrame::YV12; |
499 case PIX_FMT_YUVA420P: | |
500 return VideoFrame::YV12A; | |
501 default: | 493 default: |
502 DVLOG(1) << "Unsupported PixelFormat: " << pixel_format; | 494 DVLOG(1) << "Unsupported PixelFormat: " << pixel_format; |
503 } | 495 } |
504 return VideoFrame::INVALID; | 496 return VideoFrame::INVALID; |
505 } | 497 } |
506 | 498 |
507 PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format) { | 499 PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format) { |
508 switch (video_format) { | 500 switch (video_format) { |
509 case VideoFrame::YV16: | 501 case VideoFrame::YV16: |
510 return PIX_FMT_YUV422P; | 502 return PIX_FMT_YUV422P; |
511 case VideoFrame::YV12: | 503 case VideoFrame::YV12: |
512 return PIX_FMT_YUV420P; | 504 return PIX_FMT_YUV420P; |
513 case VideoFrame::YV12A: | |
514 return PIX_FMT_YUVA420P; | |
515 default: | 505 default: |
516 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; | 506 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; |
517 } | 507 } |
518 return PIX_FMT_NONE; | 508 return PIX_FMT_NONE; |
519 } | 509 } |
520 | 510 |
521 } // namespace media | 511 } // namespace media |
OLD | NEW |