diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-11-10 00:57:41 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-11-10 00:57:41 +0100 |
commit | 0960cc4cc60fa39a1de19f8f744274becb164bef (patch) | |
tree | 67e37ab27000ee923b1e12666a93d38b06f27961 | |
parent | b546023b9319cbaefb638a2eeac56bdbf53d6f8b (diff) | |
parent | e3e317e0c015b164b6c2eb8913e393216d78de23 (diff) | |
download | ffmpeg-0960cc4cc60fa39a1de19f8f744274becb164bef.tar.gz |
Merge commit 'e3e317e0c015b164b6c2eb8913e393216d78de23'
* commit 'e3e317e0c015b164b6c2eb8913e393216d78de23':
lavc: Compact the side-data passthrough
Conflicts:
libavcodec/utils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/utils.c | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 5c7885ac07..0ab8688f38 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -735,44 +735,34 @@ FF_ENABLE_DEPRECATION_WARNINGS int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame) { AVPacket *pkt = avctx->internal->pkt; + int i; + struct { + enum AVPacketSideDataType packet; + enum AVFrameSideDataType frame; + } sd[] = { + { AV_PKT_DATA_REPLAYGAIN , AV_FRAME_DATA_REPLAYGAIN }, + { AV_PKT_DATA_DISPLAYMATRIX, AV_FRAME_DATA_DISPLAYMATRIX }, + { AV_PKT_DATA_STEREO3D, AV_FRAME_DATA_STEREO3D }, + }; if (pkt) { - uint8_t *packet_sd; - AVFrameSideData *frame_sd; - int size; frame->pkt_pts = pkt->pts; av_frame_set_pkt_pos (frame, pkt->pos); av_frame_set_pkt_duration(frame, pkt->duration); av_frame_set_pkt_size (frame, pkt->size); - /* 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); - } - - /* copy the displaymatrix to the output frame */ - packet_sd = av_packet_get_side_data(pkt, AV_PKT_DATA_DISPLAYMATRIX, &size); - if (packet_sd) { - frame_sd = av_frame_new_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX, size); - if (!frame_sd) - return AVERROR(ENOMEM); - - memcpy(frame_sd->data, packet_sd, size); - } - - /* copy the stereo3d format to the output frame */ - packet_sd = av_packet_get_side_data(pkt, AV_PKT_DATA_STEREO3D, &size); - if (packet_sd) { - frame_sd = av_frame_new_side_data(frame, AV_FRAME_DATA_STEREO3D, size); - if (!frame_sd) - return AVERROR(ENOMEM); - - memcpy(frame_sd->data, packet_sd, size); + for (i = 0; i < FF_ARRAY_ELEMS(sd); i++) { + int size; + uint8_t *packet_sd = av_packet_get_side_data(pkt, sd[i].packet, &size); + if (packet_sd) { + AVFrameSideData *frame_sd = av_frame_new_side_data(frame, + sd[i].frame, + size); + if (!frame_sd) + return AVERROR(ENOMEM); + + memcpy(frame_sd->data, packet_sd, size); + } } } else { frame->pkt_pts = AV_NOPTS_VALUE; |