| 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 |
| 11 | 11 |
| 12 #include "vpx_config.h" | 12 #include "vpx_config.h" |
| 13 #include "./vpx_scale_rtcd.h" | 13 #include "./vpx_scale_rtcd.h" |
| 14 #include "vp8/common/onyxc_int.h" | 14 #include "vp8/common/onyxc_int.h" |
| 15 #include "vp8/common/blockd.h" | 15 #include "vp8/common/blockd.h" |
| 16 #include "onyx_int.h" | 16 #include "onyx_int.h" |
| 17 #include "vp8/common/systemdependent.h" | 17 #include "vp8/common/systemdependent.h" |
| 18 #include "quantize.h" | 18 #include "quantize.h" |
| 19 #include "vp8/common/alloccommon.h" | 19 #include "vp8/common/alloccommon.h" |
| 20 #include "mcomp.h" | 20 #include "mcomp.h" |
| 21 #include "firstpass.h" | 21 #include "firstpass.h" |
| 22 #include "psnr.h" | 22 #include "vpx/internal/vpx_psnr.h" |
| 23 #include "vpx_scale/vpx_scale.h" | 23 #include "vpx_scale/vpx_scale.h" |
| 24 #include "vp8/common/extend.h" | 24 #include "vp8/common/extend.h" |
| 25 #include "ratectrl.h" | 25 #include "ratectrl.h" |
| 26 #include "vp8/common/quant_common.h" | 26 #include "vp8/common/quant_common.h" |
| 27 #include "segmentation.h" | 27 #include "segmentation.h" |
| 28 #if CONFIG_POSTPROC | 28 #if CONFIG_POSTPROC |
| 29 #include "vp8/common/postproc.h" | 29 #include "vp8/common/postproc.h" |
| 30 #endif | 30 #endif |
| 31 #include "vpx_mem/vpx_mem.h" | 31 #include "vpx_mem/vpx_mem.h" |
| 32 #include "vp8/common/swapyv12buffer.h" | 32 #include "vp8/common/swapyv12buffer.h" |
| (...skipping 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2163 int i; | 2163 int i; |
| 2164 | 2164 |
| 2165 fprintf(f, "Layer\tBitrate\tAVGPsnr\tGLBPsnr\tAVPsnrP\t" | 2165 fprintf(f, "Layer\tBitrate\tAVGPsnr\tGLBPsnr\tAVPsnrP\t" |
| 2166 "GLPsnrP\tVPXSSIM\t\n"); | 2166 "GLPsnrP\tVPXSSIM\t\n"); |
| 2167 for (i=0; i<(int)cpi->oxcf.number_of_layers; i++) | 2167 for (i=0; i<(int)cpi->oxcf.number_of_layers; i++) |
| 2168 { | 2168 { |
| 2169 double dr = (double)cpi->bytes_in_layer[i] * | 2169 double dr = (double)cpi->bytes_in_layer[i] * |
| 2170 8.0 / 1000.0 / time_encoded; | 2170 8.0 / 1000.0 / time_encoded; |
| 2171 double samples = 3.0 / 2 * cpi->frames_in_layer[i] * | 2171 double samples = 3.0 / 2 * cpi->frames_in_layer[i] * |
| 2172 lst_yv12->y_width * lst_yv12->y_height; | 2172 lst_yv12->y_width * lst_yv12->y_height; |
| 2173 double total_psnr = vp8_mse2psnr(samples, 255.0, | 2173 double total_psnr = |
| 2174 cpi->total_error2[i]); | 2174 vpx_sse_to_psnr(samples, 255.0, |
| 2175 double total_psnr2 = vp8_mse2psnr(samples, 255.0, | 2175 cpi->total_error2[i]); |
| 2176 cpi->total_error2_p[i]); | 2176 double total_psnr2 = |
| 2177 vpx_sse_to_psnr(samples, 255.0, |
| 2178 cpi->total_error2_p[i]); |
| 2177 double total_ssim = 100 * pow(cpi->sum_ssim[i] / | 2179 double total_ssim = 100 * pow(cpi->sum_ssim[i] / |
| 2178 cpi->sum_weights[i], 8.0); | 2180 cpi->sum_weights[i], 8.0); |
| 2179 | 2181 |
| 2180 fprintf(f, "%5d\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t" | 2182 fprintf(f, "%5d\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t" |
| 2181 "%7.3f\t%7.3f\n", | 2183 "%7.3f\t%7.3f\n", |
| 2182 i, dr, | 2184 i, dr, |
| 2183 cpi->sum_psnr[i] / cpi->frames_in_layer[i], | 2185 cpi->sum_psnr[i] / cpi->frames_in_layer[i], |
| 2184 total_psnr, | 2186 total_psnr, |
| 2185 cpi->sum_psnr_p[i] / cpi->frames_in_layer[i], | 2187 cpi->sum_psnr_p[i] / cpi->frames_in_layer[i], |
| 2186 total_psnr2, total_ssim); | 2188 total_psnr2, total_ssim); |
| 2187 } | 2189 } |
| 2188 } | 2190 } |
| 2189 else | 2191 else |
| 2190 { | 2192 { |
| 2191 double samples = 3.0 / 2 * cpi->count * | 2193 double samples = 3.0 / 2 * cpi->count * |
| 2192 lst_yv12->y_width * lst_yv12->y_height; | 2194 lst_yv12->y_width * lst_yv12->y_height; |
| 2193 double total_psnr = vp8_mse2psnr(samples, 255.0, | 2195 double total_psnr = vpx_sse_to_psnr(samples, 255.0, |
| 2194 cpi->total_sq_error); | 2196 cpi->total_sq_error); |
| 2195 double total_psnr2 = vp8_mse2psnr(samples, 255.0, | 2197 double total_psnr2 = vpx_sse_to_psnr(samples, 255.0, |
| 2196 cpi->total_sq_error2); | 2198 cpi->total_sq_error2); |
| 2197 double total_ssim = 100 * pow(cpi->summed_quality / | 2199 double total_ssim = 100 * pow(cpi->summed_quality / |
| 2198 cpi->summed_weights, 8.0); | 2200 cpi->summed_weights, 8.0); |
| 2199 | 2201 |
| 2200 fprintf(f, "Bitrate\tAVGPsnr\tGLBPsnr\tAVPsnrP\t" | 2202 fprintf(f, "Bitrate\tAVGPsnr\tGLBPsnr\tAVPsnrP\t" |
| 2201 "GLPsnrP\tVPXSSIM\t Time(us)\n"); | 2203 "GLPsnrP\tVPXSSIM\t Time(us)\n"); |
| 2202 fprintf(f, "%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t" | 2204 fprintf(f, "%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t" |
| 2203 "%7.3f\t%8.0f\n", | 2205 "%7.3f\t%8.0f\n", |
| 2204 dr, cpi->total / cpi->count, total_psnr, | 2206 dr, cpi->total / cpi->count, total_psnr, |
| 2205 cpi->totalp / cpi->count, total_psnr2, | 2207 cpi->totalp / cpi->count, total_psnr2, |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2515 | 2517 |
| 2516 sse = calc_plane_error(orig->v_buffer, orig->uv_stride, | 2518 sse = calc_plane_error(orig->v_buffer, orig->uv_stride, |
| 2517 recon->v_buffer, recon->uv_stride, | 2519 recon->v_buffer, recon->uv_stride, |
| 2518 width, height); | 2520 width, height); |
| 2519 pkt.data.psnr.sse[0] += sse; | 2521 pkt.data.psnr.sse[0] += sse; |
| 2520 pkt.data.psnr.sse[3] = sse; | 2522 pkt.data.psnr.sse[3] = sse; |
| 2521 pkt.data.psnr.samples[0] += width * height; | 2523 pkt.data.psnr.samples[0] += width * height; |
| 2522 pkt.data.psnr.samples[3] = width * height; | 2524 pkt.data.psnr.samples[3] = width * height; |
| 2523 | 2525 |
| 2524 for (i = 0; i < 4; i++) | 2526 for (i = 0; i < 4; i++) |
| 2525 pkt.data.psnr.psnr[i] = vp8_mse2psnr(pkt.data.psnr.samples[i], 255.0, | 2527 pkt.data.psnr.psnr[i] = vpx_sse_to_psnr(pkt.data.psnr.samples[i], 255.0, |
| 2526 (double)(pkt.data.psnr.sse[i])); | 2528 (double)(pkt.data.psnr.sse[i])); |
| 2527 | 2529 |
| 2528 vpx_codec_pkt_list_add(cpi->output_pkt_list, &pkt); | 2530 vpx_codec_pkt_list_add(cpi->output_pkt_list, &pkt); |
| 2529 } | 2531 } |
| 2530 | 2532 |
| 2531 | 2533 |
| 2532 int vp8_use_as_reference(VP8_COMP *cpi, int ref_frame_flags) | 2534 int vp8_use_as_reference(VP8_COMP *cpi, int ref_frame_flags) |
| 2533 { | 2535 { |
| 2534 if (ref_frame_flags > 7) | 2536 if (ref_frame_flags > 7) |
| 2535 return -1 ; | 2537 return -1 ; |
| 2536 | 2538 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2674 cpi->Source = sd; | 2676 cpi->Source = sd; |
| 2675 } | 2677 } |
| 2676 | 2678 |
| 2677 | 2679 |
| 2678 static int resize_key_frame(VP8_COMP *cpi) | 2680 static int resize_key_frame(VP8_COMP *cpi) |
| 2679 { | 2681 { |
| 2680 #if CONFIG_SPATIAL_RESAMPLING | 2682 #if CONFIG_SPATIAL_RESAMPLING |
| 2681 VP8_COMMON *cm = &cpi->common; | 2683 VP8_COMMON *cm = &cpi->common; |
| 2682 | 2684 |
| 2683 /* Do we need to apply resampling for one pass cbr. | 2685 /* Do we need to apply resampling for one pass cbr. |
| 2684 * In one pass this is more limited than in two pass cbr | 2686 * In one pass this is more limited than in two pass cbr. |
| 2685 * The test and any change is only made one per key frame sequence | 2687 * The test and any change is only made once per key frame sequence. |
| 2686 */ | 2688 */ |
| 2687 if (cpi->oxcf.allow_spatial_resampling && (cpi->oxcf.end_usage == USAGE_STRE
AM_FROM_SERVER)) | 2689 if (cpi->oxcf.allow_spatial_resampling && (cpi->oxcf.end_usage == USAGE_STRE
AM_FROM_SERVER)) |
| 2688 { | 2690 { |
| 2689 int UNINITIALIZED_IS_SAFE(hr), UNINITIALIZED_IS_SAFE(hs); | 2691 int UNINITIALIZED_IS_SAFE(hr), UNINITIALIZED_IS_SAFE(hs); |
| 2690 int UNINITIALIZED_IS_SAFE(vr), UNINITIALIZED_IS_SAFE(vs); | 2692 int UNINITIALIZED_IS_SAFE(vr), UNINITIALIZED_IS_SAFE(vs); |
| 2691 int new_width, new_height; | 2693 int new_width, new_height; |
| 2692 | 2694 |
| 2693 /* If we are below the resample DOWN watermark then scale down a | 2695 /* If we are below the resample DOWN watermark then scale down a |
| 2694 * notch. | 2696 * notch. |
| 2695 */ | 2697 */ |
| 2696 if (cpi->buffer_level < (cpi->oxcf.resample_down_water_mark * cpi->oxcf.
optimal_buffer_level / 100)) | 2698 if (cpi->buffer_level < (cpi->oxcf.resample_down_water_mark * cpi->oxcf.
optimal_buffer_level / 100)) |
| 2697 { | 2699 { |
| 2698 cm->horiz_scale = (cm->horiz_scale < ONETWO) ? cm->horiz_scale + 1 :
ONETWO; | 2700 cm->horiz_scale = (cm->horiz_scale < ONETWO) ? cm->horiz_scale + 1 :
ONETWO; |
| 2699 cm->vert_scale = (cm->vert_scale < ONETWO) ? cm->vert_scale + 1 : ON
ETWO; | 2701 cm->vert_scale = (cm->vert_scale < ONETWO) ? cm->vert_scale + 1 : ON
ETWO; |
| 2700 } | 2702 } |
| 2701 /* Should we now start scaling back up */ | 2703 /* Should we now start scaling back up */ |
| 2702 else if (cpi->buffer_level > (cpi->oxcf.resample_up_water_mark * cpi->ox
cf.optimal_buffer_level / 100)) | 2704 else if (cpi->buffer_level > (cpi->oxcf.resample_up_water_mark * cpi->ox
cf.optimal_buffer_level / 100)) |
| 2703 { | 2705 { |
| 2704 cm->horiz_scale = (cm->horiz_scale > NORMAL) ? cm->horiz_scale - 1 :
NORMAL; | 2706 cm->horiz_scale = (cm->horiz_scale > NORMAL) ? cm->horiz_scale - 1 :
NORMAL; |
| 2705 cm->vert_scale = (cm->vert_scale > NORMAL) ? cm->vert_scale - 1 : NO
RMAL; | 2707 cm->vert_scale = (cm->vert_scale > NORMAL) ? cm->vert_scale - 1 : NO
RMAL; |
| 2706 } | 2708 } |
| 2707 | 2709 |
| 2708 /* Get the new hieght and width */ | 2710 /* Get the new height and width */ |
| 2709 Scale2Ratio(cm->horiz_scale, &hr, &hs); | 2711 Scale2Ratio(cm->horiz_scale, &hr, &hs); |
| 2710 Scale2Ratio(cm->vert_scale, &vr, &vs); | 2712 Scale2Ratio(cm->vert_scale, &vr, &vs); |
| 2711 new_width = ((hs - 1) + (cpi->oxcf.Width * hr)) / hs; | 2713 new_width = ((hs - 1) + (cpi->oxcf.Width * hr)) / hs; |
| 2712 new_height = ((vs - 1) + (cpi->oxcf.Height * vr)) / vs; | 2714 new_height = ((vs - 1) + (cpi->oxcf.Height * vr)) / vs; |
| 2713 | 2715 |
| 2714 /* If the image size has changed we need to reallocate the buffers | 2716 /* If the image size has changed we need to reallocate the buffers |
| 2715 * and resample the source image | 2717 * and resample the source image |
| 2716 */ | 2718 */ |
| 2717 if ((cm->Width != new_width) || (cm->Height != new_height)) | 2719 if ((cm->Width != new_width) || (cm->Height != new_height)) |
| 2718 { | 2720 { |
| (...skipping 2558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5277 recon->y_buffer, recon->y_stride, orig->y_width, orig->y_heigh
t); | 5279 recon->y_buffer, recon->y_stride, orig->y_width, orig->y_heigh
t); |
| 5278 | 5280 |
| 5279 ue = calc_plane_error(orig->u_buffer, orig->uv_stride, | 5281 ue = calc_plane_error(orig->u_buffer, orig->uv_stride, |
| 5280 recon->u_buffer, recon->uv_stride, orig->uv_width, orig->uv_he
ight); | 5282 recon->u_buffer, recon->uv_stride, orig->uv_width, orig->uv_he
ight); |
| 5281 | 5283 |
| 5282 ve = calc_plane_error(orig->v_buffer, orig->uv_stride, | 5284 ve = calc_plane_error(orig->v_buffer, orig->uv_stride, |
| 5283 recon->v_buffer, recon->uv_stride, orig->uv_width, orig->uv_he
ight); | 5285 recon->v_buffer, recon->uv_stride, orig->uv_width, orig->uv_he
ight); |
| 5284 | 5286 |
| 5285 sq_error = (double)(ye + ue + ve); | 5287 sq_error = (double)(ye + ue + ve); |
| 5286 | 5288 |
| 5287 frame_psnr = vp8_mse2psnr(t_samples, 255.0, sq_error); | 5289 frame_psnr = vpx_sse_to_psnr(t_samples, 255.0, sq_error); |
| 5288 | 5290 |
| 5289 cpi->total_y += vp8_mse2psnr(y_samples, 255.0, (double)ye); | 5291 cpi->total_y += vpx_sse_to_psnr(y_samples, 255.0, (double)ye); |
| 5290 cpi->total_u += vp8_mse2psnr(uv_samples, 255.0, (double)ue); | 5292 cpi->total_u += vpx_sse_to_psnr(uv_samples, 255.0, (double)ue); |
| 5291 cpi->total_v += vp8_mse2psnr(uv_samples, 255.0, (double)ve); | 5293 cpi->total_v += vpx_sse_to_psnr(uv_samples, 255.0, (double)ve); |
| 5292 cpi->total_sq_error += sq_error; | 5294 cpi->total_sq_error += sq_error; |
| 5293 cpi->total += frame_psnr; | 5295 cpi->total += frame_psnr; |
| 5294 #if CONFIG_POSTPROC | 5296 #if CONFIG_POSTPROC |
| 5295 { | 5297 { |
| 5296 YV12_BUFFER_CONFIG *pp = &cm->post_proc_buffer; | 5298 YV12_BUFFER_CONFIG *pp = &cm->post_proc_buffer; |
| 5297 double frame_psnr2, frame_ssim2 = 0; | 5299 double frame_psnr2, frame_ssim2 = 0; |
| 5298 double weight = 0; | 5300 double weight = 0; |
| 5299 | 5301 |
| 5300 vp8_deblock(cm, cm->frame_to_show, &cm->post_proc_buffer, cm
->filter_level * 10 / 6, 1, 0); | 5302 vp8_deblock(cm, cm->frame_to_show, &cm->post_proc_buffer, cm
->filter_level * 10 / 6, 1, 0); |
| 5301 vp8_clear_system_state(); | 5303 vp8_clear_system_state(); |
| 5302 | 5304 |
| 5303 ye = calc_plane_error(orig->y_buffer, orig->y_stride, | 5305 ye = calc_plane_error(orig->y_buffer, orig->y_stride, |
| 5304 pp->y_buffer, pp->y_stride, orig->y_width, orig->y_height)
; | 5306 pp->y_buffer, pp->y_stride, orig->y_width, orig->y_height)
; |
| 5305 | 5307 |
| 5306 ue = calc_plane_error(orig->u_buffer, orig->uv_stride, | 5308 ue = calc_plane_error(orig->u_buffer, orig->uv_stride, |
| 5307 pp->u_buffer, pp->uv_stride, orig->uv_width, orig->uv_heig
ht); | 5309 pp->u_buffer, pp->uv_stride, orig->uv_width, orig->uv_heig
ht); |
| 5308 | 5310 |
| 5309 ve = calc_plane_error(orig->v_buffer, orig->uv_stride, | 5311 ve = calc_plane_error(orig->v_buffer, orig->uv_stride, |
| 5310 pp->v_buffer, pp->uv_stride, orig->uv_width, orig->uv_heig
ht); | 5312 pp->v_buffer, pp->uv_stride, orig->uv_width, orig->uv_heig
ht); |
| 5311 | 5313 |
| 5312 sq_error2 = (double)(ye + ue + ve); | 5314 sq_error2 = (double)(ye + ue + ve); |
| 5313 | 5315 |
| 5314 frame_psnr2 = vp8_mse2psnr(t_samples, 255.0, sq_error2); | 5316 frame_psnr2 = vpx_sse_to_psnr(t_samples, 255.0, sq_error2); |
| 5315 | 5317 |
| 5316 cpi->totalp_y += vp8_mse2psnr(y_samples, | 5318 cpi->totalp_y += vpx_sse_to_psnr(y_samples, |
| 5317 255.0, (double)ye); | 5319 255.0, (double)ye); |
| 5318 cpi->totalp_u += vp8_mse2psnr(uv_samples, | 5320 cpi->totalp_u += vpx_sse_to_psnr(uv_samples, |
| 5319 255.0, (double)ue); | 5321 255.0, (double)ue); |
| 5320 cpi->totalp_v += vp8_mse2psnr(uv_samples, | 5322 cpi->totalp_v += vpx_sse_to_psnr(uv_samples, |
| 5321 255.0, (double)ve); | 5323 255.0, (double)ve); |
| 5322 cpi->total_sq_error2 += sq_error2; | 5324 cpi->total_sq_error2 += sq_error2; |
| 5323 cpi->totalp += frame_psnr2; | 5325 cpi->totalp += frame_psnr2; |
| 5324 | 5326 |
| 5325 frame_ssim2 = vp8_calc_ssim(cpi->Source, | 5327 frame_ssim2 = vp8_calc_ssim(cpi->Source, |
| 5326 &cm->post_proc_buffer, 1, &weight); | 5328 &cm->post_proc_buffer, 1, &weight); |
| 5327 | 5329 |
| 5328 cpi->summed_quality += frame_ssim2 * weight; | 5330 cpi->summed_quality += frame_ssim2 * weight; |
| 5329 cpi->summed_weights += weight; | 5331 cpi->summed_weights += weight; |
| 5330 | 5332 |
| 5331 if (cpi->oxcf.number_of_layers > 1) | 5333 if (cpi->oxcf.number_of_layers > 1) |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5590 } | 5592 } |
| 5591 | 5593 |
| 5592 return Total; | 5594 return Total; |
| 5593 } | 5595 } |
| 5594 | 5596 |
| 5595 | 5597 |
| 5596 int vp8_get_quantizer(VP8_COMP *cpi) | 5598 int vp8_get_quantizer(VP8_COMP *cpi) |
| 5597 { | 5599 { |
| 5598 return cpi->common.base_qindex; | 5600 return cpi->common.base_qindex; |
| 5599 } | 5601 } |
| OLD | NEW |