/src/ffmpeg/libavcodec/cbs_vp9_syntax_template.c
Line | Count | Source |
1 | | /* |
2 | | * This file is part of FFmpeg. |
3 | | * |
4 | | * FFmpeg is free software; you can redistribute it and/or |
5 | | * modify it under the terms of the GNU Lesser General Public |
6 | | * License as published by the Free Software Foundation; either |
7 | | * version 2.1 of the License, or (at your option) any later version. |
8 | | * |
9 | | * FFmpeg is distributed in the hope that it will be useful, |
10 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | | * Lesser General Public License for more details. |
13 | | * |
14 | | * You should have received a copy of the GNU Lesser General Public |
15 | | * License along with FFmpeg; if not, write to the Free Software |
16 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
17 | | */ |
18 | | |
19 | | static int FUNC(frame_sync_code)(CodedBitstreamContext *ctx, RWContext *rw, |
20 | | VP9RawFrameHeader *current) |
21 | 281k | { |
22 | 281k | int err; |
23 | | |
24 | 281k | fixed(8, frame_sync_byte_0, VP9_FRAME_SYNC_0); |
25 | 83.7k | fixed(8, frame_sync_byte_1, VP9_FRAME_SYNC_1); |
26 | 80.6k | fixed(8, frame_sync_byte_2, VP9_FRAME_SYNC_2); |
27 | | |
28 | 77.0k | return 0; |
29 | 80.6k | } cbs_vp9.c:cbs_vp9_read_frame_sync_code Line | Count | Source | 21 | 278k | { | 22 | 278k | int err; | 23 | | | 24 | 278k | fixed(8, frame_sync_byte_0, VP9_FRAME_SYNC_0); | 25 | 81.0k | fixed(8, frame_sync_byte_1, VP9_FRAME_SYNC_1); | 26 | 77.9k | fixed(8, frame_sync_byte_2, VP9_FRAME_SYNC_2); | 27 | | | 28 | 74.3k | return 0; | 29 | 77.9k | } |
cbs_vp9.c:cbs_vp9_write_frame_sync_code Line | Count | Source | 21 | 2.74k | { | 22 | 2.74k | int err; | 23 | | | 24 | 2.74k | fixed(8, frame_sync_byte_0, VP9_FRAME_SYNC_0); | 25 | 2.74k | fixed(8, frame_sync_byte_1, VP9_FRAME_SYNC_1); | 26 | 2.74k | fixed(8, frame_sync_byte_2, VP9_FRAME_SYNC_2); | 27 | | | 28 | 2.74k | return 0; | 29 | 2.74k | } |
|
30 | | |
31 | | static int FUNC(color_config)(CodedBitstreamContext *ctx, RWContext *rw, |
32 | | VP9RawFrameHeader *current, int profile) |
33 | 71.1k | { |
34 | 71.1k | CodedBitstreamVP9Context *vp9 = ctx->priv_data; |
35 | 71.1k | int err; |
36 | | |
37 | 71.1k | if (profile >= 2) { |
38 | 36.1k | f(1, ten_or_twelve_bit); |
39 | 29.2k | vp9->bit_depth = current->ten_or_twelve_bit ? 12 : 10; |
40 | 29.2k | } else |
41 | 35.0k | vp9->bit_depth = 8; |
42 | | |
43 | 64.3k | f(3, color_space); |
44 | | |
45 | 63.8k | if (current->color_space != VP9_CS_RGB) { |
46 | 51.6k | f(1, color_range); |
47 | 51.6k | if (profile == 1 || profile == 3) { |
48 | 32.5k | f(1, subsampling_x); |
49 | 32.5k | f(1, subsampling_y); |
50 | 32.3k | fixed(1, reserved_zero, 0); |
51 | 32.3k | } else { |
52 | 19.1k | infer(subsampling_x, 1); |
53 | 19.1k | infer(subsampling_y, 1); |
54 | 19.1k | } |
55 | 51.6k | } else { |
56 | 12.1k | infer(color_range, 1); |
57 | 12.1k | if (profile == 1 || profile == 3) { |
58 | 5.15k | infer(subsampling_x, 0); |
59 | 5.15k | infer(subsampling_y, 0); |
60 | 5.15k | fixed(1, reserved_zero, 0); |
61 | 5.15k | } |
62 | 12.1k | } |
63 | | |
64 | 61.2k | vp9->subsampling_x = current->subsampling_x; |
65 | 61.2k | vp9->subsampling_y = current->subsampling_y; |
66 | | |
67 | 61.2k | return 0; |
68 | 63.8k | } cbs_vp9.c:cbs_vp9_read_color_config Line | Count | Source | 33 | 68.6k | { | 34 | 68.6k | CodedBitstreamVP9Context *vp9 = ctx->priv_data; | 35 | 68.6k | int err; | 36 | | | 37 | 68.6k | if (profile >= 2) { | 38 | 34.1k | f(1, ten_or_twelve_bit); | 39 | 27.2k | vp9->bit_depth = current->ten_or_twelve_bit ? 12 : 10; | 40 | 27.2k | } else | 41 | 34.5k | vp9->bit_depth = 8; | 42 | | | 43 | 61.8k | f(3, color_space); | 44 | | | 45 | 61.2k | if (current->color_space != VP9_CS_RGB) { | 46 | 50.4k | f(1, color_range); | 47 | 50.4k | if (profile == 1 || profile == 3) { | 48 | 31.9k | f(1, subsampling_x); | 49 | 31.9k | f(1, subsampling_y); | 50 | 31.7k | fixed(1, reserved_zero, 0); | 51 | 31.7k | } else { | 52 | 18.4k | infer(subsampling_x, 1); | 53 | 18.4k | infer(subsampling_y, 1); | 54 | 18.4k | } | 55 | 50.4k | } else { | 56 | 10.8k | infer(color_range, 1); | 57 | 10.8k | if (profile == 1 || profile == 3) { | 58 | 4.23k | infer(subsampling_x, 0); | 59 | 4.23k | infer(subsampling_y, 0); | 60 | 4.23k | fixed(1, reserved_zero, 0); | 61 | 4.23k | } | 62 | 10.8k | } | 63 | | | 64 | 58.7k | vp9->subsampling_x = current->subsampling_x; | 65 | 58.7k | vp9->subsampling_y = current->subsampling_y; | 66 | | | 67 | 58.7k | return 0; | 68 | 61.2k | } |
cbs_vp9.c:cbs_vp9_write_color_config Line | Count | Source | 33 | 2.51k | { | 34 | 2.51k | CodedBitstreamVP9Context *vp9 = ctx->priv_data; | 35 | 2.51k | int err; | 36 | | | 37 | 2.51k | if (profile >= 2) { | 38 | 1.98k | f(1, ten_or_twelve_bit); | 39 | 1.98k | vp9->bit_depth = current->ten_or_twelve_bit ? 12 : 10; | 40 | 1.98k | } else | 41 | 535 | vp9->bit_depth = 8; | 42 | | | 43 | 2.51k | f(3, color_space); | 44 | | | 45 | 2.51k | if (current->color_space != VP9_CS_RGB) { | 46 | 1.24k | f(1, color_range); | 47 | 1.24k | if (profile == 1 || profile == 3) { | 48 | 560 | f(1, subsampling_x); | 49 | 560 | f(1, subsampling_y); | 50 | 560 | fixed(1, reserved_zero, 0); | 51 | 683 | } else { | 52 | 683 | infer(subsampling_x, 1); | 53 | 683 | infer(subsampling_y, 1); | 54 | 683 | } | 55 | 1.27k | } else { | 56 | 1.27k | infer(color_range, 1); | 57 | 1.27k | if (profile == 1 || profile == 3) { | 58 | 920 | infer(subsampling_x, 0); | 59 | 920 | infer(subsampling_y, 0); | 60 | 920 | fixed(1, reserved_zero, 0); | 61 | 920 | } | 62 | 1.27k | } | 63 | | | 64 | 2.51k | vp9->subsampling_x = current->subsampling_x; | 65 | 2.51k | vp9->subsampling_y = current->subsampling_y; | 66 | | | 67 | 2.51k | return 0; | 68 | 2.51k | } |
|
69 | | |
70 | | static int FUNC(frame_size)(CodedBitstreamContext *ctx, RWContext *rw, |
71 | | VP9RawFrameHeader *current) |
72 | 254k | { |
73 | 254k | CodedBitstreamVP9Context *vp9 = ctx->priv_data; |
74 | 254k | int err; |
75 | | |
76 | 254k | f(16, frame_width_minus_1); |
77 | 245k | f(16, frame_height_minus_1); |
78 | | |
79 | 241k | vp9->frame_width = current->frame_width_minus_1 + 1; |
80 | 241k | vp9->frame_height = current->frame_height_minus_1 + 1; |
81 | | |
82 | 241k | vp9->mi_cols = (vp9->frame_width + 7) >> 3; |
83 | 241k | vp9->mi_rows = (vp9->frame_height + 7) >> 3; |
84 | 241k | vp9->sb64_cols = (vp9->mi_cols + 7) >> 3; |
85 | 241k | vp9->sb64_rows = (vp9->mi_rows + 7) >> 3; |
86 | | |
87 | 241k | return 0; |
88 | 245k | } cbs_vp9.c:cbs_vp9_read_frame_size Line | Count | Source | 72 | 250k | { | 73 | 250k | CodedBitstreamVP9Context *vp9 = ctx->priv_data; | 74 | 250k | int err; | 75 | | | 76 | 250k | f(16, frame_width_minus_1); | 77 | 241k | f(16, frame_height_minus_1); | 78 | | | 79 | 238k | vp9->frame_width = current->frame_width_minus_1 + 1; | 80 | 238k | vp9->frame_height = current->frame_height_minus_1 + 1; | 81 | | | 82 | 238k | vp9->mi_cols = (vp9->frame_width + 7) >> 3; | 83 | 238k | vp9->mi_rows = (vp9->frame_height + 7) >> 3; | 84 | 238k | vp9->sb64_cols = (vp9->mi_cols + 7) >> 3; | 85 | 238k | vp9->sb64_rows = (vp9->mi_rows + 7) >> 3; | 86 | | | 87 | 238k | return 0; | 88 | 241k | } |
cbs_vp9.c:cbs_vp9_write_frame_size Line | Count | Source | 72 | 3.84k | { | 73 | 3.84k | CodedBitstreamVP9Context *vp9 = ctx->priv_data; | 74 | 3.84k | int err; | 75 | | | 76 | 3.84k | f(16, frame_width_minus_1); | 77 | 3.84k | f(16, frame_height_minus_1); | 78 | | | 79 | 3.84k | vp9->frame_width = current->frame_width_minus_1 + 1; | 80 | 3.84k | vp9->frame_height = current->frame_height_minus_1 + 1; | 81 | | | 82 | 3.84k | vp9->mi_cols = (vp9->frame_width + 7) >> 3; | 83 | 3.84k | vp9->mi_rows = (vp9->frame_height + 7) >> 3; | 84 | 3.84k | vp9->sb64_cols = (vp9->mi_cols + 7) >> 3; | 85 | 3.84k | vp9->sb64_rows = (vp9->mi_rows + 7) >> 3; | 86 | | | 87 | 3.84k | return 0; | 88 | 3.84k | } |
|
89 | | |
90 | | static int FUNC(render_size)(CodedBitstreamContext *ctx, RWContext *rw, |
91 | | VP9RawFrameHeader *current) |
92 | 1.15M | { |
93 | 1.15M | int err; |
94 | | |
95 | 1.15M | f(1, render_and_frame_size_different); |
96 | | |
97 | 1.15M | if (current->render_and_frame_size_different) { |
98 | 939k | f(16, render_width_minus_1); |
99 | 933k | f(16, render_height_minus_1); |
100 | 933k | } |
101 | | |
102 | 1.14M | return 0; |
103 | 1.15M | } cbs_vp9.c:cbs_vp9_read_render_size Line | Count | Source | 92 | 1.14M | { | 93 | 1.14M | int err; | 94 | | | 95 | 1.14M | f(1, render_and_frame_size_different); | 96 | | | 97 | 1.14M | if (current->render_and_frame_size_different) { | 98 | 937k | f(16, render_width_minus_1); | 99 | 931k | f(16, render_height_minus_1); | 100 | 931k | } | 101 | | | 102 | 1.13M | return 0; | 103 | 1.14M | } |
cbs_vp9.c:cbs_vp9_write_render_size Line | Count | Source | 92 | 11.0k | { | 93 | 11.0k | int err; | 94 | | | 95 | 11.0k | f(1, render_and_frame_size_different); | 96 | | | 97 | 11.0k | if (current->render_and_frame_size_different) { | 98 | 1.50k | f(16, render_width_minus_1); | 99 | 1.50k | f(16, render_height_minus_1); | 100 | 1.50k | } | 101 | | | 102 | 11.0k | return 0; | 103 | 11.0k | } |
|
104 | | |
105 | | static int FUNC(frame_size_with_refs)(CodedBitstreamContext *ctx, RWContext *rw, |
106 | | VP9RawFrameHeader *current) |
107 | 1.10M | { |
108 | 1.10M | CodedBitstreamVP9Context *vp9 = ctx->priv_data; |
109 | 1.10M | int err, i; |
110 | | |
111 | 1.98M | for (i = 0; i < VP9_REFS_PER_FRAME; i++) { |
112 | 1.79M | fs(1, found_ref[i], 1, i); |
113 | 1.78M | if (current->found_ref[i]) { |
114 | 915k | VP9ReferenceFrameState *ref = |
115 | 915k | &vp9->ref[current->ref_frame_idx[i]]; |
116 | | |
117 | 915k | vp9->frame_width = ref->frame_width; |
118 | 915k | vp9->frame_height = ref->frame_height; |
119 | | |
120 | 915k | vp9->subsampling_x = ref->subsampling_x; |
121 | 915k | vp9->subsampling_y = ref->subsampling_y; |
122 | 915k | vp9->bit_depth = ref->bit_depth; |
123 | | |
124 | 915k | break; |
125 | 915k | } |
126 | 1.78M | } |
127 | 1.10M | if (i >= VP9_REFS_PER_FRAME) |
128 | 189k | CHECK(FUNC(frame_size)(ctx, rw, current)); |
129 | 915k | else { |
130 | 915k | vp9->mi_cols = (vp9->frame_width + 7) >> 3; |
131 | 915k | vp9->mi_rows = (vp9->frame_height + 7) >> 3; |
132 | 915k | vp9->sb64_cols = (vp9->mi_cols + 7) >> 3; |
133 | 915k | vp9->sb64_rows = (vp9->mi_rows + 7) >> 3; |
134 | 915k | } |
135 | 1.09M | CHECK(FUNC(render_size)(ctx, rw, current)); |
136 | | |
137 | 1.08M | return 0; |
138 | 1.09M | } cbs_vp9.c:cbs_vp9_read_frame_size_with_refs Line | Count | Source | 107 | 1.09M | { | 108 | 1.09M | CodedBitstreamVP9Context *vp9 = ctx->priv_data; | 109 | 1.09M | int err, i; | 110 | | | 111 | 1.96M | for (i = 0; i < VP9_REFS_PER_FRAME; i++) { | 112 | 1.77M | fs(1, found_ref[i], 1, i); | 113 | 1.77M | if (current->found_ref[i]) { | 114 | 908k | VP9ReferenceFrameState *ref = | 115 | 908k | &vp9->ref[current->ref_frame_idx[i]]; | 116 | | | 117 | 908k | vp9->frame_width = ref->frame_width; | 118 | 908k | vp9->frame_height = ref->frame_height; | 119 | | | 120 | 908k | vp9->subsampling_x = ref->subsampling_x; | 121 | 908k | vp9->subsampling_y = ref->subsampling_y; | 122 | 908k | vp9->bit_depth = ref->bit_depth; | 123 | | | 124 | 908k | break; | 125 | 908k | } | 126 | 1.77M | } | 127 | 1.09M | if (i >= VP9_REFS_PER_FRAME) | 128 | 188k | CHECK(FUNC(frame_size)(ctx, rw, current)); | 129 | 908k | else { | 130 | 908k | vp9->mi_cols = (vp9->frame_width + 7) >> 3; | 131 | 908k | vp9->mi_rows = (vp9->frame_height + 7) >> 3; | 132 | 908k | vp9->sb64_cols = (vp9->mi_cols + 7) >> 3; | 133 | 908k | vp9->sb64_rows = (vp9->mi_rows + 7) >> 3; | 134 | 908k | } | 135 | 1.08M | CHECK(FUNC(render_size)(ctx, rw, current)); | 136 | | | 137 | 1.08M | return 0; | 138 | 1.08M | } |
cbs_vp9.c:cbs_vp9_write_frame_size_with_refs Line | Count | Source | 107 | 8.30k | { | 108 | 8.30k | CodedBitstreamVP9Context *vp9 = ctx->priv_data; | 109 | 8.30k | int err, i; | 110 | | | 111 | 19.3k | for (i = 0; i < VP9_REFS_PER_FRAME; i++) { | 112 | 18.1k | fs(1, found_ref[i], 1, i); | 113 | 18.1k | if (current->found_ref[i]) { | 114 | 7.20k | VP9ReferenceFrameState *ref = | 115 | 7.20k | &vp9->ref[current->ref_frame_idx[i]]; | 116 | | | 117 | 7.20k | vp9->frame_width = ref->frame_width; | 118 | 7.20k | vp9->frame_height = ref->frame_height; | 119 | | | 120 | 7.20k | vp9->subsampling_x = ref->subsampling_x; | 121 | 7.20k | vp9->subsampling_y = ref->subsampling_y; | 122 | 7.20k | vp9->bit_depth = ref->bit_depth; | 123 | | | 124 | 7.20k | break; | 125 | 7.20k | } | 126 | 18.1k | } | 127 | 8.30k | if (i >= VP9_REFS_PER_FRAME) | 128 | 1.10k | CHECK(FUNC(frame_size)(ctx, rw, current)); | 129 | 7.20k | else { | 130 | 7.20k | vp9->mi_cols = (vp9->frame_width + 7) >> 3; | 131 | 7.20k | vp9->mi_rows = (vp9->frame_height + 7) >> 3; | 132 | 7.20k | vp9->sb64_cols = (vp9->mi_cols + 7) >> 3; | 133 | 7.20k | vp9->sb64_rows = (vp9->mi_rows + 7) >> 3; | 134 | 7.20k | } | 135 | 8.30k | CHECK(FUNC(render_size)(ctx, rw, current)); | 136 | | | 137 | 8.30k | return 0; | 138 | 8.30k | } |
|
139 | | |
140 | | static int FUNC(interpolation_filter)(CodedBitstreamContext *ctx, RWContext *rw, |
141 | | VP9RawFrameHeader *current) |
142 | 1.08M | { |
143 | 1.08M | int err; |
144 | | |
145 | 1.08M | f(1, is_filter_switchable); |
146 | 1.08M | if (!current->is_filter_switchable) |
147 | 792k | f(2, raw_interpolation_filter_type); |
148 | | |
149 | 1.08M | return 0; |
150 | 1.08M | } cbs_vp9.c:cbs_vp9_read_interpolation_filter Line | Count | Source | 142 | 1.08M | { | 143 | 1.08M | int err; | 144 | | | 145 | 1.08M | f(1, is_filter_switchable); | 146 | 1.07M | if (!current->is_filter_switchable) | 147 | 787k | f(2, raw_interpolation_filter_type); | 148 | | | 149 | 1.07M | return 0; | 150 | 1.07M | } |
cbs_vp9.c:cbs_vp9_write_interpolation_filter Line | Count | Source | 142 | 8.30k | { | 143 | 8.30k | int err; | 144 | | | 145 | 8.30k | f(1, is_filter_switchable); | 146 | 8.30k | if (!current->is_filter_switchable) | 147 | 4.92k | f(2, raw_interpolation_filter_type); | 148 | | | 149 | 8.30k | return 0; | 150 | 8.30k | } |
|
151 | | |
152 | | static int FUNC(loop_filter_params)(CodedBitstreamContext *ctx, RWContext *rw, |
153 | | VP9RawFrameHeader *current) |
154 | 1.13M | { |
155 | 1.13M | int err, i; |
156 | | |
157 | 1.13M | f(6, loop_filter_level); |
158 | 1.13M | f(3, loop_filter_sharpness); |
159 | | |
160 | 1.13M | f(1, loop_filter_delta_enabled); |
161 | 1.12M | if (current->loop_filter_delta_enabled) { |
162 | 327k | f(1, loop_filter_delta_update); |
163 | 326k | if (current->loop_filter_delta_update) { |
164 | 1.01M | for (i = 0; i < VP9_MAX_REF_FRAMES; i++) { |
165 | 812k | fs(1, update_ref_delta[i], 1, i); |
166 | 811k | if (current->update_ref_delta[i]) |
167 | 811k | ss(6, loop_filter_ref_deltas[i], 1, i); |
168 | 811k | } |
169 | 603k | for (i = 0; i < 2; i++) { |
170 | 403k | fs(1, update_mode_delta[i], 1, i); |
171 | 402k | if (current->update_mode_delta[i]) |
172 | 402k | ss(6, loop_filter_mode_deltas[i], 1, i); |
173 | 402k | } |
174 | 201k | } |
175 | 802k | } else { |
176 | 802k | infer(loop_filter_delta_update, 0); |
177 | 802k | } |
178 | | |
179 | 1.12M | return 0; |
180 | 1.12M | } cbs_vp9.c:cbs_vp9_read_loop_filter_params Line | Count | Source | 154 | 1.12M | { | 155 | 1.12M | int err, i; | 156 | | | 157 | 1.12M | f(6, loop_filter_level); | 158 | 1.12M | f(3, loop_filter_sharpness); | 159 | | | 160 | 1.11M | f(1, loop_filter_delta_enabled); | 161 | 1.11M | if (current->loop_filter_delta_enabled) { | 162 | 322k | f(1, loop_filter_delta_update); | 163 | 321k | if (current->loop_filter_delta_update) { | 164 | 1.00M | for (i = 0; i < VP9_MAX_REF_FRAMES; i++) { | 165 | 804k | fs(1, update_ref_delta[i], 1, i); | 166 | 803k | if (current->update_ref_delta[i]) | 167 | 803k | ss(6, loop_filter_ref_deltas[i], 1, i); | 168 | 803k | } | 169 | 598k | for (i = 0; i < 2; i++) { | 170 | 399k | fs(1, update_mode_delta[i], 1, i); | 171 | 399k | if (current->update_mode_delta[i]) | 172 | 399k | ss(6, loop_filter_mode_deltas[i], 1, i); | 173 | 399k | } | 174 | 200k | } | 175 | 796k | } else { | 176 | 796k | infer(loop_filter_delta_update, 0); | 177 | 796k | } | 178 | | | 179 | 1.11M | return 0; | 180 | 1.11M | } |
cbs_vp9.c:cbs_vp9_write_loop_filter_params Line | Count | Source | 154 | 11.0k | { | 155 | 11.0k | int err, i; | 156 | | | 157 | 11.0k | f(6, loop_filter_level); | 158 | 11.0k | f(3, loop_filter_sharpness); | 159 | | | 160 | 11.0k | f(1, loop_filter_delta_enabled); | 161 | 11.0k | if (current->loop_filter_delta_enabled) { | 162 | 4.93k | f(1, loop_filter_delta_update); | 163 | 4.93k | if (current->loop_filter_delta_update) { | 164 | 8.97k | for (i = 0; i < VP9_MAX_REF_FRAMES; i++) { | 165 | 7.17k | fs(1, update_ref_delta[i], 1, i); | 166 | 7.17k | if (current->update_ref_delta[i]) | 167 | 7.17k | ss(6, loop_filter_ref_deltas[i], 1, i); | 168 | 7.17k | } | 169 | 5.38k | for (i = 0; i < 2; i++) { | 170 | 3.58k | fs(1, update_mode_delta[i], 1, i); | 171 | 3.58k | if (current->update_mode_delta[i]) | 172 | 3.58k | ss(6, loop_filter_mode_deltas[i], 1, i); | 173 | 3.58k | } | 174 | 1.79k | } | 175 | 6.12k | } else { | 176 | 6.12k | infer(loop_filter_delta_update, 0); | 177 | 6.12k | } | 178 | | | 179 | 11.0k | return 0; | 180 | 11.0k | } |
|
181 | | |
182 | | static int FUNC(quantization_params)(CodedBitstreamContext *ctx, RWContext *rw, |
183 | | VP9RawFrameHeader *current) |
184 | 1.12M | { |
185 | 1.12M | int err; |
186 | | |
187 | 1.12M | f(8, base_q_idx); |
188 | | |
189 | 1.12M | delta_q(delta_q_y_dc); |
190 | 1.12M | delta_q(delta_q_uv_dc); |
191 | 1.11M | delta_q(delta_q_uv_ac); |
192 | | |
193 | 1.11M | return 0; |
194 | 1.11M | } cbs_vp9.c:cbs_vp9_read_quantization_params Line | Count | Source | 184 | 1.11M | { | 185 | 1.11M | int err; | 186 | | | 187 | 1.11M | f(8, base_q_idx); | 188 | | | 189 | 1.11M | delta_q(delta_q_y_dc); | 190 | 1.11M | delta_q(delta_q_uv_dc); | 191 | 1.10M | delta_q(delta_q_uv_ac); | 192 | | | 193 | 1.10M | return 0; | 194 | 1.10M | } |
cbs_vp9.c:cbs_vp9_write_quantization_params Line | Count | Source | 184 | 11.0k | { | 185 | 11.0k | int err; | 186 | | | 187 | 11.0k | f(8, base_q_idx); | 188 | | | 189 | 11.0k | delta_q(delta_q_y_dc); | 190 | 11.0k | delta_q(delta_q_uv_dc); | 191 | 11.0k | delta_q(delta_q_uv_ac); | 192 | | | 193 | 11.0k | return 0; | 194 | 11.0k | } |
|
195 | | |
196 | | static int FUNC(segmentation_params)(CodedBitstreamContext *ctx, RWContext *rw, |
197 | | VP9RawFrameHeader *current) |
198 | 1.11M | { |
199 | 1.11M | static const uint8_t segmentation_feature_bits[VP9_SEG_LVL_MAX] = { 8, 6, 2, 0 }; |
200 | 1.11M | static const uint8_t segmentation_feature_signed[VP9_SEG_LVL_MAX] = { 1, 1, 0, 0 }; |
201 | 1.11M | int err, i, j; |
202 | | |
203 | 1.11M | f(1, segmentation_enabled); |
204 | | |
205 | 1.11M | if (current->segmentation_enabled) { |
206 | 881k | f(1, segmentation_update_map); |
207 | 880k | if (current->segmentation_update_map) { |
208 | 6.51M | for (i = 0; i < 7; i++) |
209 | 5.70M | prob(segmentation_tree_probs[i], 1, i); |
210 | 814k | f(1, segmentation_temporal_update); |
211 | 3.25M | for (i = 0; i < 3; i++) { |
212 | 2.44M | if (current->segmentation_temporal_update) |
213 | 593k | prob(segmentation_pred_prob[i], 1, i); |
214 | 1.84M | else |
215 | 1.84M | infer(segmentation_pred_prob[i], 255); |
216 | 2.44M | } |
217 | 813k | } |
218 | | |
219 | 876k | f(1, segmentation_update_data); |
220 | 875k | if (current->segmentation_update_data) { |
221 | 119k | f(1, segmentation_abs_or_delta_update); |
222 | 1.03M | for (i = 0; i < VP9_MAX_SEGMENTS; i++) { |
223 | 4.58M | for (j = 0; j < VP9_SEG_LVL_MAX; j++) { |
224 | 3.66M | fs(1, feature_enabled[i][j], 2, i, j); |
225 | 3.66M | if (current->feature_enabled[i][j] && |
226 | 1.89M | segmentation_feature_bits[j]) { |
227 | 1.40M | fs(segmentation_feature_bits[j], |
228 | 1.40M | feature_value[i][j], 2, i, j); |
229 | 1.40M | if (segmentation_feature_signed[j]) |
230 | 1.40M | fs(1, feature_sign[i][j], 2, i, j); |
231 | 377k | else |
232 | 377k | infer(feature_sign[i][j], 0); |
233 | 2.25M | } else { |
234 | 2.25M | infer(feature_value[i][j], 0); |
235 | 2.25M | infer(feature_sign[i][j], 0); |
236 | 2.25M | } |
237 | 3.66M | } |
238 | 919k | } |
239 | 118k | } |
240 | 875k | } else { |
241 | 234k | infer(segmentation_update_data, 0); |
242 | 234k | } |
243 | | |
244 | 1.10M | return 0; |
245 | 1.11M | } cbs_vp9.c:cbs_vp9_read_segmentation_params Line | Count | Source | 198 | 1.10M | { | 199 | 1.10M | static const uint8_t segmentation_feature_bits[VP9_SEG_LVL_MAX] = { 8, 6, 2, 0 }; | 200 | 1.10M | static const uint8_t segmentation_feature_signed[VP9_SEG_LVL_MAX] = { 1, 1, 0, 0 }; | 201 | 1.10M | int err, i, j; | 202 | | | 203 | 1.10M | f(1, segmentation_enabled); | 204 | | | 205 | 1.10M | if (current->segmentation_enabled) { | 206 | 877k | f(1, segmentation_update_map); | 207 | 876k | if (current->segmentation_update_map) { | 208 | 6.50M | for (i = 0; i < 7; i++) | 209 | 5.69M | prob(segmentation_tree_probs[i], 1, i); | 210 | 812k | f(1, segmentation_temporal_update); | 211 | 3.24M | for (i = 0; i < 3; i++) { | 212 | 2.43M | if (current->segmentation_temporal_update) | 213 | 591k | prob(segmentation_pred_prob[i], 1, i); | 214 | 1.84M | else | 215 | 1.84M | infer(segmentation_pred_prob[i], 255); | 216 | 2.43M | } | 217 | 812k | } | 218 | | | 219 | 872k | f(1, segmentation_update_data); | 220 | 871k | if (current->segmentation_update_data) { | 221 | 117k | f(1, segmentation_abs_or_delta_update); | 222 | 1.01M | for (i = 0; i < VP9_MAX_SEGMENTS; i++) { | 223 | 4.51M | for (j = 0; j < VP9_SEG_LVL_MAX; j++) { | 224 | 3.61M | fs(1, feature_enabled[i][j], 2, i, j); | 225 | 3.61M | if (current->feature_enabled[i][j] && | 226 | 1.88M | segmentation_feature_bits[j]) { | 227 | 1.39M | fs(segmentation_feature_bits[j], | 228 | 1.39M | feature_value[i][j], 2, i, j); | 229 | 1.39M | if (segmentation_feature_signed[j]) | 230 | 1.39M | fs(1, feature_sign[i][j], 2, i, j); | 231 | 372k | else | 232 | 372k | infer(feature_sign[i][j], 0); | 233 | 2.21M | } else { | 234 | 2.21M | infer(feature_value[i][j], 0); | 235 | 2.21M | infer(feature_sign[i][j], 0); | 236 | 2.21M | } | 237 | 3.61M | } | 238 | 906k | } | 239 | 116k | } | 240 | 871k | } else { | 241 | 227k | infer(segmentation_update_data, 0); | 242 | 227k | } | 243 | | | 244 | 1.09M | return 0; | 245 | 1.10M | } |
cbs_vp9.c:cbs_vp9_write_segmentation_params Line | Count | Source | 198 | 11.0k | { | 199 | 11.0k | static const uint8_t segmentation_feature_bits[VP9_SEG_LVL_MAX] = { 8, 6, 2, 0 }; | 200 | 11.0k | static const uint8_t segmentation_feature_signed[VP9_SEG_LVL_MAX] = { 1, 1, 0, 0 }; | 201 | 11.0k | int err, i, j; | 202 | | | 203 | 11.0k | f(1, segmentation_enabled); | 204 | | | 205 | 11.0k | if (current->segmentation_enabled) { | 206 | 3.96k | f(1, segmentation_update_map); | 207 | 3.96k | if (current->segmentation_update_map) { | 208 | 13.7k | for (i = 0; i < 7; i++) | 209 | 11.9k | prob(segmentation_tree_probs[i], 1, i); | 210 | 1.71k | f(1, segmentation_temporal_update); | 211 | 6.85k | for (i = 0; i < 3; i++) { | 212 | 5.13k | if (current->segmentation_temporal_update) | 213 | 1.79k | prob(segmentation_pred_prob[i], 1, i); | 214 | 3.34k | else | 215 | 3.34k | infer(segmentation_pred_prob[i], 255); | 216 | 5.13k | } | 217 | 1.71k | } | 218 | | | 219 | 3.96k | f(1, segmentation_update_data); | 220 | 3.96k | if (current->segmentation_update_data) { | 221 | 1.69k | f(1, segmentation_abs_or_delta_update); | 222 | 15.2k | for (i = 0; i < VP9_MAX_SEGMENTS; i++) { | 223 | 67.9k | for (j = 0; j < VP9_SEG_LVL_MAX; j++) { | 224 | 54.3k | fs(1, feature_enabled[i][j], 2, i, j); | 225 | 54.3k | if (current->feature_enabled[i][j] && | 226 | 12.4k | segmentation_feature_bits[j]) { | 227 | 9.59k | fs(segmentation_feature_bits[j], | 228 | 9.59k | feature_value[i][j], 2, i, j); | 229 | 9.59k | if (segmentation_feature_signed[j]) | 230 | 9.59k | fs(1, feature_sign[i][j], 2, i, j); | 231 | 4.25k | else | 232 | 4.25k | infer(feature_sign[i][j], 0); | 233 | 44.7k | } else { | 234 | 44.7k | infer(feature_value[i][j], 0); | 235 | 44.7k | infer(feature_sign[i][j], 0); | 236 | 44.7k | } | 237 | 54.3k | } | 238 | 13.5k | } | 239 | 1.69k | } | 240 | 7.08k | } else { | 241 | 7.08k | infer(segmentation_update_data, 0); | 242 | 7.08k | } | 243 | | | 244 | 11.0k | return 0; | 245 | 11.0k | } |
|
246 | | |
247 | | static int FUNC(tile_info)(CodedBitstreamContext *ctx, RWContext *rw, |
248 | | VP9RawFrameHeader *current) |
249 | 1.10M | { |
250 | 1.10M | CodedBitstreamVP9Context *vp9 = ctx->priv_data; |
251 | 1.10M | int min_log2_tile_cols, max_log2_tile_cols; |
252 | 1.10M | int err; |
253 | | |
254 | 1.10M | min_log2_tile_cols = 0; |
255 | 1.29M | while ((VP9_MAX_TILE_WIDTH_B64 << min_log2_tile_cols) < vp9->sb64_cols) |
256 | 193k | ++min_log2_tile_cols; |
257 | 1.10M | max_log2_tile_cols = 0; |
258 | 2.32M | while ((vp9->sb64_cols >> (max_log2_tile_cols + 1)) >= VP9_MIN_TILE_WIDTH_B64) |
259 | 1.22M | ++max_log2_tile_cols; |
260 | | |
261 | 1.10M | increment(tile_cols_log2, min_log2_tile_cols, max_log2_tile_cols); |
262 | | |
263 | 1.10M | increment(tile_rows_log2, 0, 2); |
264 | | |
265 | 1.09M | return 0; |
266 | 1.10M | } cbs_vp9.c:cbs_vp9_read_tile_info Line | Count | Source | 249 | 1.09M | { | 250 | 1.09M | CodedBitstreamVP9Context *vp9 = ctx->priv_data; | 251 | 1.09M | int min_log2_tile_cols, max_log2_tile_cols; | 252 | 1.09M | int err; | 253 | | | 254 | 1.09M | min_log2_tile_cols = 0; | 255 | 1.26M | while ((VP9_MAX_TILE_WIDTH_B64 << min_log2_tile_cols) < vp9->sb64_cols) | 256 | 173k | ++min_log2_tile_cols; | 257 | 1.09M | max_log2_tile_cols = 0; | 258 | 2.28M | while ((vp9->sb64_cols >> (max_log2_tile_cols + 1)) >= VP9_MIN_TILE_WIDTH_B64) | 259 | 1.18M | ++max_log2_tile_cols; | 260 | | | 261 | 1.09M | increment(tile_cols_log2, min_log2_tile_cols, max_log2_tile_cols); | 262 | | | 263 | 1.09M | increment(tile_rows_log2, 0, 2); | 264 | | | 265 | 1.08M | return 0; | 266 | 1.09M | } |
cbs_vp9.c:cbs_vp9_write_tile_info Line | Count | Source | 249 | 11.0k | { | 250 | 11.0k | CodedBitstreamVP9Context *vp9 = ctx->priv_data; | 251 | 11.0k | int min_log2_tile_cols, max_log2_tile_cols; | 252 | 11.0k | int err; | 253 | | | 254 | 11.0k | min_log2_tile_cols = 0; | 255 | 31.9k | while ((VP9_MAX_TILE_WIDTH_B64 << min_log2_tile_cols) < vp9->sb64_cols) | 256 | 20.8k | ++min_log2_tile_cols; | 257 | 11.0k | max_log2_tile_cols = 0; | 258 | 48.9k | while ((vp9->sb64_cols >> (max_log2_tile_cols + 1)) >= VP9_MIN_TILE_WIDTH_B64) | 259 | 37.8k | ++max_log2_tile_cols; | 260 | | | 261 | 11.0k | increment(tile_cols_log2, min_log2_tile_cols, max_log2_tile_cols); | 262 | | | 263 | 10.1k | increment(tile_rows_log2, 0, 2); | 264 | | | 265 | 10.1k | return 0; | 266 | 10.1k | } |
|
267 | | |
268 | | static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, |
269 | | VP9RawFrameHeader *current) |
270 | 1.79M | { |
271 | 1.79M | CodedBitstreamVP9Context *vp9 = ctx->priv_data; |
272 | 1.79M | int err, i; |
273 | | |
274 | 1.79M | f(2, frame_marker); |
275 | | |
276 | 1.79M | f(1, profile_low_bit); |
277 | 1.79M | f(1, profile_high_bit); |
278 | 1.79M | vp9->profile = (current->profile_high_bit << 1) + current->profile_low_bit; |
279 | 1.79M | if (vp9->profile == 3) |
280 | 365k | fixed(1, reserved_zero, 0); |
281 | | |
282 | 1.69M | f(1, show_existing_frame); |
283 | 1.69M | if (current->show_existing_frame) { |
284 | 213k | f(3, frame_to_show_map_idx); |
285 | 212k | infer(header_size_in_bytes, 0); |
286 | 212k | infer(refresh_frame_flags, 0x00); |
287 | 212k | infer(loop_filter_level, 0); |
288 | 212k | return 0; |
289 | 213k | } |
290 | | |
291 | 1.47M | f(1, frame_type); |
292 | 1.47M | f(1, show_frame); |
293 | 1.47M | f(1, error_resilient_mode); |
294 | | |
295 | 1.47M | if (current->frame_type == VP9_KEY_FRAME) { |
296 | 241k | CHECK(FUNC(frame_sync_code)(ctx, rw, current)); |
297 | 51.5k | CHECK(FUNC(color_config)(ctx, rw, current, vp9->profile)); |
298 | 42.5k | CHECK(FUNC(frame_size)(ctx, rw, current)); |
299 | 40.2k | CHECK(FUNC(render_size)(ctx, rw, current)); |
300 | | |
301 | 38.0k | infer(refresh_frame_flags, 0xff); |
302 | | |
303 | 1.22M | } else { |
304 | 1.22M | if (current->show_frame == 0) |
305 | 175k | f(1, intra_only); |
306 | 1.05M | else |
307 | 1.05M | infer(intra_only, 0); |
308 | | |
309 | 1.21M | if (current->error_resilient_mode == 0) |
310 | 1.08M | f(2, reset_frame_context); |
311 | 125k | else |
312 | 125k | infer(reset_frame_context, 0); |
313 | | |
314 | 1.19M | if (current->intra_only == 1) { |
315 | 39.5k | CHECK(FUNC(frame_sync_code)(ctx, rw, current)); |
316 | | |
317 | 25.5k | if (vp9->profile > 0) { |
318 | 19.5k | CHECK(FUNC(color_config)(ctx, rw, current, vp9->profile)); |
319 | 19.5k | } else { |
320 | 5.91k | infer(color_space, 1); |
321 | 5.91k | infer(subsampling_x, 1); |
322 | 5.91k | infer(subsampling_y, 1); |
323 | 5.91k | vp9->bit_depth = 8; |
324 | | |
325 | 5.91k | vp9->subsampling_x = current->subsampling_x; |
326 | 5.91k | vp9->subsampling_y = current->subsampling_y; |
327 | 5.91k | } |
328 | | |
329 | 24.6k | f(8, refresh_frame_flags); |
330 | | |
331 | 21.8k | CHECK(FUNC(frame_size)(ctx, rw, current)); |
332 | 19.6k | CHECK(FUNC(render_size)(ctx, rw, current)); |
333 | 1.15M | } else { |
334 | 1.15M | f(8, refresh_frame_flags); |
335 | | |
336 | 4.43M | for (i = 0; i < VP9_REFS_PER_FRAME; i++) { |
337 | 3.33M | fs(3, ref_frame_idx[i], 1, i); |
338 | 3.32M | fs(1, ref_frame_sign_bias[VP9_LAST_FRAME + i], |
339 | 3.32M | 1, VP9_LAST_FRAME + i); |
340 | 3.32M | } |
341 | | |
342 | 1.10M | CHECK(FUNC(frame_size_with_refs)(ctx, rw, current)); |
343 | 1.08M | f(1, allow_high_precision_mv); |
344 | 1.08M | CHECK(FUNC(interpolation_filter)(ctx, rw, current)); |
345 | 1.08M | } |
346 | 1.19M | } |
347 | | |
348 | 1.14M | if (current->error_resilient_mode == 0) { |
349 | 1.07M | f(1, refresh_frame_context); |
350 | 1.07M | f(1, frame_parallel_decoding_mode); |
351 | 1.07M | } else { |
352 | 64.2k | infer(refresh_frame_context, 0); |
353 | 64.2k | infer(frame_parallel_decoding_mode, 1); |
354 | 64.2k | } |
355 | | |
356 | 1.14M | f(2, frame_context_idx); |
357 | | |
358 | 1.13M | CHECK(FUNC(loop_filter_params)(ctx, rw, current)); |
359 | 1.12M | CHECK(FUNC(quantization_params)(ctx, rw, current)); |
360 | 1.11M | CHECK(FUNC(segmentation_params)(ctx, rw, current)); |
361 | 1.10M | CHECK(FUNC(tile_info)(ctx, rw, current)); |
362 | | |
363 | 1.09M | f(16, header_size_in_bytes); |
364 | | |
365 | 9.84M | for (i = 0; i < VP9_NUM_REF_FRAMES; i++) { |
366 | 8.74M | if (current->refresh_frame_flags & (1 << i)) { |
367 | 4.04M | vp9->ref[i] = (VP9ReferenceFrameState) { |
368 | 4.04M | .frame_width = vp9->frame_width, |
369 | 4.04M | .frame_height = vp9->frame_height, |
370 | 4.04M | .subsampling_x = vp9->subsampling_x, |
371 | 4.04M | .subsampling_y = vp9->subsampling_y, |
372 | 4.04M | .bit_depth = vp9->bit_depth, |
373 | 4.04M | }; |
374 | 4.04M | } |
375 | 8.74M | } |
376 | | |
377 | | // Update top-level loop filter and segmentation state with changes |
378 | | // from this frame. |
379 | 1.09M | if (current->frame_type == VP9_KEY_FRAME || |
380 | 1.05M | current->intra_only || |
381 | 1.04M | current->error_resilient_mode) { |
382 | | // setup_past_independence() - fill with the initial values. |
383 | | |
384 | 75.8k | vp9->loop_filter_ref_deltas[VP9_INTRA_FRAME] = 1; |
385 | 75.8k | vp9->loop_filter_ref_deltas[VP9_LAST_FRAME] = 0; |
386 | 75.8k | vp9->loop_filter_ref_deltas[VP9_GOLDEN_FRAME] = -1; |
387 | 75.8k | vp9->loop_filter_ref_deltas[VP9_ALTREF_FRAME] = -1; |
388 | | |
389 | 75.8k | vp9->loop_filter_mode_deltas[0] = 0; |
390 | 75.8k | vp9->loop_filter_mode_deltas[1] = 0; |
391 | | |
392 | 75.8k | memset(vp9->feature_enabled, 0, sizeof(vp9->feature_enabled)); |
393 | 75.8k | memset(vp9->feature_value, 0, sizeof(vp9->feature_value)); |
394 | 75.8k | memset(vp9->feature_sign, 0, sizeof(vp9->feature_sign)); |
395 | 75.8k | } |
396 | | |
397 | | // Modify previous state based on updates in this frame. |
398 | 1.09M | if (current->loop_filter_delta_update) { |
399 | 974k | for (i = 0; i < 4; i++) { |
400 | 779k | if (current->update_ref_delta[i]) |
401 | 513k | vp9->loop_filter_ref_deltas[i] = |
402 | 513k | current->loop_filter_ref_deltas[i]; |
403 | 779k | } |
404 | 584k | for (i = 0; i < 2; i++) { |
405 | 389k | if (current->update_mode_delta[i]) |
406 | 139k | vp9->loop_filter_mode_deltas[i] = |
407 | 139k | current->loop_filter_mode_deltas[i]; |
408 | 389k | } |
409 | 194k | } |
410 | | |
411 | 1.09M | if (current->segmentation_update_data) { |
412 | 111k | memcpy(vp9->feature_enabled, current->feature_enabled, |
413 | 111k | sizeof(vp9->feature_enabled)); |
414 | 111k | memcpy(vp9->feature_value, current->feature_value, |
415 | 111k | sizeof(vp9->feature_value)); |
416 | 111k | memcpy(vp9->feature_sign, current->feature_sign, |
417 | 111k | sizeof(vp9->feature_sign)); |
418 | | |
419 | 111k | if (current->segmentation_update_map) { |
420 | 71.2k | memcpy(vp9->segmentation_tree_probs, |
421 | 71.2k | current->segmentation_tree_probs, |
422 | 71.2k | sizeof(vp9->segmentation_tree_probs)); |
423 | 71.2k | memcpy(vp9->segmentation_pred_prob, |
424 | 71.2k | current->segmentation_pred_prob, |
425 | 71.2k | sizeof(vp9->segmentation_pred_prob)); |
426 | 71.2k | } |
427 | 111k | } |
428 | | |
429 | 1.09M | av_log(ctx->log_ctx, AV_LOG_DEBUG, "Frame: size %dx%d " |
430 | 1.09M | "subsample %dx%d bit_depth %d tiles %dx%d.\n", |
431 | 1.09M | vp9->frame_width, vp9->frame_height, |
432 | 1.09M | vp9->subsampling_x, vp9->subsampling_y, |
433 | 1.09M | vp9->bit_depth, 1 << current->tile_cols_log2, |
434 | 1.09M | 1 << current->tile_rows_log2); |
435 | | |
436 | 1.09M | return 0; |
437 | 1.09M | } cbs_vp9.c:cbs_vp9_read_uncompressed_header Line | Count | Source | 270 | 1.78M | { | 271 | 1.78M | CodedBitstreamVP9Context *vp9 = ctx->priv_data; | 272 | 1.78M | int err, i; | 273 | | | 274 | 1.78M | f(2, frame_marker); | 275 | | | 276 | 1.77M | f(1, profile_low_bit); | 277 | 1.77M | f(1, profile_high_bit); | 278 | 1.77M | vp9->profile = (current->profile_high_bit << 1) + current->profile_low_bit; | 279 | 1.77M | if (vp9->profile == 3) | 280 | 359k | fixed(1, reserved_zero, 0); | 281 | | | 282 | 1.67M | f(1, show_existing_frame); | 283 | 1.67M | if (current->show_existing_frame) { | 284 | 207k | f(3, frame_to_show_map_idx); | 285 | 205k | infer(header_size_in_bytes, 0); | 286 | 205k | infer(refresh_frame_flags, 0x00); | 287 | 205k | infer(loop_filter_level, 0); | 288 | 205k | return 0; | 289 | 207k | } | 290 | | | 291 | 1.46M | f(1, frame_type); | 292 | 1.46M | f(1, show_frame); | 293 | 1.46M | f(1, error_resilient_mode); | 294 | | | 295 | 1.45M | if (current->frame_type == VP9_KEY_FRAME) { | 296 | 239k | CHECK(FUNC(frame_sync_code)(ctx, rw, current)); | 297 | 49.2k | CHECK(FUNC(color_config)(ctx, rw, current, vp9->profile)); | 298 | 40.2k | CHECK(FUNC(frame_size)(ctx, rw, current)); | 299 | 37.9k | CHECK(FUNC(render_size)(ctx, rw, current)); | 300 | | | 301 | 35.7k | infer(refresh_frame_flags, 0xff); | 302 | | | 303 | 1.21M | } else { | 304 | 1.21M | if (current->show_frame == 0) | 305 | 168k | f(1, intra_only); | 306 | 1.05M | else | 307 | 1.05M | infer(intra_only, 0); | 308 | | | 309 | 1.20M | if (current->error_resilient_mode == 0) | 310 | 1.08M | f(2, reset_frame_context); | 311 | 122k | else | 312 | 122k | infer(reset_frame_context, 0); | 313 | | | 314 | 1.18M | if (current->intra_only == 1) { | 315 | 39.0k | CHECK(FUNC(frame_sync_code)(ctx, rw, current)); | 316 | | | 317 | 25.0k | if (vp9->profile > 0) { | 318 | 19.3k | CHECK(FUNC(color_config)(ctx, rw, current, vp9->profile)); | 319 | 19.3k | } else { | 320 | 5.69k | infer(color_space, 1); | 321 | 5.69k | infer(subsampling_x, 1); | 322 | 5.69k | infer(subsampling_y, 1); | 323 | 5.69k | vp9->bit_depth = 8; | 324 | | | 325 | 5.69k | vp9->subsampling_x = current->subsampling_x; | 326 | 5.69k | vp9->subsampling_y = current->subsampling_y; | 327 | 5.69k | } | 328 | | | 329 | 24.1k | f(8, refresh_frame_flags); | 330 | | | 331 | 21.3k | CHECK(FUNC(frame_size)(ctx, rw, current)); | 332 | 19.1k | CHECK(FUNC(render_size)(ctx, rw, current)); | 333 | 1.14M | } else { | 334 | 1.14M | f(8, refresh_frame_flags); | 335 | | | 336 | 4.40M | for (i = 0; i < VP9_REFS_PER_FRAME; i++) { | 337 | 3.30M | fs(3, ref_frame_idx[i], 1, i); | 338 | 3.30M | fs(1, ref_frame_sign_bias[VP9_LAST_FRAME + i], | 339 | 3.30M | 1, VP9_LAST_FRAME + i); | 340 | 3.30M | } | 341 | | | 342 | 1.09M | CHECK(FUNC(frame_size_with_refs)(ctx, rw, current)); | 343 | 1.08M | f(1, allow_high_precision_mv); | 344 | 1.08M | CHECK(FUNC(interpolation_filter)(ctx, rw, current)); | 345 | 1.08M | } | 346 | 1.18M | } | 347 | | | 348 | 1.13M | if (current->error_resilient_mode == 0) { | 349 | 1.07M | f(1, refresh_frame_context); | 350 | 1.06M | f(1, frame_parallel_decoding_mode); | 351 | 1.06M | } else { | 352 | 60.1k | infer(refresh_frame_context, 0); | 353 | 60.1k | infer(frame_parallel_decoding_mode, 1); | 354 | 60.1k | } | 355 | | | 356 | 1.12M | f(2, frame_context_idx); | 357 | | | 358 | 1.12M | CHECK(FUNC(loop_filter_params)(ctx, rw, current)); | 359 | 1.11M | CHECK(FUNC(quantization_params)(ctx, rw, current)); | 360 | 1.10M | CHECK(FUNC(segmentation_params)(ctx, rw, current)); | 361 | 1.09M | CHECK(FUNC(tile_info)(ctx, rw, current)); | 362 | | | 363 | 1.08M | f(16, header_size_in_bytes); | 364 | | | 365 | 9.75M | for (i = 0; i < VP9_NUM_REF_FRAMES; i++) { | 366 | 8.66M | if (current->refresh_frame_flags & (1 << i)) { | 367 | 3.99M | vp9->ref[i] = (VP9ReferenceFrameState) { | 368 | 3.99M | .frame_width = vp9->frame_width, | 369 | 3.99M | .frame_height = vp9->frame_height, | 370 | 3.99M | .subsampling_x = vp9->subsampling_x, | 371 | 3.99M | .subsampling_y = vp9->subsampling_y, | 372 | 3.99M | .bit_depth = vp9->bit_depth, | 373 | 3.99M | }; | 374 | 3.99M | } | 375 | 8.66M | } | 376 | | | 377 | | // Update top-level loop filter and segmentation state with changes | 378 | | // from this frame. | 379 | 1.08M | if (current->frame_type == VP9_KEY_FRAME || | 380 | 1.05M | current->intra_only || | 381 | 1.03M | current->error_resilient_mode) { | 382 | | // setup_past_independence() - fill with the initial values. | 383 | | | 384 | 70.5k | vp9->loop_filter_ref_deltas[VP9_INTRA_FRAME] = 1; | 385 | 70.5k | vp9->loop_filter_ref_deltas[VP9_LAST_FRAME] = 0; | 386 | 70.5k | vp9->loop_filter_ref_deltas[VP9_GOLDEN_FRAME] = -1; | 387 | 70.5k | vp9->loop_filter_ref_deltas[VP9_ALTREF_FRAME] = -1; | 388 | | | 389 | 70.5k | vp9->loop_filter_mode_deltas[0] = 0; | 390 | 70.5k | vp9->loop_filter_mode_deltas[1] = 0; | 391 | | | 392 | 70.5k | memset(vp9->feature_enabled, 0, sizeof(vp9->feature_enabled)); | 393 | 70.5k | memset(vp9->feature_value, 0, sizeof(vp9->feature_value)); | 394 | 70.5k | memset(vp9->feature_sign, 0, sizeof(vp9->feature_sign)); | 395 | 70.5k | } | 396 | | | 397 | | // Modify previous state based on updates in this frame. | 398 | 1.08M | if (current->loop_filter_delta_update) { | 399 | 965k | for (i = 0; i < 4; i++) { | 400 | 772k | if (current->update_ref_delta[i]) | 401 | 509k | vp9->loop_filter_ref_deltas[i] = | 402 | 509k | current->loop_filter_ref_deltas[i]; | 403 | 772k | } | 404 | 579k | for (i = 0; i < 2; i++) { | 405 | 386k | if (current->update_mode_delta[i]) | 406 | 138k | vp9->loop_filter_mode_deltas[i] = | 407 | 138k | current->loop_filter_mode_deltas[i]; | 408 | 386k | } | 409 | 193k | } | 410 | | | 411 | 1.08M | if (current->segmentation_update_data) { | 412 | 110k | memcpy(vp9->feature_enabled, current->feature_enabled, | 413 | 110k | sizeof(vp9->feature_enabled)); | 414 | 110k | memcpy(vp9->feature_value, current->feature_value, | 415 | 110k | sizeof(vp9->feature_value)); | 416 | 110k | memcpy(vp9->feature_sign, current->feature_sign, | 417 | 110k | sizeof(vp9->feature_sign)); | 418 | | | 419 | 110k | if (current->segmentation_update_map) { | 420 | 70.8k | memcpy(vp9->segmentation_tree_probs, | 421 | 70.8k | current->segmentation_tree_probs, | 422 | 70.8k | sizeof(vp9->segmentation_tree_probs)); | 423 | 70.8k | memcpy(vp9->segmentation_pred_prob, | 424 | 70.8k | current->segmentation_pred_prob, | 425 | 70.8k | sizeof(vp9->segmentation_pred_prob)); | 426 | 70.8k | } | 427 | 110k | } | 428 | | | 429 | 1.08M | av_log(ctx->log_ctx, AV_LOG_DEBUG, "Frame: size %dx%d " | 430 | 1.08M | "subsample %dx%d bit_depth %d tiles %dx%d.\n", | 431 | 1.08M | vp9->frame_width, vp9->frame_height, | 432 | 1.08M | vp9->subsampling_x, vp9->subsampling_y, | 433 | 1.08M | vp9->bit_depth, 1 << current->tile_cols_log2, | 434 | 1.08M | 1 << current->tile_rows_log2); | 435 | | | 436 | 1.08M | return 0; | 437 | 1.08M | } |
cbs_vp9.c:cbs_vp9_write_uncompressed_header Line | Count | Source | 270 | 17.8k | { | 271 | 17.8k | CodedBitstreamVP9Context *vp9 = ctx->priv_data; | 272 | 17.8k | int err, i; | 273 | | | 274 | 17.8k | f(2, frame_marker); | 275 | | | 276 | 17.8k | f(1, profile_low_bit); | 277 | 17.8k | f(1, profile_high_bit); | 278 | 17.8k | vp9->profile = (current->profile_high_bit << 1) + current->profile_low_bit; | 279 | 17.8k | if (vp9->profile == 3) | 280 | 6.30k | fixed(1, reserved_zero, 0); | 281 | | | 282 | 17.8k | f(1, show_existing_frame); | 283 | 17.8k | if (current->show_existing_frame) { | 284 | 6.75k | f(3, frame_to_show_map_idx); | 285 | 6.75k | infer(header_size_in_bytes, 0); | 286 | 6.75k | infer(refresh_frame_flags, 0x00); | 287 | 6.75k | infer(loop_filter_level, 0); | 288 | 6.75k | return 0; | 289 | 6.75k | } | 290 | | | 291 | 11.0k | f(1, frame_type); | 292 | 11.0k | f(1, show_frame); | 293 | 11.0k | f(1, error_resilient_mode); | 294 | | | 295 | 11.0k | if (current->frame_type == VP9_KEY_FRAME) { | 296 | 2.28k | CHECK(FUNC(frame_sync_code)(ctx, rw, current)); | 297 | 2.28k | CHECK(FUNC(color_config)(ctx, rw, current, vp9->profile)); | 298 | 2.28k | CHECK(FUNC(frame_size)(ctx, rw, current)); | 299 | 2.28k | CHECK(FUNC(render_size)(ctx, rw, current)); | 300 | | | 301 | 2.28k | infer(refresh_frame_flags, 0xff); | 302 | | | 303 | 8.76k | } else { | 304 | 8.76k | if (current->show_frame == 0) | 305 | 7.28k | f(1, intra_only); | 306 | 1.48k | else | 307 | 1.48k | infer(intra_only, 0); | 308 | | | 309 | 8.76k | if (current->error_resilient_mode == 0) | 310 | 5.63k | f(2, reset_frame_context); | 311 | 3.13k | else | 312 | 3.13k | infer(reset_frame_context, 0); | 313 | | | 314 | 8.76k | if (current->intra_only == 1) { | 315 | 459 | CHECK(FUNC(frame_sync_code)(ctx, rw, current)); | 316 | | | 317 | 459 | if (vp9->profile > 0) { | 318 | 233 | CHECK(FUNC(color_config)(ctx, rw, current, vp9->profile)); | 319 | 233 | } else { | 320 | 226 | infer(color_space, 1); | 321 | 226 | infer(subsampling_x, 1); | 322 | 226 | infer(subsampling_y, 1); | 323 | 226 | vp9->bit_depth = 8; | 324 | | | 325 | 226 | vp9->subsampling_x = current->subsampling_x; | 326 | 226 | vp9->subsampling_y = current->subsampling_y; | 327 | 226 | } | 328 | | | 329 | 459 | f(8, refresh_frame_flags); | 330 | | | 331 | 459 | CHECK(FUNC(frame_size)(ctx, rw, current)); | 332 | 459 | CHECK(FUNC(render_size)(ctx, rw, current)); | 333 | 8.30k | } else { | 334 | 8.30k | f(8, refresh_frame_flags); | 335 | | | 336 | 33.2k | for (i = 0; i < VP9_REFS_PER_FRAME; i++) { | 337 | 24.9k | fs(3, ref_frame_idx[i], 1, i); | 338 | 24.9k | fs(1, ref_frame_sign_bias[VP9_LAST_FRAME + i], | 339 | 24.9k | 1, VP9_LAST_FRAME + i); | 340 | 24.9k | } | 341 | | | 342 | 8.30k | CHECK(FUNC(frame_size_with_refs)(ctx, rw, current)); | 343 | 8.30k | f(1, allow_high_precision_mv); | 344 | 8.30k | CHECK(FUNC(interpolation_filter)(ctx, rw, current)); | 345 | 8.30k | } | 346 | 8.76k | } | 347 | | | 348 | 11.0k | if (current->error_resilient_mode == 0) { | 349 | 6.96k | f(1, refresh_frame_context); | 350 | 6.96k | f(1, frame_parallel_decoding_mode); | 351 | 6.96k | } else { | 352 | 4.08k | infer(refresh_frame_context, 0); | 353 | 4.08k | infer(frame_parallel_decoding_mode, 1); | 354 | 4.08k | } | 355 | | | 356 | 11.0k | f(2, frame_context_idx); | 357 | | | 358 | 11.0k | CHECK(FUNC(loop_filter_params)(ctx, rw, current)); | 359 | 11.0k | CHECK(FUNC(quantization_params)(ctx, rw, current)); | 360 | 11.0k | CHECK(FUNC(segmentation_params)(ctx, rw, current)); | 361 | 11.0k | CHECK(FUNC(tile_info)(ctx, rw, current)); | 362 | | | 363 | 10.1k | f(16, header_size_in_bytes); | 364 | | | 365 | 91.1k | for (i = 0; i < VP9_NUM_REF_FRAMES; i++) { | 366 | 81.0k | if (current->refresh_frame_flags & (1 << i)) { | 367 | 45.0k | vp9->ref[i] = (VP9ReferenceFrameState) { | 368 | 45.0k | .frame_width = vp9->frame_width, | 369 | 45.0k | .frame_height = vp9->frame_height, | 370 | 45.0k | .subsampling_x = vp9->subsampling_x, | 371 | 45.0k | .subsampling_y = vp9->subsampling_y, | 372 | 45.0k | .bit_depth = vp9->bit_depth, | 373 | 45.0k | }; | 374 | 45.0k | } | 375 | 81.0k | } | 376 | | | 377 | | // Update top-level loop filter and segmentation state with changes | 378 | | // from this frame. | 379 | 10.1k | if (current->frame_type == VP9_KEY_FRAME || | 380 | 7.84k | current->intra_only || | 381 | 7.38k | current->error_resilient_mode) { | 382 | | // setup_past_independence() - fill with the initial values. | 383 | | | 384 | 5.32k | vp9->loop_filter_ref_deltas[VP9_INTRA_FRAME] = 1; | 385 | 5.32k | vp9->loop_filter_ref_deltas[VP9_LAST_FRAME] = 0; | 386 | 5.32k | vp9->loop_filter_ref_deltas[VP9_GOLDEN_FRAME] = -1; | 387 | 5.32k | vp9->loop_filter_ref_deltas[VP9_ALTREF_FRAME] = -1; | 388 | | | 389 | 5.32k | vp9->loop_filter_mode_deltas[0] = 0; | 390 | 5.32k | vp9->loop_filter_mode_deltas[1] = 0; | 391 | | | 392 | 5.32k | memset(vp9->feature_enabled, 0, sizeof(vp9->feature_enabled)); | 393 | 5.32k | memset(vp9->feature_value, 0, sizeof(vp9->feature_value)); | 394 | 5.32k | memset(vp9->feature_sign, 0, sizeof(vp9->feature_sign)); | 395 | 5.32k | } | 396 | | | 397 | | // Modify previous state based on updates in this frame. | 398 | 10.1k | if (current->loop_filter_delta_update) { | 399 | 8.72k | for (i = 0; i < 4; i++) { | 400 | 6.98k | if (current->update_ref_delta[i]) | 401 | 3.50k | vp9->loop_filter_ref_deltas[i] = | 402 | 3.50k | current->loop_filter_ref_deltas[i]; | 403 | 6.98k | } | 404 | 5.23k | for (i = 0; i < 2; i++) { | 405 | 3.49k | if (current->update_mode_delta[i]) | 406 | 990 | vp9->loop_filter_mode_deltas[i] = | 407 | 990 | current->loop_filter_mode_deltas[i]; | 408 | 3.49k | } | 409 | 1.74k | } | 410 | | | 411 | 10.1k | if (current->segmentation_update_data) { | 412 | 1.64k | memcpy(vp9->feature_enabled, current->feature_enabled, | 413 | 1.64k | sizeof(vp9->feature_enabled)); | 414 | 1.64k | memcpy(vp9->feature_value, current->feature_value, | 415 | 1.64k | sizeof(vp9->feature_value)); | 416 | 1.64k | memcpy(vp9->feature_sign, current->feature_sign, | 417 | 1.64k | sizeof(vp9->feature_sign)); | 418 | | | 419 | 1.64k | if (current->segmentation_update_map) { | 420 | 364 | memcpy(vp9->segmentation_tree_probs, | 421 | 364 | current->segmentation_tree_probs, | 422 | 364 | sizeof(vp9->segmentation_tree_probs)); | 423 | 364 | memcpy(vp9->segmentation_pred_prob, | 424 | 364 | current->segmentation_pred_prob, | 425 | 364 | sizeof(vp9->segmentation_pred_prob)); | 426 | 364 | } | 427 | 1.64k | } | 428 | | | 429 | 10.1k | av_log(ctx->log_ctx, AV_LOG_DEBUG, "Frame: size %dx%d " | 430 | 10.1k | "subsample %dx%d bit_depth %d tiles %dx%d.\n", | 431 | 10.1k | vp9->frame_width, vp9->frame_height, | 432 | 10.1k | vp9->subsampling_x, vp9->subsampling_y, | 433 | 10.1k | vp9->bit_depth, 1 << current->tile_cols_log2, | 434 | 10.1k | 1 << current->tile_rows_log2); | 435 | | | 436 | 10.1k | return 0; | 437 | 10.1k | } |
|
438 | | |
439 | | static int FUNC(trailing_bits)(CodedBitstreamContext *ctx, RWContext *rw) |
440 | 1.30M | { |
441 | 1.30M | int err; |
442 | 5.15M | while (byte_alignment(rw) != 0) |
443 | 3.94M | fixed(1, zero_bit, 0); |
444 | | |
445 | 1.21M | return 0; |
446 | 1.30M | } cbs_vp9.c:cbs_vp9_read_trailing_bits Line | Count | Source | 440 | 1.28M | { | 441 | 1.28M | int err; | 442 | 5.11M | while (byte_alignment(rw) != 0) | 443 | 3.91M | fixed(1, zero_bit, 0); | 444 | | | 445 | 1.19M | return 0; | 446 | 1.28M | } |
cbs_vp9.c:cbs_vp9_write_trailing_bits Line | Count | Source | 440 | 16.8k | { | 441 | 16.8k | int err; | 442 | 43.0k | while (byte_alignment(rw) != 0) | 443 | 26.1k | fixed(1, zero_bit, 0); | 444 | | | 445 | 16.8k | return 0; | 446 | 16.8k | } |
|
447 | | |
448 | | static int FUNC(frame)(CodedBitstreamContext *ctx, RWContext *rw, |
449 | | VP9RawFrame *current) |
450 | 1.79M | { |
451 | 1.79M | int err; |
452 | | |
453 | 1.79M | HEADER("Frame"); |
454 | | |
455 | 1.79M | CHECK(FUNC(uncompressed_header)(ctx, rw, ¤t->header)); |
456 | | |
457 | 1.30M | CHECK(FUNC(trailing_bits)(ctx, rw)); |
458 | | |
459 | 1.21M | return 0; |
460 | 1.30M | } cbs_vp9.c:cbs_vp9_read_frame Line | Count | Source | 450 | 1.78M | { | 451 | 1.78M | int err; | 452 | | | 453 | 1.78M | HEADER("Frame"); | 454 | | | 455 | 1.78M | CHECK(FUNC(uncompressed_header)(ctx, rw, ¤t->header)); | 456 | | | 457 | 1.28M | CHECK(FUNC(trailing_bits)(ctx, rw)); | 458 | | | 459 | 1.19M | return 0; | 460 | 1.28M | } |
cbs_vp9.c:cbs_vp9_write_frame Line | Count | Source | 450 | 17.8k | { | 451 | 17.8k | int err; | 452 | | | 453 | 17.8k | HEADER("Frame"); | 454 | | | 455 | 17.8k | CHECK(FUNC(uncompressed_header)(ctx, rw, ¤t->header)); | 456 | | | 457 | 16.8k | CHECK(FUNC(trailing_bits)(ctx, rw)); | 458 | | | 459 | 16.8k | return 0; | 460 | 16.8k | } |
|
461 | | |
462 | | static int FUNC(superframe_index)(CodedBitstreamContext *ctx, RWContext *rw, |
463 | | VP9RawSuperframeIndex *current) |
464 | 17.6k | { |
465 | 17.6k | int err, i; |
466 | | |
467 | 17.6k | HEADER("Superframe Index"); |
468 | | |
469 | 17.6k | f(3, superframe_marker); |
470 | 17.6k | f(2, bytes_per_framesize_minus_1); |
471 | 17.6k | f(3, frames_in_superframe_minus_1); |
472 | | |
473 | 71.2k | for (i = 0; i <= current->frames_in_superframe_minus_1; i++) { |
474 | | // Surprise little-endian! |
475 | 58.6k | fle(8 * (current->bytes_per_framesize_minus_1 + 1), |
476 | 58.6k | frame_sizes[i], 1, i); |
477 | 58.6k | } |
478 | | |
479 | 12.6k | f(3, superframe_marker); |
480 | 11.8k | f(2, bytes_per_framesize_minus_1); |
481 | 11.8k | f(3, frames_in_superframe_minus_1); |
482 | | |
483 | 11.8k | return 0; |
484 | 11.8k | } cbs_vp9.c:cbs_vp9_read_superframe_index Line | Count | Source | 464 | 16.2k | { | 465 | 16.2k | int err, i; | 466 | | | 467 | 16.2k | HEADER("Superframe Index"); | 468 | | | 469 | 16.2k | f(3, superframe_marker); | 470 | 16.2k | f(2, bytes_per_framesize_minus_1); | 471 | 16.2k | f(3, frames_in_superframe_minus_1); | 472 | | | 473 | 64.1k | for (i = 0; i <= current->frames_in_superframe_minus_1; i++) { | 474 | | // Surprise little-endian! | 475 | 52.8k | fle(8 * (current->bytes_per_framesize_minus_1 + 1), | 476 | 52.8k | frame_sizes[i], 1, i); | 477 | 52.8k | } | 478 | | | 479 | 11.2k | f(3, superframe_marker); | 480 | 10.4k | f(2, bytes_per_framesize_minus_1); | 481 | 10.4k | f(3, frames_in_superframe_minus_1); | 482 | | | 483 | 10.4k | return 0; | 484 | 10.4k | } |
cbs_vp9.c:cbs_vp9_write_superframe_index Line | Count | Source | 464 | 1.40k | { | 465 | 1.40k | int err, i; | 466 | | | 467 | 1.40k | HEADER("Superframe Index"); | 468 | | | 469 | 1.40k | f(3, superframe_marker); | 470 | 1.40k | f(2, bytes_per_framesize_minus_1); | 471 | 1.40k | f(3, frames_in_superframe_minus_1); | 472 | | | 473 | 7.12k | for (i = 0; i <= current->frames_in_superframe_minus_1; i++) { | 474 | | // Surprise little-endian! | 475 | 5.72k | fle(8 * (current->bytes_per_framesize_minus_1 + 1), | 476 | 5.72k | frame_sizes[i], 1, i); | 477 | 5.72k | } | 478 | | | 479 | 1.40k | f(3, superframe_marker); | 480 | 1.40k | f(2, bytes_per_framesize_minus_1); | 481 | 1.40k | f(3, frames_in_superframe_minus_1); | 482 | | | 483 | 1.40k | return 0; | 484 | 1.40k | } |
|