History

v410 encoder and decoder

v410 is a packed 10-bit 4:4:4 YCbCr format used in QuickTime.

Derek Buitenhuis committed 14 years ago

Commit 80f6c0b1 parent 86ae51210 files · +222 −2Browse files

Unified · Split

10 files
  1. Changelog +1 −0
  2. doc/general.texi +2 −1
  3. libavcodec/Makefile +2 −0
  4. libavcodec/allcodecs.c +1 −0
  5. libavcodec/avcodec.h +1 −0
  6. libavcodec/v410dec.c +113 −0
  7. libavcodec/v410enc.c +99 −0
  8. libavcodec/version.h +1 −1
  9. libavformat/isom.c +1 −0
  10. libavformat/riff.c +1 −0
Changelog+1−0
@@ -107,6 +107,7 @@ easier to use. The changes are: · 106 unmodified lines
107- PCM format support in OMA demuxer107- PCM format support in OMA demuxer
108- CLJR encoder108- CLJR encoder
109- Dxtory capture format decoder109- Dxtory capture format decoder
110- v410 QuickTime uncompressed 4:4:4 10-bit encoder and decoder
110 111
111 112
112version 0.7:113version 0.7:
doc/general.texi+2−1
@@ -578,7 +578,8 @@ following image formats are supported: · 577 unmodified lines
578@item Tiertex Limited SEQ video @tab @tab X578@item Tiertex Limited SEQ video @tab @tab X
579 @tab Codec used in DOS CD-ROM FlashBack game.579 @tab Codec used in DOS CD-ROM FlashBack game.
580@item Ut Video @tab @tab X580@item Ut Video @tab @tab X
581@item V210 Quicktime Uncompressed 4:2:2 10-bit @tab X @tab X581@item v210 QuickTime uncompressed 4:2:2 10-bit @tab X @tab X
582@item v410 QuickTime uncompressed 4:4:4 10-bit @tab X @tab X
582@item VBLE Lossless Codec @tab @tab X583@item VBLE Lossless Codec @tab @tab X
583@item VMware Screen Codec / VMware Video @tab @tab X584@item VMware Screen Codec / VMware Video @tab @tab X
584 @tab Codec used in videos captured by VMware.585 @tab Codec used in videos captured by VMware.
libavcodec/Makefile+2−0
@@ -384,6 +384,8 @@ OBJS-$(CONFIG_ULTI_DECODER) += ulti.o · 383 unmodified lines
384OBJS-$(CONFIG_UTVIDEO_DECODER) += utvideo.o384OBJS-$(CONFIG_UTVIDEO_DECODER) += utvideo.o
385OBJS-$(CONFIG_V210_DECODER) += v210dec.o385OBJS-$(CONFIG_V210_DECODER) += v210dec.o
386OBJS-$(CONFIG_V210_ENCODER) += v210enc.o386OBJS-$(CONFIG_V210_ENCODER) += v210enc.o
387OBJS-$(CONFIG_V410_DECODER) += v410dec.o
388OBJS-$(CONFIG_V410_ENCODER) += v410enc.o
387OBJS-$(CONFIG_V210X_DECODER) += v210x.o389OBJS-$(CONFIG_V210X_DECODER) += v210x.o
388OBJS-$(CONFIG_VB_DECODER) += vb.o390OBJS-$(CONFIG_VB_DECODER) += vb.o
389OBJS-$(CONFIG_VBLE_DECODER) += vble.o391OBJS-$(CONFIG_VBLE_DECODER) += vble.o
libavcodec/allcodecs.c+1−0
@@ -204,6 +204,7 @@ void avcodec_register_all(void) · 203 unmodified lines
204 REGISTER_DECODER (UTVIDEO, utvideo);204 REGISTER_DECODER (UTVIDEO, utvideo);
205 REGISTER_ENCDEC (V210, v210);205 REGISTER_ENCDEC (V210, v210);
206 REGISTER_DECODER (V210X, v210x);206 REGISTER_DECODER (V210X, v210x);
207 REGISTER_ENCDEC (V410, v410);
207 REGISTER_DECODER (VB, vb);208 REGISTER_DECODER (VB, vb);
208 REGISTER_DECODER (VBLE, vble);209 REGISTER_DECODER (VBLE, vble);
209 REGISTER_DECODER (VC1, vc1);210 REGISTER_DECODER (VC1, vc1);
libavcodec/avcodec.h+1−0
@@ -253,6 +253,7 @@ enum CodecID { · 252 unmodified lines
253 CODEC_ID_BMV_VIDEO,253 CODEC_ID_BMV_VIDEO,
254 CODEC_ID_VBLE,254 CODEC_ID_VBLE,
255 CODEC_ID_DXTORY,255 CODEC_ID_DXTORY,
256 CODEC_ID_V410,
256 257
257 /* various PCM "codecs" */258 /* various PCM "codecs" */
258 CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs259 CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
libavcodec/v410dec.c+113−0
@@ -0,0 +1,113 @@
1/*
2 * v410 decoder
3 *
4 * Copyright (c) 2011 Derek Buitenhuis
5 *
6 * This file is part of Libav.
7 *
8 * Libav is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * Libav is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with Libav; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include "avcodec.h"
24#include "get_bits.h"
25
26static av_cold int v410_decode_init(AVCodecContext *avctx)
27{
28 avctx->pix_fmt = PIX_FMT_YUV444P10;
29 avctx->bits_per_raw_sample = 10;
30
31 if (avctx->width & 1) {
32 av_log(avctx, AV_LOG_ERROR, "v410 requires even width.\n");
33 return AVERROR_INVALIDDATA;
34 }
35
36 avctx->coded_frame = avcodec_alloc_frame();
37
38 if (!avctx->coded_frame) {
39 av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n");
40 return AVERROR(ENOMEM);
41 }
42
43 return 0;
44}
45
46static int v410_decode_frame(AVCodecContext *avctx, void *data,
47 int *data_size, AVPacket *avpkt)
48{
49 AVFrame *pic = avctx->coded_frame;
50 uint8_t *src = avpkt->data;
51 uint16_t *y, *u, *v;
52 uint32_t val;
53 int i, j;
54
55 if (pic->data[0])
56 avctx->release_buffer(avctx, pic);
57
58 pic->reference = 0;
59
60 if (avctx->get_buffer(avctx, pic) < 0) {
61 av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer.\n");
62 return AVERROR(ENOMEM);
63 }
64
65 pic->key_frame = 1;
66 pic->pict_type = FF_I_TYPE;
67
68 y = (uint16_t *)pic->data[0];
69 u = (uint16_t *)pic->data[1];
70 v = (uint16_t *)pic->data[2];
71
72 for (i = 0; i < avctx->height; i++) {
73 for (j = 0; j < avctx->width; j++) {
74 val = AV_RL32(src);
75
76 u[j] = (val >> 2) & 0x3FF;
77 y[j] = (val >> 12) & 0x3FF;
78 v[j] = (val >> 22);
79
80 src += 4;
81 }
82
83 y += pic->linesize[0] >> 1;
84 u += pic->linesize[1] >> 1;
85 v += pic->linesize[2] >> 1;
86 }
87
88 *data_size = sizeof(AVFrame);
89 *(AVFrame *)data = *pic;
90
91 return avpkt->size;
92}
93
94static av_cold int v410_decode_close(AVCodecContext *avctx)
95{
96 if (avctx->coded_frame->data[0])
97 avctx->release_buffer(avctx, avctx->coded_frame);
98
99 av_freep(&avctx->coded_frame);
100
101 return 0;
102}
103
104AVCodec ff_v410_decoder = {
105 .name = "v410",
106 .type = AVMEDIA_TYPE_VIDEO,
107 .id = CODEC_ID_V410,
108 .init = v410_decode_init,
109 .decode = v410_decode_frame,
110 .close = v410_decode_close,
111 .capabilities = CODEC_CAP_DR1,
112 .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:4:4 10-bit"),
113};
libavcodec/v410enc.c+99−0
@@ -0,0 +1,99 @@
1/*
2 * v410 encoder
3 *
4 * Copyright (c) 2011 Derek Buitenhuis
5 *
6 * This file is part of Libav.
7 *
8 * Libav is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * Libav is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with Libav; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include "avcodec.h"
24#include "put_bits.h"
25
26static av_cold int v410_encode_init(AVCodecContext *avctx)
27{
28 if (avctx->width & 1) {
29 av_log(avctx, AV_LOG_ERROR, "v410 requires even width.\n");
30 return AVERROR_INVALIDDATA;
31 }
32
33 avctx->coded_frame = avcodec_alloc_frame();
34
35 if (!avctx->coded_frame) {
36 av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n");
37 return AVERROR(ENOMEM);
38 }
39
40 return 0;
41}
42
43static int v410_encode_frame(AVCodecContext *avctx, uint8_t *buf,
44 int buf_size, void *data)
45{
46 AVFrame *pic = data;
47 uint8_t *dst = buf;
48 uint16_t *y, *u, *v;
49 uint32_t val;
50 int i, j;
51 int output_size = 0;
52
53 if (buf_size < avctx->width * avctx->height * 3) {
54 av_log(avctx, AV_LOG_ERROR, "Out buffer is too small.\n");
55 return AVERROR(ENOMEM);
56 }
57
58 avctx->coded_frame->reference = 0;
59 avctx->coded_frame->key_frame = 1;
60 avctx->coded_frame->pict_type = FF_I_TYPE;
61
62 y = (uint16_t *)pic->data[0];
63 u = (uint16_t *)pic->data[1];
64 v = (uint16_t *)pic->data[2];
65
66 for (i = 0; i < avctx->height; i++) {
67 for (j = 0; j < avctx->width; j++) {
68 val = u[j] << 2;
69 val |= y[j] << 12;
70 val |= v[j] << 22;
71 AV_WL32(dst, val);
72 dst += 4;
73 output_size += 4;
74 }
75 y += pic->linesize[0] >> 1;
76 u += pic->linesize[1] >> 1;
77 v += pic->linesize[2] >> 1;
78 }
79
80 return output_size;
81}
82
83static av_cold int v410_encode_close(AVCodecContext *avctx)
84{
85 av_freep(&avctx->coded_frame);
86
87 return 0;
88}
89
90AVCodec ff_v410_encoder = {
91 .name = "v410",
92 .type = AVMEDIA_TYPE_VIDEO,
93 .id = CODEC_ID_V410,
94 .init = v410_encode_init,
95 .encode = v410_encode_frame,
96 .close = v410_encode_close,
97 .pix_fmts = (const enum PixelFormat[]){ PIX_FMT_YUV444P10, PIX_FMT_NONE },
98 .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:4:4 10-bit"),
99};
libavcodec/version.h+1−1
@@ -21,7 +21,7 @@ · 20 unmodified lines
21#define AVCODEC_VERSION_H21#define AVCODEC_VERSION_H
22 22
23#define LIBAVCODEC_VERSION_MAJOR 5323#define LIBAVCODEC_VERSION_MAJOR 53
24#define LIBAVCODEC_VERSION_MINOR 2724#define LIBAVCODEC_VERSION_MINOR 28
25#define LIBAVCODEC_VERSION_MICRO 025#define LIBAVCODEC_VERSION_MICRO 0
26 26
27#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \27#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
libavformat/isom.c+1−0
@@ -90,6 +90,7 @@ const AVCodecTag codec_movvideo_tags[] = { · 89 unmodified lines
90 { CODEC_ID_R10K, MKTAG('R', '1', '0', 'g') }, /* UNCOMPRESSED 10BIT RGB */90 { CODEC_ID_R10K, MKTAG('R', '1', '0', 'g') }, /* UNCOMPRESSED 10BIT RGB */
91 { CODEC_ID_R210, MKTAG('r', '2', '1', '0') }, /* UNCOMPRESSED 10BIT RGB */91 { CODEC_ID_R210, MKTAG('r', '2', '1', '0') }, /* UNCOMPRESSED 10BIT RGB */
92 { CODEC_ID_V210, MKTAG('v', '2', '1', '0') }, /* UNCOMPRESSED 10BIT 4:2:2 */92 { CODEC_ID_V210, MKTAG('v', '2', '1', '0') }, /* UNCOMPRESSED 10BIT 4:2:2 */
93 { CODEC_ID_V410, MKTAG('v', '4', '1', '0') }, /* UNCOMPRESSED 10BIT 4:4:4 */
93 94
94 { CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') }, /* PhotoJPEG */95 { CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') }, /* PhotoJPEG */
95 { CODEC_ID_MJPEG, MKTAG('m', 'j', 'p', 'a') }, /* Motion-JPEG (format A) */96 { CODEC_ID_MJPEG, MKTAG('m', 'j', 'p', 'a') }, /* Motion-JPEG (format A) */
libavformat/riff.c+1−0
@@ -196,6 +196,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { · 195 unmodified lines
196 { CODEC_ID_R10K, MKTAG('R', '1', '0', 'k') },196 { CODEC_ID_R10K, MKTAG('R', '1', '0', 'k') },
197 { CODEC_ID_R210, MKTAG('r', '2', '1', '0') },197 { CODEC_ID_R210, MKTAG('r', '2', '1', '0') },
198 { CODEC_ID_V210, MKTAG('v', '2', '1', '0') },198 { CODEC_ID_V210, MKTAG('v', '2', '1', '0') },
199 { CODEC_ID_V410, MKTAG('v', '4', '1', '0') },
199 { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '1') },200 { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '1') },
200 { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '2') },201 { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '2') },
201 { CODEC_ID_INDEO4, MKTAG('I', 'V', '4', '1') },202 { CODEC_ID_INDEO4, MKTAG('I', 'V', '4', '1') },

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t