diff options
Diffstat (limited to 'media/ffmpeg/ffmpeg_common.cc')
-rw-r--r-- | media/ffmpeg/ffmpeg_common.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc index dedc40c..7af9635 100644 --- a/media/ffmpeg/ffmpeg_common.cc +++ b/media/ffmpeg/ffmpeg_common.cc @@ -185,4 +185,25 @@ bool GetStreamByteCountOverRange(AVStream* stream, return true; } +int GetSurfaceHeight(AVStream* stream) { + return stream->codec->coded_height; +} + +int GetSurfaceWidth(AVStream* stream) { + double aspect_ratio; + + if (stream->sample_aspect_ratio.num) + aspect_ratio = av_q2d(stream->sample_aspect_ratio); + else if (stream->codec->sample_aspect_ratio.num) + aspect_ratio = av_q2d(stream->codec->sample_aspect_ratio); + else + aspect_ratio = 1.0; + + int width = floor(stream->codec->coded_width * aspect_ratio + 0.5); + + // An even width makes things easier for YV12 and appears to be the behavior + // expected by WebKit layout tests. + return width & ~1; +} + } // namespace media |