]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/utils.c
ARM: NEON optimised simple_idct
[ffmpeg] / libavformat / utils.c
index c1245074461f7287569d0a0ef1b22e94696ac8d6..7a91b0f009031f9b30557cc7e11e60e31bf9ec07 100644 (file)
@@ -746,6 +746,7 @@ static int is_intra_only(AVCodecContext *enc){
         case CODEC_ID_ASV1:
         case CODEC_ID_ASV2:
         case CODEC_ID_VCR1:
+        case CODEC_ID_DNXHD:
             return 1;
         default: break;
         }
@@ -824,11 +825,28 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
     int num, den, presentation_delayed, delay, i;
     int64_t offset;
 
+    /* do we have a video B-frame ? */
+    delay= st->codec->has_b_frames;
+    presentation_delayed = 0;
+    /* XXX: need has_b_frame, but cannot get it if the codec is
+        not initialized */
+    if (delay &&
+        pc && pc->pict_type != FF_B_TYPE)
+        presentation_delayed = 1;
+
     if(pkt->pts != AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE && pkt->dts > pkt->pts && st->pts_wrap_bits<63
        /*&& pkt->dts-(1LL<<st->pts_wrap_bits) < pkt->pts*/){
         pkt->dts -= 1LL<<st->pts_wrap_bits;
     }
 
+    // some mpeg2 in mpeg-ps lack dts (issue171 / input_file.mpg)
+    // we take the conservative approach and discard both
+    // Note, if this is misbehaving for a H.264 file then possibly presentation_delayed is not set correctly.
+    if(delay==1 && pkt->dts == pkt->pts && pkt->dts != AV_NOPTS_VALUE && presentation_delayed){
+        av_log(s, AV_LOG_ERROR, "invalid dts/pts combination\n");
+        pkt->dts= pkt->pts= AV_NOPTS_VALUE;
+    }
+
     if (pkt->duration == 0) {
         compute_frame_duration(&num, &den, st, pc, pkt);
         if (den && num) {
@@ -850,14 +868,6 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
             pkt->dts += offset;
     }
 
-    /* do we have a video B-frame ? */
-    delay= st->codec->has_b_frames;
-    presentation_delayed = 0;
-    /* XXX: need has_b_frame, but cannot get it if the codec is
-        not initialized */
-    if (delay &&
-        pc && pc->pict_type != FF_B_TYPE)
-        presentation_delayed = 1;
     /* This may be redundant, but it should not hurt. */
     if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts > pkt->dts)
         presentation_delayed = 1;
@@ -1701,7 +1711,7 @@ static void av_estimate_timings_from_bit_rate(AVFormatContext *ic)
 #define DURATION_MAX_READ_SIZE 250000
 
 /* only usable for MPEG-PS streams */
-static void av_estimate_timings_from_pts(AVFormatContext *ic, offset_t old_offset)
+static void av_estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
 {
     AVPacket pkt1, *pkt = &pkt1;
     AVStream *st;
@@ -1794,7 +1804,7 @@ static void av_estimate_timings_from_pts(AVFormatContext *ic, offset_t old_offse
     }
 }
 
-static void av_estimate_timings(AVFormatContext *ic, offset_t old_offset)
+static void av_estimate_timings(AVFormatContext *ic, int64_t old_offset)
 {
     int64_t file_size;
 
@@ -1928,7 +1938,7 @@ enum CodecID codec_get_id(const AVCodecTag *tags, unsigned int tag)
     return CODEC_ID_NONE;
 }
 
-unsigned int av_codec_get_tag(const AVCodecTag *tags[4], enum CodecID id)
+unsigned int av_codec_get_tag(const AVCodecTag * const *tags, enum CodecID id)
 {
     int i;
     for(i=0; tags && tags[i]; i++){
@@ -1938,7 +1948,7 @@ unsigned int av_codec_get_tag(const AVCodecTag *tags[4], enum CodecID id)
     return 0;
 }
 
-enum CodecID av_codec_get_id(const AVCodecTag *tags[4], unsigned int tag)
+enum CodecID av_codec_get_id(const AVCodecTag * const *tags, unsigned int tag)
 {
     int i;
     for(i=0; tags && tags[i]; i++){
@@ -2003,7 +2013,7 @@ int av_find_stream_info(AVFormatContext *ic)
     int64_t last_dts[MAX_STREAMS];
     int duration_count[MAX_STREAMS]={0};
     double (*duration_error)[MAX_STD_TIMEBASES];
-    offset_t old_offset = url_ftell(ic->pb);
+    int64_t old_offset = url_ftell(ic->pb);
     int64_t codec_info_duration[MAX_STREAMS]={0};
     int codec_info_nb_frames[MAX_STREAMS]={0};
 
@@ -2457,6 +2467,10 @@ int av_write_header(AVFormatContext *s)
                 av_log(s, AV_LOG_ERROR, "dimensions not set\n");
                 return -1;
             }
+            if(av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)){
+                av_log(s, AV_LOG_ERROR, "Aspect ratio mismatch between encoder and muxer layer\n");
+                return -1;
+            }
             break;
         }
 
@@ -2849,9 +2863,6 @@ int parse_frame_rate(int *frame_rate_num, int *frame_rate_den, const char *arg)
     return ret;
 }
 
-/**
- * Gets the current time in microseconds.
- */
 int64_t av_gettime(void)
 {
     struct timeval tv;
@@ -2894,7 +2905,7 @@ int64_t parse_date(const char *datestr, int duration)
     q = NULL;
     if (!duration) {
         /* parse the year-month-day part */
-        for (i = 0; i < sizeof(date_fmt) / sizeof(date_fmt[0]); i++) {
+        for (i = 0; i < FF_ARRAY_ELEMS(date_fmt); i++) {
             q = small_strptime(p, date_fmt[i], &dt);
             if (q) {
                 break;
@@ -2918,7 +2929,7 @@ int64_t parse_date(const char *datestr, int duration)
             p++;
 
         /* parse the hour-minute-second part */
-        for (i = 0; i < sizeof(time_fmt) / sizeof(time_fmt[0]); i++) {
+        for (i = 0; i < FF_ARRAY_ELEMS(time_fmt); i++) {
             q = small_strptime(p, time_fmt[i], &dt);
             if (q) {
                 break;