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

Side by Side Diff: source/libvpx/vp8/vp8_cx_iface.c

Issue 7671004: Update libvpx snapshot to v0.9.7-p1 (Cayuga). (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp8/vp8_common.mk ('k') | source/libvpx/vp8/vp8_dx_iface.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 21 matching lines...) Expand all
32 unsigned int enable_auto_alt_ref; /** if encoder de cides to uses alternate reference frame */ 32 unsigned int enable_auto_alt_ref; /** if encoder de cides to uses alternate reference frame */
33 unsigned int noise_sensitivity; 33 unsigned int noise_sensitivity;
34 unsigned int Sharpness; 34 unsigned int Sharpness;
35 unsigned int static_thresh; 35 unsigned int static_thresh;
36 unsigned int token_partitions; 36 unsigned int token_partitions;
37 unsigned int arnr_max_frames; /* alt_ref Noise Reduction M ax Frame Count */ 37 unsigned int arnr_max_frames; /* alt_ref Noise Reduction M ax Frame Count */
38 unsigned int arnr_strength; /* alt_ref Noise Reduction Str ength */ 38 unsigned int arnr_strength; /* alt_ref Noise Reduction Str ength */
39 unsigned int arnr_type; /* alt_ref filter type */ 39 unsigned int arnr_type; /* alt_ref filter type */
40 vp8e_tuning tuning; 40 vp8e_tuning tuning;
41 unsigned int cq_level; /* constrained quality level * / 41 unsigned int cq_level; /* constrained quality level * /
42 unsigned int rc_max_intra_bitrate_pct;
42 43
43 }; 44 };
44 45
45 struct extraconfig_map 46 struct extraconfig_map
46 { 47 {
47 int usage; 48 int usage;
48 struct vp8_extracfg cfg; 49 struct vp8_extracfg cfg;
49 }; 50 };
50 51
51 static const struct extraconfig_map extracfg_map[] = 52 static const struct extraconfig_map extracfg_map[] =
(...skipping 12 matching lines...) Expand all
64 0, /* enable_auto_alt_ref */ 65 0, /* enable_auto_alt_ref */
65 0, /* noise_sensitivity */ 66 0, /* noise_sensitivity */
66 0, /* Sharpness */ 67 0, /* Sharpness */
67 0, /* static_thresh */ 68 0, /* static_thresh */
68 VP8_ONE_TOKENPARTITION, /* token_partitions */ 69 VP8_ONE_TOKENPARTITION, /* token_partitions */
69 0, /* arnr_max_frames */ 70 0, /* arnr_max_frames */
70 3, /* arnr_strength */ 71 3, /* arnr_strength */
71 3, /* arnr_type*/ 72 3, /* arnr_type*/
72 0, /* tuning*/ 73 0, /* tuning*/
73 10, /* cq_level */ 74 10, /* cq_level */
75 0, /* rc_max_intra_bitrate_pct */
74 } 76 }
75 } 77 }
76 }; 78 };
77 79
78 struct vpx_codec_alg_priv 80 struct vpx_codec_alg_priv
79 { 81 {
80 vpx_codec_priv_t base; 82 vpx_codec_priv_t base;
81 vpx_codec_enc_cfg_t cfg; 83 vpx_codec_enc_cfg_t cfg;
82 struct vp8_extracfg vp8_cfg; 84 struct vp8_extracfg vp8_cfg;
83 VP8_CONFIG oxcf; 85 VP8_CONFIG oxcf;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } while(0) 132 } while(0)
131 133
132 #define RANGE_CHECK_BOOL(p,memb) do {\ 134 #define RANGE_CHECK_BOOL(p,memb) do {\
133 if(!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean");\ 135 if(!!((p)->memb) != (p)->memb) ERROR(#memb " expected boolean");\
134 } while(0) 136 } while(0)
135 137
136 static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, 138 static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,
137 const vpx_codec_enc_cfg_t *cfg, 139 const vpx_codec_enc_cfg_t *cfg,
138 const struct vp8_extracfg *vp8_cfg) 140 const struct vp8_extracfg *vp8_cfg)
139 { 141 {
140 RANGE_CHECK(cfg, g_w, 1, 16384); 142 RANGE_CHECK(cfg, g_w, 1, 16383); /* 14 bits available */
141 RANGE_CHECK(cfg, g_h, 1, 16384); 143 RANGE_CHECK(cfg, g_h, 1, 16383); /* 14 bits available */
142 RANGE_CHECK(cfg, g_timebase.den, 1, 1000000000); 144 RANGE_CHECK(cfg, g_timebase.den, 1, 1000000000);
143 RANGE_CHECK(cfg, g_timebase.num, 1, cfg->g_timebase.den); 145 RANGE_CHECK(cfg, g_timebase.num, 1, cfg->g_timebase.den);
144 RANGE_CHECK_HI(cfg, g_profile, 3); 146 RANGE_CHECK_HI(cfg, g_profile, 3);
145 RANGE_CHECK_HI(cfg, rc_max_quantizer, 63); 147 RANGE_CHECK_HI(cfg, rc_max_quantizer, 63);
146 RANGE_CHECK_HI(cfg, rc_min_quantizer, cfg->rc_max_quantizer); 148 RANGE_CHECK_HI(cfg, rc_min_quantizer, cfg->rc_max_quantizer);
147 RANGE_CHECK_HI(cfg, g_threads, 64); 149 RANGE_CHECK_HI(cfg, g_threads, 64);
148 #if !(CONFIG_REALTIME_ONLY) 150 #if !(CONFIG_REALTIME_ONLY)
149 RANGE_CHECK_HI(cfg, g_lag_in_frames, 25); 151 RANGE_CHECK_HI(cfg, g_lag_in_frames, 25);
150 #else 152 #else
151 RANGE_CHECK_HI(cfg, g_lag_in_frames, 0); 153 RANGE_CHECK_HI(cfg, g_lag_in_frames, 0);
152 #endif 154 #endif
153 RANGE_CHECK(cfg, rc_end_usage, VPX_VBR, VPX_CQ); 155 RANGE_CHECK(cfg, rc_end_usage, VPX_VBR, VPX_CQ);
154 RANGE_CHECK_HI(cfg, rc_undershoot_pct, 100); 156 RANGE_CHECK_HI(cfg, rc_undershoot_pct, 1000);
157 RANGE_CHECK_HI(cfg, rc_overshoot_pct, 1000);
155 RANGE_CHECK_HI(cfg, rc_2pass_vbr_bias_pct, 100); 158 RANGE_CHECK_HI(cfg, rc_2pass_vbr_bias_pct, 100);
156 RANGE_CHECK(cfg, kf_mode, VPX_KF_DISABLED, VPX_KF_AUTO); 159 RANGE_CHECK(cfg, kf_mode, VPX_KF_DISABLED, VPX_KF_AUTO);
157 //RANGE_CHECK_BOOL(cfg, g_delete_firstpassfile); 160 //RANGE_CHECK_BOOL(cfg, g_delete_firstpassfile);
158 RANGE_CHECK_BOOL(cfg, rc_resize_allowed); 161 RANGE_CHECK_BOOL(cfg, rc_resize_allowed);
159 RANGE_CHECK_HI(cfg, rc_dropframe_thresh, 100); 162 RANGE_CHECK_HI(cfg, rc_dropframe_thresh, 100);
160 RANGE_CHECK_HI(cfg, rc_resize_up_thresh, 100); 163 RANGE_CHECK_HI(cfg, rc_resize_up_thresh, 100);
161 RANGE_CHECK_HI(cfg, rc_resize_down_thresh, 100); 164 RANGE_CHECK_HI(cfg, rc_resize_down_thresh, 100);
162 #if !(CONFIG_REALTIME_ONLY) 165 #if !(CONFIG_REALTIME_ONLY)
163 RANGE_CHECK(cfg, g_pass, VPX_RC_ONE_PASS, VPX_RC_LAST_PASS); 166 RANGE_CHECK(cfg, g_pass, VPX_RC_ONE_PASS, VPX_RC_LAST_PASS);
164 #else 167 #else
165 RANGE_CHECK(cfg, g_pass, VPX_RC_ONE_PASS, VPX_RC_ONE_PASS); 168 RANGE_CHECK(cfg, g_pass, VPX_RC_ONE_PASS, VPX_RC_ONE_PASS);
166 #endif 169 #endif
167 170
168 /* VP8 does not support a lower bound on the keyframe interval in 171 /* VP8 does not support a lower bound on the keyframe interval in
169 * automatic keyframe placement mode. 172 * automatic keyframe placement mode.
170 */ 173 */
171 if (cfg->kf_mode != VPX_KF_DISABLED && cfg->kf_min_dist != cfg->kf_max_dist 174 if (cfg->kf_mode != VPX_KF_DISABLED && cfg->kf_min_dist != cfg->kf_max_dist
172 && cfg->kf_min_dist > 0) 175 && cfg->kf_min_dist > 0)
173 ERROR("kf_min_dist not supported in auto mode, use 0 " 176 ERROR("kf_min_dist not supported in auto mode, use 0 "
174 "or kf_max_dist instead."); 177 "or kf_max_dist instead.");
175 178
176 RANGE_CHECK_BOOL(vp8_cfg, enable_auto_alt_ref); 179 RANGE_CHECK_BOOL(vp8_cfg, enable_auto_alt_ref);
180 RANGE_CHECK(vp8_cfg, cpu_used, -16, 16);
181
177 #if !(CONFIG_REALTIME_ONLY) 182 #if !(CONFIG_REALTIME_ONLY)
178 RANGE_CHECK(vp8_cfg, encoding_mode, VP8_BEST_QUALITY_ENCODING, VP8_REAL _TIME_ENCODING); 183 RANGE_CHECK(vp8_cfg, encoding_mode, VP8_BEST_QUALITY_ENCODING, VP8_REAL _TIME_ENCODING);
179 RANGE_CHECK(vp8_cfg, cpu_used, -16, 16);
180 RANGE_CHECK_HI(vp8_cfg, noise_sensitivity, 6); 184 RANGE_CHECK_HI(vp8_cfg, noise_sensitivity, 6);
181 #else 185 #else
182 RANGE_CHECK(vp8_cfg, encoding_mode, VP8_REAL_TIME_ENCODING, VP8_REAL_TI ME_ENCODING); 186 RANGE_CHECK(vp8_cfg, encoding_mode, VP8_REAL_TIME_ENCODING, VP8_REAL_TI ME_ENCODING);
183
184 if (!((vp8_cfg->cpu_used >= -16 && vp8_cfg->cpu_used <= -4) || (vp8_cfg->cpu _used >= 4 && vp8_cfg->cpu_used <= 16)))
185 ERROR("cpu_used out of range [-16..-4] or [4..16]");
186
187 RANGE_CHECK(vp8_cfg, noise_sensitivity, 0, 0); 187 RANGE_CHECK(vp8_cfg, noise_sensitivity, 0, 0);
188 #endif 188 #endif
189 189
190 RANGE_CHECK(vp8_cfg, token_partitions, VP8_ONE_TOKENPARTITION, VP8_EIGHT_T OKENPARTITION); 190 RANGE_CHECK(vp8_cfg, token_partitions, VP8_ONE_TOKENPARTITION, VP8_EIGHT_T OKENPARTITION);
191 RANGE_CHECK_HI(vp8_cfg, Sharpness, 7); 191 RANGE_CHECK_HI(vp8_cfg, Sharpness, 7);
192 RANGE_CHECK(vp8_cfg, arnr_max_frames, 0, 15); 192 RANGE_CHECK(vp8_cfg, arnr_max_frames, 0, 15);
193 RANGE_CHECK_HI(vp8_cfg, arnr_strength, 6); 193 RANGE_CHECK_HI(vp8_cfg, arnr_strength, 6);
194 RANGE_CHECK(vp8_cfg, arnr_type, 1, 3); 194 RANGE_CHECK(vp8_cfg, arnr_type, 1, 3);
195 RANGE_CHECK(vp8_cfg, cq_level, 0, 63); 195 RANGE_CHECK(vp8_cfg, cq_level, 0, 63);
196 196
197 #if !(CONFIG_REALTIME_ONLY) 197 #if !(CONFIG_REALTIME_ONLY)
198 if (cfg->g_pass == VPX_RC_LAST_PASS) 198 if (cfg->g_pass == VPX_RC_LAST_PASS)
199 { 199 {
200 int mb_r = (cfg->g_h + 15) / 16;
201 int mb_c = (cfg->g_w + 15) / 16;
202 size_t packet_sz = sizeof(FIRSTPASS_STATS); 200 size_t packet_sz = sizeof(FIRSTPASS_STATS);
203 int n_packets = cfg->rc_twopass_stats_in.sz / packet_sz; 201 int n_packets = cfg->rc_twopass_stats_in.sz / packet_sz;
204 FIRSTPASS_STATS *stats; 202 FIRSTPASS_STATS *stats;
205 203
206 if (!cfg->rc_twopass_stats_in.buf) 204 if (!cfg->rc_twopass_stats_in.buf)
207 ERROR("rc_twopass_stats_in.buf not set."); 205 ERROR("rc_twopass_stats_in.buf not set.");
208 206
209 if (cfg->rc_twopass_stats_in.sz % packet_sz) 207 if (cfg->rc_twopass_stats_in.sz % packet_sz)
210 ERROR("rc_twopass_stats_in.sz indicates truncated packet."); 208 ERROR("rc_twopass_stats_in.sz indicates truncated packet.");
211 209
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 else if (cfg.rc_end_usage == VPX_CBR) 300 else if (cfg.rc_end_usage == VPX_CBR)
303 { 301 {
304 oxcf->end_usage = USAGE_STREAM_FROM_SERVER; 302 oxcf->end_usage = USAGE_STREAM_FROM_SERVER;
305 } 303 }
306 else if (cfg.rc_end_usage == VPX_CQ) 304 else if (cfg.rc_end_usage == VPX_CQ)
307 { 305 {
308 oxcf->end_usage = USAGE_CONSTRAINED_QUALITY; 306 oxcf->end_usage = USAGE_CONSTRAINED_QUALITY;
309 } 307 }
310 308
311 oxcf->target_bandwidth = cfg.rc_target_bitrate; 309 oxcf->target_bandwidth = cfg.rc_target_bitrate;
310 oxcf->rc_max_intra_bitrate_pct = vp8_cfg.rc_max_intra_bitrate_pct;
312 311
313 oxcf->best_allowed_q = cfg.rc_min_quantizer; 312 oxcf->best_allowed_q = cfg.rc_min_quantizer;
314 oxcf->worst_allowed_q = cfg.rc_max_quantizer; 313 oxcf->worst_allowed_q = cfg.rc_max_quantizer;
315 oxcf->cq_level = vp8_cfg.cq_level; 314 oxcf->cq_level = vp8_cfg.cq_level;
316 oxcf->fixed_q = -1; 315 oxcf->fixed_q = -1;
317 316
318 oxcf->under_shoot_pct = cfg.rc_undershoot_pct; 317 oxcf->under_shoot_pct = cfg.rc_undershoot_pct;
319 //oxcf->over_shoot_pct = cfg.rc_overshoot_pct; 318 oxcf->over_shoot_pct = cfg.rc_overshoot_pct;
320 319
321 oxcf->maximum_buffer_size = cfg.rc_buf_sz; 320 oxcf->maximum_buffer_size = cfg.rc_buf_sz;
322 oxcf->starting_buffer_level = cfg.rc_buf_initial_sz; 321 oxcf->starting_buffer_level = cfg.rc_buf_initial_sz;
323 oxcf->optimal_buffer_level = cfg.rc_buf_optimal_sz; 322 oxcf->optimal_buffer_level = cfg.rc_buf_optimal_sz;
324 323
325 oxcf->two_pass_vbrbias = cfg.rc_2pass_vbr_bias_pct; 324 oxcf->two_pass_vbrbias = cfg.rc_2pass_vbr_bias_pct;
326 oxcf->two_pass_vbrmin_section = cfg.rc_2pass_vbr_minsection_pct; 325 oxcf->two_pass_vbrmin_section = cfg.rc_2pass_vbr_minsection_pct;
327 oxcf->two_pass_vbrmax_section = cfg.rc_2pass_vbr_maxsection_pct; 326 oxcf->two_pass_vbrmax_section = cfg.rc_2pass_vbr_maxsection_pct;
328 327
329 oxcf->auto_key = cfg.kf_mode == VPX_KF_AUTO 328 oxcf->auto_key = cfg.kf_mode == VPX_KF_AUTO
(...skipping 25 matching lines...) Expand all
355 printf("target_bandwidth: %d\n", oxcf->target_bandwidth); 354 printf("target_bandwidth: %d\n", oxcf->target_bandwidth);
356 printf("noise_sensitivity: %d\n", oxcf->noise_sensitivity); 355 printf("noise_sensitivity: %d\n", oxcf->noise_sensitivity);
357 printf("Sharpness: %d\n", oxcf->Sharpness); 356 printf("Sharpness: %d\n", oxcf->Sharpness);
358 printf("cpu_used: %d\n", oxcf->cpu_used); 357 printf("cpu_used: %d\n", oxcf->cpu_used);
359 printf("Mode: %d\n", oxcf->Mode); 358 printf("Mode: %d\n", oxcf->Mode);
360 printf("delete_first_pass_file: %d\n", oxcf->delete_first_pass_file); 359 printf("delete_first_pass_file: %d\n", oxcf->delete_first_pass_file);
361 printf("auto_key: %d\n", oxcf->auto_key); 360 printf("auto_key: %d\n", oxcf->auto_key);
362 printf("key_freq: %d\n", oxcf->key_freq); 361 printf("key_freq: %d\n", oxcf->key_freq);
363 printf("end_usage: %d\n", oxcf->end_usage); 362 printf("end_usage: %d\n", oxcf->end_usage);
364 printf("under_shoot_pct: %d\n", oxcf->under_shoot_pct); 363 printf("under_shoot_pct: %d\n", oxcf->under_shoot_pct);
364 printf("over_shoot_pct: %d\n", oxcf->over_shoot_pct);
365 printf("starting_buffer_level: %d\n", oxcf->starting_buffer_level); 365 printf("starting_buffer_level: %d\n", oxcf->starting_buffer_level);
366 printf("optimal_buffer_level: %d\n", oxcf->optimal_buffer_level); 366 printf("optimal_buffer_level: %d\n", oxcf->optimal_buffer_level);
367 printf("maximum_buffer_size: %d\n", oxcf->maximum_buffer_size); 367 printf("maximum_buffer_size: %d\n", oxcf->maximum_buffer_size);
368 printf("fixed_q: %d\n", oxcf->fixed_q); 368 printf("fixed_q: %d\n", oxcf->fixed_q);
369 printf("worst_allowed_q: %d\n", oxcf->worst_allowed_q); 369 printf("worst_allowed_q: %d\n", oxcf->worst_allowed_q);
370 printf("best_allowed_q: %d\n", oxcf->best_allowed_q); 370 printf("best_allowed_q: %d\n", oxcf->best_allowed_q);
371 printf("allow_spatial_resampling: %d\n", oxcf->allow_spatial_resampling ); 371 printf("allow_spatial_resampling: %d\n", oxcf->allow_spatial_resampling );
372 printf("resample_down_water_mark: %d\n", oxcf->resample_down_water_mark) ; 372 printf("resample_down_water_mark: %d\n", oxcf->resample_down_water_mark) ;
373 printf("resample_up_water_mark: %d\n", oxcf->resample_up_water_mark); 373 printf("resample_up_water_mark: %d\n", oxcf->resample_up_water_mark);
374 printf("allow_df: %d\n", oxcf->allow_df); 374 printf("allow_df: %d\n", oxcf->allow_df);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 MAP(VP8E_SET_NOISE_SENSITIVITY, xcfg.noise_sensitivity); 457 MAP(VP8E_SET_NOISE_SENSITIVITY, xcfg.noise_sensitivity);
458 MAP(VP8E_SET_SHARPNESS, xcfg.Sharpness); 458 MAP(VP8E_SET_SHARPNESS, xcfg.Sharpness);
459 MAP(VP8E_SET_STATIC_THRESHOLD, xcfg.static_thresh); 459 MAP(VP8E_SET_STATIC_THRESHOLD, xcfg.static_thresh);
460 MAP(VP8E_SET_TOKEN_PARTITIONS, xcfg.token_partitions); 460 MAP(VP8E_SET_TOKEN_PARTITIONS, xcfg.token_partitions);
461 461
462 MAP(VP8E_SET_ARNR_MAXFRAMES, xcfg.arnr_max_frames); 462 MAP(VP8E_SET_ARNR_MAXFRAMES, xcfg.arnr_max_frames);
463 MAP(VP8E_SET_ARNR_STRENGTH , xcfg.arnr_strength); 463 MAP(VP8E_SET_ARNR_STRENGTH , xcfg.arnr_strength);
464 MAP(VP8E_SET_ARNR_TYPE , xcfg.arnr_type); 464 MAP(VP8E_SET_ARNR_TYPE , xcfg.arnr_type);
465 MAP(VP8E_SET_TUNING, xcfg.tuning); 465 MAP(VP8E_SET_TUNING, xcfg.tuning);
466 MAP(VP8E_SET_CQ_LEVEL, xcfg.cq_level); 466 MAP(VP8E_SET_CQ_LEVEL, xcfg.cq_level);
467 MAP(VP8E_SET_MAX_INTRA_BITRATE_PCT, xcfg.rc_max_intra_bitrate_pct);
467 468
468 } 469 }
469 470
470 res = validate_config(ctx, &ctx->cfg, &xcfg); 471 res = validate_config(ctx, &ctx->cfg, &xcfg);
471 472
472 if (!res) 473 if (!res)
473 { 474 {
474 ctx->vp8_cfg = xcfg; 475 ctx->vp8_cfg = xcfg;
475 set_vp8e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg); 476 set_vp8e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg);
476 vp8_change_config(ctx->cpi, &ctx->oxcf); 477 vp8_change_config(ctx->cpi, &ctx->oxcf);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 flags |= VPX_EFLAG_FORCE_KF; 719 flags |= VPX_EFLAG_FORCE_KF;
719 ctx->fixed_kf_cntr = 1; 720 ctx->fixed_kf_cntr = 1;
720 } 721 }
721 } 722 }
722 723
723 /* Initialize the encoder instance on the first frame*/ 724 /* Initialize the encoder instance on the first frame*/
724 if (!res && ctx->cpi) 725 if (!res && ctx->cpi)
725 { 726 {
726 unsigned int lib_flags; 727 unsigned int lib_flags;
727 YV12_BUFFER_CONFIG sd; 728 YV12_BUFFER_CONFIG sd;
728 INT64 dst_time_stamp, dst_end_time_stamp; 729 int64_t dst_time_stamp, dst_end_time_stamp;
729 unsigned long size, cx_data_sz; 730 unsigned long size, cx_data_sz;
730 unsigned char *cx_data; 731 unsigned char *cx_data;
731 732
732 /* Set up internal flags */ 733 /* Set up internal flags */
733 if (ctx->base.init_flags & VPX_CODEC_USE_PSNR) 734 if (ctx->base.init_flags & VPX_CODEC_USE_PSNR)
734 ((VP8_COMP *)ctx->cpi)->b_calculate_psnr = 1; 735 ((VP8_COMP *)ctx->cpi)->b_calculate_psnr = 1;
735 736
737 if (ctx->base.init_flags & VPX_CODEC_USE_OUTPUT_PARTITION)
738 ((VP8_COMP *)ctx->cpi)->output_partition = 1;
739
736 /* Convert API flags to internal codec lib flags */ 740 /* Convert API flags to internal codec lib flags */
737 lib_flags = (flags & VPX_EFLAG_FORCE_KF) ? FRAMEFLAGS_KEY : 0; 741 lib_flags = (flags & VPX_EFLAG_FORCE_KF) ? FRAMEFLAGS_KEY : 0;
738 742
739 /* vp8 use 10,000,000 ticks/second as time stamp */ 743 /* vp8 use 10,000,000 ticks/second as time stamp */
740 dst_time_stamp = pts * 10000000 * ctx->cfg.g_timebase.num / ctx->cfg. g_timebase.den; 744 dst_time_stamp = pts * 10000000 * ctx->cfg.g_timebase.num / ctx->cfg. g_timebase.den;
741 dst_end_time_stamp = (pts + duration) * 10000000 * ctx->cfg.g_timebase.n um / ctx->cfg.g_timebase.den; 745 dst_end_time_stamp = (pts + duration) * 10000000 * ctx->cfg.g_timebase.n um / ctx->cfg.g_timebase.den;
742 746
743 if (img != NULL) 747 if (img != NULL)
744 { 748 {
745 res = image2yuvconfig(img, &sd); 749 res = image2yuvconfig(img, &sd);
(...skipping 19 matching lines...) Expand all
765 if (size) 769 if (size)
766 { 770 {
767 vpx_codec_pts_t round, delta; 771 vpx_codec_pts_t round, delta;
768 vpx_codec_cx_pkt_t pkt; 772 vpx_codec_cx_pkt_t pkt;
769 VP8_COMP *cpi = (VP8_COMP *)ctx->cpi; 773 VP8_COMP *cpi = (VP8_COMP *)ctx->cpi;
770 774
771 /* Add the frame packet to the list of returned packets. */ 775 /* Add the frame packet to the list of returned packets. */
772 round = 1000000 * ctx->cfg.g_timebase.num / 2 - 1; 776 round = 1000000 * ctx->cfg.g_timebase.num / 2 - 1;
773 delta = (dst_end_time_stamp - dst_time_stamp); 777 delta = (dst_end_time_stamp - dst_time_stamp);
774 pkt.kind = VPX_CODEC_CX_FRAME_PKT; 778 pkt.kind = VPX_CODEC_CX_FRAME_PKT;
775 pkt.data.frame.buf = cx_data;
776 pkt.data.frame.sz = size;
777 pkt.data.frame.pts = 779 pkt.data.frame.pts =
778 (dst_time_stamp * ctx->cfg.g_timebase.den + round) 780 (dst_time_stamp * ctx->cfg.g_timebase.den + round)
779 / ctx->cfg.g_timebase.num / 10000000; 781 / ctx->cfg.g_timebase.num / 10000000;
780 pkt.data.frame.duration = 782 pkt.data.frame.duration =
781 (delta * ctx->cfg.g_timebase.den + round) 783 (delta * ctx->cfg.g_timebase.den + round)
782 / ctx->cfg.g_timebase.num / 10000000; 784 / ctx->cfg.g_timebase.num / 10000000;
783 pkt.data.frame.flags = lib_flags << 16; 785 pkt.data.frame.flags = lib_flags << 16;
784 786
785 if (lib_flags & FRAMEFLAGS_KEY) 787 if (lib_flags & FRAMEFLAGS_KEY)
786 pkt.data.frame.flags |= VPX_FRAME_IS_KEY; 788 pkt.data.frame.flags |= VPX_FRAME_IS_KEY;
787 789
788 if (!cpi->common.show_frame) 790 if (!cpi->common.show_frame)
789 { 791 {
790 pkt.data.frame.flags |= VPX_FRAME_IS_INVISIBLE; 792 pkt.data.frame.flags |= VPX_FRAME_IS_INVISIBLE;
791 793
792 // This timestamp should be as close as possible to the 794 // This timestamp should be as close as possible to the
793 // prior PTS so that if a decoder uses pts to schedule when 795 // prior PTS so that if a decoder uses pts to schedule when
794 // to do this, we start right after last frame was decoded. 796 // to do this, we start right after last frame was decoded.
795 // Invisible frames have no duration. 797 // Invisible frames have no duration.
796 pkt.data.frame.pts = ((cpi->last_time_stamp_seen 798 pkt.data.frame.pts = ((cpi->last_time_stamp_seen
797 * ctx->cfg.g_timebase.den + round) 799 * ctx->cfg.g_timebase.den + round)
798 / ctx->cfg.g_timebase.num / 10000000) + 1; 800 / ctx->cfg.g_timebase.num / 10000000) + 1;
799 pkt.data.frame.duration = 0; 801 pkt.data.frame.duration = 0;
800 } 802 }
801 803
802 vpx_codec_pkt_list_add(&ctx->pkt_list.head, &pkt); 804 if (cpi->droppable)
805 pkt.data.frame.flags |= VPX_FRAME_IS_DROPPABLE;
806
807 if (cpi->output_partition)
808 {
809 int i;
810 const int num_partitions =
811 (1 << cpi->common.multi_token_partition) + 1;
812
813 pkt.data.frame.flags |= VPX_FRAME_IS_FRAGMENT;
814
815 for (i = 0; i < num_partitions; ++i)
816 {
817 pkt.data.frame.buf = cx_data;
818 pkt.data.frame.sz = cpi->partition_sz[i];
819 pkt.data.frame.partition_id = i;
820 /* don't set the fragment bit for the last partition */
821 if (i == (num_partitions - 1))
822 pkt.data.frame.flags &= ~VPX_FRAME_IS_FRAGMENT;
823 vpx_codec_pkt_list_add(&ctx->pkt_list.head, &pkt);
824 cx_data += cpi->partition_sz[i];
825 cx_data_sz -= cpi->partition_sz[i];
826 }
827 }
828 else
829 {
830 pkt.data.frame.buf = cx_data;
831 pkt.data.frame.sz = size;
832 pkt.data.frame.partition_id = -1;
833 vpx_codec_pkt_list_add(&ctx->pkt_list.head, &pkt);
834 cx_data += size;
835 cx_data_sz -= size;
836 }
803 837
804 //printf("timestamp: %lld, duration: %d\n", pkt->data.frame.pts, pkt->data.frame.duration); 838 //printf("timestamp: %lld, duration: %d\n", pkt->data.frame.pts, pkt->data.frame.duration);
805 cx_data += size;
806 cx_data_sz -= size;
807 } 839 }
808 } 840 }
809 } 841 }
810 842
811 return res; 843 return res;
812 } 844 }
813 845
814 846
815 static const vpx_codec_cx_pkt_t *vp8e_get_cxdata(vpx_codec_alg_priv_t *ctx, 847 static const vpx_codec_cx_pkt_t *vp8e_get_cxdata(vpx_codec_alg_priv_t *ctx,
816 vpx_codec_iter_t *iter) 848 vpx_codec_iter_t *iter)
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 {VP8E_SET_SHARPNESS, set_param}, 1081 {VP8E_SET_SHARPNESS, set_param},
1050 {VP8E_SET_STATIC_THRESHOLD, set_param}, 1082 {VP8E_SET_STATIC_THRESHOLD, set_param},
1051 {VP8E_SET_TOKEN_PARTITIONS, set_param}, 1083 {VP8E_SET_TOKEN_PARTITIONS, set_param},
1052 {VP8E_GET_LAST_QUANTIZER, get_param}, 1084 {VP8E_GET_LAST_QUANTIZER, get_param},
1053 {VP8E_GET_LAST_QUANTIZER_64, get_param}, 1085 {VP8E_GET_LAST_QUANTIZER_64, get_param},
1054 {VP8E_SET_ARNR_MAXFRAMES, set_param}, 1086 {VP8E_SET_ARNR_MAXFRAMES, set_param},
1055 {VP8E_SET_ARNR_STRENGTH , set_param}, 1087 {VP8E_SET_ARNR_STRENGTH , set_param},
1056 {VP8E_SET_ARNR_TYPE , set_param}, 1088 {VP8E_SET_ARNR_TYPE , set_param},
1057 {VP8E_SET_TUNING, set_param}, 1089 {VP8E_SET_TUNING, set_param},
1058 {VP8E_SET_CQ_LEVEL, set_param}, 1090 {VP8E_SET_CQ_LEVEL, set_param},
1091 {VP8E_SET_MAX_INTRA_BITRATE_PCT, set_param},
1059 { -1, NULL}, 1092 { -1, NULL},
1060 }; 1093 };
1061 1094
1062 static vpx_codec_enc_cfg_map_t vp8e_usage_cfg_map[] = 1095 static vpx_codec_enc_cfg_map_t vp8e_usage_cfg_map[] =
1063 { 1096 {
1064 { 1097 {
1065 0, 1098 0,
1066 { 1099 {
1067 0, /* g_usage */ 1100 0, /* g_usage */
1068 0, /* g_threads */ 1101 0, /* g_threads */
(...skipping 12 matching lines...) Expand all
1081 0, /* rc_dropframe_thresh */ 1114 0, /* rc_dropframe_thresh */
1082 0, /* rc_resize_allowed */ 1115 0, /* rc_resize_allowed */
1083 60, /* rc_resize_down_thresold */ 1116 60, /* rc_resize_down_thresold */
1084 30, /* rc_resize_up_thresold */ 1117 30, /* rc_resize_up_thresold */
1085 1118
1086 VPX_VBR, /* rc_end_usage */ 1119 VPX_VBR, /* rc_end_usage */
1087 #if VPX_ENCODER_ABI_VERSION > (1 + VPX_CODEC_ABI_VERSION) 1120 #if VPX_ENCODER_ABI_VERSION > (1 + VPX_CODEC_ABI_VERSION)
1088 {0}, /* rc_twopass_stats_in */ 1121 {0}, /* rc_twopass_stats_in */
1089 #endif 1122 #endif
1090 256, /* rc_target_bandwidth */ 1123 256, /* rc_target_bandwidth */
1091
1092 4, /* rc_min_quantizer */ 1124 4, /* rc_min_quantizer */
1093 63, /* rc_max_quantizer */ 1125 63, /* rc_max_quantizer */
1094 95, /* rc_undershoot_pct */ 1126 100, /* rc_undershoot_pct */
1095 200, /* rc_overshoot_pct */ 1127 100, /* rc_overshoot_pct */
1096 1128
1097 6000, /* rc_max_buffer_size */ 1129 6000, /* rc_max_buffer_size */
1098 4000, /* rc_buffer_initial_size; */ 1130 4000, /* rc_buffer_initial_size; */
1099 5000, /* rc_buffer_optimal_size; */ 1131 5000, /* rc_buffer_optimal_size; */
1100 1132
1101 50, /* rc_two_pass_vbrbias */ 1133 50, /* rc_two_pass_vbrbias */
1102 0, /* rc_two_pass_vbrmin_section */ 1134 0, /* rc_two_pass_vbrmin_section */
1103 400, /* rc_two_pass_vbrmax_section */ 1135 400, /* rc_two_pass_vbrmax_section */
1104 1136
1105 /* keyframing settings (kf) */ 1137 /* keyframing settings (kf) */
(...skipping 10 matching lines...) Expand all
1116 }; 1148 };
1117 1149
1118 1150
1119 #ifndef VERSION_STRING 1151 #ifndef VERSION_STRING
1120 #define VERSION_STRING 1152 #define VERSION_STRING
1121 #endif 1153 #endif
1122 CODEC_INTERFACE(vpx_codec_vp8_cx) = 1154 CODEC_INTERFACE(vpx_codec_vp8_cx) =
1123 { 1155 {
1124 "WebM Project VP8 Encoder" VERSION_STRING, 1156 "WebM Project VP8 Encoder" VERSION_STRING,
1125 VPX_CODEC_INTERNAL_ABI_VERSION, 1157 VPX_CODEC_INTERNAL_ABI_VERSION,
1126 VPX_CODEC_CAP_ENCODER | VPX_CODEC_CAP_PSNR, 1158 VPX_CODEC_CAP_ENCODER | VPX_CODEC_CAP_PSNR |
1159 VPX_CODEC_CAP_OUTPUT_PARTITION,
1127 /* vpx_codec_caps_t caps; */ 1160 /* vpx_codec_caps_t caps; */
1128 vp8e_init, /* vpx_codec_init_fn_t init; */ 1161 vp8e_init, /* vpx_codec_init_fn_t init; */
1129 vp8e_destroy, /* vpx_codec_destroy_fn_t destroy; */ 1162 vp8e_destroy, /* vpx_codec_destroy_fn_t destroy; */
1130 vp8e_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */ 1163 vp8e_ctf_maps, /* vpx_codec_ctrl_fn_map_t *ctrl_maps; */
1131 NOT_IMPLEMENTED, /* vpx_codec_get_mmap_fn_t get_mmap; */ 1164 NOT_IMPLEMENTED, /* vpx_codec_get_mmap_fn_t get_mmap; */
1132 NOT_IMPLEMENTED, /* vpx_codec_set_mmap_fn_t set_mmap; */ 1165 NOT_IMPLEMENTED, /* vpx_codec_set_mmap_fn_t set_mmap; */
1133 { 1166 {
1134 NOT_IMPLEMENTED, /* vpx_codec_peek_si_fn_t peek_si; */ 1167 NOT_IMPLEMENTED, /* vpx_codec_peek_si_fn_t peek_si; */
1135 NOT_IMPLEMENTED, /* vpx_codec_get_si_fn_t get_si; */ 1168 NOT_IMPLEMENTED, /* vpx_codec_get_si_fn_t get_si; */
1136 NOT_IMPLEMENTED, /* vpx_codec_decode_fn_t decode; */ 1169 NOT_IMPLEMENTED, /* vpx_codec_decode_fn_t decode; */
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 {NOT_IMPLEMENTED}, /* decoder functions */ 1255 {NOT_IMPLEMENTED}, /* decoder functions */
1223 { 1256 {
1224 vp8e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */ 1257 vp8e_usage_cfg_map, /* vpx_codec_enc_cfg_map_t peek_si; */
1225 api1_encode, /* vpx_codec_encode_fn_t encode; */ 1258 api1_encode, /* vpx_codec_encode_fn_t encode; */
1226 vp8e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */ 1259 vp8e_get_cxdata, /* vpx_codec_get_cx_data_fn_t frame_get; */
1227 vp8e_set_config, 1260 vp8e_set_config,
1228 NOT_IMPLEMENTED, 1261 NOT_IMPLEMENTED,
1229 vp8e_get_preview, 1262 vp8e_get_preview,
1230 } /* encoder functions */ 1263 } /* encoder functions */
1231 }; 1264 };
OLDNEW
« no previous file with comments | « source/libvpx/vp8/vp8_common.mk ('k') | source/libvpx/vp8/vp8_dx_iface.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698