diff mpeg.c @ 470:334e08488ad1 libavformat

correctly interleave packets during encoding dts/pts fixed for streamcopy dont use coded_frame->key_frame hack in muxers, use AVPacket.flags instead
author michael
date Sat, 29 May 2004 18:50:31 +0000
parents 60f897e8dd2d
children 8c9c99ccaa25
line wrap: on
line diff
--- a/mpeg.c	Sat May 29 12:01:28 2004 +0000
+++ b/mpeg.c	Sat May 29 18:50:31 2004 +0000
@@ -803,51 +803,6 @@
     s->packet_number++;
 }
 
-/* XXX: move that to upper layer */
-/* XXX: we assume that there are always 'max_b_frames' between
-   reference frames. A better solution would be to use the AVFrame pts
-   field */
-static void compute_pts_dts(AVStream *st, int64_t *ppts, int64_t *pdts, 
-                            int64_t timestamp)
-{
-    int frame_delay;
-    int64_t pts, dts;
-
-    if (st->codec.codec_type == CODEC_TYPE_VIDEO && 
-        st->codec.max_b_frames != 0) {
-        frame_delay = (st->codec.frame_rate_base * 90000LL) / 
-            st->codec.frame_rate;
-        if (timestamp == 0) {
-            /* specific case for first frame : DTS just before */
-            pts = timestamp;
-            dts = timestamp - frame_delay;
-        } else {
-            timestamp -= frame_delay;
-            if (st->codec.coded_frame->pict_type == FF_B_TYPE) {
-                /* B frames has identical pts/dts */
-                pts = timestamp;
-                dts = timestamp;
-            } else {
-                /* a reference frame has a pts equal to the dts of the
-                   _next_ one */
-                dts = timestamp;
-                pts = timestamp + (st->codec.max_b_frames + 1) * frame_delay;
-            }
-        }
-#if 1
-        av_log(&st->codec, AV_LOG_DEBUG, "pts=%0.3f dts=%0.3f pict_type=%c\n", 
-               pts / 90000.0, dts / 90000.0, 
-               av_get_pict_type_char(st->codec.coded_frame->pict_type));
-#endif
-    } else {
-        pts = timestamp;
-        dts = timestamp;
-    }
-
-    *ppts = pts & ((1LL << 33) - 1);
-    *pdts = dts & ((1LL << 33) - 1);
-}
-
 static int64_t update_scr(AVFormatContext *ctx,int stream_index,int64_t pts)
 {
     MpegMuxContext *s = ctx->priv_data;
@@ -923,9 +878,6 @@
     int64_t pts, dts, new_start_pts, new_start_dts;
     int len, avail_size;
     
-    //XXX/FIXME this is and always was broken
-//    compute_pts_dts(st, &pts, &dts, pkt->pts);
-
     pts= pkt->pts;
     dts= pkt->dts;
 
@@ -1395,7 +1347,7 @@
     pkt->dts = dts;
     pkt->stream_index = st->index;
 #if 0
-    printf("%d: pts=%0.3f dts=%0.3f\n",
+    av_log(s, AV_LOG_DEBUG, "%d: pts=%0.3f dts=%0.3f\n",
            pkt->stream_index, pkt->pts / 90000.0, pkt->dts / 90000.0);
 #endif
     return 0;