[FFmpeg-devel] [PATCHv3 7/7] avcodec/utils: use the unpack_dictionary function
wm4
nfxjfg at googlemail.com
Mon Oct 28 20:06:00 CET 2013
On Sun, 27 Oct 2013 22:47:35 -0400
Ben Boeckel <mathstuf at gmail.com> wrote:
> Signed-off-by: Ben Boeckel <mathstuf at gmail.com>
> ---
> libavcodec/utils.c | 18 ++++--------------
> 1 file changed, 4 insertions(+), 14 deletions(-)
>
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 3832b81..c3526f2 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -1943,25 +1943,15 @@ static void apply_param_change(AVCodecContext *avctx, AVPacket *avpkt)
>
> static int add_metadata_from_side_data(AVCodecContext *avctx, AVFrame *frame)
> {
> - int size, ret = 0;
> + int size;
> const uint8_t *side_metadata;
> const uint8_t *end;
>
> + AVDictionary **frame_md = avpriv_frame_get_metadatap(frame);
> +
> side_metadata = av_packet_get_side_data(avctx->pkt,
> AV_PKT_DATA_STRINGS_METADATA, &size);
> - if (!side_metadata)
> - goto end;
> - end = side_metadata + size;
> - while (side_metadata < end) {
> - const uint8_t *key = side_metadata;
> - const uint8_t *val = side_metadata + strlen(key) + 1;
> - int ret = av_dict_set(avpriv_frame_get_metadatap(frame), key, val, 0);
> - if (ret < 0)
> - break;
> - side_metadata = val + strlen(val) + 1;
> - }
> -end:
> - return ret;
> + return av_packet_unpack_dictionary(side_metadata, size, frame_md);
> }
>
> int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
Does the same, just removes the duplicated code that was factored out
earlier. Looks ok.
More information about the ffmpeg-devel
mailing list