Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: source/libvpx/vp9/vp9_dx_iface.c

Issue 390713002: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: libvpx: Pull from upstream Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/vp9_cx_iface.c ('k') | source/libvpx/vp9/vp9dx.mk » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <stdlib.h> 11 #include <stdlib.h>
12 #include <string.h> 12 #include <string.h>
13 13
14 #include "./vpx_version.h" 14 #include "./vpx_version.h"
15 15
16 #include "vpx/internal/vpx_codec_internal.h" 16 #include "vpx/internal/vpx_codec_internal.h"
17 #include "vpx/vp8dx.h" 17 #include "vpx/vp8dx.h"
18 #include "vpx/vpx_decoder.h" 18 #include "vpx/vpx_decoder.h"
19 19
20 #include "vp9/common/vp9_frame_buffers.h" 20 #include "vp9/common/vp9_frame_buffers.h"
21 21
22 #include "vp9/decoder/vp9_decoder.h" 22 #include "vp9/decoder/vp9_decoder.h"
23 #include "vp9/decoder/vp9_decodeframe.h"
23 #include "vp9/decoder/vp9_read_bit_buffer.h" 24 #include "vp9/decoder/vp9_read_bit_buffer.h"
24 25
25 #include "vp9/vp9_iface_common.h" 26 #include "vp9/vp9_iface_common.h"
26 27
27 #define VP9_CAP_POSTPROC (CONFIG_VP9_POSTPROC ? VPX_CODEC_CAP_POSTPROC : 0) 28 #define VP9_CAP_POSTPROC (CONFIG_VP9_POSTPROC ? VPX_CODEC_CAP_POSTPROC : 0)
28 29
29 typedef vpx_codec_stream_info_t vp9_stream_info_t; 30 typedef vpx_codec_stream_info_t vp9_stream_info_t;
30 31
31 struct vpx_codec_alg_priv { 32 struct vpx_codec_alg_priv {
32 vpx_codec_priv_t base; 33 vpx_codec_priv_t base;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 92 }
92 93
93 vpx_free(ctx); 94 vpx_free(ctx);
94 95
95 return VPX_CODEC_OK; 96 return VPX_CODEC_OK;
96 } 97 }
97 98
98 static vpx_codec_err_t decoder_peek_si_internal(const uint8_t *data, 99 static vpx_codec_err_t decoder_peek_si_internal(const uint8_t *data,
99 unsigned int data_sz, 100 unsigned int data_sz,
100 vpx_codec_stream_info_t *si, 101 vpx_codec_stream_info_t *si,
102 int *is_intra_only,
101 vpx_decrypt_cb decrypt_cb, 103 vpx_decrypt_cb decrypt_cb,
102 void *decrypt_state) { 104 void *decrypt_state) {
105 int intra_only_flag = 0;
103 uint8_t clear_buffer[9]; 106 uint8_t clear_buffer[9];
104 107
105 if (data + data_sz <= data) 108 if (data + data_sz <= data)
106 return VPX_CODEC_INVALID_PARAM; 109 return VPX_CODEC_INVALID_PARAM;
107 110
108 si->is_kf = 0; 111 si->is_kf = 0;
109 si->w = si->h = 0; 112 si->w = si->h = 0;
110 113
111 if (decrypt_cb) { 114 if (decrypt_cb) {
112 data_sz = MIN(sizeof(clear_buffer), data_sz); 115 data_sz = MIN(sizeof(clear_buffer), data_sz);
113 decrypt_cb(decrypt_state, data, clear_buffer, data_sz); 116 decrypt_cb(decrypt_state, data, clear_buffer, data_sz);
114 data = clear_buffer; 117 data = clear_buffer;
115 } 118 }
116 119
117 { 120 {
121 int show_frame;
122 int error_resilient;
118 struct vp9_read_bit_buffer rb = { data, data + data_sz, 0, NULL, NULL }; 123 struct vp9_read_bit_buffer rb = { data, data + data_sz, 0, NULL, NULL };
119 const int frame_marker = vp9_rb_read_literal(&rb, 2); 124 const int frame_marker = vp9_rb_read_literal(&rb, 2);
120 const int version = vp9_rb_read_bit(&rb); 125 const int version = vp9_rb_read_bit(&rb);
121 (void) vp9_rb_read_bit(&rb); // unused version bit 126 (void) vp9_rb_read_bit(&rb); // unused version bit
122 127
123 if (frame_marker != VP9_FRAME_MARKER) 128 if (frame_marker != VP9_FRAME_MARKER)
124 return VPX_CODEC_UNSUP_BITSTREAM; 129 return VPX_CODEC_UNSUP_BITSTREAM;
125 130
126 if (version > 1) return VPX_CODEC_UNSUP_BITSTREAM; 131 if (version > 1) return VPX_CODEC_UNSUP_BITSTREAM;
127 132
128 if (vp9_rb_read_bit(&rb)) { // show an existing frame 133 if (vp9_rb_read_bit(&rb)) { // show an existing frame
134 vp9_rb_read_literal(&rb, 3); // Frame buffer to show.
129 return VPX_CODEC_OK; 135 return VPX_CODEC_OK;
130 } 136 }
131 137
132 if (data_sz <= 8) 138 if (data_sz <= 8)
133 return VPX_CODEC_UNSUP_BITSTREAM; 139 return VPX_CODEC_UNSUP_BITSTREAM;
134 140
135 si->is_kf = !vp9_rb_read_bit(&rb); 141 si->is_kf = !vp9_rb_read_bit(&rb);
142 show_frame = vp9_rb_read_bit(&rb);
143 error_resilient = vp9_rb_read_bit(&rb);
144
136 if (si->is_kf) { 145 if (si->is_kf) {
137 const int sRGB = 7; 146 const int sRGB = 7;
138 int colorspace; 147 int colorspace;
139 148
140 rb.bit_offset += 1; // show frame 149 if (!vp9_read_sync_code(&rb))
141 rb.bit_offset += 1; // error resilient
142
143 if (vp9_rb_read_literal(&rb, 8) != VP9_SYNC_CODE_0 ||
144 vp9_rb_read_literal(&rb, 8) != VP9_SYNC_CODE_1 ||
145 vp9_rb_read_literal(&rb, 8) != VP9_SYNC_CODE_2) {
146 return VPX_CODEC_UNSUP_BITSTREAM; 150 return VPX_CODEC_UNSUP_BITSTREAM;
147 }
148 151
149 colorspace = vp9_rb_read_literal(&rb, 3); 152 colorspace = vp9_rb_read_literal(&rb, 3);
150 if (colorspace != sRGB) { 153 if (colorspace != sRGB) {
151 rb.bit_offset += 1; // [16,235] (including xvycc) vs [0,255] range 154 rb.bit_offset += 1; // [16,235] (including xvycc) vs [0,255] range
152 if (version == 1) { 155 if (version == 1) {
153 rb.bit_offset += 2; // subsampling x/y 156 rb.bit_offset += 2; // subsampling x/y
154 rb.bit_offset += 1; // has extra plane 157 rb.bit_offset += 1; // has extra plane
155 } 158 }
156 } else { 159 } else {
157 if (version == 1) { 160 if (version == 1) {
158 rb.bit_offset += 1; // has extra plane 161 rb.bit_offset += 1; // has extra plane
159 } else { 162 } else {
160 // RGB is only available in version 1 163 // RGB is only available in version 1
161 return VPX_CODEC_UNSUP_BITSTREAM; 164 return VPX_CODEC_UNSUP_BITSTREAM;
162 } 165 }
163 } 166 }
167 vp9_read_frame_size(&rb, (int *)&si->w, (int *)&si->h);
168 } else {
169 intra_only_flag = show_frame ? 0 : vp9_rb_read_bit(&rb);
170 rb.bit_offset += error_resilient ? 0 : 2; // reset_frame_context
164 171
165 // TODO(jzern): these are available on non-keyframes in intra only mode. 172 if (intra_only_flag) {
166 si->w = vp9_rb_read_literal(&rb, 16) + 1; 173 if (!vp9_read_sync_code(&rb))
167 si->h = vp9_rb_read_literal(&rb, 16) + 1; 174 return VPX_CODEC_UNSUP_BITSTREAM;
175 rb.bit_offset += REF_FRAMES; // refresh_frame_flags
176 vp9_read_frame_size(&rb, (int *)&si->w, (int *)&si->h);
177 }
168 } 178 }
169 } 179 }
170 180 if (is_intra_only != NULL)
181 *is_intra_only = intra_only_flag;
171 return VPX_CODEC_OK; 182 return VPX_CODEC_OK;
172 } 183 }
173 184
174 static vpx_codec_err_t decoder_peek_si(const uint8_t *data, 185 static vpx_codec_err_t decoder_peek_si(const uint8_t *data,
175 unsigned int data_sz, 186 unsigned int data_sz,
176 vpx_codec_stream_info_t *si) { 187 vpx_codec_stream_info_t *si) {
177 return decoder_peek_si_internal(data, data_sz, si, NULL, NULL); 188 return decoder_peek_si_internal(data, data_sz, si, NULL, NULL, NULL);
178 } 189 }
179 190
180 static vpx_codec_err_t decoder_get_si(vpx_codec_alg_priv_t *ctx, 191 static vpx_codec_err_t decoder_get_si(vpx_codec_alg_priv_t *ctx,
181 vpx_codec_stream_info_t *si) { 192 vpx_codec_stream_info_t *si) {
182 const size_t sz = (si->sz >= sizeof(vp9_stream_info_t)) 193 const size_t sz = (si->sz >= sizeof(vp9_stream_info_t))
183 ? sizeof(vp9_stream_info_t) 194 ? sizeof(vp9_stream_info_t)
184 : sizeof(vpx_codec_stream_info_t); 195 : sizeof(vpx_codec_stream_info_t);
185 memcpy(si, &ctx->si, sz); 196 memcpy(si, &ctx->si, sz);
186 si->sz = (unsigned int)sz; 197 si->sz = (unsigned int)sz;
187 198
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 270
260 (void)deadline; 271 (void)deadline;
261 272
262 vp9_zero(sd); 273 vp9_zero(sd);
263 ctx->img_avail = 0; 274 ctx->img_avail = 0;
264 275
265 // Determine the stream parameters. Note that we rely on peek_si to 276 // Determine the stream parameters. Note that we rely on peek_si to
266 // validate that we have a buffer that does not wrap around the top 277 // validate that we have a buffer that does not wrap around the top
267 // of the heap. 278 // of the heap.
268 if (!ctx->si.h) { 279 if (!ctx->si.h) {
280 int is_intra_only = 0;
269 const vpx_codec_err_t res = 281 const vpx_codec_err_t res =
270 decoder_peek_si_internal(*data, data_sz, &ctx->si, ctx->decrypt_cb, 282 decoder_peek_si_internal(*data, data_sz, &ctx->si, &is_intra_only,
271 ctx->decrypt_state); 283 ctx->decrypt_cb, ctx->decrypt_state);
272 if (res != VPX_CODEC_OK) 284 if (res != VPX_CODEC_OK)
273 return res; 285 return res;
274 286
275 if (!ctx->si.is_kf) 287 if (!ctx->si.is_kf && !is_intra_only)
276 return VPX_CODEC_ERROR; 288 return VPX_CODEC_ERROR;
277 } 289 }
278 290
279 // Initialize the decoder instance on the first frame 291 // Initialize the decoder instance on the first frame
280 if (ctx->pbi == NULL) { 292 if (ctx->pbi == NULL) {
281 init_decoder(ctx); 293 init_decoder(ctx);
282 if (ctx->pbi == NULL) 294 if (ctx->pbi == NULL)
283 return VPX_CODEC_ERROR; 295 return VPX_CODEC_ERROR;
284 } 296 }
285 297
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 { // NOLINT 708 { // NOLINT
697 NOT_IMPLEMENTED, // vpx_codec_enc_cfg_map_t 709 NOT_IMPLEMENTED, // vpx_codec_enc_cfg_map_t
698 NOT_IMPLEMENTED, // vpx_codec_encode_fn_t 710 NOT_IMPLEMENTED, // vpx_codec_encode_fn_t
699 NOT_IMPLEMENTED, // vpx_codec_get_cx_data_fn_t 711 NOT_IMPLEMENTED, // vpx_codec_get_cx_data_fn_t
700 NOT_IMPLEMENTED, // vpx_codec_enc_config_set_fn_t 712 NOT_IMPLEMENTED, // vpx_codec_enc_config_set_fn_t
701 NOT_IMPLEMENTED, // vpx_codec_get_global_headers_fn_t 713 NOT_IMPLEMENTED, // vpx_codec_get_global_headers_fn_t
702 NOT_IMPLEMENTED, // vpx_codec_get_preview_frame_fn_t 714 NOT_IMPLEMENTED, // vpx_codec_get_preview_frame_fn_t
703 NOT_IMPLEMENTED // vpx_codec_enc_mr_get_mem_loc_fn_t 715 NOT_IMPLEMENTED // vpx_codec_enc_mr_get_mem_loc_fn_t
704 } 716 }
705 }; 717 };
OLDNEW
« no previous file with comments | « source/libvpx/vp9/vp9_cx_iface.c ('k') | source/libvpx/vp9/vp9dx.mk » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698