Merge remote-tracking branch 'cehoyos/master'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 10 Jun 2014 16:22:37 +0000 (18:22 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 10 Jun 2014 16:22:41 +0000 (18:22 +0200)
* cehoyos/master:
  Allow values >31bit for -analyzeduration.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/nutenc.c
libavformat/rawdec.c
libavformat/rawdec.h
libavformat/utils.c

index 223db8c..b7ea286 100644 (file)
@@ -698,7 +698,7 @@ static int nut_write_header(AVFormatContext *s)
     nut->avf = s;
 
     nut->version = FFMAX(NUT_STABLE_VERSION, 3 + !!nut->flags);
-    if (nut->flags && s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
+    if (nut->version > 3 && s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
         av_log(s, AV_LOG_ERROR,
                "The additional syncpoint modes require version %d, "
                "that is currently not finalized, "
@@ -961,10 +961,10 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
     int best_header_idx;
     int key_frame = !!(pkt->flags & AV_PKT_FLAG_KEY);
     int store_sp  = 0;
-    int ret;
+    int ret = 0;
     int sm_size = 0;
     int data_size = pkt->size;
-    uint8_t *sm_buf;
+    uint8_t *sm_buf = NULL;
 
     if (pkt->pts < 0) {
         av_log(s, AV_LOG_ERROR,
@@ -979,9 +979,12 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
         ret = avio_open_dyn_buf(&sm_bc);
         if (ret < 0)
             return ret;
-        write_sm_data(s, sm_bc, pkt, 0);
-        write_sm_data(s, sm_bc, pkt, 1);
+        ret = write_sm_data(s, sm_bc, pkt, 0);
+        if (ret >= 0)
+            ret = write_sm_data(s, sm_bc, pkt, 1);
         sm_size = avio_close_dyn_buf(sm_bc, &sm_buf);
+        if (ret < 0)
+            goto fail;
         data_size += sm_size;
     }
 
@@ -1023,7 +1026,7 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
         nut->last_syncpoint_pos = avio_tell(bc);
         ret                     = avio_open_dyn_buf(&dyn_bc);
         if (ret < 0)
-            return ret;
+            goto fail;
         put_tt(nut, nus->time_base, dyn_bc, pkt->dts);
         ff_put_v(dyn_bc, sp_pos != INT64_MAX ? (nut->last_syncpoint_pos - sp_pos) >> 4 : 0);
 
@@ -1035,15 +1038,17 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
 
         if (nut->write_index) {
         if ((ret = ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0 /*unused*/, pkt->dts)) < 0)
-            return ret;
+            goto fail;
 
         if ((1ll<<60) % nut->sp_count == 0)
             for (i=0; i<s->nb_streams; i++) {
                 int j;
                 StreamContext *nus = &nut->stream[i];
                 av_reallocp_array(&nus->keyframe_pts, 2*nut->sp_count, sizeof(*nus->keyframe_pts));
-                if (!nus->keyframe_pts)
-                    return AVERROR(ENOMEM);
+                if (!nus->keyframe_pts) {
+                    ret = AVERROR(ENOMEM);
+                    goto fail;
+                }
                 for (j=nut->sp_count == 1 ? 0 : nut->sp_count; j<2*nut->sp_count; j++)
                     nus->keyframe_pts[j] = AV_NOPTS_VALUE;
         }
@@ -1135,7 +1140,6 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
 
     if (flags & FLAG_SM_DATA) {
         avio_write(bc, sm_buf, sm_size);
-        av_freep(&sm_buf);
     }
     avio_write(bc, pkt->data + nut->header_len[header_idx], pkt->size - nut->header_len[header_idx]);
 
@@ -1160,7 +1164,10 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
         nut->max_pts_tb = nus->time_base;
     }
 
-    return 0;
+fail:
+    av_freep(&sm_buf);
+
+    return ret;
 }
 
 static int nut_write_trailer(AVFormatContext *s)
index 62e5901..ca9b282 100644 (file)
@@ -185,15 +185,23 @@ static int mjpeg_probe(AVProbeData *p)
         }
     }
 
-    if (nb_invalid == 0 && nb_frames > 2)
-        return AVPROBE_SCORE_EXTENSION / 2;
-    if (nb_invalid*4 + 1 < nb_frames)
+    if (nb_invalid*4 + 1 < nb_frames) {
+        static const char ct_jpeg[] = "\r\nContent-Type: image/jpeg\r\n\r\n";
+        int i;
+
+        for (i=0; i<FFMIN(p->buf_size - sizeof(ct_jpeg), 100); i++)
+            if (!memcmp(p->buf + i, ct_jpeg, sizeof(ct_jpeg) - 1))
+                return AVPROBE_SCORE_EXTENSION;
+
+        if (nb_invalid == 0 && nb_frames > 2)
+            return AVPROBE_SCORE_EXTENSION / 2;
         return AVPROBE_SCORE_EXTENSION / 4;
+    }
 
     return 0;
 }
 
