[Ffmpeg-devel] RE: Lowres option problem
Roberta Weber
beta_n
Fri Sep 22 20:28:13 CEST 2006
Hi!
I tryed to set CODEC_FLAG_EMU_EDGE in AVCodecContext->flags,
but the lowres = 3 still causes segmentation fault error.
When I used lowres = 1, I didn't have problem. I used the
following code. Any suggestion, please ?
int
main (int argc, char *argv[])
{
AVFormatContext *pFormatCtx;
int i, videoStream;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
AVFrame *pFrame;
int numBytes;
uint8_t *buffer;
av_register_all ();
if (av_open_input_file (&pFormatCtx, argv[1], NULL, 0, NULL) != 0)
return -1;
if (av_find_stream_info (pFormatCtx) < 0)
return -1;
dump_format (pFormatCtx, 0, argv[1], 0);
videoStream = -1;
for (i = 0; i < pFormatCtx->nb_streams; i++)
if ((pFormatCtx->streams[i]->codec)->codec_type == CODEC_TYPE_VIDEO)
{
videoStream = i;
break;
}
if (videoStream == -1)
return -1;
pCodecCtx = pFormatCtx->streams[videoStream]->codec;
pCodecCtx->flags = CODEC_FLAG_EMU_EDGE;
pCodecCtx->lowres = 3;
pCodec = avcodec_find_decoder (pCodecCtx->codec_id);
if (pCodec == NULL)
return -1;
if (pCodec->capabilities & CODEC_CAP_TRUNCATED)
pCodecCtx->flags |= CODEC_FLAG_TRUNCATED;
if (avcodec_open (pCodecCtx, pCodec) < 0)
return -1;
pFrame = avcodec_alloc_frame ();
numBytes =
avpicture_get_size (PIX_FMT_RGB24, pCodecCtx->width, pCodecCtx->height);
buffer = new uint8_t[numBytes];
while (GetNextFrame (pFormatCtx, pCodecCtx, videoStream, pFrame))
{ //...
}
delete[]buffer;
av_free (pFrame);
avcodec_close (pCodecCtx);
av_close_input_file (pFormatCtx);
return 0;
}
Thanks,
Roberta.
> -----Original Message-----
> From: ffmpeg-devel-bounces at mplayerhq.hu
> [mailto:ffmpeg-devel-bounces at mplayerhq.hu] On Behalf Of Roberta Weber
> Sent: Friday, September 22, 2006 3:16
> To: ffmpeg-devel at mplayerhq.hu
> Subject: [Ffmpeg-devel] Lowres option problem
>
> Hi,
>
> I used lowres = 3 in my code and this option causes
> segmentation fault in the first GetNextFrame:
>
>Did you set CODEC_FLAG_EMU_EDGE in AVCodecContext->flags? It is
>necessary, although I do not know what it means exactly or why it is
>needed. Anybody knows?
>
>If you are using libavcodec alone (i.e. without libavformat) be sure to
>call avcodec_init() before calling avcodec_register_all() (with
>libavformat they are both called from av_register_all()).
>
>Best,
>
>Diego
>
>
>Diego Santa Cruz, PhD
>GE Security
>Engineered Systems EMEA
>Research Scientist
>
>T +41 21 695 0019
>F +41 21 695 0001
>E diego.santacruz at ge.com
>www.gesecurity.net
>
>Victoria House
>Route de la Pierre, 22
>1024 Ecublens
>Switzerland
>VisioWave sarl
---------------------------------
O Yahoo! est? de cara nova. Venha conferir!
More information about the ffmpeg-devel
mailing list