The decoder also supports a12v, but removes the transparency layer
since no samples with actual transparency are available for testing.
63 | 64 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,172 @@ |
0 |
+/* |
|
1 |
+ * 012v decoder |
|
2 |
+ * |
|
3 |
+ * Copyright (C) 2012 Carl Eugen Hoyos |
|
4 |
+ * |
|
5 |
+ * This file is part of FFmpeg. |
|
6 |
+ * |
|
7 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
8 |
+ * modify it under the terms of the GNU Lesser General Public |
|
9 |
+ * License as published by the Free Software Foundation; either |
|
10 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
11 |
+ * |
|
12 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
13 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
15 |
+ * Lesser General Public License for more details. |
|
16 |
+ * |
|
17 |
+ * You should have received a copy of the GNU Lesser General Public |
|
18 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
19 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
20 |
+ */ |
|
21 |
+ |
|
22 |
+#include "avcodec.h" |
|
23 |
+#include "internal.h" |
|
24 |
+#include "libavutil/intreadwrite.h" |
|
25 |
+ |
|
26 |
+static av_cold int zero12v_decode_init(AVCodecContext *avctx) |
|
27 |
+{ |
|
28 |
+ avctx->pix_fmt = PIX_FMT_YUV422P16; |
|
29 |
+ avctx->bits_per_raw_sample = 10; |
|
30 |
+ |
|
31 |
+ avctx->coded_frame = avcodec_alloc_frame(); |
|
32 |
+ if (!avctx->coded_frame) |
|
33 |
+ return AVERROR(ENOMEM); |
|
34 |
+ |
|
35 |
+ if (avctx->codec_tag == MKTAG('a', '1', '2', 'v')) |
|
36 |
+ av_log_ask_for_sample(avctx, "Samples with actual transparency needed\n"); |
|
37 |
+ |
|
38 |
+ avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; |
|
39 |
+ avctx->coded_frame->key_frame = 1; |
|
40 |
+ return 0; |
|
41 |
+} |
|
42 |
+ |
|
43 |
+static int zero12v_decode_frame(AVCodecContext *avctx, void *data, |
|
44 |
+ int *got_frame, AVPacket *avpkt) |
|
45 |
+{ |
|
46 |
+ int line = 0; |
|
47 |
+ const int width = avctx->width; |
|
48 |
+ AVFrame *pic = avctx->coded_frame; |
|
49 |
+ uint16_t *y, *u, *v; |
|
50 |
+ const uint8_t *line_end, *src = avpkt->data; |
|
51 |
+ int stride = avctx->width * 8 / 3; |
|
52 |
+ |
|
53 |
+ if (pic->data[0]) |
|
54 |
+ avctx->release_buffer(avctx, pic); |
|
55 |
+ |
|
56 |
+ if (width == 1) { |
|
57 |
+ av_log(avctx, AV_LOG_ERROR, "Width 1 not supported.\n"); |
|
58 |
+ return AVERROR_INVALIDDATA; |
|
59 |
+ } |
|
60 |
+ if (avpkt->size < avctx->height * stride) { |
|
61 |
+ av_log(avctx, AV_LOG_ERROR, "Packet too small: %d instead of %d\n", |
|
62 |
+ avpkt->size, avctx->height * stride); |
|
63 |
+ return AVERROR_INVALIDDATA; |
|
64 |
+ } |
|
65 |
+ |
|
66 |
+ pic->reference = 0; |
|
67 |
+ if (ff_get_buffer(avctx, pic) < 0) |
|
68 |
+ return AVERROR_INVALIDDATA;; |
|
69 |
+ |
|
70 |
+ y = (uint16_t *)pic->data[0]; |
|
71 |
+ u = (uint16_t *)pic->data[1]; |
|
72 |
+ v = (uint16_t *)pic->data[2]; |
|
73 |
+ line_end = avpkt->data + stride; |
|
74 |
+ |
|
75 |
+ while (line++ < avctx->height) { |
|
76 |
+ while (1) { |
|
77 |
+ uint32_t t = AV_RL32(src); |
|
78 |
+ src += 4; |
|
79 |
+ *u++ = t << 6 & 0xFFC0; |
|
80 |
+ *y++ = t >> 4 & 0xFFC0; |
|
81 |
+ *v++ = t >> 14 & 0xFFC0; |
|
82 |
+ |
|
83 |
+ if (src >= line_end - 1) { |
|
84 |
+ *y = 0x80; |
|
85 |
+ src++; |
|
86 |
+ line_end += stride; |
|
87 |
+ y = (uint16_t *)(pic->data[0] + line * pic->linesize[0]); |
|
88 |
+ u = (uint16_t *)(pic->data[1] + line * pic->linesize[1]); |
|
89 |
+ v = (uint16_t *)(pic->data[2] + line * pic->linesize[2]); |
|
90 |
+ break; |
|
91 |
+ } |
|
92 |
+ |
|
93 |
+ t = AV_RL32(src); |
|
94 |
+ src += 4; |
|
95 |
+ *y++ = t << 6 & 0xFFC0; |
|
96 |
+ *u++ = t >> 4 & 0xFFC0; |
|
97 |
+ *y++ = t >> 14 & 0xFFC0; |
|
98 |
+ if (src >= line_end - 2) { |
|
99 |
+ if (!(width & 1)) { |
|
100 |
+ *y = 0x80; |
|
101 |
+ src += 2; |
|
102 |
+ } |
|
103 |
+ line_end += stride; |
|
104 |
+ y = (uint16_t *)(pic->data[0] + line * pic->linesize[0]); |
|
105 |
+ u = (uint16_t *)(pic->data[1] + line * pic->linesize[1]); |
|
106 |
+ v = (uint16_t *)(pic->data[2] + line * pic->linesize[2]); |
|
107 |
+ break; |
|
108 |
+ } |
|
109 |
+ |
|
110 |
+ t = AV_RL32(src); |
|
111 |
+ src += 4; |
|
112 |
+ *v++ = t << 6 & 0xFFC0; |
|
113 |
+ *y++ = t >> 4 & 0xFFC0; |
|
114 |
+ *u++ = t >> 14 & 0xFFC0; |
|
115 |
+ |
|
116 |
+ if (src >= line_end - 1) { |
|
117 |
+ *y = 0x80; |
|
118 |
+ src++; |
|
119 |
+ line_end += stride; |
|
120 |
+ y = (uint16_t *)(pic->data[0] + line * pic->linesize[0]); |
|
121 |
+ u = (uint16_t *)(pic->data[1] + line * pic->linesize[1]); |
|
122 |
+ v = (uint16_t *)(pic->data[2] + line * pic->linesize[2]); |
|
123 |
+ break; |
|
124 |
+ } |
|
125 |
+ |
|
126 |
+ t = AV_RL32(src); |
|
127 |
+ src += 4; |
|
128 |
+ *y++ = t << 6 & 0xFFC0; |
|
129 |
+ *v++ = t >> 4 & 0xFFC0; |
|
130 |
+ *y++ = t >> 14 & 0xFFC0; |
|
131 |
+ |
|
132 |
+ if (src >= line_end - 2) { |
|
133 |
+ if (width & 1) { |
|
134 |
+ *y = 0x80; |
|
135 |
+ src += 2; |
|
136 |
+ } |
|
137 |
+ line_end += stride; |
|
138 |
+ y = (uint16_t *)(pic->data[0] + line * pic->linesize[0]); |
|
139 |
+ u = (uint16_t *)(pic->data[1] + line * pic->linesize[1]); |
|
140 |
+ v = (uint16_t *)(pic->data[2] + line * pic->linesize[2]); |
|
141 |
+ break; |
|
142 |
+ } |
|
143 |
+ } |
|
144 |
+ } |
|
145 |
+ |
|
146 |
+ *got_frame = 1; |
|
147 |
+ *(AVFrame*)data= *avctx->coded_frame; |
|
148 |
+ |
|
149 |
+ return avpkt->size; |
|
150 |
+} |
|
151 |
+ |
|
152 |
+static av_cold int zero12v_decode_close(AVCodecContext *avctx) |
|
153 |
+{ |
|
154 |
+ AVFrame *pic = avctx->coded_frame; |
|
155 |
+ if (pic->data[0]) |
|
156 |
+ avctx->release_buffer(avctx, pic); |
|
157 |
+ av_freep(&avctx->coded_frame); |
|
158 |
+ |
|
159 |
+ return 0; |
|
160 |
+} |
|
161 |
+ |
|
162 |
+AVCodec ff_zero12v_decoder = { |
|
163 |
+ .name = "012v", |
|
164 |
+ .type = AVMEDIA_TYPE_VIDEO, |
|
165 |
+ .id = AV_CODEC_ID_012V, |
|
166 |
+ .init = zero12v_decode_init, |
|
167 |
+ .close = zero12v_decode_close, |
|
168 |
+ .decode = zero12v_decode_frame, |
|
169 |
+ .capabilities = CODEC_CAP_DR1, |
|
170 |
+ .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"), |
|
171 |
+}; |
... | ... |
@@ -75,6 +75,7 @@ OBJS-$(CONFIG_VIDEODSP) += videodsp.o |
75 | 75 |
OBJS-$(CONFIG_VP3DSP) += vp3dsp.o |
76 | 76 |
|
77 | 77 |
# decoders/encoders/hardware accelerators |
78 |
+OBJS-$(CONFIG_ZERO12V_DECODER) += 012v.o |
|
78 | 79 |
OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o |
79 | 80 |
OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o |
80 | 81 |
OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o \ |
... | ... |
@@ -294,6 +294,7 @@ void avcodec_register_all(void) |
294 | 294 |
REGISTER_ENCDEC (Y41P, y41p); |
295 | 295 |
REGISTER_DECODER(YOP, yop); |
296 | 296 |
REGISTER_ENCDEC (YUV4, yuv4); |
297 |
+ REGISTER_DECODER(ZERO12V, zero12v); |
|
297 | 298 |
REGISTER_DECODER(ZEROCODEC, zerocodec); |
298 | 299 |
REGISTER_ENCDEC (ZLIB, zlib); |
299 | 300 |
REGISTER_ENCDEC (ZMBV, zmbv); |
... | ... |
@@ -273,6 +273,7 @@ enum AVCodecID { |
273 | 273 |
AV_CODEC_ID_EXR = MKBETAG('0','E','X','R'), |
274 | 274 |
AV_CODEC_ID_AVRP = MKBETAG('A','V','R','P'), |
275 | 275 |
|
276 |
+ AV_CODEC_ID_012V = MKBETAG('0','1','2','V'), |
|
276 | 277 |
AV_CODEC_ID_G2M = MKBETAG( 0 ,'G','2','M'), |
277 | 278 |
AV_CODEC_ID_AVUI = MKBETAG('A','V','U','I'), |
278 | 279 |
AV_CODEC_ID_AYUV = MKBETAG('A','Y','U','V'), |
... | ... |
@@ -1263,6 +1263,13 @@ static const AVCodecDescriptor codec_descriptors[] = { |
1263 | 1263 |
.props = AV_CODEC_PROP_INTRA_ONLY, |
1264 | 1264 |
}, |
1265 | 1265 |
{ |
1266 |
+ .id = AV_CODEC_ID_012V, |
|
1267 |
+ .type = AVMEDIA_TYPE_VIDEO, |
|
1268 |
+ .name = "012v", |
|
1269 |
+ .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"), |
|
1270 |
+ .props = AV_CODEC_PROP_INTRA_ONLY, |
|
1271 |
+ }, |
|
1272 |
+ { |
|
1266 | 1273 |
.id = AV_CODEC_ID_G2M, |
1267 | 1274 |
.type = AVMEDIA_TYPE_VIDEO, |
1268 | 1275 |
.name = "g2m", |
... | ... |
@@ -29,8 +29,8 @@ |
29 | 29 |
#include "libavutil/avutil.h" |
30 | 30 |
|
31 | 31 |
#define LIBAVCODEC_VERSION_MAJOR 54 |
32 |
-#define LIBAVCODEC_VERSION_MINOR 85 |
|
33 |
-#define LIBAVCODEC_VERSION_MICRO 101 |
|
32 |
+#define LIBAVCODEC_VERSION_MINOR 86 |
|
33 |
+#define LIBAVCODEC_VERSION_MICRO 100 |
|
34 | 34 |
|
35 | 35 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
36 | 36 |
LIBAVCODEC_VERSION_MINOR, \ |
... | ... |
@@ -325,6 +325,8 @@ const AVCodecTag ff_codec_bmp_tags[] = { |
325 | 325 |
{ AV_CODEC_ID_CLLC, MKTAG('C', 'L', 'L', 'C') }, |
326 | 326 |
{ AV_CODEC_ID_MSS2, MKTAG('M', 'S', 'S', '2') }, |
327 | 327 |
{ AV_CODEC_ID_SVQ3, MKTAG('S', 'V', 'Q', '3') }, |
328 |
+ { AV_CODEC_ID_012V, MKTAG('0', '1', '2', 'v') }, |
|
329 |
+ { AV_CODEC_ID_012V, MKTAG('a', '1', '2', 'v') }, |
|
328 | 330 |
{ AV_CODEC_ID_NONE, 0 } |
329 | 331 |
}; |
330 | 332 |
|