[MEncoder-users] V210 Codec
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Tue Feb 17 18:42:32 CET 2009
On Tue, Feb 17, 2009 at 06:18:39AM -0800, P.J. Trudell wrote:
> I hope someone working with the v210 codec can point me in the right direction. I had it working once but had to wipe the machine and I can't seem to get there again.
You could just apply attached patch to MPlayer.
If someone has or can create a video in that v210 format with e.g. a width of
704 (or any other resolution that is divisible by 64 but not 128) I'd be
interested (the current patch _might_ break with that, unfortunately I
found no official specification of the format).
Not you need to apply it to a very recent version of MPlayer or it will
crash.
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: etc/codecs.conf
===================================================================
--- etc/codecs.conf (revision 28634)
+++ etc/codecs.conf (working copy)
@@ -2324,6 +2324,14 @@
dll "dnxhd"
out 422P
+videocodec ffv210
+ info "FFmpeg v210"
+ status working
+ fourcc v210
+ driver ffmpeg
+ dll "v210"
+ out UYVY
+
; quicktime codecs:
videocodec qt3ivx
Index: libavcodec/v210.c
===================================================================
--- libavcodec/v210.c (revision 0)
+++ libavcodec/v210.c (revision 0)
@@ -0,0 +1,109 @@
+/*
+ * v210 (10 bit 4:2:2 YUV) decoder
+ * Copyright (c) 2009 Reimar Doeffinger
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "avcodec.h"
+#include "bytestream.h"
+
+static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
+ const uint8_t *buf, int buf_size) {
+ int x, y;
+ AVFrame *picture = data;
+ AVFrame *pic = avctx->priv_data;
+ uint8_t *dst_line = pic->data[0];
+ const uint8_t *src_line = buf;
+ int src_linesize = (avctx->width + 5) / 6 * 16;
+ src_linesize = (src_linesize + 63) & ~63;
+ if (buf_size < src_linesize * avctx->height) {
+ av_log(avctx, AV_LOG_ERROR, "coded frame too small\n");
+ return -1;
+ }
+
+ for (y = 0; y < avctx->height; y++) {
+ const uint8_t *src = src_line;
+ uint64_t val;
+ for (x = 0; x < avctx->width - 5; x += 6) {
+ val = bytestream_get_le64(&src);
+ dst_line[2 * x + 0] = val >> 2;
+ dst_line[2 * x + 1] = val >> 12;
+ dst_line[2 * x + 2] = val >> 22;
+ dst_line[2 * x + 3] = val >> 34;
+ dst_line[2 * x + 4] = val >> 44;
+ dst_line[2 * x + 5] = val >> 54;
+ val = bytestream_get_le64(&src);
+ dst_line[2 * x + 6] = val >> 2;
+ dst_line[2 * x + 7] = val >> 12;
+ dst_line[2 * x + 8] = val >> 22;
+ dst_line[2 * x + 9] = val >> 34;
+ dst_line[2 * x + 10] = val >> 44;
+ dst_line[2 * x + 11] = val >> 54;
+ }
+ if (x < avctx->width - 1) {
+ val = bytestream_get_le64(&src);
+ dst_line[2 * x + 0] = val >> 2;
+ dst_line[2 * x + 1] = val >> 12;
+ dst_line[2 * x + 2] = val >> 22;
+ dst_line[2 * x + 3] = val >> 34;
+ }
+ if (x < avctx->width - 3) {
+ dst_line[2 * x + 4] = val >> 44;
+ dst_line[2 * x + 5] = val >> 54;
+ val = bytestream_get_le64(&src);
+ dst_line[2 * x + 6] = val >> 2;
+ dst_line[2 * x + 7] = val >> 12;
+ }
+ src_line += src_linesize;
+ dst_line += pic->linesize[0];
+ }
+
+ *picture = *pic;
+ *data_size = sizeof(AVFrame);
+ return src_line - buf;
+}
+
+static av_cold int decode_init(AVCodecContext *avctx) {
+ AVFrame *pic = avctx->priv_data;
+ if (avcodec_check_dimensions(avctx, avctx->height, avctx->width) < 0)
+ return 1;
+ avctx->pix_fmt = PIX_FMT_UYVY422;
+ if (avctx->get_buffer(avctx, pic) < 0)
+ return 1;
+ pic->pict_type = FF_I_TYPE;
+ pic->key_frame = 1;
+ return 0;
+}
+
+static av_cold int decode_end(AVCodecContext *avctx) {
+ avctx->release_buffer(avctx, avctx->priv_data);
+ return 0;
+}
+
+AVCodec v210_decoder = {
+ "v210",
+ CODEC_TYPE_VIDEO,
+ CODEC_ID_V210,
+ sizeof(AVFrame),
+ decode_init,
+ NULL,
+ decode_end,
+ decode_frame,
+ CODEC_CAP_DR1,
+ .long_name = NULL_IF_CONFIG_SMALL("v210 10 bit 4:2:2 YUV"),
+};
+
Index: libavcodec/Makefile
===================================================================
--- libavcodec/Makefile (revision 17393)
+++ libavcodec/Makefile (working copy)
@@ -219,6 +219,7 @@
OBJS-$(CONFIG_TTA_DECODER) += tta.o
OBJS-$(CONFIG_TXD_DECODER) += txd.o s3tc.o
OBJS-$(CONFIG_ULTI_DECODER) += ulti.o
+OBJS-$(CONFIG_V210_DECODER) += v210.o
OBJS-$(CONFIG_VB_DECODER) += vb.o
OBJS-$(CONFIG_VC1_DECODER) += vc1.o vc1data.o vc1dsp.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o error_resilience.o mpegvideo.o
OBJS-$(CONFIG_VC1_VDPAU_DECODER) += vdpau.o vc1.o vc1data.o vc1dsp.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o error_resilience.o mpegvideo.o
Index: libavcodec/allcodecs.c
===================================================================
--- libavcodec/allcodecs.c (revision 17393)
+++ libavcodec/allcodecs.c (working copy)
@@ -156,6 +156,7 @@
REGISTER_DECODER (TSCC, tscc);
REGISTER_DECODER (TXD, txd);
REGISTER_DECODER (ULTI, ulti);
+ REGISTER_DECODER (V210, v210);
REGISTER_DECODER (VB, vb);
REGISTER_DECODER (VC1, vc1);
REGISTER_DECODER (VC1_VDPAU, vc1_vdpau);
Index: libavcodec/avcodec.h
===================================================================
--- libavcodec/avcodec.h (revision 17393)
+++ libavcodec/avcodec.h (working copy)
@@ -191,6 +191,7 @@
CODEC_ID_TGV,
CODEC_ID_TGQ,
CODEC_ID_TQI,
+ CODEC_ID_V210,
/* various PCM "codecs" */
CODEC_ID_PCM_S16LE= 0x10000,
More information about the MEncoder-users
mailing list