commit 5ca4e2662113cb70fbcf40fc96d51f320d5d86fe
parent ebf0f06f2ba192c0140681eb209d5e4b02a57f6f
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 5 Aug 2012 23:25:37 +0000
-fix gop
Diffstat:
2 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/src/plugins/mpeg_extractor.c b/src/plugins/mpeg_extractor.c
@@ -52,7 +52,8 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
ssize_t avail;
mpeg2_state_t state;
char format[256];
- int finished;
+ char gop_format[256];
+ int have_gop;
if (NULL == (handle = mpeg2_init ()))
return;
@@ -61,8 +62,8 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
mpeg2_close (handle);
return;
}
- finished = 3;
- while (0 != finished)
+ have_gop = 0;
+ while (1)
{
state = mpeg2_parse (handle);
switch (state)
@@ -101,19 +102,16 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
ADD ("MPEG2", EXTRACTOR_METATYPE_FORMAT_VERSION);
else
ADD ("MPEG1", EXTRACTOR_METATYPE_FORMAT_VERSION);
- finished &= ~2;
break;
case STATE_GOP:
- if ( (NULL != info->gop) &&
- (0 != info->gop->pictures) )
+ if (NULL != info->gop)
{
- snprintf (format,
- sizeof(format),
- "%u:%u:%u (%u frames)",
- info->gop->hours,
- info->gop->minutes, info->gop->seconds, info->gop->pictures);
- ADD (format, EXTRACTOR_METATYPE_DURATION);
- finished &= ~1;
+ snprintf (gop_format,
+ sizeof (gop_format),
+ "%02u:%02u:%02u (%u frames)",
+ info->gop->hours, info->gop->minutes, info->gop->seconds,
+ info->gop->pictures);
+ have_gop = 1;
}
break;
case STATE_SLICE:
@@ -127,6 +125,8 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
}
}
EXIT:
+ if (1 == have_gop)
+ ADD (gop_format, EXTRACTOR_METATYPE_DURATION);
mpeg2_close (handle);
}
diff --git a/src/plugins/test_mpeg.c b/src/plugins/test_mpeg.c
@@ -63,17 +63,14 @@ main (int argc, char *argv[])
strlen ("MPEG1") + 1,
0
},
-#if 0
- /* GOP is somehow not working for this example */
{
EXTRACTOR_METATYPE_DURATION,
EXTRACTOR_METAFORMAT_UTF8,
"text/plain",
- "0:0:0 (0 frames)", /* FIXME: this is obviously the wrong answer */
- strlen ("0:0:0 (0 frames)") + 1,
+ "00:00:03 (22 frames)",
+ strlen ("00:00:03 (22 frames)") + 1,
0
},
-#endif
{ 0, 0, NULL, NULL, 0, -1 }
};
struct ProblemSet ps[] =