On Tue, Nov 4, 2014 at 3:13 PM, Luca Barbato <[email protected]> wrote:
> ---
>
> libavcodec/utils.c | 44 ++++++++++++++++++--------------------------
> 1 file changed, 18 insertions(+), 26 deletions(-)
>
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 95d2193..57ead5e 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -561,8 +561,17 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame
> *frame)
> {
> AVPacket *pkt = avctx->internal->pkt;
> uint8_t *packet_sd;
> - int size;
> + int size, i;
> AVFrameSideData *frame_sd;
frame_sd and packet_sd do not need to have such high scope now
> + struct {
> + enum AVPacketSideDataType packet;
> + enum AVFrameSideDataType frame;
> + } side_data[] = {
> + { AV_PKT_DATA_REPLAYGAIN , AV_FRAME_DATA_REPLAYGAIN },
> + { AV_PKT_DATA_DISPLAYMATRIX, AV_FRAME_DATA_DISPLAYMATRIX },
> + { AV_PKT_DATA_STEREO3D, AV_FRAME_DATA_STEREO3D },
> + };
> +
stray extra line
>
> frame->color_primaries = avctx->color_primaries;
> frame->color_trc = avctx->color_trc;
> @@ -578,32 +587,15 @@ int ff_decode_frame_props(AVCodecContext *avctx,
> AVFrame *frame)
>
> 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);
> - }
> - /* 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);
> + for (i = 0; i < FF_ARRAY_ELEMS(side_data); i++) {
> + packet_sd = av_packet_get_side_data(pkt, side_data[i].packet, &size);
> + if (packet_sd) {
> + frame_sd = av_frame_new_side_data(frame, side_data[i].frame,
> 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);
> + memcpy(frame_sd->data, packet_sd, size);
> + }
> }
Change possibly ok after the nits, but a comment before the loop
explaining what it does would be nice.
--
Vittorio
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel