[FFmpeg-soc] Extend TSMuxer to H264 muxing

Michael Niedermayer michaelni at gmx.at
Sun Apr 13 20:36:49 CEST 2008


On Mon, Apr 14, 2008 at 01:52:41AM +0800, zhentan feng wrote:
> Hi
> 
> 2008/4/3, Baptiste Coudurier <baptiste.coudurier at smartjog.com>:
> >
> > Hi,
> >
> > zhentan feng wrote:
> > > [...]
> >
> > >
> > >  New Add fields:
> > >       1,AVC video descriptor
> > >       2,AVC timing and HRD descriptor
> >
> >
> > Those are worth to be added.
> >
> > Also We must ensure in some way that H264 bitstream contains AUD NAL
> > units.
> >
> >
> > >
> > > (4)At last, how do I test the code works right for H264 muxing?
> > > Tank you for any advice.
> > >
> >
> >
> > Well for now, use VLC to play back streams, but justify all your changes
> > by the specs.
> >
> >
> I add AVC video descriptor and AVC timing and HRD descriptor when write PMT
> in TS init,
> and check the AUD nal units for pkt->data.
> 
> here is the patch attached below.
> 
> Thanks for your any advice.

[...]
> +int check_aud_nal_units(AVPacket * pkt)
> +{
> +    int size = pkt->size;
> +    uint8_t *buf = pkt->data;
> +    int buf_index = 0;
> +    int is_aud = 0;
> +    uint8_t *new_buf = 0;
> +    for(; buf_index + 3 < size; buf_index++){
> +        if(buf[buf_index] == 0 && buf[buf_index+1] == 0 && buf[buf_index+2] == 1){
> +            is_aud = 1;
> +            break;
> +        }
> +    }

> +    if(!is_aud){
> +    new_buf = av_mallocz(size + 3);

missing indention


> +    if (!new_buf)
> +        return 0;
> +    new_buf[0] = 0;
> +    new_buf[1] = 0;
> +    new_buf[2] = 1;
> +    memcpy(new_buf + 3, buf, size);
> +    av_free(buf);
> +    pkt->data = new_buf;
> +    pkt->size = size + 3;        

trailing whitespace


[...]
> @@ -406,7 +439,12 @@
>      int64_t pts, dts;
>      PacketDesc *pkt_desc;
>      const int preload= av_rescale(ctx->preload, 90000, AV_TIME_BASE);
> +    if(st->codec->codec_id == CODEC_ID_H264)
> +        check_aud_nal_units(pkt);
>  
> +    int size= pkt->size;
> +    uint8_t *buf= pkt->data;
> +

mixing declarations and statements, breaks gcc 2.95 support


>      pts= pkt->pts;
>      dts= pkt->dts;
>  
> Index: mpegtsenc.c
> ===================================================================
> --- mpegtsenc.c	(revision 2130)
> +++ mpegtsenc.c	(working copy)
> @@ -288,6 +288,39 @@
>                  put16(&q, 1); /* ancillary page id */
>              }
>              break;
> +        case CODEC_TYPE_VIDEO:
> +            {
> +                if(st->codec->codec_id == CODEC_ID_H264){
> +                    H264Context * h_st = st->codec->priv_data;

This is invalid, there is a reason why its called priv_data, and that is
that it is private to the codec.

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-soc/attachments/20080413/863e05a8/attachment.pgp>


More information about the FFmpeg-soc mailing list