| OLD | NEW |
| 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 |
| 11 #ifndef VP9_DECODER_VP9_DECODER_H_ | 11 #ifndef VP9_DECODER_VP9_DECODER_H_ |
| 12 #define VP9_DECODER_VP9_DECODER_H_ | 12 #define VP9_DECODER_VP9_DECODER_H_ |
| 13 | 13 |
| 14 #include "./vpx_config.h" | 14 #include "./vpx_config.h" |
| 15 | 15 |
| 16 #include "vpx/vpx_codec.h" | 16 #include "vpx/vpx_codec.h" |
| 17 #include "vpx_scale/yv12config.h" | 17 #include "vpx_scale/yv12config.h" |
| 18 #include "vp9/common/vp9_loopfilter_thread.h" | 18 #include "vp9/common/vp9_thread_common.h" |
| 19 #include "vp9/common/vp9_onyxc_int.h" | 19 #include "vp9/common/vp9_onyxc_int.h" |
| 20 #include "vp9/common/vp9_ppflags.h" | 20 #include "vp9/common/vp9_ppflags.h" |
| 21 #include "vp9/common/vp9_thread.h" | 21 #include "vp9/common/vp9_thread.h" |
| 22 #include "vp9/decoder/vp9_dthread.h" |
| 22 #include "vp9/decoder/vp9_reader.h" | 23 #include "vp9/decoder/vp9_reader.h" |
| 23 | 24 |
| 24 #ifdef __cplusplus | 25 #ifdef __cplusplus |
| 25 extern "C" { | 26 extern "C" { |
| 26 #endif | 27 #endif |
| 27 | 28 |
| 28 // TODO(hkuang): combine this with TileWorkerData. | 29 // TODO(hkuang): combine this with TileWorkerData. |
| 29 typedef struct TileData { | 30 typedef struct TileData { |
| 30 VP9_COMMON *cm; | 31 VP9_COMMON *cm; |
| 31 vp9_reader bit_reader; | 32 vp9_reader bit_reader; |
| 32 DECLARE_ALIGNED(16, MACROBLOCKD, xd); | 33 DECLARE_ALIGNED(16, MACROBLOCKD, xd); |
| 33 } TileData; | 34 } TileData; |
| 34 | 35 |
| 35 typedef struct TileWorkerData { | 36 typedef struct TileWorkerData { |
| 36 VP9_COMMON *cm; | 37 struct VP9Decoder *pbi; |
| 37 vp9_reader bit_reader; | 38 vp9_reader bit_reader; |
| 39 FRAME_COUNTS counts; |
| 38 DECLARE_ALIGNED(16, MACROBLOCKD, xd); | 40 DECLARE_ALIGNED(16, MACROBLOCKD, xd); |
| 39 struct vpx_internal_error_info error_info; | 41 struct vpx_internal_error_info error_info; |
| 40 } TileWorkerData; | 42 } TileWorkerData; |
| 41 | 43 |
| 42 typedef struct VP9Decoder { | 44 typedef struct VP9Decoder { |
| 43 DECLARE_ALIGNED(16, MACROBLOCKD, mb); | 45 DECLARE_ALIGNED(16, MACROBLOCKD, mb); |
| 44 | 46 |
| 45 DECLARE_ALIGNED(16, VP9_COMMON, common); | 47 DECLARE_ALIGNED(16, VP9_COMMON, common); |
| 46 | 48 |
| 47 int ready_for_new_data; | 49 int ready_for_new_data; |
| 48 | 50 |
| 49 int refresh_frame_flags; | 51 int refresh_frame_flags; |
| 50 | 52 |
| 51 int frame_parallel_decode; // frame-based threading. | 53 int frame_parallel_decode; // frame-based threading. |
| 52 | 54 |
| 55 // TODO(hkuang): Combine this with cur_buf in macroblockd as they are |
| 56 // the same. |
| 57 RefCntBuffer *cur_buf; // Current decoding frame buffer. |
| 58 RefCntBuffer *prev_buf; // Previous decoding frame buffer. |
| 59 |
| 60 VP9Worker *frame_worker_owner; // frame_worker that owns this pbi. |
| 53 VP9Worker lf_worker; | 61 VP9Worker lf_worker; |
| 54 VP9Worker *tile_workers; | 62 VP9Worker *tile_workers; |
| 55 TileWorkerData *tile_worker_data; | 63 TileWorkerData *tile_worker_data; |
| 56 TileInfo *tile_worker_info; | 64 TileInfo *tile_worker_info; |
| 57 int num_tile_workers; | 65 int num_tile_workers; |
| 58 | 66 |
| 59 TileData *tile_data; | 67 TileData *tile_data; |
| 60 int total_tiles; | 68 int total_tiles; |
| 61 | 69 |
| 62 VP9LfSync lf_row_sync; | 70 VP9LfSync lf_row_sync; |
| 63 | 71 |
| 64 vpx_decrypt_cb decrypt_cb; | 72 vpx_decrypt_cb decrypt_cb; |
| 65 void *decrypt_state; | 73 void *decrypt_state; |
| 66 | 74 |
| 67 int max_threads; | 75 int max_threads; |
| 68 int inv_tile_order; | 76 int inv_tile_order; |
| 69 int need_resync; // wait for key/intra-only frame | 77 int need_resync; // wait for key/intra-only frame. |
| 78 int hold_ref_buf; // hold the reference buffer. |
| 70 } VP9Decoder; | 79 } VP9Decoder; |
| 71 | 80 |
| 72 int vp9_receive_compressed_data(struct VP9Decoder *pbi, | 81 int vp9_receive_compressed_data(struct VP9Decoder *pbi, |
| 73 size_t size, const uint8_t **dest); | 82 size_t size, const uint8_t **dest); |
| 74 | 83 |
| 75 int vp9_get_raw_frame(struct VP9Decoder *pbi, YV12_BUFFER_CONFIG *sd, | 84 int vp9_get_raw_frame(struct VP9Decoder *pbi, YV12_BUFFER_CONFIG *sd, |
| 76 vp9_ppflags_t *flags); | 85 vp9_ppflags_t *flags); |
| 77 | 86 |
| 78 vpx_codec_err_t vp9_copy_reference_dec(struct VP9Decoder *pbi, | 87 vpx_codec_err_t vp9_copy_reference_dec(struct VP9Decoder *pbi, |
| 79 VP9_REFFRAME ref_frame_flag, | 88 VP9_REFFRAME ref_frame_flag, |
| 80 YV12_BUFFER_CONFIG *sd); | 89 YV12_BUFFER_CONFIG *sd); |
| 81 | 90 |
| 82 vpx_codec_err_t vp9_set_reference_dec(VP9_COMMON *cm, | 91 vpx_codec_err_t vp9_set_reference_dec(VP9_COMMON *cm, |
| 83 VP9_REFFRAME ref_frame_flag, | 92 VP9_REFFRAME ref_frame_flag, |
| 84 YV12_BUFFER_CONFIG *sd); | 93 YV12_BUFFER_CONFIG *sd); |
| 85 | 94 |
| 86 struct VP9Decoder *vp9_decoder_create(); | |
| 87 | |
| 88 void vp9_decoder_remove(struct VP9Decoder *pbi); | |
| 89 | |
| 90 static INLINE uint8_t read_marker(vpx_decrypt_cb decrypt_cb, | 95 static INLINE uint8_t read_marker(vpx_decrypt_cb decrypt_cb, |
| 91 void *decrypt_state, | 96 void *decrypt_state, |
| 92 const uint8_t *data) { | 97 const uint8_t *data) { |
| 93 if (decrypt_cb) { | 98 if (decrypt_cb) { |
| 94 uint8_t marker; | 99 uint8_t marker; |
| 95 decrypt_cb(decrypt_state, data, &marker, 1); | 100 decrypt_cb(decrypt_state, data, &marker, 1); |
| 96 return marker; | 101 return marker; |
| 97 } | 102 } |
| 98 return *data; | 103 return *data; |
| 99 } | 104 } |
| 100 | 105 |
| 101 // This function is exposed for use in tests, as well as the inlined function | 106 // This function is exposed for use in tests, as well as the inlined function |
| 102 // "read_marker". | 107 // "read_marker". |
| 103 vpx_codec_err_t vp9_parse_superframe_index(const uint8_t *data, | 108 vpx_codec_err_t vp9_parse_superframe_index(const uint8_t *data, |
| 104 size_t data_sz, | 109 size_t data_sz, |
| 105 uint32_t sizes[8], int *count, | 110 uint32_t sizes[8], int *count, |
| 106 vpx_decrypt_cb decrypt_cb, | 111 vpx_decrypt_cb decrypt_cb, |
| 107 void *decrypt_state); | 112 void *decrypt_state); |
| 108 | 113 |
| 114 struct VP9Decoder *vp9_decoder_create(BufferPool *const pool); |
| 115 |
| 116 void vp9_decoder_remove(struct VP9Decoder *pbi); |
| 117 |
| 118 static INLINE void decrease_ref_count(int idx, RefCntBuffer *const frame_bufs, |
| 119 BufferPool *const pool) { |
| 120 if (idx >= 0) { |
| 121 --frame_bufs[idx].ref_count; |
| 122 // A worker may only get a free framebuffer index when calling get_free_fb. |
| 123 // But the private buffer is not set up until finish decoding header. |
| 124 // So any error happens during decoding header, the frame_bufs will not |
| 125 // have valid priv buffer. |
| 126 if (frame_bufs[idx].ref_count == 0 && |
| 127 frame_bufs[idx].raw_frame_buffer.priv) { |
| 128 pool->release_fb_cb(pool->cb_priv, &frame_bufs[idx].raw_frame_buffer); |
| 129 } |
| 130 } |
| 131 } |
| 132 |
| 109 #ifdef __cplusplus | 133 #ifdef __cplusplus |
| 110 } // extern "C" | 134 } // extern "C" |
| 111 #endif | 135 #endif |
| 112 | 136 |
| 113 #endif // VP9_DECODER_VP9_DECODER_H_ | 137 #endif // VP9_DECODER_VP9_DECODER_H_ |
| OLD | NEW |