[FFmpeg-devel] [PATCH] RTP H.264 / AVC support

Luca Abeni lucabe72
Thu Jun 3 13:18:56 CEST 2010

Hi Michael,

On 06/03/2010 12:56 PM, Michael Niedermayer wrote:
>>> Regarding the rtpenc_h264.c modifications, I think that introducing a
>>> static inline const uint8_t *ff_avc_find_startcode_avc(const uint8_t *p,
>>> const uint8_t *end, int nal_length_size)
>>> or a
>>> static inline int ff_avc_nal_size_avc(const uint8_t *p, int
>>> nal_length_size)
>>> helper (that can be shared with the bsf and with h264.c) can help in
>>> writing a small patch.
>> I took a stab at this but just getting the length isn't really very useful
>> in terms of minimizing code.
>> #include "libavcodec/bytestream.h"
>> static inline int ff_avc_nal_size_avc(const uint8_t **p, int
>> nal_length_size)
>> {
>>      int nalsize;
>>      switch(nal_length_size) {
>>      case 1: nalsize = **p; break;
>>      case 2: nalsize = AV_RB16(*p); break;
>>      default: nalsize = AV_RB32(*p); break;
>>      }
>>      *p += nal_length_size;
>>      return nalsize;
>> }
> while(nal_length_size--)
>      nalsize= 256*nalsize + *(*p)++;
> also i will reject duplication of the nal unit parsing code.

I agree; in fact my proposal was to get this code from h264.c
and to re-use it wherever it's possible (including h264.c).

Something like an inline function (or a macro) in h264.h, that
can be used in h264.c, int the mp4toannexb BSF, in rtpenc_h264.c,
and where needed...
Would that be acceptable? If not, what do you suggest?


More information about the ffmpeg-devel mailing list