diff --git a/src/encmain.c b/src/encmain.c index 0bd39731..7e6b038d 100644 --- a/src/encmain.c +++ b/src/encmain.c @@ -154,6 +154,9 @@ int main(int argc, char *argv[]) init_encoder_input(&encoder->in, input, cfg->width, cfg->height); + // Init coeff data table + encoder->in.cur_pic->coeff = MALLOC(coefficient, cfg->width * cfg->height); + // Start coding cycle while data on input and not on the last frame while(!feof(input) && (!cfg->frames || encoder->frame < cfg->frames)) { int32_t diff; @@ -202,6 +205,10 @@ int main(int argc, char *argv[]) // TODO: reuse memory from old reference encoder->in.cur_pic = picture_init(encoder->in.width, encoder->in.height, encoder->in.width_in_lcu, encoder->in.height_in_lcu); + // Copy pointer from the last cur_pic because we don't want to reallocate it + encoder->in.cur_pic->coeff = encoder->ref->pics[0]->coeff; + encoder->ref->pics[0]->coeff = NULL; + encoder->frame++; } // Coding finished diff --git a/src/picture.c b/src/picture.c index 9b77d23c..5e89aa7b 100644 --- a/src/picture.c +++ b/src/picture.c @@ -244,6 +244,8 @@ picture *picture_init(int32_t width, int32_t height, memset(pic->cu_array[i], 0, sizeof(cu_info) * cu_array_size); } + pic->coeff = NULL; + return pic; } @@ -275,6 +277,9 @@ int picture_destroy(picture *pic) free(pic->cu_array); pic->cu_array = NULL; + free(pic->coeff); + pic->coeff = NULL; + return 1; } diff --git a/src/picture.h b/src/picture.h index 764d621c..9cf4d65d 100644 --- a/src/picture.h +++ b/src/picture.h @@ -73,6 +73,8 @@ typedef struct pixel* u_recdata; // \brief Pointer to reconstructed U-data. pixel* v_recdata; // \brief Pointer to reconstructed V-data. + coefficient* coeff; //!< \brief coefficient pointer + int32_t width; // \brief Luma pixel array width. int32_t height; // \brief Luma pixel array height. int32_t height_in_lcu; // \brief Picture width in number of LCU's.