summaryrefslogtreecommitdiff
path: root/vp8
diff options
context:
space:
mode:
authorJoey Parrish <joeyparrish@google.com>2014-04-24 07:45:20 -0700
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2014-04-24 07:45:20 -0700
commit109f58acfd8d46deec1e0bd4d0f82daa36cd6b8e (patch)
tree8ec8ba887aec90a218087311785b7c24d77d7501 /vp8
parent025969d910c39ad43b95447efa2fdd46a335276a (diff)
parent18c08607e0a216962fd3df4f7926ce288ee81b9b (diff)
downloadlibvpx-109f58acfd8d46deec1e0bd4d0f82daa36cd6b8e.tar
libvpx-109f58acfd8d46deec1e0bd4d0f82daa36cd6b8e.tar.gz
libvpx-109f58acfd8d46deec1e0bd4d0f82daa36cd6b8e.tar.bz2
libvpx-109f58acfd8d46deec1e0bd4d0f82daa36cd6b8e.zip
Merge "Add VPXD_SET_DECRYPTOR support to the VP9 decoder."
Diffstat (limited to 'vp8')
-rw-r--r--vp8/common/common.h3
-rw-r--r--vp8/decoder/dboolhuff.c7
-rw-r--r--vp8/decoder/dboolhuff.h11
-rw-r--r--vp8/decoder/decodeframe.c4
-rw-r--r--vp8/decoder/error_concealment.c4
-rw-r--r--vp8/decoder/onyxd_int.h2
-rw-r--r--vp8/encoder/mcomp.c1
-rw-r--r--vp8/encoder/mr_dissim.c1
-rw-r--r--vp8/encoder/onyx_int.h3
-rw-r--r--vp8/encoder/pickinter.c1
-rw-r--r--vp8/vp8_dx_iface.c22
11 files changed, 30 insertions, 29 deletions
diff --git a/vp8/common/common.h b/vp8/common/common.h
index ee5b58c75..17262d698 100644
--- a/vp8/common/common.h
+++ b/vp8/common/common.h
@@ -22,6 +22,9 @@
extern "C" {
#endif
+#define MIN(x, y) (((x) < (y)) ? (x) : (y))
+#define MAX(x, y) (((x) > (y)) ? (x) : (y))
+
/* Only need this for fixed-size arrays, for structs just assign. */
#define vp8_copy( Dest, Src) { \
diff --git a/vp8/decoder/dboolhuff.c b/vp8/decoder/dboolhuff.c
index 0007d7a7a..b874d4c46 100644
--- a/vp8/decoder/dboolhuff.c
+++ b/vp8/decoder/dboolhuff.c
@@ -10,11 +10,12 @@
#include "dboolhuff.h"
+#include "vp8/common/common.h"
int vp8dx_start_decode(BOOL_DECODER *br,
const unsigned char *source,
unsigned int source_sz,
- vp8_decrypt_cb *decrypt_cb,
+ vpx_decrypt_cb decrypt_cb,
void *decrypt_state)
{
br->user_buffer_end = source+source_sz;
@@ -39,7 +40,7 @@ void vp8dx_bool_decoder_fill(BOOL_DECODER *br)
const unsigned char *bufptr = br->user_buffer;
VP8_BD_VALUE value = br->value;
int count = br->count;
- int shift = VP8_BD_VALUE_SIZE - 8 - (count + 8);
+ int shift = VP8_BD_VALUE_SIZE - CHAR_BIT - (count + CHAR_BIT);
size_t bytes_left = br->user_buffer_end - bufptr;
size_t bits_left = bytes_left * CHAR_BIT;
int x = (int)(shift + CHAR_BIT - bits_left);
@@ -47,7 +48,7 @@ void vp8dx_bool_decoder_fill(BOOL_DECODER *br)
unsigned char decrypted[sizeof(VP8_BD_VALUE) + 1];
if (br->decrypt_cb) {
- size_t n = bytes_left > sizeof(decrypted) ? sizeof(decrypted) : bytes_left;
+ size_t n = MIN(sizeof(decrypted), bytes_left);
br->decrypt_cb(br->decrypt_state, bufptr, decrypted, (int)n);
bufptr = decrypted;
}
diff --git a/vp8/decoder/dboolhuff.h b/vp8/decoder/dboolhuff.h
index 36af7eed5..51c5adc28 100644
--- a/vp8/decoder/dboolhuff.h
+++ b/vp8/decoder/dboolhuff.h
@@ -17,6 +17,7 @@
#include "vpx_config.h"
#include "vpx_ports/mem.h"
+#include "vpx/vp8dx.h"
#include "vpx/vpx_integer.h"
#ifdef __cplusplus
@@ -32,12 +33,6 @@ typedef size_t VP8_BD_VALUE;
Even relatively modest values like 100 would work fine.*/
#define VP8_LOTS_OF_BITS (0x40000000)
-/*Decrypt n bytes of data from input -> output, using the decrypt_state
- passed in VP8D_SET_DECRYPTOR.
-*/
-typedef void (vp8_decrypt_cb)(void *decrypt_state, const unsigned char *input,
- unsigned char *output, int count);
-
typedef struct
{
const unsigned char *user_buffer_end;
@@ -45,7 +40,7 @@ typedef struct
VP8_BD_VALUE value;
int count;
unsigned int range;
- vp8_decrypt_cb *decrypt_cb;
+ vpx_decrypt_cb decrypt_cb;
void *decrypt_state;
} BOOL_DECODER;
@@ -54,7 +49,7 @@ DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]);
int vp8dx_start_decode(BOOL_DECODER *br,
const unsigned char *source,
unsigned int source_sz,
- vp8_decrypt_cb *decrypt_cb,
+ vpx_decrypt_cb decrypt_cb,
void *decrypt_state);
void vp8dx_bool_decoder_fill(BOOL_DECODER *br);
diff --git a/vp8/decoder/decodeframe.c b/vp8/decoder/decodeframe.c
index 14f611ad9..e7cf0d9b9 100644
--- a/vp8/decoder/decodeframe.c
+++ b/vp8/decoder/decodeframe.c
@@ -17,6 +17,7 @@
#include "vp8/common/reconintra4x4.h"
#include "vp8/common/reconinter.h"
#include "detokenize.h"
+#include "vp8/common/common.h"
#include "vp8/common/invtrans.h"
#include "vp8/common/alloccommon.h"
#include "vp8/common/entropymode.h"
@@ -1018,8 +1019,7 @@ int vp8_decode_frame(VP8D_COMP *pbi)
const unsigned char *clear = data;
if (pbi->decrypt_cb)
{
- int n = (int)(data_end - data);
- if (n > 10) n = 10;
+ int n = (int)MIN(sizeof(clear_buffer), data_end - data);
pbi->decrypt_cb(pbi->decrypt_state, data, clear_buffer, n);
clear = clear_buffer;
}
diff --git a/vp8/decoder/error_concealment.c b/vp8/decoder/error_concealment.c
index 0b58c98fd..4b304c83c 100644
--- a/vp8/decoder/error_concealment.c
+++ b/vp8/decoder/error_concealment.c
@@ -15,9 +15,7 @@
#include "decodemv.h"
#include "vpx_mem/vpx_mem.h"
#include "vp8/common/findnearmv.h"
-
-#define MIN(x,y) (((x)<(y))?(x):(y))
-#define MAX(x,y) (((x)>(y))?(x):(y))
+#include "vp8/common/common.h"
#define FLOOR(x,q) ((x) & -(1 << (q)))
diff --git a/vp8/decoder/onyxd_int.h b/vp8/decoder/onyxd_int.h
index 8ef489403..aa2cc57f7 100644
--- a/vp8/decoder/onyxd_int.h
+++ b/vp8/decoder/onyxd_int.h
@@ -126,7 +126,7 @@ typedef struct VP8D_COMP
int independent_partitions;
int frame_corrupt_residual;
- vp8_decrypt_cb *decrypt_cb;
+ vpx_decrypt_cb decrypt_cb;
void *decrypt_state;
} VP8D_COMP;
diff --git a/vp8/encoder/mcomp.c b/vp8/encoder/mcomp.c
index 0b11ea64a..54abe76ac 100644
--- a/vp8/encoder/mcomp.c
+++ b/vp8/encoder/mcomp.c
@@ -17,6 +17,7 @@
#include <limits.h>
#include <math.h>
#include "vp8/common/findnearmv.h"
+#include "vp8/common/common.h"
#ifdef VP8_ENTROPY_STATS
static int mv_ref_ct [31] [4] [2];
diff --git a/vp8/encoder/mr_dissim.c b/vp8/encoder/mr_dissim.c
index 71218cca1..8d96445f5 100644
--- a/vp8/encoder/mr_dissim.c
+++ b/vp8/encoder/mr_dissim.c
@@ -15,6 +15,7 @@
#include "mr_dissim.h"
#include "vpx_mem/vpx_mem.h"
#include "rdopt.h"
+#include "vp8/common/common.h"
void vp8_cal_low_res_mb_cols(VP8_COMP *cpi)
{
diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h
index 6b371671d..df17dff34 100644
--- a/vp8/encoder/onyx_int.h
+++ b/vp8/encoder/onyx_int.h
@@ -61,9 +61,6 @@ extern "C" {
#define VP8_TEMPORAL_ALT_REF 1
#endif
-#define MAX(x,y) (((x)>(y))?(x):(y))
-#define MIN(x,y) (((x)<(y))?(x):(y))
-
typedef struct
{
int kf_indicated;
diff --git a/vp8/encoder/pickinter.c b/vp8/encoder/pickinter.c
index c5279fed2..39a3baf10 100644
--- a/vp8/encoder/pickinter.c
+++ b/vp8/encoder/pickinter.c
@@ -14,6 +14,7 @@
#include "onyx_int.h"
#include "modecosts.h"
#include "encodeintra.h"
+#include "vp8/common/common.h"
#include "vp8/common/entropymode.h"
#include "pickinter.h"
#include "vp8/common/findnearmv.h"
diff --git a/vp8/vp8_dx_iface.c b/vp8/vp8_dx_iface.c
index d75d25859..10cbc6a58 100644
--- a/vp8/vp8_dx_iface.c
+++ b/vp8/vp8_dx_iface.c
@@ -16,9 +16,10 @@
#include "vpx/vp8dx.h"
#include "vpx/internal/vpx_codec_internal.h"
#include "vpx_version.h"
+#include "common/alloccommon.h"
+#include "common/common.h"
#include "common/onyxd.h"
#include "decoder/onyxd_int.h"
-#include "common/alloccommon.h"
#include "vpx_mem/vpx_mem.h"
#if CONFIG_ERROR_CONCEALMENT
#include "decoder/error_concealment.h"
@@ -56,7 +57,7 @@ struct vpx_codec_alg_priv
int dbg_color_b_modes_flag;
int dbg_display_mv_flag;
#endif
- vp8_decrypt_cb *decrypt_cb;
+ vpx_decrypt_cb decrypt_cb;
void *decrypt_state;
vpx_image_t img;
int img_setup;
@@ -156,7 +157,7 @@ static vpx_codec_err_t vp8_destroy(vpx_codec_alg_priv_t *ctx)
static vpx_codec_err_t vp8_peek_si_internal(const uint8_t *data,
unsigned int data_sz,
vpx_codec_stream_info_t *si,
- vp8_decrypt_cb *decrypt_cb,
+ vpx_decrypt_cb decrypt_cb,
void *decrypt_state)
{
vpx_codec_err_t res = VPX_CODEC_OK;
@@ -177,7 +178,7 @@ static vpx_codec_err_t vp8_peek_si_internal(const uint8_t *data,
const uint8_t *clear = data;
if (decrypt_cb)
{
- int n = data_sz > 10 ? 10 : data_sz;
+ int n = MIN(sizeof(clear_buffer), data_sz);
decrypt_cb(decrypt_state, data, clear_buffer, n);
clear = clear_buffer;
}
@@ -379,12 +380,15 @@ static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx,
}
res = vp8_create_decoder_instances(&ctx->yv12_frame_buffers, &oxcf);
- ctx->yv12_frame_buffers.pbi[0]->decrypt_cb = ctx->decrypt_cb;
- ctx->yv12_frame_buffers.pbi[0]->decrypt_state = ctx->decrypt_state;
-
ctx->decoder_init = 1;
}
+ /* Set these even if already initialized. The caller may have changed the
+ * decrypt config between frames.
+ */
+ ctx->yv12_frame_buffers.pbi[0]->decrypt_cb = ctx->decrypt_cb;
+ ctx->yv12_frame_buffers.pbi[0]->decrypt_state = ctx->decrypt_state;
+
if (!res)
{
VP8D_COMP *pbi = ctx->yv12_frame_buffers.pbi[0];
@@ -722,7 +726,7 @@ static vpx_codec_err_t vp8_set_decryptor(vpx_codec_alg_priv_t *ctx,
int ctrl_id,
va_list args)
{
- vp8_decrypt_init *init = va_arg(args, vp8_decrypt_init *);
+ vpx_decrypt_init *init = va_arg(args, vpx_decrypt_init *);
if (init)
{
@@ -749,7 +753,7 @@ vpx_codec_ctrl_fn_map_t vp8_ctf_maps[] =
{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},
- {VP8D_SET_DECRYPTOR, vp8_set_decryptor},
+ {VPXD_SET_DECRYPTOR, vp8_set_decryptor},
{ -1, NULL},
};