Commit 2b1ec180 authored by Sebastien Alaiwan's avatar Sebastien Alaiwan

Drop support for decryption

This is a leftover from prior to media source extensions.
Decryption in Chrome doesn't use this path.

Change-Id: I95e07b5c93c380895bf017c7ebca4b2a0ca84949
parent de849bdf
......@@ -82,13 +82,6 @@ enum aom_dec_control_id {
*/
AOMD_GET_LAST_REF_USED,
/** decryption function to decrypt encoded buffer data immediately
* before decoding. Takes a aom_decrypt_init, which contains
* a callback function and opaque context pointer.
*/
AOMD_SET_DECRYPTOR,
// AOMD_SET_DECRYPTOR = AOMD_SET_DECRYPTOR,
/** control function to get the dimensions that the current frame is decoded
* at. This may be different to the intended display size for the frame as
* specified in the wrapper or frame header (see AV1D_GET_DISPLAY_SIZE). */
......@@ -157,24 +150,6 @@ enum aom_dec_control_id {
AOM_DECODER_CTRL_ID_MAX,
};
/** Decrypt n bytes of data from input -> output, using the decrypt_state
* passed in AOMD_SET_DECRYPTOR.
*/
typedef void (*aom_decrypt_cb)(void *decrypt_state, const unsigned char *input,
unsigned char *output, int count);
/*!\brief Structure to hold decryption state
*
* Defines a structure to hold the decryption state and access function.
*/
typedef struct aom_decrypt_init {
/*! Decrypt callback. */
aom_decrypt_cb decrypt_cb;
/*! Decryption state. */
void *decrypt_state;
} aom_decrypt_init;
/*!\cond */
/*!\brief AOM decoder control function parameter type
*
......@@ -191,10 +166,6 @@ AOM_CTRL_USE_TYPE(AOMD_GET_LAST_REF_USED, int *)
#define AOM_CTRL_AOMD_GET_LAST_REF_USED
AOM_CTRL_USE_TYPE(AOMD_GET_LAST_QUANTIZER, int *)
#define AOM_CTRL_AOMD_GET_LAST_QUANTIZER
AOM_CTRL_USE_TYPE(AOMD_SET_DECRYPTOR, aom_decrypt_init *)
#define AOM_CTRL_AOMD_SET_DECRYPTOR
// AOM_CTRL_USE_TYPE(AOMD_SET_DECRYPTOR, aom_decrypt_init *)
//#define AOM_CTRL_AOMD_SET_DECRYPTOR
AOM_CTRL_USE_TYPE(AV1D_GET_DISPLAY_SIZE, int *)
#define AOM_CTRL_AV1D_GET_DISPLAY_SIZE
AOM_CTRL_USE_TYPE(AV1D_GET_BIT_DEPTH, unsigned int *)
......
......@@ -62,10 +62,7 @@ extern "C" {
typedef struct daala_reader aom_reader;
static INLINE int aom_reader_init(aom_reader *r, const uint8_t *buffer,
size_t size, aom_decrypt_cb decrypt_cb,
void *decrypt_state) {
(void)decrypt_cb;
(void)decrypt_state;
size_t size) {
return aom_daala_reader_init(r, buffer, (int)size);
}
......
......@@ -46,8 +46,6 @@ struct aom_codec_alg_priv {
aom_codec_stream_info_t si;
int postproc_cfg_set;
aom_postproc_cfg_t postproc_cfg;
aom_decrypt_cb decrypt_cb;
void *decrypt_state;
aom_image_t img;
int img_avail;
int flushed;
......@@ -212,30 +210,24 @@ static int parse_bitdepth_colorspace_sampling(BITSTREAM_PROFILE profile,
}
#endif
static aom_codec_err_t decoder_peek_si_internal(
const uint8_t *data, unsigned int data_sz, aom_codec_stream_info_t *si,
int *is_intra_only, aom_decrypt_cb decrypt_cb, void *decrypt_state) {
static aom_codec_err_t decoder_peek_si_internal(const uint8_t *data,
unsigned int data_sz,
aom_codec_stream_info_t *si,
int *is_intra_only) {
int intra_only_flag = 0;
uint8_t clear_buffer[9];
if (data + data_sz <= data) return AOM_CODEC_INVALID_PARAM;
si->is_kf = 0;
si->w = si->h = 0;
if (decrypt_cb) {
data_sz = AOMMIN(sizeof(clear_buffer), data_sz);
decrypt_cb(decrypt_state, data, clear_buffer, data_sz);
data = clear_buffer;
}
// skip a potential superframe index
{
uint32_t frame_sizes[8];
int frame_count;
int index_size = 0;
aom_codec_err_t res = av1_parse_superframe_index(
data, data_sz, frame_sizes, &frame_count, &index_size, NULL, NULL);
aom_codec_err_t res = av1_parse_superframe_index(data, data_sz, frame_sizes,
&frame_count, &index_size);
if (res != AOM_CODEC_OK) return res;
data += index_size;
......@@ -356,7 +348,7 @@ static aom_codec_err_t decoder_peek_si_internal(
static aom_codec_err_t decoder_peek_si(const uint8_t *data,
unsigned int data_sz,
aom_codec_stream_info_t *si) {
return decoder_peek_si_internal(data, data_sz, si, NULL, NULL, NULL);
return decoder_peek_si_internal(data, data_sz, si, NULL);
}
static aom_codec_err_t decoder_get_si(aom_codec_alg_priv_t *ctx,
......@@ -565,8 +557,7 @@ static aom_codec_err_t decode_one(aom_codec_alg_priv_t *ctx,
if (!ctx->si.h) {
int is_intra_only = 0;
const aom_codec_err_t res =
decoder_peek_si_internal(*data, data_sz, &ctx->si, &is_intra_only,
ctx->decrypt_cb, ctx->decrypt_state);
decoder_peek_si_internal(*data, data_sz, &ctx->si, &is_intra_only);
if (res != AOM_CODEC_OK) return res;
if (!ctx->si.is_kf && !is_intra_only) return AOM_CODEC_ERROR;
......@@ -580,10 +571,6 @@ static aom_codec_err_t decode_one(aom_codec_alg_priv_t *ctx,
frame_worker_data->user_priv = user_priv;
frame_worker_data->received_frame = 1;
// Set these even if already initialized. The caller may have changed the
// decrypt config between frames.
frame_worker_data->pbi->decrypt_cb = ctx->decrypt_cb;
frame_worker_data->pbi->decrypt_state = ctx->decrypt_state;
#if CONFIG_INSPECTION
frame_worker_data->pbi->inspect_cb = ctx->inspect_cb;
frame_worker_data->pbi->inspect_ctx = ctx->inspect_ctx;
......@@ -702,8 +689,7 @@ static aom_codec_err_t decoder_decode(aom_codec_alg_priv_t *ctx,
#if !CONFIG_OBU
int index_size = 0;
res = av1_parse_superframe_index(data, data_sz, frame_sizes, &frame_count,
&index_size, ctx->decrypt_cb,
ctx->decrypt_state);
&index_size);
if (res != AOM_CODEC_OK) return res;
data_start += index_size;
......@@ -786,8 +772,7 @@ static aom_codec_err_t decoder_decode(aom_codec_alg_priv_t *ctx,
// Account for suboptimal termination by the encoder.
while (data_start < data_end) {
const uint8_t marker =
read_marker(ctx->decrypt_cb, ctx->decrypt_state, data_start);
const uint8_t marker = read_marker(data_start);
if (marker) break;
++data_start;
}
......@@ -1169,14 +1154,6 @@ static aom_codec_err_t ctrl_set_invert_tile_order(aom_codec_alg_priv_t *ctx,
return AOM_CODEC_OK;
}
static aom_codec_err_t ctrl_set_decryptor(aom_codec_alg_priv_t *ctx,
va_list args) {
aom_decrypt_init *init = va_arg(args, aom_decrypt_init *);
ctx->decrypt_cb = init ? init->decrypt_cb : NULL;
ctx->decrypt_state = init ? init->decrypt_state : NULL;
return AOM_CODEC_OK;
}
static aom_codec_err_t ctrl_set_byte_alignment(aom_codec_alg_priv_t *ctx,
va_list args) {
const int legacy_byte_alignment = 0;
......@@ -1267,7 +1244,6 @@ static aom_codec_ctrl_fn_map_t decoder_ctrl_maps[] = {
{ AOM_SET_DBG_COLOR_B_MODES, ctrl_set_dbg_options },
{ AOM_SET_DBG_DISPLAY_MV, ctrl_set_dbg_options },
{ AV1_INVERT_TILE_DECODE_ORDER, ctrl_set_invert_tile_order },
{ AOMD_SET_DECRYPTOR, ctrl_set_decryptor },
{ AV1_SET_BYTE_ALIGNMENT, ctrl_set_byte_alignment },
{ AV1_SET_SKIP_LOOP_FILTER, ctrl_set_skip_loop_filter },
{ AV1_SET_DECODE_TILE_ROW, ctrl_set_decode_tile_row },
......
......@@ -86,7 +86,7 @@ static void loop_restoration_read_sb_coeffs(const AV1_COMMON *const cm,
static struct aom_read_bit_buffer *init_read_bit_buffer(
AV1Decoder *pbi, struct aom_read_bit_buffer *rb, const uint8_t *data,
const uint8_t *data_end, uint8_t clear_data[MAX_AV1_HEADER_SIZE]);
const uint8_t *data_end);
static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
size_t partition_size);
static size_t read_uncompressed_header(AV1Decoder *pbi,
......@@ -744,8 +744,7 @@ static void decode_partition(AV1Decoder *const pbi, MACROBLOCKD *const xd,
static void setup_bool_decoder(const uint8_t *data, const uint8_t *data_end,
const size_t read_size,
struct aom_internal_error_info *error_info,
aom_reader *r, uint8_t allow_update_cdf,
aom_decrypt_cb decrypt_cb, void *decrypt_state) {
aom_reader *r, uint8_t allow_update_cdf) {
// Validate the calculated partition length. If the buffer
// described by the partition can't be fully read, then restrict
// it to the portion that can be (for EC mode) or throw an error.
......@@ -753,7 +752,7 @@ static void setup_bool_decoder(const uint8_t *data, const uint8_t *data_end,
aom_internal_error(error_info, AOM_CODEC_CORRUPT_FRAME,
"Truncated packet or corrupt tile length");
if (aom_reader_init(r, data, read_size, decrypt_cb, decrypt_state))
if (aom_reader_init(r, data, read_size))
aom_internal_error(error_info, AOM_CODEC_MEM_ERROR,
"Failed to allocate bool decoder %d", 1);
......@@ -1659,9 +1658,8 @@ static int mem_get_varsize(const uint8_t *src, int sz) {
// based on 'is_last'.
static void get_ls_tile_buffer(
const uint8_t *const data_end, struct aom_internal_error_info *error_info,
const uint8_t **data, aom_decrypt_cb decrypt_cb, void *decrypt_state,
TileBufferDec (*const tile_buffers)[MAX_TILE_COLS], int tile_size_bytes,
int col, int row, int tile_copy_mode) {
const uint8_t **data, TileBufferDec (*const tile_buffers)[MAX_TILE_COLS],
int tile_size_bytes, int col, int row, int tile_copy_mode) {
size_t size;
size_t copy_size = 0;
......@@ -1670,15 +1668,7 @@ static void get_ls_tile_buffer(
if (!read_is_valid(*data, tile_size_bytes, data_end))
aom_internal_error(error_info, AOM_CODEC_CORRUPT_FRAME,
"Truncated packet or corrupt tile length");
if (decrypt_cb) {
uint8_t be_data[4];
decrypt_cb(decrypt_state, *data, be_data, tile_size_bytes);
// Only read number of bytes in cm->tile_size_bytes.
size = mem_get_varsize(be_data, tile_size_bytes);
} else {
size = mem_get_varsize(*data, tile_size_bytes);
}
size = mem_get_varsize(*data, tile_size_bytes);
// If tile_copy_mode = 1, then the top bit of the tile header indicates copy
// mode.
......@@ -1778,8 +1768,7 @@ static void get_ls_tile_buffers(
tile_buffers[r][c].col = c;
get_ls_tile_buffer(tile_col_data_end[c], &pbi->common.error, &data,
pbi->decrypt_cb, pbi->decrypt_state, tile_buffers,
tile_size_bytes, c, r, tile_copy_mode);
tile_buffers, tile_size_bytes, c, r, tile_copy_mode);
}
}
......@@ -1793,8 +1782,7 @@ static void get_ls_tile_buffers(
tile_buffers[r][c].col = c;
get_ls_tile_buffer(tile_col_data_end[c], &pbi->common.error, &data,
pbi->decrypt_cb, pbi->decrypt_state, tile_buffers,
tile_size_bytes, c, r, tile_copy_mode);
tile_buffers, tile_size_bytes, c, r, tile_copy_mode);
}
}
}
......@@ -1806,8 +1794,7 @@ static void get_ls_tile_buffers(
static void get_tile_buffer(const uint8_t *const data_end,
const int tile_size_bytes, int is_last,
struct aom_internal_error_info *error_info,
const uint8_t **data, aom_decrypt_cb decrypt_cb,
void *decrypt_state, TileBufferDec *const buf) {
const uint8_t **data, TileBufferDec *const buf) {
size_t size;
if (!is_last) {
......@@ -1815,13 +1802,7 @@ static void get_tile_buffer(const uint8_t *const data_end,
aom_internal_error(error_info, AOM_CODEC_CORRUPT_FRAME,
"Truncated packet or corrupt tile length");
if (decrypt_cb) {
uint8_t be_data[4];
decrypt_cb(decrypt_state, *data, be_data, tile_size_bytes);
size = mem_get_varsize(be_data, tile_size_bytes);
} else {
size = mem_get_varsize(*data, tile_size_bytes);
}
size = mem_get_varsize(*data, tile_size_bytes);
*data += tile_size_bytes;
if (size > (size_t)(data_end - *data))
......@@ -1853,7 +1834,6 @@ static void get_tile_buffers(AV1Decoder *pbi, const uint8_t *data,
int first_tile_in_tg = 0;
#if !CONFIG_OBU
struct aom_read_bit_buffer rb_tg_hdr;
uint8_t clear_data[MAX_AV1_HEADER_SIZE];
const size_t hdr_size = pbi->uncomp_hdr_size + pbi->first_partition_size;
const int tg_size_bit_offset = pbi->tg_size_bit_offset;
#endif
......@@ -1893,7 +1873,7 @@ static void get_tile_buffers(AV1Decoder *pbi, const uint8_t *data,
#endif // CONFIG_DEPENDENT_HORZTILES
#else // CONFIG_OBU
if (hdr_offset) {
init_read_bit_buffer(pbi, &rb_tg_hdr, data, data_end, clear_data);
init_read_bit_buffer(pbi, &rb_tg_hdr, data, data_end);
rb_tg_hdr.bit_offset = tg_size_bit_offset;
read_tile_group_range(pbi, &rb_tg_hdr);
#if CONFIG_DEPENDENT_HORZTILES
......@@ -1905,8 +1885,7 @@ static void get_tile_buffers(AV1Decoder *pbi, const uint8_t *data,
first_tile_in_tg += tc == first_tile_in_tg ? pbi->tg_size : 0;
data += hdr_offset;
get_tile_buffer(data_end, pbi->tile_size_bytes, is_last,
&pbi->common.error, &data, pbi->decrypt_cb,
pbi->decrypt_state, buf);
&pbi->common.error, &data, buf);
#if CONFIG_DEPENDENT_HORZTILES
cm->tile_group_start_row[r][c] = tile_group_start_row;
cm->tile_group_start_col[r][c] = tile_group_start_col;
......@@ -2048,8 +2027,7 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data,
av1_zero(td->dqcoeff);
av1_tile_init(&td->xd.tile, td->cm, tile_row, tile_col);
setup_bool_decoder(buf->data, data_end, buf->size, &cm->error,
&td->bit_reader, allow_update_cdf, pbi->decrypt_cb,
pbi->decrypt_state);
&td->bit_reader, allow_update_cdf);
#if CONFIG_ACCOUNTING
if (pbi->acct_enabled) {
td->bit_reader.accounting = &pbi->accounting;
......@@ -3158,19 +3136,12 @@ static void debug_check_frame_counts(const AV1_COMMON *const cm) {
static struct aom_read_bit_buffer *init_read_bit_buffer(
AV1Decoder *pbi, struct aom_read_bit_buffer *rb, const uint8_t *data,
const uint8_t *data_end, uint8_t clear_data[MAX_AV1_HEADER_SIZE]) {
const uint8_t *data_end) {
rb->bit_offset = 0;
rb->error_handler = error_handler;
rb->error_handler_data = &pbi->common;
if (pbi->decrypt_cb) {
const int n = (int)AOMMIN(MAX_AV1_HEADER_SIZE, data_end - data);
pbi->decrypt_cb(pbi->decrypt_state, data, clear_data, n);
rb->bit_buffer = clear_data;
rb->bit_buffer_end = clear_data + n;
} else {
rb->bit_buffer = data;
rb->bit_buffer_end = data_end;
}
rb->bit_buffer = data;
rb->bit_buffer_end = data_end;
return rb;
}
......@@ -3259,10 +3230,9 @@ size_t av1_decode_frame_headers_and_setup(AV1Decoder *pbi, const uint8_t *data,
}
xd->global_motion = cm->global_motion;
uint8_t clear_data[MAX_AV1_HEADER_SIZE];
struct aom_read_bit_buffer rb;
const size_t first_partition_size = read_uncompressed_header(
pbi, init_read_bit_buffer(pbi, &rb, data, data_end, clear_data));
pbi, init_read_bit_buffer(pbi, &rb, data, data_end));
#if CONFIG_EXT_TILE
// If cm->single_tile_decoding = 0, the independent decoding of a single tile
......@@ -3721,11 +3691,9 @@ void av1_decode_frame_from_obus(struct AV1Decoder *pbi, const uint8_t *data,
// decode frame as a series of OBUs
while (!frame_decoding_finished && !cm->error.error_code) {
struct aom_read_bit_buffer rb;
uint8_t clear_data[80];
size_t obu_header_size, obu_payload_size = 0;
init_read_bit_buffer(pbi, &rb, data + PRE_OBU_SIZE_BYTES, data_end,
clear_data);
init_read_bit_buffer(pbi, &rb, data + PRE_OBU_SIZE_BYTES, data_end);
// every obu is preceded by PRE_OBU_SIZE_BYTES-byte size of obu (obu header +
// payload size)
......
......@@ -459,9 +459,7 @@ int av1_get_frame_to_show(AV1Decoder *pbi, YV12_BUFFER_CONFIG *frame) {
aom_codec_err_t av1_parse_superframe_index(const uint8_t *data, size_t data_sz,
uint32_t sizes[8], int *count,
int *index_size,
aom_decrypt_cb decrypt_cb,
void *decrypt_state) {
int *index_size) {
// A chunk ending with a byte matching 0xc0 is an invalid chunk unless
// it is a super frame index. If the last byte of real video compression
// data is 0xc0 the encoder must add a 0 byte. If we have the marker but
......@@ -472,7 +470,7 @@ aom_codec_err_t av1_parse_superframe_index(const uint8_t *data, size_t data_sz,
size_t frame_sz_sum = 0;
assert(data_sz);
marker = read_marker(decrypt_cb, decrypt_state, data);
marker = read_marker(data);
*count = 0;
if ((marker & 0xe0) == 0xc0) {
......@@ -486,8 +484,7 @@ aom_codec_err_t av1_parse_superframe_index(const uint8_t *data, size_t data_sz,
if (data_sz < index_sz) return AOM_CODEC_CORRUPT_FRAME;
{
const uint8_t marker2 =
read_marker(decrypt_cb, decrypt_state, data + index_sz - 1);
const uint8_t marker2 = read_marker(data + index_sz - 1);
// This chunk is marked as having a superframe index but doesn't have
// the matching marker byte at the front of the index therefore it's an
......@@ -500,14 +497,6 @@ aom_codec_err_t av1_parse_superframe_index(const uint8_t *data, size_t data_sz,
uint32_t i, j;
const uint8_t *x = &data[1];
// Frames has a maximum of 8 and mag has a maximum of 4.
uint8_t clear_buffer[28];
assert(sizeof(clear_buffer) >= (frames - 1) * mag);
if (decrypt_cb) {
decrypt_cb(decrypt_state, x, clear_buffer, (frames - 1) * mag);
x = clear_buffer;
}
for (i = 0; i < frames - 1; ++i) {
uint32_t this_sz = 0;
......
......@@ -77,9 +77,6 @@ typedef struct AV1Decoder {
AV1LfSync lf_row_sync;
aom_decrypt_cb decrypt_cb;
void *decrypt_state;
int allow_lowbitdepth;
int max_threads;
int inv_tile_order;
......@@ -119,23 +116,13 @@ aom_codec_err_t av1_copy_reference_dec(struct AV1Decoder *pbi, int idx,
aom_codec_err_t av1_set_reference_dec(AV1_COMMON *cm, int idx,
YV12_BUFFER_CONFIG *sd);
static INLINE uint8_t read_marker(aom_decrypt_cb decrypt_cb,
void *decrypt_state, const uint8_t *data) {
if (decrypt_cb) {
uint8_t marker;
decrypt_cb(decrypt_state, data, &marker, 1);
return marker;
}
return *data;
}
static INLINE uint8_t read_marker(const uint8_t *data) { return *data; }
// This function is exposed for use in tests, as well as the inlined function
// "read_marker".
aom_codec_err_t av1_parse_superframe_index(const uint8_t *data, size_t data_sz,
uint32_t sizes[8], int *count,
int *index_size,
aom_decrypt_cb decrypt_cb,
void *decrypt_state);
int *index_size);
struct AV1Decoder *av1_decoder_create(BufferPool *const pool);
......
......@@ -35,7 +35,7 @@ TEST(AV1, TestAccounting) {
}
aom_stop_encode(&bw);
aom_reader br;
aom_reader_init(&br, bw_buffer, bw.pos, NULL, NULL);
aom_reader_init(&br, bw_buffer, bw.pos);
Accounting accounting;
aom_accounting_init(&accounting);
......@@ -51,7 +51,7 @@ TEST(AV1, TestAccounting) {
GTEST_ASSERT_EQ(accounting.syms.num_syms, 0);
// Should record 2 * kSymbols accounting symbols.
aom_reader_init(&br, bw_buffer, bw.pos, NULL, NULL);
aom_reader_init(&br, bw_buffer, bw.pos);
br.accounting = &accounting;
for (int i = 0; i < kSymbols; i++) {
aom_read(&br, 32, "A");
......
......@@ -60,7 +60,7 @@ TEST(AV1, TestPrimitiveRefsubexpfin) {
}
aom_stop_encode(&bw);
aom_reader br;
aom_reader_init(&br, bw_buffer, bw.pos, NULL, NULL);
aom_reader_init(&br, bw_buffer, bw.pos);
GTEST_ASSERT_GE(aom_reader_tell(&br), 0u);
GTEST_ASSERT_LE(aom_reader_tell(&br), 1u);
for (int n = 0; n < kRanges; ++n) {
......
......@@ -69,7 +69,7 @@ TEST(AV1, TestBitIO) {
aom_stop_encode(&bw);
aom_reader br;
aom_reader_init(&br, bw_buffer, bw.pos, NULL, NULL);
aom_reader_init(&br, bw_buffer, bw.pos);
bit_rnd.Reset(random_seed);
for (int i = 0; i < kBitsToTest; ++i) {
if (bit_method == 2) {
......@@ -106,7 +106,7 @@ TEST(AV1, TestTell) {
}
aom_stop_encode(&bw);
aom_reader br;
aom_reader_init(&br, bw_buffer, bw.pos, NULL, NULL);
aom_reader_init(&br, bw_buffer, bw.pos);
uint32_t last_tell = aom_reader_tell(&br);
uint32_t last_tell_frac = aom_reader_tell_frac(&br);
double frac_diff_total = 0;
......
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