[Libav-user] Swscale bad dst image pointers

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Libav-user] Swscale bad dst image pointers

Dorian Green
Hello, can someone enlighten me as to why this gives error -22 "invalid argument" which results in bad dst image pointers?

------------------------------------------------------

AVFrame * frame = av_frame_alloc();
If (!frame){

std::cout << "frame failed to initialize" << std::endl;

}

Int size = av_image_get_buffer_size(pCodecContext->pix_fmt,pCodecContext->width,pCodecContext->height,0);

auto picture_src = (uint8_t*)av_malloc(sizeof(uint8_t) * size);

av_image_fill_arrays(frame->data,frame->linesize,picture_src,pCodecContext->pix_fmt,pCodecContext->width,pCodecContext->height,0);

img_convert_ctx = sws_getContext(pCodecContext->width,pCodecContext->height,pCodecContext->pix_fmt,pCodecContext->width,pCodecContext->height,AV_PIX_FMT_RGB24, SWS_BICUBIC, nullptr, nullptr, nullptr);

sws_scale(img_convert_ctx, frame->data,frame->linesize,0,pCodecContext->height,frame->data,frame->linesize);

----------------------------------------------------
What is it that i'm not understanding?



_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Swscale bad dst image pointers

Gonzalo Garramuño



On 20/11/19 03:19, Dorian Green wrote:
Hello, can someone enlighten me as to why this gives error -22 "invalid argument" which results in bad dst image pointers?

------------------------------------------------------

AVFrame * frame = av_frame_alloc();
If (!frame){

std::cout << "frame failed to initialize" << std::endl;

}

Int size = av_image_get_buffer_size(pCodecContext->pix_fmt,pCodecContext->width,pCodecContext->height,0);

auto picture_src = (uint8_t*)av_malloc(sizeof(uint8_t) * size);

av_image_fill_arrays(frame->data,frame->linesize,picture_src,pCodecContext->pix_fmt,pCodecContext->width,pCodecContext->height,0);

You might want to set the alignment to 1, just in case.

sws_scale(img_convert_ctx, frame->data,frame->linesize,0,pCodecContext->height,frame->data,frame->linesize);

----------------------------------------------------
What is it that i'm not understanding?

You are using sws_scale to decode to the same pointers it is reading from.  That's more likely your problem.


_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Swscale bad dst image pointers

Dorian Green
Set alignment to 1. I also made a separate avframe named gl_frame and renamed the first to av_frame, change swscale to use "av_frame" and "gl_frame" as dst but still received "bad dst image pointers" any other ideas? 

On Sun, Nov 24, 2019, 5:53 PM gga <[hidden email]> wrote:



On 20/11/19 03:19, Dorian Green wrote:
Hello, can someone enlighten me as to why this gives error -22 "invalid argument" which results in bad dst image pointers?

------------------------------------------------------

AVFrame * frame = av_frame_alloc();
If (!frame){

std::cout << "frame failed to initialize" << std::endl;

}

Int size = av_image_get_buffer_size(pCodecContext->pix_fmt,pCodecContext->width,pCodecContext->height,0);

auto picture_src = (uint8_t*)av_malloc(sizeof(uint8_t) * size);

av_image_fill_arrays(frame->data,frame->linesize,picture_src,pCodecContext->pix_fmt,pCodecContext->width,pCodecContext->height,0);

You might want to set the alignment to 1, just in case.

sws_scale(img_convert_ctx, frame->data,frame->linesize,0,pCodecContext->height,frame->data,frame->linesize);

----------------------------------------------------
What is it that i'm not understanding?

You are using sws_scale to decode to the same pointers it is reading from.  That's more likely your problem.

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Swscale bad dst image pointers

Gonzalo Garramuño


El 25/11/19 a las 02:01, Dorian Green escribió:
> Set alignment to 1. I also made a separate avframe named gl_frame and
> renamed the first to av_frame, change swscale to use "av_frame" and
> "gl_frame" as dst but still received "bad dst image pointers" any
> other ideas?
>
I don't have any more ideas, but can you show us the new code? Someone
else might spot the problem.
_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Swscale bad dst image pointers

Dorian Green
Sure! I posted the entire code in hopes someone sees something else wrong. I receive a blank opengl with no output and the same bad dst image pointers. https://pastebin.com/u1Gvr209

On Mon, Nov 25, 2019 at 10:39 AM Gonzalo Garramuño <[hidden email]> wrote:


El 25/11/19 a las 02:01, Dorian Green escribió:
> Set alignment to 1. I also made a separate avframe named gl_frame and
> renamed the first to av_frame, change swscale to use "av_frame" and
> "gl_frame" as dst but still received "bad dst image pointers" any
> other ideas?
>
I don't have any more ideas, but can you show us the new code? Someone
else might spot the problem.
_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: [NEWSLETTER] Re: Swscale bad dst image pointers

Mihai Chindea

try setting the desired pixel format before calling av_frame_get_buffer()



gl_frame->format=AV_PIX_FMT_RGB24;

av_frame_get_buffer(gl_frame, 1);




From: Libav-user <[hidden email]> on behalf of Dorian Green <[hidden email]>
Sent: Tuesday, November 26, 2019 9:36 AM
To: This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter.
Subject: [NEWSLETTER] Re: [Libav-user] Swscale bad dst image pointers
 
Sure! I posted the entire code in hopes someone sees something else wrong. I receive a blank opengl with no output and the same bad dst image pointers. https://pastebin.com/u1Gvr209

On Mon, Nov 25, 2019 at 10:39 AM Gonzalo Garramuño <[hidden email]> wrote:


El 25/11/19 a las 02:01, Dorian Green escribió:
> Set alignment to 1. I also made a separate avframe named gl_frame and
> renamed the first to av_frame, change swscale to use "av_frame" and
> "gl_frame" as dst but still received "bad dst image pointers" any
> other ideas?
>
I don't have any more ideas, but can you show us the new code? Someone
else might spot the problem.
_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Swscale bad dst image pointers

Gonzalo Garramuño
In reply to this post by Dorian Green
Besides what I pointed to you privately, you seem to be missing the
allocation and usage of the pFrame.  You seem to have it mixed with the
av_frame variable.


On 26/11/19 04:36, Dorian Green wrote:
> Sure! I posted the entire code in hopes someone sees something else
> wrong. I receive a blank opengl with no output and the same bad dst
> image pointers. https://pastebin.com/u1Gvr209
>

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Swscale bad dst image pointers

Dorian Green
Both of you were correct I set the format and that made the bad day image pointers error go away. Did not read the api clearly as it requires width, height AND pix_fmt. I also fixed the Pframr issue. Now im still having a black screen :(. I will open a new message for help with that. Thank you all for your help.

On Tue, Nov 26, 2019, 6:15 AM gga <[hidden email]> wrote:
Besides what I pointed to you privately, you seem to be missing the
allocation and usage of the pFrame.  You seem to have it mixed with the
av_frame variable.


On 26/11/19 04:36, Dorian Green wrote:
> Sure! I posted the entire code in hopes someone sees something else
> wrong. I receive a blank opengl with no output and the same bad dst
> image pointers. https://pastebin.com/u1Gvr209
>

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

_______________________________________________
Libav-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".