avcodec/wavpack: use av_buffer_replace() to simplify code

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Gil Pedersen <git@gpost.dk>
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
Gil Pedersen 2020-11-18 13:05:16 +00:00 committed by James Almer
parent 381ab69042
commit abcca6a055
1 changed files with 3 additions and 4 deletions

View File

@ -1024,13 +1024,12 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
return ret;
}
av_buffer_unref(&fdst->dsd_ref);
fdst->dsdctx = NULL;
fdst->dsd_channels = 0;
ret = av_buffer_replace(&fdst->dsd_ref, fsrc->dsd_ref);
if (ret < 0)
return ret;
if (fsrc->dsd_ref) {
fdst->dsd_ref = av_buffer_ref(fsrc->dsd_ref);
if (!fdst->dsd_ref)
return AVERROR(ENOMEM);
fdst->dsdctx = (DSDContext*)fdst->dsd_ref->data;
fdst->dsd_channels = fsrc->dsd_channels;
}