VP9 SVC: Write bitstream for each spatial layer in sample.

Added control for denoiser in the sample SVC encoder.

Change-Id: I8e62aa2fc13a943eb110cb33e419e912a898bbc7
This commit is contained in:
Jerome Jiang 2018-03-30 14:15:06 -07:00
parent 4127799a91
commit 1d6f930517

View File

@ -632,7 +632,7 @@ int main(int argc, const char **argv) {
int end_of_stream = 0; int end_of_stream = 0;
int frames_received = 0; int frames_received = 0;
#if OUTPUT_RC_STATS #if OUTPUT_RC_STATS
VpxVideoWriter *outfile[VPX_TS_MAX_LAYERS] = { NULL }; VpxVideoWriter *outfile[VPX_SS_MAX_LAYERS] = { NULL };
struct RateControlStats rc; struct RateControlStats rc;
vpx_svc_layer_id_t layer_id; vpx_svc_layer_id_t layer_id;
vpx_svc_ref_frame_config_t ref_frame_config; vpx_svc_ref_frame_config_t ref_frame_config;
@ -644,6 +644,8 @@ int main(int argc, const char **argv) {
struct vpx_usec_timer timer; struct vpx_usec_timer timer;
int64_t cx_time = 0; int64_t cx_time = 0;
memset(&svc_ctx, 0, sizeof(svc_ctx)); memset(&svc_ctx, 0, sizeof(svc_ctx));
memset(&app_input, 0, sizeof(AppInput));
memset(&info, 0, sizeof(VpxVideoInfo));
exec_name = argv[0]; exec_name = argv[0];
parse_command_line(argc, argv, &app_input, &svc_ctx, &enc_cfg); parse_command_line(argc, argv, &app_input, &svc_ctx, &enc_cfg);
@ -692,16 +694,16 @@ int main(int argc, const char **argv) {
die("Failed to open %s for writing\n", app_input.output_filename); die("Failed to open %s for writing\n", app_input.output_filename);
} }
#if OUTPUT_RC_STATS #if OUTPUT_RC_STATS
// For now, just write temporal layer streams. // Write out spatial layer stream.
// TODO(marpan): do spatial by re-writing superframe. // TODO(marpan/jianj): allow for writing each spatial and temporal stream.
if (svc_ctx.output_rc_stat) { if (svc_ctx.output_rc_stat) {
for (tl = 0; tl < enc_cfg.ts_number_layers; ++tl) { for (sl = 0; sl < enc_cfg.ss_number_layers; ++sl) {
char file_name[PATH_MAX]; char file_name[PATH_MAX];
snprintf(file_name, sizeof(file_name), "%s_t%d.ivf", snprintf(file_name, sizeof(file_name), "%s_s%d.ivf",
app_input.output_filename, tl); app_input.output_filename, sl);
outfile[tl] = vpx_video_writer_open(file_name, kContainerIVF, &info); outfile[sl] = vpx_video_writer_open(file_name, kContainerIVF, &info);
if (!outfile[tl]) die("Failed to open %s for writing", file_name); if (!outfile[sl]) die("Failed to open %s for writing", file_name);
} }
} }
#endif #endif
@ -726,6 +728,8 @@ int main(int argc, const char **argv) {
vpx_codec_control(&codec, VP9E_SET_SVC_INTER_LAYER_PRED, 0); vpx_codec_control(&codec, VP9E_SET_SVC_INTER_LAYER_PRED, 0);
vpx_codec_control(&codec, VP9E_SET_NOISE_SENSITIVITY, 0);
// Encode frames // Encode frames
while (!end_of_stream) { while (!end_of_stream) {
vpx_codec_iter_t iter = NULL; vpx_codec_iter_t iter = NULL;
@ -800,6 +804,7 @@ int main(int argc, const char **argv) {
uint64_t sizes[8]; uint64_t sizes[8];
uint64_t sizes_parsed[8]; uint64_t sizes_parsed[8];
int count = 0; int count = 0;
int tot_size = 0;
vp9_zero(sizes); vp9_zero(sizes);
vp9_zero(sizes_parsed); vp9_zero(sizes_parsed);
#endif #endif
@ -825,14 +830,16 @@ int main(int argc, const char **argv) {
num_layers_encoded++; num_layers_encoded++;
} }
} }
} tot_size = 0;
for (tl = layer_id.temporal_layer_id; for (sl = 0; sl < enc_cfg.ss_number_layers; ++sl) {
tl < enc_cfg.ts_number_layers; ++tl) { if (cx_pkt->data.frame.spatial_layer_encoded[sl]) {
tot_size += sizes[sl];
vpx_video_writer_write_frame( vpx_video_writer_write_frame(
outfile[tl], cx_pkt->data.frame.buf, cx_pkt->data.frame.sz, outfile[sl], cx_pkt->data.frame.buf, tot_size,
cx_pkt->data.frame.pts); cx_pkt->data.frame.pts);
} }
}
}
for (sl = 0; sl < enc_cfg.ss_number_layers; ++sl) { for (sl = 0; sl < enc_cfg.ss_number_layers; ++sl) {
if (cx_pkt->data.frame.spatial_layer_encoded[sl]) { if (cx_pkt->data.frame.spatial_layer_encoded[sl]) {
for (tl = layer_id.temporal_layer_id; for (tl = layer_id.temporal_layer_id;
@ -941,8 +948,8 @@ int main(int argc, const char **argv) {
} }
#if OUTPUT_RC_STATS #if OUTPUT_RC_STATS
if (svc_ctx.output_rc_stat) { if (svc_ctx.output_rc_stat) {
for (tl = 0; tl < enc_cfg.ts_number_layers; ++tl) { for (sl = 0; sl < enc_cfg.ss_number_layers; ++sl) {
vpx_video_writer_close(outfile[tl]); vpx_video_writer_close(outfile[sl]);
} }
} }
#endif #endif