Andrew rates additions
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / ffmpeg.C
index 0f41bd2382ecbbc630b75f5af847bb3c5101b283..90e4a8510421a5c4bdf60d44422dc5245d0e29f9 100644 (file)
@@ -1222,8 +1222,7 @@ int FFVideoStream::probe(int64_t pos)
                return -1;
        }
                
-       if (ffmpeg->interlace_from_codec)
-               return 1;
+       if (ffmpeg->interlace_from_codec) return 1;
 
                ret = read_frame(frame);
                if( ret > 0 ) {
@@ -1854,12 +1853,15 @@ int FFMPEG::check_sample_rate(AVCodec *codec, int sample_rate)
        return 0;
 }
 
+// check_frame_rate and std_frame_rate needed for 23.976
+// and 59.94 fps mpeg2
 static inline AVRational std_frame_rate(int i)
 {
        static const int m1 = 1001*12, m2 = 1000*12;
        static const int freqs[] = {
                40*m1, 48*m1, 50*m1, 60*m1, 80*m1,120*m1, 240*m1,
-               24*m2, 30*m2, 60*m2, 12*m2, 15*m2, 48*m2, 0,
+               24*m2, 30*m2, 60*m2, 12*m2, 15*m2, 48*m2, 90*m2,
+               100*m2, 120*m2, 144*m2, 72*m2, 0,
        };
        int freq = i<30*12 ? (i+1)*1001 : freqs[i-30*12];
        return (AVRational) { freq, 1001*12 };
@@ -2915,7 +2917,12 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
                        int mask_h = (1<<desc->log2_chroma_h)-1;
                        ctx->height = (vid->height+mask_h) & ~mask_h;
                        ctx->sample_aspect_ratio = to_sample_aspect_ratio(asset);
-                       AVRational frame_rate = check_frame_rate(codec->supported_framerates, vid->frame_rate);
+                       AVRational frame_rate;
+                       if (ctx->codec->id == AV_CODEC_ID_MPEG1VIDEO ||
+                           ctx->codec->id == AV_CODEC_ID_MPEG2VIDEO)
+                       frame_rate = check_frame_rate(codec->supported_framerates, vid->frame_rate);
+                       else
+                       frame_rate = av_d2q(vid->frame_rate, INT_MAX);
                        if( !frame_rate.num || !frame_rate.den ) {
                                eprintf(_("check_frame_rate failed %s\n"), filename);
                                ret = 1;
@@ -3563,12 +3570,10 @@ float FFMPEG::ff_aspect_ratio(int stream)
        AVRational dar;
        AVRational sar = av_guess_sample_aspect_ratio(fmt_ctx, strm, NULL);
         if (sar.num) {
-            printf("sample_aspect_ratio, %f \n", av_q2d(sar));
             av_reduce(&dar.num, &dar.den,
                       par->width  * sar.num,
                       par->height * sar.den,
                       1024*1024);
-                      printf("display_aspect_ratio, %f \n", av_q2d(dar));
                       return av_q2d(dar);
                       }
         return ffvideo[stream]->aspect_ratio;
@@ -3617,7 +3622,6 @@ int FFMPEG::ff_interlace(int stream)
 // https://ffmpeg.org/doxygen/trunk/structAVCodecParserContext.html
 /* reads from demuxer because codec frame not ready */
        int interlace0 = ffvideo[stream]->st->codecpar->field_order;
-       printf("interlace from demux: %i\n", interlace0);
 
        switch (interlace0)
        {