| 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 |
| 385 config->Initialize(codec, | 391 config->Initialize(codec, |
| 386 profile, | 392 profile, |
| 387 format, | 393 format, |
| 388 coded_size, visible_rect, natural_size, | 394 coded_size, visible_rect, natural_size, |
| 389 stream->codec->extradata, stream->codec->extradata_size, | 395 stream->codec->extradata, stream->codec->extradata_size, |
| 390 is_encrypted, | 396 is_encrypted, |
| 391 true); | 397 true); |
| 392 } | 398 } |
| 393 | 399 |
| 394 void VideoDecoderConfigToAVCodecContext( | 400 void VideoDecoderConfigToAVCodecContext( |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 VideoFrame::Format PixelFormatToVideoFormat(PixelFormat pixel_format) { | 489 VideoFrame::Format PixelFormatToVideoFormat(PixelFormat pixel_format) { |
| 484 switch (pixel_format) { | 490 switch (pixel_format) { |
| 485 case PIX_FMT_YUV422P: | 491 case PIX_FMT_YUV422P: |
| 486 return VideoFrame::YV16; | 492 return VideoFrame::YV16; |
| 487 // TODO(scherkus): We should be paying attention to the color range of each | 493 // TODO(scherkus): We should be paying attention to the color range of each |
| 488 // format and scaling as appropriate when rendering. Regular YUV has a range | 494 // format and scaling as appropriate when rendering. Regular YUV has a range |
| 489 // of 16-239 where as YUVJ has a range of 0-255. | 495 // of 16-239 where as YUVJ has a range of 0-255. |
| 490 case PIX_FMT_YUV420P: | 496 case PIX_FMT_YUV420P: |
| 491 case PIX_FMT_YUVJ420P: | 497 case PIX_FMT_YUVJ420P: |
| 492 return VideoFrame::YV12; | 498 return VideoFrame::YV12; |
| 499 case PIX_FMT_YUVA420P: |
| 500 return VideoFrame::YV12A; |
| 493 default: | 501 default: |
| 494 DVLOG(1) << "Unsupported PixelFormat: " << pixel_format; | 502 DVLOG(1) << "Unsupported PixelFormat: " << pixel_format; |
| 495 } | 503 } |
| 496 return VideoFrame::INVALID; | 504 return VideoFrame::INVALID; |
| 497 } | 505 } |
| 498 | 506 |
| 499 PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format) { | 507 PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format) { |
| 500 switch (video_format) { | 508 switch (video_format) { |
| 501 case VideoFrame::YV16: | 509 case VideoFrame::YV16: |
| 502 return PIX_FMT_YUV422P; | 510 return PIX_FMT_YUV422P; |
| 503 case VideoFrame::YV12: | 511 case VideoFrame::YV12: |
| 504 return PIX_FMT_YUV420P; | 512 return PIX_FMT_YUV420P; |
| 513 case VideoFrame::YV12A: |
| 514 return PIX_FMT_YUVA420P; |
| 505 default: | 515 default: |
| 506 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; | 516 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; |
| 507 } | 517 } |
| 508 return PIX_FMT_NONE; | 518 return PIX_FMT_NONE; |
| 509 } | 519 } |
| 510 | 520 |
| 511 } // namespace media | 521 } // namespace media |
| OLD | NEW |