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

Side by Side Diff: source/libvpx/webmdec.cc

Issue 1124333011: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: only update to last nights LKGR Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « source/libvpx/webmdec.h ('k') | update_libvpx.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 rewind(vpx_ctx->file); 56 rewind(vpx_ctx->file);
57 reset(webm_ctx); 57 reset(webm_ctx);
58 } 58 }
59 59
60 } // namespace 60 } // namespace
61 61
62 int file_is_webm(struct WebmInputContext *webm_ctx, 62 int file_is_webm(struct WebmInputContext *webm_ctx,
63 struct VpxInputContext *vpx_ctx) { 63 struct VpxInputContext *vpx_ctx) {
64 mkvparser::MkvReader *const reader = new mkvparser::MkvReader(vpx_ctx->file); 64 mkvparser::MkvReader *const reader = new mkvparser::MkvReader(vpx_ctx->file);
65 webm_ctx->reader = reader; 65 webm_ctx->reader = reader;
66 webm_ctx->reached_eos = 0;
66 67
67 mkvparser::EBMLHeader header; 68 mkvparser::EBMLHeader header;
68 long long pos = 0; 69 long long pos = 0;
69 if (header.Parse(reader, pos) < 0) { 70 if (header.Parse(reader, pos) < 0) {
70 rewind_and_reset(webm_ctx, vpx_ctx); 71 rewind_and_reset(webm_ctx, vpx_ctx);
71 return 0; 72 return 0;
72 } 73 }
73 74
74 mkvparser::Segment* segment; 75 mkvparser::Segment* segment;
75 if (mkvparser::Segment::CreateInstance(reader, pos, segment)) { 76 if (mkvparser::Segment::CreateInstance(reader, pos, segment)) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 115
115 get_first_cluster(webm_ctx); 116 get_first_cluster(webm_ctx);
116 117
117 return 1; 118 return 1;
118 } 119 }
119 120
120 int webm_read_frame(struct WebmInputContext *webm_ctx, 121 int webm_read_frame(struct WebmInputContext *webm_ctx,
121 uint8_t **buffer, 122 uint8_t **buffer,
122 size_t *bytes_in_buffer, 123 size_t *bytes_in_buffer,
123 size_t *buffer_size) { 124 size_t *buffer_size) {
125 // This check is needed for frame parallel decoding, in which case this
126 // function could be called even after it has reached end of input stream.
127 if (webm_ctx->reached_eos) {
128 return 1;
129 }
124 mkvparser::Segment *const segment = 130 mkvparser::Segment *const segment =
125 reinterpret_cast<mkvparser::Segment*>(webm_ctx->segment); 131 reinterpret_cast<mkvparser::Segment*>(webm_ctx->segment);
126 const mkvparser::Cluster* cluster = 132 const mkvparser::Cluster* cluster =
127 reinterpret_cast<const mkvparser::Cluster*>(webm_ctx->cluster); 133 reinterpret_cast<const mkvparser::Cluster*>(webm_ctx->cluster);
128 const mkvparser::Block *block = 134 const mkvparser::Block *block =
129 reinterpret_cast<const mkvparser::Block*>(webm_ctx->block); 135 reinterpret_cast<const mkvparser::Block*>(webm_ctx->block);
130 const mkvparser::BlockEntry *block_entry = 136 const mkvparser::BlockEntry *block_entry =
131 reinterpret_cast<const mkvparser::BlockEntry*>(webm_ctx->block_entry); 137 reinterpret_cast<const mkvparser::BlockEntry*>(webm_ctx->block_entry);
132 bool block_entry_eos = false; 138 bool block_entry_eos = false;
133 do { 139 do {
134 long status = 0; 140 long status = 0;
135 bool get_new_block = false; 141 bool get_new_block = false;
136 if (block_entry == NULL && !block_entry_eos) { 142 if (block_entry == NULL && !block_entry_eos) {
137 status = cluster->GetFirst(block_entry); 143 status = cluster->GetFirst(block_entry);
138 get_new_block = true; 144 get_new_block = true;
139 } else if (block_entry_eos || block_entry->EOS()) { 145 } else if (block_entry_eos || block_entry->EOS()) {
140 cluster = segment->GetNext(cluster); 146 cluster = segment->GetNext(cluster);
141 if (cluster == NULL || cluster->EOS()) { 147 if (cluster == NULL || cluster->EOS()) {
142 *bytes_in_buffer = 0; 148 *bytes_in_buffer = 0;
149 webm_ctx->reached_eos = 1;
143 return 1; 150 return 1;
144 } 151 }
145 status = cluster->GetFirst(block_entry); 152 status = cluster->GetFirst(block_entry);
146 block_entry_eos = false; 153 block_entry_eos = false;
147 get_new_block = true; 154 get_new_block = true;
148 } else if (block == NULL || 155 } else if (block == NULL ||
149 webm_ctx->block_frame_index == block->GetFrameCount() || 156 webm_ctx->block_frame_index == block->GetFrameCount() ||
150 block->GetTrackNumber() != webm_ctx->video_track_index) { 157 block->GetTrackNumber() != webm_ctx->video_track_index) {
151 status = cluster->GetNext(block_entry, block_entry); 158 status = cluster->GetNext(block_entry, block_entry);
152 if (block_entry == NULL || block_entry->EOS()) { 159 if (block_entry == NULL || block_entry->EOS()) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 vpx_ctx->framerate.numerator = (i - 1) * 1000000; 212 vpx_ctx->framerate.numerator = (i - 1) * 1000000;
206 vpx_ctx->framerate.denominator = 213 vpx_ctx->framerate.denominator =
207 static_cast<int>(webm_ctx->timestamp_ns / 1000); 214 static_cast<int>(webm_ctx->timestamp_ns / 1000);
208 delete[] buffer; 215 delete[] buffer;
209 216
210 get_first_cluster(webm_ctx); 217 get_first_cluster(webm_ctx);
211 webm_ctx->block = NULL; 218 webm_ctx->block = NULL;
212 webm_ctx->block_entry = NULL; 219 webm_ctx->block_entry = NULL;
213 webm_ctx->block_frame_index = 0; 220 webm_ctx->block_frame_index = 0;
214 webm_ctx->timestamp_ns = 0; 221 webm_ctx->timestamp_ns = 0;
222 webm_ctx->reached_eos = 0;
215 223
216 return 0; 224 return 0;
217 } 225 }
218 226
219 void webm_free(struct WebmInputContext *webm_ctx) { 227 void webm_free(struct WebmInputContext *webm_ctx) {
220 reset(webm_ctx); 228 reset(webm_ctx);
221 } 229 }
OLDNEW
« no previous file with comments | « source/libvpx/webmdec.h ('k') | update_libvpx.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698