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
diff --git a/aom/aomdx.h b/aom/aomdx.h
index 7d2100e..4ab2361 100644
--- a/aom/aomdx.h
+++ b/aom/aomdx.h
@@ -82,13 +82,6 @@
    */
   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 @@
   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 @@
 #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 *)
diff --git a/aom_dsp/bitreader.h b/aom_dsp/bitreader.h
index 69709d9..d60da8c 100644
--- a/aom_dsp/bitreader.h
+++ b/aom_dsp/bitreader.h
@@ -62,10 +62,7 @@
 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);
 }
 
diff --git a/av1/av1_dx_iface.c b/av1/av1_dx_iface.c
index a8903e5..3090d73 100644
--- a/av1/av1_dx_iface.c
+++ b/av1/av1_dx_iface.c
@@ -46,8 +46,6 @@
   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 @@
 }
 #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(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 @@
   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 @@
     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 @@
 #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 @@
 
         // 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 @@
   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 @@
   { 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 },
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index ca70f37..0d2716b 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -86,7 +86,7 @@
 
 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 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 @@
     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 @@
 // 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 @@
   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 @@
         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 @@
         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_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 @@
       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 @@
   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 @@
 #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 @@
       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 @@
       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 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 @@
   }
   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 @@
   // 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)
diff --git a/av1/decoder/decoder.c b/av1/decoder/decoder.c
index 0bce555..3464887 100644
--- a/av1/decoder/decoder.c
+++ b/av1/decoder/decoder.c
@@ -459,9 +459,7 @@
 
 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 @@
   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 @@
     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 @@
       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;
 
diff --git a/av1/decoder/decoder.h b/av1/decoder/decoder.h
index 28227a5..6d8c171 100644
--- a/av1/decoder/decoder.h
+++ b/av1/decoder/decoder.h
@@ -77,9 +77,6 @@
 
   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_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);
 
diff --git a/test/accounting_test.cc b/test/accounting_test.cc
index abe0369..cc5ef3c 100644
--- a/test/accounting_test.cc
+++ b/test/accounting_test.cc
@@ -35,7 +35,7 @@
   }
   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 @@
   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");
diff --git a/test/binary_codes_test.cc b/test/binary_codes_test.cc
index 30599fc..42610ea 100644
--- a/test/binary_codes_test.cc
+++ b/test/binary_codes_test.cc
@@ -60,7 +60,7 @@
   }
   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) {
diff --git a/test/boolcoder_test.cc b/test/boolcoder_test.cc
index 4095402..ef4ee50 100644
--- a/test/boolcoder_test.cc
+++ b/test/boolcoder_test.cc
@@ -69,7 +69,7 @@
         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 @@
     }
     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;