summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/h264.c4
-rw-r--r--tools/h264.h14
-rw-r--r--tools/pes.c10
3 files changed, 19 insertions, 9 deletions
diff --git a/tools/h264.c b/tools/h264.c
index 8bdb7f6e..b6380ef0 100644
--- a/tools/h264.c
+++ b/tools/h264.c
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: h264.c,v 1.4 2008-07-29 12:56:32 phintuka Exp $
+ * $Id: h264.c,v 1.5 2008-07-29 14:01:36 phintuka Exp $
*
*/
@@ -186,7 +186,7 @@ int h264_get_video_size(const uint8_t *buf, int len, video_size_t *size)
int i;
/* H.264 detection, search for NAL AUD */
- if (!(buf[0] == 0 && buf[1] == 0 && buf[2] == 1 && buf[3] == NAL_AUD))
+ if (!IS_NAL_AUD(buf))
return 0;
/* if I-frame, search for NAL SPS */
diff --git a/tools/h264.h b/tools/h264.h
index e7e55189..3d6f1cae 100644
--- a/tools/h264.h
+++ b/tools/h264.h
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: h264.h,v 1.5 2008-07-29 12:55:28 phintuka Exp $
+ * $Id: h264.h,v 1.6 2008-07-29 14:01:35 phintuka Exp $
*
*/
@@ -22,6 +22,18 @@ extern "C" {
#define NAL_AUD 0x09 /* Access Unit Delimiter */
#define NAL_END_SEQ 0x10 /* End of Sequence */
+
+#if defined(__i386__) || defined(__x86_64__)
+# define IS_NAL_SPS(buf) (*(uint32_t*)(buf) == 0x07010000U)
+# define IS_NAL_AUD(buf) (*(uint32_t*)(buf) == 0x09010000U)
+# define IS_NAL_END_SEQ(buf) (*(uint32_t*)(buf) == 0x10010000U)
+#else
+# define IS_NAL_SPS(buf) ((buf)[0] == 0 && (buf)[1] == 0 && (buf)[2] == 1 && (buf)[3] == NAL_SPS)
+# define IS_NAL_AUD(buf) ((buf)[0] == 0 && (buf)[1] == 0 && (buf)[2] == 1 && (buf)[3] == NAL_AUD)
+# define IS_NAL_END_SEQ(buf) ((buf)[0] == 0 && (buf)[1] == 0 && (buf)[2] == 1 && (buf)[3] == NAL_END_SEQ)
+#endif
+
+
typedef struct {
int width;
int height;
diff --git a/tools/pes.c b/tools/pes.c
index 2b68c55b..5ab9c1ac 100644
--- a/tools/pes.c
+++ b/tools/pes.c
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: pes.c,v 1.4 2008-05-20 11:09:52 phintuka Exp $
+ * $Id: pes.c,v 1.5 2008-07-29 14:01:36 phintuka Exp $
*
*/
@@ -111,7 +111,7 @@ int pes_is_frame_h264(const uint8_t *buf, int len)
buf += 9 + buf[8];
- if (!buf[0] && !buf[1] && buf[2] == 0x01 && buf[3] == NAL_AUD)
+ if (IS_NAL_AUD(buf))
return 1;
return 0;
}
@@ -142,11 +142,9 @@ int pes_get_video_size(const uint8_t *buf, int len, video_size_t *size, int h264
buf += i;
len -= i;
- if (h264 || (!buf[0] && !buf[1] && buf[2] == 0x01 && buf[3] == NAL_AUD))
+ if (h264 || IS_NAL_AUD(buf))
return h264_get_video_size(buf, len, size);
- else
- return mpeg2_get_video_size(buf, len, size);
- return 0;
+ return mpeg2_get_video_size(buf, len, size);
}