diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-03-24 17:26:17 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-03-24 17:26:17 +0400 |
commit | c08e523586b6be36bee3f73d609733cd80a57674 (patch) | |
tree | 5d728f8f5c8647e7ffe3197c25875a1b3dee380d /libavcodec/utils.c | |
parent | 83e89787984d3f96cb793ebfddc6078d6bc50073 (diff) | |
parent | 4a0f6651434c6f213d830140f575b4ec7858519f (diff) |
Merge commit '4a0f6651434c6f213d830140f575b4ec7858519f'
* commit '4a0f6651434c6f213d830140f575b4ec7858519f':
libavcodec: when decoding, copy replaygain side data to decoded frames
Conflicts:
libavcodec/internal.h
libavcodec/rawdec.c
libavcodec/utils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r-- | libavcodec/utils.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 7ffe6c6524..e7cca9646e 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -827,6 +827,35 @@ static void compat_release_buffer(void *opaque, uint8_t *data) FF_ENABLE_DEPRECATION_WARNINGS #endif +int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) +{ + AVPacket *pkt = avctx->internal->pkt; + uint8_t *packet_sd; + int size; + AVFrameSideData *frame_sd; + + + frame->reordered_opaque = avctx->reordered_opaque; + if (!pkt) { + frame->pkt_pts = AV_NOPTS_VALUE; + return 0; + } + + frame->pkt_pts = pkt->pts; + + /* copy the replaygain data to the output frame */ + packet_sd = av_packet_get_side_data(pkt, AV_PKT_DATA_REPLAYGAIN, &size); + if (packet_sd) { + frame_sd = av_frame_new_side_data(frame, AV_FRAME_DATA_REPLAYGAIN, size); + if (!frame_sd) + return AVERROR(ENOMEM); + + memcpy(frame_sd->data, packet_sd, size); + } + + return 0; +} + static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags) { int override_dimensions = 1; @@ -845,6 +874,9 @@ static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags) override_dimensions = 0; } } + ret = ff_decode_frame_props(avctx, frame); + if (ret < 0) + return ret; if ((ret = ff_init_buffer_info(avctx, frame)) < 0) return ret; @@ -1001,11 +1033,8 @@ static int reget_buffer_internal(AVCodecContext *avctx, AVFrame *frame) if (!frame->data[0]) return ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF); - if (av_frame_is_writable(frame)) { - frame->pkt_pts = avctx->internal->pkt ? avctx->internal->pkt->pts : AV_NOPTS_VALUE; - frame->reordered_opaque = avctx->reordered_opaque; - return 0; - } + if (av_frame_is_writable(frame)) + return ff_decode_frame_props(avctx, frame); tmp = av_frame_alloc(); if (!tmp) |