Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2019-09-19 12:59:33 +0300
committerSybren A. Stüvel <sybren@blender.org>2019-09-19 16:12:53 +0300
commit1e09dd094b0187ef7b7b202154bc810dc1479034 (patch)
tree6ba7a44c649a5a6ec64b172f14912c811eba4cb9 /source/blender/imbuf/intern/anim_movie.c
parent2f6a0647659de2cfa695b3f53bb401e80503ed40 (diff)
Cleanup: don't index the same array multiple times
There is now a clearer distinction between `video_stream` (the stream itself) and `video_stream_index` (its index), and no more repetition of accessing the same item of an array. This also makes the code a bit more readable in preparation for an upcoming functional change.
Diffstat (limited to 'source/blender/imbuf/intern/anim_movie.c')
-rw-r--r--source/blender/imbuf/intern/anim_movie.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index 52d8db95054..da7dcc54343 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -493,12 +493,13 @@ BLI_INLINE bool need_aligned_ffmpeg_buffer(struct anim *anim)
static int startffmpeg(struct anim *anim)
{
- int i, videoStream;
+ int i, video_stream_index;
AVCodec *pCodec;
AVFormatContext *pFormatCtx = NULL;
AVCodecContext *pCodecCtx;
AVRational frame_rate;
+ AVStream *video_stream;
int frs_num;
double frs_den;
int streamcount;
@@ -528,7 +529,7 @@ static int startffmpeg(struct anim *anim)
av_dump_format(pFormatCtx, 0, anim->name, 0);
/* Find the video stream */
- videoStream = -1;
+ video_stream_index = -1;
for (i = 0; i < pFormatCtx->nb_streams; i++) {
if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
@@ -536,17 +537,18 @@ static int startffmpeg(struct anim *anim)
streamcount--;
continue;
}
- videoStream = i;
+ video_stream_index = i;
break;
}
}
- if (videoStream == -1) {
+ if (video_stream_index == -1) {
avformat_close_input(&pFormatCtx);
return -1;
}
- pCodecCtx = pFormatCtx->streams[videoStream]->codec;
+ video_stream = pFormatCtx->streams[video_stream_index];
+ pCodecCtx = video_stream->codec;
/* Find the decoder for the video stream */
pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
@@ -567,9 +569,9 @@ static int startffmpeg(struct anim *anim)
return -1;
}
- frame_rate = av_get_r_frame_rate_compat(pFormatCtx, pFormatCtx->streams[videoStream]);
- if (pFormatCtx->streams[videoStream]->nb_frames != 0) {
- anim->duration = pFormatCtx->streams[videoStream]->nb_frames;
+ frame_rate = av_get_r_frame_rate_compat(pFormatCtx, video_stream);
+ if (video_stream->nb_frames != 0) {
+ anim->duration = video_stream->nb_frames;
}
else {
anim->duration = (int)(pFormatCtx->duration * av_q2d(frame_rate) / AV_TIME_BASE + 0.5f);
@@ -596,7 +598,7 @@ static int startffmpeg(struct anim *anim)
anim->pFormatCtx = pFormatCtx;
anim->pCodecCtx = pCodecCtx;
anim->pCodec = pCodec;
- anim->videoStream = videoStream;
+ anim->videoStream = video_stream_index;
anim->interlacing = 0;
anim->orientation = 0;