* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/fifo.h"
+#include "libavcodec/bitstream.h"
#include "avformat.h"
-#include "bitstream.h"
-#include "fifo.h"
#include "mpeg.h"
#define MAX_PAYLOAD_SIZE 4096
} else {
put_bits(&pb, 4, 0x2);
}
- put_bits(&pb, 3, (uint32_t)((timestamp >> 30) & 0x07));
+ put_bits(&pb, 3, (uint32_t)((timestamp >> 30) & 0x07));
put_bits(&pb, 1, 1);
put_bits(&pb, 15, (uint32_t)((timestamp >> 15) & 0x7fff));
put_bits(&pb, 1, 1);
- put_bits(&pb, 15, (uint32_t)((timestamp) & 0x7fff));
+ put_bits(&pb, 15, (uint32_t)((timestamp ) & 0x7fff));
put_bits(&pb, 1, 1);
if (s->is_mpeg2) {
/* clock extension */
id = stream->id;
if (id < 0xc0) {
- /* special case for private streams (AC3 use that) */
+ /* special case for private streams (AC-3 uses that) */
if (private_stream_coded)
continue;
private_stream_coded = 1;
int video_bitrate;
s->packet_number = 0;
- s->is_vcd = (ENABLE_MPEG1VCD_MUXER && ctx->oformat == &mpeg1vcd_muxer);
- s->is_svcd = (ENABLE_MPEG2SVCD_MUXER && ctx->oformat == &mpeg2svcd_muxer);
+ s->is_vcd = (ENABLE_MPEG1VCD_MUXER && ctx->oformat == &mpeg1vcd_muxer);
+ s->is_svcd = (ENABLE_MPEG2SVCD_MUXER && ctx->oformat == &mpeg2svcd_muxer);
s->is_mpeg2 = ((ENABLE_MPEG2VOB_MUXER && ctx->oformat == &mpeg2vob_muxer) ||
(ENABLE_MPEG2DVD_MUXER && ctx->oformat == &mpeg2dvd_muxer) ||
(ENABLE_MPEG2SVCD_MUXER && ctx->oformat == &mpeg2svcd_muxer));
- s->is_dvd = (ENABLE_MPEG2DVD_MUXER && ctx->oformat == &mpeg2dvd_muxer);
+ s->is_dvd = (ENABLE_MPEG2DVD_MUXER && ctx->oformat == &mpeg2dvd_muxer);
if(ctx->packet_size)
s->packet_size = ctx->packet_size;
switch(st->codec->codec_type) {
case CODEC_TYPE_AUDIO:
- if (st->codec->codec_id == CODEC_ID_AC3) {
+ if (st->codec->codec_id == CODEC_ID_AC3) {
stream->id = ac3_id++;
} else if (st->codec->codec_id == CODEC_ID_DTS) {
stream->id = dts_id++;
/* Add the header overhead to the data rate.
2279 data bytes per audio pack, 2294 data bytes per video pack*/
- overhead_rate = ((audio_bitrate / 8.0) / 2279) * (2324 - 2279);
+ overhead_rate = ((audio_bitrate / 8.0) / 2279) * (2324 - 2279);
overhead_rate += ((video_bitrate / 8.0) / 2294) * (2324 - 2294);
overhead_rate *= 8;
(((timestamp >> 30) & 0x07) << 1) |
1);
put_be16(pb, (uint16_t)((((timestamp >> 15) & 0x7fff) << 1) | 1));
- put_be16(pb, (uint16_t)((((timestamp) & 0x7fff) << 1) | 1));
+ put_be16(pb, (uint16_t)((((timestamp ) & 0x7fff) << 1) | 1));
}
}
if (stream->id < 0xc0) {
- /* AC3/LPCM private data header */
+ /* AC-3/LPCM private data header */
buf_index += 4;
if (stream->id >= 0xa0) {
int n;
header_len -= timestamp_len;
if (s->is_dvd && stream->align_iframe) {
pad_packet_bytes += timestamp_len;
- packet_size -= timestamp_len;
+ packet_size -= timestamp_len;
} else {
payload_size += timestamp_len;
}
packet_size += pad_packet_bytes;
payload_size += pad_packet_bytes; // undo the previous adjustment
if (stuffing_size < 0) {
- stuffing_size = pad_packet_bytes;
+ stuffing_size = pad_packet_bytes;
} else {
stuffing_size += pad_packet_bytes;
}
stuffing_size = 0;
if (stuffing_size > 16) { /*<=16 for MPEG-1, <=32 for MPEG-2*/
pad_packet_bytes += stuffing_size;
- packet_size -= stuffing_size;
- payload_size -= stuffing_size;
+ packet_size -= stuffing_size;
+ payload_size -= stuffing_size;
stuffing_size = 0;
}
/* P-STD buffer info */
if (id == AUDIO_ID)
- put_be16(ctx->pb, 0x4000 | stream->max_buffer_size/128);
+ put_be16(ctx->pb, 0x4000 | stream->max_buffer_size/ 128);
else
put_be16(ctx->pb, 0x6000 | stream->max_buffer_size/1024);
}
put_byte(ctx->pb, stream->lpcm_header[1]);
put_byte(ctx->pb, stream->lpcm_header[2]);
} else if (id >= 0x40) {
- /* AC3 */
+ /* AC-3 */
put_byte(ctx->pb, nb_frames);
put_be16(ctx->pb, trailer_size+1);
}
}
/* output data */
- if(av_fifo_generic_read(&stream->fifo, payload_size - stuffing_size, &put_buffer, ctx->pb) < 0)
- return -1;
+ assert(payload_size - stuffing_size <= av_fifo_size(&stream->fifo));
+ av_fifo_generic_read(&stream->fifo, payload_size - stuffing_size, &put_buffer, ctx->pb);
stream->bytes_to_iframe -= payload_size - stuffing_size;
}else{
payload_size=
MpegMuxContext *s = ctx->priv_data;
AVStream *st;
StreamInfo *stream;
- int i, avail_space, es_size, trailer_size;
+ int i, avail_space=0, es_size, trailer_size;
int best_i= -1;
int best_score= INT_MIN;
int ignore_constraints=0;
stream->predecode_packet= pkt_desc;
stream->next_packet= &pkt_desc->next;
- av_fifo_realloc(&stream->fifo, av_fifo_size(&stream->fifo) + size + 1);
+ if (av_fifo_realloc2(&stream->fifo, av_fifo_size(&stream->fifo) + size) < 0)
+ return -1;
if (s->is_dvd){
if (is_iframe && (s->packet_number == 0 || (pts - stream->vobu_start_pts >= 36000))) { // min VOBU length 0.4 seconds (mpucoder)
}
}
- av_fifo_write(&stream->fifo, buf, size);
+ av_fifo_generic_write(&stream->fifo, buf, size, NULL);
for(;;){
int ret= output_packet(ctx, 0);
#ifdef CONFIG_MPEG1SYSTEM_MUXER
AVOutputFormat mpeg1system_muxer = {
"mpeg",
- "MPEG1 System format",
+ NULL_IF_CONFIG_SMALL("MPEG-1 System format"),
"video/mpeg",
"mpg,mpeg",
sizeof(MpegMuxContext),
#ifdef CONFIG_MPEG1VCD_MUXER
AVOutputFormat mpeg1vcd_muxer = {
"vcd",
- "MPEG1 System format (VCD)",
+ NULL_IF_CONFIG_SMALL("MPEG-1 System format (VCD)"),
"video/mpeg",
NULL,
sizeof(MpegMuxContext),
#ifdef CONFIG_MPEG2VOB_MUXER
AVOutputFormat mpeg2vob_muxer = {
"vob",
- "MPEG2 PS format (VOB)",
+ NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"),
"video/mpeg",
"vob",
sizeof(MpegMuxContext),
#ifdef CONFIG_MPEG2SVCD_MUXER
AVOutputFormat mpeg2svcd_muxer = {
"svcd",
- "MPEG2 PS format (VOB)",
+ NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"),
"video/mpeg",
"vob",
sizeof(MpegMuxContext),
#ifdef CONFIG_MPEG2DVD_MUXER
AVOutputFormat mpeg2dvd_muxer = {
"dvd",
- "MPEG2 PS format (DVD VOB)",
+ NULL_IF_CONFIG_SMALL("MPEG-2 PS format (DVD VOB)"),
"video/mpeg",
"dvd",
sizeof(MpegMuxContext),