2008/3/28, Baptiste Coudurier <baptiste.coudurier@smartjog.com>:
Hi,
On Thu, Mar 27, 2008 at 10:52:09PM +0800, zhentan feng wrote:
Index: mpegenc.c ===================================================================
--- mpegenc.c (revision 2048) +++ mpegenc.c (working copy) @@ -266,11 +266,13 @@ static int mpeg_mux_init(AVFormatContext *ctx) {
MpegMuxContext *s = ctx->priv_data;
- int bitrate, i, mpa_id, mpv_id, mps_id, ac3_id, dts_id, lpcm_id, j; + int bitrate, i; AVStream *st; PESStream *stream; int audio_bitrate; int video_bitrate; + int *ps_audio_bound = &(s->audio_bound); + int *ps_video_bound = &(s->video_bound);
[...]
+ if(ff_pes_muxer_init(ctx,ps_audio_bound,ps_video_bound) != 0)
Code seems to only count audio and video streams, I don't think ff_pes_muxer_init needs to be extented, only count them in mpeg_mux_init (a small for loop should do the trick).
yes. ps_audio_bound, and ps_video_bound are just flags to keep off TS can not execute some codes when call the function ff_pes_muxer_init(). I review the codes again , find mepg_mux_init() in mpegenc.c and mpegts_write_header() in mpegtsenc.c actually have small common codes. Moreover, mpegtsenc.c initial the stream data as below: for(i=0;i<ctx->nb_streams;i++) { st = ctx->streams[i]; stream = st->priv_data; but mpegenc.c initial the stream like this: for(i=0;i<ctx->nb_streams;i++) { st = ctx->streams[i]; stream = av_mallocz(sizeof(StreamInfo)); if (!stream) goto fail; st->priv_data = stream; Thus, I think it is stiff resued without flags to sign PS or TS stream. So, I leave it just as svn-soc original.
[...]
/** + * Caculate the PES header to flush + * @param[in] ps_flag the sign for PS, '1' is PS, '0' is TS + * @param[in] is_mpeg2 the pointer point to PS struct + * @param[in] is_dvd the pointer point to PS struct
[...]
+ */ +void ff_pes_cal_header(int ps_flag,int *is_mpeg2,int *is_dvd,int id,PESStream *stream, + int *packet_size,int *header_len,int64_t *pts,int64_t *dts, + int *payload_size,int *startcode,int *stuffing_size, + int *trailer_size,int *pad_packet_bytes); + +/**
I think some flags should be used for different variants:
#define FMT_MPEG2 0x01 #define FMT_VCD 0x02 | FMT_MPEG2 #define FMT_SVCD 0x04 | FMT_MPEG2 #define FMT_DVD 0x08 | FMT_MPEG2 #define FMT_TS 0x10 | FMT_MPEG2
then add a "format" field in PESStream.
You will be able to check with (s->format & FMT_MPEG2).
Beware of mpeg1system muxer though.
It should be simpler and cleaner, and will avoid passing 3 args.
This needs a separate patch.
The patch names "ff_pes_cal_header_3-29.patch" show the changes.
[...]
-- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA SMARTJOG SAS http://www.smartjog.com Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA Phone: +33 1 49966312
_______________________________________________ FFmpeg-soc mailing list FFmpeg-soc@mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc
-- Best wishes~