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