annotate mpegts.h @ 4723:a2390c6a35e6 libavformat

Fix index generation in the way that it was supposed to be used. See the discussion in the ML thread "[PATCH] rmdec.c: merge old/new packet reading code". Over time, this code broke somewhat, e.g. seq was never actually written into (and was thus always 1, therefore the seq condition was always true), whereas it was supposed to be set to the sequence number of the video slice in case the video frame is divided over multiple RM packets (slices). The problem of this is that packets other than those containing the beginning of a video frame would be indexed as well. Secondly, flags&2 is supposed to be true for video keyframes and for these audio packets containing the start of a block. For some codecs (e.g. AAC), that is every single packet, whereas for others (e.g. cook), that is the packet containing the first of a series of scrambled packets that are to be descrambled together. Indexing any of the following would lead to incomplete and thus useless frames. Problem here is that flags would be reset to 2 to indicate that the first packet is ready to be returned, and in addition if no data was left to be returned (which is always true for the first packet), then we wouldn't actually write the index entry anyway. All in all, the idea was good and it probably worked at some point, but that is long ago. This patch should at the very least make it likely for this code to be executed again at the right times, i.e. the way it was originally intended to be used.
author rbultje
date Sun, 15 Mar 2009 20:14:25 +0000
parents 77e0c7511d41
children c6796179d3fa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
152
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
1 /*
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
2 * MPEG2 transport stream defines
4251
77e0c7511d41 cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents: 3852
diff changeset
3 * Copyright (c) 2003 Fabrice Bellard
152
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
4 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1167
diff changeset
5 * This file is part of FFmpeg.
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1167
diff changeset
6 *
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1167
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
152
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1167
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
152
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
11 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1167
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
152
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
15 * Lesser General Public License for more details.
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
16 *
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1167
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
896
edbe5c3717f9 Update licensing information: The FSF changed postal address.
diego
parents: 891
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
152
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
20 */
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
21
3852
1b6245500d8c Globally rename the header inclusion guard names.
stefano
parents: 3716
diff changeset
22 #ifndef AVFORMAT_MPEGTS_H
1b6245500d8c Globally rename the header inclusion guard names.
stefano
parents: 3716
diff changeset
23 #define AVFORMAT_MPEGTS_H
2172
92f61ed53965 add multiple inclusion guards to headers
mru
parents: 2171
diff changeset
24
2171
a6d6b2b19341 include all prerequisites in header files
mru
parents: 1774
diff changeset
25 #include "avformat.h"
a6d6b2b19341 include all prerequisites in header files
mru
parents: 1774
diff changeset
26
152
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
27 #define TS_FEC_PACKET_SIZE 204
891
6e45fbd73a52 added support for DVHS (192) packet size
nicodvb
parents: 885
diff changeset
28 #define TS_DVHS_PACKET_SIZE 192
152
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
29 #define TS_PACKET_SIZE 188
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
30 #define NB_PID_MAX 8192
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
31 #define MAX_SECTION_SIZE 4096
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
32
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
33 /* pids */
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
34 #define PAT_PID 0x0000
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
35 #define SDT_PID 0x0011
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
36
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
37 /* table ids */
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
38 #define PAT_TID 0x00
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 819
diff changeset
39 #define PMT_TID 0x02
152
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
40 #define SDT_TID 0x42
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
41
819
a6c035e7f429 DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 496
diff changeset
42 /* descriptor ids */
a6c035e7f429 DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 496
diff changeset
43 #define DVB_SUBT_DESCID 0x59
a6c035e7f429 DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 496
diff changeset
44
160
9bde37b1a5ce try to filter _all_ PATs if no SDT could be found patch by (<gbazin at altern dot org>)
michaelni
parents: 152
diff changeset
45 #define STREAM_TYPE_VIDEO_MPEG1 0x01
9bde37b1a5ce try to filter _all_ PATs if no SDT could be found patch by (<gbazin at altern dot org>)
michaelni
parents: 152
diff changeset
46 #define STREAM_TYPE_VIDEO_MPEG2 0x02
9bde37b1a5ce try to filter _all_ PATs if no SDT could be found patch by (<gbazin at altern dot org>)
michaelni
parents: 152
diff changeset
47 #define STREAM_TYPE_AUDIO_MPEG1 0x03
9bde37b1a5ce try to filter _all_ PATs if no SDT could be found patch by (<gbazin at altern dot org>)
michaelni
parents: 152
diff changeset
48 #define STREAM_TYPE_AUDIO_MPEG2 0x04
152
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
49 #define STREAM_TYPE_PRIVATE_SECTION 0x05
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
50 #define STREAM_TYPE_PRIVATE_DATA 0x06
313
622892a75ddb support more codecs in MPEG-TS patch by (mru at kth dot se (Mns Rullgrd))
michael
parents: 292
diff changeset
51 #define STREAM_TYPE_AUDIO_AAC 0x0f
622892a75ddb support more codecs in MPEG-TS patch by (mru at kth dot se (Mns Rullgrd))
michael
parents: 292
diff changeset
52 #define STREAM_TYPE_VIDEO_MPEG4 0x10
493
166b71445aec h264 in mpeg-ts fix by (Mns Rullgrd <mru at kth dot se>)
michael
parents: 313
diff changeset
53 #define STREAM_TYPE_VIDEO_H264 0x1b
1774
814fbf5732eb demux VC1 in mpegts
nicodvb
parents: 1723
diff changeset
54 #define STREAM_TYPE_VIDEO_VC1 0xea
3716
2ca19db359bd Dirac encapsulation in MPEG-TS
diego
parents: 3059
diff changeset
55 #define STREAM_TYPE_VIDEO_DIRAC 0xd1
152
cc03a75cbde4 mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff changeset
56
165
e4d2f704bf80 - Looks a tiny bit harder in mpegps_probe() for a valid start code. This is
michaelni
parents: 160
diff changeset
57 #define STREAM_TYPE_AUDIO_AC3 0x81
496
112057e05179 libdts support by (Benjamin Zores <ben at geexbox dot org>)
michael
parents: 493
diff changeset
58 #define STREAM_TYPE_AUDIO_DTS 0x8a
3059
f982a5a75e40 treat stream_type==0x82 as AUDIO_DTS when the program has a REGISTRATION_DESCRIPTOR with the value HDMV; approved by Mans
nicodvb
parents: 2620
diff changeset
59 #define STREAM_TYPE_AUDIO_HDMV_DTS 0x82
165
e4d2f704bf80 - Looks a tiny bit harder in mpegps_probe() for a valid start code. This is
michaelni
parents: 160
diff changeset
60
819
a6c035e7f429 DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 496
diff changeset
61 #define STREAM_TYPE_SUBTITLE_DVB 0x100
a6c035e7f429 DVB subtitle decoder by (Ian Caulfield: imc25, cam ac uk)
michael
parents: 496
diff changeset
62
292
155ce13f1033 mpeg TS demux API (called from RTP layer) - raw mpeg TS reader (uses fake codec MPEG2TS)
bellard
parents: 165
diff changeset
63 typedef struct MpegTSContext MpegTSContext;
155ce13f1033 mpeg TS demux API (called from RTP layer) - raw mpeg TS reader (uses fake codec MPEG2TS)
bellard
parents: 165
diff changeset
64
155ce13f1033 mpeg TS demux API (called from RTP layer) - raw mpeg TS reader (uses fake codec MPEG2TS)
bellard
parents: 165
diff changeset
65 MpegTSContext *mpegts_parse_open(AVFormatContext *s);
155ce13f1033 mpeg TS demux API (called from RTP layer) - raw mpeg TS reader (uses fake codec MPEG2TS)
bellard
parents: 165
diff changeset
66 int mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt,
155ce13f1033 mpeg TS demux API (called from RTP layer) - raw mpeg TS reader (uses fake codec MPEG2TS)
bellard
parents: 165
diff changeset
67 const uint8_t *buf, int len);
155ce13f1033 mpeg TS demux API (called from RTP layer) - raw mpeg TS reader (uses fake codec MPEG2TS)
bellard
parents: 165
diff changeset
68 void mpegts_parse_close(MpegTSContext *ts);
2172
92f61ed53965 add multiple inclusion guards to headers
mru
parents: 2171
diff changeset
69
3852
1b6245500d8c Globally rename the header inclusion guard names.
stefano
parents: 3716
diff changeset
70 #endif /* AVFORMAT_MPEGTS_H */