From 22dcecd3d87149c416bc0258920d78db8048de58 Mon Sep 17 00:00:00 2001 From: Jerome Jiang Date: Wed, 6 Jun 2018 15:44:01 -0700 Subject: [PATCH] VP9 SVC: Write out svc src for all spatial layers. Change-Id: Ie78676e4df75f3f870ee2de0c87a8167b7ec68e0 --- vp9/encoder/vp9_encoder.c | 19 +++++++++++++++++++ vpx_util/vpx_write_yuv_frame.c | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index fca8f331d..a1c48e28e 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -84,6 +84,9 @@ static FILE *yuv_skinmap_file = NULL; #ifdef OUTPUT_YUV_REC FILE *yuv_rec_file; #endif +#ifdef OUTPUT_YUV_SVC_SRC +FILE *yuv_svc_src[3] = { NULL, NULL, NULL }; +#endif #if 0 FILE *framepsnr; @@ -2250,6 +2253,11 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf, #ifdef OUTPUT_YUV_REC yuv_rec_file = fopen("rec.yuv", "wb"); #endif +#ifdef OUTPUT_YUV_SVC_SRC + yuv_svc_src[0] = fopen("svc_src_0.yuv", "wb"); + yuv_svc_src[1] = fopen("svc_src_1.yuv", "wb"); + yuv_svc_src[2] = fopen("svc_src_2.yuv", "wb"); +#endif #if 0 framepsnr = fopen("framepsnr.stt", "a"); @@ -2568,6 +2576,11 @@ void vp9_remove_compressor(VP9_COMP *cpi) { #ifdef OUTPUT_YUV_REC fclose(yuv_rec_file); #endif +#ifdef OUTPUT_YUV_SVC_SRC + fclose(yuv_svc_src[0]); + fclose(yuv_svc_src[1]); + fclose(yuv_svc_src[2]); +#endif #if 0 @@ -3661,6 +3674,12 @@ static int encode_without_recode_loop(VP9_COMP *cpi, size_t *size, cm, cpi->un_scaled_source, &cpi->scaled_source, (cpi->oxcf.pass == 0), filter_scaler, phase_scaler); } +#ifdef OUTPUT_YUV_SVC_SRC + // Write out at most 3 spatial layers. + if (is_one_pass_cbr_svc(cpi) && cpi->svc.spatial_layer_id < 3) { + vpx_write_yuv_frame(yuv_svc_src[cpi->svc.spatial_layer_id], cpi->Source); + } +#endif // Unfiltered raw source used in metrics calculation if the source // has been filtered. if (is_psnr_calc_enabled(cpi)) { diff --git a/vpx_util/vpx_write_yuv_frame.c b/vpx_util/vpx_write_yuv_frame.c index ab6855811..4ef57a2fe 100644 --- a/vpx_util/vpx_write_yuv_frame.c +++ b/vpx_util/vpx_write_yuv_frame.c @@ -13,7 +13,7 @@ void vpx_write_yuv_frame(FILE *yuv_file, YV12_BUFFER_CONFIG *s) { #if defined(OUTPUT_YUV_SRC) || defined(OUTPUT_YUV_DENOISED) || \ - defined(OUTPUT_YUV_SKINMAP) + defined(OUTPUT_YUV_SKINMAP) || defined(OUTPUT_YUV_SVC_SRC) unsigned char *src = s->y_buffer; int h = s->y_crop_height; -- 2.40.0