1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

mjpegdec: parse JPS extension and save relevant stereo3d information

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Kirill Gavrilov 2014-01-29 21:22:24 +04:00 committed by Michael Niedermayer
parent 72afa381b3
commit e9e7e68516
2 changed files with 52 additions and 0 deletions

View File

@ -1554,6 +1554,45 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
goto out;
}
/* JPS extension by VRex */
if (s->start_code == APP3 && id == AV_RB32("_JPS") && len >= 10) {
int flags, layout, type;
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_INFO, "_JPSJPS_\n");
skip_bits(&s->gb, 32); len -= 4; /* JPS_ */
skip_bits(&s->gb, 16); len -= 2; /* block length */
skip_bits(&s->gb, 8); /* reserved */
flags = get_bits(&s->gb, 8);
layout = get_bits(&s->gb, 8);
type = get_bits(&s->gb, 8);
len -= 4;
s->stereo3d = av_stereo3d_alloc();
if (!s->stereo3d) {
goto out;
}
if (type == 0) {
s->stereo3d->type = AV_STEREO3D_2D;
} else if (type == 1) {
switch (layout) {
case 0x01:
s->stereo3d->type = AV_STEREO3D_LINES;
break;
case 0x02:
s->stereo3d->type = AV_STEREO3D_SIDEBYSIDE;
break;
case 0x03:
s->stereo3d->type = AV_STEREO3D_TOPBOTTOM;
break;
}
if (!(flags & 0x04)) {
s->stereo3d->flags = AV_STEREO3D_FLAG_INVERT;
}
}
goto out;
}
/* EXIF metadata */
if (s->start_code == APP1 && id == AV_RB32("Exif") && len >= 2) {
GetByteContext gbytes;
@ -1787,6 +1826,7 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
int ret = 0;
av_dict_free(&s->exif_metadata);
av_freep(&s->stereo3d);
buf_ptr = buf;
buf_end = buf + buf_size;
@ -2017,6 +2057,15 @@ the_end:
}
}
if (s->stereo3d) {
AVStereo3D *stereo = av_stereo3d_create_side_data(data);
if (stereo) {
stereo->type = s->stereo3d->type;
stereo->flags = s->stereo3d->flags;
}
av_freep(&s->stereo3d);
}
av_dict_copy(avpriv_frame_get_metadatap(data), s->exif_metadata, 0);
av_dict_free(&s->exif_metadata);

View File

@ -31,6 +31,7 @@
#include "libavutil/log.h"
#include "libavutil/pixdesc.h"
#include "libavutil/stereo3d.h"
#include "avcodec.h"
#include "get_bits.h"
@ -122,6 +123,8 @@ typedef struct MJpegDecodeContext {
int extern_huff;
AVDictionary *exif_metadata;
AVStereo3D *stereo3d; ///!< stereoscopic information (cached, since it is read before frame allocation)
const AVPixFmtDescriptor *pix_desc;
} MJpegDecodeContext;