# HG changeset patch # User michael # Date 1068674217 0 # Node ID 622892a75ddbad25f30642f7c107e11a244dd037 # Parent 8a04d2e1be2f25dda7d084b1331c42f0bb27c2a7 support more codecs in MPEG-TS patch by (mru at kth dot se (Mns Rullgrd)) diff -r 8a04d2e1be2f -r 622892a75ddb mpegts.c --- a/mpegts.c Mon Nov 10 18:49:58 2003 +0000 +++ b/mpegts.c Wed Nov 12 21:56:57 2003 +0000 @@ -30,7 +30,7 @@ synchronisation is lost */ #define MAX_RESYNC_SIZE 4096 -static int add_pes_stream(MpegTSContext *ts, int pid); +static int add_pes_stream(MpegTSContext *ts, int pid, int stream_type); enum MpegTSFilterType { MPEGTS_PES, @@ -403,8 +403,11 @@ case STREAM_TYPE_AUDIO_MPEG2: case STREAM_TYPE_VIDEO_MPEG1: case STREAM_TYPE_VIDEO_MPEG2: + case STREAM_TYPE_VIDEO_MPEG4: + case STREAM_TYPE_VIDEO_H264: + case STREAM_TYPE_AUDIO_AAC: case STREAM_TYPE_AUDIO_AC3: - add_pes_stream(ts, pid); + add_pes_stream(ts, pid, stream_type); break; default: /* we ignore the other streams */ @@ -632,6 +635,7 @@ typedef struct PESContext { int pid; + int stream_type; MpegTSContext *ts; AVFormatContext *stream; AVStream *st; @@ -698,15 +702,45 @@ goto skip; if (!pes->st) { /* allocate stream */ - if (code >= 0x1c0 && code <= 0x1df) { + switch(pes->stream_type){ + case STREAM_TYPE_AUDIO_MPEG1: + case STREAM_TYPE_AUDIO_MPEG2: codec_type = CODEC_TYPE_AUDIO; - codec_id = CODEC_ID_MP2; - } else if (code == 0x1bd) { + codec_id = CODEC_ID_MP3; + break; + case STREAM_TYPE_VIDEO_MPEG1: + case STREAM_TYPE_VIDEO_MPEG2: + codec_type = CODEC_TYPE_VIDEO; + codec_id = CODEC_ID_MPEG2VIDEO; + break; + case STREAM_TYPE_VIDEO_MPEG4: + codec_type = CODEC_TYPE_VIDEO; + codec_id = CODEC_ID_MPEG4; + break; + case STREAM_TYPE_VIDEO_H264: + codec_type = CODEC_TYPE_VIDEO; + codec_id = CODEC_ID_H264; + break; + case STREAM_TYPE_AUDIO_AAC: + codec_type = CODEC_TYPE_AUDIO; + codec_id = CODEC_ID_AAC; + break; + case STREAM_TYPE_AUDIO_AC3: codec_type = CODEC_TYPE_AUDIO; codec_id = CODEC_ID_AC3; - } else { - codec_type = CODEC_TYPE_VIDEO; - codec_id = CODEC_ID_MPEG1VIDEO; + break; + default: + if (code >= 0x1c0 && code <= 0x1df) { + codec_type = CODEC_TYPE_AUDIO; + codec_id = CODEC_ID_MP2; + } else if (code == 0x1bd) { + codec_type = CODEC_TYPE_AUDIO; + codec_id = CODEC_ID_AC3; + } else { + codec_type = CODEC_TYPE_VIDEO; + codec_id = CODEC_ID_MPEG1VIDEO; + } + break; } st = av_new_stream(pes->stream, pes->pid); if (st) { @@ -794,7 +828,7 @@ } } -static int add_pes_stream(MpegTSContext *ts, int pid) +static int add_pes_stream(MpegTSContext *ts, int pid, int stream_type) { MpegTSFilter *tss; PESContext *pes; @@ -806,6 +840,7 @@ pes->ts = ts; pes->stream = ts->stream; pes->pid = pid; + pes->stream_type = stream_type; tss = mpegts_open_pes_filter(ts, pid, mpegts_push_data, pes); if (!tss) { av_free(pes); @@ -826,7 +861,7 @@ is_start = packet[1] & 0x40; tss = ts->pids[pid]; if (ts->auto_guess && tss == NULL && is_start) { - add_pes_stream(ts, pid); + add_pes_stream(ts, pid, 0); tss = ts->pids[pid]; } if (!tss) diff -r 8a04d2e1be2f -r 622892a75ddb mpegts.h --- a/mpegts.h Mon Nov 10 18:49:58 2003 +0000 +++ b/mpegts.h Wed Nov 12 21:56:57 2003 +0000 @@ -37,6 +37,9 @@ #define STREAM_TYPE_AUDIO_MPEG2 0x04 #define STREAM_TYPE_PRIVATE_SECTION 0x05 #define STREAM_TYPE_PRIVATE_DATA 0x06 +#define STREAM_TYPE_AUDIO_AAC 0x0f +#define STREAM_TYPE_VIDEO_MPEG4 0x10 +#define STREAM_TYPE_VIDEO_H264 0x1a #define STREAM_TYPE_AUDIO_AC3 0x81 diff -r 8a04d2e1be2f -r 622892a75ddb mpegtsenc.c --- a/mpegtsenc.c Mon Nov 10 18:49:58 2003 +0000 +++ b/mpegtsenc.c Wed Nov 12 21:56:57 2003 +0000 @@ -258,13 +258,27 @@ for(i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; MpegTSWriteStream *ts_st = st->priv_data; - switch(st->codec.codec_type) { - case CODEC_TYPE_VIDEO: - stream_type = STREAM_TYPE_VIDEO_MPEG2; //XXX/FIXME is this (and the define) correct? + switch(st->codec.codec_id) { + case CODEC_ID_MPEG1VIDEO: + case CODEC_ID_MPEG2VIDEO: + stream_type = STREAM_TYPE_VIDEO_MPEG2; + break; + case CODEC_ID_MPEG4: + stream_type = STREAM_TYPE_VIDEO_MPEG4; break; - case CODEC_TYPE_AUDIO: + case CODEC_ID_H264: + stream_type = STREAM_TYPE_VIDEO_H264; + break; + case CODEC_ID_MP2: + case CODEC_ID_MP3: stream_type = STREAM_TYPE_AUDIO_MPEG1; break; + case CODEC_ID_AAC: + stream_type = STREAM_TYPE_AUDIO_AAC; + break; + case CODEC_ID_AC3: + stream_type = STREAM_TYPE_AUDIO_AC3; + break; default: stream_type = STREAM_TYPE_PRIVATE_DATA; break;