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

Side by Side Diff: media/ffmpeg/ffmpeg_common.cc

Issue 289373011: Support for YUV 4:4:4 subsampling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Software path. Created 6 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
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 "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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 393 }
394 394
395 VideoFrame::Format format = PixelFormatToVideoFormat(stream->codec->pix_fmt); 395 VideoFrame::Format format = PixelFormatToVideoFormat(stream->codec->pix_fmt);
396 if (codec == kCodecVP9) { 396 if (codec == kCodecVP9) {
397 // TODO(tomfinegan): libavcodec doesn't know about VP9. 397 // TODO(tomfinegan): libavcodec doesn't know about VP9.
398 format = VideoFrame::YV12; 398 format = VideoFrame::YV12;
399 coded_size = natural_size; 399 coded_size = natural_size;
400 } 400 }
401 401
402 // Pad out |coded_size| for subsampled YUV formats. 402 // Pad out |coded_size| for subsampled YUV formats.
403 coded_size.set_width((coded_size.width() + 1) / 2 * 2); 403 if (format != VideoFrame::I444) {
404 if (format != VideoFrame::YV16) 404 coded_size.set_width((coded_size.width() + 1) / 2 * 2);
405 coded_size.set_height((coded_size.height() + 1) / 2 * 2); 405 if (format != VideoFrame::YV16)
406 coded_size.set_height((coded_size.height() + 1) / 2 * 2);
407 }
406 408
407 bool is_encrypted = false; 409 bool is_encrypted = false;
408 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);
409 if (key) 411 if (key)
410 is_encrypted = true; 412 is_encrypted = true;
411 413
412 AVDictionaryEntry* webm_alpha = 414 AVDictionaryEntry* webm_alpha =
413 av_dict_get(stream->metadata, "alpha_mode", NULL, 0); 415 av_dict_get(stream->metadata, "alpha_mode", NULL, 0);
414 if (webm_alpha && !strcmp(webm_alpha->value, "1")) { 416 if (webm_alpha && !strcmp(webm_alpha->value, "1")) {
415 format = VideoFrame::YV12A; 417 format = VideoFrame::YV12A;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 // FFmpeg channel_layout is 0 for .wav and .mp3. Attempt to guess layout 512 // FFmpeg channel_layout is 0 for .wav and .mp3. Attempt to guess layout
511 // based on the channel count. 513 // based on the channel count.
512 return GuessChannelLayout(channels); 514 return GuessChannelLayout(channels);
513 } 515 }
514 } 516 }
515 517
516 VideoFrame::Format PixelFormatToVideoFormat(PixelFormat pixel_format) { 518 VideoFrame::Format PixelFormatToVideoFormat(PixelFormat pixel_format) {
517 switch (pixel_format) { 519 switch (pixel_format) {
518 case PIX_FMT_YUV422P: 520 case PIX_FMT_YUV422P:
519 return VideoFrame::YV16; 521 return VideoFrame::YV16;
522 case PIX_FMT_YUV444P:
523 return VideoFrame::I444;
520 case PIX_FMT_YUV420P: 524 case PIX_FMT_YUV420P:
521 return VideoFrame::YV12; 525 return VideoFrame::YV12;
522 case PIX_FMT_YUVJ420P: 526 case PIX_FMT_YUVJ420P:
523 return VideoFrame::YV12J; 527 return VideoFrame::YV12J;
524 case PIX_FMT_YUVA420P: 528 case PIX_FMT_YUVA420P:
525 return VideoFrame::YV12A; 529 return VideoFrame::YV12A;
526 default: 530 default:
527 DVLOG(1) << "Unsupported PixelFormat: " << pixel_format; 531 DVLOG(1) << "Unsupported PixelFormat: " << pixel_format;
528 } 532 }
529 return VideoFrame::UNKNOWN; 533 return VideoFrame::UNKNOWN;
530 } 534 }
531 535
532 PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format) { 536 PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format) {
533 switch (video_format) { 537 switch (video_format) {
534 case VideoFrame::YV16: 538 case VideoFrame::YV16:
535 return PIX_FMT_YUV422P; 539 return PIX_FMT_YUV422P;
536 case VideoFrame::YV12: 540 case VideoFrame::YV12:
537 return PIX_FMT_YUV420P; 541 return PIX_FMT_YUV420P;
538 case VideoFrame::YV12J: 542 case VideoFrame::YV12J:
539 return PIX_FMT_YUVJ420P; 543 return PIX_FMT_YUVJ420P;
540 case VideoFrame::YV12A: 544 case VideoFrame::YV12A:
541 return PIX_FMT_YUVA420P; 545 return PIX_FMT_YUVA420P;
546 case VideoFrame::I444:
547 return PIX_FMT_YUV422P;
scherkus (not reviewing) 2014/05/22 23:45:11 shouldn't this be PIX_FMT_YUV444P?
sandersd (OOO until July 31) 2014/05/23 00:45:22 Done.
542 default: 548 default:
543 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format; 549 DVLOG(1) << "Unsupported VideoFrame::Format: " << video_format;
544 } 550 }
545 return PIX_FMT_NONE; 551 return PIX_FMT_NONE;
546 } 552 }
547 553
548 bool FFmpegUTCDateToTime(const char* date_utc, 554 bool FFmpegUTCDateToTime(const char* date_utc,
549 base::Time* out) { 555 base::Time* out) {
550 DCHECK(date_utc); 556 DCHECK(date_utc);
551 DCHECK(out); 557 DCHECK(out);
(...skipping 20 matching lines...) Expand all
572 return false; 578 return false;
573 579
574 *out = parsed_time; 580 *out = parsed_time;
575 return true; 581 return true;
576 } 582 }
577 583
578 return false; 584 return false;
579 } 585 }
580 586
581 } // namespace media 587 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698