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

Unified Diff: media/filters/ffmpeg_demuxer.cc

Issue 363813002: Update to Pipeline Metadata and Decoder Stream for Orientation Data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Split enum to own file Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: media/filters/ffmpeg_demuxer.cc
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
index 05fa340ad55147d5b6d0934f35ea1b73c71d665d..1248974714eda608dfec7e03a48c1af9f0663e93 100644
--- a/media/filters/ffmpeg_demuxer.cc
+++ b/media/filters/ffmpeg_demuxer.cc
@@ -14,6 +14,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/metrics/sparse_histogram.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/sys_byteorder.h"
@@ -97,6 +98,8 @@ FFmpegDemuxerStream::FFmpegDemuxerStream(FFmpegDemuxer* demuxer,
DCHECK(demuxer_);
bool is_encrypted = false;
+ int rotation = 0;
+ AVDictionaryEntry* rotation_entry = NULL;
// Determine our media format.
switch (stream->codec->codec_type) {
@@ -109,6 +112,36 @@ FFmpegDemuxerStream::FFmpegDemuxerStream(FFmpegDemuxer* demuxer,
type_ = VIDEO;
AVStreamToVideoDecoderConfig(stream, &video_config_, true);
is_encrypted = video_config_.is_encrypted();
+
+ // Extract rotation metadata
+ rotation_entry = av_dict_get(stream->metadata, "rotate", NULL, 0);
+ if (rotation_entry && rotation_entry->value && rotation_entry->value[0])
+ base::StringToInt(rotation_entry->value, &rotation);
+
+ // Check that it is only a 90 degree increment
+ DCHECK(rotation == 0 || rotation == 90 || rotation == 180 ||
scherkus (not reviewing) 2014/07/07 22:41:11 if you gracefully handle it below there's no need
+ rotation == 270);
+
+ // Translate to the appropriate enum
scherkus (not reviewing) 2014/07/07 22:41:11 comment isn't very helpful -- I'd remove it
+ switch (rotation) {
+ case 90:
+ set_video_rotation(VIDEO_ROTATION_90);
+ break;
+ case 180:
+ set_video_rotation(VIDEO_ROTATION_180);
+ break;
+ case 270:
+ set_video_rotation(VIDEO_ROTATION_270);
+ break;
+ case 0:
+ set_video_rotation(VIDEO_ROTATION_0);
+ break;
+ default:
+ set_video_rotation(VIDEO_ROTATION_0);
+ LOG(ERROR) << "Unsupported video rotation metadata: " << rotation;
+ break;
+ }
+
break;
case AVMEDIA_TYPE_SUBTITLE:
type_ = TEXT;
« media/base/video_rotation.h ('K') | « media/base/video_rotation.h ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698