Return the original picture from encoder_encode.

This commit is contained in:
Arttu Ylä-Outinen 2015-09-09 11:21:39 +03:00
parent afd0d3eee0
commit efd361ee8e
4 changed files with 14 additions and 8 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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_