]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/raw.c
Remove unused variables, fixes the following warnings:
[ffmpeg] / libavformat / raw.c
index 32b439b01695eb3f6b55290cb15148d12e9615b4..bd9380315ca6b54b1234a48967a8c8ec2fa31fdc 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include "avformat.h"
-#include "ac3.h"
+#include "ac3_parser.h"
+#include "raw.h"
 
 #ifdef CONFIG_MUXERS
 /* simple formats */
-static int raw_write_header(struct AVFormatContext *s)
-{
-    return 0;
-}
-
 static int flac_write_header(struct AVFormatContext *s)
 {
     static const uint8_t header[8] = {
@@ -43,15 +39,23 @@ static int flac_write_header(struct AVFormatContext *s)
     return 0;
 }
 
-static int raw_write_packet(struct AVFormatContext *s, AVPacket *pkt)
+
+static int roq_write_header(struct AVFormatContext *s)
 {
-    put_buffer(&s->pb, pkt->data, pkt->size);
+    static const uint8_t header[] = {
+        0x84, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x00
+    };
+
+    put_buffer(&s->pb, header, 8);
     put_flush_packet(&s->pb);
+
     return 0;
 }
 
-static int raw_write_trailer(struct AVFormatContext *s)
+static int raw_write_packet(struct AVFormatContext *s, AVPacket *pkt)
 {
+    put_buffer(&s->pb, pkt->data, pkt->size);
+    put_flush_packet(&s->pb);
     return 0;
 }
 #endif //CONFIG_MUXERS
@@ -64,7 +68,7 @@ static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
 
     st = av_new_stream(s, 0);
     if (!st)
-        return AVERROR_NOMEM;
+        return AVERROR(ENOMEM);
 
         id = s->iformat->value;
         if (id == CODEC_ID_RAWVIDEO) {
@@ -107,7 +111,7 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     pkt->stream_index = 0;
     if (ret <= 0) {
-        return AVERROR_IO;
+        return AVERROR(EIO);
     }
     /* note: we need to modify the packet size here to handle the last
        packet */
@@ -122,14 +126,14 @@ static int raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
     size = RAW_PACKET_SIZE;
 
     if (av_new_packet(pkt, size) < 0)
-        return AVERROR_IO;
+        return AVERROR(EIO);
 
     pkt->pos= url_ftell(&s->pb);
     pkt->stream_index = 0;
     ret = get_partial_buffer(&s->pb, pkt->data, size);
     if (ret <= 0) {
         av_free_packet(pkt);
-        return AVERROR_IO;
+        return AVERROR(EIO);
     }
     pkt->size = ret;
     return ret;
@@ -141,7 +145,7 @@ static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
     int ret, size, w, h, unk1, unk2;
 
     if (get_le32(&s->pb) != MKTAG('M', 'J', 'P', 'G'))
-        return AVERROR_IO; // FIXME
+        return AVERROR(EIO); // FIXME
 
     size = get_le32(&s->pb);
 
@@ -158,14 +162,14 @@ static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
         size, w, h, unk1, unk2);
 
     if (av_new_packet(pkt, size) < 0)
-        return AVERROR_IO;
+        return AVERROR(EIO);
 
     pkt->pos = url_ftell(&s->pb);
     pkt->stream_index = 0;
     ret = get_buffer(&s->pb, pkt->data, size);
     if (ret <= 0) {
         av_free_packet(pkt);
-        return AVERROR_IO;
+        return AVERROR(EIO);
     }
     pkt->size = ret;
     return ret;
@@ -214,11 +218,11 @@ static int ac3_read_header(AVFormatContext *s,
 
     st = av_new_stream(s, 0);
     if (!st)
-        return AVERROR_NOMEM;
+        return AVERROR(ENOMEM);
 
     st->codec->codec_type = CODEC_TYPE_AUDIO;
     st->codec->codec_id = CODEC_ID_AC3;
-    st->need_parsing = 1;
+    st->need_parsing = AVSTREAM_PARSE_FULL;
     /* the parameters will be extracted from the compressed bitstream */
     return 0;
 }
@@ -230,10 +234,10 @@ static int shorten_read_header(AVFormatContext *s,
 
     st = av_new_stream(s, 0);
     if (!st)
-        return AVERROR_NOMEM;
+        return AVERROR(ENOMEM);
     st->codec->codec_type = CODEC_TYPE_AUDIO;
     st->codec->codec_id = CODEC_ID_SHORTEN;
-    st->need_parsing = 1;
+    st->need_parsing = AVSTREAM_PARSE_FULL;
     /* the parameters will be extracted from the compressed bitstream */
     return 0;
 }
@@ -246,10 +250,10 @@ static int flac_read_header(AVFormatContext *s,
 
     st = av_new_stream(s, 0);
     if (!st)
-        return AVERROR_NOMEM;
+        return AVERROR(ENOMEM);
     st->codec->codec_type = CODEC_TYPE_AUDIO;
     st->codec->codec_id = CODEC_ID_FLAC;
-    st->need_parsing = 1;
+    st->need_parsing = AVSTREAM_PARSE_FULL;
     /* the parameters will be extracted from the compressed bitstream */
     return 0;
 }
@@ -262,11 +266,11 @@ static int dts_read_header(AVFormatContext *s,
 
     st = av_new_stream(s, 0);
     if (!st)
-        return AVERROR_NOMEM;
+        return AVERROR(ENOMEM);
 
     st->codec->codec_type = CODEC_TYPE_AUDIO;
     st->codec->codec_id = CODEC_ID_DTS;
-    st->need_parsing = 1;
+    st->need_parsing = AVSTREAM_PARSE_FULL;
     /* the parameters will be extracted from the compressed bitstream */
     return 0;
 }
@@ -279,11 +283,11 @@ static int aac_read_header(AVFormatContext *s,
 
     st = av_new_stream(s, 0);
     if (!st)
-        return AVERROR_NOMEM;
+        return AVERROR(ENOMEM);
 
     st->codec->codec_type = CODEC_TYPE_AUDIO;
     st->codec->codec_id = CODEC_ID_AAC;
-    st->need_parsing = 1;
+    st->need_parsing = AVSTREAM_PARSE_FULL;
     /* the parameters will be extracted from the compressed bitstream */
     return 0;
 }
@@ -296,14 +300,14 @@ static int video_read_header(AVFormatContext *s,
 
     st = av_new_stream(s, 0);
     if (!st)
-        return AVERROR_NOMEM;
+        return AVERROR(ENOMEM);
 
     st->codec->codec_type = CODEC_TYPE_VIDEO;
     st->codec->codec_id = s->iformat->value;
-    st->need_parsing = 1;
+    st->need_parsing = AVSTREAM_PARSE_FULL;
 
     /* for mjpeg, specify frame rate */
-    /* for mpeg4 specify it too (most mpeg4 streams dont have the fixed_vop_rate set ...)*/
+    /* for mpeg4 specify it too (most mpeg4 streams do not have the fixed_vop_rate set ...)*/
     if (ap->time_base.num) {
         av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
     } else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
@@ -347,32 +351,29 @@ static int mpegvideo_probe(AVProbeData *p)
     return 0;
 }
 
-#define VIDEO_OBJECT_START_CODE        0x00000100
-#define VIDEO_OBJECT_LAYER_START_CODE  0x00000120
 #define VISUAL_OBJECT_START_CODE       0x000001b5
 #define VOP_START_CODE                 0x000001b6
 
 static int mpeg4video_probe(AVProbeData *probe_packet)
 {
     uint32_t temp_buffer= -1;
-    int VO=0, VOL=0, VOP = 0, VISO = 0;
+    int VO=0, VOL=0, VOP = 0, VISO = 0, res=0;
     int i;
 
     for(i=0; i<probe_packet->buf_size; i++){
         temp_buffer = (temp_buffer<<8) + probe_packet->buf[i];
-        if ((temp_buffer & 0xffffff00) == 0x100) {
-            switch(temp_buffer){
-            case VOP_START_CODE:             VOP++; break;
-            case VISUAL_OBJECT_START_CODE:  VISO++; break;
-            }
-            switch(temp_buffer & 0xfffffff0){
-            case VIDEO_OBJECT_START_CODE:            VO++; break;
-            case VIDEO_OBJECT_LAYER_START_CODE:     VOL++; break;
-            }
-        }
+        if ((temp_buffer & 0xffffff00) != 0x100)
+            continue;
+
+        if (temp_buffer == VOP_START_CODE)                         VOP++;
+        else if (temp_buffer == VISUAL_OBJECT_START_CODE)          VISO++;
+        else if (temp_buffer < 0x120)                              VO++;
+        else if (temp_buffer < 0x130)                              VOL++;
+        else if (   !(0x1AF < temp_buffer && temp_buffer < 0x1B7)
+                 && !(0x1B9 < temp_buffer && temp_buffer < 0x1C4)) res++;
     }
 
-    if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0)
+    if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res==0)
         return AVPROBE_SCORE_MAX/2;
     return 0;
 }
