Signed-off-by: Paul B Mahol <onemda@gmail.com>
Paul B Mahol authored on 2017/06/02 18:28:35... | ... |
@@ -18,6 +18,7 @@ version <next>: |
18 | 18 |
- remove the libschroedinger encoder/decoder wrappers |
19 | 19 |
- surround audio filter |
20 | 20 |
- sofalizer filter switched to libmysofa |
21 |
+- Gremlin Digital Video demuxer and decoder |
|
21 | 22 |
|
22 | 23 |
version 3.3: |
23 | 24 |
- CrystalHD decoder moved to new decode API |
... | ... |
@@ -192,6 +192,7 @@ OBJS-$(CONFIG_G722_MUXER) += rawenc.o |
192 | 192 |
OBJS-$(CONFIG_G723_1_DEMUXER) += g723_1.o |
193 | 193 |
OBJS-$(CONFIG_G723_1_MUXER) += rawenc.o |
194 | 194 |
OBJS-$(CONFIG_G729_DEMUXER) += g729dec.o |
195 |
+OBJS-$(CONFIG_GDV_DEMUXER) += gdv.o |
|
195 | 196 |
OBJS-$(CONFIG_GENH_DEMUXER) += genh.o |
196 | 197 |
OBJS-$(CONFIG_H261_DEMUXER) += h261dec.o rawdec.o |
197 | 198 |
OBJS-$(CONFIG_H261_MUXER) += rawenc.o |
... | ... |
@@ -134,6 +134,7 @@ static void register_all(void) |
134 | 134 |
REGISTER_MUXDEMUX(G722, g722); |
135 | 135 |
REGISTER_MUXDEMUX(G723_1, g723_1); |
136 | 136 |
REGISTER_DEMUXER (G729, g729); |
137 |
+ REGISTER_DEMUXER (GDV, gdv); |
|
137 | 138 |
REGISTER_DEMUXER (GENH, genh); |
138 | 139 |
REGISTER_MUXDEMUX(GIF, gif); |
139 | 140 |
REGISTER_MUXDEMUX(GSM, gsm); |
140 | 141 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,161 @@ |
0 |
+/* |
|
1 |
+ * Gremlin Digital Video demuxer |
|
2 |
+ * Copyright (c) 2017 Paul B Mahol |
|
3 |
+ * |
|
4 |
+ * This file is part of FFmpeg. |
|
5 |
+ * |
|
6 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
7 |
+ * modify it under the terms of the GNU Lesser General Public |
|
8 |
+ * License as published by the Free Software Foundation; either |
|
9 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
10 |
+ * |
|
11 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
12 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
+ * Lesser General Public License for more details. |
|
15 |
+ * |
|
16 |
+ * You should have received a copy of the GNU Lesser General Public |
|
17 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
+ */ |
|
20 |
+ |
|
21 |
+#include "libavutil/intreadwrite.h" |
|
22 |
+ |
|
23 |
+#include "avformat.h" |
|
24 |
+#include "avio.h" |
|
25 |
+#include "internal.h" |
|
26 |
+ |
|
27 |
+typedef struct GDVContext { |
|
28 |
+ int is_first_video; |
|
29 |
+ int is_audio; |
|
30 |
+ int audio_size; |
|
31 |
+ int audio_stream_index; |
|
32 |
+ int video_stream_index; |
|
33 |
+ unsigned pal[256]; |
|
34 |
+} GDVContext; |
|
35 |
+ |
|
36 |
+static int gdv_read_probe(AVProbeData *p) |
|
37 |
+{ |
|
38 |
+ if (AV_RL32(p->buf) == 0x29111994) |
|
39 |
+ return AVPROBE_SCORE_MAX; |
|
40 |
+ |
|
41 |
+ return 0; |
|
42 |
+} |
|
43 |
+ |
|
44 |
+static int gdv_read_header(AVFormatContext *ctx) |
|
45 |
+{ |
|
46 |
+ GDVContext *gdv = ctx->priv_data; |
|
47 |
+ AVIOContext *pb = ctx->pb; |
|
48 |
+ AVStream *vst, *ast; |
|
49 |
+ unsigned fps, snd_flags, vid_depth; |
|
50 |
+ |
|
51 |
+ avio_skip(pb, 6); |
|
52 |
+ |
|
53 |
+ vst = avformat_new_stream(ctx, 0); |
|
54 |
+ if (!vst) |
|
55 |
+ return AVERROR(ENOMEM); |
|
56 |
+ |
|
57 |
+ vst->start_time = 0; |
|
58 |
+ vst->duration = |
|
59 |
+ vst->nb_frames = avio_rl16(pb); |
|
60 |
+ |
|
61 |
+ fps = avio_rl16(pb); |
|
62 |
+ snd_flags = avio_rl16(pb); |
|
63 |
+ if (snd_flags & 1) { |
|
64 |
+ ast = avformat_new_stream(ctx, 0); |
|
65 |
+ if (!ast) |
|
66 |
+ return AVERROR(ENOMEM); |
|
67 |
+ |
|
68 |
+ ast->start_time = 0; |
|
69 |
+ ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; |
|
70 |
+ ast->codecpar->codec_tag = 0; |
|
71 |
+ ast->codecpar->sample_rate = avio_rl16(pb); |
|
72 |
+ ast->codecpar->channels = 1 + !!(snd_flags & 2); |
|
73 |
+ if (snd_flags & 8) { |
|
74 |
+ ast->codecpar->codec_id = AV_CODEC_ID_GREMLIN_DPCM; |
|
75 |
+ } else { |
|
76 |
+ ast->codecpar->codec_id = (snd_flags & 4) ? AV_CODEC_ID_PCM_S16LE : AV_CODEC_ID_PCM_U8; |
|
77 |
+ } |
|
78 |
+ |
|
79 |
+ avpriv_set_pts_info(ast, 64, 1, ast->codecpar->sample_rate); |
|
80 |
+ gdv->audio_size = (ast->codecpar->sample_rate / fps) * |
|
81 |
+ ast->codecpar->channels * (1 + !!(snd_flags & 4)) / (1 + !!(snd_flags & 8)); |
|
82 |
+ gdv->is_audio = 1; |
|
83 |
+ } |
|
84 |
+ vid_depth = avio_rl16(pb); |
|
85 |
+ avio_skip(pb, 4); |
|
86 |
+ |
|
87 |
+ vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; |
|
88 |
+ vst->codecpar->codec_id = AV_CODEC_ID_GDV; |
|
89 |
+ vst->codecpar->codec_tag = 0; |
|
90 |
+ vst->codecpar->width = avio_rl16(pb); |
|
91 |
+ vst->codecpar->height = avio_rl16(pb); |
|
92 |
+ |
|
93 |
+ avpriv_set_pts_info(vst, 64, 1, fps); |
|
94 |
+ |
|
95 |
+ if (vid_depth & 1) { |
|
96 |
+ int i; |
|
97 |
+ |
|
98 |
+ for (i = 0; i < 256; i++) { |
|
99 |
+ unsigned r = avio_r8(pb); |
|
100 |
+ unsigned g = avio_r8(pb); |
|
101 |
+ unsigned b = avio_r8(pb); |
|
102 |
+ gdv->pal[i] = 0xFF << 24 | r << 18 | g << 10 | b << 2; |
|
103 |
+ } |
|
104 |
+ } |
|
105 |
+ |
|
106 |
+ gdv->is_first_video = 1; |
|
107 |
+ |
|
108 |
+ return 0; |
|
109 |
+} |
|
110 |
+ |
|
111 |
+static int gdv_read_packet(AVFormatContext *ctx, AVPacket *pkt) |
|
112 |
+{ |
|
113 |
+ GDVContext *gdv = ctx->priv_data; |
|
114 |
+ AVIOContext *pb = ctx->pb; |
|
115 |
+ int ret; |
|
116 |
+ |
|
117 |
+ if (avio_feof(pb)) |
|
118 |
+ return pb->error ? pb->error : AVERROR_EOF; |
|
119 |
+ |
|
120 |
+ if (gdv->audio_size && gdv->is_audio) { |
|
121 |
+ ret = av_get_packet(pb, pkt, gdv->audio_size); |
|
122 |
+ if (ret < 0) |
|
123 |
+ return ret; |
|
124 |
+ pkt->stream_index = 1; |
|
125 |
+ gdv->is_audio = 0; |
|
126 |
+ } else { |
|
127 |
+ uint8_t *pal; |
|
128 |
+ |
|
129 |
+ if (avio_rl16(pb) != 0x1305) |
|
130 |
+ return AVERROR_INVALIDDATA; |
|
131 |
+ ret = av_get_packet(pb, pkt, 4 + avio_rl16(pb)); |
|
132 |
+ if (ret < 0) |
|
133 |
+ return ret; |
|
134 |
+ pkt->stream_index = 0; |
|
135 |
+ gdv->is_audio = 1; |
|
136 |
+ |
|
137 |
+ if (gdv->is_first_video) { |
|
138 |
+ pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, |
|
139 |
+ AVPALETTE_SIZE); |
|
140 |
+ if (!pal) { |
|
141 |
+ av_packet_unref(pkt); |
|
142 |
+ return AVERROR(ENOMEM); |
|
143 |
+ } |
|
144 |
+ memcpy(pal, gdv->pal, AVPALETTE_SIZE); |
|
145 |
+ pkt->flags |= AV_PKT_FLAG_KEY; |
|
146 |
+ gdv->is_first_video = 0; |
|
147 |
+ } |
|
148 |
+ } |
|
149 |
+ |
|
150 |
+ return 0; |
|
151 |
+} |
|
152 |
+ |
|
153 |
+AVInputFormat ff_gdv_demuxer = { |
|
154 |
+ .name = "gdv", |
|
155 |
+ .long_name = NULL_IF_CONFIG_SMALL("Gremlin Digital Video"), |
|
156 |
+ .priv_data_size = sizeof(GDVContext), |
|
157 |
+ .read_probe = gdv_read_probe, |
|
158 |
+ .read_header = gdv_read_header, |
|
159 |
+ .read_packet = gdv_read_packet, |
|
160 |
+}; |
... | ... |
@@ -32,8 +32,8 @@ |
32 | 32 |
// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) |
33 | 33 |
// Also please add any ticket numbers that you believe might be affected here |
34 | 34 |
#define LIBAVFORMAT_VERSION_MAJOR 57 |
35 |
-#define LIBAVFORMAT_VERSION_MINOR 72 |
|
36 |
-#define LIBAVFORMAT_VERSION_MICRO 101 |
|
35 |
+#define LIBAVFORMAT_VERSION_MINOR 73 |
|
36 |
+#define LIBAVFORMAT_VERSION_MICRO 100 |
|
37 | 37 |
|
38 | 38 |
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |
39 | 39 |
LIBAVFORMAT_VERSION_MINOR, \ |