Commit ad693e1f authored by hkuang's avatar hkuang

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
parent 9ce3a7d7
......@@ -69,6 +69,18 @@ class WebMVideoSource : public CompressedVideoSource {
}
}
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_;
}
......
......@@ -41,6 +41,7 @@ void reset(struct WebmInputContext *const webm_ctx) {
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 @@ int webm_read_frame(struct WebmInputContext *webm_ctx,
}
*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);
......
......@@ -28,6 +28,7 @@ struct WebmInputContext {
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
......
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