[FFmpeg-devel] [PATCH]pes packetizer

realsun sunxiaohui
Tue Jul 10 09:35:37 CEST 2007


Michael Niedermayer wrote:
> 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
>   

changed to ff_lpcm_freq_tab

>
> [...]
>   
>> -        stream = av_mallocz(sizeof(StreamInfo));
>> -        if (!stream)
>> -            goto fail;
>> -        st->priv_data = stream;
>> -
>> +        stream = (PESStream*)st->priv_data;
>>     
>
> uneeded cast
>   

removed

>
> [...]
>   
>> -            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
>   

fixed

>
> [...]
>   
>>  }
>>  
>>  static inline void put_timestamp(ByteIOContext *pb, int id, int64_t timestamp)
>>     
>
> this function is duplicated after the patch
>   

removed

>
> [...]
>   
>> -static int get_nb_frames(AVFormatContext *ctx, StreamInfo *stream, int len){
>> +int get_nb_frames(AVFormatContext *ctx, PESStream *stream, int len){
>>     
>
> missing prefix
>   

added, but maybe that should be in another patch to change the function
name.

>
> [...]
>   
>> @@ -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
>   

fixed

>
> [...]
>
>   
>> -            /* 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
>   

fixed

> [...]
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pes.diff
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070710/41c5df30/attachment.txt>



More information about the ffmpeg-devel mailing list