Originally committed as revision 20891 to svn://svn.ffmpeg.org/ffmpeg/trunk
Unified · Split
| @@ -45,6 +45,7 @@ version <next>: · 44 unmodified lines | ||
| 45 | 45 | - -formats option split into -formats, -codecs, -bsfs, and -protocols |
| 46 | 46 | - IV8 demuxer |
| 47 | 47 | - CDG demuxer and decoder |
| 48 | +- R210 decoder | |
| 48 | 49 | |
| 49 | 50 | |
| 50 | 51 | |
| @@ -430,6 +430,7 @@ following image formats are supported: · 429 unmodified lines | ||
| 430 | 430 | @tab fourcc: 'smc ' |
| 431 | 431 | @item QuickTime video (RPZA) @tab @tab X |
| 432 | 432 | @tab fourcc: rpza |
| 433 | +@item R210 Quicktime Uncompressed RGB 10-bit @tab @tab X | |
| 433 | 434 | @item Raw Video @tab X @tab X |
| 434 | 435 | @item RealVideo 1.0 @tab X @tab X |
| 435 | 436 | @item RealVideo 2.0 @tab X @tab X |
| @@ -247,6 +247,7 @@ OBJS-$(CONFIG_QDRAW_DECODER) += qdrw.o · 246 unmodified lines | ||
| 247 | 247 | OBJS-$(CONFIG_QPEG_DECODER) += qpeg.o |
| 248 | 248 | OBJS-$(CONFIG_QTRLE_DECODER) += qtrle.o |
| 249 | 249 | OBJS-$(CONFIG_QTRLE_ENCODER) += qtrleenc.o |
| 250 | +OBJS-$(CONFIG_R210_DECODER) += r210dec.o | |
| 250 | 251 | OBJS-$(CONFIG_RA_144_DECODER) += ra144.o celp_filters.o |
| 251 | 252 | OBJS-$(CONFIG_RA_288_DECODER) += ra288.o celp_math.o celp_filters.o |
| 252 | 253 | OBJS-$(CONFIG_RAWVIDEO_DECODER) += rawdec.o |
| @@ -146,6 +146,7 @@ void avcodec_register_all(void) · 145 unmodified lines | ||
| 146 | 146 | REGISTER_DECODER (QDRAW, qdraw); |
| 147 | 147 | REGISTER_DECODER (QPEG, qpeg); |
| 148 | 148 | REGISTER_ENCDEC (QTRLE, qtrle); |
| 149 | + REGISTER_DECODER (R210, r210); | |
| 149 | 150 | REGISTER_ENCDEC (RAWVIDEO, rawvideo); |
| 150 | 151 | REGISTER_DECODER (RL2, rl2); |
| 151 | 152 | REGISTER_ENCDEC (ROQ, roq); |
| @@ -201,6 +201,7 @@ enum CodecID { · 200 unmodified lines | ||
| 201 | 201 | CODEC_ID_FRWU, |
| 202 | 202 | CODEC_ID_FLASHSV2, |
| 203 | 203 | CODEC_ID_CDGRAPHICS, |
| 204 | + CODEC_ID_R210, | |
| 204 | 205 | |
| 205 | 206 | /* various PCM "codecs" */ |
| 206 | 207 | CODEC_ID_PCM_S16LE= 0x10000, |
| @@ -0,0 +1,104 @@ | ||
| 1 | +/* | |
| 2 | + * R210 decoder | |
| 3 | + * | |
| 4 | + * Copyright (c) 2009 Reimar Doeffinger <Reimar.Doeffinger@gmx.de> | |
| 5 | + * | |
| 6 | + * This file is part of FFmpeg. | |
| 7 | + * | |
| 8 | + * FFmpeg 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 | + * FFmpeg 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 FFmpeg; 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 "libavutil/bswap.h" | |
| 25 | + | |
| 26 | +static av_cold int decode_init(AVCodecContext *avctx) | |
| 27 | +{ | |
| 28 | + avctx->pix_fmt = PIX_FMT_RGB48; | |
| 29 | + avctx->bits_per_raw_sample = 10; | |
| 30 | + | |
| 31 | + avctx->coded_frame = avcodec_alloc_frame(); | |
| 32 | + | |
| 33 | + return 0; | |
| 34 | +} | |
| 35 | + | |
| 36 | +static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, | |
| 37 | + AVPacket *avpkt) | |
| 38 | +{ | |
| 39 | + int h, w; | |
| 40 | + AVFrame *pic = avctx->coded_frame; | |
| 41 | + const uint32_t *src = (const uint32_t *)avpkt->data; | |
| 42 | + int aligned_width = FFALIGN(avctx->width, 64); | |
| 43 | + uint8_t *dst_line; | |
| 44 | + | |
| 45 | + if (pic->data[0]) | |
| 46 | + avctx->release_buffer(avctx, pic); | |
| 47 | + | |
| 48 | + if (avpkt->size < 4 * aligned_width * avctx->height) { | |
| 49 | + av_log(avctx, AV_LOG_ERROR, "packet too small\n"); | |
| 50 | + return -1; | |
| 51 | + } | |
| 52 | + | |
| 53 | + pic->reference = 0; | |
| 54 | + if (avctx->get_buffer(avctx, pic) < 0) | |
| 55 | + return -1; | |
| 56 | + | |
| 57 | + pic->pict_type = FF_I_TYPE; | |
| 58 | + pic->key_frame = 1; | |
| 59 | + dst_line = pic->data[0]; | |
| 60 | + | |
| 61 | + for (h = 0; h < avctx->height; h++) { | |
| 62 | + uint16_t *dst = (uint16_t *)dst_line; | |
| 63 | + for (w = 0; w < avctx->width; w++) { | |
| 64 | + uint32_t pixel = be2me_32(*src++); | |
| 65 | + uint16_t r, g, b; | |
| 66 | + r = pixel << 6; | |
| 67 | + g = (pixel >> 4) & 0xffc0; | |
| 68 | + b = (pixel >> 14) & 0xffc0; | |
| 69 | + *dst++ = r | (r >> 10); | |
| 70 | + *dst++ = g | (g >> 10); | |
| 71 | + *dst++ = b | (b >> 10); | |
| 72 | + } | |
| 73 | + src += aligned_width - avctx->width; | |
| 74 | + dst_line += pic->linesize[0]; | |
| 75 | + } | |
| 76 | + | |
| 77 | + *data_size = sizeof(AVFrame); | |
| 78 | + *(AVFrame*)data = *avctx->coded_frame; | |
| 79 | + | |
| 80 | + return avpkt->size; | |
| 81 | +} | |
| 82 | + | |
| 83 | +static av_cold int decode_close(AVCodecContext *avctx) | |
| 84 | +{ | |
| 85 | + AVFrame *pic = avctx->coded_frame; | |
| 86 | + if (pic->data[0]) | |
| 87 | + avctx->release_buffer(avctx, pic); | |
| 88 | + av_freep(&avctx->coded_frame); | |
| 89 | + | |
| 90 | + return 0; | |
| 91 | +} | |
| 92 | + | |
| 93 | +AVCodec r210_decoder = { | |
| 94 | + "r210", | |
| 95 | + CODEC_TYPE_VIDEO, | |
| 96 | + CODEC_ID_R210, | |
| 97 | + 0, | |
| 98 | + decode_init, | |
| 99 | + NULL, | |
| 100 | + decode_close, | |
| 101 | + decode_frame, | |
| 102 | + CODEC_CAP_DR1, | |
| 103 | + .long_name = NULL_IF_CONFIG_SMALL("Uncompressed RGB 10-bit"), | |
| 104 | +}; | |
| @@ -67,6 +67,7 @@ const AVCodecTag codec_movvideo_tags[] = { · 66 unmodified lines | ||
| 67 | 67 | { CODEC_ID_RAWVIDEO, MKTAG('2', 'v', 'u', 'y') }, /* UNCOMPRESSED 8BIT 4:2:2 */ |
| 68 | 68 | { CODEC_ID_RAWVIDEO, MKTAG('y', 'u', 'v', 's') }, /* same as 2vuy but byte swapped */ |
| 69 | 69 | |
| 70 | + { CODEC_ID_R210, MKTAG('r', '2', '1', '0') }, /* UNCOMPRESSED 10BIT RGB */ | |
| 70 | 71 | { CODEC_ID_V210, MKTAG('v', '2', '1', '0') }, /* UNCOMPRESSED 10BIT 4:2:2 */ |
| 71 | 72 | |
| 72 | 73 | { CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') }, /* PhotoJPEG */ |
| @@ -163,6 +163,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { · 162 unmodified lines | ||
| 163 | 163 | { CODEC_ID_RAWVIDEO, MKTAG('H', 'D', 'Y', 'C') }, |
| 164 | 164 | { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', 'U', '9') }, |
| 165 | 165 | { CODEC_ID_FRWU, MKTAG('F', 'R', 'W', 'U') }, |
| 166 | + { CODEC_ID_R210, MKTAG('r', '2', '1', '0') }, | |
| 166 | 167 | { CODEC_ID_V210, MKTAG('v', '2', '1', '0') }, |
| 167 | 168 | { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '1') }, |
| 168 | 169 | { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '2') }, |