aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/mpeg_extractor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/mpeg_extractor.c')
-rw-r--r--src/plugins/mpeg_extractor.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/plugins/mpeg_extractor.c b/src/plugins/mpeg_extractor.c
index 145f748..05a972f 100644
--- a/src/plugins/mpeg_extractor.c
+++ b/src/plugins/mpeg_extractor.c
@@ -54,6 +54,7 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
54 char gop_format[256]; 54 char gop_format[256];
55 int have_gop; 55 int have_gop;
56 uint64_t fsize; 56 uint64_t fsize;
57 unsigned int fail_count;
57 58
58 if (NULL == (handle = mpeg2_init ())) 59 if (NULL == (handle = mpeg2_init ()))
59 return; 60 return;
@@ -65,12 +66,16 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
65 fsize = ec->get_size (ec->cls); 66 fsize = ec->get_size (ec->cls);
66 buf = NULL; 67 buf = NULL;
67 have_gop = 0; 68 have_gop = 0;
69 fail_count = 0;
68 while (1) 70 while (1)
69 { 71 {
70 state = mpeg2_parse (handle); 72 state = mpeg2_parse (handle);
71 switch (state) 73 switch (state)
72 { 74 {
73 case STATE_BUFFER: 75 case STATE_BUFFER:
76 if (fail_count > 16)
77 goto EXIT; /* do not read large non-mpeg files */
78 fail_count++;
74 if (0 >= (avail = ec->read (ec->cls, 79 if (0 >= (avail = ec->read (ec->cls,
75 &buf, 80 &buf,
76 16 * 1024))) 81 16 * 1024)))
@@ -78,6 +83,7 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
78 mpeg2_buffer (handle, buf, buf + avail); 83 mpeg2_buffer (handle, buf, buf + avail);
79 break; 84 break;
80 case STATE_SEQUENCE: 85 case STATE_SEQUENCE:
86 fail_count = 0;
81 format[0] = fsize; 87 format[0] = fsize;
82 format[0]++; 88 format[0]++;
83 ADD ("video/mpeg", EXTRACTOR_METATYPE_MIMETYPE); 89 ADD ("video/mpeg", EXTRACTOR_METATYPE_MIMETYPE);
@@ -116,6 +122,7 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
116 } 122 }
117 break; 123 break;
118 case STATE_GOP: 124 case STATE_GOP:
125 fail_count = 0;
119 if ( (NULL != info->gop) && 126 if ( (NULL != info->gop) &&
120 (0 != info->gop->pictures) ) 127 (0 != info->gop->pictures) )
121 { 128 {
@@ -128,8 +135,10 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
128 } 135 }
129 break; 136 break;
130 case STATE_SLICE: 137 case STATE_SLICE:
138 fail_count = 0;
131 break; 139 break;
132 case STATE_END: 140 case STATE_END:
141 fail_count = 0;
133 break; 142 break;
134 case STATE_INVALID: 143 case STATE_INVALID:
135 goto EXIT; 144 goto EXIT;