@@ -405,16 +406,13 @@ static int h261_probe(AVProbeData *p)
 
 static int ac3_probe(AVProbeData *p)
 {
-    int max_frames, first_frames, frames;
+    int max_frames, first_frames = 0, frames;
     uint8_t *buf, *buf2, *end;
     AC3HeaderInfo hdr;
 
-    if(p->buf_size < 7)
-        return 0;
-
     max_frames = 0;
     buf = p->buf;
-    end = buf + FFMIN(4096, p->buf_size - 7);
+    end = buf + p->buf_size;
 
     for(; buf < end; buf++) {
         buf2 = buf;
@@ -434,6 +432,12 @@ static int ac3_probe(AVProbeData *p)
     else                   return 0;
 }
 
+static int flac_probe(AVProbeData *p)
+{
+    if(memcmp(p->buf, "fLaC", 4)) return 0;
+    else                          return AVPROBE_SCORE_MAX / 2;
+}
+
 AVInputFormat shorten_demuxer = {
     "shn",
     "raw shorten",
@@ -450,7 +454,7 @@ AVInputFormat flac_demuxer = {
     "flac",
     "raw flac",
     0,
-    NULL,
+    flac_probe,
     flac_read_header,
     raw_read_partial_packet,
     raw_read_close,
@@ -469,11 +473,11 @@ AVOutputFormat flac_muxer = {
     0,
     flac_write_header,
     raw_write_packet,
-    raw_write_trailer,
     .flags= AVFMT_NOTIMESTAMPS,
 };
 #endif //CONFIG_MUXERS
 
+#ifdef CONFIG_AC3_DEMUXER
 AVInputFormat ac3_demuxer = {
     "ac3",
     "raw ac3",
@@ -485,6 +489,7 @@ AVInputFormat ac3_demuxer = {
     .flags= AVFMT_GENERIC_INDEX,
     .extensions = "ac3",
 };
+#endif
 
 #ifdef CONFIG_MUXERS
 AVOutputFormat ac3_muxer = {
@@ -495,9 +500,8 @@ AVOutputFormat ac3_muxer = {
     0,
     CODEC_ID_AC3,
     0,
-    raw_write_header,
+    NULL,
     raw_write_packet,
-    raw_write_trailer,
     .flags= AVFMT_NOTIMESTAMPS,
 };
 #endif //CONFIG_MUXERS
@@ -526,6 +530,21 @@ AVInputFormat aac_demuxer = {
     .extensions = "aac",
 };
 
+#ifdef CONFIG_ROQ_MUXER
+AVOutputFormat roq_muxer =
+{
+    "RoQ",
+    "Id RoQ format",
+    NULL,
+    "roq",
+    0,
+    CODEC_ID_ROQ_DPCM,
+    CODEC_ID_ROQ,
+    roq_write_header,
+    raw_write_packet,
+};
+#endif //CONFIG_ROQ_MUXER
+
 AVInputFormat h261_demuxer = {
     "h261",
     "raw h261",
@@ -548,9 +567,8 @@ AVOutputFormat h261_muxer = {
     0,
     0,
     CODEC_ID_H261,
-    raw_write_header,
+    NULL,
     raw_write_packet,
-    raw_write_trailer,
     .flags= AVFMT_NOTIMESTAMPS,
 };
 #endif //CONFIG_MUXERS
@@ -577,9 +595,8 @@ AVOutputFormat h263_muxer = {
     0,
     0,
     CODEC_ID_H263,
-    raw_write_header,
+    NULL,
     raw_write_packet,
-    raw_write_trailer,
     .flags= AVFMT_NOTIMESTAMPS,
 };
 #endif //CONFIG_MUXERS
@@ -606,9 +623,8 @@ AVOutputFormat m4v_muxer = {
     0,
     CODEC_ID_NONE,
     CODEC_ID_MPEG4,
-    raw_write_header,
+    NULL,
     raw_write_packet,
-    raw_write_trailer,
     .flags= AVFMT_NOTIMESTAMPS,
 };
 #endif //CONFIG_MUXERS
@@ -635,9 +651,8 @@ AVOutputFormat h264_muxer = {
     0,
     CODEC_ID_NONE,
     CODEC_ID_H264,
-    raw_write_header,
+    NULL,
     raw_write_packet,
-    raw_write_trailer,
     .flags= AVFMT_NOTIMESTAMPS,
 };
 #endif //CONFIG_MUXERS
@@ -663,9 +678,8 @@ AVOutputFormat mpeg1video_muxer = {
     0,
     0,
     CODEC_ID_MPEG1VIDEO,
-    raw_write_header,
+    NULL,
     raw_write_packet,
-    raw_write_trailer,
     .flags= AVFMT_NOTIMESTAMPS,
 };
 #endif //CONFIG_MUXERS
@@ -679,9 +693,8 @@ AVOutputFormat mpeg2video_muxer = {
     0,
     0,
     CODEC_ID_MPEG2VIDEO,
-    raw_write_header,
+    NULL,
     raw_write_packet,
-    raw_write_trailer,
     .flags= AVFMT_NOTIMESTAMPS,
 };
 #endif //CONFIG_MUXERS
@@ -721,9 +734,8 @@ AVOutputFormat mjpeg_muxer = {
     0,
     0,
     CODEC_ID_MJPEG,
-    raw_write_header,
+    NULL,
     raw_write_packet,
-    raw_write_trailer,
     .flags= AVFMT_NOTIMESTAMPS,
 };
 #endif //CONFIG_MUXERS
@@ -766,9 +778,8 @@ AVOutputFormat pcm_ ## name ## _muxer = {\
     0,\
     codec,\
     0,\
-    raw_write_header,\
+    NULL,\
     raw_write_packet,\
-    raw_write_trailer,\
     .flags= AVFMT_NOTIMESTAMPS,\
 };
 
@@ -836,7 +847,7 @@ static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     pkt->stream_index = 0;
     if (ret != packet_size) {
-        return AVERROR_IO;
+        return AVERROR(EIO);
     } else {
         return 0;
     }
@@ -851,7 +862,7 @@ AVInputFormat rawvideo_demuxer = {
     rawvideo_read_packet,
     raw_read_close,
     .flags= AVFMT_GENERIC_INDEX,
-    .extensions = "yuv,cif,qcif",
+    .extensions = "yuv,cif,qcif,rgb",
     .value = CODEC_ID_RAWVIDEO,
 };
 
@@ -860,13 +871,12 @@ AVOutputFormat rawvideo_muxer = {
     "rawvideo",
     "raw video format",
     NULL,
-    "yuv",
+    "yuv,rgb",
     0,
     CODEC_ID_NONE,
     CODEC_ID_RAWVIDEO,
-    raw_write_header,
+    NULL,
     raw_write_packet,
-    raw_write_trailer,
     .flags= AVFMT_NOTIMESTAMPS,
 };
 #endif //CONFIG_MUXERS
@@ -889,9 +899,8 @@ AVOutputFormat null_muxer = {
     CODEC_ID_PCM_S16LE,
 #endif
     CODEC_ID_RAWVIDEO,
-    raw_write_header,
+    NULL,
     null_write_packet,
-    raw_write_trailer,
     .flags = AVFMT_NOFILE | AVFMT_RAWPICTURE | AVFMT_NOTIMESTAMPS,
 };
 #endif //CONFIG_MUXERS