* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/buffer.h"
#include "libavutil/crc.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/log.h"
int64_t pts, dts;
int64_t ts_packet_pos; /**< position of first TS packet of this PES packet */
uint8_t header[MAX_PES_HEADER_SIZE];
- uint8_t *buffer;
+ AVBufferRef *buffer;
SLConfigDescr sl;
} PESContext;
av_freep(&filter->u.section_filter.section_buf);
else if (filter->type == MPEGTS_PES) {
PESContext *pes = filter->u.pes_filter.opaque;
- av_freep(&pes->buffer);
+ av_buffer_unref(&pes->buffer);
/* referenced private data will be freed later in
* avformat_close_input */
if (!((PESContext *)filter->u.pes_filter.opaque)->st) {
score = analyze(buf, size, TS_PACKET_SIZE, NULL);
dvhs_score = analyze(buf, size, TS_DVHS_PACKET_SIZE, NULL);
fec_score= analyze(buf, size, TS_FEC_PACKET_SIZE, NULL);
-// av_log(NULL, AV_LOG_DEBUG, "score: %d, dvhs_score: %d, fec_score: %d \n", score, dvhs_score, fec_score);
+ av_dlog(NULL, "score: %d, dvhs_score: %d, fec_score: %d \n",
+ score, dvhs_score, fec_score);
if (score > fec_score && score > dvhs_score) return TS_PACKET_SIZE;
else if(dvhs_score > score && dvhs_score > fec_score) return TS_DVHS_PACKET_SIZE;
{ 0x10, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_MPEG4 },
{ 0x11, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_AAC_LATM }, /* LATM syntax */
{ 0x1b, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264 },
+ { 0x42, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_CAVS },
{ 0xd1, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_DIRAC },
{ 0xea, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VC1 },
{ 0 },
{
av_init_packet(pkt);
- pkt->destruct = av_destruct_packet;
- pkt->data = pes->buffer;
+ pkt->buf = pes->buffer;
+ pkt->data = pes->buffer->data;
pkt->size = pes->data_index;
if(pes->total_size != MAX_PES_PAYLOAD &&
pes->flags = 0;
}
-static uint64_t get_bits64(GetBitContext *gb, int bits)
-{
- uint64_t ret = 0;
- while (bits > 17) {
- ret <<= 17;
- ret |= get_bits(gb, 17);
- bits -= 17;
- }
- ret <<= bits;
- ret |= get_bits(gb, bits);
- return ret;
-}
-
static int read_sl_header(PESContext *pes, SLConfigDescr *sl, const uint8_t *buf, int buf_size)
{
GetBitContext gb;
code = pes->header[3] | 0x100;
av_dlog(pes->stream, "pid=%x pes_code=%#x\n", pes->pid, code);
- if ((pes->st && pes->st->discard == AVDISCARD_ALL) ||
+ if ((pes->st && pes->st->discard == AVDISCARD_ALL &&
+ (!pes->sub_st || pes->sub_st->discard == AVDISCARD_ALL)) ||
code == 0x1be) /* padding_stream */
goto skip;
pes->total_size = MAX_PES_PAYLOAD;
/* allocate pes buffer */
- pes->buffer = av_malloc(pes->total_size+FF_INPUT_BUFFER_PADDING_SIZE);
+ pes->buffer = av_buffer_alloc(pes->total_size +
+ FF_INPUT_BUFFER_PADDING_SIZE);
if (!pes->buffer)
return AVERROR(ENOMEM);
if (pes->data_index > 0 && pes->data_index+buf_size > pes->total_size) {
new_pes_packet(pes, ts->pkt);
pes->total_size = MAX_PES_PAYLOAD;
- pes->buffer = av_malloc(pes->total_size+FF_INPUT_BUFFER_PADDING_SIZE);
+ pes->buffer = av_buffer_alloc(pes->total_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!pes->buffer)
return AVERROR(ENOMEM);
ts->stop_parse = 1;
// not sure if this is legal in ts but see issue #2392
buf_size = pes->total_size;
}
- memcpy(pes->buffer+pes->data_index, p, buf_size);
+ memcpy(pes->buffer->data + pes->data_index, p, buf_size);
pes->data_index += buf_size;
}
buf_size = 0;
descr->sl.au_seq_num_len = (lengths >> 7) & 0x1f;
descr->sl.packet_seq_num_len = (lengths >> 2) & 0x1f;
} else {
- av_log_missing_feature(d->s, "Predefined SLConfigDescriptor\n", 0);
+ avpriv_report_missing_feature(d->s, "Predefined SLConfigDescriptor");
}
return 0;
}
}
if (st->codec->extradata) {
if (st->codec->extradata_size == 4 && memcmp(st->codec->extradata, *pp, 4))
- av_log_ask_for_sample(fc, "DVB sub with multiple IDs\n");
+ avpriv_request_sample(fc, "DVB sub with multiple IDs");
} else {
st->codec->extradata = av_malloc(4 + FF_INPUT_BUFFER_PADDING_SIZE);
if (st->codec->extradata) {
int i;
av_dlog(ts->stream, "PMT: len %i\n", section_len);
- hex_dump_debug(ts->stream, (uint8_t *)section, section_len);
+ hex_dump_debug(ts->stream, section, section_len);
p_end = section + section_len - 4;
p = section;
int sid, pmt_pid;
av_dlog(ts->stream, "PAT:\n");
- hex_dump_debug(ts->stream, (uint8_t *)section, section_len);
+ hex_dump_debug(ts->stream, section, section_len);
p_end = section + section_len - 4;
p = section;
char *name, *provider_name;
av_dlog(ts->stream, "SDT:\n");
- hex_dump_debug(ts->stream, (uint8_t *)section, section_len);
+ hex_dump_debug(ts->stream, section, section_len);
p_end = section + section_len - 4;
p = section;
if (ts->pids[i]) {
if (ts->pids[i]->type == MPEGTS_PES) {
PESContext *pes = ts->pids[i]->u.pes_filter.opaque;
- av_freep(&pes->buffer);
+ av_buffer_unref(&pes->buffer);
pes->data_index = 0;
pes->state = MPEGTS_SKIP; /* skip until pes header */
}
score = analyze(p->buf, TS_PACKET_SIZE *check_count, TS_PACKET_SIZE , NULL)*CHECK_COUNT/check_count;
dvhs_score= analyze(p->buf, TS_DVHS_PACKET_SIZE*check_count, TS_DVHS_PACKET_SIZE, NULL)*CHECK_COUNT/check_count;
fec_score = analyze(p->buf, TS_FEC_PACKET_SIZE *check_count, TS_FEC_PACKET_SIZE , NULL)*CHECK_COUNT/check_count;
-// av_log(NULL, AV_LOG_DEBUG, "score: %d, dvhs_score: %d, fec_score: %d \n", score, dvhs_score, fec_score);
+ av_dlog(NULL, "score: %d, dvhs_score: %d, fec_score: %d \n",
+ score, dvhs_score, fec_score);
// we need a clear definition for the returned score otherwise things will become messy sooner or later
if (score > fec_score && score > dvhs_score && score > 6) return AVPROBE_SCORE_MAX + score - CHECK_COUNT;
return ret;
}
-static int mpegts_read_close(AVFormatContext *s)
+static void mpegts_free(MpegTSContext *ts)
{
- MpegTSContext *ts = s->priv_data;
int i;
clear_programs(ts);
for(i=0;i<NB_PID_MAX;i++)
if (ts->pids[i]) mpegts_close_filter(ts, ts->pids[i]);
+}
+static int mpegts_read_close(AVFormatContext *s)
+{
+ MpegTSContext *ts = s->priv_data;
+ mpegts_free(ts);
return 0;
}
void ff_mpegts_parse_close(MpegTSContext *ts)
{
- int i;
-
- for(i=0;i<NB_PID_MAX;i++)
- av_free(ts->pids[i]);
+ mpegts_free(ts);
av_free(ts);
}