v410 is a packed 10-bit 4:4:4 YCbCr format used in QuickTime.
Unified · Split
| @@ -107,6 +107,7 @@ easier to use. The changes are: · 106 unmodified lines | ||
| 107 | 107 | - PCM format support in OMA demuxer |
| 108 | 108 | - CLJR encoder |
| 109 | 109 | - Dxtory capture format decoder |
| 110 | +- v410 QuickTime uncompressed 4:4:4 10-bit encoder and decoder | |
| 110 | 111 | |
| 111 | 112 | |
| 112 | 113 | version 0.7: |
| @@ -578,7 +578,8 @@ following image formats are supported: · 577 unmodified lines | ||
| 578 | 578 | @item Tiertex Limited SEQ video @tab @tab X |
| 579 | 579 | @tab Codec used in DOS CD-ROM FlashBack game. |
| 580 | 580 | @item Ut Video @tab @tab X |
| 581 | −@item V210 Quicktime Uncompressed 4:2:2 10-bit @tab X @tab X | |
| 581 | +@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 | 583 | @item VBLE Lossless Codec @tab @tab X |
| 583 | 584 | @item VMware Screen Codec / VMware Video @tab @tab X |
| 584 | 585 | @tab Codec used in videos captured by VMware. |
| @@ -384,6 +384,8 @@ OBJS-$(CONFIG_ULTI_DECODER) += ulti.o · 383 unmodified lines | ||
| 384 | 384 | OBJS-$(CONFIG_UTVIDEO_DECODER) += utvideo.o |
| 385 | 385 | OBJS-$(CONFIG_V210_DECODER) += v210dec.o |
| 386 | 386 | OBJS-$(CONFIG_V210_ENCODER) += v210enc.o |
| 387 | +OBJS-$(CONFIG_V410_DECODER) += v410dec.o | |
| 388 | +OBJS-$(CONFIG_V410_ENCODER) += v410enc.o | |
| 387 | 389 | OBJS-$(CONFIG_V210X_DECODER) += v210x.o |
| 388 | 390 | OBJS-$(CONFIG_VB_DECODER) += vb.o |
| 389 | 391 | OBJS-$(CONFIG_VBLE_DECODER) += vble.o |
| @@ -204,6 +204,7 @@ void avcodec_register_all(void) · 203 unmodified lines | ||
| 204 | 204 | REGISTER_DECODER (UTVIDEO, utvideo); |
| 205 | 205 | REGISTER_ENCDEC (V210, v210); |
| 206 | 206 | REGISTER_DECODER (V210X, v210x); |
| 207 | + REGISTER_ENCDEC (V410, v410); | |
| 207 | 208 | REGISTER_DECODER (VB, vb); |
| 208 | 209 | REGISTER_DECODER (VBLE, vble); |
| 209 | 210 | REGISTER_DECODER (VC1, vc1); |
| @@ -253,6 +253,7 @@ enum CodecID { · 252 unmodified lines | ||
| 253 | 253 | CODEC_ID_BMV_VIDEO, |
| 254 | 254 | CODEC_ID_VBLE, |
| 255 | 255 | CODEC_ID_DXTORY, |
| 256 | + CODEC_ID_V410, | |
| 256 | 257 | |
| 257 | 258 | /* various PCM "codecs" */ |
| 258 | 259 | CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs |
| @@ -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 | + | |
| 26 | +static 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 | + | |
| 46 | +static 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 | + | |
| 94 | +static 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 | + | |
| 104 | +AVCodec 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 | +}; | |
| @@ -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 | + | |
| 26 | +static 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 | + | |
| 43 | +static 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 | + | |
| 83 | +static av_cold int v410_encode_close(AVCodecContext *avctx) | |
| 84 | +{ | |
| 85 | + av_freep(&avctx->coded_frame); | |
| 86 | + | |
| 87 | + return 0; | |
| 88 | +} | |
| 89 | + | |
| 90 | +AVCodec 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 | +}; | |
| @@ -21,7 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | #define AVCODEC_VERSION_H |
| 22 | 22 | |
| 23 | 23 | #define LIBAVCODEC_VERSION_MAJOR 53 |
| 24 | −#define LIBAVCODEC_VERSION_MINOR 27 | |
| 24 | +#define LIBAVCODEC_VERSION_MINOR 28 | |
| 25 | 25 | #define LIBAVCODEC_VERSION_MICRO 0 |
| 26 | 26 | |
| 27 | 27 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
| @@ -90,6 +90,7 @@ const AVCodecTag codec_movvideo_tags[] = { · 89 unmodified lines | ||
| 90 | 90 | { CODEC_ID_R10K, MKTAG('R', '1', '0', 'g') }, /* UNCOMPRESSED 10BIT RGB */ |
| 91 | 91 | { CODEC_ID_R210, MKTAG('r', '2', '1', '0') }, /* UNCOMPRESSED 10BIT RGB */ |
| 92 | 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 | 95 | { CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') }, /* PhotoJPEG */ |
| 95 | 96 | { CODEC_ID_MJPEG, MKTAG('m', 'j', 'p', 'a') }, /* Motion-JPEG (format A) */ |
| @@ -196,6 +196,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { · 195 unmodified lines | ||
| 196 | 196 | { CODEC_ID_R10K, MKTAG('R', '1', '0', 'k') }, |
| 197 | 197 | { CODEC_ID_R210, MKTAG('r', '2', '1', '0') }, |
| 198 | 198 | { CODEC_ID_V210, MKTAG('v', '2', '1', '0') }, |
| 199 | + { CODEC_ID_V410, MKTAG('v', '4', '1', '0') }, | |
| 199 | 200 | { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '1') }, |
| 200 | 201 | { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '2') }, |
| 201 | 202 | { CODEC_ID_INDEO4, MKTAG('I', 'V', '4', '1') }, |