[FFmpeg-soc] [soc]: r2372 - in dvbmuxer: mpegenc.c mpegpes.h mpegpesenc.c mpegtsenc.c

bcoudurier subversion at mplayerhq.hu
Wed Jun 4 00:09:41 CEST 2008


Author: bcoudurier
Date: Wed Jun  4 00:09:41 2008
New Revision: 2372

Log:
use ff_pes_write_packet

Modified:
   dvbmuxer/mpegenc.c
   dvbmuxer/mpegpes.h
   dvbmuxer/mpegpesenc.c
   dvbmuxer/mpegtsenc.c

Modified: dvbmuxer/mpegenc.c
==============================================================================
--- dvbmuxer/mpegenc.c	(original)
+++ dvbmuxer/mpegenc.c	Wed Jun  4 00:09:41 2008
@@ -862,47 +862,7 @@ static int output_packet(AVFormatContext
 static int mpeg_mux_write_packet(AVFormatContext *ctx, AVPacket *pkt)
 {
     MpegMuxContext *s = ctx->priv_data;
-    int stream_index= pkt->stream_index;
-    int size= pkt->size;
-    uint8_t *buf= pkt->data;
-    AVStream *st = ctx->streams[stream_index];
-    StreamInfo *stream = st->priv_data;
-    int64_t pts, dts;
-    PacketDesc *pkt_desc;
-    const int preload= av_rescale(ctx->preload, 90000, AV_TIME_BASE);
-    const int is_iframe = st->codec->codec_type == CODEC_TYPE_VIDEO && (pkt->flags & PKT_FLAG_KEY);
-
-    pts= pkt->pts;
-    dts= pkt->dts;
-
-    if(pts != AV_NOPTS_VALUE) pts += preload;
-    if(dts != AV_NOPTS_VALUE) dts += preload;
-
-//av_log(ctx, AV_LOG_DEBUG, "dts:%f pts:%f flags:%d stream:%d nopts:%d\n", dts/90000.0, pts/90000.0, pkt->flags, pkt->stream_index, pts != AV_NOPTS_VALUE);
-    if (!stream->premux_packet)
-        stream->next_packet = &stream->premux_packet;
-    *stream->next_packet=
-    pkt_desc= av_mallocz(sizeof(PacketDesc));
-    pkt_desc->pts= pts;
-    pkt_desc->dts= dts;
-    pkt_desc->unwritten_size=
-    pkt_desc->size= size;
-    if(!stream->predecode_packet)
-        stream->predecode_packet= pkt_desc;
-    stream->next_packet= &pkt_desc->next;
-
-    av_fifo_realloc(&stream->fifo, av_fifo_size(&stream->fifo) + size);
-
-    if (s->is_dvd){
-        if (is_iframe && (s->packet_number == 0 || (pts - stream->vobu_start_pts >= 36000))) { // min VOBU length 0.4 seconds (mpucoder)
-            stream->bytes_to_iframe = av_fifo_size(&stream->fifo);
-            stream->align_iframe = 1;
-            stream->vobu_start_pts = pts;
-        }
-    }
-
-    av_fifo_generic_write(&stream->fifo, buf, size, NULL);
-
+    ff_pes_write_packet(ctx, pkt, s->packet_number);
     for(;;){
         int ret= output_packet(ctx, 0);
         if(ret<=0)

Modified: dvbmuxer/mpegpes.h
==============================================================================
--- dvbmuxer/mpegpes.h	(original)
+++ dvbmuxer/mpegpes.h	Wed Jun  4 00:09:41 2008
@@ -86,10 +86,11 @@ void ff_pes_muxer_end(AVFormatContext *c
 
 /**
  * Write packet into PES FIFO.
- * @param [in] ctx  AVFormatContext
- * @param [in] pkt  Packet to write.
+ * @param [in] ctx           AVFormatContext
+ * @param [in] pkt           Packet to write.
+ * @param [in] packet_number Current muxer packet number
  */
-void ff_pes_write_packet(AVFormatContext *ctx, AVPacket *pkt);
+void ff_pes_write_packet(AVFormatContext *ctx, AVPacket *pkt, int packet_number);
 
 /**
  * Find the best stream to mux into the PES stream.

Modified: dvbmuxer/mpegpesenc.c
==============================================================================
--- dvbmuxer/mpegpesenc.c	(original)
+++ dvbmuxer/mpegpesenc.c	Wed Jun  4 00:09:41 2008
@@ -376,7 +376,7 @@ retry:
     return 1;
 }
 
-void ff_pes_write_packet(AVFormatContext *ctx, AVPacket *pkt)
+void ff_pes_write_packet(AVFormatContext *ctx, AVPacket *pkt, int packet_number)
 {
     int stream_index= pkt->stream_index;
     int size= pkt->size;
@@ -386,6 +386,7 @@ void ff_pes_write_packet(AVFormatContext
     int64_t pts, dts;
     PacketDesc *pkt_desc;
     const int preload= av_rescale(ctx->preload, 90000, AV_TIME_BASE);
+    const int is_iframe = st->codec->codec_type == CODEC_TYPE_VIDEO && (pkt->flags & PKT_FLAG_KEY);
 
     pts= pkt->pts;
     dts= pkt->dts;
@@ -407,6 +408,15 @@ void ff_pes_write_packet(AVFormatContext
     stream->next_packet= &pkt_desc->next;
 
     av_fifo_realloc(&stream->fifo, av_fifo_size(&stream->fifo) + size);
+
+    if (stream->format == PES_FMT_DVD){
+        if (is_iframe && (packet_number == 0 || (pts - stream->vobu_start_pts >= 36000))) { // min VOBU length 0.4 seconds (mpucoder)
+            stream->bytes_to_iframe = av_fifo_size(&stream->fifo);
+            stream->align_iframe = 1;
+            stream->vobu_start_pts = pts;
+        }
+    }
+
     av_fifo_generic_write(&stream->fifo, buf, size, NULL);
 }
 

Modified: dvbmuxer/mpegtsenc.c
==============================================================================
--- dvbmuxer/mpegtsenc.c	(original)
+++ dvbmuxer/mpegtsenc.c	Wed Jun  4 00:09:41 2008
@@ -692,7 +692,7 @@ static int output_packet(AVFormatContext
 
 static int mpegts_write_packet(AVFormatContext *ctx, AVPacket *pkt)
 {
-    ff_pes_write_packet(ctx, pkt);
+    ff_pes_write_packet(ctx, pkt, 0);
     for(;;){
         int ret = output_packet(ctx, 0);
         if(ret<=0)



More information about the FFmpeg-soc mailing list