[Libav-user] High-res JPEG2000 decoding memory problem
Никита Скиба
zaulan at gmail.com
Tue Mar 29 12:02:22 CEST 2016
Hello to all!
Recently I have faced a problem with JP2K decoding via
avcodec_decode_video2.
Source picture is 6144x4096 with rgb24 pixel format and I am trying to
decode it into RGB or YUV frame, but get error code -12 in
avcodec_decode_video2 return and error message:
[jpeg2000 @ 009651E0] Cannot allocate memory
- in the av_log callback.
When I am forcing decode to YUV by setting:
context->pix_fmt = AV_PIX_FMT_YUV420P;
- the problem repeating.
Also tried with:
context->thread_count = 200;
context->thread_type = FF_THREAD_SLICE;
- but nothing changes.
ffplay.exe and ffmpeg.exe works well. Also, I have got 8Gb RAM.
Could you, please help me with that problem?
Sources samples
// Frame allocation:
if (!m_frame)
{
m_frame.reset(av_frame_alloc(), [](AVFrame* f) { av_frame_free(&f); });
if ( !m_frame )
{
return 0;
}
}
// Main decompression call.
AVPacket pkt;
av_init_packet(&pkt);
pkt.data = data;
pkt.size = static_cast<int>(size);
// << WORKAROUND >> START
int ret = avcodec_decode_video2(pCodecCtx, pAVFrame, &getPic, &pkt);
if (ret < 0)
{
char buf[AV_ERROR_MAX_STRING_SIZE];
av_strerror(ret, buf, sizeof(buf));
av_log(pCodecCtx, AV_LOG_ERROR, "Error %s\n", av_make_error_string(buf,
AV_ERROR_MAX_STRING_SIZE, ret));
}
while (!getPic && (ret > 0)
(cID == AV_CODEC_ID_H264 ||
cID == AV_CODEC_ID_HEVC ||
cID == AV_CODEC_ID_MPEG4 ||
cID == AV_CODEC_ID_JPEG2000))
{
// attempt to get frame from queue
int ret = avcodec_decode_video2(pCodecCtx, pAVFrame, &getPic, &pkt);
av_log(pCodecCtx, AV_LOG_ERROR, "Another attempt to decode.");
if (ret < 0)
{
char buf[AV_ERROR_MAX_STRING_SIZE];
av_strerror(ret, buf, sizeof(buf));
av_log(pCodecCtx, AV_LOG_ERROR, "Error %s\n", av_make_error_string(buf,
AV_ERROR_MAX_STRING_SIZE, ret));
}
}
JP2K sample frame located here
https://yadi.sk/d/GyRd2t_fqZQ8f
Tell me if I could help with something else.
Thanks in advance!
Nikita
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160329/e5975354/attachment.html>
More information about the Libav-user
mailing list