[FFmpeg-devel] [PATCH] h264 bitstream filter
Måns Rullgård
mans
Fri Aug 31 12:33:12 CEST 2007
Benoit Fouet wrote:
> M?ns Rullg?rd wrote:
>> Benoit Fouet <benoit.fouet at purplelabs.com> writes:
>>
>>> + if (unit_type == 5 /* IDR picture */)
>>> + /* sps and pps have to be prepended to NAL unit */
>>> + alloc_and_copy(poutbuf, poutbuf_size,
>>> + ctx->sps_pps_data, ctx->size,
>>> + buf, buf_size,
>>> + ctx->size);
>>> + else if (unit_type == 6 /* SEI */ || unit_type == 9 /* AUD */)
>>> + /* sps and pps have to be appended to NAL unit */
>>> + alloc_and_copy(poutbuf, poutbuf_size,
>>> + buf, buf_size,
>>> + ctx->sps_pps_data, ctx->size,
>>> + 0);
>>>
>>
>> This is wrong. Maybe you misunderstood what I said about where to
>> insert SPS and PPS.
>
> it seems so...
>
>> They should be added before the first type 5 NAL
>> unit of an IDR picture, after whatever SEI or AUD units that picture
>> has. A multislice IDR picture only needs SPS and PPS before the first
>> slice, and non-IDR pictures should not have SPS or PPS added.
>>
>>
>
> i'm not sure i get it, here is what i understood, please correct me if
> i'm wrong
> i receive NALU in the filter
> if it's the first coded slice of an IDR picture (type 5 NAL), i prepend
> sps and pps NALUs (i don't really have to care about SEI or AUD in the
> bitstream filter case, right?)
> else, i don't add sps and pps
>
> this would give, in pseudo code:
>
> if (not sps and pps data)
> retrieve sps and pps
> first_idr=1
>
> if (first_idr && nal_unit_type == 5)
> prepend sps and pps
> first_idr=0
> else
> don't prepend sps and pps
> if( nal_unit_type != 5)
> first_idr=1
>
> is this right ?
Yes, that looks like it should do the trick.
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list