From efd361ee8ed424e788c9a13905671341ececef47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Wed, 9 Sep 2015 11:21:39 +0300 Subject: [PATCH] Return the original picture from encoder_encode. --- src/encmain.c | 2 +- src/kvazaar.c | 3 +++ src/kvazaar.h | 15 +++++++++------ src/kvazaar_version.h | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/encmain.c b/src/encmain.c index 170be23c..2ee58c26 100644 --- a/src/encmain.c +++ b/src/encmain.c @@ -213,7 +213,7 @@ int main(int argc, char *argv[]) kvz_picture *img_rec = NULL; uint32_t len_out = 0; kvz_frame_info info_out; - if (!api->encoder_encode(enc, img_in, &chunks_out, &len_out, &img_rec, &info_out)) { + if (!api->encoder_encode(enc, img_in, &chunks_out, &len_out, &img_rec, NULL, &info_out)) { fprintf(stderr, "Failed to encode image.\n"); api->picture_free(img_in); goto exit_failure; diff --git a/src/kvazaar.c b/src/kvazaar.c index 7d6c48b3..59d24d05 100644 --- a/src/kvazaar.c +++ b/src/kvazaar.c @@ -127,11 +127,13 @@ static int kvazaar_encode(kvz_encoder *enc, kvz_data_chunk **data_out, uint32_t *len_out, kvz_picture **pic_out, + kvz_picture **src_out, kvz_frame_info *info_out) { if (data_out) *data_out = NULL; if (len_out) *len_out = 0; if (pic_out) *pic_out = NULL; + if (src_out) *src_out = NULL; encoder_state_t *state = &enc->states[enc->cur_state_num]; @@ -174,6 +176,7 @@ static int kvazaar_encode(kvz_encoder *enc, if (len_out) *len_out = kvz_bitstream_tell(&output_state->stream) / 8; if (data_out) *data_out = kvz_bitstream_take_chunks(&output_state->stream); if (pic_out) *pic_out = kvz_image_copy_ref(output_state->tile->frame->rec); + if (src_out) *src_out = kvz_image_copy_ref(output_state->tile->frame->source); if (info_out) set_frame_info(info_out, output_state); output_state->frame_done = 1; diff --git a/src/kvazaar.h b/src/kvazaar.h index d46db10e..a0939d24 100644 --- a/src/kvazaar.h +++ b/src/kvazaar.h @@ -344,9 +344,9 @@ typedef struct kvz_api { * \brief Encode one frame. * * Add pic_in to the encoding pipeline. If an encoded frame is ready, return - * the bitstream, length of the bitstream, the reconstructed frame and frame - * info in data_out, len_out, pic_out and info_out, respectively. Otherwise, - * set the output parameters to NULL. + * the bitstream, length of the bitstream, the reconstructed frame, the + * original frame and frame info in data_out, len_out, pic_out, src_out and + * info_out, respectively. Otherwise, set the output parameters to NULL. * * After passing all of the input frames, the caller should keep calling this * function with pic_in set to NULL, until no more data is returned in the @@ -354,17 +354,19 @@ typedef struct kvz_api { * * The caller must not modify pic_in after passing it to this function. * - * If pic_out and data_out are set to non-NULL values, the caller is - * responsible for calling picture_free and chunk_free on them. + * If data_out, pic_out and src_out are set to non-NULL values, the caller is + * responsible for calling chunk_free and picture_free on them. * * A null pointer may be passed in place of any of the parameters data_out, - * len_out, pic_out or info_out to skip returning the corresponding value. + * len_out, pic_out, src_out or info_out to skip returning the corresponding + * value. * * \param encoder encoder * \param pic_in input frame or NULL * \param data_out Returns the encoded data. * \param len_out Returns number of bytes in the encoded data. * \param pic_out Returns the reconstructed picture. + * \param src_out Returns the original picture. * \param info_out Returns information about the encoded picture. * \return 1 on success, 0 on error. */ @@ -373,6 +375,7 @@ typedef struct kvz_api { kvz_data_chunk **data_out, uint32_t *len_out, kvz_picture **pic_out, + kvz_picture **src_out, kvz_frame_info *info_out); } kvz_api; diff --git a/src/kvazaar_version.h b/src/kvazaar_version.h index 8584c4ae..9f4d2453 100644 --- a/src/kvazaar_version.h +++ b/src/kvazaar_version.h @@ -21,6 +21,6 @@ ****************************************************************************/ // KVZ_API_VERSION is incremented every time the public api changes. -#define KVZ_API_VERSION 6 +#define KVZ_API_VERSION 7 #endif // KVAZAAR_VERSION_H_