summaryrefslogtreecommitdiff
path: root/libavformat/gdv.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2017-06-28 19:24:29 +0200
committerPaul B Mahol <onemda@gmail.com>2017-06-29 15:54:20 +0200
commit4d681269e0966446b21a324c15c5e5e6cef7c378 (patch)
tree0d755bfeda94ab30604ca5ba394d68b069e7335b /libavformat/gdv.c
parent45dbb40cd1b350fd421233da3e13e969f7c1df81 (diff)
avcodec/gdv: add decompression for 2 and 5 method
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavformat/gdv.c')
-rw-r--r--libavformat/gdv.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/libavformat/gdv.c b/libavformat/gdv.c
index 87bba2fdbd..90692bd61c 100644
--- a/libavformat/gdv.c
+++ b/libavformat/gdv.c
@@ -42,14 +42,40 @@ static int gdv_read_probe(AVProbeData *p)
return 0;
}
+struct {
+ uint16_t id;
+ uint16_t width;
+ uint16_t height;
+} FixedSize[] = {
+ { 0, 320, 200},
+ { 1, 640, 200},
+ { 2, 320, 167},
+ { 3, 320, 180},
+ { 4, 320, 400},
+ { 5, 320, 170},
+ { 6, 160, 85},
+ { 7, 160, 83},
+ { 8, 160, 90},
+ { 9, 280, 128},
+ {10, 320, 240},
+ {11, 320, 201},
+ {16, 640, 400},
+ {17, 640, 200},
+ {18, 640, 180},
+ {19, 640, 167},
+ {20, 640, 170},
+ {21, 320, 240}
+};
+
static int gdv_read_header(AVFormatContext *ctx)
{
GDVContext *gdv = ctx->priv_data;
AVIOContext *pb = ctx->pb;
AVStream *vst, *ast;
- unsigned fps, snd_flags, vid_depth;
+ unsigned fps, snd_flags, vid_depth, size_id;
- avio_skip(pb, 6);
+ avio_skip(pb, 4);
+ size_id = avio_rl16(pb);
vst = avformat_new_stream(ctx, 0);
if (!vst)
@@ -91,6 +117,18 @@ static int gdv_read_header(AVFormatContext *ctx)
vst->codecpar->width = avio_rl16(pb);
vst->codecpar->height = avio_rl16(pb);
+ if (vst->codecpar->width == 0 || vst->codecpar->height == 0) {
+ int i;
+
+ for (i = 0; i < FF_ARRAY_ELEMS(FixedSize) - 1; i++) {
+ if (FixedSize[i].id == size_id)
+ break;
+ }
+
+ vst->codecpar->width = FixedSize[i].width;
+ vst->codecpar->height = FixedSize[i].height;
+ }
+
avpriv_set_pts_info(vst, 64, 1, fps);
if (vid_depth & 1) {
@@ -100,7 +138,7 @@ static int gdv_read_header(AVFormatContext *ctx)
unsigned r = avio_r8(pb);
unsigned g = avio_r8(pb);
unsigned b = avio_r8(pb);
- gdv->pal[i] = 0xFF << 24 | r << 18 | g << 10 | b << 2;
+ gdv->pal[i] = 0xFFU << 24 | r << 18 | g << 10 | b << 2;
}
}