ref: ad693e1ff514f56928fc62790315906f9564395e
parent: 9ce3a7d76c5ef702337b96b9aa2c944da1b31869
author: hkuang <[email protected]>
date: Fri Oct 31 08:10:46 EDT 2014
Add key frame seeking to webmdec and webm_video_source. This is for the frame parallel's pause/seek/resume unit test. Change-Id: Ie235f86ca5f3d525896222766f6d610e6682fd76
--- a/test/webm_video_source.h
+++ b/test/webm_video_source.h
@@ -69,6 +69,18 @@
}
}
+ void SeekToNextKeyFrame() {
+ ASSERT_TRUE(vpx_ctx_->file != NULL);
+ do {
+ const int status = webm_read_frame(webm_ctx_, &buf_, &buf_sz_, &buf_sz_);
+ ASSERT_GE(status, 0) << "webm_read_frame failed";
+ ++frame_;
+ if (status == 1) {
+ end_of_file_ = true;
+ }
+ } while (!webm_ctx_->is_key_frame && !end_of_file_);
+ }
+
virtual const uint8_t *cxdata() const {
return end_of_file_ ? NULL : buf_;
}
--- a/webmdec.cc
+++ b/webmdec.cc
@@ -41,6 +41,7 @@
webm_ctx->block_frame_index = 0;
webm_ctx->video_track_index = 0;
webm_ctx->timestamp_ns = 0;
+ webm_ctx->is_key_frame = false;
}
void get_first_cluster(struct WebmInputContext *const webm_ctx) {
@@ -182,6 +183,7 @@
}
*bytes_in_buffer = frame.len;
webm_ctx->timestamp_ns = block->GetTime(cluster);
+ webm_ctx->is_key_frame = block->IsKey();
mkvparser::MkvReader *const reader =
reinterpret_cast<mkvparser::MkvReader*>(webm_ctx->reader);
--- a/webmdec.h
+++ b/webmdec.h
@@ -28,6 +28,7 @@
int block_frame_index;
int video_track_index;
uint64_t timestamp_ns;
+ int is_key_frame;
};
// Checks if the input is a WebM file. If so, initializes WebMInputContext so