Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not an issue #15

Closed
ridams opened this issue Jul 10, 2019 · 3 comments
Closed

Not an issue #15

ridams opened this issue Jul 10, 2019 · 3 comments

Comments

@ridams
Copy link

ridams commented Jul 10, 2019

How should we convert an AVFrame (ffmpeg decoding result in RGB format) to sod_img ?

@symisc
Copy link
Owner

symisc commented Jul 10, 2019

You should probably create an empty image via sod_make_image() and fill each RGB pixel via sod_img_set_pixel() as follows:

sod_img img = sod_make_image(640, 580, 3/* RGB*/);
for(int i = 0; i < img.w ; i++){
for(int j = 0; j < img.h; j++){
sod_img_set_pixel(img, i, j, 0 /*RED*/, val);
sod_img_set_pixel(img, i, j, 1 /*GREEN*/, val);
sod_img_set_pixel(img, i, j, 2 /*BLUE*/, val);
}
}

@ridams
Copy link
Author

ridams commented Jul 10, 2019

Thanks for reply, It should work but I tried this way :
av_image_copy_to_buffer(buf, size,(const uint8_t * const *)pFrame->data,
(const int *)pFrame->linesize,pFrame->format,width,height, 1);

then sod_img img=sod_img_load_from_mem((const unsigned char*)buf,size,1);

img.data is NULL
buf here is a raw image so does sod_img_load_from_mem accept a raw data without a header ?
cause the 1st method is slow

@symisc
Copy link
Owner

symisc commented Jul 11, 2019

sod_img_load_from_mem() require an image header such as PNG, JPEG, BMP, PPM, etc. to be present in order to decode the image into raw pixels. If you already have your raw pixels decoded, you should use the solution above which is quite fast for most scenarios.

@symisc symisc closed this as completed Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants