X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fmpegenc.c;h=0e0164511a11b797e592f1096e598e362f2c569c;hb=c3675dfe1e345a81d704fa0dd31151b8d54589ee;hp=eef385f06caec5ebfa0aeff12a20ebad83ef59ac;hpb=c6610a216ed2948885772154a2eed696e0cb4aca;p=ffmpeg diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index eef385f06ca..0e0164511a1 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -2,20 +2,20 @@ * MPEG1/2 muxer * Copyright (c) 2000, 2001, 2002 Fabrice Bellard * - * This file is part of FFmpeg. + * This file is part of Libav. * - * FFmpeg is free software; you can redistribute it and/or + * Libav is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * FFmpeg is distributed in the hope that it will be useful, + * Libav is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software + * License along with Libav; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -491,14 +491,14 @@ static int mpeg_mux_init(AVFormatContext *ctx) return AVERROR(ENOMEM); } -static inline void put_timestamp(ByteIOContext *pb, int id, int64_t timestamp) +static inline void put_timestamp(AVIOContext *pb, int id, int64_t timestamp) { - put_byte(pb, + avio_w8(pb, (id << 4) | (((timestamp >> 30) & 0x07) << 1) | 1); - put_be16(pb, (uint16_t)((((timestamp >> 15) & 0x7fff) << 1) | 1)); - put_be16(pb, (uint16_t)((((timestamp ) & 0x7fff) << 1) | 1)); + avio_wb16(pb, (uint16_t)((((timestamp >> 15) & 0x7fff) << 1) | 1)); + avio_wb16(pb, (uint16_t)((((timestamp ) & 0x7fff) << 1) | 1)); } @@ -613,21 +613,21 @@ static int get_packet_payload_size(AVFormatContext *ctx, int stream_index, #endif /* Write an MPEG padding packet header. */ -static void put_padding_packet(AVFormatContext *ctx, ByteIOContext *pb,int packet_bytes) +static void put_padding_packet(AVFormatContext *ctx, AVIOContext *pb,int packet_bytes) { MpegMuxContext *s = ctx->priv_data; int i; - put_be32(pb, PADDING_STREAM); - put_be16(pb, packet_bytes - 6); + avio_wb32(pb, PADDING_STREAM); + avio_wb16(pb, packet_bytes - 6); if (!s->is_mpeg2) { - put_byte(pb, 0x0f); + avio_w8(pb, 0x0f); packet_bytes -= 7; } else packet_bytes -= 6; for(i=0;ipb, buffer, size); + avio_write(ctx->pb, buffer, size); - put_be32(ctx->pb, PRIVATE_STREAM_2); - put_be16(ctx->pb, 0x03d4); // length - put_byte(ctx->pb, 0x00); // substream ID, 00=PCI + avio_wb32(ctx->pb, PRIVATE_STREAM_2); + avio_wb16(ctx->pb, 0x03d4); // length + avio_w8(ctx->pb, 0x00); // substream ID, 00=PCI for (i = 0; i < 979; i++) - put_byte(ctx->pb, 0x00); + avio_w8(ctx->pb, 0x00); - put_be32(ctx->pb, PRIVATE_STREAM_2); - put_be16(ctx->pb, 0x03fa); // length - put_byte(ctx->pb, 0x01); // substream ID, 01=DSI + avio_wb32(ctx->pb, PRIVATE_STREAM_2); + avio_wb16(ctx->pb, 0x03fa); // length + avio_w8(ctx->pb, 0x01); // substream ID, 01=DSI for (i = 0; i < 1017; i++) - put_byte(ctx->pb, 0x00); + avio_w8(ctx->pb, 0x00); memset(buffer, 0, 128); buf_ptr = buffer; @@ -734,7 +734,7 @@ static int flush_packet(AVFormatContext *ctx, int stream_index, } } size = buf_ptr - buffer; - put_buffer(ctx->pb, buffer, size); + avio_write(ctx->pb, buffer, size); packet_size = s->packet_size - size; @@ -839,16 +839,16 @@ static int flush_packet(AVFormatContext *ctx, int stream_index, nb_frames= get_nb_frames(ctx, stream, payload_size - stuffing_size); - put_be32(ctx->pb, startcode); + avio_wb32(ctx->pb, startcode); - put_be16(ctx->pb, packet_size); + avio_wb16(ctx->pb, packet_size); if (!s->is_mpeg2) for(i=0;ipb, 0xff); + avio_w8(ctx->pb, 0xff); if (s->is_mpeg2) { - put_byte(ctx->pb, 0x80); /* mpeg2 id */ + avio_w8(ctx->pb, 0x80); /* mpeg2 id */ pes_flags=0; @@ -865,8 +865,8 @@ static int flush_packet(AVFormatContext *ctx, int stream_index, if (stream->packet_number == 0) pes_flags |= 0x01; - put_byte(ctx->pb, pes_flags); /* flags */ - put_byte(ctx->pb, header_len - 3 + stuffing_size); + avio_w8(ctx->pb, pes_flags); /* flags */ + avio_w8(ctx->pb, header_len - 3 + stuffing_size); if (pes_flags & 0x80) /*write pts*/ put_timestamp(ctx->pb, (pes_flags & 0x40) ? 0x03 : 0x02, pts); @@ -874,13 +874,13 @@ static int flush_packet(AVFormatContext *ctx, int stream_index, put_timestamp(ctx->pb, 0x01, dts); if (pes_flags & 0x01) { /*write pes extension*/ - put_byte(ctx->pb, 0x10); /* flags */ + avio_w8(ctx->pb, 0x10); /* flags */ /* P-STD buffer info */ if ((id & 0xe0) == AUDIO_ID) - put_be16(ctx->pb, 0x4000 | stream->max_buffer_size/ 128); + avio_wb16(ctx->pb, 0x4000 | stream->max_buffer_size/ 128); else - put_be16(ctx->pb, 0x6000 | stream->max_buffer_size/1024); + avio_wb16(ctx->pb, 0x6000 | stream->max_buffer_size/1024); } } else { @@ -892,38 +892,38 @@ static int flush_packet(AVFormatContext *ctx, int stream_index, put_timestamp(ctx->pb, 0x02, pts); } } else { - put_byte(ctx->pb, 0x0f); + avio_w8(ctx->pb, 0x0f); } } if (s->is_mpeg2) { /* special stuffing byte that is always written to prevent accidental generation of start codes. */ - put_byte(ctx->pb, 0xff); + avio_w8(ctx->pb, 0xff); for(i=0;ipb, 0xff); + avio_w8(ctx->pb, 0xff); } if (startcode == PRIVATE_STREAM_1) { - put_byte(ctx->pb, id); + avio_w8(ctx->pb, id); if (id >= 0xa0) { /* LPCM (XXX: check nb_frames) */ - put_byte(ctx->pb, 7); - put_be16(ctx->pb, 4); /* skip 3 header bytes */ - put_byte(ctx->pb, stream->lpcm_header[0]); - put_byte(ctx->pb, stream->lpcm_header[1]); - put_byte(ctx->pb, stream->lpcm_header[2]); + avio_w8(ctx->pb, 7); + avio_wb16(ctx->pb, 4); /* skip 3 header bytes */ + avio_w8(ctx->pb, stream->lpcm_header[0]); + avio_w8(ctx->pb, stream->lpcm_header[1]); + avio_w8(ctx->pb, stream->lpcm_header[2]); } else if (id >= 0x40) { /* AC-3 */ - put_byte(ctx->pb, nb_frames); - put_be16(ctx->pb, trailer_size+1); + avio_w8(ctx->pb, nb_frames); + avio_wb16(ctx->pb, trailer_size+1); } } /* output data */ assert(payload_size - stuffing_size <= av_fifo_size(stream->fifo)); - av_fifo_generic_read(stream->fifo, ctx->pb, payload_size - stuffing_size, &put_buffer); + av_fifo_generic_read(stream->fifo, ctx->pb, payload_size - stuffing_size, &avio_write); stream->bytes_to_iframe -= payload_size - stuffing_size; }else{ payload_size= @@ -934,9 +934,9 @@ static int flush_packet(AVFormatContext *ctx, int stream_index, put_padding_packet(ctx,ctx->pb, pad_packet_bytes); for(i=0;ipb, 0x00); + avio_w8(ctx->pb, 0x00); - put_flush_packet(ctx->pb); + avio_flush(ctx->pb); s->packet_number++; @@ -961,11 +961,11 @@ static void put_vcd_padding_sector(AVFormatContext *ctx) int i; for(i=0;ipacket_size;i++) - put_byte(ctx->pb, 0); + avio_w8(ctx->pb, 0); s->vcd_padding_bytes_written += s->packet_size; - put_flush_packet(ctx->pb); + avio_flush(ctx->pb); /* 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 @@ -1220,8 +1220,8 @@ static int mpeg_mux_end(AVFormatContext *ctx) /* End header according to MPEG1 systems standard. We do not write it as it is usually not needed by decoders and because it complicates MPEG stream concatenation. */ - //put_be32(ctx->pb, ISO_11172_END_CODE); - //put_flush_packet(ctx->pb); + //avio_wb32(ctx->pb, ISO_11172_END_CODE); + //avio_flush(ctx->pb); for(i=0;inb_streams;i++) { stream = ctx->streams[i]->priv_data;