[FFmpeg-devel] adding RGBA and BGRA to nvenc.c

Sven C. Dack sven.c.dack at sky.com
Wed Sep 7 12:40:13 EEST 2016


On 07/09/16 09:23, Timo Rothenpieler wrote:
>>               avctx->width << 1, avctx->height);
>> +    } else if (frame->format == AV_PIX_FMT_RGBA || frame->format ==
>> AV_PIX_FMT_RGB0) {
>> +      av_image_copy_plane(buf, lockBufferParams->pitch,
>> +           frame->data[0], frame->linesize[0],
>> +           avctx->width << 2, avctx->height);
>> +    } else if (frame->format == AV_PIX_FMT_BGRA || frame->format ==
>> AV_PIX_FMT_BGR0) {
>> +      av_image_copy_plane(buf, lockBufferParams->pitch,
>> +           frame->data[0], frame->linesize[0],
>> +           avctx->width << 2, avctx->height);
>>       } else {
> These are identical, so please put them into one if.
>
> Also, why is the twist from AV_PIX_FMT_RGBA to NV_ENC_BUFFER_FORMAT_ABGR
> necessary?
>
> The nvenc header describes it as "8 bit Packed A8B8G8R8", so did they
> mess it up?

It is necessary in order to make it work. The twist here is intentional as I 
pointed out earlier. If you do it the other way around as described in the 
documentation then you get false and missing colours.

I'd like to keep in the transparency channel unless you know there is an actual 
problem with it. The encoder may not use it, but it is no reason not to pass it 
on. Otherwise will RGBA/BGRA have to be converted into RGB0/BGR0 and you will 
again get a performance penalty.

Sven



More information about the ffmpeg-devel mailing list