[FFmpeg-soc] [soc]: r1130 - in rv40: add_rv40.patch rv40_parser.c
kostya
subversion at mplayerhq.hu
Tue Aug 21 13:31:31 CEST 2007
Author: kostya
Date: Tue Aug 21 13:31:31 2007
New Revision: 1130
Log:
Parser for gathering all slices for one frame
Added:
rv40/rv40_parser.c
Modified:
rv40/add_rv40.patch
Modified: rv40/add_rv40.patch
==============================================================================
--- rv40/add_rv40.patch (original)
+++ rv40/add_rv40.patch Tue Aug 21 13:31:31 2007
@@ -10,6 +10,14 @@ Index: libavcodec/Makefile
OBJS-$(CONFIG_SGI_DECODER) += sgidec.o
OBJS-$(CONFIG_SGI_ENCODER) += sgienc.o rle.o
OBJS-$(CONFIG_SHORTEN_DECODER) += shorten.o golomb.o
+@@ -315,6 +316,7 @@
+ OBJS-$(CONFIG_MPEGAUDIO_PARSER) += mpegaudio_parser.o mpegaudiodecheader.o mpegaudiodata.o
+ OBJS-$(CONFIG_MPEGVIDEO_PARSER) += mpegvideo_parser.o
+ OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o
++OBJS-$(CONFIG_RV40_PARSER) += rv40_parser.o
+ OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o
+
+ OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o
Index: libavcodec/allcodecs.c
===================================================================
--- libavcodec/allcodecs.c
@@ -22,3 +30,36 @@ Index: libavcodec/allcodecs.c
REGISTER_ENCDEC (SGI, sgi);
REGISTER_DECODER(SMACKER, smacker);
REGISTER_DECODER(SMC, smc);
+@@ -272,6 +273,7 @@
+ REGISTER_PARSER (MPEGAUDIO, mpegaudio);
+ REGISTER_PARSER (MPEGVIDEO, mpegvideo);
+ REGISTER_PARSER (PNM, pnm);
++ REGISTER_PARSER (RV40, rv40);
+ REGISTER_PARSER (VC1, vc1);
+
+ /* bitstream filters */
+Index: libavcodec/avcodec.h
+===================================================================
+--- libavcodec/avcodec.h
++++ libavcodec/avcodec.h
+@@ -2777,6 +2777,7 @@
+ extern AVCodecParser mpegaudio_parser;
+ extern AVCodecParser mpegvideo_parser;
+ extern AVCodecParser pnm_parser;
++extern AVCodecParser rv40_parser;
+ extern AVCodecParser vc1_parser;
+
+
+Index: libavformat/rmdec.c
+===================================================================
+--- libavformat/rmdec.c (revision 9713)
++++ libavformat/rmdec.c (working copy)
+@@ -331,7 +331,7 @@
+ case 1: st->codec->codec_id = CODEC_ID_RV10; break;
+ case 2: st->codec->codec_id = CODEC_ID_RV20; break;
+ case 3: st->codec->codec_id = CODEC_ID_RV30; break;
+- case 4: st->codec->codec_id = CODEC_ID_RV40; break;
++ case 4: st->codec->codec_id = CODEC_ID_RV40; st->need_parsing = 1; break;
+ default: goto fail1;
+ }
+ }
Added: rv40/rv40_parser.c
==============================================================================
--- (empty file)
+++ rv40/rv40_parser.c Tue Aug 21 13:31:31 2007
@@ -0,0 +1,91 @@
+/*
+ * RV40 parser
+ * Copyright (c) 2007 Konstantin Shishkov
+ *
+ * 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
+ */
+
+/**
+ * @file rv40_parser.c
+ * RV40 parser that combines slices
+ */
+
+#include "parser.h"
+
+/** These bits of slice header should be the same for all slices in one frame */
+#define KEY_MASK 0xE0CFFF80
+
+typedef struct RV40ParseContext{
+ ParseContext pc;
+ int slices;
+}RV40ParseContext;
+
+static int rv40_parse_init(AVCodecParserContext *s)
+{
+ ParseContext *pc = s->priv_data;
+
+ pc->state = -1;
+ return 0;
+}
+
+static int rv40_parse(AVCodecParserContext *s,
+ AVCodecContext *avctx,
+ const uint8_t **poutbuf, int *poutbuf_size,
+ const uint8_t *buf, int buf_size)
+{
+ ParseContext *pc = s->priv_data;
+ RV40ParseContext *rpc = s->priv_data;
+ int hdr, buf_size2;
+
+ hdr = AV_RB32(buf) & KEY_MASK;
+ if(pc->state == -1){
+ rpc->slices = 0;
+ pc->state = hdr;
+ }
+ if(hdr == pc->state){//add another slice
+ rpc->slices++;
+ buf_size2 = buf_size;
+ /* adjust buffer size for faster slice header searches / bits reading */
+ buf_size = (buf_size + 3) & ~3;
+ if (ff_combine_frame(pc, END_NOT_FOUND, &buf, &buf_size) < 0) {
+ *poutbuf = NULL;
+ *poutbuf_size = 0;
+ return buf_size2;
+ }
+ *poutbuf = NULL;
+ *poutbuf_size = 0;
+ return buf_size;
+ }else{ // new frame
+ pc->state = -1;
+ if (ff_combine_frame(pc, 0, &buf, &buf_size) < 0) {
+ *poutbuf = NULL;
+ *poutbuf_size = 0;
+ return buf_size;
+ }
+ *poutbuf = buf;
+ *poutbuf_size = buf_size;
+ return 0;
+ }
+}
+
+AVCodecParser rv40_parser = {
+ { CODEC_ID_RV40 },
+ sizeof(RV40ParseContext),
+ rv40_parse_init,
+ rv40_parse,
+ ff_parse_close,
+};
More information about the FFmpeg-soc
mailing list