rtpdec_mpeg4: add more verbose error logging
authorGilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Fri, 20 Feb 2015 21:41:58 +0000 (23:41 +0200)
committerMartin Storsjö <martin@martin.st>
Sat, 21 Feb 2015 21:37:58 +0000 (23:37 +0200)
Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/rtpdec_mpeg4.c

index 0c0d336..ac9d918 100644 (file)
@@ -171,12 +171,18 @@ static int aac_parse_packet(AVFormatContext *ctx, PayloadContext *data,
     int ret;
 
     if (!buf) {
-        if (data->cur_au_index > data->nb_au_headers)
+        if (data->cur_au_index > data->nb_au_headers) {
+            av_log(ctx, AV_LOG_ERROR, "Invalid parser state\n");
             return AVERROR_INVALIDDATA;
-        if (data->buf_size - data->buf_pos < data->au_headers[data->cur_au_index].size)
+        }
+        if (data->buf_size - data->buf_pos < data->au_headers[data->cur_au_index].size) {
+            av_log(ctx, AV_LOG_ERROR, "Invalid AU size\n");
             return AVERROR_INVALIDDATA;
-        if ((ret = av_new_packet(pkt, data->au_headers[data->cur_au_index].size)) < 0)
+        }
+        if ((ret = av_new_packet(pkt, data->au_headers[data->cur_au_index].size)) < 0) {
+            av_log(ctx, AV_LOG_ERROR, "Out of memory\n");
             return ret;
+        }
         memcpy(pkt->data, &data->buf[data->buf_pos], data->au_headers[data->cur_au_index].size);
         data->buf_pos += data->au_headers[data->cur_au_index].size;
         pkt->stream_index = st->index;
@@ -184,16 +190,22 @@ static int aac_parse_packet(AVFormatContext *ctx, PayloadContext *data,
         return data->cur_au_index < data->nb_au_headers;
     }
 
-    if (rtp_parse_mp4_au(data, buf, len))
+    if (rtp_parse_mp4_au(data, buf, len)) {
+        av_log(ctx, AV_LOG_ERROR, "Error parsing AU headers\n");
         return -1;
+    }
 
     buf += data->au_headers_length_bytes + 2;
     len -= data->au_headers_length_bytes + 2;
 
-    if (len < data->au_headers[0].size)
+    if (len < data->au_headers[0].size) {
+        av_log(ctx, AV_LOG_ERROR, "First AU larger than packet size\n");
         return AVERROR_INVALIDDATA;
-    if ((ret = av_new_packet(pkt, data->au_headers[0].size)) < 0)
+    }
+    if ((ret = av_new_packet(pkt, data->au_headers[0].size)) < 0) {
+        av_log(ctx, AV_LOG_ERROR, "Out of memory\n");
         return ret;
+    }
     memcpy(pkt->data, buf, data->au_headers[0].size);
     len -= data->au_headers[0].size;
     buf += data->au_headers[0].size;