From 71194ef6a8ffe7cfd32b0db465de9f1fd0202eb3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
Date: Tue, 8 Jan 2013 23:21:15 +0200
Subject: [PATCH 1/3] rtpdec_vp8: Mark broken packets with AV_PKT_FLAG_CORRUPT
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This allows the caller to either include them (and get more packets
decoded, but possibly some nonperfect frames), or discard them (by
setting fflags=discardcorrupt).

Signed-off-by: Martin Storsjö <martin@martin.st>
---
 libavformat/rtpdec_vp8.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavformat/rtpdec_vp8.c b/libavformat/rtpdec_vp8.c
index 96a1a3407e..c1bffaac0d 100644
--- a/libavformat/rtpdec_vp8.c
+++ b/libavformat/rtpdec_vp8.c
@@ -90,6 +90,8 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8,
             if (ret < 0)
                 return ret;
             *timestamp = vp8->timestamp;
+            if (vp8->sequence_dirty)
+                pkt->flags |= AV_PKT_FLAG_CORRUPT;
             return 0;
         }
         return AVERROR(EAGAIN);
@@ -199,6 +201,7 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8,
                     if (ret < 0)
                         return ret;
                     pkt->size = vp8->first_part_size;
+                    pkt->flags |= AV_PKT_FLAG_CORRUPT;
                     returned_old_frame = 1;
                     old_timestamp = vp8->timestamp;
                 } else {
@@ -261,6 +264,8 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8,
             return ret;
         if (vp8->broken_frame)
             pkt->size = vp8->first_part_size;
+        if (vp8->sequence_dirty)
+            pkt->flags |= AV_PKT_FLAG_CORRUPT;
         return 0;
     }
 

From 3f98848d6e04a11f28e776b665fb14e58d56e015 Mon Sep 17 00:00:00 2001
From: Justin Ruggles <justin.ruggles@gmail.com>
Date: Sun, 23 Dec 2012 13:17:05 -0500
Subject: [PATCH 2/3] au: validate bits-per-sample separately from codec tag

---
 libavformat/au.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavformat/au.c b/libavformat/au.c
index 8f9a3facd1..5499c6bd75 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -64,6 +64,7 @@ static int au_read_header(AVFormatContext *s)
     unsigned int tag;
     AVIOContext *pb = s->pb;
     unsigned int id, channels, rate;
+    int bps;
     enum AVCodecID codec;
     AVStream *st;
 
@@ -80,7 +81,13 @@ static int au_read_header(AVFormatContext *s)
 
     codec = ff_codec_get_id(codec_au_tags, id);
 
-    if (!av_get_bits_per_sample(codec)) {
+    if (codec == AV_CODEC_ID_NONE) {
+        av_log_ask_for_sample(s, "unknown or unsupported codec tag: %d\n", id);
+        return AVERROR_PATCHWELCOME;
+    }
+
+    bps = av_get_bits_per_sample(codec);
+    if (!bps) {
         av_log_ask_for_sample(s, "could not determine bits per sample\n");
         return AVERROR_PATCHWELCOME;
     }

From 9a7b56883d1333cdfcdf0fa7584a333841b86114 Mon Sep 17 00:00:00 2001
From: Justin Ruggles <justin.ruggles@gmail.com>
Date: Sun, 23 Dec 2012 13:19:31 -0500
Subject: [PATCH 3/3] au: set bit rate

---
 libavformat/au.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/au.c b/libavformat/au.c
index 5499c6bd75..f1038da64b 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -111,6 +111,7 @@ static int au_read_header(AVFormatContext *s)
     st->codec->codec_id = codec;
     st->codec->channels = channels;
     st->codec->sample_rate = rate;
+    st->codec->bit_rate    = channels * rate * bps;
     avpriv_set_pts_info(st, 64, 1, rate);
     return 0;
 }