]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/dxa.c
Remove unnecessary header inclusion directives.
[ffmpeg] / libavformat / dxa.c
index f49d3d4acfb79c818670da7daff8196def11518a..c00c917d0b9c776276e78e1aebbc0cfbd690e359 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * DXA demuxer
- * Copyright (c) 2007 Konstantin Shishkov.
+ * Copyright (c) 2007 Konstantin Shishkov
  *
  * This file is part of FFmpeg.
  *
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "riff.h"
 
@@ -35,11 +36,15 @@ typedef struct{
 
 static int dxa_probe(AVProbeData *p)
 {
-    /* check file header */
-    if (p->buf_size <= 4)
+    int w, h;
+    if (p->buf_size < 15)
         return 0;
+    w = AV_RB16(p->buf + 11);
+    h = AV_RB16(p->buf + 13);
+    /* check file header */
     if (p->buf[0] == 'D' && p->buf[1] == 'E' &&
-        p->buf[2] == 'X' && p->buf[3] == 'A')
+        p->buf[2] == 'X' && p->buf[3] == 'A' &&
+        w && w <= 2048 && h && h <= 2048)
         return AVPROBE_SCORE_MAX;
     else
         return 0;
@@ -47,7 +52,7 @@ static int dxa_probe(AVProbeData *p)
 
 static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
 {
-    ByteIOContext *pb = &s->pb;
+    ByteIOContext *pb = s->pb;
     DXAContext *c = s->priv_data;
     AVStream *st, *ast;
     uint32_t tag;
@@ -97,7 +102,7 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
         ast = av_new_stream(s, 0);
         if (!ast)
             return -1;
-        get_wav_header(pb, ast->codec, fsize);
+        ff_get_wav_header(pb, ast->codec, fsize);
         // find 'data' chunk
         while(url_ftell(pb) < c->vidpos && !url_feof(pb)){
             tag = get_le32(pb);
@@ -114,7 +119,7 @@ static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap)
     }
 
     /* now we are ready: build format streams */
-    st->codec->codec_type = CODEC_TYPE_VIDEO;
+    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codec->codec_id   = CODEC_ID_DXA;
     st->codec->width      = w;
     st->codec->height     = h;
@@ -146,54 +151,54 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     if(!c->readvid && c->has_sound && c->bytes_left){
         c->readvid = 1;
-        url_fseek(&s->pb, c->wavpos, SEEK_SET);
+        url_fseek(s->pb, c->wavpos, SEEK_SET);
         size = FFMIN(c->bytes_left, c->bpc);
-        ret = av_get_packet(&s->pb, pkt, size);
+        ret = av_get_packet(s->pb, pkt, size);
         pkt->stream_index = 1;
         if(ret != size)
-            return AVERROR_IO;
+            return AVERROR(EIO);
         c->bytes_left -= size;
-        c->wavpos = url_ftell(&s->pb);
+        c->wavpos = url_ftell(s->pb);
         return 0;
     }
-    url_fseek(&s->pb, c->vidpos, SEEK_SET);
-    while(!url_feof(&s->pb) && c->frames){
-        get_buffer(&s->pb, buf, 4);
+    url_fseek(s->pb, c->vidpos, SEEK_SET);
+    while(!url_feof(s->pb) && c->frames){
+        get_buffer(s->pb, buf, 4);
         switch(AV_RL32(buf)){
         case MKTAG('N', 'U', 'L', 'L'):
             if(av_new_packet(pkt, 4 + pal_size) < 0)
-                return AVERROR_NOMEM;
+                return AVERROR(ENOMEM);
             pkt->stream_index = 0;
             if(pal_size) memcpy(pkt->data, pal, pal_size);
             memcpy(pkt->data + pal_size, buf, 4);
             c->frames--;
-            c->vidpos = url_ftell(&s->pb);
+            c->vidpos = url_ftell(s->pb);
             c->readvid = 0;
             return 0;
         case MKTAG('C', 'M', 'A', 'P'):
             pal_size = 768+4;
             memcpy(pal, buf, 4);
-            get_buffer(&s->pb, pal + 4, 768);
+            get_buffer(s->pb, pal + 4, 768);
             break;
         case MKTAG('F', 'R', 'A', 'M'):
-            get_buffer(&s->pb, buf + 4, DXA_EXTRA_SIZE - 4);
+            get_buffer(s->pb, buf + 4, DXA_EXTRA_SIZE - 4);
             size = AV_RB32(buf + 5);
             if(size > 0xFFFFFF){
                 av_log(s, AV_LOG_ERROR, "Frame size is too big: %d\n", size);
                 return -1;
             }
             if(av_new_packet(pkt, size + DXA_EXTRA_SIZE + pal_size) < 0)
-                return AVERROR_NOMEM;
+                return AVERROR(ENOMEM);
             memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE);
-            ret = get_buffer(&s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
+            ret = get_buffer(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
             if(ret != size){
                 av_free_packet(pkt);
-                return AVERROR_IO;
+                return AVERROR(EIO);
             }
             if(pal_size) memcpy(pkt->data, pal, pal_size);
             pkt->stream_index = 0;
             c->frames--;
-            c->vidpos = url_ftell(&s->pb);
+            c->vidpos = url_ftell(s->pb);
             c->readvid = 0;
             return 0;
         default:
@@ -206,7 +211,7 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
 
 AVInputFormat dxa_demuxer = {
     "dxa",
-    "dxa",
+    NULL_IF_CONFIG_SMALL("DXA"),
     sizeof(DXAContext),
     dxa_probe,
     dxa_read_header,