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

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

Issue 11555023: libvpx: Add VP9 decoder. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 8 years 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11
12 #include <stdlib.h>
13 #include <string.h>
14 #include "vpx/vpx_decoder.h"
15 #include "vpx/vp8dx.h"
16 #include "vpx/internal/vpx_codec_internal.h"
17 #include "vpx_version.h"
18 #include "common/vp9_onyxd.h"
19 #include "decoder/vp9_onyxd_int.h"
20
21 #define VP8_CAP_POSTPROC (CONFIG_POSTPROC ? VPX_CODEC_CAP_POSTPROC : 0)
22 typedef vpx_codec_stream_info_t vp8_stream_info_t;
23
24 /* Structures for handling memory allocations */
25 typedef enum {
26 VP8_SEG_ALG_PRIV = 256,
27 VP8_SEG_MAX
28 } mem_seg_id_t;
29 #define NELEMENTS(x) ((int)(sizeof(x)/sizeof(x[0])))
30
31 static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si, vpx_codec_flags_ t);
32
33 typedef struct {
34 unsigned int id;
35 unsigned long sz;
36 unsigned int align;
37 unsigned int flags;
38 unsigned long(*calc_sz)(const vpx_codec_dec_cfg_t *, vpx_codec_flags_t);
39 } mem_req_t;
40
41 static const mem_req_t vp8_mem_req_segs[] = {
42 {VP8_SEG_ALG_PRIV, 0, 8, VPX_CODEC_MEM_ZERO, vp8_priv_sz},
43 {VP8_SEG_MAX, 0, 0, 0, NULL}
44 };
45
46 struct vpx_codec_alg_priv {
47 vpx_codec_priv_t base;
48 vpx_codec_mmap_t mmaps[NELEMENTS(vp8_mem_req_segs) - 1];
49 vpx_codec_dec_cfg_t cfg;
50 vp8_stream_info_t si;
51 int defer_alloc;
52 int decoder_init;
53 VP9D_PTR pbi;
54 int postproc_cfg_set;
55 vp8_postproc_cfg_t postproc_cfg;
56 #if CONFIG_POSTPROC_VISUALIZER
57 unsigned int dbg_postproc_flag;
58 int dbg_color_ref_frame_flag;
59 int dbg_color_mb_modes_flag;
60 int dbg_color_b_modes_flag;
61 int dbg_display_mv_flag;
62 #endif
63 vpx_image_t img;
64 int img_setup;
65 int img_avail;
66 };
67
68 static unsigned long vp8_priv_sz(const vpx_codec_dec_cfg_t *si,
69 vpx_codec_flags_t flags) {
70 /* Although this declaration is constant, we can't use it in the requested
71 * segments list because we want to define the requested segments list
72 * before defining the private type (so that the number of memory maps is
73 * known)
74 */
75 (void)si;
76 return sizeof(vpx_codec_alg_priv_t);
77 }
78
79
80 static void vp8_mmap_dtor(vpx_codec_mmap_t *mmap) {
81 free(mmap->priv);
82 }
83
84 static vpx_codec_err_t vp8_mmap_alloc(vpx_codec_mmap_t *mmap) {
85 vpx_codec_err_t res;
86 unsigned int align;
87
88 align = mmap->align ? mmap->align - 1 : 0;
89
90 if (mmap->flags & VPX_CODEC_MEM_ZERO)
91 mmap->priv = calloc(1, mmap->sz + align);
92 else
93 mmap->priv = malloc(mmap->sz + align);
94
95 res = (mmap->priv) ? VPX_CODEC_OK : VPX_CODEC_MEM_ERROR;
96 mmap->base = (void *)((((uintptr_t)mmap->priv) + align) & ~(uintptr_t)align);
97 mmap->dtor = vp8_mmap_dtor;
98 return res;
99 }
100
101 static vpx_codec_err_t vp8_validate_mmaps(const vp8_stream_info_t *si,
102 const vpx_codec_mmap_t *mmaps,
103 vpx_codec_flags_t init_flags) {
104 int i;
105 vpx_codec_err_t res = VPX_CODEC_OK;
106
107 for (i = 0; i < NELEMENTS(vp8_mem_req_segs) - 1; i++) {
108 /* Ensure the segment has been allocated */
109 if (!mmaps[i].base) {
110 res = VPX_CODEC_MEM_ERROR;
111 break;
112 }
113
114 /* Verify variable size segment is big enough for the current si. */
115 if (vp8_mem_req_segs[i].calc_sz) {
116 vpx_codec_dec_cfg_t cfg;
117
118 cfg.w = si->w;
119 cfg.h = si->h;
120
121 if (mmaps[i].sz < vp8_mem_req_segs[i].calc_sz(&cfg, init_flags)) {
122 res = VPX_CODEC_MEM_ERROR;
123 break;
124 }
125 }
126 }
127
128 return res;
129 }
130
131 static void vp8_init_ctx(vpx_codec_ctx_t *ctx, const vpx_codec_mmap_t *mmap) {
132 int i;
133
134 ctx->priv = mmap->base;
135 ctx->priv->sz = sizeof(*ctx->priv);
136 ctx->priv->iface = ctx->iface;
137 ctx->priv->alg_priv = mmap->base;
138
139 for (i = 0; i < NELEMENTS(ctx->priv->alg_priv->mmaps); i++)
140 ctx->priv->alg_priv->mmaps[i].id = vp8_mem_req_segs[i].id;
141
142 ctx->priv->alg_priv->mmaps[0] = *mmap;
143 ctx->priv->alg_priv->si.sz = sizeof(ctx->priv->alg_priv->si);
144 ctx->priv->init_flags = ctx->init_flags;
145
146 if (ctx->config.dec) {
147 /* Update the reference to the config structure to an internal copy. */
148 ctx->priv->alg_priv->cfg = *ctx->config.dec;
149 ctx->config.dec = &ctx->priv->alg_priv->cfg;
150 }
151 }
152
153 static void *mmap_lkup(vpx_codec_alg_priv_t *ctx, unsigned int id) {
154 int i;
155
156 for (i = 0; i < NELEMENTS(ctx->mmaps); i++)
157 if (ctx->mmaps[i].id == id)
158 return ctx->mmaps[i].base;
159
160 return NULL;
161 }
162 static void vp8_finalize_mmaps(vpx_codec_alg_priv_t *ctx) {
163 /* nothing to clean up */
164 }
165
166 static vpx_codec_err_t vp8_init(vpx_codec_ctx_t *ctx,
167 vpx_codec_priv_enc_mr_cfg_t *data) {
168 vpx_codec_err_t res = VPX_CODEC_OK;
169
170 /* This function only allocates space for the vpx_codec_alg_priv_t
171 * structure. More memory may be required at the time the stream
172 * information becomes known.
173 */
174 if (!ctx->priv) {
175 vpx_codec_mmap_t mmap;
176
177 mmap.id = vp8_mem_req_segs[0].id;
178 mmap.sz = sizeof(vpx_codec_alg_priv_t);
179 mmap.align = vp8_mem_req_segs[0].align;
180 mmap.flags = vp8_mem_req_segs[0].flags;
181
182 res = vp8_mmap_alloc(&mmap);
183
184 if (!res) {
185 vp8_init_ctx(ctx, &mmap);
186
187 ctx->priv->alg_priv->defer_alloc = 1;
188 /*post processing level initialized to do nothing */
189 }
190 }
191
192 return res;
193 }
194
195 static vpx_codec_err_t vp8_destroy(vpx_codec_alg_priv_t *ctx) {
196 int i;
197
198 vp9_remove_decompressor(ctx->pbi);
199
200 for (i = NELEMENTS(ctx->mmaps) - 1; i >= 0; i--) {
201 if (ctx->mmaps[i].dtor)
202 ctx->mmaps[i].dtor(&ctx->mmaps[i]);
203 }
204
205 return VPX_CODEC_OK;
206 }
207
208 static vpx_codec_err_t vp8_peek_si(const uint8_t *data,
209 unsigned int data_sz,
210 vpx_codec_stream_info_t *si) {
211 vpx_codec_err_t res = VPX_CODEC_OK;
212
213 if (data + data_sz <= data)
214 res = VPX_CODEC_INVALID_PARAM;
215 else {
216 /* Parse uncompresssed part of key frame header.
217 * 3 bytes:- including version, frame type and an offset
218 * 3 bytes:- sync code (0x9d, 0x01, 0x2a)
219 * 4 bytes:- including image width and height in the lowest 14 bits
220 * of each 2-byte value.
221 */
222 si->is_kf = 0;
223
224 if (data_sz >= 10 && !(data[0] & 0x01)) { /* I-Frame */
225 const uint8_t *c = data + 3;
226 si->is_kf = 1;
227
228 /* vet via sync code */
229 if (c[0] != 0x9d || c[1] != 0x01 || c[2] != 0x2a)
230 res = VPX_CODEC_UNSUP_BITSTREAM;
231
232 si->w = (c[3] | (c[4] << 8)) & 0x3fff;
233 si->h = (c[5] | (c[6] << 8)) & 0x3fff;
234
235 /*printf("w=%d, h=%d\n", si->w, si->h);*/
236 if (!(si->h | si->w))
237 res = VPX_CODEC_UNSUP_BITSTREAM;
238 } else
239 res = VPX_CODEC_UNSUP_BITSTREAM;
240 }
241
242 return res;
243
244 }
245
246 static vpx_codec_err_t vp8_get_si(vpx_codec_alg_priv_t *ctx,
247 vpx_codec_stream_info_t *si) {
248
249 unsigned int sz;
250
251 if (si->sz >= sizeof(vp8_stream_info_t))
252 sz = sizeof(vp8_stream_info_t);
253 else
254 sz = sizeof(vpx_codec_stream_info_t);
255
256 memcpy(si, &ctx->si, sz);
257 si->sz = sz;
258
259 return VPX_CODEC_OK;
260 }
261
262
263 static vpx_codec_err_t
264 update_error_state(vpx_codec_alg_priv_t *ctx,
265 const struct vpx_internal_error_info *error) {
266 vpx_codec_err_t res;
267
268 if ((res = error->error_code))
269 ctx->base.err_detail = error->has_detail
270 ? error->detail
271 : NULL;
272
273 return res;
274 }
275
276 static void yuvconfig2image(vpx_image_t *img,
277 const YV12_BUFFER_CONFIG *yv12,
278 void *user_priv) {
279 /** vpx_img_wrap() doesn't allow specifying independent strides for
280 * the Y, U, and V planes, nor other alignment adjustments that
281 * might be representable by a YV12_BUFFER_CONFIG, so we just
282 * initialize all the fields.*/
283 img->fmt = yv12->clrtype == REG_YUV ?
284 VPX_IMG_FMT_I420 : VPX_IMG_FMT_VPXI420;
285 img->w = yv12->y_stride;
286 img->h = (yv12->y_height + 2 * VP9BORDERINPIXELS + 15) & ~15;
287 img->d_w = yv12->y_width;
288 img->d_h = yv12->y_height;
289 img->x_chroma_shift = 1;
290 img->y_chroma_shift = 1;
291 img->planes[VPX_PLANE_Y] = yv12->y_buffer;
292 img->planes[VPX_PLANE_U] = yv12->u_buffer;
293 img->planes[VPX_PLANE_V] = yv12->v_buffer;
294 img->planes[VPX_PLANE_ALPHA] = NULL;
295 img->stride[VPX_PLANE_Y] = yv12->y_stride;
296 img->stride[VPX_PLANE_U] = yv12->uv_stride;
297 img->stride[VPX_PLANE_V] = yv12->uv_stride;
298 img->stride[VPX_PLANE_ALPHA] = yv12->y_stride;
299 img->bps = 12;
300 img->user_priv = user_priv;
301 img->img_data = yv12->buffer_alloc;
302 img->img_data_owner = 0;
303 img->self_allocd = 0;
304 }
305
306 static vpx_codec_err_t decode_one(vpx_codec_alg_priv_t *ctx,
307 const uint8_t **data,
308 unsigned int data_sz,
309 void *user_priv,
310 long deadline) {
311 vpx_codec_err_t res = VPX_CODEC_OK;
312
313 ctx->img_avail = 0;
314
315 /* Determine the stream parameters. Note that we rely on peek_si to
316 * validate that we have a buffer that does not wrap around the top
317 * of the heap.
318 */
319 if (!ctx->si.h)
320 res = ctx->base.iface->dec.peek_si(*data, data_sz, &ctx->si);
321
322
323 /* Perform deferred allocations, if required */
324 if (!res && ctx->defer_alloc) {
325 int i;
326
327 for (i = 1; !res && i < NELEMENTS(ctx->mmaps); i++) {
328 vpx_codec_dec_cfg_t cfg;
329
330 cfg.w = ctx->si.w;
331 cfg.h = ctx->si.h;
332 ctx->mmaps[i].id = vp8_mem_req_segs[i].id;
333 ctx->mmaps[i].sz = vp8_mem_req_segs[i].sz;
334 ctx->mmaps[i].align = vp8_mem_req_segs[i].align;
335 ctx->mmaps[i].flags = vp8_mem_req_segs[i].flags;
336
337 if (!ctx->mmaps[i].sz)
338 ctx->mmaps[i].sz = vp8_mem_req_segs[i].calc_sz(&cfg,
339 ctx->base.init_flags);
340
341 res = vp8_mmap_alloc(&ctx->mmaps[i]);
342 }
343
344 if (!res)
345 vp8_finalize_mmaps(ctx);
346
347 ctx->defer_alloc = 0;
348 }
349
350 /* Initialize the decoder instance on the first frame*/
351 if (!res && !ctx->decoder_init) {
352 res = vp8_validate_mmaps(&ctx->si, ctx->mmaps, ctx->base.init_flags);
353
354 if (!res) {
355 VP9D_CONFIG oxcf;
356 VP9D_PTR optr;
357
358 vp9_initialize_dec();
359
360 oxcf.Width = ctx->si.w;
361 oxcf.Height = ctx->si.h;
362 oxcf.Version = 9;
363 oxcf.postprocess = 0;
364 oxcf.max_threads = ctx->cfg.threads;
365 optr = vp9_create_decompressor(&oxcf);
366
367 /* If postprocessing was enabled by the application and a
368 * configuration has not been provided, default it.
369 */
370 if (!ctx->postproc_cfg_set
371 && (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC)) {
372 ctx->postproc_cfg.post_proc_flag =
373 VP8_DEBLOCK | VP8_DEMACROBLOCK;
374 ctx->postproc_cfg.deblocking_level = 4;
375 ctx->postproc_cfg.noise_level = 0;
376 }
377
378 if (!optr)
379 res = VPX_CODEC_ERROR;
380 else
381 ctx->pbi = optr;
382 }
383
384 ctx->decoder_init = 1;
385 }
386
387 if (!res && ctx->pbi) {
388 YV12_BUFFER_CONFIG sd;
389 int64_t time_stamp = 0, time_end_stamp = 0;
390 vp9_ppflags_t flags = {0};
391
392 if (ctx->base.init_flags & VPX_CODEC_USE_POSTPROC) {
393 flags.post_proc_flag = ctx->postproc_cfg.post_proc_flag
394 #if CONFIG_POSTPROC_VISUALIZER
395
396 | ((ctx->dbg_color_ref_frame_flag != 0) ? VP9D_DEBU G_CLR_FRM_REF_BLKS : 0)
397 | ((ctx->dbg_color_mb_modes_flag != 0) ? VP9D_DEBUG _CLR_BLK_MODES : 0)
398 | ((ctx->dbg_color_b_modes_flag != 0) ? VP9D_DEBUG_ CLR_BLK_MODES : 0)
399 | ((ctx->dbg_display_mv_flag != 0) ? VP9D_DEBUG_DRA W_MV : 0)
400 #endif
401 ;
402 flags.deblocking_level = ctx->postproc_cfg.deblocking_level;
403 flags.noise_level = ctx->postproc_cfg.noise_level;
404 #if CONFIG_POSTPROC_VISUALIZER
405 flags.display_ref_frame_flag = ctx->dbg_color_ref_frame_flag;
406 flags.display_mb_modes_flag = ctx->dbg_color_mb_modes_flag;
407 flags.display_b_modes_flag = ctx->dbg_color_b_modes_flag;
408 flags.display_mv_flag = ctx->dbg_display_mv_flag;
409 #endif
410 }
411
412 if (vp9_receive_compressed_data(ctx->pbi, data_sz, data, deadline)) {
413 VP9D_COMP *pbi = (VP9D_COMP *)ctx->pbi;
414 res = update_error_state(ctx, &pbi->common.error);
415 }
416
417 if (!res && 0 == vp9_get_raw_frame(ctx->pbi, &sd, &time_stamp,
418 &time_end_stamp, &flags)) {
419 yuvconfig2image(&ctx->img, &sd, user_priv);
420 ctx->img_avail = 1;
421 }
422 }
423
424 return res;
425 }
426
427 static vpx_codec_err_t vp9_decode(vpx_codec_alg_priv_t *ctx,
428 const uint8_t *data,
429 unsigned int data_sz,
430 void *user_priv,
431 long deadline) {
432 const uint8_t *data_start = data;
433 const uint8_t *data_end = data + data_sz;
434 vpx_codec_err_t res;
435
436 do {
437 res = decode_one(ctx, &data_start, data_sz, user_priv, deadline);
438 assert(data_start >= data);
439 assert(data_start <= data_end);
440
441 /* Early exit if there was a decode error */
442 if (res)
443 break;
444
445 /* Account for suboptimal termination by the encoder. */
446 while (data_start < data_end && *data_start == 0)
447 data_start++;
448
449 data_sz = data_end - data_start;
450 } while (data_start < data_end);
451 return res;
452 }
453
454 static vpx_image_t *vp8_get_frame(vpx_codec_alg_priv_t *ctx,
455 vpx_codec_iter_t *iter) {
456 vpx_image_t *img = NULL;
457
458 if (ctx->img_avail) {
459 /* iter acts as a flip flop, so an image is only returned on the first
460 * call to get_frame.
461 */
462 if (!(*iter)) {
463 img = &ctx->img;
464 *iter = img;
465 }
466 }
467
468 return img;
469 }
470
471
472 static
473 vpx_codec_err_t vp8_xma_get_mmap(const vpx_codec_ctx_t *ctx,
474 vpx_codec_mmap_t *mmap,
475 vpx_codec_iter_t *iter) {
476 vpx_codec_err_t res;
477 const mem_req_t *seg_iter = *iter;
478
479 /* Get address of next segment request */
480 do {
481 if (!seg_iter)
482 seg_iter = vp8_mem_req_segs;
483 else if (seg_iter->id != VP8_SEG_MAX)
484 seg_iter++;
485
486 *iter = (vpx_codec_iter_t)seg_iter;
487
488 if (seg_iter->id != VP8_SEG_MAX) {
489 mmap->id = seg_iter->id;
490 mmap->sz = seg_iter->sz;
491 mmap->align = seg_iter->align;
492 mmap->flags = seg_iter->flags;
493
494 if (!seg_iter->sz)
495 mmap->sz = seg_iter->calc_sz(ctx->config.dec, ctx->init_flags);
496
497 res = VPX_CODEC_OK;
498 } else
499 res = VPX_CODEC_LIST_END;
500 } while (!mmap->sz && res != VPX_CODEC_LIST_END);
501
502 return res;
503 }
504
505 static vpx_codec_err_t vp8_xma_set_mmap(vpx_codec_ctx_t *ctx,
506 const vpx_codec_mmap_t *mmap) {
507 vpx_codec_err_t res = VPX_CODEC_MEM_ERROR;
508 int i, done;
509
510 if (!ctx->priv) {
511 if (mmap->id == VP8_SEG_ALG_PRIV) {
512 if (!ctx->priv) {
513 vp8_init_ctx(ctx, mmap);
514 res = VPX_CODEC_OK;
515 }
516 }
517 }
518
519 done = 1;
520
521 if (!res && ctx->priv->alg_priv) {
522 for (i = 0; i < NELEMENTS(ctx->priv->alg_priv->mmaps); i++) {
523 if (ctx->priv->alg_priv->mmaps[i].id == mmap->id)
524 if (!ctx->priv->alg_priv->mmaps[i].base) {
525 ctx->priv->alg_priv->mmaps[i] = *mmap;
526 res = VPX_CODEC_OK;
527 }
528
529 done &= (ctx->priv->alg_priv->mmaps[i].base != NULL);
530 }
531 }
532
533 if (done && !res) {
534 vp8_finalize_mmaps(ctx->priv->alg_priv);
535 res = ctx->iface->init(ctx, NULL);
536 }
537
538 return res;
539 }
540
541 static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img,
542 YV12_BUFFER_CONFIG *yv12) {
543 vpx_codec_err_t res = VPX_CODEC_OK;
544 yv12->y_buffer = img->planes[VPX_PLANE_Y];
545 yv12->u_buffer = img->planes[VPX_PLANE_U];
546 yv12->v_buffer = img->planes[VPX_PLANE_V];
547
548 yv12->y_width = img->d_w;
549 yv12->y_height = img->d_h;
550 yv12->uv_width = yv12->y_width / 2;
551 yv12->uv_height = yv12->y_height / 2;
552
553 yv12->y_stride = img->stride[VPX_PLANE_Y];
554 yv12->uv_stride = img->stride[VPX_PLANE_U];
555
556 yv12->border = (img->stride[VPX_PLANE_Y] - img->d_w) / 2;
557 yv12->clrtype = (img->fmt == VPX_IMG_FMT_VPXI420 ||
558 img->fmt == VPX_IMG_FMT_VPXYV12);
559
560 return res;
561 }
562
563
564 static vpx_codec_err_t vp9_set_reference(vpx_codec_alg_priv_t *ctx,
565 int ctr_id,
566 va_list args) {
567
568 vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *);
569
570 if (data) {
571 vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data;
572 YV12_BUFFER_CONFIG sd;
573
574 image2yuvconfig(&frame->img, &sd);
575
576 return vp9_set_reference_dec(ctx->pbi, frame->frame_type, &sd);
577 } else
578 return VPX_CODEC_INVALID_PARAM;
579
580 }
581
582 static vpx_codec_err_t vp9_get_reference(vpx_codec_alg_priv_t *ctx,
583 int ctr_id,
584 va_list args) {
585
586 vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *);
587
588 if (data) {
589 vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data;
590 YV12_BUFFER_CONFIG sd;
591
592 image2yuvconfig(&frame->img, &sd);
593
594 return vp9_get_reference_dec(ctx->pbi, frame->frame_type, &sd);
595 } else
596 return VPX_CODEC_INVALID_PARAM;
597
598 }
599
600 static vpx_codec_err_t vp8_set_postproc(vpx_codec_alg_priv_t *ctx,
601 int ctr_id,
602 va_list args) {
603 #if CONFIG_POSTPROC
604 vp8_postproc_cfg_t *data = va_arg(args, vp8_postproc_cfg_t *);
605
606 if (data) {
607 ctx->postproc_cfg_set = 1;
608 ctx->postproc_cfg = *((vp8_postproc_cfg_t *)data);
609 return VPX_CODEC_OK;
610 } else
611 return VPX_CODEC_INVALID_PARAM;
612
613 #else
614 return VPX_CODEC_INCAPABLE;
615 #endif
616 }
617
618 static vpx_codec_err_t vp8_set_dbg_options(vpx_codec_alg_priv_t *ctx,
619 int ctrl_id,
620 va_list args) {
621 #if CONFIG_POSTPROC_VISUALIZER && CONFIG_POSTPROC
622 int data = va_arg(args, int);
623
624 #define MAP(id, var) case id: var = data; break;
625
626 switch (ctrl_id) {
627 MAP(VP8_SET_DBG_COLOR_REF_FRAME, ctx->dbg_color_ref_frame_flag);
628 MAP(VP8_SET_DBG_COLOR_MB_MODES, ctx->dbg_color_mb_modes_flag);
629 MAP(VP8_SET_DBG_COLOR_B_MODES, ctx->dbg_color_b_modes_flag);
630 MAP(VP8_SET_DBG_DISPLAY_MV, ctx->dbg_display_mv_flag);
631 }
632
633 return VPX_CODEC_OK;
634 #else
635 return VPX_CODEC_INCAPABLE;
636 #endif
637 }
638
639 static vpx_codec_err_t vp8_get_last_ref_updates(vpx_codec_alg_priv_t *ctx,
640 int ctrl_id,
641 va_list args) {
642 int *update_info = va_arg(args, int *);
643 VP9D_COMP *pbi = (VP9D_COMP *)ctx->pbi;
644
645 if (update_info) {
646 *update_info = pbi->common.refresh_alt_ref_frame * (int) VP8_ALTR_FRAME
647 + pbi->common.refresh_golden_frame * (int) VP8_GOLD_FRAME
648 + pbi->common.refresh_last_frame * (int) VP8_LAST_FRAME;
649
650 return VPX_CODEC_OK;
651 } else
652 return VPX_CODEC_INVALID_PARAM;
653 }
654
655
656 static vpx_codec_err_t vp8_get_frame_corrupted(vpx_codec_alg_priv_t *ctx,
657 int ctrl_id,
658 va_list args) {
659
660 int *corrupted = va_arg(args, int *);
661
662 if (corrupted) {
663 VP9D_COMP *pbi = (VP9D_COMP *)ctx->pbi;
664 *corrupted = pbi->common.frame_to_show->corrupted;
665
666 return VPX_CODEC_OK;
667 } else
668 return VPX_CODEC_INVALID_PARAM;
669
670 }
671
672 static vpx_codec_ctrl_fn_map_t ctf_maps[] = {
673 {VP8_SET_REFERENCE, vp9_set_reference},
674 {VP8_COPY_REFERENCE, vp9_get_reference},
675 {VP8_SET_POSTPROC, vp8_set_postproc},
676 {VP8_SET_DBG_COLOR_REF_FRAME, vp8_set_dbg_options},
677 {VP8_SET_DBG_COLOR_MB_MODES, vp8_set_dbg_options},
678 {VP8_SET_DBG_COLOR_B_MODES, vp8_set_dbg_options},
679 {VP8_SET_DBG_DISPLAY_MV, vp8_set_dbg_options},
680 {VP8D_GET_LAST_REF_UPDATES, vp8_get_last_ref_updates},
681 {VP8D_GET_FRAME_CORRUPTED, vp8_get_frame_corrupted},
682 { -1, NULL},
683 };
684
685
686 #ifndef VERSION_STRING
687 #define VERSION_STRING
688 #endif
689 CODEC_INTERFACE(vpx_codec_vp9_dx) = {
690 "WebM Project VP9 Decoder" VERSION_STRING,
691 VPX_CODEC_INTERNAL_ABI_VERSION,
692 VPX_CODEC_CAP_DECODER | VP8_CAP_POSTPROC,
693 /* vpx_codec_caps_t caps; */
694 vp8_init, /* vpx_codec_init_fn_t init; */
695 vp8_destroy, /* vpx_codec_destroy_fn_t destroy; */
696 ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */
697 vp8_xma_get_mmap, /* vpx_codec_get_mmap_fn_t get_mmap; */
698 vp8_xma_set_mmap, /* vpx_codec_set_mmap_fn_t set_mmap; */
699 {
700 vp8_peek_si, /* vpx_codec_peek_si_fn_t peek_si; */
701 vp8_get_si, /* vpx_codec_get_si_fn_t get_si; */
702 vp9_decode, /* vpx_codec_decode_fn_t decode; */
703 vp8_get_frame, /* vpx_codec_frame_get_fn_t frame_get; */
704 },
705 {
706 /* encoder functions */
707 NOT_IMPLEMENTED,
708 NOT_IMPLEMENTED,
709 NOT_IMPLEMENTED,
710 NOT_IMPLEMENTED,
711 NOT_IMPLEMENTED,
712 NOT_IMPLEMENTED
713 }
714 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698