[FFmpeg-devel] [PATCH 1/3] avcodec/tiff_common: add ff_tadd_bytes_metadata()

Clément Bœsch u at pkh.me
Tue Sep 24 21:28:56 CEST 2013


On Tue, Sep 24, 2013 at 09:01:08PM +0200, Michael Niedermayer wrote:
> The le argument is passed so the function has the same prototype as the
> other similar functions. It is otherwise unused
> 
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
>  libavcodec/tiff_common.c |   31 +++++++++++++++++++++++++++++++
>  libavcodec/tiff_common.h |    6 ++++++
>  2 files changed, 37 insertions(+)
> 
> diff --git a/libavcodec/tiff_common.c b/libavcodec/tiff_common.c
> index b7bd587..1300935 100644
> --- a/libavcodec/tiff_common.c
> +++ b/libavcodec/tiff_common.c
> @@ -207,6 +207,37 @@ int ff_tadd_shorts_metadata(int count, const char *name, const char *sep,
>  }
>  
>  
> +int ff_tadd_bytes_metadata(int count, const char *name, const char *sep,
> +                           GetByteContext *gb, int le, AVDictionary **metadata)
> +{
> +    AVBPrint bp;
> +    char *ap;
> +    int i;
> +
> +    if (count >= INT_MAX / sizeof(int8_t) || count <= 0)
> +        return AVERROR_INVALIDDATA;
> +    if (bytestream2_get_bytes_left(gb) < count * sizeof(int8_t))
> +        return AVERROR_INVALIDDATA;
> +    if (!sep) sep = ", ";
> +
> +    av_bprint_init(&bp, 10 * count, AV_BPRINT_SIZE_AUTOMATIC);
> +
> +    for (i = 0; i < count; i++) {
> +        av_bprintf(&bp, "%s%i", (i ? sep : ""), bytestream2_get_byte(gb));
> +    }
> +
> +    if ((i = av_bprint_finalize(&bp, &ap))) {
> +        return i;
> +    }
> +    if (!ap) {
> +        return AVERROR(ENOMEM);
> +    }
> +
> +    av_dict_set(metadata, name, ap, AV_DICT_DONT_STRDUP_VAL);
> +
> +    return 0;
> +}
> +

Why isn't this optional? Won't this make it unusable/a real pain for apps
to deal with this?

Instead, I would suggest to add some escaping the print_string() callback
of the default writer (maybe optionnal), which would replace any non
printable char with a "\\x%02X" value.

[...]

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130924/be2d70e3/attachment.asc>


More information about the ffmpeg-devel mailing list