]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/raw.c
Fix breakage introduced by setting the sample_fmt to SAMPLE_FMT_NONE (r20623). This...
[ffmpeg] / libavformat / raw.c
index f807a96f31f09498b5f4f933d8ad3a56ebbb5676..f4d7bb16c3b02a6759b4095654a02283a92c6b0c 100644 (file)
@@ -66,7 +66,7 @@ static int raw_write_packet(struct AVFormatContext *s, AVPacket *pkt)
 static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
 {
     AVStream *st;
-    int id;
+    enum CodecID id;
 
     st = av_new_stream(s, 0);
     if (!st)
@@ -120,12 +120,8 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
     ret= av_get_packet(s->pb, pkt, size);
 
     pkt->stream_index = 0;
-    if (ret <= 0) {
-        return AVERROR(EIO);
-    }
-    /* note: we need to modify the packet size here to handle the last
-       packet */
-    pkt->size = ret;
+    if (ret < 0)
+        return ret;
 
     bps= av_get_bits_per_sample(s->streams[0]->codec->codec_id);
     assert(bps); // if false there IS a bug elsewhere (NOT in this function)
@@ -142,14 +138,14 @@ int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
     size = RAW_PACKET_SIZE;
 
     if (av_new_packet(pkt, size) < 0)
-        return AVERROR(EIO);
+        return AVERROR(ENOMEM);
 
     pkt->pos= url_ftell(s->pb);
     pkt->stream_index = 0;
     ret = get_partial_buffer(s->pb, pkt->data, size);
-    if (ret <= 0) {
+    if (ret < 0) {
         av_free_packet(pkt);
-        return AVERROR(EIO);
+        return ret;
     }
     pkt->size = ret;
     return ret;
@@ -174,11 +170,9 @@ static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
     pkt->dts= pkt->pos / packet_size;
 
     pkt->stream_index = 0;
-    if (ret != packet_size) {
-        return AVERROR(EIO);
-    } else {
-        return 0;
-    }
+    if (ret < 0)
+        return ret;
+    return 0;
 }
 #endif
 
@@ -206,14 +200,14 @@ static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
         size, w, h, unk1, unk2);
 
     if (av_new_packet(pkt, size) < 0)
-        return AVERROR(EIO);
+        return AVERROR(ENOMEM);
 
     pkt->pos = url_ftell(s->pb);
     pkt->stream_index = 0;
     ret = get_buffer(s->pb, pkt->data, size);
-    if (ret <= 0) {
+    if (ret < 0) {
         av_free_packet(pkt);
-        return AVERROR(EIO);
+        return ret;
     }
     pkt->size = ret;
     return ret;
@@ -225,8 +219,8 @@ int pcm_read_seek(AVFormatContext *s,
                   int stream_index, int64_t timestamp, int flags)
 {
     AVStream *st;
-    int block_align, byte_rate, ret;
-    int64_t pos;
+    int block_align, byte_rate;
+    int64_t pos, ret;
 
     st = s->streams[0];
 
@@ -288,6 +282,7 @@ static int video_read_header(AVFormatContext *s,
     } else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
                 st->codec->codec_id == CODEC_ID_MPEG4 ||
                 st->codec->codec_id == CODEC_ID_DIRAC ||
+                st->codec->codec_id == CODEC_ID_DNXHD ||
                 st->codec->codec_id == CODEC_ID_H264) {
         st->codec->time_base= (AVRational){1,25};
     }
@@ -478,7 +473,9 @@ static int h263_probe(AVProbeData *p)
             last_src_fmt= src_fmt;
         }
     }
-    if(valid_psc > 2*invalid_psc + 2*res_change + 2){
+//av_log(NULL, AV_LOG_ERROR, "h263_probe: psc:%d invalid:%d res_change:%d\n", valid_psc, invalid_psc, res_change);
+//h263_probe: psc:3 invalid:0 res_change:0 (1588/recent_ffmpeg_parses_mpg_incorrectly.mpg)
+    if(valid_psc > 2*invalid_psc + 2*res_change + 3){
         return 50;
     }else if(valid_psc > 2*invalid_psc)
         return 25;
@@ -628,8 +625,11 @@ static int ac3_eac3_probe(AVProbeData *p, enum CodecID expected_codec_id)
             first_frames = frames;
     }
     if(codec_id != expected_codec_id) return 0;
-    if   (first_frames>=3) return AVPROBE_SCORE_MAX * 3 / 4;
-    else if(max_frames>=3) return AVPROBE_SCORE_MAX / 2;
+    // keep this in sync with mp3 probe, both need to avoid
+    // issues with MPEG-files!
+    if   (first_frames>=4) return AVPROBE_SCORE_MAX/2+1;
+    else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
+    else if(max_frames>=4) return AVPROBE_SCORE_MAX/4;
     else if(max_frames>=1) return 1;
     else                   return 0;
 }