libavformat API usage: use avformat_close_input() instead of av_close_input_file()

This commit is contained in:
Anton Khirnov 2014-01-16 15:40:37 +01:00 committed by Sergey Sharybin
parent 414e40c353
commit f99e581ae1
5 changed files with 31 additions and 22 deletions

@ -388,4 +388,13 @@ int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *pkt,
#endif
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53, 17, 0)
FFMPEG_INLINE
void avformat_close_input(AVFormatContext **ctx)
{
av_close_input_file(*ctx);
*ctx = NULL;
}
#endif
#endif

@ -486,7 +486,7 @@ static int startffmpeg(struct anim *anim)
}
if (avformat_find_stream_info(pFormatCtx, NULL) < 0) {
av_close_input_file(pFormatCtx);
avformat_close_input(&pFormatCtx);
return -1;
}
@ -507,7 +507,7 @@ static int startffmpeg(struct anim *anim)
}
if (videoStream == -1) {
av_close_input_file(pFormatCtx);
avformat_close_input(&pFormatCtx);
return -1;
}
@ -516,14 +516,14 @@ static int startffmpeg(struct anim *anim)
/* Find the decoder for the video stream */
pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
if (pCodec == NULL) {
av_close_input_file(pFormatCtx);
avformat_close_input(&pFormatCtx);
return -1;
}
pCodecCtx->workaround_bugs = 1;
if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0) {
av_close_input_file(pFormatCtx);
avformat_close_input(&pFormatCtx);
return -1;
}
@ -575,7 +575,7 @@ static int startffmpeg(struct anim *anim)
fprintf(stderr,
"ffmpeg has changed alloc scheme ... ARGHHH!\n");
avcodec_close(anim->pCodecCtx);
av_close_input_file(anim->pFormatCtx);
avformat_close_input(&anim->pFormatCtx);
av_free(anim->pFrameRGB);
av_free(anim->pFrameDeinterlaced);
av_free(anim->pFrame);
@ -616,7 +616,7 @@ static int startffmpeg(struct anim *anim)
fprintf(stderr,
"Can't transform color space??? Bailing out...\n");
avcodec_close(anim->pCodecCtx);
av_close_input_file(anim->pFormatCtx);
avformat_close_input(&anim->pFormatCtx);
av_free(anim->pFrameRGB);
av_free(anim->pFrameDeinterlaced);
av_free(anim->pFrame);
@ -1142,7 +1142,7 @@ static void free_anim_ffmpeg(struct anim *anim)
if (anim->pCodecCtx) {
avcodec_close(anim->pCodecCtx);
av_close_input_file(anim->pFormatCtx);
avformat_close_input(&anim->pFormatCtx);
av_free(anim->pFrameRGB);
av_free(anim->pFrame);

@ -747,7 +747,7 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, IMB_Tim
}
if (avformat_find_stream_info(context->iFormatCtx, NULL) < 0) {
av_close_input_file(context->iFormatCtx);
avformat_close_input(&context->iFormatCtx);
MEM_freeN(context);
return NULL;
}
@ -767,7 +767,7 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, IMB_Tim
}
if (context->videoStream == -1) {
av_close_input_file(context->iFormatCtx);
avformat_close_input(&context->iFormatCtx);
MEM_freeN(context);
return NULL;
}
@ -778,7 +778,7 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, IMB_Tim
context->iCodec = avcodec_find_decoder(context->iCodecCtx->codec_id);
if (context->iCodec == NULL) {
av_close_input_file(context->iFormatCtx);
avformat_close_input(&context->iFormatCtx);
MEM_freeN(context);
return NULL;
}
@ -786,7 +786,7 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, IMB_Tim
context->iCodecCtx->workaround_bugs = 1;
if (avcodec_open2(context->iCodecCtx, context->iCodec, NULL) < 0) {
av_close_input_file(context->iFormatCtx);
avformat_close_input(&context->iFormatCtx);
MEM_freeN(context);
return NULL;
}

@ -353,7 +353,7 @@ static int isffmpeg(const char *filename)
if (avformat_find_stream_info(pFormatCtx, NULL) < 0) {
if (UTIL_DEBUG) fprintf(stderr, "isffmpeg: avformat_find_stream_info failed\n");
av_close_input_file(pFormatCtx);
avformat_close_input(&pFormatCtx);
return 0;
}
@ -372,7 +372,7 @@ static int isffmpeg(const char *filename)
}
if (videoStream == -1) {
av_close_input_file(pFormatCtx);
avformat_close_input(&pFormatCtx);
return 0;
}
@ -381,17 +381,17 @@ static int isffmpeg(const char *filename)
/* Find the decoder for the video stream */
pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
if (pCodec == NULL) {
av_close_input_file(pFormatCtx);
avformat_close_input(&pFormatCtx);
return 0;
}
if (avcodec_open2(pCodecCtx, pCodec, NULL) < 0) {
av_close_input_file(pFormatCtx);
avformat_close_input(&pFormatCtx);
return 0;
}
avcodec_close(pCodecCtx);
av_close_input_file(pFormatCtx);
avformat_close_input(&pFormatCtx);
return 1;
}

@ -99,7 +99,7 @@ bool VideoFFmpeg::release()
}
if (m_formatCtx)
{
av_close_input_file(m_formatCtx);
avformat_close_input(&m_formatCtx);
m_formatCtx = NULL;
}
if (m_frame)
@ -176,7 +176,7 @@ int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AV
if (avformat_find_stream_info(formatCtx, NULL) < 0)
{
av_close_input_file(formatCtx);
avformat_close_input(&formatCtx);
return -1;
}
@ -195,7 +195,7 @@ int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AV
if (videoStream==-1)
{
av_close_input_file(formatCtx);
avformat_close_input(&formatCtx);
return -1;
}
@ -205,13 +205,13 @@ int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AV
codec=avcodec_find_decoder(codecCtx->codec_id);
if (codec==NULL)
{
av_close_input_file(formatCtx);
avformat_close_input(&formatCtx);
return -1;
}
codecCtx->workaround_bugs = 1;
if (avcodec_open2(codecCtx, codec, NULL) < 0)
{
av_close_input_file(formatCtx);
avformat_close_input(&formatCtx);
return -1;
}
@ -278,7 +278,7 @@ int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AV
if (!m_imgConvertCtx) {
avcodec_close(m_codecCtx);
m_codecCtx = NULL;
av_close_input_file(m_formatCtx);
avformat_close_input(&m_formatCtx);
m_formatCtx = NULL;
av_free(m_frame);
m_frame = NULL;