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

Side by Side Diff: source/libvpx/vp9/vp9_cx_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 "vpx/vpx_codec.h"
13 #include "vpx/internal/vpx_codec_internal.h"
14 #include "vpx_version.h"
15 #include "vp9/encoder/vp9_onyx_int.h"
16 #include "vpx/vp8cx.h"
17 #include "vp9/encoder/vp9_firstpass.h"
18 #include "vp9/common/vp9_onyx.h"
19 #include <stdlib.h>
20 #include <string.h>
21
22 struct vp8_extracfg {
23 struct vpx_codec_pkt_list *pkt_list;
24 int cpu_used; /** available cpu per centage in 1/16*/
25 unsigned int enable_auto_alt_ref; /** if encoder deci des to uses alternate reference frame */
26 unsigned int noise_sensitivity;
27 unsigned int Sharpness;
28 unsigned int static_thresh;
29 unsigned int token_partitions;
30 unsigned int arnr_max_frames; /* alt_ref Noise Reduction Max Frame Count */
31 unsigned int arnr_strength; /* alt_ref Noise Reduction Stren gth */
32 unsigned int arnr_type; /* alt_ref filter type */
33 unsigned int experimental;
34 vp8e_tuning tuning;
35 unsigned int cq_level; /* constrained quality level */
36 unsigned int rc_max_intra_bitrate_pct;
37 #if CONFIG_LOSSLESS
38 unsigned int lossless;
39 #endif
40 };
41
42 struct extraconfig_map {
43 int usage;
44 struct vp8_extracfg cfg;
45 };
46
47 static const struct extraconfig_map extracfg_map[] = {
48 {
49 0,
50 {
51 NULL,
52 0, /* cpu_used */
53 0, /* enable_auto_alt_ref */
54 0, /* noise_sensitivity */
55 0, /* Sharpness */
56 0, /* static_thresh */
57 VP8_ONE_TOKENPARTITION, /* token_partitions */
58 0, /* arnr_max_frames */
59 3, /* arnr_strength */
60 3, /* arnr_type*/
61 0, /* experimental mode */
62 0, /* tuning*/
63 10, /* cq_level */
64 0, /* rc_max_intra_bitrate_pct */
65 #if CONFIG_LOSSLESS
66 0, /* lossless */
67 #endif
68 }
69 }
70 };
71
72 struct vpx_codec_alg_priv {
73 vpx_codec_priv_t base;
74 vpx_codec_enc_cfg_t cfg;
75 struct vp8_extracfg vp8_cfg;
76 VP9_CONFIG oxcf;
77 VP9_PTR cpi;
78 unsigned char *cx_data;
79 unsigned int cx_data_sz;
80 unsigned char *pending_cx_data;
81 unsigned int pending_cx_data_sz;
82 vpx_image_t preview_img;
83 unsigned int next_frame_flag;
84 vp8_postproc_cfg_t preview_ppcfg;
85 vpx_codec_pkt_list_decl(64) pkt_list; // changed to accomendate t he maximum number of lagged frames allowed
86 unsigned int fixed_kf_cntr;
87 };
88
89
90 static vpx_codec_err_t
91 update_error_state(vpx_codec_alg_priv_t *ctx,
92 const struct vpx_internal_error_info *error) {
93 vpx_codec_err_t res;
94
95 if ((res = error->error_code))
96 ctx->base.err_detail = error->has_detail
97 ? error->detail
98 : NULL;
99
100 return res;
101 }
102
103
104 #undef ERROR
105 #define ERROR(str) do {\
106 ctx->base.err_detail = str;\
107 return VPX_CODEC_INVALID_PARAM;\
108 } while(0)
109
110 #define RANGE_CHECK(p,memb,lo,hi) do {\
111 if(!(((p)->memb == lo || (p)->memb > (lo)) && (p)->memb <= hi)) \
112 ERROR(#memb " out of range ["#lo".."#hi"]");\
113 } while(0)
114
115 #define RANGE_CHECK_HI(p,memb,hi) do {\
116 if(!((p)->memb <= (hi))) \
117 ERROR(#memb " out of range [.."#hi"]");\
118 } while(0)
119
120 #define RANGE_CHECK_LO(p,memb,lo) do {\
121 if(!((p)->memb >= (lo))) \
122 ERROR(#memb " out of range ["#lo"..]");\
123 } while(0)
124
125 #define RANGE_CHECK_BOOL(p,memb) do {\
126 if(!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean");\
127 } while(0)
128
129 static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,
130 const vpx_codec_enc_cfg_t *cfg,
131 const struct vp8_extracfg *vp8_cfg) {
132 RANGE_CHECK(cfg, g_w, 1, 16383); /* 14 bits available */
133 RANGE_CHECK(cfg, g_h, 1, 16383); /* 14 bits available */
134 RANGE_CHECK(cfg, g_timebase.den, 1, 1000000000);
135 RANGE_CHECK(cfg, g_timebase.num, 1, cfg->g_timebase.den);
136 RANGE_CHECK_HI(cfg, g_profile, 3);
137
138 RANGE_CHECK_HI(cfg, rc_max_quantizer, 63);
139 RANGE_CHECK_HI(cfg, rc_min_quantizer, cfg->rc_max_quantizer);
140 #if CONFIG_LOSSLESS
141 RANGE_CHECK_BOOL(vp8_cfg, lossless);
142 if (vp8_cfg->lossless) {
143 RANGE_CHECK_HI(cfg, rc_max_quantizer, 0);
144 RANGE_CHECK_HI(cfg, rc_min_quantizer, 0);
145 }
146 #endif
147
148 RANGE_CHECK_HI(cfg, g_threads, 64);
149 RANGE_CHECK_HI(cfg, g_lag_in_frames, MAX_LAG_BUFFERS);
150 RANGE_CHECK(cfg, rc_end_usage, VPX_VBR, VPX_CQ);
151 RANGE_CHECK_HI(cfg, rc_undershoot_pct, 1000);
152 RANGE_CHECK_HI(cfg, rc_overshoot_pct, 1000);
153 RANGE_CHECK_HI(cfg, rc_2pass_vbr_bias_pct, 100);
154 RANGE_CHECK(cfg, kf_mode, VPX_KF_DISABLED, VPX_KF_AUTO);
155 // RANGE_CHECK_BOOL(cfg, g_delete_firstpassfile);
156 RANGE_CHECK_BOOL(cfg, rc_resize_allowed);
157 RANGE_CHECK_HI(cfg, rc_dropframe_thresh, 100);
158 RANGE_CHECK_HI(cfg, rc_resize_up_thresh, 100);
159 RANGE_CHECK_HI(cfg, rc_resize_down_thresh, 100);
160 RANGE_CHECK(cfg, g_pass, VPX_RC_ONE_PASS, VPX_RC_LAST_PASS);
161
162 /* VP8 does not support a lower bound on the keyframe interval in
163 * automatic keyframe placement mode.
164 */
165 if (cfg->kf_mode != VPX_KF_DISABLED && cfg->kf_min_dist != cfg->kf_max_dist
166 && cfg->kf_min_dist > 0)
167 ERROR("kf_min_dist not supported in auto mode, use 0 "
168 "or kf_max_dist instead.");
169
170 RANGE_CHECK_BOOL(vp8_cfg, enable_auto_alt_ref);
171 RANGE_CHECK(vp8_cfg, cpu_used, -16, 16);
172
173 RANGE_CHECK_HI(vp8_cfg, noise_sensitivity, 6);
174
175 RANGE_CHECK(vp8_cfg, token_partitions, VP8_ONE_TOKENPARTITION, VP8_EIGHT_TOK ENPARTITION);
176 RANGE_CHECK_HI(vp8_cfg, Sharpness, 7);
177 RANGE_CHECK(vp8_cfg, arnr_max_frames, 0, 15);
178 RANGE_CHECK_HI(vp8_cfg, arnr_strength, 6);
179 RANGE_CHECK(vp8_cfg, arnr_type, 1, 3);
180 RANGE_CHECK(vp8_cfg, cq_level, 0, 63);
181
182 if (cfg->g_pass == VPX_RC_LAST_PASS) {
183 size_t packet_sz = sizeof(FIRSTPASS_STATS);
184 int n_packets = (int)(cfg->rc_twopass_stats_in.sz / packet_sz);
185 FIRSTPASS_STATS *stats;
186
187 if (!cfg->rc_twopass_stats_in.buf)
188 ERROR("rc_twopass_stats_in.buf not set.");
189
190 if (cfg->rc_twopass_stats_in.sz % packet_sz)
191 ERROR("rc_twopass_stats_in.sz indicates truncated packet.");
192
193 if (cfg->rc_twopass_stats_in.sz < 2 * packet_sz)
194 ERROR("rc_twopass_stats_in requires at least two packets.");
195
196 stats = (void *)((char *)cfg->rc_twopass_stats_in.buf
197 + (n_packets - 1) * packet_sz);
198
199 if ((int)(stats->count + 0.5) != n_packets - 1)
200 ERROR("rc_twopass_stats_in missing EOS stats packet");
201 }
202
203 return VPX_CODEC_OK;
204 }
205
206
207 static vpx_codec_err_t validate_img(vpx_codec_alg_priv_t *ctx,
208 const vpx_image_t *img) {
209 switch (img->fmt) {
210 case VPX_IMG_FMT_YV12:
211 case VPX_IMG_FMT_I420:
212 case VPX_IMG_FMT_VPXI420:
213 case VPX_IMG_FMT_VPXYV12:
214 break;
215 default:
216 ERROR("Invalid image format. Only YV12 and I420 images are supported");
217 }
218
219 if ((img->d_w != ctx->cfg.g_w) || (img->d_h != ctx->cfg.g_h))
220 ERROR("Image size must match encoder init configuration size");
221
222 return VPX_CODEC_OK;
223 }
224
225
226 static vpx_codec_err_t set_vp8e_config(VP9_CONFIG *oxcf,
227 vpx_codec_enc_cfg_t cfg,
228 struct vp8_extracfg vp8_cfg) {
229 oxcf->Version = cfg.g_profile;
230 oxcf->Version |= vp8_cfg.experimental ? 0x4 : 0;
231
232 oxcf->Width = cfg.g_w;
233 oxcf->Height = cfg.g_h;
234 /* guess a frame rate if out of whack, use 30 */
235 oxcf->frame_rate = (double)(cfg.g_timebase.den) / (double)(cfg.g_t imebase.num);
236
237 if (oxcf->frame_rate > 180) {
238 oxcf->frame_rate = 30;
239 }
240
241 switch (cfg.g_pass) {
242 case VPX_RC_ONE_PASS:
243 oxcf->Mode = MODE_BESTQUALITY;
244 break;
245 case VPX_RC_FIRST_PASS:
246 oxcf->Mode = MODE_FIRSTPASS;
247 break;
248 case VPX_RC_LAST_PASS:
249 oxcf->Mode = MODE_SECONDPASS_BEST;
250 break;
251 }
252
253 if (cfg.g_pass == VPX_RC_FIRST_PASS) {
254 oxcf->allow_lag = 0;
255 oxcf->lag_in_frames = 0;
256 } else {
257 oxcf->allow_lag = (cfg.g_lag_in_frames) > 0;
258 oxcf->lag_in_frames = cfg.g_lag_in_frames;
259 }
260
261 // VBR only supported for now.
262 // CBR code has been deprectated for experimental phase.
263 // CQ mode not yet tested
264 oxcf->end_usage = USAGE_LOCAL_FILE_PLAYBACK;
265 /*if (cfg.rc_end_usage == VPX_CQ)
266 oxcf->end_usage = USAGE_CONSTRAINED_QUALITY;
267 else
268 oxcf->end_usage = USAGE_LOCAL_FILE_PLAYBACK;*/
269
270 oxcf->target_bandwidth = cfg.rc_target_bitrate;
271 oxcf->rc_max_intra_bitrate_pct = vp8_cfg.rc_max_intra_bitrate_pct;
272
273 oxcf->best_allowed_q = cfg.rc_min_quantizer;
274 oxcf->worst_allowed_q = cfg.rc_max_quantizer;
275 oxcf->cq_level = vp8_cfg.cq_level;
276 oxcf->fixed_q = -1;
277
278 oxcf->under_shoot_pct = cfg.rc_undershoot_pct;
279 oxcf->over_shoot_pct = cfg.rc_overshoot_pct;
280
281 oxcf->maximum_buffer_size = cfg.rc_buf_sz;
282 oxcf->starting_buffer_level = cfg.rc_buf_initial_sz;
283 oxcf->optimal_buffer_level = cfg.rc_buf_optimal_sz;
284
285 oxcf->two_pass_vbrbias = cfg.rc_2pass_vbr_bias_pct;
286 oxcf->two_pass_vbrmin_section = cfg.rc_2pass_vbr_minsection_pct;
287 oxcf->two_pass_vbrmax_section = cfg.rc_2pass_vbr_maxsection_pct;
288
289 oxcf->auto_key = cfg.kf_mode == VPX_KF_AUTO
290 && cfg.kf_min_dist != cfg.kf_max_dist;
291 // oxcf->kf_min_dist = cfg.kf_min_dis;
292 oxcf->key_freq = cfg.kf_max_dist;
293
294 // oxcf->delete_first_pass_file = cfg.g_delete_firstpassfile;
295 // strcpy(oxcf->first_pass_file, cfg.g_firstpass_file);
296
297 oxcf->cpu_used = vp8_cfg.cpu_used;
298 oxcf->encode_breakout = vp8_cfg.static_thresh;
299 oxcf->play_alternate = vp8_cfg.enable_auto_alt_ref;
300 oxcf->noise_sensitivity = vp8_cfg.noise_sensitivity;
301 oxcf->Sharpness = vp8_cfg.Sharpness;
302
303 oxcf->two_pass_stats_in = cfg.rc_twopass_stats_in;
304 oxcf->output_pkt_list = vp8_cfg.pkt_list;
305
306 oxcf->arnr_max_frames = vp8_cfg.arnr_max_frames;
307 oxcf->arnr_strength = vp8_cfg.arnr_strength;
308 oxcf->arnr_type = vp8_cfg.arnr_type;
309
310 oxcf->tuning = vp8_cfg.tuning;
311
312 #if CONFIG_LOSSLESS
313 oxcf->lossless = vp8_cfg.lossless;
314 #endif
315
316 /*
317 printf("Current VP8 Settings: \n");
318 printf("target_bandwidth: %d\n", oxcf->target_bandwidth);
319 printf("noise_sensitivity: %d\n", oxcf->noise_sensitivity);
320 printf("Sharpness: %d\n", oxcf->Sharpness);
321 printf("cpu_used: %d\n", oxcf->cpu_used);
322 printf("Mode: %d\n", oxcf->Mode);
323 printf("delete_first_pass_file: %d\n", oxcf->delete_first_pass_file);
324 printf("auto_key: %d\n", oxcf->auto_key);
325 printf("key_freq: %d\n", oxcf->key_freq);
326 printf("end_usage: %d\n", oxcf->end_usage);
327 printf("under_shoot_pct: %d\n", oxcf->under_shoot_pct);
328 printf("over_shoot_pct: %d\n", oxcf->over_shoot_pct);
329 printf("starting_buffer_level: %d\n", oxcf->starting_buffer_level);
330 printf("optimal_buffer_level: %d\n", oxcf->optimal_buffer_level);
331 printf("maximum_buffer_size: %d\n", oxcf->maximum_buffer_size);
332 printf("fixed_q: %d\n", oxcf->fixed_q);
333 printf("worst_allowed_q: %d\n", oxcf->worst_allowed_q);
334 printf("best_allowed_q: %d\n", oxcf->best_allowed_q);
335 printf("two_pass_vbrbias: %d\n", oxcf->two_pass_vbrbias);
336 printf("two_pass_vbrmin_section: %d\n", oxcf->two_pass_vbrmin_section);
337 printf("two_pass_vbrmax_section: %d\n", oxcf->two_pass_vbrmax_section);
338 printf("allow_lag: %d\n", oxcf->allow_lag);
339 printf("lag_in_frames: %d\n", oxcf->lag_in_frames);
340 printf("play_alternate: %d\n", oxcf->play_alternate);
341 printf("Version: %d\n", oxcf->Version);
342 printf("encode_breakout: %d\n", oxcf->encode_breakout);
343 */
344 return VPX_CODEC_OK;
345 }
346
347 static vpx_codec_err_t vp8e_set_config(vpx_codec_alg_priv_t *ctx,
348 const vpx_codec_enc_cfg_t *cfg) {
349 vpx_codec_err_t res;
350
351 if ((cfg->g_w != ctx->cfg.g_w) || (cfg->g_h != ctx->cfg.g_h))
352 ERROR("Cannot change width or height after initialization");
353
354 /* Prevent increasing lag_in_frames. This check is stricter than it needs
355 * to be -- the limit is not increasing past the first lag_in_frames
356 * value, but we don't track the initial config, only the last successful
357 * config.
358 */
359 if ((cfg->g_lag_in_frames > ctx->cfg.g_lag_in_frames))
360 ERROR("Cannot increase lag_in_frames");
361
362 res = validate_config(ctx, cfg, &ctx->vp8_cfg);
363
364 if (!res) {
365 ctx->cfg = *cfg;
366 set_vp8e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg);
367 vp9_change_config(ctx->cpi, &ctx->oxcf);
368 }
369
370 return res;
371 }
372
373
374 int vp9_reverse_trans(int q);
375
376
377 static vpx_codec_err_t get_param(vpx_codec_alg_priv_t *ctx,
378 int ctrl_id,
379 va_list args) {
380 void *arg = va_arg(args, void *);
381
382 #define MAP(id, var) case id: *(RECAST(id, arg)) = var; break
383
384 if (!arg)
385 return VPX_CODEC_INVALID_PARAM;
386
387 switch (ctrl_id) {
388 MAP(VP8E_GET_LAST_QUANTIZER, vp9_get_quantizer(ctx->cpi));
389 MAP(VP8E_GET_LAST_QUANTIZER_64,
390 vp9_reverse_trans(vp9_get_quantizer(ctx->cpi)));
391 }
392
393 return VPX_CODEC_OK;
394 #undef MAP
395 }
396
397
398 static vpx_codec_err_t set_param(vpx_codec_alg_priv_t *ctx,
399 int ctrl_id,
400 va_list args) {
401 vpx_codec_err_t res = VPX_CODEC_OK;
402 struct vp8_extracfg xcfg = ctx->vp8_cfg;
403
404 #define MAP(id, var) case id: var = CAST(id, args); break;
405
406 switch (ctrl_id) {
407 MAP(VP8E_SET_CPUUSED, xcfg.cpu_used);
408 MAP(VP8E_SET_ENABLEAUTOALTREF, xcfg.enable_auto_alt_ref);
409 MAP(VP8E_SET_NOISE_SENSITIVITY, xcfg.noise_sensitivity);
410 MAP(VP8E_SET_SHARPNESS, xcfg.Sharpness);
411 MAP(VP8E_SET_STATIC_THRESHOLD, xcfg.static_thresh);
412 MAP(VP8E_SET_TOKEN_PARTITIONS, xcfg.token_partitions);
413
414 MAP(VP8E_SET_ARNR_MAXFRAMES, xcfg.arnr_max_frames);
415 MAP(VP8E_SET_ARNR_STRENGTH, xcfg.arnr_strength);
416 MAP(VP8E_SET_ARNR_TYPE, xcfg.arnr_type);
417 MAP(VP8E_SET_TUNING, xcfg.tuning);
418 MAP(VP8E_SET_CQ_LEVEL, xcfg.cq_level);
419 MAP(VP8E_SET_MAX_INTRA_BITRATE_PCT, xcfg.rc_max_intra_bitrate_pct);
420 #if CONFIG_LOSSLESS
421 MAP(VP9E_SET_LOSSLESS, xcfg.lossless);
422 #endif
423 }
424
425 res = validate_config(ctx, &ctx->cfg, &xcfg);
426
427 if (!res) {
428 ctx->vp8_cfg = xcfg;
429 set_vp8e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg);
430 vp9_change_config(ctx->cpi, &ctx->oxcf);
431 }
432
433 return res;
434 #undef MAP
435 }
436
437
438 static vpx_codec_err_t vp8e_common_init(vpx_codec_ctx_t *ctx,
439 int experimental) {
440 vpx_codec_err_t res = VPX_CODEC_OK;
441 struct vpx_codec_alg_priv *priv;
442 vpx_codec_enc_cfg_t *cfg;
443 unsigned int i;
444
445 VP9_PTR optr;
446
447 if (!ctx->priv) {
448 priv = calloc(1, sizeof(struct vpx_codec_alg_priv));
449
450 if (!priv) {
451 return VPX_CODEC_MEM_ERROR;
452 }
453
454 ctx->priv = &priv->base;
455 ctx->priv->sz = sizeof(*ctx->priv);
456 ctx->priv->iface = ctx->iface;
457 ctx->priv->alg_priv = priv;
458 ctx->priv->init_flags = ctx->init_flags;
459 ctx->priv->enc.total_encoders = 1;
460
461 if (ctx->config.enc) {
462 /* Update the reference to the config structure to an
463 * internal copy.
464 */
465 ctx->priv->alg_priv->cfg = *ctx->config.enc;
466 ctx->config.enc = &ctx->priv->alg_priv->cfg;
467 }
468
469 cfg = &ctx->priv->alg_priv->cfg;
470
471 /* Select the extra vp6 configuration table based on the current
472 * usage value. If the current usage value isn't found, use the
473 * values for usage case 0.
474 */
475 for (i = 0;
476 extracfg_map[i].usage && extracfg_map[i].usage != cfg->g_usage;
477 i++);
478
479 priv->vp8_cfg = extracfg_map[i].cfg;
480 priv->vp8_cfg.pkt_list = &priv->pkt_list.head;
481 priv->vp8_cfg.experimental = experimental;
482
483 priv->cx_data_sz = priv->cfg.g_w * priv->cfg.g_h * 3 / 2 * 2;
484
485 if (priv->cx_data_sz < 4096) priv->cx_data_sz = 4096;
486
487 priv->cx_data = malloc(priv->cx_data_sz);
488
489 if (!priv->cx_data) {
490 return VPX_CODEC_MEM_ERROR;
491 }
492
493 vp9_initialize_enc();
494
495 res = validate_config(priv, &priv->cfg, &priv->vp8_cfg);
496
497 if (!res) {
498 set_vp8e_config(&ctx->priv->alg_priv->oxcf,
499 ctx->priv->alg_priv->cfg,
500 ctx->priv->alg_priv->vp8_cfg);
501 optr = vp9_create_compressor(&ctx->priv->alg_priv->oxcf);
502
503 if (!optr)
504 res = VPX_CODEC_MEM_ERROR;
505 else
506 ctx->priv->alg_priv->cpi = optr;
507 }
508 }
509
510 return res;
511 }
512
513
514 static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx,
515 vpx_codec_priv_enc_mr_cfg_t *data) {
516 return vp8e_common_init(ctx, 0);
517 }
518
519
520 #if CONFIG_EXPERIMENTAL
521 static vpx_codec_err_t vp8e_exp_init(vpx_codec_ctx_t *ctx,
522 vpx_codec_priv_enc_mr_cfg_t *data) {
523 return vp8e_common_init(ctx, 1);
524 }
525 #endif
526
527
528 static vpx_codec_err_t vp8e_destroy(vpx_codec_alg_priv_t *ctx) {
529
530 free(ctx->cx_data);
531 vp9_remove_compressor(&ctx->cpi);
532 free(ctx);
533 return VPX_CODEC_OK;
534 }
535
536 static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img,
537 YV12_BUFFER_CONFIG *yv12) {
538 vpx_codec_err_t res = VPX_CODEC_OK;
539 yv12->y_buffer = img->planes[VPX_PLANE_Y];
540 yv12->u_buffer = img->planes[VPX_PLANE_U];
541 yv12->v_buffer = img->planes[VPX_PLANE_V];
542
543 yv12->y_width = img->d_w;
544 yv12->y_height = img->d_h;
545 yv12->uv_width = (1 + yv12->y_width) / 2;
546 yv12->uv_height = (1 + yv12->y_height) / 2;
547
548 yv12->y_stride = img->stride[VPX_PLANE_Y];
549 yv12->uv_stride = img->stride[VPX_PLANE_U];
550
551 yv12->border = (img->stride[VPX_PLANE_Y] - img->w) / 2;
552 yv12->clrtype = (img->fmt == VPX_IMG_FMT_VPXI420 || img->fmt == VPX_IMG_FMT_VP XYV12); // REG_YUV = 0
553 return res;
554 }
555
556 static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx,
557 unsigned long duration,
558 unsigned long deadline) {
559 unsigned int new_qc;
560
561 /* Use best quality mode if no deadline is given. */
562 if (deadline)
563 new_qc = MODE_GOODQUALITY;
564 else
565 new_qc = MODE_BESTQUALITY;
566
567 if (ctx->cfg.g_pass == VPX_RC_FIRST_PASS)
568 new_qc = MODE_FIRSTPASS;
569 else if (ctx->cfg.g_pass == VPX_RC_LAST_PASS)
570 new_qc = (new_qc == MODE_BESTQUALITY)
571 ? MODE_SECONDPASS_BEST
572 : MODE_SECONDPASS;
573
574 if (ctx->oxcf.Mode != new_qc) {
575 ctx->oxcf.Mode = new_qc;
576 vp9_change_config(ctx->cpi, &ctx->oxcf);
577 }
578 }
579
580
581 static vpx_codec_err_t vp8e_encode(vpx_codec_alg_priv_t *ctx,
582 const vpx_image_t *img,
583 vpx_codec_pts_t pts,
584 unsigned long duration,
585 vpx_enc_frame_flags_t flags,
586 unsigned long deadline) {
587 vpx_codec_err_t res = VPX_CODEC_OK;
588
589 if (img)
590 res = validate_img(ctx, img);
591
592 pick_quickcompress_mode(ctx, duration, deadline);
593 vpx_codec_pkt_list_init(&ctx->pkt_list);
594
595 /* Handle Flags */
596 if (((flags & VP8_EFLAG_NO_UPD_GF) && (flags & VP8_EFLAG_FORCE_GF))
597 || ((flags & VP8_EFLAG_NO_UPD_ARF) && (flags & VP8_EFLAG_FORCE_ARF))) {
598 ctx->base.err_detail = "Conflicting flags.";
599 return VPX_CODEC_INVALID_PARAM;
600 }
601
602 if (flags & (VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_GF
603 | VP8_EFLAG_NO_REF_ARF)) {
604 int ref = 7;
605
606 if (flags & VP8_EFLAG_NO_REF_LAST)
607 ref ^= VP9_LAST_FLAG;
608
609 if (flags & VP8_EFLAG_NO_REF_GF)
610 ref ^= VP9_GOLD_FLAG;
611
612 if (flags & VP8_EFLAG_NO_REF_ARF)
613 ref ^= VP9_ALT_FLAG;
614
615 vp9_use_as_reference(ctx->cpi, ref);
616 }
617
618 if (flags & (VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF
619 | VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_FORCE_GF
620 | VP8_EFLAG_FORCE_ARF)) {
621 int upd = 7;
622
623 if (flags & VP8_EFLAG_NO_UPD_LAST)
624 upd ^= VP9_LAST_FLAG;
625
626 if (flags & VP8_EFLAG_NO_UPD_GF)
627 upd ^= VP9_GOLD_FLAG;
628
629 if (flags & VP8_EFLAG_NO_UPD_ARF)
630 upd ^= VP9_ALT_FLAG;
631
632 vp9_update_reference(ctx->cpi, upd);
633 }
634
635 if (flags & VP8_EFLAG_NO_UPD_ENTROPY) {
636 vp9_update_entropy(ctx->cpi, 0);
637 }
638
639 /* Handle fixed keyframe intervals */
640 if (ctx->cfg.kf_mode == VPX_KF_AUTO
641 && ctx->cfg.kf_min_dist == ctx->cfg.kf_max_dist) {
642 if (++ctx->fixed_kf_cntr > ctx->cfg.kf_min_dist) {
643 flags |= VPX_EFLAG_FORCE_KF;
644 ctx->fixed_kf_cntr = 1;
645 }
646 }
647
648 /* Initialize the encoder instance on the first frame*/
649 if (!res && ctx->cpi) {
650 unsigned int lib_flags;
651 YV12_BUFFER_CONFIG sd;
652 int64_t dst_time_stamp, dst_end_time_stamp;
653 unsigned long size, cx_data_sz;
654 unsigned char *cx_data;
655
656 /* Set up internal flags */
657 if (ctx->base.init_flags & VPX_CODEC_USE_PSNR)
658 ((VP9_COMP *)ctx->cpi)->b_calculate_psnr = 1;
659
660 // if (ctx->base.init_flags & VPX_CODEC_USE_OUTPUT_PARTITION)
661 // ((VP9_COMP *)ctx->cpi)->output_partition = 1;
662
663 /* Convert API flags to internal codec lib flags */
664 lib_flags = (flags & VPX_EFLAG_FORCE_KF) ? FRAMEFLAGS_KEY : 0;
665
666 /* vp8 use 10,000,000 ticks/second as time stamp */
667 dst_time_stamp = pts * 10000000 * ctx->cfg.g_timebase.num / ctx->cfg.g_ti mebase.den;
668 dst_end_time_stamp = (pts + duration) * 10000000 * ctx->cfg.g_timebase.num / ctx->cfg.g_timebase.den;
669
670 if (img != NULL) {
671 res = image2yuvconfig(img, &sd);
672
673 if (vp9_receive_raw_frame(ctx->cpi, ctx->next_frame_flag | lib_flags,
674 &sd, dst_time_stamp, dst_end_time_stamp)) {
675 VP9_COMP *cpi = (VP9_COMP *)ctx->cpi;
676 res = update_error_state(ctx, &cpi->common.error);
677 }
678
679 /* reset for next frame */
680 ctx->next_frame_flag = 0;
681 }
682
683 cx_data = ctx->cx_data;
684 cx_data_sz = ctx->cx_data_sz;
685 lib_flags = 0;
686
687 /* Any pending invisible frames? */
688 if (ctx->pending_cx_data) {
689 memmove(cx_data, ctx->pending_cx_data, ctx->pending_cx_data_sz);
690 ctx->pending_cx_data = cx_data;
691 cx_data += ctx->pending_cx_data_sz;
692 cx_data_sz -= ctx->pending_cx_data_sz;
693
694 /* TODO: this is a minimal check, the underlying codec doesn't respect
695 * the buffer size anyway.
696 */
697 if (cx_data_sz < ctx->cx_data_sz / 2) {
698 ctx->base.err_detail = "Compressed data buffer too small";
699 return VPX_CODEC_ERROR;
700 }
701 }
702
703 while (cx_data_sz >= ctx->cx_data_sz / 2 &&
704 -1 != vp9_get_compressed_data(ctx->cpi, &lib_flags, &size,
705 cx_data, &dst_time_stamp,
706 &dst_end_time_stamp, !img)) {
707 if (size) {
708 vpx_codec_pts_t round, delta;
709 vpx_codec_cx_pkt_t pkt;
710 VP9_COMP *cpi = (VP9_COMP *)ctx->cpi;
711
712 /* Pack invisible frames with the next visisble frame */
713 if (!cpi->common.show_frame) {
714 if (!ctx->pending_cx_data)
715 ctx->pending_cx_data = cx_data;
716 ctx->pending_cx_data_sz += size;
717 cx_data += size;
718 cx_data_sz -= size;
719 continue;
720 }
721
722 /* Add the frame packet to the list of returned packets. */
723 round = 1000000 * ctx->cfg.g_timebase.num / 2 - 1;
724 delta = (dst_end_time_stamp - dst_time_stamp);
725 pkt.kind = VPX_CODEC_CX_FRAME_PKT;
726 pkt.data.frame.pts =
727 (dst_time_stamp * ctx->cfg.g_timebase.den + round)
728 / ctx->cfg.g_timebase.num / 10000000;
729 pkt.data.frame.duration = (unsigned long)
730 ((delta * ctx->cfg.g_timebase.den + round)
731 / ctx->cfg.g_timebase.num / 10000000);
732 pkt.data.frame.flags = lib_flags << 16;
733
734 if (lib_flags & FRAMEFLAGS_KEY)
735 pkt.data.frame.flags |= VPX_FRAME_IS_KEY;
736
737 if (!cpi->common.show_frame) {
738 pkt.data.frame.flags |= VPX_FRAME_IS_INVISIBLE;
739
740 // This timestamp should be as close as possible to the
741 // prior PTS so that if a decoder uses pts to schedule when
742 // to do this, we start right after last frame was decoded.
743 // Invisible frames have no duration.
744 pkt.data.frame.pts = ((cpi->last_time_stamp_seen
745 * ctx->cfg.g_timebase.den + round)
746 / ctx->cfg.g_timebase.num / 10000000) + 1;
747 pkt.data.frame.duration = 0;
748 }
749
750 if (cpi->droppable)
751 pkt.data.frame.flags |= VPX_FRAME_IS_DROPPABLE;
752
753 /*if (cpi->output_partition)
754 {
755 int i;
756 const int num_partitions = 1;
757
758 pkt.data.frame.flags |= VPX_FRAME_IS_FRAGMENT;
759
760 for (i = 0; i < num_partitions; ++i)
761 {
762 pkt.data.frame.buf = cx_data;
763 pkt.data.frame.sz = cpi->partition_sz[i];
764 pkt.data.frame.partition_id = i;
765 // don't set the fragment bit for the last partition
766 if (i == (num_partitions - 1))
767 pkt.data.frame.flags &= ~VPX_FRAME_IS_FRAGMENT;
768 vpx_codec_pkt_list_add(&ctx->pkt_list.head, &pkt);
769 cx_data += cpi->partition_sz[i];
770 cx_data_sz -= cpi->partition_sz[i];
771 }
772 }
773 else*/
774 {
775 if (ctx->pending_cx_data) {
776 pkt.data.frame.buf = ctx->pending_cx_data;
777 pkt.data.frame.sz = ctx->pending_cx_data_sz + size;
778 ctx->pending_cx_data = NULL;
779 ctx->pending_cx_data_sz = 0;
780 } else {
781 pkt.data.frame.buf = cx_data;
782 pkt.data.frame.sz = size;
783 }
784 pkt.data.frame.partition_id = -1;
785 vpx_codec_pkt_list_add(&ctx->pkt_list.head, &pkt);
786 cx_data += size;
787 cx_data_sz -= size;
788 }
789
790 // printf("timestamp: %lld, duration: %d\n", pkt->data.frame.pts, pkt->d ata.frame.duration);
791 }
792 }
793 }
794
795 return res;
796 }
797
798
799 static const vpx_codec_cx_pkt_t *vp8e_get_cxdata(vpx_codec_alg_priv_t *ctx,
800 vpx_codec_iter_t *iter) {
801 return vpx_codec_pkt_list_get(&ctx->pkt_list.head, iter);
802 }
803
804 static vpx_codec_err_t vp8e_set_reference(vpx_codec_alg_priv_t *ctx,
805 int ctr_id,
806 va_list args) {
807 vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *);
808
809 if (data) {
810 vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data;
811 YV12_BUFFER_CONFIG sd;
812
813 image2yuvconfig(&frame->img, &sd);
814 vp9_set_reference_enc(ctx->cpi, frame->frame_type, &sd);
815 return VPX_CODEC_OK;
816 } else
817 return VPX_CODEC_INVALID_PARAM;
818
819 }
820
821 static vpx_codec_err_t vp8e_get_reference(vpx_codec_alg_priv_t *ctx,
822 int ctr_id,
823 va_list args) {
824
825 vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *);
826
827 if (data) {
828 vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data;
829 YV12_BUFFER_CONFIG sd;
830
831 image2yuvconfig(&frame->img, &sd);
832 vp9_get_reference_enc(ctx->cpi, frame->frame_type, &sd);
833 return VPX_CODEC_OK;
834 } else
835 return VPX_CODEC_INVALID_PARAM;
836 }
837
838 static vpx_codec_err_t vp8e_set_previewpp(vpx_codec_alg_priv_t *ctx,
839 int ctr_id,
840 va_list args) {
841 #if CONFIG_POSTPROC
842 vp8_postproc_cfg_t *data = va_arg(args, vp8_postproc_cfg_t *);
843 (void)ctr_id;
844
845 if (data) {
846 ctx->preview_ppcfg = *((vp8_postproc_cfg_t *)data);
847 return VPX_CODEC_OK;
848 } else
849 return VPX_CODEC_INVALID_PARAM;
850 #else
851 (void)ctx;
852 (void)ctr_id;
853 (void)args;
854 return VPX_CODEC_INCAPABLE;
855 #endif
856 }
857
858
859 static vpx_image_t *vp8e_get_preview(vpx_codec_alg_priv_t *ctx) {
860
861 YV12_BUFFER_CONFIG sd;
862 vp9_ppflags_t flags = {0};
863
864 if (ctx->preview_ppcfg.post_proc_flag) {
865 flags.post_proc_flag = ctx->preview_ppcfg.post_proc_flag;
866 flags.deblocking_level = ctx->preview_ppcfg.deblocking_level;
867 flags.noise_level = ctx->preview_ppcfg.noise_level;
868 }
869
870 if (0 == vp9_get_preview_raw_frame(ctx->cpi, &sd, &flags)) {
871
872 /*
873 vpx_img_wrap(&ctx->preview_img, VPX_IMG_FMT_YV12,
874 sd.y_width + 2*VP9BORDERINPIXELS,
875 sd.y_height + 2*VP9BORDERINPIXELS,
876 1,
877 sd.buffer_alloc);
878 vpx_img_set_rect(&ctx->preview_img,
879 VP9BORDERINPIXELS, VP9BORDERINPIXELS,
880 sd.y_width, sd.y_height);
881 */
882
883 ctx->preview_img.bps = 12;
884 ctx->preview_img.planes[VPX_PLANE_Y] = sd.y_buffer;
885 ctx->preview_img.planes[VPX_PLANE_U] = sd.u_buffer;
886 ctx->preview_img.planes[VPX_PLANE_V] = sd.v_buffer;
887
888 if (sd.clrtype == REG_YUV)
889 ctx->preview_img.fmt = VPX_IMG_FMT_I420;
890 else
891 ctx->preview_img.fmt = VPX_IMG_FMT_VPXI420;
892
893 ctx->preview_img.x_chroma_shift = 1;
894 ctx->preview_img.y_chroma_shift = 1;
895
896 ctx->preview_img.d_w = sd.y_width;
897 ctx->preview_img.d_h = sd.y_height;
898 ctx->preview_img.stride[VPX_PLANE_Y] = sd.y_stride;
899 ctx->preview_img.stride[VPX_PLANE_U] = sd.uv_stride;
900 ctx->preview_img.stride[VPX_PLANE_V] = sd.uv_stride;
901 ctx->preview_img.w = sd.y_width;
902 ctx->preview_img.h = sd.y_height;
903
904 return &ctx->preview_img;
905 } else
906 return NULL;
907 }
908
909 static vpx_codec_err_t vp8e_update_entropy(vpx_codec_alg_priv_t *ctx,
910 int ctr_id,
911 va_list args) {
912 int update = va_arg(args, int);
913 vp9_update_entropy(ctx->cpi, update);
914 return VPX_CODEC_OK;
915
916 }
917
918 static vpx_codec_err_t vp8e_update_reference(vpx_codec_alg_priv_t *ctx,
919 int ctr_id,
920 va_list args) {
921 int update = va_arg(args, int);
922 vp9_update_reference(ctx->cpi, update);
923 return VPX_CODEC_OK;
924 }
925
926 static vpx_codec_err_t vp8e_use_reference(vpx_codec_alg_priv_t *ctx,
927 int ctr_id,
928 va_list args) {
929 int reference_flag = va_arg(args, int);
930 vp9_use_as_reference(ctx->cpi, reference_flag);
931 return VPX_CODEC_OK;
932 }
933
934 static vpx_codec_err_t vp8e_set_roi_map(vpx_codec_alg_priv_t *ctx,
935 int ctr_id,
936 va_list args) {
937 vpx_roi_map_t *data = va_arg(args, vpx_roi_map_t *);
938
939 if (data) {
940 vpx_roi_map_t *roi = (vpx_roi_map_t *)data;
941
942 if (!vp9_set_roimap(ctx->cpi, roi->roi_map, roi->rows, roi->cols,
943 roi->delta_q, roi->delta_lf, roi->static_threshold))
944 return VPX_CODEC_OK;
945 else
946 return VPX_CODEC_INVALID_PARAM;
947 } else
948 return VPX_CODEC_INVALID_PARAM;
949 }
950
951
952 static vpx_codec_err_t vp8e_set_activemap(vpx_codec_alg_priv_t *ctx,
953 int ctr_id,
954 va_list args) {
955 vpx_active_map_t *data = va_arg(args, vpx_active_map_t *);
956
957 if (data) {
958
959 vpx_active_map_t *map = (vpx_active_map_t *)data;
960
961 if (!vp9_set_active_map(ctx->cpi, map->active_map, map->rows, map->cols))
962 return VPX_CODEC_OK;
963 else
964 return VPX_CODEC_INVALID_PARAM;
965 } else
966 return VPX_CODEC_INVALID_PARAM;
967 }
968
969 static vpx_codec_err_t vp8e_set_scalemode(vpx_codec_alg_priv_t *ctx,
970 int ctr_id,
971 va_list args) {
972
973 vpx_scaling_mode_t *data = va_arg(args, vpx_scaling_mode_t *);
974
975 if (data) {
976 int res;
977 vpx_scaling_mode_t scalemode = *(vpx_scaling_mode_t *)data;
978 res = vp9_set_internal_size(ctx->cpi, scalemode.h_scaling_mode,
979 scalemode.v_scaling_mode);
980
981 if (!res) {
982 /*force next frame a key frame to effect scaling mode */
983 ctx->next_frame_flag |= FRAMEFLAGS_KEY;
984 return VPX_CODEC_OK;
985 } else
986 return VPX_CODEC_INVALID_PARAM;
987 } else
988 return VPX_CODEC_INVALID_PARAM;
989 }
990
991
992 static vpx_codec_ctrl_fn_map_t vp8e_ctf_maps[] = {
993 {VP8_SET_REFERENCE, vp8e_set_reference},
994 {VP8_COPY_REFERENCE, vp8e_get_reference},
995 {VP8_SET_POSTPROC, vp8e_set_previewpp},
996 {VP8E_UPD_ENTROPY, vp8e_update_entropy},
997 {VP8E_UPD_REFERENCE, vp8e_update_reference},
998 {VP8E_USE_REFERENCE, vp8e_use_reference},
999 {VP8E_SET_ROI_MAP, vp8e_set_roi_map},
1000 {VP8E_SET_ACTIVEMAP, vp8e_set_activemap},
1001 {VP8E_SET_SCALEMODE, vp8e_set_scalemode},
1002 {VP8E_SET_CPUUSED, set_param},
1003 {VP8E_SET_NOISE_SENSITIVITY, set_param},
1004 {VP8E_SET_ENABLEAUTOALTREF, set_param},
1005 {VP8E_SET_SHARPNESS, set_param},
1006 {VP8E_SET_STATIC_THRESHOLD, set_param},
1007 {VP8E_SET_TOKEN_PARTITIONS, set_param},
1008 {VP8E_GET_LAST_QUANTIZER, get_param},
1009 {VP8E_GET_LAST_QUANTIZER_64, get_param},
1010 {VP8E_SET_ARNR_MAXFRAMES, set_param},
1011 {VP8E_SET_ARNR_STRENGTH, set_param},
1012 {VP8E_SET_ARNR_TYPE, set_param},
1013 {VP8E_SET_TUNING, set_param},
1014 {VP8E_SET_CQ_LEVEL, set_param},
1015 {VP8E_SET_MAX_INTRA_BITRATE_PCT, set_param},
1016 #if CONFIG_LOSSLESS
1017 {VP9E_SET_LOSSLESS, set_param},
1018 #endif
1019 { -1, NULL},
1020 };
1021
1022 static vpx_codec_enc_cfg_map_t vp8e_usage_cfg_map[] = {
1023 {
1024 0,
1025 {
1026 0, /* g_usage */
1027 0, /* g_threads */
1028 0, /* g_profile */
1029
1030 320, /* g_width */
1031 240, /* g_height */
1032 {1, 30}, /* g_timebase */
1033
1034 0, /* g_error_resilient */
1035
1036 VPX_RC_ONE_PASS, /* g_pass */
1037
1038 0, /* g_lag_in_frames */
1039
1040 0, /* rc_dropframe_thresh */
1041 0, /* rc_resize_allowed */
1042 60, /* rc_resize_down_thresold */
1043 30, /* rc_resize_up_thresold */
1044
1045 VPX_VBR, /* rc_end_usage */
1046 #if VPX_ENCODER_ABI_VERSION > (1 + VPX_CODEC_ABI_VERSION)
1047 {0}, /* rc_twopass_stats_in */
1048 #endif
1049 256, /* rc_target_bandwidth */
1050 4, /* rc_min_quantizer */
1051 63, /* rc_max_quantizer */
1052 100, /* rc_undershoot_pct */
1053 100, /* rc_overshoot_pct */
1054
1055 6000, /* rc_max_buffer_size */
1056 4000, /* rc_buffer_initial_size; */
1057 5000, /* rc_buffer_optimal_size; */
1058
1059 50, /* rc_two_pass_vbrbias */
1060 0, /* rc_two_pass_vbrmin_section */
1061 400, /* rc_two_pass_vbrmax_section */
1062
1063 /* keyframing settings (kf) */
1064 VPX_KF_AUTO, /* g_kfmode*/
1065 0, /* kf_min_dist */
1066 9999, /* kf_max_dist */
1067
1068 #if VPX_ENCODER_ABI_VERSION == (1 + VPX_CODEC_ABI_VERSION)
1069 1, /* g_delete_first_pass_file */
1070 "vp8.fpf" /* first pass filename */
1071 #endif
1072 }
1073 },
1074 { -1, {NOT_IMPLEMENTED}}
1075 };
1076
1077
1078 #ifndef VERSION_STRING
1079 #define VERSION_STRING
1080 #endif
1081 CODEC_INTERFACE(vpx_codec_vp9_cx) = {
1082 "WebM Project VP9 Encoder" VERSION_STRING,
1083 VPX_CODEC_INTERNAL_ABI_VERSION,
1084 VPX_CODEC_CAP_ENCODER | VPX_CODEC_CAP_PSNR |
1085 VPX_CODEC_CAP_OUTPUT_PARTITION,
1086 /* vpx_codec_caps_t caps; */
1087 vp8e_init, /* vpx_codec_init_fn_t init; */
1088 vp8e_destroy, /* vpx_codec_destroy_fn_t destroy; */
1089 vp8e_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */
1090 NOT_IMPLEMENTED, /* vpx_codec_get_mmap_fn_t get_mmap; */
1091 NOT_IMPLEMENTED, /* vpx_codec_set_mmap_fn_t set_mmap; */
1092 {
1093 NOT_IMPLEMENTED, /* vpx_codec_peek_si_fn_t peek_si; */
1094 NOT_IMPLEMENTED, /* vpx_codec_get_si_fn_t get_si; */
1095 NOT_IMPLEMENTED, /* vpx_codec_decode_fn_t decode; */
1096 NOT_IMPLEMENTED, /* vpx_codec_frame_get_fn_t frame_get; */
1097 },
1098 {
1099 vp8e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */
1100 vp8e_encode, /* vpx_codec_encode_fn_t encode; */
1101 vp8e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */
1102 vp8e_set_config,
1103 NOT_IMPLEMENTED,
1104 vp8e_get_preview,
1105 } /* encoder functions */
1106 };
1107
1108
1109 #if CONFIG_EXPERIMENTAL
1110
1111 CODEC_INTERFACE(vpx_codec_vp9x_cx) = {
1112 "VP8 Experimental Encoder" VERSION_STRING,
1113 VPX_CODEC_INTERNAL_ABI_VERSION,
1114 VPX_CODEC_CAP_ENCODER | VPX_CODEC_CAP_PSNR,
1115 /* vpx_codec_caps_t caps; */
1116 vp8e_exp_init, /* vpx_codec_init_fn_t init; */
1117 vp8e_destroy, /* vpx_codec_destroy_fn_t destroy; */
1118 vp8e_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */
1119 NOT_IMPLEMENTED, /* vpx_codec_get_mmap_fn_t get_mmap; */
1120 NOT_IMPLEMENTED, /* vpx_codec_set_mmap_fn_t set_mmap; */
1121 {
1122 NOT_IMPLEMENTED, /* vpx_codec_peek_si_fn_t peek_si; */
1123 NOT_IMPLEMENTED, /* vpx_codec_get_si_fn_t get_si; */
1124 NOT_IMPLEMENTED, /* vpx_codec_decode_fn_t decode; */
1125 NOT_IMPLEMENTED, /* vpx_codec_frame_get_fn_t frame_get; */
1126 },
1127 {
1128 vp8e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */
1129 vp8e_encode, /* vpx_codec_encode_fn_t encode; */
1130 vp8e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */
1131 vp8e_set_config,
1132 NOT_IMPLEMENTED,
1133 vp8e_get_preview,
1134 } /* encoder functions */
1135 };
1136 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698