Go to the documentation of this file.
32 #define SERIES1_PES_LENGTH 11
33 #define SERIES2_PES_LENGTH 16
34 #define AC3_PES_LENGTH 14
35 #define VIDEO_PES_LENGTH 16
36 #define DTIVO_PTS_OFFSET 6
37 #define SA_PTS_OFFSET 9
38 #define AC3_PTS_OFFSET 9
39 #define VIDEO_PTS_OFFSET 9
40 #define AC3_PKT_LENGTH 1536
46 #define TIVO_PES_FILEID 0xf5467abd
47 #define CHUNK_SIZE (128 * 1024)
48 #define CHUNK_PEEK_COUNT 3
127 for (
i = 0;
i < num_recs;
i++) {
128 const uint8_t *record_header = buf + (
i * 16);
131 rec_hdr->
rec_type = record_header[3];
132 rec_hdr->subrec_type = record_header[2] & 0x0f;
133 if ((record_header[0] & 0x80) == 0x80) {
137 b1 = (((record_header[0] & 0x0f) << 4) |
138 ((record_header[1] & 0xf0) >> 4));
139 b2 = (((record_header[1] & 0x0f) << 4) |
140 ((record_header[2] & 0xf0) >> 4));
144 rec_hdr->rec_size = 0;
147 rec_hdr->rec_size = (record_header[0] << 8 |
148 record_header[1]) << 4 |
149 (record_header[2] >> 4);
150 rec_hdr->ty_pts =
AV_RB64(&record_header[8]);
157 const uint8_t *
buffer,
int search_len)
161 for (count = 0; count < search_len; count++) {
173 int num_6e0, num_be0, num_9c0, num_3c0;
188 ff_dlog(
s,
"probe: chunk has %d recs\n", num_recs);
200 num_6e0 = num_be0 = num_9c0 = num_3c0 = 0;
201 for (
i = 0;
i < num_recs;
i++) {
202 switch (hdrs[
i].subrec_type << 8 | hdrs[
i].rec_type) {
217 ff_dlog(
s,
"probe: chunk has %d 0x6e0 recs, %d 0xbe0 recs.\n",
222 ff_dlog(
s,
"detected Series 1 Tivo\n");
225 }
else if (num_be0 > 0) {
226 ff_dlog(
s,
"detected Series 2 Tivo\n");
231 ff_dlog(
s,
"detected AC-3 Audio (DTivo)\n");
236 }
else if (num_3c0 > 0) {
238 ff_dlog(
s,
"detected MPEG Audio\n");
244 uint32_t data_offset = 16 * num_recs;
246 for (
i = 0;
i < num_recs;
i++) {
250 if ((hdrs[
i].subrec_type << 8 | hdrs[
i].rec_type) == 0x3c0 && hdrs[
i].rec_size > 15) {
253 &chunk[data_offset], 5);
254 if (pes_offset >= 0) {
256 if ((chunk[data_offset + 6 + pes_offset] & 0x80) == 0x80) {
259 ff_dlog(
s,
"detected Stand-Alone Tivo\n");
264 ff_dlog(
s,
"detected DirecTV Tivo\n");
339 int read_size, num_recs;
362 if (ty->
chunk[3] & 0x80) {
372 ff_dlog(
s,
"chunk has %d records\n", num_recs);
396 if (subrec_type != 0x02 && subrec_type != 0x0c &&
397 subrec_type != 0x08 && rec_size > 4) {
402 if (es_offset1 != -1) {
405 if (subrec_type != 0x06) {
420 ff_dlog(
s,
"video rec type 0x%02x has short PES"
421 " (%"PRId64
" bytes)\n", subrec_type, rec_size);
430 if (subrec_type == 0x06) {
446 if (subrec_type != 0x02) {
447 if (subrec_type == 0x0c &&
pkt->
size >= 6)
449 if (subrec_type == 0x07) {
479 if (offset < 0 || offset + ty->pes_length > rec_len) {
481 ff_dlog(
s,
"PES header at %"PRId32
" not complete in record. storing.\n",
offset);
488 ff_dlog(
s,
"PES header not found in record of %"PRId32
" bytes!\n", rec_len);
519 if (subrec_type == 2) {
529 ff_dlog(
s,
"continuing PES header\n");
531 if (
need >= rec_size) {
550 if (es_offset1 < 0) {
551 ff_dlog(
s,
"Can't find audio PES header in packet.\n");
581 }
else if (subrec_type == 0x03) {
593 if ((es_offset1 == 0) && (rec_size == 16)) {
610 }
else if (subrec_type == 0x04) {
619 }
else if (subrec_type == 0x09) {
717 .p.extensions =
"ty,ty+",
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
static const uint8_t ty_AC3AudioPacket[]
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static int ty_read_header(AVFormatContext *s)
enum AVMediaType codec_type
General type of the encoded data.
static int64_t ff_parse_pes_pts(const uint8_t *buf)
Parse MPEG-PES five-byte timestamp.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#define AVERROR_EOF
End of file.
static int find_es_header(const uint8_t *header, const uint8_t *buffer, int search_len)
static int analyze_chunk(AVFormatContext *s, const uint8_t *chunk)
static int ty_read_packet(AVFormatContext *s, AVPacket *pkt)
int buf_size
Size of buf except extra allocated bytes.
static double b1(void *priv, double x, double y)
static av_cold int read_close(AVFormatContext *ctx)
static int ty_probe(const AVProbeData *p)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
static int demux_audio(AVFormatContext *s, TyRecHdr *rec_hdr, AVPacket *pkt)
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
enum AVStreamParseType need_parsing
must be printed separately If there s no standard function for printing the type you need
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static TyRecHdr * parse_chunk_headers(const uint8_t *buf, int num_recs)
static int read_header(FFV1Context *f)
This structure contains the data a format has to probe a file.
static const uint8_t ty_MPEGAudioPacket[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_NOPTS_VALUE
Undefined timestamp value.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
static const uint8_t header[24]
static double b2(void *priv, double x, double y)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
static int get_chunk(AVFormatContext *s)
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define SERIES2_PES_LENGTH
void * av_calloc(size_t nmemb, size_t size)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
const FFInputFormat ff_ty_demuxer
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int read_probe(const AVProbeData *p)
static int demux_video(AVFormatContext *s, TyRecHdr *rec_hdr, AVPacket *pkt)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
#define SERIES1_PES_LENGTH
static int check_sync_pes(AVFormatContext *s, AVPacket *pkt, int32_t offset, int32_t rec_len)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static const uint8_t ty_VideoPacket[]
uint8_t chunk[CHUNK_SIZE]
static int ty_read_close(AVFormatContext *s)
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_RB64
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.