[FFmpeg-cvslog] r24747 - in trunk/libavformat: internal.h rtpdec_mpeg4.c utils.c

mstorsjo subversion
Mon Aug 9 12:05:33 CEST 2010


Author: mstorsjo
Date: Mon Aug  9 12:05:33 2010
New Revision: 24747

Log:
Make hex_to_data a lavf internal function

This is useful for other future RTP depacketizers

Modified:
   trunk/libavformat/internal.h
   trunk/libavformat/rtpdec_mpeg4.c
   trunk/libavformat/utils.c

Modified: trunk/libavformat/internal.h
==============================================================================
--- trunk/libavformat/internal.h	Mon Aug  9 10:14:48 2010	(r24746)
+++ trunk/libavformat/internal.h	Mon Aug  9 12:05:33 2010	(r24747)
@@ -53,6 +53,16 @@ const char *small_strptime(const char *p
 
 char *ff_data_to_hex(char *buf, const uint8_t *src, int size, int lowercase);
 
+/**
+ * Parse a string of hexadecimal strings. Any space between the hexadecimal
+ * digits is ignored.
+ *
+ * @param data if non-null, the parsed data is written to this pointer
+ * @param p the string to parse
+ * @return the number of bytes written (or to be written, if data is null)
+ */
+int ff_hex_to_data(uint8_t *data, const char *p);
+
 void ff_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int idx);
 
 /**

Modified: trunk/libavformat/rtpdec_mpeg4.c
==============================================================================
--- trunk/libavformat/rtpdec_mpeg4.c	Mon Aug  9 10:14:48 2010	(r24746)
+++ trunk/libavformat/rtpdec_mpeg4.c	Mon Aug  9 12:05:33 2010	(r24747)
@@ -61,35 +61,6 @@ struct PayloadContext
     int cur_au_index;
 };
 
-/* return the length and optionally the data */
-static int hex_to_data(uint8_t *data, const char *p)
-{
-    int c, len, v;
-
-    len = 0;
-    v = 1;
-    for (;;) {
-        p += strspn(p, SPACE_CHARS);
-        if (*p == '\0')
-            break;
-        c = toupper((unsigned char) *p++);
-        if (c >= '0' && c <= '9')
-            c = c - '0';
-        else if (c >= 'A' && c <= 'F')
-            c = c - 'A' + 10;
-        else
-            break;
-        v = (v << 4) | c;
-        if (v & 0x100) {
-            if (data)
-                data[len] = v;
-            len++;
-            v = 1;
-        }
-    }
-    return len;
-}
-
 typedef struct {
     const char *str;
     uint16_t    type;
@@ -139,14 +110,14 @@ static void free_context(PayloadContext 
 static int parse_fmtp_config(AVCodecContext * codec, char *value)
 {
     /* decode the hexa encoded parameter */
-    int len = hex_to_data(NULL, value);
+    int len = ff_hex_to_data(NULL, value);
     if (codec->extradata)
         av_free(codec->extradata);
     codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
     if (!codec->extradata)
         return AVERROR(ENOMEM);
     codec->extradata_size = len;
-    hex_to_data(codec->extradata, value);
+    ff_hex_to_data(codec->extradata, value);
     return 0;
 }
 

Modified: trunk/libavformat/utils.c
==============================================================================
--- trunk/libavformat/utils.c	Mon Aug  9 10:14:48 2010	(r24746)
+++ trunk/libavformat/utils.c	Mon Aug  9 12:05:33 2010	(r24747)
@@ -3600,6 +3600,34 @@ char *ff_data_to_hex(char *buff, const u
     return buff;
 }
 
+int ff_hex_to_data(uint8_t *data, const char *p)
+{
+    int c, len, v;
+
+    len = 0;
+    v = 1;
+    for (;;) {
+        p += strspn(p, SPACE_CHARS);
+        if (*p == '\0')
+            break;
+        c = toupper((unsigned char) *p++);
+        if (c >= '0' && c <= '9')
+            c = c - '0';
+        else if (c >= 'A' && c <= 'F')
+            c = c - 'A' + 10;
+        else
+            break;
+        v = (v << 4) | c;
+        if (v & 0x100) {
+            if (data)
+                data[len] = v;
+            len++;
+            v = 1;
+        }
+    }
+    return len;
+}
+
 void av_set_pts_info(AVStream *s, int pts_wrap_bits,
                      unsigned int pts_num, unsigned int pts_den)
 {



More information about the ffmpeg-cvslog mailing list