diff options
-rw-r--r-- | tools/mpeg.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/tools/mpeg.c b/tools/mpeg.c index 35e95da3..029f8ede 100644 --- a/tools/mpeg.c +++ b/tools/mpeg.c @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: mpeg.c,v 1.1 2008-02-04 22:42:13 phintuka Exp $ + * $Id: mpeg.c,v 1.2 2008-06-11 15:51:19 phintuka Exp $ * */ @@ -18,7 +18,6 @@ const char * const picture_type_str[] = { "P-Frame" }; - int mpeg2_get_picture_type(const uint8_t *buf, int len) { int i; @@ -39,9 +38,23 @@ int mpeg2_get_video_size(const uint8_t *buf, int len, video_size_t *size) for (i = 0; i < len-6; i++) { if (buf[i] == 0 && buf[i + 1] == 0 && buf[i + 2] == 1) { if (buf[i + 3] == SC_SEQUENCE) { + static const mpeg_rational_t mpeg2_aspect[16] = { + {0,1}, {1,1}, {4,3}, {16,9}, {221,100}, + {0,1}, {0,1}, {0,1}, { 0,1}, { 0,1}, + {0,1}, {0,1}, {0,1}, { 0,1}, { 0,1}, + {0,1}, + }; + int d = (buf[i+4] << 16) | (buf[i+5] << 8) | buf[i+6]; + int a = buf[i+7] >> 4; + size->width = (d >> 12); size->height = (d & 0xfff); + + memcpy(&size->pixel_aspect, &mpeg2_aspect[a], sizeof(mpeg_rational_t)); + size->pixel_aspect.num *= size->height; + size->pixel_aspect.den *= size->width; + return 1; } } |