[FFmpeg-devel] [Read EXIF metadata 3/3] Read EXIF metadata in JPEG input.

Michael Niedermayer michaelni at gmx.at
Mon Aug 12 15:35:00 CEST 2013


On Sun, Aug 11, 2013 at 07:08:37PM +0200, Thilo Borgmann wrote:
> 3/3 rev 7
> 
> -Thilo

>  Changelog             |    1 +
>  libavcodec/Makefile   |    2 +-
>  libavcodec/mjpegdec.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
>  libavcodec/mjpegdec.h |    1 +
>  4 files changed, 49 insertions(+), 1 deletion(-)
> e9936a83843f15e4a107b7f7690c2ba5e323f853  0003-Read-EXIF-metadata-in-JPEG-input.patch
> From 6f2ab3bd2fcf05bc4644448de52efb6f3487149f Mon Sep 17 00:00:00 2001
> From: Thilo Borgmann <thilo.borgmann at googlemail.com>
> Date: Sun, 11 Aug 2013 18:19:08 +0200
> Subject: [PATCH 3/3] Read EXIF metadata in JPEG input.
> 
> ---
>  Changelog             |    1 +
>  libavcodec/Makefile   |    2 +-
>  libavcodec/mjpegdec.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
>  libavcodec/mjpegdec.h |    1 +
>  4 files changed, 49 insertions(+), 1 deletions(-)
> 
> diff --git a/Changelog b/Changelog
> index f1d7fa6..4a6c60c 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -14,6 +14,7 @@ version <next>
>  - ffmpeg -t option can now be used for inputs, to limit the duration of
>    data read from an input file
>  - incomplete Voxware MetaSound decoder
> +- read EXIF metadata from JPEG
>  
>  
>  version 2.0:
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 5ba8a1a..e9ba2fa 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -267,7 +267,7 @@ OBJS-$(CONFIG_METASOUND_DECODER)       += metasound.o metasound_data.o \
>                                            twinvq.o
>  OBJS-$(CONFIG_MICRODVD_DECODER)        += microdvddec.o ass.o
>  OBJS-$(CONFIG_MIMIC_DECODER)           += mimic.o
> -OBJS-$(CONFIG_MJPEG_DECODER)           += mjpegdec.o mjpeg.o
> +OBJS-$(CONFIG_MJPEG_DECODER)           += mjpegdec.o mjpeg.o exif.o tiff_common.o
>  OBJS-$(CONFIG_MJPEG_ENCODER)           += mjpegenc.o mjpeg.o
>  OBJS-$(CONFIG_MJPEGB_DECODER)          += mjpegbdec.o mjpegdec.o mjpeg.o
>  OBJS-$(CONFIG_MLP_DECODER)             += mlpdec.o mlpdsp.o
> diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
> index c92738f..f1b30a2 100644
> --- a/libavcodec/mjpegdec.c
> +++ b/libavcodec/mjpegdec.c
> @@ -39,6 +39,9 @@
>  #include "mjpeg.h"
>  #include "mjpegdec.h"
>  #include "jpeglsdec.h"
> +#include "tiff.h"
> +#include "exif.h"
> +#include "bytestream.h"
>  
>  
>  static int build_vlc(VLC *vlc, const uint8_t *bits_table,
> @@ -1493,6 +1496,43 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
>          goto out;
>      }
>  
> +    /* EXIF metadata */
> +    if (s->start_code == APP1 && id == AV_RB32("Exif")) {
> +        GetByteContext gbytes;
> +        int ret, le, ifd_offset, bytes_read;
> +        const uint8_t *aligned;
> +
> +        skip_bits(&s->gb, 16); // skip padding
> +        len -= 2;
> +

> +        // init byte wise reading
> +        aligned = align_get_bits(&s->gb);
> +        bytestream2_init(&gbytes, aligned, get_bits_left(&s->gb) >> 3);

The space available in the app marker is len not neccesary
get_bits_left()

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130812/dc31abe1/attachment.asc>


More information about the ffmpeg-devel mailing list