Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#1037 closed defect (needs_more_info)

avcodec_alloc_context3 and avcodec_alloc_frame causes app to exit on Android 3.2

Reported by: pawg Owned by:
Priority: important Component: avcodec
Version: 0.10 Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I am trying to decode H264 video on Samsung Galaxy Tab 10.1 using Android 3.2, kernel version 2.6.36.3. I am using FFmpeg software decoder. When I try to allocate context or frame using avcodec_alloc_context3 or avcodec_alloc_frame, my app freezes and after about 5 seconds exits without any error or log captured on Logcat.

Code which fails:

AVCodec* myCodec;
AVCodecContext* myContext;
AVFrame* myFrame;

myCodec = avcodec_find_decoder(CODEC_ID_H264);
myContext = avcodec_alloc_context3(myCodec);
myFrame = avcodec_alloc_frame();

Attachments (1)

output.txt (6.7 KB ) - added by pawg 12 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 by Carl Eugen Hoyos, 12 years ago

The code you provide does not look as if it would compile, and please add backtrace if FFmpeg really freezes.

by pawg, 12 years ago

Attachment: output.txt added

comment:2 by pawg, 12 years ago

My code compiles fine using latest android ndk. Not sure what you mean by backtrace, but I added output from android system log. I may add that on android 2.x there are no problems with my app.

in reply to:  2 comment:3 by Carl Eugen Hoyos, 12 years ago

Replying to pawg:

My code compiles fine using latest android ndk.

Which code? You only posted a small part that will not compile.

Not sure what you mean by backtrace

Please see http://ffmpeg.org/bugreports.html

comment:4 by pawg, 12 years ago

My codec initialization function is the following:

/*
AVCodec* myCodec;
AVCodecContext* myContext;
AVFrame* myFrame;
**These variables are defined at class level - put here only for information*/

init(){

avcodec_init();
avcodec_register_all();
myCodec = NULL;

myCodec = avcodec_find_decoder(CODEC_ID_H264);
if (!myCodec) {

log.error("codec CODEC_ID_H264 not found");
return;

}

/*this function causes the application to exit, the same goes for avcodec_alloc_frame if I comment this line*/
myContext = avcodec_alloc_context3(myCodec);

if (myCodec->capabilities & CODEC_CAP_TRUNCATED)

myContext->flags |= CODEC_FLAG_TRUNCATED;

myContext->flags2 |= (CODEC_FLAG2_CHUNKS | CODEC_FLAG_TRUNCATED);

if (avcodec_open(myContext, myCodec) < 0) {

log.error("Could not open codec");
return;

}
myFrame = avcodec_alloc_frame();
log.information("initialized decoder");

}

Last edited 12 years ago by pawg (previous) (diff)

comment:5 by Carl Eugen Hoyos, 12 years ago

I still believe that a C (or C++) program that has "AVCodec* myCodec;" as first line will not compile. Don't you think so?

Please consider providing gdb output, it will show where the problem you see occurs.

comment:6 by pawg, 12 years ago

I made an update to my source code - the variables were only defined as reference and the function is part of a bigger class. The provided output.txt from dump gives info that a possible problem is with av_opt_set_defaults2 function.

comment:7 by Michael Niedermayer, 12 years ago

output.txt says SIGILL which very likely means you used the wrong compiler options to compile some of the code.

comment:8 by Carl Eugen Hoyos, 12 years ago

Resolution: needs_more_info
Status: newclosed

Please reopen if you can at least provide gdb output, see http://ffmpeg.org/bugreports.html

comment:9 by pawg, 12 years ago

Ticket can be left as closed with "no issue" status - ndk compiler needed to have additional flags for Tegra 2 cpu

Note: See TracTickets for help on using tickets.