From eacad83ff935ac4c9ae96fabdd9abc6ebb58e8a6 Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Wed, 19 Mar 2014 13:23:41 +0200 Subject: [PATCH] Fix encoder reconstruction output for non multiple of 8 sized input. Output changed so that only pixels within the conformance window are output. --- src/encmain.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/encmain.c b/src/encmain.c index 1d4c9b7d..236d5b87 100644 --- a/src/encmain.c +++ b/src/encmain.c @@ -302,10 +302,26 @@ int main(int argc, char *argv[]) encode_one_frame(encoder); if (cfg->debug != NULL) { - // Write reconstructed frame out (for debugging purposes) - fwrite(encoder->in.cur_pic->y_recdata, cfg->width * cfg->height, 1, recout); - fwrite(encoder->in.cur_pic->u_recdata, (cfg->width * cfg->height)>>2, 1, recout); - fwrite(encoder->in.cur_pic->v_recdata, (cfg->width * cfg->height)>>2, 1, recout); + // Write reconstructed frame out. + // Use conformance-window dimensions instead of internal ones. + const int width = encoder->in.width; + const int height = encoder->in.height; + const int out_width = encoder->in.real_width; + const int out_height = encoder->in.real_height; + int y; + const pixel *y_rec = encoder->in.cur_pic->y_recdata; + const pixel *u_rec = encoder->in.cur_pic->u_recdata; + const pixel *v_rec = encoder->in.cur_pic->v_recdata; + + for (y = 0; y < out_height; ++y) { + fwrite(&y_rec[y * width], sizeof(*y_rec), out_width, recout); + } + for (y = 0; y < out_height / 2; ++y) { + fwrite(&u_rec[y * width / 2], sizeof(*u_rec), out_width / 2, recout); + } + for (y = 0; y < out_height / 2; ++y) { + fwrite(&v_rec[y * width / 2], sizeof(*v_rec), out_width / 2, recout); + } } // Calculate the bytes pushed to output for this frame