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

Unified Diff: source/libvpx/vp8/vp8_dx_iface.c

Issue 12807010: libvpx: Fix pull from upstream (Closed) Base URL: https://src.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/libvpx/vp8/encoder/x86/quantize_sse2.c ('k') | source/libvpx/vpxenc.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/libvpx/vp8/vp8_dx_iface.c
===================================================================
--- source/libvpx/vp8/vp8_dx_iface.c (revision 191065)
+++ source/libvpx/vp8/vp8_dx_iface.c (working copy)
@@ -29,6 +29,8 @@
#define VP8_CAP_ERROR_CONCEALMENT (CONFIG_ERROR_CONCEALMENT ? \
VPX_CODEC_CAP_ERROR_CONCEALMENT : 0)
+#define VP8_DECRYPT_KEY_SIZE 32
+
typedef vpx_codec_stream_info_t vp8_stream_info_t;
/* Structures for handling memory allocations */
@@ -73,6 +75,7 @@
int dbg_color_b_modes_flag;
int dbg_display_mv_flag;
#endif
+ unsigned char decrypt_key[VP8_DECRYPT_KEY_SIZE];
vpx_image_t img;
int img_setup;
struct frame_buffers yv12_frame_buffers;
@@ -150,6 +153,8 @@
return res;
}
+static const unsigned char fake_decrypt_key[VP8_DECRYPT_KEY_SIZE] = { 0 };
+
static void vp8_init_ctx(vpx_codec_ctx_t *ctx, const vpx_codec_mmap_t *mmap)
{
int i;
@@ -164,6 +169,8 @@
ctx->priv->alg_priv->mmaps[0] = *mmap;
ctx->priv->alg_priv->si.sz = sizeof(ctx->priv->alg_priv->si);
+ memcpy(ctx->priv->alg_priv->decrypt_key, fake_decrypt_key,
+ VP8_DECRYPT_KEY_SIZE);
ctx->priv->init_flags = ctx->init_flags;
if (ctx->config.dec)
@@ -262,14 +269,17 @@
return VPX_CODEC_OK;
}
-static vpx_codec_err_t vp8_peek_si(const uint8_t *data,
- unsigned int data_sz,
- vpx_codec_stream_info_t *si)
+static vpx_codec_err_t vp8_peek_si_external(const uint8_t *data,
+ unsigned int data_sz,
+ vpx_codec_stream_info_t *si,
+ const unsigned char *decrypt_key)
{
vpx_codec_err_t res = VPX_CODEC_OK;
if(data + data_sz <= data)
+ {
res = VPX_CODEC_INVALID_PARAM;
+ }
else
{
/* Parse uncompresssed part of key frame header.
@@ -278,30 +288,45 @@
* 4 bytes:- including image width and height in the lowest 14 bits
* of each 2-byte value.
*/
+
+ const uint8_t data0 = decrypt_byte(data, data, decrypt_key);
si->is_kf = 0;
+ if (data_sz >= 10 && !(data0 & 0x01)) /* I-Frame */
+ {
+ const uint8_t data3 = decrypt_byte(data + 3, data, decrypt_key);
+ const uint8_t data4 = decrypt_byte(data + 4, data, decrypt_key);
+ const uint8_t data5 = decrypt_byte(data + 5, data, decrypt_key);
+ const uint8_t data6 = decrypt_byte(data + 6, data, decrypt_key);
+ const uint8_t data7 = decrypt_byte(data + 7, data, decrypt_key);
+ const uint8_t data8 = decrypt_byte(data + 8, data, decrypt_key);
+ const uint8_t data9 = decrypt_byte(data + 9, data, decrypt_key);
- if (data_sz >= 10 && !(data[0] & 0x01)) /* I-Frame */
- {
- const uint8_t *c = data + 3;
si->is_kf = 1;
/* vet via sync code */
- if (c[0] != 0x9d || c[1] != 0x01 || c[2] != 0x2a)
+ if (data3 != 0x9d || data4 != 0x01 || data5 != 0x2a)
res = VPX_CODEC_UNSUP_BITSTREAM;
- si->w = (c[3] | (c[4] << 8)) & 0x3fff;
- si->h = (c[5] | (c[6] << 8)) & 0x3fff;
+ si->w = (data6 | (data7 << 8)) & 0x3fff;
+ si->h = (data8 | (data9 << 8)) & 0x3fff;
/*printf("w=%d, h=%d\n", si->w, si->h);*/
if (!(si->h | si->w))
res = VPX_CODEC_UNSUP_BITSTREAM;
}
else
+ {
res = VPX_CODEC_UNSUP_BITSTREAM;
+ }
}
return res;
+}
+static vpx_codec_err_t vp8_peek_si(const uint8_t *data,
+ unsigned int data_sz,
+ vpx_codec_stream_info_t *si) {
+ return vp8_peek_si_external(data, data_sz, si, fake_decrypt_key);
}
static vpx_codec_err_t vp8_get_si(vpx_codec_alg_priv_t *ctx,
@@ -430,8 +455,10 @@
w = ctx->si.w;
h = ctx->si.h;
- res = ctx->base.iface->dec.peek_si(ctx->fragments.ptrs[0],
- ctx->fragments.sizes[0], &ctx->si);
+ res = vp8_peek_si_external(ctx->fragments.ptrs[0],
+ ctx->fragments.sizes[0],
+ &ctx->si,
+ ctx->decrypt_key);
if((res == VPX_CODEC_UNSUP_BITSTREAM) && !ctx->si.is_kf)
{
@@ -505,6 +532,7 @@
}
res = vp8_create_decoder_instances(&ctx->yv12_frame_buffers, &oxcf);
+ ctx->yv12_frame_buffers.pbi[0]->decrypt_key = ctx->decrypt_key;
}
ctx->decoder_init = 1;
@@ -926,6 +954,20 @@
}
+
+static vpx_codec_err_t vp8_set_decrypt_key(vpx_codec_alg_priv_t *ctx,
+ int ctr_id,
+ va_list args)
+{
+ const unsigned char *data = va_arg(args, const unsigned char *);
+ if (data == NULL) {
+ return VPX_CODEC_INVALID_PARAM;
+ }
+
+ memcpy(ctx->decrypt_key, data, VP8_DECRYPT_KEY_SIZE);
+ return VPX_CODEC_OK;
+}
+
vpx_codec_ctrl_fn_map_t vp8_ctf_maps[] =
{
{VP8_SET_REFERENCE, vp8_set_reference},
@@ -938,6 +980,7 @@
{VP8D_GET_LAST_REF_UPDATES, vp8_get_last_ref_updates},
{VP8D_GET_FRAME_CORRUPTED, vp8_get_frame_corrupted},
{VP8D_GET_LAST_REF_USED, vp8_get_last_ref_frame},
+ {VP8_SET_DECRYPT_KEY, vp8_set_decrypt_key},
{ -1, NULL},
};
« no previous file with comments | « source/libvpx/vp8/encoder/x86/quantize_sse2.c ('k') | source/libvpx/vpxenc.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698