[FFmpeg-devel] [PATCH v11 1/3] libavcodec/dnxucdec: DNxUncompressed decoder

Anton Khirnov anton at khirnov.net
Thu Oct 10 15:13:43 EEST 2024


Quoting Martin Schitter (2024-10-10 04:58:40)
> +static int pass_though(AVCodecContext *avctx, AVFrame *frame, const AVPacket *avpkt)
> +{
> +    /* there is no need to copy as the data already match
> +     * a known pixel format */
> +
> +    frame->buf[0] = av_buffer_ref(avpkt->buf);
> +
> +    if (!frame->buf[0]) {
> +        return AVERROR(ENOMEM);
> +    }
> +
> +    return av_image_fill_arrays(frame->data, frame->linesize, avpkt->data,
> +                               avctx->pix_fmt, avctx->width, avctx->height, 1);
> +}

I've already commented on this in a previous version - this should be
directly exported as rawvideo by the demuxer rather than requiring a
special encoder.

> +static int float2planes(AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt)
> +{
> +    int lw;
> +    const size_t sof = 4;
> +
> +    lw = frame->width;
> +
> +    for(int y = 0; y < frame->height; y++){
> +        for(int x = 0; x < frame->width; x++){
> +            memcpy(&frame->data[2][sof*(lw*y + x)], &pkt->data[sof* 3*(lw*y + x)], sof);
> +            memcpy(&frame->data[0][sof*(lw*y + x)], &pkt->data[sof*(3*(lw*y + x) + 1)], sof);
> +            memcpy(&frame->data[1][sof*(lw*y + x)], &pkt->data[sof*(3*(lw*y + x) + 2)], sof);
> +        }
> +    }

Same here, deinterleaving packed to planar is a job for swscale.

> +    return pkt->size;
> +}
> +
> +static int half_add_alpha(AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt)
> +{
> +    /* ffmpeg doesn't provide any Float16 RGB pixel format without alpha channel
> +     * right now. As workaround we simply add an opaque alpha layer. */

So why not add the format then?

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list