OLD | NEW |
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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 int show_psnr = 0; | 209 int show_psnr = 0; |
210 uint64_t psnr_sse_total[NUM_ENCODERS] = {0}; | 210 uint64_t psnr_sse_total[NUM_ENCODERS] = {0}; |
211 uint64_t psnr_samples_total[NUM_ENCODERS] = {0}; | 211 uint64_t psnr_samples_total[NUM_ENCODERS] = {0}; |
212 double psnr_totals[NUM_ENCODERS][4] = {{0,0}}; | 212 double psnr_totals[NUM_ENCODERS][4] = {{0,0}}; |
213 int psnr_count[NUM_ENCODERS] = {0}; | 213 int psnr_count[NUM_ENCODERS] = {0}; |
214 | 214 |
215 /* Set the required target bitrates for each resolution level. | 215 /* Set the required target bitrates for each resolution level. |
216 * If target bitrate for highest-resolution level is set to 0, | 216 * If target bitrate for highest-resolution level is set to 0, |
217 * (i.e. target_bitrate[0]=0), we skip encoding at that level. | 217 * (i.e. target_bitrate[0]=0), we skip encoding at that level. |
218 */ | 218 */ |
219 unsigned int target_bitrate[NUM_ENCODERS]={1400, 500, 100}; | 219 unsigned int target_bitrate[NUM_ENCODERS]={1000, 500, 100}; |
220 /* Enter the frame rate of the input video */ | 220 /* Enter the frame rate of the input video */ |
221 int framerate = 30; | 221 int framerate = 30; |
222 /* Set down-sampling factor for each resolution level. | 222 /* Set down-sampling factor for each resolution level. |
223 dsf[0] controls down sampling from level 0 to level 1; | 223 dsf[0] controls down sampling from level 0 to level 1; |
224 dsf[1] controls down sampling from level 1 to level 2; | 224 dsf[1] controls down sampling from level 1 to level 2; |
225 dsf[2] is not used. */ | 225 dsf[2] is not used. */ |
226 vpx_rational_t dsf[NUM_ENCODERS] = {{2, 1}, {2, 1}, {1, 1}}; | 226 vpx_rational_t dsf[NUM_ENCODERS] = {{2, 1}, {2, 1}, {1, 1}}; |
227 | 227 |
228 if(argc!= (5+NUM_ENCODERS)) | 228 if(argc!= (5+NUM_ENCODERS)) |
229 die("Usage: %s <width> <height> <infile> <outfile(s)> <output psnr?>\n", | 229 die("Usage: %s <width> <height> <infile> <outfile(s)> <output psnr?>\n", |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 die_codec(&codec[0], "Failed to initialize encoder"); | 344 die_codec(&codec[0], "Failed to initialize encoder"); |
345 | 345 |
346 /* The extra encoding configuration parameters can be set as follows. */ | 346 /* The extra encoding configuration parameters can be set as follows. */ |
347 /* Set encoding speed */ | 347 /* Set encoding speed */ |
348 for ( i=0; i<NUM_ENCODERS; i++) | 348 for ( i=0; i<NUM_ENCODERS; i++) |
349 { | 349 { |
350 int speed = -6; | 350 int speed = -6; |
351 if(vpx_codec_control(&codec[i], VP8E_SET_CPUUSED, speed)) | 351 if(vpx_codec_control(&codec[i], VP8E_SET_CPUUSED, speed)) |
352 die_codec(&codec[i], "Failed to set cpu_used"); | 352 die_codec(&codec[i], "Failed to set cpu_used"); |
353 } | 353 } |
354 /* Set static thresh for highest-resolution encoder. Set it to 1000 for | 354 |
355 * better performance. */ | 355 /* Set static threshold. */ |
| 356 for ( i=0; i<NUM_ENCODERS; i++) |
356 { | 357 { |
357 unsigned int static_thresh = 1000; | 358 unsigned int static_thresh = 1; |
358 if(vpx_codec_control(&codec[0], VP8E_SET_STATIC_THRESHOLD, static_thresh
)) | |
359 die_codec(&codec[0], "Failed to set static threshold"); | |
360 } | |
361 /* Set static thresh = 0 for other encoders for better quality */ | |
362 for ( i=1; i<NUM_ENCODERS; i++) | |
363 { | |
364 unsigned int static_thresh = 0; | |
365 if(vpx_codec_control(&codec[i], VP8E_SET_STATIC_THRESHOLD, static_thresh
)) | 359 if(vpx_codec_control(&codec[i], VP8E_SET_STATIC_THRESHOLD, static_thresh
)) |
366 die_codec(&codec[i], "Failed to set static threshold"); | 360 die_codec(&codec[i], "Failed to set static threshold"); |
367 } | 361 } |
| 362 |
368 /* Set NOISE_SENSITIVITY to do TEMPORAL_DENOISING */ | 363 /* Set NOISE_SENSITIVITY to do TEMPORAL_DENOISING */ |
369 for ( i=0; i< NUM_ENCODERS; i++) | 364 /* Enable denoising for the highest-resolution encoder. */ |
| 365 if(vpx_codec_control(&codec[0], VP8E_SET_NOISE_SENSITIVITY, 1)) |
| 366 die_codec(&codec[0], "Failed to set noise_sensitivity"); |
| 367 for ( i=1; i< NUM_ENCODERS; i++) |
370 { | 368 { |
371 if(vpx_codec_control(&codec[i], VP8E_SET_NOISE_SENSITIVITY, 0)) | 369 if(vpx_codec_control(&codec[i], VP8E_SET_NOISE_SENSITIVITY, 0)) |
372 die_codec(&codec[i], "Failed to set noise_sensitivity"); | 370 die_codec(&codec[i], "Failed to set noise_sensitivity"); |
373 } | 371 } |
374 | 372 |
| 373 |
375 frame_avail = 1; | 374 frame_avail = 1; |
376 got_data = 0; | 375 got_data = 0; |
377 | 376 |
378 while(frame_avail || got_data) | 377 while(frame_avail || got_data) |
379 { | 378 { |
380 vpx_codec_iter_t iter[NUM_ENCODERS]={NULL}; | 379 vpx_codec_iter_t iter[NUM_ENCODERS]={NULL}; |
381 const vpx_codec_cx_pkt_t *pkt[NUM_ENCODERS]; | 380 const vpx_codec_cx_pkt_t *pkt[NUM_ENCODERS]; |
382 | 381 |
383 flags = 0; | 382 flags = 0; |
384 frame_avail = read_frame_p(infile, &raw[0]); | 383 frame_avail = read_frame_p(infile, &raw[0]); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 | 476 |
478 /* Try to rewrite the file header with the actual frame count */ | 477 /* Try to rewrite the file header with the actual frame count */ |
479 if(!fseek(outfile[i], 0, SEEK_SET)) | 478 if(!fseek(outfile[i], 0, SEEK_SET)) |
480 write_ivf_file_header(outfile[i], &cfg[i], frame_cnt-1); | 479 write_ivf_file_header(outfile[i], &cfg[i], frame_cnt-1); |
481 fclose(outfile[i]); | 480 fclose(outfile[i]); |
482 } | 481 } |
483 printf("\n"); | 482 printf("\n"); |
484 | 483 |
485 return EXIT_SUCCESS; | 484 return EXIT_SUCCESS; |
486 } | 485 } |
OLD | NEW |