You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avformat/mpegts: rename PES total_size to PES_packet_length
This renames PESContext->total_size to PESContext->PES_packet_length and keeps it 0 for unbound packets, so its name and semantics will match the standard. There should be no change in functionality. Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
@@ -254,7 +254,7 @@ typedef struct PESContext {
|
|||||||
/* used to get the format */
|
/* used to get the format */
|
||||||
int data_index;
|
int data_index;
|
||||||
int flags; /**< copied to the AVPacket flags */
|
int flags; /**< copied to the AVPacket flags */
|
||||||
int total_size;
|
int PES_packet_length;
|
||||||
int pes_header_size;
|
int pes_header_size;
|
||||||
int extended_stream_id;
|
int extended_stream_id;
|
||||||
uint8_t stream_id;
|
uint8_t stream_id;
|
||||||
@@ -998,8 +998,8 @@ static int new_pes_packet(PESContext *pes, AVPacket *pkt)
|
|||||||
pkt->data = pes->buffer->data;
|
pkt->data = pes->buffer->data;
|
||||||
pkt->size = pes->data_index;
|
pkt->size = pes->data_index;
|
||||||
|
|
||||||
if (pes->total_size != MAX_PES_PAYLOAD &&
|
if (pes->PES_packet_length &&
|
||||||
pes->pes_header_size + pes->data_index != pes->total_size +
|
pes->pes_header_size + pes->data_index != pes->PES_packet_length +
|
||||||
PES_START_SIZE) {
|
PES_START_SIZE) {
|
||||||
av_log(pes->stream, AV_LOG_WARNING, "PES packet size mismatch\n");
|
av_log(pes->stream, AV_LOG_WARNING, "PES packet size mismatch\n");
|
||||||
pes->flags |= AV_PKT_FLAG_CORRUPT;
|
pes->flags |= AV_PKT_FLAG_CORRUPT;
|
||||||
@@ -1183,11 +1183,8 @@ static int mpegts_push_data(MpegTSFilter *filter,
|
|||||||
mpegts_set_stream_info(pes->st, pes, 0, 0);
|
mpegts_set_stream_info(pes->st, pes, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pes->total_size = AV_RB16(pes->header + 4);
|
pes->PES_packet_length = AV_RB16(pes->header + 4);
|
||||||
/* NOTE: a zero total size means the PES size is
|
/* NOTE: zero length means the PES size is unbounded */
|
||||||
* unbounded */
|
|
||||||
if (!pes->total_size)
|
|
||||||
pes->total_size = MAX_PES_PAYLOAD;
|
|
||||||
|
|
||||||
if (pes->stream_id != STREAM_ID_PROGRAM_STREAM_MAP &&
|
if (pes->stream_id != STREAM_ID_PROGRAM_STREAM_MAP &&
|
||||||
pes->stream_id != STREAM_ID_PRIVATE_STREAM_2 &&
|
pes->stream_id != STREAM_ID_PRIVATE_STREAM_2 &&
|
||||||
@@ -1360,22 +1357,27 @@ skip:
|
|||||||
break;
|
break;
|
||||||
case MPEGTS_PAYLOAD:
|
case MPEGTS_PAYLOAD:
|
||||||
do {
|
do {
|
||||||
|
int max_packet_size = MAX_PES_PAYLOAD;
|
||||||
|
if (pes->PES_packet_length)
|
||||||
|
max_packet_size = pes->PES_packet_length;
|
||||||
|
|
||||||
if (pes->data_index > 0 &&
|
if (pes->data_index > 0 &&
|
||||||
pes->data_index + buf_size > pes->total_size) {
|
pes->data_index + buf_size > max_packet_size) {
|
||||||
ret = new_pes_packet(pes, ts->pkt);
|
ret = new_pes_packet(pes, ts->pkt);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
pes->total_size = MAX_PES_PAYLOAD;
|
pes->PES_packet_length = 0;
|
||||||
|
max_packet_size = MAX_PES_PAYLOAD;
|
||||||
ts->stop_parse = 1;
|
ts->stop_parse = 1;
|
||||||
} else if (pes->data_index == 0 &&
|
} else if (pes->data_index == 0 &&
|
||||||
buf_size > pes->total_size) {
|
buf_size > max_packet_size) {
|
||||||
// pes packet size is < ts size packet and pes data is padded with 0xff
|
// pes packet size is < ts size packet and pes data is padded with 0xff
|
||||||
// not sure if this is legal in ts but see issue #2392
|
// not sure if this is legal in ts but see issue #2392
|
||||||
buf_size = pes->total_size;
|
buf_size = max_packet_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pes->buffer) {
|
if (!pes->buffer) {
|
||||||
pes->buffer = buffer_pool_get(ts, pes->total_size);
|
pes->buffer = buffer_pool_get(ts, max_packet_size);
|
||||||
if (!pes->buffer)
|
if (!pes->buffer)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
@@ -1384,11 +1386,9 @@ skip:
|
|||||||
pes->data_index += buf_size;
|
pes->data_index += buf_size;
|
||||||
/* emit complete packets with known packet size
|
/* emit complete packets with known packet size
|
||||||
* decreases demuxer delay for infrequent packets like subtitles from
|
* decreases demuxer delay for infrequent packets like subtitles from
|
||||||
* a couple of seconds to milliseconds for properly muxed files.
|
* a couple of seconds to milliseconds for properly muxed files. */
|
||||||
* total_size is the number of bytes following pes_packet_length
|
if (!ts->stop_parse && pes->PES_packet_length &&
|
||||||
* in the pes header, i.e. not counting the first PES_START_SIZE bytes */
|
pes->pes_header_size + pes->data_index == pes->PES_packet_length + PES_START_SIZE) {
|
||||||
if (!ts->stop_parse && pes->total_size < MAX_PES_PAYLOAD &&
|
|
||||||
pes->pes_header_size + pes->data_index == pes->total_size + PES_START_SIZE) {
|
|
||||||
ts->stop_parse = 1;
|
ts->stop_parse = 1;
|
||||||
ret = new_pes_packet(pes, ts->pkt);
|
ret = new_pes_packet(pes, ts->pkt);
|
||||||
pes->state = MPEGTS_SKIP;
|
pes->state = MPEGTS_SKIP;
|
||||||
|
Reference in New Issue
Block a user