On 27 June 2010 10:25, Martin Storsjö <[email protected]> wrote:
> All of these look good to me. I guess you checked that the parameters that
> you pass to the parser and parser callback suit the other ones (xiph, amr)
> too, so you won't have to change the interface when fixing the rest?
>

Yes, the only required changes are internal. Those are in patch 0008,
which I can squash with 0002 if you'd prefer.

Xiph and AMR cleanups attached, but I'd appreciate it if someone could
test the AMR and Vorbis audio stuff for me.

Josh
From 1f8c7af3f8942201500a352299ddecc71ea54f98 Mon Sep 17 00:00:00 2001
From: Josh Allmann <[email protected]>
Date: Mon, 28 Jun 2010 00:17:52 -0700
Subject: [PATCH 08/11] malloc fmtp value.

---
 libavformat/rtpdec.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 74858f6..4881832 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -538,8 +538,14 @@ int ff_parse_fmtp(AVStream *stream, PayloadContext *data, const char *p,
                                     char *attr, char *value))
 {
     char attr[256];
-    char value[4096];
+    char *value;
     int res;
+    int value_size = strlen(p);
+
+    if (!(value = av_malloc(value_size))) {
+        av_log(stream, AV_LOG_ERROR, "Failed to allocate data for FMTP.");
+        return AVERROR(ENOMEM);
+    }
 
     // remove protocol identifier
     while (*p && *p == ' ') p++; // strip spaces
@@ -548,11 +554,14 @@ int ff_parse_fmtp(AVStream *stream, PayloadContext *data, const char *p,
 
     while (ff_rtsp_next_attr_and_value(&p,
                                        attr, sizeof(attr),
-                                       value, sizeof(value))) {
+                                       value, value_size)) {
 
         res = parse_fmtp(stream, data, attr, value);
-        if (res < 0)
+        if (res < 0 && res != AVERROR_PATCHWELCOME) {
+            av_free(value);
             return res;
+        }
     }
+    av_free(value);
     return 0;
 }
-- 
1.7.0.4

From 648a3e23e9486442ce1b287410a18605a390dc1a Mon Sep 17 00:00:00 2001
From: Josh Allmann <[email protected]>
Date: Mon, 28 Jun 2010 00:19:11 -0700
Subject: [PATCH 09/11] Clean up FMTP parsing code in Xiph RTP depacketizer.

---
 libavformat/rtpdec_xiph.c |   29 ++++-------------------------
 1 files changed, 4 insertions(+), 25 deletions(-)

diff --git a/libavformat/rtpdec_xiph.c b/libavformat/rtpdec_xiph.c
index 34704a2..fa55f47 100644
--- a/libavformat/rtpdec_xiph.c
+++ b/libavformat/rtpdec_xiph.c
@@ -286,10 +286,11 @@ parse_packed_headers(const uint8_t * packed_headers,
     return 0;
 }
 
