uint8_t id;
int max_buffer_size; /* in bytes */
int buffer_index;
- PacketDesc *predecode_packet;
+ PacketDesc *predecode_packet; /* start of packet queue */
+ PacketDesc *last_packet; /* end of packet queue */
PacketDesc *premux_packet;
- PacketDesc **next_packet;
int packet_number;
uint8_t lpcm_header[3];
int lpcm_align;
int preload;
} MpegMuxContext;
-extern AVOutputFormat ff_mpeg1vcd_muxer;
-extern AVOutputFormat ff_mpeg2dvd_muxer;
-extern AVOutputFormat ff_mpeg2svcd_muxer;
-extern AVOutputFormat ff_mpeg2vob_muxer;
+extern const AVOutputFormat ff_mpeg1vcd_muxer;
+extern const AVOutputFormat ff_mpeg2dvd_muxer;
+extern const AVOutputFormat ff_mpeg2svcd_muxer;
+extern const AVOutputFormat ff_mpeg2vob_muxer;
static int put_pack_header(AVFormatContext *ctx, uint8_t *buf,
int64_t timestamp)
for (i = 0; i < zero_trail_bytes; i++)
avio_w8(ctx->pb, 0x00);
- avio_flush(ctx->pb);
+ avio_write_marker(ctx->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_FLUSH_POINT);
s->packet_number++;
s->vcd_padding_bytes_written += s->packet_size;
- avio_flush(ctx->pb);
+ avio_write_marker(ctx->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_FLUSH_POINT);
/* increasing the packet number is correct. The SCR of the following packs
* is calculated from the packet_number and it has to include the padding
}
stream->buffer_index -= pkt_desc->size;
stream->predecode_packet = pkt_desc->next;
+ if (!stream->predecode_packet)
+ stream->last_packet = NULL;
av_freep(&pkt_desc);
}
}
StreamInfo *stream = st->priv_data;
int64_t pts, dts;
PacketDesc *pkt_desc;
- int preload;
+ int preload, ret;
const int is_iframe = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
(pkt->flags & AV_PKT_FLAG_KEY);
av_log(ctx, AV_LOG_TRACE, "dts:%f pts:%f flags:%d stream:%d nopts:%d\n",
dts / 90000.0, pts / 90000.0, pkt->flags,
pkt->stream_index, pts != AV_NOPTS_VALUE);
- if (!stream->premux_packet)
- stream->next_packet = &stream->premux_packet;
- *stream->next_packet =
- pkt_desc = av_mallocz(sizeof(PacketDesc));
- if (!pkt_desc)
- return AVERROR(ENOMEM);
- pkt_desc->pts = pts;
- pkt_desc->dts = dts;
if (st->codecpar->codec_id == AV_CODEC_ID_PCM_DVD) {
if (size < 3) {
size -= 3;
}
+ pkt_desc = av_mallocz(sizeof(PacketDesc));
+ if (!pkt_desc)
+ return AVERROR(ENOMEM);
+ if (!stream->predecode_packet) {
+ stream->predecode_packet = pkt_desc;
+ } else
+ stream->last_packet->next = pkt_desc;
+ stream->last_packet = pkt_desc;
+ if (!stream->premux_packet)
+ stream->premux_packet = pkt_desc;
+ pkt_desc->pts = pts;
+ pkt_desc->dts = dts;
pkt_desc->unwritten_size =
pkt_desc->size = size;
- if (!stream->predecode_packet)
- stream->predecode_packet = pkt_desc;
- stream->next_packet = &pkt_desc->next;
- if (av_fifo_realloc2(stream->fifo, av_fifo_size(stream->fifo) + size) < 0)
- return -1;
+ ret = av_fifo_realloc2(stream->fifo, av_fifo_size(stream->fifo) + size);
+ if (ret < 0)
+ return ret;
if (s->is_dvd) {
// min VOBU length 0.4 seconds (mpucoder)
if (is_iframe &&
- (s->packet_number == 0 ||
+ (s->packet_number == 0 || pts != AV_NOPTS_VALUE &&
(pts - stream->vobu_start_pts >= 36000))) {
stream->bytes_to_iframe = av_fifo_size(stream->fifo);
stream->align_iframe = 1;
* it as it is usually not needed by decoders and because it
* complicates MPEG stream concatenation. */
// avio_wb32(ctx->pb, ISO_11172_END_CODE);
- // avio_flush(ctx->pb);
for (i = 0; i < ctx->nb_streams; i++) {
stream = ctx->streams[i]->priv_data;
{
for (int i = 0; i < ctx->nb_streams; i++) {
StreamInfo *stream = ctx->streams[i]->priv_data;
+ if (!stream)
+ continue;
+ for (PacketDesc *pkt = stream->predecode_packet; pkt; ) {
+ PacketDesc *tmp = pkt->next;
+ av_free(pkt);
+ pkt = tmp;
+ }
av_fifo_freep(&stream->fifo);
}
}
#if CONFIG_MPEG1SYSTEM_MUXER
MPEGENC_CLASS(mpeg)
-AVOutputFormat ff_mpeg1system_muxer = {
+const AVOutputFormat ff_mpeg1system_muxer = {
.name = "mpeg",
.long_name = NULL_IF_CONFIG_SMALL("MPEG-1 Systems / MPEG program stream"),
.mime_type = "video/mpeg",
#if CONFIG_MPEG1VCD_MUXER
MPEGENC_CLASS(vcd)
-AVOutputFormat ff_mpeg1vcd_muxer = {
+const AVOutputFormat ff_mpeg1vcd_muxer = {
.name = "vcd",
.long_name = NULL_IF_CONFIG_SMALL("MPEG-1 Systems / MPEG program stream (VCD)"),
.mime_type = "video/mpeg",
#if CONFIG_MPEG2VOB_MUXER
MPEGENC_CLASS(vob)
-AVOutputFormat ff_mpeg2vob_muxer = {
+const AVOutputFormat ff_mpeg2vob_muxer = {
.name = "vob",
.long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS (VOB)"),
.mime_type = "video/mpeg",
/* Same as mpeg2vob_mux except that the pack size is 2324 */
#if CONFIG_MPEG2SVCD_MUXER
MPEGENC_CLASS(svcd)
-AVOutputFormat ff_mpeg2svcd_muxer = {
+const AVOutputFormat ff_mpeg2svcd_muxer = {
.name = "svcd",
.long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS (SVCD)"),
.mime_type = "video/mpeg",
/* Same as mpeg2vob_mux except the 'is_dvd' flag is set to produce NAV pkts */
#if CONFIG_MPEG2DVD_MUXER
MPEGENC_CLASS(dvd)
-AVOutputFormat ff_mpeg2dvd_muxer = {
+const AVOutputFormat ff_mpeg2dvd_muxer = {
.name = "dvd",
.long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS (DVD VOB)"),
.mime_type = "video/mpeg",