안녕하세요 회원여러분.

ffmpeg을 이용해서 영상처리를 하고 있습니다. 

코덱초기화 후에 
avcodec_find_decoder
avcodec_alloc_context2
avcodec_open,
avcodec_alloc_frame
...

디코딩을 위한 사전 작업들은 정상적으로 잘 되었다고 생각합니다. 컴파일 시 특별한 문제도 없고, 리턴되는 값들도 정상적입니다.
그런데 avcodec_decode_video2에서 디코딩이 되지를 않습니다. -1이 리턴되어버리네요.

함수 원형은 아래와 같습니다.
int avcodec_decode_video2(AVCodecContext * 
avctx
,
AVFrame * picture,
int * got_picture_ptr,
AVPacket * avpkt 

)

AVCodecContext도 정상적으로 할당했고, 필요한 필드셋팅도 마쳤습니다.
AVFrame도 avcodec_alloc_frame으로 할당했고,
AVPacket의 data, size 값도 정상적으로 넣었습니다.

아이폰에서 돌아가는 소스인데, 아이폰에서는 정상적으로 돌아갑니다. 이 소스를 JNI로 컴파일해서 사용하려고 하는데
디코딩 실패나는 이유를 모르겠습니다.ㅠ ffmpeg은 android용으로 컴파일 하였습니다.
도움이 절실하네요 ...

=====================================================
다음은 소스 일부입니다.

/* Decoder */
codec_id = CODEC_ID_H264;
codec = avcodec_find_decoder(codec_id);

/* AVCodecContext */
avCtx = avcodec_alloc_context2(AVMEDIA_TYPE_VIDEO);
if(avCtx) {
avCtx->codec_id = codec_id;
avCtx->extradata_size = 256;
avCtx->extradata = (uint8_t*)malloc(v_ctx->extradata_size);

if(avCtx->extradata)
memset(avCtx->extradata, 0, avCtx->extradata_size);

avCtx->pix_fmt = PIX_FMT_YUV420P;
avCtx->width = width;
avCtx->height = height;
max_width = m_width;
max_height = m_height;
layout = _layout;

video_buffer = (uint8_t *)malloc(max_width * max_height * 2);
}

/* Codec open */
avcodec_open(avCtx, codec);

/* AVFrame */
frm_rgb = avcodec_alloc_frame();
frm_yuv = avcodec_alloc_frame();

// pps_info 값은 라인이 길어서 생략 
memcpy(avCtx->extradata, pps_info, size);

avpicture_fill((AVPicture *)frm_rgb, video_buffer, PIX_FMT_RGB565, max_width / layout, max_height / layout);

/* Decoding */
AVPacket avp;
av_init_packet(&avp);

avp.data = (uint8_t*)packet;
avp.size = size;

avcodec_decode_video2(avCtx, frm_yuv, &got_pic, &avp);
// 디코딩을 하게 되면 리턴값은 -1이 리턴되며,
// got_pic 값은 0이 됩니다.
=====================================================