-FF_DEF_RAWVIDEO_DEMUXER(mjpeg, "raw MJPEG video", mjpeg_probe, "mjpg,mjpeg,mpo", AV_CODEC_ID_MJPEG)
+FF_DEF_RAWVIDEO_DEMUXER2(mjpeg, "raw MJPEG video", mjpeg_probe, "mjpg,mjpeg,mpo", AV_CODEC_ID_MJPEG, AVFMT_GENERIC_INDEX|AVFMT_NOTIMESTAMPS)
 #endif
 
 #if CONFIG_MLP_DEMUXER
@@ -233,5 +241,5 @@ AVInputFormat ff_shorten_demuxer = {
 #endif
 
 #if CONFIG_VC1_DEMUXER
-FF_DEF_RAWVIDEO_DEMUXER(vc1, "raw VC-1", NULL, "vc1", AV_CODEC_ID_VC1)
+FF_DEF_RAWVIDEO_DEMUXER2(vc1, "raw VC-1", NULL, "vc1", AV_CODEC_ID_VC1, AVFMT_GENERIC_INDEX|AVFMT_NOTIMESTAMPS)
 #endif
index 5910855..328a4fb 100644 (file)
@@ -49,7 +49,7 @@ static const AVClass name ## _demuxer_class = {\
     .version    = LIBAVUTIL_VERSION_INT,\
 };
 
-#define FF_DEF_RAWVIDEO_DEMUXER(shortname, longname, probe, ext, id)\
+#define FF_DEF_RAWVIDEO_DEMUXER2(shortname, longname, probe, ext, id, flag)\
 FF_RAWVIDEO_DEMUXER_CLASS(shortname)\
 AVInputFormat ff_ ## shortname ## _demuxer = {\
     .name           = #shortname,\
@@ -58,10 +58,13 @@ AVInputFormat ff_ ## shortname ## _demuxer = {\
     .read_header    = ff_raw_video_read_header,\
     .read_packet    = ff_raw_read_partial_packet,\
     .extensions     = ext,\
-    .flags          = AVFMT_GENERIC_INDEX,\
+    .flags          = flag,\
     .raw_codec_id   = id,\
     .priv_data_size = sizeof(FFRawVideoDemuxerContext),\
     .priv_class     = &shortname ## _demuxer_class,\
 };
 
+#define FF_DEF_RAWVIDEO_DEMUXER(shortname, longname, probe, ext, id)\
+FF_DEF_RAWVIDEO_DEMUXER2(shortname, longname, probe, ext, id, AVFMT_GENERIC_INDEX)
+
 #endif /* AVFORMAT_RAWDEC_H */
index ba409ec..5e6b1b0 100644 (file)
@@ -3206,6 +3206,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
                 !st->codec->extradata)
                 break;
             if (st->first_dts == AV_NOPTS_VALUE &&
+                !(ic->iformat->flags & AVFMT_NOTIMESTAMPS) &&
                 (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
                  st->codec->codec_type == AVMEDIA_TYPE_AUDIO))
                 break;