[PATCH] Do not send packets with no video data to decoder

Adam Iglewski adam.iglewski
Sat May 9 01:53:12 CEST 2009


---
 libavformat/westwood.c |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/libavformat/westwood.c b/libavformat/westwood.c
index 8726385..9f988aa 100644
--- a/libavformat/westwood.c
+++ b/libavformat/westwood.c
@@ -84,6 +84,8 @@ typedef struct WsVqaDemuxContext {
     int video_stream_index;
 
     int64_t audio_frame_counter;
+    unsigned int vqfl_chunk_size;
+    unsigned char* vqfl_chunk_data;
 } WsVqaDemuxContext;
 
 static int wsaud_probe(AVProbeData *p)
@@ -314,6 +316,8 @@ static int wsvqa_read_header(AVFormatContext *s,
         url_fseek(pb, chunk_size, SEEK_CUR);
     } while (chunk_tag != FINF_TAG);
 
+    wsvqa->vqfl_chunk_size=0;
+    wsvqa->vqfl_chunk_data=NULL;
     return 0;
 }
 
@@ -333,8 +337,33 @@ static int wsvqa_read_packet(AVFormatContext *s,
         chunk_size = AV_RB32(&preamble[4]);
         skip_byte = chunk_size & 0x01;
 
-        if ((chunk_type == SND1_TAG) || (chunk_type == SND2_TAG) || (chunk_type == VQFR_TAG) || (chunk_type == VQFL_TAG)) {
+        if (chunk_type == VQFL_TAG) {
 
+            wsvqa->vqfl_chunk_size = chunk_size;
+            wsvqa->vqfl_chunk_data = av_mallocz(chunk_size);
+            if (!wsvqa->vqfl_chunk_data)
+                return AVERROR(ENOMEM);
+            ret = get_buffer(pb, wsvqa->vqfl_chunk_data, chunk_size);
+            if (ret != chunk_size)
+                return AVERROR(EIO);
+            if (skip_byte)
+                url_fseek(pb, 1, SEEK_CUR);
+            continue;
+
+        } else if ((chunk_type == SND1_TAG) || (chunk_type == SND2_TAG) || (chunk_type == VQFR_TAG)) {
+
+            if ((chunk_type == VQFR_TAG) && wsvqa->vqfl_chunk_size) {
+                if (av_new_packet(pkt, chunk_size + wsvqa->vqfl_chunk_size))
+                    return AVERROR(EIO);
+                ret = get_buffer(pb, pkt->data, chunk_size);
+                if (ret != chunk_size) {
+                    av_free_packet(pkt);
+                    return AVERROR(EIO);
+                }
+                memcpy(pkt->data + chunk_size,wsvqa->vqfl_chunk_data,wsvqa->vqfl_chunk_size);
+                wsvqa->vqfl_chunk_size=0;
+                av_free(wsvqa->vqfl_chunk_data);
+            } else {
             if (av_new_packet(pkt, chunk_size))
                 return AVERROR(EIO);
             ret = get_buffer(pb, pkt->data, chunk_size);
@@ -342,6 +371,7 @@ static int wsvqa_read_packet(AVFormatContext *s,
                 av_free_packet(pkt);
                 return AVERROR(EIO);
             }
+            }
 
             if (chunk_type == SND2_TAG) {
                 pkt->stream_index = wsvqa->audio_stream_index;
-- 
1.6.0.4



--------------000406070301060204010203
Content-Type: text/x-diff;
 name="0005-Simplify-decode_format80-function.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0005-Simplify-decode_format80-function.patch"




More information about the ffmpeg-devel mailing list