[FFmpeg-devel] [PATCH]pes packetizer
Michael Niedermayer
michaelni
Fri Jul 6 18:49:47 CEST 2007
Hi
On Thu, Jul 05, 2007 at 02:25:07PM +0800, realsun wrote:
[...]
> -#define MAX_PAYLOAD_SIZE 4096
> -//#define DEBUG_SEEK
> +const int lpcm_freq_tab[4] = { 48000, 96000, 44100, 32000 };
non static and no prefix
[...]
> - stream = av_mallocz(sizeof(StreamInfo));
> - if (!stream)
> - goto fail;
> - st->priv_data = stream;
> -
> + stream = (PESStream*)st->priv_data;
uneeded cast
[...]
> - stream->id = mpv_id++;
> - if (st->codec->rc_buffer_size)
> - stream->max_buffer_size = 6*1024 + st->codec->rc_buffer_size/8;
> - else
> - stream->max_buffer_size = 230*1024; //FIXME this is probably too small as default
> #if 0
> /* see VCD standard, p. IV-7*/
> stream->max_buffer_size = 46 * 1024;
> @@ -366,10 +49,12 @@
> Right now it is also used for everything else.*/
> stream->max_buffer_size = 230 * 1024;
> #endif
> - s->video_bound++;
> + if (st->codec->rc_buffer_size)
> + stream->max_buffer_size = 6*1024 + st->codec->rc_buffer_size/8;
> + else
> + stream->max_buffer_size = 230*1024; //FIXME this is probably too small as default
cosmetic
[...]
> }
>
> static inline void put_timestamp(ByteIOContext *pb, int id, int64_t timestamp)
this function is duplicated after the patch
[...]
> -static int get_nb_frames(AVFormatContext *ctx, StreamInfo *stream, int len){
> +int get_nb_frames(AVFormatContext *ctx, PESStream *stream, int len){
missing prefix
[...]
> @@ -861,133 +130,35 @@
> if (pes_flags & 0x01) { /*write pes extension*/
> put_byte(&ctx->pb, 0x10); /* flags */
>
> + /* P-STD buffer info */
> + if (id == AUDIO_ID)
> + put_be16(&ctx->pb, 0x4000 | stream->max_buffer_size/128);
> + else
> + put_be16(&ctx->pb, 0x6000 | stream->max_buffer_size/1024);
> - /* P-STD buffer info */
> - if (id == AUDIO_ID)
> - put_be16(&ctx->pb, 0x4000 | stream->max_buffer_size/128);
> - else
> - put_be16(&ctx->pb, 0x6000 | stream->max_buffer_size/1024);
> - }
cosmetic
[...]
> - /* special stuffing byte that is always written
> - to prevent accidental generation of start codes. */
> - put_byte(&ctx->pb, 0xff);
> -
> - for(i=0;i<stuffing_size;i++)
> - put_byte(&ctx->pb, 0xff);
> - }
> -
> - if (startcode == PRIVATE_STREAM_1) {
> - put_byte(&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]);
> - } else if (id >= 0x40) {
> - /* AC3 */
> - 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;
> - stream->bytes_to_iframe -= payload_size - stuffing_size;
> - }else{
> - payload_size=
> - stuffing_size= 0;
> }
>
> + /* special stuffing byte that is always written
> + to prevent accidental generation of start codes. */
> + put_byte(&ctx->pb, 0xff);
> +
> + for(i=0;i<stuffing_size;i++)
> + put_byte(&ctx->pb, 0xff);
> +
> + put_buffer(&ctx->pb, pes_content, pes_content_len);
> +
> + /* output data */
> + if(av_fifo_generic_read(&stream->fifo, data_size, &put_buffer, &ctx->pb) < 0)
> + return -1;
> + return data_size;
this contains cosmetics
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
There will always be a question for which you do not know the correct awnser.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070706/44c9c573/attachment.pgp>
More information about the ffmpeg-devel
mailing list