]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/rmdec.c
Do not declare a counter as unsigned when it is not needed
[ffmpeg] / libavformat / rmdec.c
index c5c3969abf51bd5df33a6da64028bc9695f36145..aa8bda7e3c6aeec755dc76ef724303dfada80cf0 100644 (file)
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
+
+#include "libavutil/avstring.h"
 #include "avformat.h"
 #include "rm.h"
-#include "avstring.h"
 
 static inline void get_strl(ByteIOContext *pb, char *buf, int buf_size, int len)
 {
@@ -234,6 +235,8 @@ ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVStream *st)
             return -1;
         }
         st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+        if (!st->codec->extradata)
+            return AVERROR(ENOMEM);
         get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
 
 //        av_log(NULL, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2);
@@ -274,7 +277,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
     AVStream *st;
     ByteIOContext *pb = s->pb;
     unsigned int tag;
-    int tag_size, i;
+    int tag_size;
     unsigned int start_time, duration;
     char buf[128];
     int flags = 0;
@@ -294,7 +297,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
 
     for(;;) {
         if (url_feof(pb))
-            goto fail;
+            return -1;
         tag = get_le32(pb);
         tag_size = get_be32(pb);
         get_be16(pb);
@@ -308,7 +311,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
                tag_size);
 #endif
         if (tag_size < 10 && tag != MKTAG('D', 'A', 'T', 'A'))
-            goto fail;
+            return -1;
         switch(tag) {
         case MKTAG('P', 'R', 'O', 'P'):
             /* file header */
@@ -333,7 +336,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
         case MKTAG('M', 'D', 'P', 'R'):
             st = av_new_stream(s, 0);
             if (!st)
-                goto fail;
+                return AVERROR(ENOMEM);
             st->id = get_be16(pb);
             get_be32(pb); /* max bit rate */
             st->codec->bit_rate = get_be32(pb); /* bit rate */
@@ -366,12 +369,6 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
     get_be32(pb); /* next data header */
     rm->curpic_num = -1;
     return 0;
-
- fail:
-    for(i=0;i<s->nb_streams;i++) {
-        av_free(s->streams[i]);
-    }
-    return AVERROR(EIO);
 }
 
 static int get_num(ByteIOContext *pb, int *len)
@@ -401,7 +398,7 @@ static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_
     uint32_t state=0xFFFFFFFF;
 
     while(!url_feof(pb)){
-        *pos= url_ftell(pb);
+        *pos= url_ftell(pb) - 3;
         if(rm->remaining_len > 0){
             num= rm->current_stream;
             len= rm->remaining_len;
@@ -609,10 +606,10 @@ ff_rm_parse_packet (AVFormatContext *s, AVStream *st, int len, AVPacket *pkt,
                 av_get_packet(pb, pkt, rm->sub_packet_lengths[0]);
                 *flags = 2; // Mark first packet as keyframe
             }
-        } else
+        } else {
             av_get_packet(pb, pkt, len);
             rm_ac3_swap_bytes(st, pkt);
-
+        }
     } else
         av_get_packet(pb, pkt, len);
 
@@ -716,7 +713,7 @@ resync:
         if (ff_rm_parse_packet (s, st, len, pkt, &seq, &flags, &timestamp) < 0)
             goto resync;
 
-        if( (flags&2) && (seq&0x7F) == 1 )
+        if((flags&2) && (seq&0x7F) == 1)
             av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME);
     }
 
@@ -790,7 +787,7 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index,
 
 AVInputFormat rm_demuxer = {
     "rm",
-    "rm format",
+    NULL_IF_CONFIG_SMALL("RM format"),
     sizeof(RMContext),
     rm_probe,
     rm_read_header,