Browse code

Move H.261 parser to its own file.

Originally committed as revision 8888 to svn://svn.ffmpeg.org/ffmpeg/trunk

Diego Biurrun authored on 2007/05/05 04:38:10
Showing 3 changed files
... ...
@@ -279,7 +279,7 @@ OBJS-$(CONFIG_CAVSVIDEO_PARSER)        += cavs.o parser.o
279 279
 OBJS-$(CONFIG_DCA_PARSER)              += dca_parser.o
280 280
 OBJS-$(CONFIG_DVBSUB_PARSER)           += dvbsubdec.o
281 281
 OBJS-$(CONFIG_DVDSUB_PARSER)           += dvdsubdec.o
282
-OBJS-$(CONFIG_H261_PARSER)             += h261.o
282
+OBJS-$(CONFIG_H261_PARSER)             += h261_parser.o
283 283
 OBJS-$(CONFIG_H263_PARSER)             += h263dec.o
284 284
 OBJS-$(CONFIG_H264_PARSER)             += h264.o
285 285
 OBJS-$(CONFIG_MJPEG_PARSER)            += mjpeg.o
... ...
@@ -856,61 +856,6 @@ static int h261_decode_gob(H261Context *h){
856 856
     return -1;
857 857
 }
858 858
 
859
-#ifdef CONFIG_H261_PARSER
860
-static int h261_find_frame_end(ParseContext *pc, AVCodecContext* avctx, const uint8_t *buf, int buf_size){
861
-    int vop_found, i, j;
862
-    uint32_t state;
863
-
864
-    vop_found= pc->frame_start_found;
865
-    state= pc->state;
866
-
867
-    for(i=0; i<buf_size && !vop_found; i++){
868
-        state= (state<<8) | buf[i];
869
-        for(j=0; j<8; j++){
870
-            if(((state>>j)&0xFFFFF) == 0x00010){
871
-                vop_found=1;
872
-                break;
873
-            }
874
-        }
875
-    }
876
-    if(vop_found){
877
-        for(; i<buf_size; i++){
878
-            state= (state<<8) | buf[i];
879
-            for(j=0; j<8; j++){
880
-                if(((state>>j)&0xFFFFF) == 0x00010){
881
-                    pc->frame_start_found=0;
882
-                    pc->state= state>>(2*8);
883
-                    return i-1;
884
-                }
885
-            }
886
-        }
887
-    }
888
-
889
-    pc->frame_start_found= vop_found;
890
-    pc->state= state;
891
-    return END_NOT_FOUND;
892
-}
893
-
894
-static int h261_parse(AVCodecParserContext *s,
895
-                      AVCodecContext *avctx,
896
-                      uint8_t **poutbuf, int *poutbuf_size,
897
-                      const uint8_t *buf, int buf_size)
898
-{
899
-    ParseContext *pc = s->priv_data;
900
-    int next;
901
-
902
-    next= h261_find_frame_end(pc,avctx, buf, buf_size);
903
-    if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
904
-        *poutbuf = NULL;
905
-        *poutbuf_size = 0;
906
-        return buf_size;
907
-    }
908
-    *poutbuf = (uint8_t *)buf;
909
-    *poutbuf_size = buf_size;
910
-    return next;
911
-}
912
-#endif
913
-
914 859
 /**
915 860
  * returns the number of bytes consumed for building the current frame
916 861
  */
... ...
@@ -1045,13 +990,3 @@ AVCodec h261_decoder = {
1045 1045
     h261_decode_frame,
1046 1046
     CODEC_CAP_DR1,
1047 1047
 };
1048
-
1049
-#ifdef CONFIG_H261_PARSER
1050
-AVCodecParser h261_parser = {
1051
-    { CODEC_ID_H261 },
1052
-    sizeof(ParseContext),
1053
-    NULL,
1054
-    h261_parse,
1055
-    ff_parse_close,
1056
-};
1057
-#endif
1058 1048
new file mode 100644
... ...
@@ -0,0 +1,91 @@
0
+/*
1
+ * H261 parser
2
+ * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
3
+ * Copyright (c) 2004 Maarten Daniels
4
+ *
5
+ * This file is part of FFmpeg.
6
+ *
7
+ * FFmpeg is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2.1 of the License, or (at your option) any later version.
11
+ *
12
+ * FFmpeg is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+ * Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public
18
+ * License along with FFmpeg; if not, write to the Free Software
19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
+ */
21
+
22
+/**
23
+ * @file h261_parser.c
24
+ * h261codec.
25
+ */
26
+
27
+#include "dsputil.h"
28
+#include "parser.h"
29
+
30
+
31
+static int h261_find_frame_end(ParseContext *pc, AVCodecContext* avctx, const uint8_t *buf, int buf_size){
32
+    int vop_found, i, j;
33
+    uint32_t state;
34
+
35
+    vop_found= pc->frame_start_found;
36
+    state= pc->state;
37
+
38
+    for(i=0; i<buf_size && !vop_found; i++){
39
+        state= (state<<8) | buf[i];
40
+        for(j=0; j<8; j++){
41
+            if(((state>>j)&0xFFFFF) == 0x00010){
42
+                vop_found=1;
43
+                break;
44
+            }
45
+        }
46
+    }
47
+    if(vop_found){
48
+        for(; i<buf_size; i++){
49
+            state= (state<<8) | buf[i];
50
+            for(j=0; j<8; j++){
51
+                if(((state>>j)&0xFFFFF) == 0x00010){
52
+                    pc->frame_start_found=0;
53
+                    pc->state= state>>(2*8);
54
+                    return i-1;
55
+                }
56
+            }
57
+        }
58
+    }
59
+
60
+    pc->frame_start_found= vop_found;
61
+    pc->state= state;
62
+    return END_NOT_FOUND;
63
+}
64
+
65
+static int h261_parse(AVCodecParserContext *s,
66
+                      AVCodecContext *avctx,
67
+                      uint8_t **poutbuf, int *poutbuf_size,
68
+                      const uint8_t *buf, int buf_size)
69
+{
70
+    ParseContext *pc = s->priv_data;
71
+    int next;
72
+
73
+    next= h261_find_frame_end(pc,avctx, buf, buf_size);
74
+    if (ff_combine_frame(pc, next, (uint8_t **)&buf, &buf_size) < 0) {
75
+        *poutbuf = NULL;
76
+        *poutbuf_size = 0;
77
+        return buf_size;
78
+    }
79
+    *poutbuf = (uint8_t *)buf;
80
+    *poutbuf_size = buf_size;
81
+    return next;
82
+}
83
+
84
+AVCodecParser h261_parser = {
85
+    { CODEC_ID_H261 },
86
+    sizeof(ParseContext),
87
+    NULL,
88
+    h261_parse,
89
+    ff_parse_close,
90
+};