History

Pack psnr pkt outside of vp9_get_compressed_data

angiebird committed 7 years ago

Commit 76cdfe21 parent 8eb69623 files · +33 −21Browse files

Unified · Split

3 files
  1. vp9/encoder/vp9_encoder.c +11 −21
  2. vp9/encoder/vp9_encoder.h +3 −0
  3. vp9/vp9_cx_iface.c +19 −0
vp9/encoder/vp9_encoder.c+11−21
@@ -460,8 +460,8 @@ static int compute_context_model_diff(const VP9_COMMON *const cm) { · 459 unmodified lines
460#endif // !CONFIG_REALTIME_ONLY460#endif // !CONFIG_REALTIME_ONLY
461 461
462// Test for whether to calculate metrics for the frame.462// Test for whether to calculate metrics for the frame.
463static int is_psnr_calc_enabled(VP9_COMP *cpi) {463static int is_psnr_calc_enabled(const VP9_COMP *cpi) {
464 VP9_COMMON *const cm = &cpi->common;464 const VP9_COMMON *const cm = &cpi->common;
465 const VP9EncoderConfig *const oxcf = &cpi->oxcf;465 const VP9EncoderConfig *const oxcf = &cpi->oxcf;
466 466
467 return cpi->b_calculate_psnr && (oxcf->pass != 1) && cm->show_frame;467 return cpi->b_calculate_psnr && (oxcf->pass != 1) && cm->show_frame;
@@ -2761,25 +2761,18 @@ void vp9_remove_compressor(VP9_COMP *cpi) { · 2293 unmodified lines
2761#endif2761#endif
2762}2762}
2763 2763
2764static void generate_psnr_packet(VP9_COMP *cpi) {2764int vp9_get_psnr(const VP9_COMP *cpi, PSNR_STATS *psnr) {
2765 struct vpx_codec_cx_pkt pkt;2765 if (is_psnr_calc_enabled(cpi)) {
2766 int i;
2767 PSNR_STATS psnr;
2768#if CONFIG_VP9_HIGHBITDEPTH2766#if CONFIG_VP9_HIGHBITDEPTH
2769 vpx_calc_highbd_psnr(cpi->raw_source_frame, cpi->common.frame_to_show, &psnr,2767 vpx_calc_highbd_psnr(cpi->raw_source_frame, cpi->common.frame_to_show, psnr,
2770 cpi->td.mb.e_mbd.bd, cpi->oxcf.input_bit_depth);2768 cpi->td.mb.e_mbd.bd, cpi->oxcf.input_bit_depth);
2771#else2769#else
2772 vpx_calc_psnr(cpi->raw_source_frame, cpi->common.frame_to_show, &psnr);2770 vpx_calc_psnr(cpi->raw_source_frame, cpi->common.frame_to_show, psnr);
2773#endif2771#endif
2774 2772 return 1;
2775 for (i = 0; i < 4; ++i) {2773 } else {
2776 pkt.data.psnr.samples[i] = psnr.samples[i];2774 vp9_zero(*psnr);
2777 pkt.data.psnr.sse[i] = psnr.sse[i];2775 return 0;
2778 pkt.data.psnr.psnr[i] = psnr.psnr[i];
2779 }
2780 pkt.kind = VPX_CODEC_PSNR_PKT;
2781 if (!cpi->use_svc) {
2782 vpx_codec_pkt_list_add(cpi->output_pkt_list, &pkt);
2783 }2776 }
2784}2777}
2785 2778
@@ -7358,9 +7351,6 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, · 4572 unmodified lines
7358 vpx_usec_timer_mark(&cmptimer);7351 vpx_usec_timer_mark(&cmptimer);
7359 cpi->time_compress_data += vpx_usec_timer_elapsed(&cmptimer);7352 cpi->time_compress_data += vpx_usec_timer_elapsed(&cmptimer);
7360 7353
7361 // Should we calculate metrics for the frame.
7362 if (is_psnr_calc_enabled(cpi)) generate_psnr_packet(cpi);
7363
7364 if (cpi->keep_level_stats && oxcf->pass != 1)7354 if (cpi->keep_level_stats && oxcf->pass != 1)
7365 update_level_info(cpi, size, arf_src_index);7355 update_level_info(cpi, size, arf_src_index);
7366 7356
vp9/encoder/vp9_encoder.h+3−0
@@ -20,6 +20,7 @@ · 19 unmodified lines
20#include "vpx_dsp/ssim.h"20#include "vpx_dsp/ssim.h"
21#endif21#endif
22#include "vpx_dsp/variance.h"22#include "vpx_dsp/variance.h"
23#include "vpx_dsp/psnr.h"
23#include "vpx_ports/system_state.h"24#include "vpx_ports/system_state.h"
24#include "vpx_util/vpx_thread.h"25#include "vpx_util/vpx_thread.h"
25#include "vpx_util/vpx_timestamp.h"26#include "vpx_util/vpx_timestamp.h"
@@ -1063,6 +1064,8 @@ void vp9_new_framerate(VP9_COMP *cpi, double framerate); · 1037 unmodified lines
1063 1064
1064void vp9_set_row_mt(VP9_COMP *cpi);1065void vp9_set_row_mt(VP9_COMP *cpi);
1065 1066
1067int vp9_get_psnr(const VP9_COMP *cpi, PSNR_STATS *psnr);
1068
1066#define LAYER_IDS_TO_IDX(sl, tl, num_tl) ((sl) * (num_tl) + (tl))1069#define LAYER_IDS_TO_IDX(sl, tl, num_tl) ((sl) * (num_tl) + (tl))
1067 1070
1068#ifdef __cplusplus1071#ifdef __cplusplus
vp9/vp9_cx_iface.c+19−0
@@ -13,6 +13,7 @@ · 12 unmodified lines
13 13
14#include "./vpx_config.h"14#include "./vpx_config.h"
15#include "vpx/vpx_encoder.h"15#include "vpx/vpx_encoder.h"
16#include "vpx_dsp/psnr.h"
16#include "vpx_ports/vpx_once.h"17#include "vpx_ports/vpx_once.h"
17#include "vpx_ports/system_state.h"18#include "vpx_ports/system_state.h"
18#include "vpx_util/vpx_timestamp.h"19#include "vpx_util/vpx_timestamp.h"
@@ -1117,6 +1118,13 @@ static vpx_codec_frame_flags_t get_frame_pkt_flags(const VP9_COMP *cpi, · 1098 unmodified lines
1117 return flags;1118 return flags;
1118}1119}
1119 1120
1121static INLINE vpx_codec_cx_pkt_t get_psnr_pkt(const PSNR_STATS *psnr) {
1122 vpx_codec_cx_pkt_t pkt;
1123 pkt.kind = VPX_CODEC_PSNR_PKT;
1124 pkt.data.psnr = *psnr;
1125 return pkt;
1126}
1127
1120const size_t kMinCompressedSize = 8192;1128const size_t kMinCompressedSize = 8192;
1121static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,1129static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx,
1122 const vpx_image_t *img,1130 const vpx_image_t *img,
@@ -1240,6 +1248,17 @@ static vpx_codec_err_t encoder_encode(vpx_codec_alg_priv_t *ctx, · 117 unmodified lines
1240 -1 != vp9_get_compressed_data(cpi, &lib_flags, &size, cx_data,1248 -1 != vp9_get_compressed_data(cpi, &lib_flags, &size, cx_data,
1241 &dst_time_stamp, &dst_end_time_stamp,1249 &dst_time_stamp, &dst_end_time_stamp,
1242 !img)) {1250 !img)) {
1251 // Pack psnr pkt
1252 if (size > 0 && !cpi->use_svc) {
1253 // TODO(angiebird): Figure out why we don't need psnr pkt when use_svc
1254 // is on
1255 PSNR_STATS psnr;
1256 if (vp9_get_psnr(cpi, &psnr)) {
1257 vpx_codec_cx_pkt_t psnr_pkt = get_psnr_pkt(&psnr);
1258 vpx_codec_pkt_list_add(&ctx->pkt_list.head, &psnr_pkt);
1259 }
1260 }
1261
1243 if (size || (cpi->use_svc && cpi->svc.skip_enhancement_layer)) {1262 if (size || (cpi->use_svc && cpi->svc.skip_enhancement_layer)) {
1244 // Pack invisible frames with the next visible frame1263 // Pack invisible frames with the next visible frame
1245 if (!cpi->common.show_frame ||1264 if (!cpi->common.show_frame ||

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t