Commit 893e084b authored by ivankr@chromium.org's avatar ivankr@chromium.org

Add proper duration to WebmEncoder-created files.


BUG=132423
TEST=Manual, encoded video can be looped


Review URL: https://chromiumcodereview.appspot.com/10823006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148335 0039d316-1c4b-4281-b951-d872f2087c98
parent 679facce
...@@ -84,7 +84,7 @@ bool WebmEncoder::EncodeFromSprite(const SkBitmap& sprite, ...@@ -84,7 +84,7 @@ bool WebmEncoder::EncodeFromSprite(const SkBitmap& sprite,
fps_.den = fps_d; fps_.den = fps_d;
// Sprite is tiled vertically. // Sprite is tiled vertically.
size_t frame_count = sprite.height() / width_; frame_count_ = sprite.height() / width_;
vpx_image_t image; vpx_image_t image;
vpx_img_alloc(&image, VPX_IMG_FMT_I420, width_, height_, 16); vpx_img_alloc(&image, VPX_IMG_FMT_I420, width_, height_, 16);
...@@ -124,7 +124,7 @@ bool WebmEncoder::EncodeFromSprite(const SkBitmap& sprite, ...@@ -124,7 +124,7 @@ bool WebmEncoder::EncodeFromSprite(const SkBitmap& sprite,
if (!WriteWebmHeader()) if (!WriteWebmHeader())
return false; return false;
for (size_t frame = 0; frame < frame_count && !has_errors_; ++frame) { for (size_t frame = 0; frame < frame_count_ && !has_errors_; ++frame) {
int res = libyuv::ConvertToI420( int res = libyuv::ConvertToI420(
src, src_frame_size, src, src_frame_size,
image.planes[VPX_PLANE_Y], image.stride[VPX_PLANE_Y], image.planes[VPX_PLANE_Y], image.stride[VPX_PLANE_Y],
...@@ -183,6 +183,8 @@ bool WebmEncoder::WriteWebmHeader() { ...@@ -183,6 +183,8 @@ bool WebmEncoder::WriteWebmHeader() {
{ {
// All timecodes in the segment will be expressed in milliseconds. // All timecodes in the segment will be expressed in milliseconds.
Ebml_SerializeUnsigned(&ebml_writer_, TimecodeScale, 1000000); Ebml_SerializeUnsigned(&ebml_writer_, TimecodeScale, 1000000);
double duration = 1000. * frame_count_ * fps_.den / fps_.num;
Ebml_SerializeFloat(&ebml_writer_, Segment_Duration, duration);
} }
EndSubElement(); // Info EndSubElement(); // Info
......
...@@ -70,6 +70,9 @@ class MEDIA_EXPORT WebmEncoder { ...@@ -70,6 +70,9 @@ class MEDIA_EXPORT WebmEncoder {
size_t height_; size_t height_;
vpx_rational_t fps_; vpx_rational_t fps_;
// Number of frames in video.
size_t frame_count_;
// VPX config in use. // VPX config in use.
vpx_codec_enc_cfg_t config_; vpx_codec_enc_cfg_t config_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment