John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1 | /* |
John Koleszar | c2140b8 | 2010-09-09 08:16:39 -0400 | [diff] [blame] | 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 3 | * |
John Koleszar | 94c52e4 | 2010-06-18 12:39:21 -0400 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license |
John Koleszar | 09202d8 | 2010-06-04 16:19:40 -0400 | [diff] [blame] | 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 |
John Koleszar | 94c52e4 | 2010-06-18 12:39:21 -0400 | [diff] [blame] | 7 | * in the file PATENTS. All contributing project authors may |
John Koleszar | 09202d8 | 2010-06-04 16:19:40 -0400 | [diff] [blame] | 8 | * be found in the AUTHORS file in the root of the source tree. |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | |
John Koleszar | 8df79e9 | 2012-06-15 15:40:13 -0700 | [diff] [blame] | 12 | #include "vpx_rtcd.h" |
John Koleszar | b749234 | 2010-05-24 11:39:59 -0400 | [diff] [blame] | 13 | #include "vpx/vpx_codec.h" |
| 14 | #include "vpx/internal/vpx_codec_internal.h" |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 15 | #include "vpx_version.h" |
John Koleszar | 02321de | 2011-02-10 14:41:38 -0500 | [diff] [blame] | 16 | #include "vp8/encoder/onyx_int.h" |
John Koleszar | 2bf8fb5 | 2012-05-02 16:37:37 -0700 | [diff] [blame] | 17 | #include "vpx/vp8cx.h" |
John Koleszar | bb7dd5b | 2010-10-14 16:40:12 -0400 | [diff] [blame] | 18 | #include "vp8/encoder/firstpass.h" |
John Koleszar | 02321de | 2011-02-10 14:41:38 -0500 | [diff] [blame] | 19 | #include "vp8/common/onyx.h" |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 20 | #include <stdlib.h> |
| 21 | #include <string.h> |
| 22 | |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 23 | struct vp8_extracfg |
| 24 | { |
| 25 | struct vpx_codec_pkt_list *pkt_list; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 26 | int cpu_used; /** available cpu percentage in 1/16*/ |
| 27 | unsigned int enable_auto_alt_ref; /** if encoder decides to uses alternate reference frame */ |
| 28 | unsigned int noise_sensitivity; |
| 29 | unsigned int Sharpness; |
| 30 | unsigned int static_thresh; |
| 31 | unsigned int token_partitions; |
| 32 | unsigned int arnr_max_frames; /* alt_ref Noise Reduction Max Frame Count */ |
| 33 | unsigned int arnr_strength; /* alt_ref Noise Reduction Strength */ |
| 34 | unsigned int arnr_type; /* alt_ref filter type */ |
John Koleszar | b0da9b3 | 2010-12-17 09:43:39 -0500 | [diff] [blame] | 35 | vp8e_tuning tuning; |
Paul Wilkins | e0846c9 | 2011-01-07 18:29:37 +0000 | [diff] [blame] | 36 | unsigned int cq_level; /* constrained quality level */ |
John Koleszar | 1654ae9 | 2011-07-28 09:17:32 -0400 | [diff] [blame] | 37 | unsigned int rc_max_intra_bitrate_pct; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 38 | |
| 39 | }; |
| 40 | |
| 41 | struct extraconfig_map |
| 42 | { |
| 43 | int usage; |
| 44 | struct vp8_extracfg cfg; |
| 45 | }; |
| 46 | |
| 47 | static const struct extraconfig_map extracfg_map[] = |
| 48 | { |
| 49 | { |
| 50 | 0, |
| 51 | { |
| 52 | NULL, |
| 53 | #if !(CONFIG_REALTIME_ONLY) |
John Koleszar | 89c8b3d | 2010-06-14 10:22:55 -0400 | [diff] [blame] | 54 | 0, /* cpu_used */ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 55 | #else |
John Koleszar | 89c8b3d | 2010-06-14 10:22:55 -0400 | [diff] [blame] | 56 | 4, /* cpu_used */ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 57 | #endif |
| 58 | 0, /* enable_auto_alt_ref */ |
| 59 | 0, /* noise_sensitivity */ |
| 60 | 0, /* Sharpness */ |
John Koleszar | 89c8b3d | 2010-06-14 10:22:55 -0400 | [diff] [blame] | 61 | 0, /* static_thresh */ |
Attila Nagy | 52cf4dc | 2012-02-09 12:37:03 +0200 | [diff] [blame] | 62 | #if (CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING) |
| 63 | VP8_EIGHT_TOKENPARTITION, |
| 64 | #else |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 65 | VP8_ONE_TOKENPARTITION, /* token_partitions */ |
Attila Nagy | 52cf4dc | 2012-02-09 12:37:03 +0200 | [diff] [blame] | 66 | #endif |
Adrian Grange | 8ee7284 | 2010-09-30 10:06:09 +0100 | [diff] [blame] | 67 | 0, /* arnr_max_frames */ |
| 68 | 3, /* arnr_strength */ |
| 69 | 3, /* arnr_type*/ |
John Koleszar | b0da9b3 | 2010-12-17 09:43:39 -0500 | [diff] [blame] | 70 | 0, /* tuning*/ |
Paul Wilkins | e0846c9 | 2011-01-07 18:29:37 +0000 | [diff] [blame] | 71 | 10, /* cq_level */ |
John Koleszar | 1654ae9 | 2011-07-28 09:17:32 -0400 | [diff] [blame] | 72 | 0, /* rc_max_intra_bitrate_pct */ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 73 | } |
| 74 | } |
| 75 | }; |
| 76 | |
| 77 | struct vpx_codec_alg_priv |
| 78 | { |
| 79 | vpx_codec_priv_t base; |
| 80 | vpx_codec_enc_cfg_t cfg; |
| 81 | struct vp8_extracfg vp8_cfg; |
| 82 | VP8_CONFIG oxcf; |
John Koleszar | b0056c3 | 2011-12-20 16:54:54 -0800 | [diff] [blame] | 83 | struct VP8_COMP *cpi; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 84 | unsigned char *cx_data; |
| 85 | unsigned int cx_data_sz; |
| 86 | vpx_image_t preview_img; |
| 87 | unsigned int next_frame_flag; |
| 88 | vp8_postproc_cfg_t preview_ppcfg; |
John Koleszar | 0164a1c | 2012-05-21 14:30:56 -0700 | [diff] [blame] | 89 | /* pkt_list size depends on the maximum number of lagged frames allowed. */ |
| 90 | vpx_codec_pkt_list_decl(64) pkt_list; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 91 | unsigned int fixed_kf_cntr; |
| 92 | }; |
| 93 | |
| 94 | |
| 95 | static vpx_codec_err_t |
| 96 | update_error_state(vpx_codec_alg_priv_t *ctx, |
| 97 | const struct vpx_internal_error_info *error) |
| 98 | { |
| 99 | vpx_codec_err_t res; |
| 100 | |
| 101 | if ((res = error->error_code)) |
| 102 | ctx->base.err_detail = error->has_detail |
| 103 | ? error->detail |
| 104 | : NULL; |
| 105 | |
| 106 | return res; |
| 107 | } |
| 108 | |
| 109 | |
John Koleszar | 79e2b1f | 2010-11-17 09:08:47 -0500 | [diff] [blame] | 110 | #undef ERROR |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 111 | #define ERROR(str) do {\ |
| 112 | ctx->base.err_detail = str;\ |
| 113 | return VPX_CODEC_INVALID_PARAM;\ |
| 114 | } while(0) |
| 115 | |
| 116 | #define RANGE_CHECK(p,memb,lo,hi) do {\ |
Guillermo Ballester Valor | 5a72620 | 2010-06-11 14:33:49 -0400 | [diff] [blame] | 117 | if(!(((p)->memb == lo || (p)->memb > (lo)) && (p)->memb <= hi)) \ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 118 | ERROR(#memb " out of range ["#lo".."#hi"]");\ |
| 119 | } while(0) |
| 120 | |
Guillermo Ballester Valor | 2369068 | 2010-06-11 14:33:49 -0400 | [diff] [blame] | 121 | #define RANGE_CHECK_HI(p,memb,hi) do {\ |
| 122 | if(!((p)->memb <= (hi))) \ |
| 123 | ERROR(#memb " out of range [.."#hi"]");\ |
| 124 | } while(0) |
| 125 | |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 126 | #define RANGE_CHECK_LO(p,memb,lo) do {\ |
| 127 | if(!((p)->memb >= (lo))) \ |
| 128 | ERROR(#memb " out of range ["#lo"..]");\ |
| 129 | } while(0) |
| 130 | |
| 131 | #define RANGE_CHECK_BOOL(p,memb) do {\ |
| 132 | if(!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean");\ |
| 133 | } while(0) |
| 134 | |
| 135 | static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, |
| 136 | const vpx_codec_enc_cfg_t *cfg, |
James Berry | c1c47e8 | 2011-12-07 15:48:00 -0500 | [diff] [blame] | 137 | const struct vp8_extracfg *vp8_cfg, |
| 138 | int finalize) |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 139 | { |
Attila Nagy | 1aadced | 2011-04-12 15:01:22 +0300 | [diff] [blame] | 140 | RANGE_CHECK(cfg, g_w, 1, 16383); /* 14 bits available */ |
| 141 | RANGE_CHECK(cfg, g_h, 1, 16383); /* 14 bits available */ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 142 | RANGE_CHECK(cfg, g_timebase.den, 1, 1000000000); |
| 143 | RANGE_CHECK(cfg, g_timebase.num, 1, cfg->g_timebase.den); |
Guillermo Ballester Valor | 2369068 | 2010-06-11 14:33:49 -0400 | [diff] [blame] | 144 | RANGE_CHECK_HI(cfg, g_profile, 3); |
Guillermo Ballester Valor | 2369068 | 2010-06-11 14:33:49 -0400 | [diff] [blame] | 145 | RANGE_CHECK_HI(cfg, rc_max_quantizer, 63); |
John Koleszar | 2d03f07 | 2011-01-28 11:56:18 -0500 | [diff] [blame] | 146 | RANGE_CHECK_HI(cfg, rc_min_quantizer, cfg->rc_max_quantizer); |
Guillermo Ballester Valor | 2369068 | 2010-06-11 14:33:49 -0400 | [diff] [blame] | 147 | RANGE_CHECK_HI(cfg, g_threads, 64); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 148 | #if !(CONFIG_REALTIME_ONLY) |
Guillermo Ballester Valor | 2369068 | 2010-06-11 14:33:49 -0400 | [diff] [blame] | 149 | RANGE_CHECK_HI(cfg, g_lag_in_frames, 25); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 150 | #else |
Guillermo Ballester Valor | 2369068 | 2010-06-11 14:33:49 -0400 | [diff] [blame] | 151 | RANGE_CHECK_HI(cfg, g_lag_in_frames, 0); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 152 | #endif |
Paul Wilkins | e0846c9 | 2011-01-07 18:29:37 +0000 | [diff] [blame] | 153 | RANGE_CHECK(cfg, rc_end_usage, VPX_VBR, VPX_CQ); |
John Koleszar | c99f9d7 | 2011-04-11 11:29:23 -0400 | [diff] [blame] | 154 | RANGE_CHECK_HI(cfg, rc_undershoot_pct, 1000); |
| 155 | RANGE_CHECK_HI(cfg, rc_overshoot_pct, 1000); |
Guillermo Ballester Valor | 2369068 | 2010-06-11 14:33:49 -0400 | [diff] [blame] | 156 | RANGE_CHECK_HI(cfg, rc_2pass_vbr_bias_pct, 100); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 157 | RANGE_CHECK(cfg, kf_mode, VPX_KF_DISABLED, VPX_KF_AUTO); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 158 | RANGE_CHECK_BOOL(cfg, rc_resize_allowed); |
Guillermo Ballester Valor | 2369068 | 2010-06-11 14:33:49 -0400 | [diff] [blame] | 159 | RANGE_CHECK_HI(cfg, rc_dropframe_thresh, 100); |
| 160 | RANGE_CHECK_HI(cfg, rc_resize_up_thresh, 100); |
| 161 | RANGE_CHECK_HI(cfg, rc_resize_down_thresh, 100); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 162 | #if !(CONFIG_REALTIME_ONLY) |
| 163 | RANGE_CHECK(cfg, g_pass, VPX_RC_ONE_PASS, VPX_RC_LAST_PASS); |
| 164 | #else |
| 165 | RANGE_CHECK(cfg, g_pass, VPX_RC_ONE_PASS, VPX_RC_ONE_PASS); |
| 166 | #endif |
| 167 | |
| 168 | /* VP8 does not support a lower bound on the keyframe interval in |
| 169 | * automatic keyframe placement mode. |
| 170 | */ |
| 171 | if (cfg->kf_mode != VPX_KF_DISABLED && cfg->kf_min_dist != cfg->kf_max_dist |
| 172 | && cfg->kf_min_dist > 0) |
| 173 | ERROR("kf_min_dist not supported in auto mode, use 0 " |
| 174 | "or kf_max_dist instead."); |
| 175 | |
| 176 | RANGE_CHECK_BOOL(vp8_cfg, enable_auto_alt_ref); |
Yunqing Wang | 4fd81a9 | 2011-04-11 15:55:04 -0400 | [diff] [blame] | 177 | RANGE_CHECK(vp8_cfg, cpu_used, -16, 16); |
John Koleszar | c8f4c18 | 2012-05-08 11:23:42 -0700 | [diff] [blame] | 178 | |
| 179 | #if CONFIG_REALTIME_ONLY && !CONFIG_TEMPORAL_DENOISING |
| 180 | RANGE_CHECK(vp8_cfg, noise_sensitivity, 0, 0); |
| 181 | #else |
| 182 | RANGE_CHECK_HI(vp8_cfg, noise_sensitivity, 6); |
Stefan Holmer | 9c41143 | 2012-03-06 10:48:18 +0100 | [diff] [blame] | 183 | #endif |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 184 | |
| 185 | RANGE_CHECK(vp8_cfg, token_partitions, VP8_ONE_TOKENPARTITION, VP8_EIGHT_TOKENPARTITION); |
Guillermo Ballester Valor | 2369068 | 2010-06-11 14:33:49 -0400 | [diff] [blame] | 186 | RANGE_CHECK_HI(vp8_cfg, Sharpness, 7); |
Adrian Grange | 8ee7284 | 2010-09-30 10:06:09 +0100 | [diff] [blame] | 187 | RANGE_CHECK(vp8_cfg, arnr_max_frames, 0, 15); |
Frank Galligan | 1554272 | 2010-10-04 21:12:22 -0400 | [diff] [blame] | 188 | RANGE_CHECK_HI(vp8_cfg, arnr_strength, 6); |
Adrian Grange | 8ee7284 | 2010-09-30 10:06:09 +0100 | [diff] [blame] | 189 | RANGE_CHECK(vp8_cfg, arnr_type, 1, 3); |
Paul Wilkins | e0846c9 | 2011-01-07 18:29:37 +0000 | [diff] [blame] | 190 | RANGE_CHECK(vp8_cfg, cq_level, 0, 63); |
James Berry | c1c47e8 | 2011-12-07 15:48:00 -0500 | [diff] [blame] | 191 | if(finalize && cfg->rc_end_usage == VPX_CQ) |
| 192 | RANGE_CHECK(vp8_cfg, cq_level, |
| 193 | cfg->rc_min_quantizer, cfg->rc_max_quantizer); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 194 | |
Attila Nagy | cb791aa | 2011-01-10 11:14:10 +0200 | [diff] [blame] | 195 | #if !(CONFIG_REALTIME_ONLY) |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 196 | if (cfg->g_pass == VPX_RC_LAST_PASS) |
| 197 | { |
Adrian Grange | ed40ff9 | 2011-03-10 11:32:48 -0800 | [diff] [blame] | 198 | size_t packet_sz = sizeof(FIRSTPASS_STATS); |
John Koleszar | bb7dd5b | 2010-10-14 16:40:12 -0400 | [diff] [blame] | 199 | int n_packets = cfg->rc_twopass_stats_in.sz / packet_sz; |
| 200 | FIRSTPASS_STATS *stats; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 201 | |
| 202 | if (!cfg->rc_twopass_stats_in.buf) |
| 203 | ERROR("rc_twopass_stats_in.buf not set."); |
| 204 | |
John Koleszar | bb7dd5b | 2010-10-14 16:40:12 -0400 | [diff] [blame] | 205 | if (cfg->rc_twopass_stats_in.sz % packet_sz) |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 206 | ERROR("rc_twopass_stats_in.sz indicates truncated packet."); |
| 207 | |
John Koleszar | bb7dd5b | 2010-10-14 16:40:12 -0400 | [diff] [blame] | 208 | if (cfg->rc_twopass_stats_in.sz < 2 * packet_sz) |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 209 | ERROR("rc_twopass_stats_in requires at least two packets."); |
| 210 | |
John Koleszar | bb7dd5b | 2010-10-14 16:40:12 -0400 | [diff] [blame] | 211 | stats = (void*)((char *)cfg->rc_twopass_stats_in.buf |
| 212 | + (n_packets - 1) * packet_sz); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 213 | |
John Koleszar | bb7dd5b | 2010-10-14 16:40:12 -0400 | [diff] [blame] | 214 | if ((int)(stats->count + 0.5) != n_packets - 1) |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 215 | ERROR("rc_twopass_stats_in missing EOS stats packet"); |
| 216 | } |
Attila Nagy | cb791aa | 2011-01-10 11:14:10 +0200 | [diff] [blame] | 217 | #endif |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 218 | |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 219 | RANGE_CHECK(cfg, ts_number_layers, 1, 5); |
| 220 | |
| 221 | if (cfg->ts_number_layers > 1) |
| 222 | { |
Scott Graham | 92963df | 2012-05-08 11:45:35 -0700 | [diff] [blame] | 223 | unsigned int i; |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 224 | RANGE_CHECK_HI(cfg, ts_periodicity, 16); |
| 225 | |
| 226 | for (i=1; i<cfg->ts_number_layers; i++) |
| 227 | if (cfg->ts_target_bitrate[i] <= cfg->ts_target_bitrate[i-1]) |
| 228 | ERROR("ts_target_bitrate entries are not strictly increasing"); |
| 229 | |
| 230 | RANGE_CHECK(cfg, ts_rate_decimator[cfg->ts_number_layers-1], 1, 1); |
| 231 | for (i=cfg->ts_number_layers-2; i>0; i--) |
| 232 | if (cfg->ts_rate_decimator[i-1] != 2*cfg->ts_rate_decimator[i]) |
| 233 | ERROR("ts_rate_decimator factors are not powers of 2"); |
| 234 | |
| 235 | RANGE_CHECK_HI(cfg, ts_layer_id[i], cfg->ts_number_layers-1); |
| 236 | } |
| 237 | |
Attila Nagy | 52cf4dc | 2012-02-09 12:37:03 +0200 | [diff] [blame] | 238 | #if (CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING) |
| 239 | if(cfg->g_threads > (1 << vp8_cfg->token_partitions)) |
| 240 | ERROR("g_threads cannot be bigger than number of token partitions"); |
| 241 | #endif |
| 242 | |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 243 | return VPX_CODEC_OK; |
| 244 | } |
| 245 | |
| 246 | |
| 247 | static vpx_codec_err_t validate_img(vpx_codec_alg_priv_t *ctx, |
| 248 | const vpx_image_t *img) |
| 249 | { |
| 250 | switch (img->fmt) |
| 251 | { |
James Zern | 6cd4a10 | 2010-05-20 23:22:39 -0400 | [diff] [blame] | 252 | case VPX_IMG_FMT_YV12: |
| 253 | case VPX_IMG_FMT_I420: |
| 254 | case VPX_IMG_FMT_VPXI420: |
| 255 | case VPX_IMG_FMT_VPXYV12: |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 256 | break; |
| 257 | default: |
| 258 | ERROR("Invalid image format. Only YV12 and I420 images are supported"); |
| 259 | } |
| 260 | |
| 261 | if ((img->d_w != ctx->cfg.g_w) || (img->d_h != ctx->cfg.g_h)) |
| 262 | ERROR("Image size must match encoder init configuration size"); |
| 263 | |
| 264 | return VPX_CODEC_OK; |
| 265 | } |
| 266 | |
| 267 | |
| 268 | static vpx_codec_err_t set_vp8e_config(VP8_CONFIG *oxcf, |
| 269 | vpx_codec_enc_cfg_t cfg, |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 270 | struct vp8_extracfg vp8_cfg, |
| 271 | vpx_codec_priv_enc_mr_cfg_t *mr_cfg) |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 272 | { |
| 273 | oxcf->multi_threaded = cfg.g_threads; |
| 274 | oxcf->Version = cfg.g_profile; |
| 275 | |
| 276 | oxcf->Width = cfg.g_w; |
| 277 | oxcf->Height = cfg.g_h; |
John Koleszar | bdd35c1 | 2011-11-11 10:47:20 -0800 | [diff] [blame] | 278 | oxcf->timebase = cfg.g_timebase; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 279 | |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 280 | oxcf->error_resilient_mode = cfg.g_error_resilient; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 281 | |
| 282 | switch (cfg.g_pass) |
| 283 | { |
| 284 | case VPX_RC_ONE_PASS: |
| 285 | oxcf->Mode = MODE_BESTQUALITY; |
| 286 | break; |
| 287 | case VPX_RC_FIRST_PASS: |
| 288 | oxcf->Mode = MODE_FIRSTPASS; |
| 289 | break; |
| 290 | case VPX_RC_LAST_PASS: |
| 291 | oxcf->Mode = MODE_SECONDPASS_BEST; |
| 292 | break; |
| 293 | } |
| 294 | |
James Zern | 7b0b6a2 | 2012-06-13 11:59:12 -0700 | [diff] [blame] | 295 | if (cfg.g_pass == VPX_RC_FIRST_PASS || cfg.g_pass == VPX_RC_ONE_PASS) |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 296 | { |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 297 | oxcf->allow_lag = 0; |
| 298 | oxcf->lag_in_frames = 0; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 299 | } |
| 300 | else |
| 301 | { |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 302 | oxcf->allow_lag = (cfg.g_lag_in_frames) > 0; |
| 303 | oxcf->lag_in_frames = cfg.g_lag_in_frames; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | oxcf->allow_df = (cfg.rc_dropframe_thresh > 0); |
| 307 | oxcf->drop_frames_water_mark = cfg.rc_dropframe_thresh; |
| 308 | |
| 309 | oxcf->allow_spatial_resampling = cfg.rc_resize_allowed; |
| 310 | oxcf->resample_up_water_mark = cfg.rc_resize_up_thresh; |
| 311 | oxcf->resample_down_water_mark = cfg.rc_resize_down_thresh; |
| 312 | |
| 313 | if (cfg.rc_end_usage == VPX_VBR) |
| 314 | { |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 315 | oxcf->end_usage = USAGE_LOCAL_FILE_PLAYBACK; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 316 | } |
| 317 | else if (cfg.rc_end_usage == VPX_CBR) |
| 318 | { |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 319 | oxcf->end_usage = USAGE_STREAM_FROM_SERVER; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 320 | } |
Paul Wilkins | e0846c9 | 2011-01-07 18:29:37 +0000 | [diff] [blame] | 321 | else if (cfg.rc_end_usage == VPX_CQ) |
| 322 | { |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 323 | oxcf->end_usage = USAGE_CONSTRAINED_QUALITY; |
Paul Wilkins | e0846c9 | 2011-01-07 18:29:37 +0000 | [diff] [blame] | 324 | } |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 325 | |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 326 | oxcf->target_bandwidth = cfg.rc_target_bitrate; |
John Koleszar | 1654ae9 | 2011-07-28 09:17:32 -0400 | [diff] [blame] | 327 | oxcf->rc_max_intra_bitrate_pct = vp8_cfg.rc_max_intra_bitrate_pct; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 328 | |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 329 | oxcf->best_allowed_q = cfg.rc_min_quantizer; |
| 330 | oxcf->worst_allowed_q = cfg.rc_max_quantizer; |
| 331 | oxcf->cq_level = vp8_cfg.cq_level; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 332 | oxcf->fixed_q = -1; |
| 333 | |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 334 | oxcf->under_shoot_pct = cfg.rc_undershoot_pct; |
| 335 | oxcf->over_shoot_pct = cfg.rc_overshoot_pct; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 336 | |
Adrian Grange | e479379 | 2012-01-13 14:09:40 -0800 | [diff] [blame] | 337 | oxcf->maximum_buffer_size_in_ms = cfg.rc_buf_sz; |
| 338 | oxcf->starting_buffer_level_in_ms = cfg.rc_buf_initial_sz; |
| 339 | oxcf->optimal_buffer_level_in_ms = cfg.rc_buf_optimal_sz; |
| 340 | |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 341 | oxcf->maximum_buffer_size = cfg.rc_buf_sz; |
| 342 | oxcf->starting_buffer_level = cfg.rc_buf_initial_sz; |
| 343 | oxcf->optimal_buffer_level = cfg.rc_buf_optimal_sz; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 344 | |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 345 | oxcf->two_pass_vbrbias = cfg.rc_2pass_vbr_bias_pct; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 346 | oxcf->two_pass_vbrmin_section = cfg.rc_2pass_vbr_minsection_pct; |
| 347 | oxcf->two_pass_vbrmax_section = cfg.rc_2pass_vbr_maxsection_pct; |
| 348 | |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 349 | oxcf->auto_key = cfg.kf_mode == VPX_KF_AUTO |
| 350 | && cfg.kf_min_dist != cfg.kf_max_dist; |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 351 | oxcf->key_freq = cfg.kf_max_dist; |
| 352 | |
| 353 | oxcf->number_of_layers = cfg.ts_number_layers; |
| 354 | oxcf->periodicity = cfg.ts_periodicity; |
| 355 | |
| 356 | if (oxcf->number_of_layers > 1) |
| 357 | { |
| 358 | memcpy (oxcf->target_bitrate, cfg.ts_target_bitrate, |
| 359 | sizeof(cfg.ts_target_bitrate)); |
| 360 | memcpy (oxcf->rate_decimator, cfg.ts_rate_decimator, |
| 361 | sizeof(cfg.ts_rate_decimator)); |
| 362 | memcpy (oxcf->layer_id, cfg.ts_layer_id, sizeof(cfg.ts_layer_id)); |
| 363 | } |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 364 | |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 365 | #if CONFIG_MULTI_RES_ENCODING |
Yunqing Wang | c647ec4 | 2011-12-16 16:50:29 -0500 | [diff] [blame] | 366 | /* When mr_cfg is NULL, oxcf->mr_total_resolutions and oxcf->mr_encoder_id |
| 367 | * are both memset to 0, which ensures the correct logic under this |
| 368 | * situation. |
| 369 | */ |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 370 | if(mr_cfg) |
| 371 | { |
| 372 | oxcf->mr_total_resolutions = mr_cfg->mr_total_resolutions; |
| 373 | oxcf->mr_encoder_id = mr_cfg->mr_encoder_id; |
| 374 | oxcf->mr_down_sampling_factor.num = mr_cfg->mr_down_sampling_factor.num; |
| 375 | oxcf->mr_down_sampling_factor.den = mr_cfg->mr_down_sampling_factor.den; |
| 376 | oxcf->mr_low_res_mode_info = mr_cfg->mr_low_res_mode_info; |
| 377 | } |
| 378 | #endif |
| 379 | |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 380 | oxcf->cpu_used = vp8_cfg.cpu_used; |
| 381 | oxcf->encode_breakout = vp8_cfg.static_thresh; |
| 382 | oxcf->play_alternate = vp8_cfg.enable_auto_alt_ref; |
| 383 | oxcf->noise_sensitivity = vp8_cfg.noise_sensitivity; |
| 384 | oxcf->Sharpness = vp8_cfg.Sharpness; |
| 385 | oxcf->token_partitions = vp8_cfg.token_partitions; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 386 | |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 387 | oxcf->two_pass_stats_in = cfg.rc_twopass_stats_in; |
| 388 | oxcf->output_pkt_list = vp8_cfg.pkt_list; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 389 | |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 390 | oxcf->arnr_max_frames = vp8_cfg.arnr_max_frames; |
| 391 | oxcf->arnr_strength = vp8_cfg.arnr_strength; |
| 392 | oxcf->arnr_type = vp8_cfg.arnr_type; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 393 | |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 394 | oxcf->tuning = vp8_cfg.tuning; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 395 | |
| 396 | /* |
| 397 | printf("Current VP8 Settings: \n"); |
| 398 | printf("target_bandwidth: %d\n", oxcf->target_bandwidth); |
| 399 | printf("noise_sensitivity: %d\n", oxcf->noise_sensitivity); |
| 400 | printf("Sharpness: %d\n", oxcf->Sharpness); |
| 401 | printf("cpu_used: %d\n", oxcf->cpu_used); |
| 402 | printf("Mode: %d\n", oxcf->Mode); |
| 403 | printf("delete_first_pass_file: %d\n", oxcf->delete_first_pass_file); |
| 404 | printf("auto_key: %d\n", oxcf->auto_key); |
| 405 | printf("key_freq: %d\n", oxcf->key_freq); |
| 406 | printf("end_usage: %d\n", oxcf->end_usage); |
| 407 | printf("under_shoot_pct: %d\n", oxcf->under_shoot_pct); |
John Koleszar | c99f9d7 | 2011-04-11 11:29:23 -0400 | [diff] [blame] | 408 | printf("over_shoot_pct: %d\n", oxcf->over_shoot_pct); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 409 | printf("starting_buffer_level: %d\n", oxcf->starting_buffer_level); |
| 410 | printf("optimal_buffer_level: %d\n", oxcf->optimal_buffer_level); |
| 411 | printf("maximum_buffer_size: %d\n", oxcf->maximum_buffer_size); |
| 412 | printf("fixed_q: %d\n", oxcf->fixed_q); |
| 413 | printf("worst_allowed_q: %d\n", oxcf->worst_allowed_q); |
| 414 | printf("best_allowed_q: %d\n", oxcf->best_allowed_q); |
| 415 | printf("allow_spatial_resampling: %d\n", oxcf->allow_spatial_resampling); |
| 416 | printf("resample_down_water_mark: %d\n", oxcf->resample_down_water_mark); |
| 417 | printf("resample_up_water_mark: %d\n", oxcf->resample_up_water_mark); |
| 418 | printf("allow_df: %d\n", oxcf->allow_df); |
| 419 | printf("drop_frames_water_mark: %d\n", oxcf->drop_frames_water_mark); |
| 420 | printf("two_pass_vbrbias: %d\n", oxcf->two_pass_vbrbias); |
| 421 | printf("two_pass_vbrmin_section: %d\n", oxcf->two_pass_vbrmin_section); |
| 422 | printf("two_pass_vbrmax_section: %d\n", oxcf->two_pass_vbrmax_section); |
| 423 | printf("allow_lag: %d\n", oxcf->allow_lag); |
| 424 | printf("lag_in_frames: %d\n", oxcf->lag_in_frames); |
| 425 | printf("play_alternate: %d\n", oxcf->play_alternate); |
| 426 | printf("Version: %d\n", oxcf->Version); |
| 427 | printf("multi_threaded: %d\n", oxcf->multi_threaded); |
| 428 | printf("encode_breakout: %d\n", oxcf->encode_breakout); |
| 429 | */ |
| 430 | return VPX_CODEC_OK; |
| 431 | } |
| 432 | |
| 433 | static vpx_codec_err_t vp8e_set_config(vpx_codec_alg_priv_t *ctx, |
| 434 | const vpx_codec_enc_cfg_t *cfg) |
| 435 | { |
| 436 | vpx_codec_err_t res; |
| 437 | |
John Koleszar | 51acb01 | 2012-02-07 17:07:49 -0800 | [diff] [blame] | 438 | if (((cfg->g_w != ctx->cfg.g_w) || (cfg->g_h != ctx->cfg.g_h)) |
John Koleszar | 410ae57 | 2012-05-23 12:07:53 -0700 | [diff] [blame] | 439 | && (cfg->g_lag_in_frames > 1 || cfg->g_pass != VPX_RC_ONE_PASS)) |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 440 | ERROR("Cannot change width or height after initialization"); |
| 441 | |
| 442 | /* Prevent increasing lag_in_frames. This check is stricter than it needs |
| 443 | * to be -- the limit is not increasing past the first lag_in_frames |
| 444 | * value, but we don't track the initial config, only the last successful |
| 445 | * config. |
| 446 | */ |
| 447 | if ((cfg->g_lag_in_frames > ctx->cfg.g_lag_in_frames)) |
| 448 | ERROR("Cannot increase lag_in_frames"); |
| 449 | |
James Berry | c1c47e8 | 2011-12-07 15:48:00 -0500 | [diff] [blame] | 450 | res = validate_config(ctx, cfg, &ctx->vp8_cfg, 0); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 451 | |
| 452 | if (!res) |
| 453 | { |
| 454 | ctx->cfg = *cfg; |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 455 | set_vp8e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg, NULL); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 456 | vp8_change_config(ctx->cpi, &ctx->oxcf); |
| 457 | } |
| 458 | |
| 459 | return res; |
| 460 | } |
| 461 | |
| 462 | |
| 463 | int vp8_reverse_trans(int); |
| 464 | |
| 465 | |
| 466 | static vpx_codec_err_t get_param(vpx_codec_alg_priv_t *ctx, |
| 467 | int ctrl_id, |
| 468 | va_list args) |
| 469 | { |
| 470 | void *arg = va_arg(args, void *); |
| 471 | |
| 472 | #define MAP(id, var) case id: *(RECAST(id, arg)) = var; break |
| 473 | |
| 474 | if (!arg) |
| 475 | return VPX_CODEC_INVALID_PARAM; |
| 476 | |
| 477 | switch (ctrl_id) |
| 478 | { |
| 479 | MAP(VP8E_GET_LAST_QUANTIZER, vp8_get_quantizer(ctx->cpi)); |
| 480 | MAP(VP8E_GET_LAST_QUANTIZER_64, vp8_reverse_trans(vp8_get_quantizer(ctx->cpi))); |
| 481 | } |
| 482 | |
| 483 | return VPX_CODEC_OK; |
| 484 | #undef MAP |
| 485 | } |
| 486 | |
| 487 | |
| 488 | static vpx_codec_err_t set_param(vpx_codec_alg_priv_t *ctx, |
| 489 | int ctrl_id, |
| 490 | va_list args) |
| 491 | { |
| 492 | vpx_codec_err_t res = VPX_CODEC_OK; |
| 493 | struct vp8_extracfg xcfg = ctx->vp8_cfg; |
| 494 | |
| 495 | #define MAP(id, var) case id: var = CAST(id, args); break; |
| 496 | |
| 497 | switch (ctrl_id) |
| 498 | { |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 499 | MAP(VP8E_SET_CPUUSED, xcfg.cpu_used); |
| 500 | MAP(VP8E_SET_ENABLEAUTOALTREF, xcfg.enable_auto_alt_ref); |
| 501 | MAP(VP8E_SET_NOISE_SENSITIVITY, xcfg.noise_sensitivity); |
| 502 | MAP(VP8E_SET_SHARPNESS, xcfg.Sharpness); |
| 503 | MAP(VP8E_SET_STATIC_THRESHOLD, xcfg.static_thresh); |
| 504 | MAP(VP8E_SET_TOKEN_PARTITIONS, xcfg.token_partitions); |
| 505 | |
| 506 | MAP(VP8E_SET_ARNR_MAXFRAMES, xcfg.arnr_max_frames); |
| 507 | MAP(VP8E_SET_ARNR_STRENGTH , xcfg.arnr_strength); |
| 508 | MAP(VP8E_SET_ARNR_TYPE , xcfg.arnr_type); |
John Koleszar | b0da9b3 | 2010-12-17 09:43:39 -0500 | [diff] [blame] | 509 | MAP(VP8E_SET_TUNING, xcfg.tuning); |
Paul Wilkins | e0846c9 | 2011-01-07 18:29:37 +0000 | [diff] [blame] | 510 | MAP(VP8E_SET_CQ_LEVEL, xcfg.cq_level); |
John Koleszar | 1654ae9 | 2011-07-28 09:17:32 -0400 | [diff] [blame] | 511 | MAP(VP8E_SET_MAX_INTRA_BITRATE_PCT, xcfg.rc_max_intra_bitrate_pct); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 512 | |
| 513 | } |
| 514 | |
James Berry | c1c47e8 | 2011-12-07 15:48:00 -0500 | [diff] [blame] | 515 | res = validate_config(ctx, &ctx->cfg, &xcfg, 0); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 516 | |
| 517 | if (!res) |
| 518 | { |
| 519 | ctx->vp8_cfg = xcfg; |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 520 | set_vp8e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg, NULL); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 521 | vp8_change_config(ctx->cpi, &ctx->oxcf); |
| 522 | } |
| 523 | |
| 524 | return res; |
| 525 | #undef MAP |
| 526 | } |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 527 | |
| 528 | static vpx_codec_err_t vp8e_mr_alloc_mem(const vpx_codec_enc_cfg_t *cfg, |
| 529 | void **mem_loc) |
| 530 | { |
Yunqing Wang | ad479a9 | 2012-05-23 13:40:24 -0400 | [diff] [blame] | 531 | vpx_codec_err_t res = 0; |
| 532 | |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 533 | #if CONFIG_MULTI_RES_ENCODING |
Yunqing Wang | 65dd157 | 2012-05-16 15:06:42 -0400 | [diff] [blame] | 534 | LOWER_RES_FRAME_INFO *shared_mem_loc; |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 535 | int mb_rows = ((cfg->g_w + 15) >>4); |
| 536 | int mb_cols = ((cfg->g_h + 15) >>4); |
| 537 | |
Yunqing Wang | 65dd157 | 2012-05-16 15:06:42 -0400 | [diff] [blame] | 538 | shared_mem_loc = calloc(1, sizeof(LOWER_RES_FRAME_INFO)); |
| 539 | if(!shared_mem_loc) |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 540 | { |
Yunqing Wang | ad479a9 | 2012-05-23 13:40:24 -0400 | [diff] [blame] | 541 | res = VPX_CODEC_MEM_ERROR; |
Yunqing Wang | 65dd157 | 2012-05-16 15:06:42 -0400 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | shared_mem_loc->mb_info = calloc(mb_rows*mb_cols, sizeof(LOWER_RES_MB_INFO)); |
| 545 | if(!(shared_mem_loc->mb_info)) |
| 546 | { |
Yunqing Wang | ad479a9 | 2012-05-23 13:40:24 -0400 | [diff] [blame] | 547 | res = VPX_CODEC_MEM_ERROR; |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 548 | } |
| 549 | else |
Yunqing Wang | 65dd157 | 2012-05-16 15:06:42 -0400 | [diff] [blame] | 550 | { |
| 551 | *mem_loc = (void *)shared_mem_loc; |
Yunqing Wang | ad479a9 | 2012-05-23 13:40:24 -0400 | [diff] [blame] | 552 | res = VPX_CODEC_OK; |
Yunqing Wang | 65dd157 | 2012-05-16 15:06:42 -0400 | [diff] [blame] | 553 | } |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 554 | #endif |
Yunqing Wang | ad479a9 | 2012-05-23 13:40:24 -0400 | [diff] [blame] | 555 | return res; |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 556 | } |
| 557 | |
| 558 | static vpx_codec_err_t vp8e_init(vpx_codec_ctx_t *ctx, |
| 559 | vpx_codec_priv_enc_mr_cfg_t *mr_cfg) |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 560 | { |
John Koleszar | 2bf8fb5 | 2012-05-02 16:37:37 -0700 | [diff] [blame] | 561 | vpx_codec_err_t res = VPX_CODEC_OK; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 562 | struct vpx_codec_alg_priv *priv; |
| 563 | vpx_codec_enc_cfg_t *cfg; |
| 564 | unsigned int i; |
| 565 | |
John Koleszar | b0056c3 | 2011-12-20 16:54:54 -0800 | [diff] [blame] | 566 | struct VP8_COMP *optr; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 567 | |
John Koleszar | 8df79e9 | 2012-06-15 15:40:13 -0700 | [diff] [blame] | 568 | vpx_rtcd(); |
| 569 | |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 570 | if (!ctx->priv) |
| 571 | { |
| 572 | priv = calloc(1, sizeof(struct vpx_codec_alg_priv)); |
| 573 | |
Attila Nagy | e6db21e | 2011-02-22 15:02:05 +0200 | [diff] [blame] | 574 | if (!priv) |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 575 | { |
Attila Nagy | e6db21e | 2011-02-22 15:02:05 +0200 | [diff] [blame] | 576 | return VPX_CODEC_MEM_ERROR; |
| 577 | } |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 578 | |
Attila Nagy | e6db21e | 2011-02-22 15:02:05 +0200 | [diff] [blame] | 579 | ctx->priv = &priv->base; |
| 580 | ctx->priv->sz = sizeof(*ctx->priv); |
| 581 | ctx->priv->iface = ctx->iface; |
| 582 | ctx->priv->alg_priv = priv; |
| 583 | ctx->priv->init_flags = ctx->init_flags; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 584 | |
Attila Nagy | e6db21e | 2011-02-22 15:02:05 +0200 | [diff] [blame] | 585 | if (ctx->config.enc) |
| 586 | { |
| 587 | /* Update the reference to the config structure to an |
| 588 | * internal copy. |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 589 | */ |
Attila Nagy | e6db21e | 2011-02-22 15:02:05 +0200 | [diff] [blame] | 590 | ctx->priv->alg_priv->cfg = *ctx->config.enc; |
| 591 | ctx->config.enc = &ctx->priv->alg_priv->cfg; |
| 592 | } |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 593 | |
Attila Nagy | e6db21e | 2011-02-22 15:02:05 +0200 | [diff] [blame] | 594 | cfg = &ctx->priv->alg_priv->cfg; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 595 | |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 596 | /* Select the extra vp8 configuration table based on the current |
Attila Nagy | e6db21e | 2011-02-22 15:02:05 +0200 | [diff] [blame] | 597 | * usage value. If the current usage value isn't found, use the |
| 598 | * values for usage case 0. |
| 599 | */ |
| 600 | for (i = 0; |
| 601 | extracfg_map[i].usage && extracfg_map[i].usage != cfg->g_usage; |
| 602 | i++); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 603 | |
Attila Nagy | e6db21e | 2011-02-22 15:02:05 +0200 | [diff] [blame] | 604 | priv->vp8_cfg = extracfg_map[i].cfg; |
| 605 | priv->vp8_cfg.pkt_list = &priv->pkt_list.head; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 606 | |
Attila Nagy | e6db21e | 2011-02-22 15:02:05 +0200 | [diff] [blame] | 607 | priv->cx_data_sz = priv->cfg.g_w * priv->cfg.g_h * 3 / 2 * 2; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 608 | |
James Berry | bac6c22 | 2011-10-24 11:50:27 -0400 | [diff] [blame] | 609 | if (priv->cx_data_sz < 32768) priv->cx_data_sz = 32768; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 610 | |
Attila Nagy | e6db21e | 2011-02-22 15:02:05 +0200 | [diff] [blame] | 611 | priv->cx_data = malloc(priv->cx_data_sz); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 612 | |
Attila Nagy | e6db21e | 2011-02-22 15:02:05 +0200 | [diff] [blame] | 613 | if (!priv->cx_data) |
| 614 | { |
| 615 | return VPX_CODEC_MEM_ERROR; |
| 616 | } |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 617 | |
James Berry | c1c47e8 | 2011-12-07 15:48:00 -0500 | [diff] [blame] | 618 | res = validate_config(priv, &priv->cfg, &priv->vp8_cfg, 0); |
Attila Nagy | e6db21e | 2011-02-22 15:02:05 +0200 | [diff] [blame] | 619 | |
| 620 | if (!res) |
| 621 | { |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 622 | if(mr_cfg) |
| 623 | ctx->priv->enc.total_encoders = mr_cfg->mr_total_resolutions; |
| 624 | else |
| 625 | ctx->priv->enc.total_encoders = 1; |
| 626 | |
Attila Nagy | e6db21e | 2011-02-22 15:02:05 +0200 | [diff] [blame] | 627 | set_vp8e_config(&ctx->priv->alg_priv->oxcf, |
| 628 | ctx->priv->alg_priv->cfg, |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 629 | ctx->priv->alg_priv->vp8_cfg, |
| 630 | mr_cfg); |
| 631 | |
Attila Nagy | e6db21e | 2011-02-22 15:02:05 +0200 | [diff] [blame] | 632 | optr = vp8_create_compressor(&ctx->priv->alg_priv->oxcf); |
| 633 | |
| 634 | if (!optr) |
| 635 | res = VPX_CODEC_MEM_ERROR; |
| 636 | else |
| 637 | ctx->priv->alg_priv->cpi = optr; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 638 | } |
| 639 | } |
| 640 | |
| 641 | return res; |
| 642 | } |
| 643 | |
| 644 | static vpx_codec_err_t vp8e_destroy(vpx_codec_alg_priv_t *ctx) |
| 645 | { |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 646 | #if CONFIG_MULTI_RES_ENCODING |
| 647 | /* Free multi-encoder shared memory */ |
| 648 | if (ctx->oxcf.mr_total_resolutions > 0 && (ctx->oxcf.mr_encoder_id == ctx->oxcf.mr_total_resolutions-1)) |
Yunqing Wang | 65dd157 | 2012-05-16 15:06:42 -0400 | [diff] [blame] | 649 | { |
| 650 | LOWER_RES_FRAME_INFO *shared_mem_loc = (LOWER_RES_FRAME_INFO *)ctx->oxcf.mr_low_res_mode_info; |
| 651 | free(shared_mem_loc->mb_info); |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 652 | free(ctx->oxcf.mr_low_res_mode_info); |
Yunqing Wang | 65dd157 | 2012-05-16 15:06:42 -0400 | [diff] [blame] | 653 | } |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 654 | #endif |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 655 | |
| 656 | free(ctx->cx_data); |
| 657 | vp8_remove_compressor(&ctx->cpi); |
| 658 | free(ctx); |
| 659 | return VPX_CODEC_OK; |
| 660 | } |
| 661 | |
| 662 | static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img, |
| 663 | YV12_BUFFER_CONFIG *yv12) |
| 664 | { |
| 665 | vpx_codec_err_t res = VPX_CODEC_OK; |
John Koleszar | b6c7191 | 2010-05-24 21:45:05 -0400 | [diff] [blame] | 666 | yv12->y_buffer = img->planes[VPX_PLANE_Y]; |
| 667 | yv12->u_buffer = img->planes[VPX_PLANE_U]; |
| 668 | yv12->v_buffer = img->planes[VPX_PLANE_V]; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 669 | |
| 670 | yv12->y_width = img->d_w; |
| 671 | yv12->y_height = img->d_h; |
| 672 | yv12->uv_width = (1 + yv12->y_width) / 2; |
| 673 | yv12->uv_height = (1 + yv12->y_height) / 2; |
| 674 | |
John Koleszar | b6c7191 | 2010-05-24 21:45:05 -0400 | [diff] [blame] | 675 | yv12->y_stride = img->stride[VPX_PLANE_Y]; |
| 676 | yv12->uv_stride = img->stride[VPX_PLANE_U]; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 677 | |
John Koleszar | b6c7191 | 2010-05-24 21:45:05 -0400 | [diff] [blame] | 678 | yv12->border = (img->stride[VPX_PLANE_Y] - img->w) / 2; |
John Koleszar | 0164a1c | 2012-05-21 14:30:56 -0700 | [diff] [blame] | 679 | yv12->clrtype = (img->fmt == VPX_IMG_FMT_VPXI420 || img->fmt == VPX_IMG_FMT_VPXYV12); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 680 | return res; |
| 681 | } |
| 682 | |
| 683 | static void pick_quickcompress_mode(vpx_codec_alg_priv_t *ctx, |
| 684 | unsigned long duration, |
| 685 | unsigned long deadline) |
| 686 | { |
| 687 | unsigned int new_qc; |
| 688 | |
| 689 | #if !(CONFIG_REALTIME_ONLY) |
| 690 | /* Use best quality mode if no deadline is given. */ |
| 691 | new_qc = MODE_BESTQUALITY; |
| 692 | |
| 693 | if (deadline) |
| 694 | { |
| 695 | uint64_t duration_us; |
| 696 | |
| 697 | /* Convert duration parameter from stream timebase to microseconds */ |
| 698 | duration_us = (uint64_t)duration * 1000000 |
| 699 | * (uint64_t)ctx->cfg.g_timebase.num |
| 700 | / (uint64_t)ctx->cfg.g_timebase.den; |
| 701 | |
| 702 | /* If the deadline is more that the duration this frame is to be shown, |
| 703 | * use good quality mode. Otherwise use realtime mode. |
| 704 | */ |
| 705 | new_qc = (deadline > duration_us) ? MODE_GOODQUALITY : MODE_REALTIME; |
| 706 | } |
| 707 | |
| 708 | #else |
| 709 | new_qc = MODE_REALTIME; |
| 710 | #endif |
| 711 | |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 712 | if (ctx->cfg.g_pass == VPX_RC_FIRST_PASS) |
| 713 | new_qc = MODE_FIRSTPASS; |
| 714 | else if (ctx->cfg.g_pass == VPX_RC_LAST_PASS) |
| 715 | new_qc = (new_qc == MODE_BESTQUALITY) |
| 716 | ? MODE_SECONDPASS_BEST |
| 717 | : MODE_SECONDPASS; |
| 718 | |
| 719 | if (ctx->oxcf.Mode != new_qc) |
| 720 | { |
| 721 | ctx->oxcf.Mode = new_qc; |
| 722 | vp8_change_config(ctx->cpi, &ctx->oxcf); |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | |
| 727 | static vpx_codec_err_t vp8e_encode(vpx_codec_alg_priv_t *ctx, |
| 728 | const vpx_image_t *img, |
| 729 | vpx_codec_pts_t pts, |
| 730 | unsigned long duration, |
| 731 | vpx_enc_frame_flags_t flags, |
| 732 | unsigned long deadline) |
| 733 | { |
| 734 | vpx_codec_err_t res = VPX_CODEC_OK; |
| 735 | |
John Koleszar | 25a36d6 | 2012-04-19 10:00:33 -0700 | [diff] [blame] | 736 | if (!ctx->cfg.rc_target_bitrate) |
| 737 | return res; |
| 738 | |
John Koleszar | 44d35f7 | 2012-05-11 10:51:05 -0700 | [diff] [blame] | 739 | if (!ctx->cfg.rc_target_bitrate) |
| 740 | return res; |
| 741 | |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 742 | if (img) |
| 743 | res = validate_img(ctx, img); |
| 744 | |
James Berry | c1c47e8 | 2011-12-07 15:48:00 -0500 | [diff] [blame] | 745 | if (!res) |
| 746 | res = validate_config(ctx, &ctx->cfg, &ctx->vp8_cfg, 1); |
| 747 | |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 748 | pick_quickcompress_mode(ctx, duration, deadline); |
| 749 | vpx_codec_pkt_list_init(&ctx->pkt_list); |
| 750 | |
| 751 | /* Handle Flags */ |
| 752 | if (((flags & VP8_EFLAG_NO_UPD_GF) && (flags & VP8_EFLAG_FORCE_GF)) |
| 753 | || ((flags & VP8_EFLAG_NO_UPD_ARF) && (flags & VP8_EFLAG_FORCE_ARF))) |
| 754 | { |
| 755 | ctx->base.err_detail = "Conflicting flags."; |
| 756 | return VPX_CODEC_INVALID_PARAM; |
| 757 | } |
| 758 | |
| 759 | if (flags & (VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_GF |
| 760 | | VP8_EFLAG_NO_REF_ARF)) |
| 761 | { |
| 762 | int ref = 7; |
| 763 | |
| 764 | if (flags & VP8_EFLAG_NO_REF_LAST) |
Johann | 965d868 | 2012-05-23 16:08:37 -0700 | [diff] [blame] | 765 | ref ^= VP8_LAST_FRAME; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 766 | |
| 767 | if (flags & VP8_EFLAG_NO_REF_GF) |
Johann | 965d868 | 2012-05-23 16:08:37 -0700 | [diff] [blame] | 768 | ref ^= VP8_GOLD_FRAME; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 769 | |
| 770 | if (flags & VP8_EFLAG_NO_REF_ARF) |
Johann | 965d868 | 2012-05-23 16:08:37 -0700 | [diff] [blame] | 771 | ref ^= VP8_ALTR_FRAME; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 772 | |
| 773 | vp8_use_as_reference(ctx->cpi, ref); |
| 774 | } |
| 775 | |
| 776 | if (flags & (VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF |
| 777 | | VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_FORCE_GF |
| 778 | | VP8_EFLAG_FORCE_ARF)) |
| 779 | { |
| 780 | int upd = 7; |
| 781 | |
| 782 | if (flags & VP8_EFLAG_NO_UPD_LAST) |
Johann | 965d868 | 2012-05-23 16:08:37 -0700 | [diff] [blame] | 783 | upd ^= VP8_LAST_FRAME; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 784 | |
| 785 | if (flags & VP8_EFLAG_NO_UPD_GF) |
Johann | 965d868 | 2012-05-23 16:08:37 -0700 | [diff] [blame] | 786 | upd ^= VP8_GOLD_FRAME; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 787 | |
| 788 | if (flags & VP8_EFLAG_NO_UPD_ARF) |
Johann | 965d868 | 2012-05-23 16:08:37 -0700 | [diff] [blame] | 789 | upd ^= VP8_ALTR_FRAME; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 790 | |
| 791 | vp8_update_reference(ctx->cpi, upd); |
| 792 | } |
| 793 | |
| 794 | if (flags & VP8_EFLAG_NO_UPD_ENTROPY) |
| 795 | { |
| 796 | vp8_update_entropy(ctx->cpi, 0); |
| 797 | } |
| 798 | |
| 799 | /* Handle fixed keyframe intervals */ |
| 800 | if (ctx->cfg.kf_mode == VPX_KF_AUTO |
| 801 | && ctx->cfg.kf_min_dist == ctx->cfg.kf_max_dist) |
| 802 | { |
| 803 | if (++ctx->fixed_kf_cntr > ctx->cfg.kf_min_dist) |
| 804 | { |
| 805 | flags |= VPX_EFLAG_FORCE_KF; |
Andoni Morales Alastruey | 4814016 | 2011-02-07 18:04:02 +0100 | [diff] [blame] | 806 | ctx->fixed_kf_cntr = 1; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 807 | } |
| 808 | } |
| 809 | |
| 810 | /* Initialize the encoder instance on the first frame*/ |
| 811 | if (!res && ctx->cpi) |
| 812 | { |
| 813 | unsigned int lib_flags; |
| 814 | YV12_BUFFER_CONFIG sd; |
James Zern | b45065d | 2011-07-25 18:44:59 -0700 | [diff] [blame] | 815 | int64_t dst_time_stamp, dst_end_time_stamp; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 816 | unsigned long size, cx_data_sz; |
| 817 | unsigned char *cx_data; |
James Berry | bc71511 | 2011-10-12 11:18:50 -0400 | [diff] [blame] | 818 | unsigned char *cx_data_end; |
| 819 | int comp_data_state = 0; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 820 | |
| 821 | /* Set up internal flags */ |
| 822 | if (ctx->base.init_flags & VPX_CODEC_USE_PSNR) |
| 823 | ((VP8_COMP *)ctx->cpi)->b_calculate_psnr = 1; |
| 824 | |
Stefan Holmer | 7296b3f | 2011-06-13 16:42:27 +0200 | [diff] [blame] | 825 | if (ctx->base.init_flags & VPX_CODEC_USE_OUTPUT_PARTITION) |
| 826 | ((VP8_COMP *)ctx->cpi)->output_partition = 1; |
| 827 | |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 828 | /* Convert API flags to internal codec lib flags */ |
| 829 | lib_flags = (flags & VPX_EFLAG_FORCE_KF) ? FRAMEFLAGS_KEY : 0; |
| 830 | |
| 831 | /* vp8 use 10,000,000 ticks/second as time stamp */ |
| 832 | dst_time_stamp = pts * 10000000 * ctx->cfg.g_timebase.num / ctx->cfg.g_timebase.den; |
| 833 | dst_end_time_stamp = (pts + duration) * 10000000 * ctx->cfg.g_timebase.num / ctx->cfg.g_timebase.den; |
| 834 | |
| 835 | if (img != NULL) |
| 836 | { |
| 837 | res = image2yuvconfig(img, &sd); |
| 838 | |
| 839 | if (vp8_receive_raw_frame(ctx->cpi, ctx->next_frame_flag | lib_flags, |
| 840 | &sd, dst_time_stamp, dst_end_time_stamp)) |
| 841 | { |
| 842 | VP8_COMP *cpi = (VP8_COMP *)ctx->cpi; |
| 843 | res = update_error_state(ctx, &cpi->common.error); |
| 844 | } |
| 845 | |
| 846 | /* reset for next frame */ |
| 847 | ctx->next_frame_flag = 0; |
| 848 | } |
| 849 | |
| 850 | cx_data = ctx->cx_data; |
| 851 | cx_data_sz = ctx->cx_data_sz; |
James Berry | bc71511 | 2011-10-12 11:18:50 -0400 | [diff] [blame] | 852 | cx_data_end = ctx->cx_data + cx_data_sz; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 853 | lib_flags = 0; |
| 854 | |
James Berry | bc71511 | 2011-10-12 11:18:50 -0400 | [diff] [blame] | 855 | while (cx_data_sz >= ctx->cx_data_sz / 2) |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 856 | { |
James Berry | bc71511 | 2011-10-12 11:18:50 -0400 | [diff] [blame] | 857 | comp_data_state = vp8_get_compressed_data(ctx->cpi, |
| 858 | &lib_flags, |
| 859 | &size, |
| 860 | cx_data, |
| 861 | cx_data_end, |
| 862 | &dst_time_stamp, |
| 863 | &dst_end_time_stamp, |
| 864 | !img); |
| 865 | |
| 866 | if(comp_data_state == VPX_CODEC_CORRUPT_FRAME) |
| 867 | return VPX_CODEC_CORRUPT_FRAME; |
| 868 | else if(comp_data_state == -1) |
| 869 | break; |
| 870 | |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 871 | if (size) |
| 872 | { |
| 873 | vpx_codec_pts_t round, delta; |
| 874 | vpx_codec_cx_pkt_t pkt; |
| 875 | VP8_COMP *cpi = (VP8_COMP *)ctx->cpi; |
| 876 | |
| 877 | /* Add the frame packet to the list of returned packets. */ |
| 878 | round = 1000000 * ctx->cfg.g_timebase.num / 2 - 1; |
| 879 | delta = (dst_end_time_stamp - dst_time_stamp); |
| 880 | pkt.kind = VPX_CODEC_CX_FRAME_PKT; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 881 | pkt.data.frame.pts = |
| 882 | (dst_time_stamp * ctx->cfg.g_timebase.den + round) |
| 883 | / ctx->cfg.g_timebase.num / 10000000; |
| 884 | pkt.data.frame.duration = |
| 885 | (delta * ctx->cfg.g_timebase.den + round) |
| 886 | / ctx->cfg.g_timebase.num / 10000000; |
| 887 | pkt.data.frame.flags = lib_flags << 16; |
| 888 | |
| 889 | if (lib_flags & FRAMEFLAGS_KEY) |
| 890 | pkt.data.frame.flags |= VPX_FRAME_IS_KEY; |
| 891 | |
| 892 | if (!cpi->common.show_frame) |
| 893 | { |
| 894 | pkt.data.frame.flags |= VPX_FRAME_IS_INVISIBLE; |
| 895 | |
John Koleszar | 0164a1c | 2012-05-21 14:30:56 -0700 | [diff] [blame] | 896 | /* This timestamp should be as close as possible to the |
| 897 | * prior PTS so that if a decoder uses pts to schedule when |
| 898 | * to do this, we start right after last frame was decoded. |
| 899 | * Invisible frames have no duration. |
| 900 | */ |
Frank Galligan | 45e6494 | 2010-10-05 17:46:37 -0400 | [diff] [blame] | 901 | pkt.data.frame.pts = ((cpi->last_time_stamp_seen |
| 902 | * ctx->cfg.g_timebase.den + round) |
| 903 | / ctx->cfg.g_timebase.num / 10000000) + 1; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 904 | pkt.data.frame.duration = 0; |
| 905 | } |
| 906 | |
John Koleszar | 37de0b8 | 2011-07-07 10:38:23 -0400 | [diff] [blame] | 907 | if (cpi->droppable) |
| 908 | pkt.data.frame.flags |= VPX_FRAME_IS_DROPPABLE; |
| 909 | |
Stefan Holmer | 7296b3f | 2011-06-13 16:42:27 +0200 | [diff] [blame] | 910 | if (cpi->output_partition) |
| 911 | { |
| 912 | int i; |
| 913 | const int num_partitions = |
| 914 | (1 << cpi->common.multi_token_partition) + 1; |
Attila Nagy | 0afcc76 | 2011-07-20 14:09:42 +0300 | [diff] [blame] | 915 | |
| 916 | pkt.data.frame.flags |= VPX_FRAME_IS_FRAGMENT; |
| 917 | |
Stefan Holmer | 7296b3f | 2011-06-13 16:42:27 +0200 | [diff] [blame] | 918 | for (i = 0; i < num_partitions; ++i) |
| 919 | { |
Attila Nagy | 52cf4dc | 2012-02-09 12:37:03 +0200 | [diff] [blame] | 920 | #if CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING |
| 921 | pkt.data.frame.buf = cpi->partition_d[i]; |
| 922 | #else |
Stefan Holmer | 7296b3f | 2011-06-13 16:42:27 +0200 | [diff] [blame] | 923 | pkt.data.frame.buf = cx_data; |
Attila Nagy | 52cf4dc | 2012-02-09 12:37:03 +0200 | [diff] [blame] | 924 | cx_data += cpi->partition_sz[i]; |
| 925 | cx_data_sz -= cpi->partition_sz[i]; |
| 926 | #endif |
Stefan Holmer | 7296b3f | 2011-06-13 16:42:27 +0200 | [diff] [blame] | 927 | pkt.data.frame.sz = cpi->partition_sz[i]; |
| 928 | pkt.data.frame.partition_id = i; |
| 929 | /* don't set the fragment bit for the last partition */ |
Attila Nagy | 0afcc76 | 2011-07-20 14:09:42 +0300 | [diff] [blame] | 930 | if (i == (num_partitions - 1)) |
| 931 | pkt.data.frame.flags &= ~VPX_FRAME_IS_FRAGMENT; |
Stefan Holmer | 7296b3f | 2011-06-13 16:42:27 +0200 | [diff] [blame] | 932 | vpx_codec_pkt_list_add(&ctx->pkt_list.head, &pkt); |
Stefan Holmer | 7296b3f | 2011-06-13 16:42:27 +0200 | [diff] [blame] | 933 | } |
Attila Nagy | 52cf4dc | 2012-02-09 12:37:03 +0200 | [diff] [blame] | 934 | #if CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING |
| 935 | /* In lagged mode the encoder can buffer multiple frames. |
| 936 | * We don't want this in partitioned output because |
| 937 | * partitions are spread all over the output buffer. |
| 938 | * So, force an exit! |
| 939 | */ |
| 940 | cx_data_sz -= ctx->cx_data_sz / 2; |
| 941 | #endif |
Stefan Holmer | 7296b3f | 2011-06-13 16:42:27 +0200 | [diff] [blame] | 942 | } |
| 943 | else |
| 944 | { |
| 945 | pkt.data.frame.buf = cx_data; |
| 946 | pkt.data.frame.sz = size; |
| 947 | pkt.data.frame.partition_id = -1; |
| 948 | vpx_codec_pkt_list_add(&ctx->pkt_list.head, &pkt); |
| 949 | cx_data += size; |
| 950 | cx_data_sz -= size; |
| 951 | } |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 952 | } |
| 953 | } |
| 954 | } |
| 955 | |
| 956 | return res; |
| 957 | } |
| 958 | |
| 959 | |
| 960 | static const vpx_codec_cx_pkt_t *vp8e_get_cxdata(vpx_codec_alg_priv_t *ctx, |
| 961 | vpx_codec_iter_t *iter) |
| 962 | { |
| 963 | return vpx_codec_pkt_list_get(&ctx->pkt_list.head, iter); |
| 964 | } |
| 965 | |
| 966 | static vpx_codec_err_t vp8e_set_reference(vpx_codec_alg_priv_t *ctx, |
| 967 | int ctr_id, |
| 968 | va_list args) |
| 969 | { |
| 970 | vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *); |
| 971 | |
| 972 | if (data) |
| 973 | { |
| 974 | vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data; |
| 975 | YV12_BUFFER_CONFIG sd; |
| 976 | |
| 977 | image2yuvconfig(&frame->img, &sd); |
| 978 | vp8_set_reference(ctx->cpi, frame->frame_type, &sd); |
| 979 | return VPX_CODEC_OK; |
| 980 | } |
| 981 | else |
| 982 | return VPX_CODEC_INVALID_PARAM; |
| 983 | |
| 984 | } |
| 985 | |
| 986 | static vpx_codec_err_t vp8e_get_reference(vpx_codec_alg_priv_t *ctx, |
| 987 | int ctr_id, |
| 988 | va_list args) |
| 989 | { |
| 990 | |
| 991 | vpx_ref_frame_t *data = va_arg(args, vpx_ref_frame_t *); |
| 992 | |
| 993 | if (data) |
| 994 | { |
| 995 | vpx_ref_frame_t *frame = (vpx_ref_frame_t *)data; |
| 996 | YV12_BUFFER_CONFIG sd; |
| 997 | |
| 998 | image2yuvconfig(&frame->img, &sd); |
| 999 | vp8_get_reference(ctx->cpi, frame->frame_type, &sd); |
| 1000 | return VPX_CODEC_OK; |
| 1001 | } |
| 1002 | else |
| 1003 | return VPX_CODEC_INVALID_PARAM; |
| 1004 | } |
| 1005 | |
| 1006 | static vpx_codec_err_t vp8e_set_previewpp(vpx_codec_alg_priv_t *ctx, |
| 1007 | int ctr_id, |
| 1008 | va_list args) |
| 1009 | { |
James Zern | 76640f8 | 2010-08-20 16:06:56 -0400 | [diff] [blame] | 1010 | #if CONFIG_POSTPROC |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1011 | vp8_postproc_cfg_t *data = va_arg(args, vp8_postproc_cfg_t *); |
James Zern | 76640f8 | 2010-08-20 16:06:56 -0400 | [diff] [blame] | 1012 | (void)ctr_id; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1013 | |
| 1014 | if (data) |
| 1015 | { |
| 1016 | ctx->preview_ppcfg = *((vp8_postproc_cfg_t *)data); |
| 1017 | return VPX_CODEC_OK; |
| 1018 | } |
| 1019 | else |
| 1020 | return VPX_CODEC_INVALID_PARAM; |
James Zern | 76640f8 | 2010-08-20 16:06:56 -0400 | [diff] [blame] | 1021 | #else |
| 1022 | (void)ctx; |
| 1023 | (void)ctr_id; |
| 1024 | (void)args; |
| 1025 | return VPX_CODEC_INCAPABLE; |
| 1026 | #endif |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1027 | } |
| 1028 | |
| 1029 | |
| 1030 | static vpx_image_t *vp8e_get_preview(vpx_codec_alg_priv_t *ctx) |
| 1031 | { |
| 1032 | |
| 1033 | YV12_BUFFER_CONFIG sd; |
Fritz Koenig | 647df00 | 2010-11-04 16:03:36 -0700 | [diff] [blame] | 1034 | vp8_ppflags_t flags = {0}; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1035 | |
Fritz Koenig | 647df00 | 2010-11-04 16:03:36 -0700 | [diff] [blame] | 1036 | if (ctx->preview_ppcfg.post_proc_flag) |
| 1037 | { |
| 1038 | flags.post_proc_flag = ctx->preview_ppcfg.post_proc_flag; |
| 1039 | flags.deblocking_level = ctx->preview_ppcfg.deblocking_level; |
| 1040 | flags.noise_level = ctx->preview_ppcfg.noise_level; |
| 1041 | } |
| 1042 | |
| 1043 | if (0 == vp8_get_preview_raw_frame(ctx->cpi, &sd, &flags)) |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1044 | { |
| 1045 | |
| 1046 | /* |
James Zern | 6cd4a10 | 2010-05-20 23:22:39 -0400 | [diff] [blame] | 1047 | vpx_img_wrap(&ctx->preview_img, VPX_IMG_FMT_YV12, |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1048 | sd.y_width + 2*VP8BORDERINPIXELS, |
| 1049 | sd.y_height + 2*VP8BORDERINPIXELS, |
| 1050 | 1, |
| 1051 | sd.buffer_alloc); |
| 1052 | vpx_img_set_rect(&ctx->preview_img, |
| 1053 | VP8BORDERINPIXELS, VP8BORDERINPIXELS, |
| 1054 | sd.y_width, sd.y_height); |
| 1055 | */ |
| 1056 | |
| 1057 | ctx->preview_img.bps = 12; |
John Koleszar | b6c7191 | 2010-05-24 21:45:05 -0400 | [diff] [blame] | 1058 | ctx->preview_img.planes[VPX_PLANE_Y] = sd.y_buffer; |
| 1059 | ctx->preview_img.planes[VPX_PLANE_U] = sd.u_buffer; |
| 1060 | ctx->preview_img.planes[VPX_PLANE_V] = sd.v_buffer; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1061 | |
| 1062 | if (sd.clrtype == REG_YUV) |
James Zern | 6cd4a10 | 2010-05-20 23:22:39 -0400 | [diff] [blame] | 1063 | ctx->preview_img.fmt = VPX_IMG_FMT_I420; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1064 | else |
James Zern | 6cd4a10 | 2010-05-20 23:22:39 -0400 | [diff] [blame] | 1065 | ctx->preview_img.fmt = VPX_IMG_FMT_VPXI420; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1066 | |
| 1067 | ctx->preview_img.x_chroma_shift = 1; |
| 1068 | ctx->preview_img.y_chroma_shift = 1; |
| 1069 | |
James Berry | ddacf1c | 2011-02-08 14:23:18 -0500 | [diff] [blame] | 1070 | ctx->preview_img.d_w = sd.y_width; |
| 1071 | ctx->preview_img.d_h = sd.y_height; |
John Koleszar | b6c7191 | 2010-05-24 21:45:05 -0400 | [diff] [blame] | 1072 | ctx->preview_img.stride[VPX_PLANE_Y] = sd.y_stride; |
| 1073 | ctx->preview_img.stride[VPX_PLANE_U] = sd.uv_stride; |
| 1074 | ctx->preview_img.stride[VPX_PLANE_V] = sd.uv_stride; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1075 | ctx->preview_img.w = sd.y_width; |
| 1076 | ctx->preview_img.h = sd.y_height; |
| 1077 | |
| 1078 | return &ctx->preview_img; |
| 1079 | } |
| 1080 | else |
| 1081 | return NULL; |
| 1082 | } |
| 1083 | |
| 1084 | static vpx_codec_err_t vp8e_update_entropy(vpx_codec_alg_priv_t *ctx, |
| 1085 | int ctr_id, |
| 1086 | va_list args) |
| 1087 | { |
| 1088 | int update = va_arg(args, int); |
| 1089 | vp8_update_entropy(ctx->cpi, update); |
| 1090 | return VPX_CODEC_OK; |
| 1091 | |
| 1092 | } |
| 1093 | |
| 1094 | static vpx_codec_err_t vp8e_update_reference(vpx_codec_alg_priv_t *ctx, |
| 1095 | int ctr_id, |
| 1096 | va_list args) |
| 1097 | { |
| 1098 | int update = va_arg(args, int); |
| 1099 | vp8_update_reference(ctx->cpi, update); |
| 1100 | return VPX_CODEC_OK; |
| 1101 | } |
| 1102 | |
| 1103 | static vpx_codec_err_t vp8e_use_reference(vpx_codec_alg_priv_t *ctx, |
| 1104 | int ctr_id, |
| 1105 | va_list args) |
| 1106 | { |
| 1107 | int reference_flag = va_arg(args, int); |
| 1108 | vp8_use_as_reference(ctx->cpi, reference_flag); |
| 1109 | return VPX_CODEC_OK; |
| 1110 | } |
| 1111 | |
| 1112 | static vpx_codec_err_t vp8e_set_roi_map(vpx_codec_alg_priv_t *ctx, |
| 1113 | int ctr_id, |
| 1114 | va_list args) |
| 1115 | { |
| 1116 | vpx_roi_map_t *data = va_arg(args, vpx_roi_map_t *); |
| 1117 | |
| 1118 | if (data) |
| 1119 | { |
| 1120 | vpx_roi_map_t *roi = (vpx_roi_map_t *)data; |
| 1121 | |
| 1122 | if (!vp8_set_roimap(ctx->cpi, roi->roi_map, roi->rows, roi->cols, roi->delta_q, roi->delta_lf, roi->static_threshold)) |
| 1123 | return VPX_CODEC_OK; |
| 1124 | else |
| 1125 | return VPX_CODEC_INVALID_PARAM; |
| 1126 | } |
| 1127 | else |
| 1128 | return VPX_CODEC_INVALID_PARAM; |
| 1129 | } |
| 1130 | |
| 1131 | |
| 1132 | static vpx_codec_err_t vp8e_set_activemap(vpx_codec_alg_priv_t *ctx, |
| 1133 | int ctr_id, |
| 1134 | va_list args) |
| 1135 | { |
| 1136 | vpx_active_map_t *data = va_arg(args, vpx_active_map_t *); |
| 1137 | |
| 1138 | if (data) |
| 1139 | { |
| 1140 | |
| 1141 | vpx_active_map_t *map = (vpx_active_map_t *)data; |
| 1142 | |
| 1143 | if (!vp8_set_active_map(ctx->cpi, map->active_map, map->rows, map->cols)) |
| 1144 | return VPX_CODEC_OK; |
| 1145 | else |
| 1146 | return VPX_CODEC_INVALID_PARAM; |
| 1147 | } |
| 1148 | else |
| 1149 | return VPX_CODEC_INVALID_PARAM; |
| 1150 | } |
| 1151 | |
| 1152 | static vpx_codec_err_t vp8e_set_scalemode(vpx_codec_alg_priv_t *ctx, |
| 1153 | int ctr_id, |
| 1154 | va_list args) |
| 1155 | { |
| 1156 | |
| 1157 | vpx_scaling_mode_t *data = va_arg(args, vpx_scaling_mode_t *); |
| 1158 | |
| 1159 | if (data) |
| 1160 | { |
| 1161 | int res; |
| 1162 | vpx_scaling_mode_t scalemode = *(vpx_scaling_mode_t *)data ; |
| 1163 | res = vp8_set_internal_size(ctx->cpi, scalemode.h_scaling_mode, scalemode.v_scaling_mode); |
| 1164 | |
| 1165 | if (!res) |
| 1166 | { |
| 1167 | /*force next frame a key frame to effect scaling mode */ |
| 1168 | ctx->next_frame_flag |= FRAMEFLAGS_KEY; |
| 1169 | return VPX_CODEC_OK; |
| 1170 | } |
| 1171 | else |
| 1172 | return VPX_CODEC_INVALID_PARAM; |
| 1173 | } |
| 1174 | else |
| 1175 | return VPX_CODEC_INVALID_PARAM; |
| 1176 | } |
| 1177 | |
| 1178 | |
| 1179 | static vpx_codec_ctrl_fn_map_t vp8e_ctf_maps[] = |
| 1180 | { |
| 1181 | {VP8_SET_REFERENCE, vp8e_set_reference}, |
| 1182 | {VP8_COPY_REFERENCE, vp8e_get_reference}, |
| 1183 | {VP8_SET_POSTPROC, vp8e_set_previewpp}, |
| 1184 | {VP8E_UPD_ENTROPY, vp8e_update_entropy}, |
| 1185 | {VP8E_UPD_REFERENCE, vp8e_update_reference}, |
| 1186 | {VP8E_USE_REFERENCE, vp8e_use_reference}, |
| 1187 | {VP8E_SET_ROI_MAP, vp8e_set_roi_map}, |
| 1188 | {VP8E_SET_ACTIVEMAP, vp8e_set_activemap}, |
| 1189 | {VP8E_SET_SCALEMODE, vp8e_set_scalemode}, |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1190 | {VP8E_SET_CPUUSED, set_param}, |
| 1191 | {VP8E_SET_NOISE_SENSITIVITY, set_param}, |
| 1192 | {VP8E_SET_ENABLEAUTOALTREF, set_param}, |
| 1193 | {VP8E_SET_SHARPNESS, set_param}, |
| 1194 | {VP8E_SET_STATIC_THRESHOLD, set_param}, |
| 1195 | {VP8E_SET_TOKEN_PARTITIONS, set_param}, |
| 1196 | {VP8E_GET_LAST_QUANTIZER, get_param}, |
| 1197 | {VP8E_GET_LAST_QUANTIZER_64, get_param}, |
| 1198 | {VP8E_SET_ARNR_MAXFRAMES, set_param}, |
| 1199 | {VP8E_SET_ARNR_STRENGTH , set_param}, |
| 1200 | {VP8E_SET_ARNR_TYPE , set_param}, |
John Koleszar | b0da9b3 | 2010-12-17 09:43:39 -0500 | [diff] [blame] | 1201 | {VP8E_SET_TUNING, set_param}, |
Paul Wilkins | e0846c9 | 2011-01-07 18:29:37 +0000 | [diff] [blame] | 1202 | {VP8E_SET_CQ_LEVEL, set_param}, |
John Koleszar | 1654ae9 | 2011-07-28 09:17:32 -0400 | [diff] [blame] | 1203 | {VP8E_SET_MAX_INTRA_BITRATE_PCT, set_param}, |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1204 | { -1, NULL}, |
| 1205 | }; |
| 1206 | |
| 1207 | static vpx_codec_enc_cfg_map_t vp8e_usage_cfg_map[] = |
| 1208 | { |
| 1209 | { |
| 1210 | 0, |
| 1211 | { |
| 1212 | 0, /* g_usage */ |
| 1213 | 0, /* g_threads */ |
| 1214 | 0, /* g_profile */ |
| 1215 | |
| 1216 | 320, /* g_width */ |
| 1217 | 240, /* g_height */ |
| 1218 | {1, 30}, /* g_timebase */ |
| 1219 | |
| 1220 | 0, /* g_error_resilient */ |
| 1221 | |
| 1222 | VPX_RC_ONE_PASS, /* g_pass */ |
| 1223 | |
| 1224 | 0, /* g_lag_in_frames */ |
| 1225 | |
John Koleszar | 2321621 | 2010-09-02 09:32:03 -0400 | [diff] [blame] | 1226 | 0, /* rc_dropframe_thresh */ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1227 | 0, /* rc_resize_allowed */ |
| 1228 | 60, /* rc_resize_down_thresold */ |
| 1229 | 30, /* rc_resize_up_thresold */ |
| 1230 | |
| 1231 | VPX_VBR, /* rc_end_usage */ |
| 1232 | #if VPX_ENCODER_ABI_VERSION > (1 + VPX_CODEC_ABI_VERSION) |
| 1233 | {0}, /* rc_twopass_stats_in */ |
| 1234 | #endif |
| 1235 | 256, /* rc_target_bandwidth */ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1236 | 4, /* rc_min_quantizer */ |
| 1237 | 63, /* rc_max_quantizer */ |
John Koleszar | c99f9d7 | 2011-04-11 11:29:23 -0400 | [diff] [blame] | 1238 | 100, /* rc_undershoot_pct */ |
| 1239 | 100, /* rc_overshoot_pct */ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1240 | |
| 1241 | 6000, /* rc_max_buffer_size */ |
| 1242 | 4000, /* rc_buffer_initial_size; */ |
| 1243 | 5000, /* rc_buffer_optimal_size; */ |
| 1244 | |
| 1245 | 50, /* rc_two_pass_vbrbias */ |
| 1246 | 0, /* rc_two_pass_vbrmin_section */ |
| 1247 | 400, /* rc_two_pass_vbrmax_section */ |
| 1248 | |
| 1249 | /* keyframing settings (kf) */ |
| 1250 | VPX_KF_AUTO, /* g_kfmode*/ |
| 1251 | 0, /* kf_min_dist */ |
Ralph Giles | 2a0d7b1 | 2012-01-05 10:39:38 -0600 | [diff] [blame] | 1252 | 128, /* kf_max_dist */ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1253 | |
| 1254 | #if VPX_ENCODER_ABI_VERSION == (1 + VPX_CODEC_ABI_VERSION) |
| 1255 | 1, /* g_delete_first_pass_file */ |
| 1256 | "vp8.fpf" /* first pass filename */ |
| 1257 | #endif |
Adrian Grange | 217591f | 2011-10-06 15:49:11 -0700 | [diff] [blame] | 1258 | |
| 1259 | 1, /* ts_number_layers */ |
| 1260 | {0}, /* ts_target_bitrate */ |
| 1261 | {0}, /* ts_rate_decimator */ |
| 1262 | 0, /* ts_periodicity */ |
| 1263 | {0}, /* ts_layer_id */ |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1264 | }}, |
| 1265 | { -1, {NOT_IMPLEMENTED}} |
| 1266 | }; |
| 1267 | |
| 1268 | |
| 1269 | #ifndef VERSION_STRING |
| 1270 | #define VERSION_STRING |
| 1271 | #endif |
John Koleszar | fa7a55b | 2010-09-21 10:35:52 -0400 | [diff] [blame] | 1272 | CODEC_INTERFACE(vpx_codec_vp8_cx) = |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1273 | { |
John Koleszar | 317a666 | 2010-06-10 12:08:01 -0400 | [diff] [blame] | 1274 | "WebM Project VP8 Encoder" VERSION_STRING, |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1275 | VPX_CODEC_INTERNAL_ABI_VERSION, |
Stefan Holmer | 7296b3f | 2011-06-13 16:42:27 +0200 | [diff] [blame] | 1276 | VPX_CODEC_CAP_ENCODER | VPX_CODEC_CAP_PSNR | |
| 1277 | VPX_CODEC_CAP_OUTPUT_PARTITION, |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1278 | /* vpx_codec_caps_t caps; */ |
| 1279 | vp8e_init, /* vpx_codec_init_fn_t init; */ |
| 1280 | vp8e_destroy, /* vpx_codec_destroy_fn_t destroy; */ |
| 1281 | vp8e_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */ |
| 1282 | NOT_IMPLEMENTED, /* vpx_codec_get_mmap_fn_t get_mmap; */ |
| 1283 | NOT_IMPLEMENTED, /* vpx_codec_set_mmap_fn_t set_mmap; */ |
| 1284 | { |
| 1285 | NOT_IMPLEMENTED, /* vpx_codec_peek_si_fn_t peek_si; */ |
| 1286 | NOT_IMPLEMENTED, /* vpx_codec_get_si_fn_t get_si; */ |
| 1287 | NOT_IMPLEMENTED, /* vpx_codec_decode_fn_t decode; */ |
| 1288 | NOT_IMPLEMENTED, /* vpx_codec_frame_get_fn_t frame_get; */ |
| 1289 | }, |
| 1290 | { |
| 1291 | vp8e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */ |
| 1292 | vp8e_encode, /* vpx_codec_encode_fn_t encode; */ |
| 1293 | vp8e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */ |
| 1294 | vp8e_set_config, |
| 1295 | NOT_IMPLEMENTED, |
| 1296 | vp8e_get_preview, |
Yunqing Wang | aa7335e | 2011-10-25 15:14:16 -0400 | [diff] [blame] | 1297 | vp8e_mr_alloc_mem, |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1298 | } /* encoder functions */ |
| 1299 | }; |