Very informative : I didn't know AVPicture had a bad rep.

I'll check it out.

Thanks.


On Sep 13, 2013, at 12:47, wm4 <[email protected]> wrote:

> On Thu, 12 Sep 2013 14:46:31 +0200
> Fulbert Boussaton <[email protected]> wrote:
> 
>> AVFormatContext*     Ctx;
>> avformat_open_input(&Ctx, <...>, NULL, &Options);
>> avformat_find_stream_info(Ctx, NULL);
>> AVCodecContext* VCodecCtx = Ctx->streams[0]->codec;
>> AVCodec* TargetVideoCodec = avcodec_find_decoder(VCodecCtx->codec_id);
>> avcodec_open2(VCodecCtx, TargetVideoCodec, NULL);
>> AVFrame* TargetFrame = avcodec_alloc_frame();
>> AVFrame* TargetFrameRGB = avcodec_alloc_frame();
>> int FrameSizeInBytes = avpicture_get_size(PIX_FMT_RGB24, VCodecCtx->width, 
>> VCodecCtx->height);
>> uint8_t* FrameBuffer = (uint8_t*) av_malloc(FrameSizeInBytes);
>> avpicture_fill((AVPicture*) TargetFrameRGB, FrameBuffer, PIX_FMT_RGB24, 
>> VCodecCtx->width, VCodecCtx->height);
>> struct SwsContext* ScaleCtx = sws_getContext(VCodecCtx->width, 
>> VCodecCtx->height, VCodecCtx->pix_fmt, VCodecCtx->width, VCodecCtx->height, 
>> PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL);
>> 
>> And here are the functions I call to release all the previous structures :
>> 
>> sws_freeContext(ScaleCtx);
>> avpicture_free((AVPicture*)TargetFrameRGB);
>> av_free(FrameBuffer);
>> avcodec_free_frame(&TargetFrame);
>> avcodec_free_frame(&TargetFrameRGB);
>> avcodec_close(VCodecCtx);
>> avformat_close_input(&Ctx);
> 
> This all looks very wrong. I'd just stick to the AVFrame API, and not
> touch AVPicture. In some cases, you cast AVFrame to AVPicture, which
> only works by coincidence. (I'm not sure if it's possibly supposed to
> work - as far as I'm concerned AVPicture is ridiculous. You can get
> everything done without using AVPicture at all.)
> 
> See libavutil/frame.h.
> _______________________________________________
> Libav-user mailing list
> [email protected]
> http://ffmpeg.org/mailman/listinfo/libav-user

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

Reply via email to