[FFmpeg-soc] [soc]: r2350 - in dvbmuxer: mpegpesenc.c mpegtsenc.c

bcoudurier subversion at mplayerhq.hu
Tue Jun 3 01:16:35 CEST 2008


Author: bcoudurier
Date: Tue Jun  3 01:16:34 2008
New Revision: 2350

Log:
simplify and reuse code

Modified:
   dvbmuxer/mpegpesenc.c
   dvbmuxer/mpegtsenc.c

Modified: dvbmuxer/mpegpesenc.c
==============================================================================
--- dvbmuxer/mpegpesenc.c	(original)
+++ dvbmuxer/mpegpesenc.c	Tue Jun  3 01:16:34 2008
@@ -117,18 +117,16 @@ void ff_pes_cal_header(StreamInfo *strea
     }
 
     *payload_size = *packet_size - *header_len;
-    if (stream->format != PES_FMT_TS) {
-        if (stream->id < 0xc0) {
-            *startcode = PRIVATE_STREAM_1;
-            *payload_size -= 1;
-            if (stream->id >= 0x40) {
+    if (stream->id < 0xc0) {
+        *startcode = PRIVATE_STREAM_1;
+        *payload_size -= 1;
+        if (stream->id >= 0x40) {
+            *payload_size -= 3;
+            if (stream->id >= 0xa0)
                 *payload_size -= 3;
-                if (stream->id >= 0xa0)
-                    *payload_size -= 3;
-            }
-        } else {
-            *startcode = 0x100 + stream->id;
         }
+    } else {
+        *startcode = 0x100 + stream->id;
     }
     *stuffing_size = *payload_size - av_fifo_size(&stream->fifo);
 

Modified: dvbmuxer/mpegtsenc.c
==============================================================================
--- dvbmuxer/mpegtsenc.c	(original)
+++ dvbmuxer/mpegtsenc.c	Tue Jun  3 01:16:34 2008
@@ -140,23 +140,10 @@ static int mpegts_write_section1(MpegTSS
 #define PAT_RETRANS_TIME 100
 #define MAX_DELTA_PCR 9000 /**< 0.1s according to ISO 13818-1 */
 
-
-/**
- *  lookup table from codec id to pes stream id
- */
-static const int pes_streamid[CODEC_TYPE_NB] = {
-   0xe0,        /**< CODEC_TYPE_VIDEO    */
-   0xc0,        /**< CODEC_TYPE_AUDIO    */
-   0xbd,        /**< CODEC_TYPE_DATA     */
-   0xbd,        /**< CODEC_TYPE_SUBTITLE */
-};
-
 typedef struct MpegTSWriteStream {
     StreamInfo pes_stream;
     int packet_size;
     int packet_number;
-    int startcode;  /**< PES header start code */
-    uint8_t id;
     struct MpegTSService *service;
     int pid; /* stream associated pid */
     int cc;
@@ -433,12 +420,18 @@ static int mpegts_write_header(AVFormatC
             service->pcr_pid == 0x1fff)
             service->pcr_pid = ts_st->pid;
 
-        ts_st->id = pes_streamid[st->codec->codec_type];
-
-        if(ts_st->id < 0xc0)
-            ts_st->startcode = PRIVATE_STREAM_1;
-        else
-            ts_st->startcode = 0x100 + ts_st->id;
+        if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
+            ts_st->pes_stream.id = 0xe0;
+        } else if (st->codec->codec_type == CODEC_TYPE_AUDIO &&
+                   (st->codec->codec_id == CODEC_ID_MP2 ||
+                    st->codec->codec_id == CODEC_ID_MP3)) {
+            ts_st->pes_stream.id = 0xc0;
+        } else {
+            ts_st->pes_stream.id = 0xbd;
+            if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) {
+                //private_code = 0x20;
+            }
+        }
 
         if(st->codec->rc_max_rate)
             codec_rate= st->codec->rc_max_rate;
@@ -636,7 +629,7 @@ static int flush_packet(AVFormatContext 
                           &payload_size, &startcode, &stuffing_size,
                           &trailer_size, &pad_packet_bytes);
         pes_size = ff_pes_write_buf(ctx, stream_index, stream->payload,
-                 pts, dts, stream->startcode, header_len,
+                 pts, dts, startcode, header_len,
                  packet_size, payload_size, stuffing_size);
         if(pes_size < 0)
             return -1;



More information about the FFmpeg-soc mailing list