[FFmpeg-soc] [soc]: r1191 - qcelp/qcelp_parser.c

reynaldo subversion at mplayerhq.hu
Sat Aug 25 23:42:14 CEST 2007


Author: reynaldo
Date: Sat Aug 25 23:42:14 2007
New Revision: 1191

Log:
Adds missing qcelp_parcer.c draft

Added:
   qcelp/qcelp_parser.c

Added: qcelp/qcelp_parser.c
==============================================================================
--- (empty file)
+++ qcelp/qcelp_parser.c	Sat Aug 25 23:42:14 2007
@@ -0,0 +1,109 @@
+/*
+ * QCELP parser
+ * Copyright (c) 2007 Reynaldo H. Verdejo Pinochet
+ *
+ * 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 qcelp_parser.c
+ * QCELP parser
+ * @author Reynaldo H. Verdejo Pinochet
+ */
+
+#include "parser.h"
+#include "qcelpdata.h"
+
+
+/**
+ * finds the end of the current frame in the bitstream.
+ * @return the position of the first byte of the next frame, or -1
+ */
+
+static int qcelp_find_frame_end(ParseContext *pc, const uint8_t *buf,
+       int buf_size)
+{
+    if(buf_size < 3)
+        return END_NOT_FOUND;
+
+    switch(buf_size)
+    {
+        case 35:
+        case 34:
+        case 17:
+        case 16:
+        case  8:
+        case  7:
+        case  4:
+        case  3:
+            return buf_size;
+    }
+
+    switch(buf[0])
+    {
+        case 4:
+            return 35;
+        case 3:
+            return 17;
+        case 2:
+            return  8;
+        case 1:
+            return  4;
+    }
+
+    return END_NOT_FOUND;
+}
+
+static int qcelp_parse(AVCodecParserContext *s, AVCodecContext *avctx,
+       const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf,
+       int buf_size)
+{
+    int next;
+
+    ParseContext *pc = s->priv_data;
+    int start_found  = pc->frame_start_found;
+    uint32_t state   = pc->state;
+
+    start_found=1;
+
+    if(s->flags & PARSER_FLAG_COMPLETE_FRAMES)
+    {
+        next=buf_size;
+    }else{
+        next=qcelp_find_frame_end(pc, buf, buf_size);
+
+        if (ff_combine_frame(pc, next, &buf, &buf_size) < 0)
+        {
+            *poutbuf = NULL;
+            *poutbuf_size = 0;
+            return buf_size;
+        }
+    }
+
+    *poutbuf = buf;
+    *poutbuf_size = buf_size;
+
+    return next;
+}
+
+AVCodecParser qcelp_parser = {
+    { CODEC_ID_QCELP },
+    sizeof(ParseContext),
+    NULL,
+    qcelp_parse,
+    ff_parse_close,
+};



More information about the FFmpeg-soc mailing list