descampsa / yuv2rgb

C99 library for fast image conversion between yuv420p and rgb24
BSD 3-Clause "New" or "Revised" License
170 stars 62 forks source link

function params #7

Closed LuoZijun closed 5 years ago

LuoZijun commented 7 years ago

for now:


AVFrame *src_frame = av_frame_alloc();
AVFrame *dst_frame = av_frame_alloc();
// const size_t y_stride   = width + (16-width%16)%16,
//              uv_stride  = (width+1)/2 + (16-((width+1)/2)%16)%16,
//              rgb_stride = width*3 +(16-(3*width)%16)%16;
// const YCbCrType yuv_format = YCBCR_601;
// rgb24_yuv420_std(width, height, rgb, rgb_stride, y, u, v, y_stride, uv_stride, yuv_type);
rgb24_yuv420_std(src_frame->width, src_frame->height, src_frame->data[0],
                 src_frame->linesize[0],
                 dst_frame->data[0], dst_frame->data[1], dst_frame->data[2],
                 dst_frame->linesize[0], dst_frame->linesize[1], YCBCR_601);

can we make this function call (and other same function ) is easy ? just like ffmpeg AVFrame::linesize struct, so maybe we can call this function like this:

rgb24_yuv420_std(src_frame->width, src_frame->height,
                 src_frame->data, src_frame->linesize,
                 dst_frame->data, dst_frame->linesize,
                 YCBCR_601);
descampsa commented 7 years ago

hmm, yeah, good idea, thanks! That might make the function slightly harder to call outside of the ffmpeg context, since you will have to create the pointer/linesize arrays, but that will probably be more readable like that, there are definitely too many arguments to these functions.

LuoZijun commented 7 years ago

Oh, my mean is like that struct , alloc this struct data by ffmpeg or your self, that't not a problem.


// rgb24_yuv420_std(width, height, rgb, rgb_stride, y, u, v, y_stride, uv_stride, yuv_type);

int width = 1440;
int height=900;
uint8_t rgb_pixels    = [[u8; width*height], 0x00, 0x00, 0x00];
uint8_t rgb_linesize = [width*3, 0x00, 0x00, 0x00];
uint8_t yuv_pixels    = [ *[Y data], *[U data], *[V data] ];
uint8_t yuv_linesize = [width*3, 0x00, 0x00, 0x00];

rgb24_yuv420_std(width, height, rgb_pixels, rgb_linesize,
                 yuv_pixels[0], yuv_pixels[1], yuv_pixels[2],
                 yuv_linesize[0], yuv_linesize[1], YCBCR_601);

at last, this not an code problem, just one suggestion :)