-static int xiph_parse_fmtp_pair(AVCodecContext * codec,
+static int xiph_parse_fmtp_pair(AVStream* stream,
                                 PayloadContext *xiph_data,
                                 char *attr, char *value)
 {
+    AVCodecContext *codec = stream->codec;
     int result = 0;
 
     if (!strcmp(attr, "sampling")) {
@@ -346,34 +347,12 @@ static int xiph_parse_sdp_line(AVFormatContext *s, int st_index,
                                  PayloadContext *data, const char *line)
 {
     const char *p;
-    char *value;
-    char attr[25];
-    int value_size = strlen(line), attr_size = sizeof(attr), res = 0;
-    AVCodecContext* codec = s->streams[st_index]->codec;
-
-    assert(data);
-
-    if (!(value = av_malloc(value_size))) {
-        av_log(codec, AV_LOG_ERROR, "Out of memory\n");
-        return AVERROR(ENOMEM);
-    }
 
     if (av_strstart(line, "fmtp:", &p)) {
-        // remove protocol identifier
-        while (*p && *p == ' ') p++; // strip spaces
-        while (*p && *p != ' ') p++; // eat protocol identifier
-        while (*p && *p == ' ') p++; // strip trailing spaces
-
-        while (ff_rtsp_next_attr_and_value(&p,
-                                           attr, attr_size,
-                                           value, value_size)) {
-            res = xiph_parse_fmtp_pair(codec, data, attr, value);
-            if (res < 0 && res != AVERROR_PATCHWELCOME)
-                return res;
-        }
+        return ff_parse_fmtp(s->streams[st_index], data, p,
+                             &xiph_parse_fmtp_pair);
     }
 
-    av_free(value);
     return 0;
 }
 
-- 
1.7.0.4

From 2a3458590fc686866894572b3229ca1ca8a80736 Mon Sep 17 00:00:00 2001
From: Josh Allmann <[email protected]>
Date: Mon, 28 Jun 2010 00:30:45 -0700
Subject: [PATCH 10/11] Clean up FMTP parsing code for AMR RTP depacketizer.

---
 libavformat/rtpdec_amr.c |   39 ++++++++++++++++++++-------------------
 1 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/libavformat/rtpdec_amr.c b/libavformat/rtpdec_amr.c
index a7b36c7..0d38a4a 100644
--- a/libavformat/rtpdec_amr.c
+++ b/libavformat/rtpdec_amr.c
@@ -120,34 +120,20 @@ static int amr_handle_packet(AVFormatContext *ctx,
     return 0;
 }
 
-static int amr_parse_sdp_line(AVFormatContext *s, int st_index,
-                              PayloadContext *data, const char *line)
+static int amr_parse_fmtp(AVStream *stream, PayloadContext *data,
+                          char *attr, char *value)
 {
-    const char *p;
-    char attr[25], value[25];
-
-    /* Parse an fmtp line this one:
-     * a=fmtp:97 octet-align=1; interleaving=0
-     * That is, a normal fmtp: line followed by semicolon & space
-     * separated key/value pairs.
-     */
-    if (av_strstart(line, "fmtp:", &p)) {
         int octet_align = 0;
         int crc = 0;
         int interleaving = 0;
         int channels = 1;
 
-        while (*p && *p == ' ') p++; /* strip spaces */
-        while (*p && *p != ' ') p++; /* eat protocol identifier */
-        while (*p && *p == ' ') p++; /* strip trailing spaces */
-
-        while (ff_rtsp_next_attr_and_value(&p, attr, sizeof(attr), value, sizeof(value))) {
             /* Some AMR SDP configurations contain "octet-align", without
              * the trailing =1. Therefore, if the value is empty,
              * interpret it as "1".
              */
             if (!strcmp(value, "")) {
-                av_log(s, AV_LOG_WARNING, "AMR fmtp attribute %s had "
+                av_log(stream, AV_LOG_WARNING, "AMR fmtp attribute %s had "
                                           "nonstandard empty value\n", attr);
                 strcpy(value, "1");
             }
@@ -159,11 +145,26 @@ static int amr_parse_sdp_line(AVFormatContext *s, int st_index,
                 interleaving = atoi(value);
             else if (!strcmp(attr, "channels"))
                 channels = atoi(value);
-        }
         if (!octet_align || crc || interleaving || channels != 1) {
-            av_log(s, AV_LOG_ERROR, "Unsupported RTP/AMR configuration!\n");
+            av_log(stream, AV_LOG_ERROR, "Unsupported RTP/AMR configuration!\n");
             return -1;
         }
+    return 0;
+}
+
+static int amr_parse_sdp_line(AVFormatContext *s, int st_index,
+                              PayloadContext *data, const char *line)
+{
+    const char *p;
+
+    /* Parse an fmtp line this one:
+     * a=fmtp:97 octet-align=1; interleaving=0
+     * That is, a normal fmtp: line followed by semicolon & space
+     * separated key/value pairs.
+     */
+    if (av_strstart(line, "fmtp:", &p)) {
+        return ff_parse_fmtp(s->streams[st_index], data, p,
+                             &amr_parse_fmtp);
     }
     return 0;
 }
-- 
1.7.0.4

From 7bdebb322bc56dce8eb867c00a7bbe6c64266398 Mon Sep 17 00:00:00 2001
From: Josh Allmann <[email protected]>
Date: Mon, 28 Jun 2010 00:46:57 -0700
Subject: [PATCH 11/11] amr rtp cosmetics

---
 libavformat/rtpdec_amr.c |   56 ++++++++++++++++++++++++---------------------
 1 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/libavformat/rtpdec_amr.c b/libavformat/rtpdec_amr.c
index 0d38a4a..b01afd0 100644
--- a/libavformat/rtpdec_amr.c
+++ b/libavformat/rtpdec_amr.c
@@ -123,32 +123,35 @@ static int amr_handle_packet(AVFormatContext *ctx,
 static int amr_parse_fmtp(AVStream *stream, PayloadContext *data,
                           char *attr, char *value)
 {
-        int octet_align = 0;
-        int crc = 0;
-        int interleaving = 0;
-        int channels = 1;
-
-            /* Some AMR SDP configurations contain "octet-align", without
-             * the trailing =1. Therefore, if the value is empty,
-             * interpret it as "1".
-             */
-            if (!strcmp(value, "")) {
-                av_log(stream, AV_LOG_WARNING, "AMR fmtp attribute %s had "
-                                          "nonstandard empty value\n", attr);
-                strcpy(value, "1");
-            }
-            if (!strcmp(attr, "octet-align"))
-                octet_align = atoi(value);
-            else if (!strcmp(attr, "crc"))
-                crc = atoi(value);
-            else if (!strcmp(attr, "interleaving"))
-                interleaving = atoi(value);
-            else if (!strcmp(attr, "channels"))
-                channels = atoi(value);
-        if (!octet_align || crc || interleaving || channels != 1) {
-            av_log(stream, AV_LOG_ERROR, "Unsupported RTP/AMR configuration!\n");
-            return -1;
-        }
+    int octet_align = 0;
+    int crc = 0;
+    int interleaving = 0;
+    int channels = 1;
+
+    /* Some AMR SDP configurations contain "octet-align", without
+     * the trailing =1. Therefore, if the value is empty,
+     * interpret it as "1".
+     */
+    if (!strcmp(value, "")) {
+        av_log(stream, AV_LOG_WARNING, "AMR fmtp attribute %s had "
+                                        "nonstandard empty value\n", attr);
+        strcpy(value, "1");
+    }
+
+    if (!strcmp(attr, "octet-align"))
+        octet_align = atoi(value);
+    else if (!strcmp(attr, "crc"))
+        crc = atoi(value);
+    else if (!strcmp(attr, "interleaving"))
+        interleaving = atoi(value);
+    else if (!strcmp(attr, "channels"))
+        channels = atoi(value);
+
+    if (!octet_align || crc || interleaving || channels != 1) {
+        av_log(stream, AV_LOG_ERROR, "Unsupported RTP/AMR configuration!\n");
+        return -1;
+    }
+
     return 0;
 }
 
@@ -166,6 +169,7 @@ static int amr_parse_sdp_line(AVFormatContext *s, int st_index,
         return ff_parse_fmtp(s->streams[st_index], data, p,
                              &amr_parse_fmtp);
     }
+
     return 0;
 }
 
-- 
1.7.0.4

_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc

Reply via email to