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

Side by Side Diff: source/libvpx/vp9/decoder/vp9_decoder.c

Issue 484923003: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 *sd = *cm->frame_to_show; 307 *sd = *cm->frame_to_show;
308 ret = 0; 308 ret = 0;
309 } 309 }
310 #else 310 #else
311 *sd = *cm->frame_to_show; 311 *sd = *cm->frame_to_show;
312 ret = 0; 312 ret = 0;
313 #endif /*!CONFIG_POSTPROC*/ 313 #endif /*!CONFIG_POSTPROC*/
314 vp9_clear_system_state(); 314 vp9_clear_system_state();
315 return ret; 315 return ret;
316 } 316 }
317
318 vpx_codec_err_t vp9_parse_superframe_index(const uint8_t *data,
319 size_t data_sz,
320 uint32_t sizes[8], int *count,
321 vpx_decrypt_cb decrypt_cb,
322 void *decrypt_state) {
323 // A chunk ending with a byte matching 0xc0 is an invalid chunk unless
324 // it is a super frame index. If the last byte of real video compression
325 // data is 0xc0 the encoder must add a 0 byte. If we have the marker but
326 // not the associated matching marker byte at the front of the index we have
327 // an invalid bitstream and need to return an error.
328
329 uint8_t marker;
330
331 assert(data_sz);
332 marker = read_marker(decrypt_cb, decrypt_state, data + data_sz - 1);
333 *count = 0;
334
335 if ((marker & 0xe0) == 0xc0) {
336 const uint32_t frames = (marker & 0x7) + 1;
337 const uint32_t mag = ((marker >> 3) & 0x3) + 1;
338 const size_t index_sz = 2 + mag * frames;
339
340 // This chunk is marked as having a superframe index but doesn't have
341 // enough data for it, thus it's an invalid superframe index.
342 if (data_sz < index_sz)
343 return VPX_CODEC_CORRUPT_FRAME;
344
345 {
346 const uint8_t marker2 = read_marker(decrypt_cb, decrypt_state,
347 data + data_sz - index_sz);
348
349 // This chunk is marked as having a superframe index but doesn't have
350 // the matching marker byte at the front of the index therefore it's an
351 // invalid chunk.
352 if (marker != marker2)
353 return VPX_CODEC_CORRUPT_FRAME;
354 }
355
356 {
357 // Found a valid superframe index.
358 uint32_t i, j;
359 const uint8_t *x = &data[data_sz - index_sz + 1];
360
361 // Frames has a maximum of 8 and mag has a maximum of 4.
362 uint8_t clear_buffer[32];
363 assert(sizeof(clear_buffer) >= frames * mag);
364 if (decrypt_cb) {
365 decrypt_cb(decrypt_state, x, clear_buffer, frames * mag);
366 x = clear_buffer;
367 }
368
369 for (i = 0; i < frames; ++i) {
370 uint32_t this_sz = 0;
371
372 for (j = 0; j < mag; ++j)
373 this_sz |= (*x++) << (j * 8);
374 sizes[i] = this_sz;
375 }
376 *count = frames;
377 }
378 }
379 return VPX_CODEC_OK;
380 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_decoder.h ('k') | source/libvpx/vp9/encoder/arm/neon/vp9_quantize_neon.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698