From 28b17ef0e6a82361f7061b9e074609dde9a76254 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Jan 2021 14:31:30 +1100 Subject: Cleanup: replace 'long long' with int64_t in imbuf indexer --- source/blender/imbuf/intern/IMB_indexer.h | 25 +++++------ source/blender/imbuf/intern/anim_movie.c | 73 +++++++++++++++---------------- source/blender/imbuf/intern/indexer.c | 59 ++++++++++++------------- 3 files changed, 74 insertions(+), 83 deletions(-) (limited to 'source/blender/imbuf') diff --git a/source/blender/imbuf/intern/IMB_indexer.h b/source/blender/imbuf/intern/IMB_indexer.h index 07c47965262..363ad45e0e6 100644 --- a/source/blender/imbuf/intern/IMB_indexer.h +++ b/source/blender/imbuf/intern/IMB_indexer.h @@ -48,9 +48,9 @@ typedef struct anim_index_entry { int frameno; - unsigned long long seek_pos; - unsigned long long seek_pos_dts; - unsigned long long pts; + uint64_t seek_pos; + uint64_t seek_pos_dts; + uint64_t pts; } anim_index_entry; struct anim_index { @@ -77,28 +77,25 @@ typedef struct anim_index_builder { } anim_index_builder; anim_index_builder *IMB_index_builder_create(const char *name); -void IMB_index_builder_add_entry(anim_index_builder *fp, - int frameno, - unsigned long long seek_pos, - unsigned long long seek_pos_dts, - unsigned long long pts); +void IMB_index_builder_add_entry( + anim_index_builder *fp, int frameno, uint64_t seek_pos, uint64_t seek_pos_dts, uint64_t pts); void IMB_index_builder_proc_frame(anim_index_builder *fp, unsigned char *buffer, int data_size, int frameno, - unsigned long long seek_pos, - unsigned long long seek_pos_dts, - unsigned long long pts); + uint64_t seek_pos, + uint64_t seek_pos_dts, + uint64_t pts); void IMB_index_builder_finish(anim_index_builder *fp, int rollback); struct anim_index *IMB_indexer_open(const char *name); -unsigned long long IMB_indexer_get_seek_pos(struct anim_index *idx, int frame_index); -unsigned long long IMB_indexer_get_seek_pos_dts(struct anim_index *idx, int frame_index); +uint64_t IMB_indexer_get_seek_pos(struct anim_index *idx, int frame_index); +uint64_t IMB_indexer_get_seek_pos_dts(struct anim_index *idx, int frame_index); int IMB_indexer_get_frame_index(struct anim_index *idx, int frameno); -unsigned long long IMB_indexer_get_pts(struct anim_index *idx, int frame_index); +uint64_t IMB_indexer_get_pts(struct anim_index *idx, int frame_index); int IMB_indexer_get_duration(struct anim_index *idx); int IMB_indexer_can_scan(struct anim_index *idx, int old_frame_index, int new_frame_index); diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 9b01ea0840f..c40e65b1c5c 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -892,13 +892,12 @@ static int ffmpeg_decode_video_frame(struct anim *anim) while ((rval = av_read_frame(anim->pFormatCtx, &anim->next_packet)) >= 0) { av_log(anim->pFormatCtx, AV_LOG_DEBUG, - "%sREAD: strID=%d (VID: %d) dts=%lld pts=%lld " - "%s\n", + "%sREAD: strID=%d (VID: %d) dts=%" PRId64 " pts=%" PRId64 " %s\n", (anim->next_packet.stream_index == anim->videoStream) ? "->" : " ", anim->next_packet.stream_index, anim->videoStream, - (anim->next_packet.dts == AV_NOPTS_VALUE) ? -1 : (long long int)anim->next_packet.dts, - (anim->next_packet.pts == AV_NOPTS_VALUE) ? -1 : (long long int)anim->next_packet.pts, + (anim->next_packet.dts == AV_NOPTS_VALUE) ? -1 : (int64_t)anim->next_packet.dts, + (anim->next_packet.pts == AV_NOPTS_VALUE) ? -1 : (int64_t)anim->next_packet.pts, (anim->next_packet.flags & AV_PKT_FLAG_KEY) ? " KEY" : ""); if (anim->next_packet.stream_index == anim->videoStream) { anim->pFrameComplete = 0; @@ -911,12 +910,10 @@ static int ffmpeg_decode_video_frame(struct anim *anim) av_log(anim->pFormatCtx, AV_LOG_DEBUG, - " FRAME DONE: next_pts=%lld " - "pkt_pts=%lld, guessed_pts=%lld\n", - (anim->pFrame->pts == AV_NOPTS_VALUE) ? -1 : (long long int)anim->pFrame->pts, - (anim->pFrame->pkt_pts == AV_NOPTS_VALUE) ? -1 : - (long long int)anim->pFrame->pkt_pts, - (long long int)anim->next_pts); + " FRAME DONE: next_pts=%" PRId64 " pkt_pts=%" PRId64 ", guessed_pts=%" PRId64 "\n", + (anim->pFrame->pts == AV_NOPTS_VALUE) ? -1 : (int64_t)anim->pFrame->pts, + (anim->pFrame->pkt_pts == AV_NOPTS_VALUE) ? -1 : (int64_t)anim->pFrame->pkt_pts, + (int64_t)anim->next_pts); break; } } @@ -946,11 +943,11 @@ static int ffmpeg_decode_video_frame(struct anim *anim) av_log(anim->pFormatCtx, AV_LOG_DEBUG, - " FRAME DONE (after EOF): next_pts=%lld " - "pkt_pts=%lld, guessed_pts=%lld\n", - (anim->pFrame->pts == AV_NOPTS_VALUE) ? -1 : (long long int)anim->pFrame->pts, - (anim->pFrame->pkt_pts == AV_NOPTS_VALUE) ? -1 : (long long int)anim->pFrame->pkt_pts, - (long long int)anim->next_pts); + " FRAME DONE (after EOF): next_pts=%" PRId64 " pkt_pts=%" PRId64 + ", guessed_pts=%" PRId64 "\n", + (anim->pFrame->pts == AV_NOPTS_VALUE) ? -1 : (int64_t)anim->pFrame->pts, + (anim->pFrame->pkt_pts == AV_NOPTS_VALUE) ? -1 : (int64_t)anim->pFrame->pkt_pts, + (int64_t)anim->next_pts); rval = 0; } } @@ -975,16 +972,16 @@ static void ffmpeg_decode_video_frame_scan(struct anim *anim, int64_t pts_to_sea av_log(anim->pFormatCtx, AV_LOG_DEBUG, - "SCAN start: considering pts=%lld in search of %lld\n", - (long long int)anim->next_pts, - (long long int)pts_to_search); + "SCAN start: considering pts=%" PRId64 " in search of %" PRId64 "\n", + (int64_t)anim->next_pts, + (int64_t)pts_to_search); while (count > 0 && anim->next_pts < pts_to_search) { av_log(anim->pFormatCtx, AV_LOG_DEBUG, - " WHILE: pts=%lld in search of %lld\n", - (long long int)anim->next_pts, - (long long int)pts_to_search); + " WHILE: pts=%" PRId64 " in search of %" PRId64 "\n", + (int64_t)anim->next_pts, + (int64_t)pts_to_search); if (!ffmpeg_decode_video_frame(anim)) { break; } @@ -994,9 +991,9 @@ static void ffmpeg_decode_video_frame_scan(struct anim *anim, int64_t pts_to_sea av_log(anim->pFormatCtx, AV_LOG_ERROR, "SCAN failed: completely lost in stream, " - "bailing out at PTS=%lld, searching for PTS=%lld\n", - (long long int)anim->next_pts, - (long long int)pts_to_search); + "bailing out at PTS=%" PRId64 ", searching for PTS=%" PRId64 "\n", + (int64_t)anim->next_pts, + (int64_t)pts_to_search); } if (anim->next_pts == pts_to_search) { av_log(anim->pFormatCtx, AV_LOG_DEBUG, "SCAN HAPPY: we found our PTS!\n"); @@ -1091,9 +1088,9 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position, IMB_Timecode_Typ av_log(anim->pFormatCtx, AV_LOG_DEBUG, - "FETCH: looking for PTS=%lld " - "(pts_timebase=%g, frame_rate=%g, st_time=%lld)\n", - (long long int)pts_to_search, + "FETCH: looking for PTS=%" PRId64 " (pts_timebase=%g, frame_rate=%g, st_time=%" PRId64 + ")\n", + (int64_t)pts_to_search, pts_time_base, frame_rate, st_time); @@ -1101,9 +1098,9 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position, IMB_Timecode_Typ if (anim->last_frame && anim->last_pts <= pts_to_search && anim->next_pts > pts_to_search) { av_log(anim->pFormatCtx, AV_LOG_DEBUG, - "FETCH: frame repeat: last: %lld next: %lld\n", - (long long int)anim->last_pts, - (long long int)anim->next_pts); + "FETCH: frame repeat: last: %" PRId64 " next: %" PRId64 "\n", + (int64_t)anim->last_pts, + (int64_t)anim->next_pts); IMB_refImBuf(anim->last_frame); anim->curposition = position; return anim->last_frame; @@ -1128,13 +1125,13 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position, IMB_Timecode_Typ int ret; if (tc_index) { - unsigned long long dts; + uint64_t dts; pos = IMB_indexer_get_seek_pos(tc_index, new_frame_index); dts = IMB_indexer_get_seek_pos_dts(tc_index, new_frame_index); - av_log(anim->pFormatCtx, AV_LOG_DEBUG, "TC INDEX seek pos = %lld\n", pos); - av_log(anim->pFormatCtx, AV_LOG_DEBUG, "TC INDEX seek dts = %llu\n", dts); + av_log(anim->pFormatCtx, AV_LOG_DEBUG, "TC INDEX seek pos = %" PRId64 "\n", pos); + av_log(anim->pFormatCtx, AV_LOG_DEBUG, "TC INDEX seek dts = %" PRIu64 "\n", dts); if (ffmpeg_seek_by_byte(anim->pFormatCtx)) { av_log(anim->pFormatCtx, AV_LOG_DEBUG, "... using BYTE pos\n"); @@ -1152,7 +1149,7 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position, IMB_Timecode_Typ av_log(anim->pFormatCtx, AV_LOG_DEBUG, - "NO INDEX seek pos = %lld, st_time = %lld\n", + "NO INDEX seek pos = %" PRId64 ", st_time = %" PRId64 "\n", pos, (st_time != AV_NOPTS_VALUE) ? st_time : 0); @@ -1164,7 +1161,7 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position, IMB_Timecode_Typ pos += st_time; } - av_log(anim->pFormatCtx, AV_LOG_DEBUG, "NO INDEX final seek pos = %lld\n", pos); + av_log(anim->pFormatCtx, AV_LOG_DEBUG, "NO INDEX final seek pos = %" PRId64 "\n", pos); ret = av_seek_frame(anim->pFormatCtx, -1, pos, AVSEEK_FLAG_BACKWARD); } @@ -1173,11 +1170,11 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position, IMB_Timecode_Typ av_log(anim->pFormatCtx, AV_LOG_ERROR, "FETCH: " - "error while seeking to DTS = %lld " - "(frameno = %d, PTS = %lld): errcode = %d\n", + "error while seeking to DTS = %" PRId64 " (frameno = %d, PTS = %" PRId64 + "): errcode = %d\n", pos, position, - (long long int)pts_to_search, + (int64_t)pts_to_search, ret); } diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 09f37d733de..8233483706c 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -99,25 +99,22 @@ anim_index_builder *IMB_index_builder_create(const char *name) return rv; } -void IMB_index_builder_add_entry(anim_index_builder *fp, - int frameno, - unsigned long long seek_pos, - unsigned long long seek_pos_dts, - unsigned long long pts) +void IMB_index_builder_add_entry( + anim_index_builder *fp, int frameno, uint64_t seek_pos, uint64_t seek_pos_dts, uint64_t pts) { fwrite(&frameno, sizeof(int), 1, fp->fp); - fwrite(&seek_pos, sizeof(unsigned long long), 1, fp->fp); - fwrite(&seek_pos_dts, sizeof(unsigned long long), 1, fp->fp); - fwrite(&pts, sizeof(unsigned long long), 1, fp->fp); + fwrite(&seek_pos, sizeof(uint64_t), 1, fp->fp); + fwrite(&seek_pos_dts, sizeof(uint64_t), 1, fp->fp); + fwrite(&pts, sizeof(uint64_t), 1, fp->fp); } void IMB_index_builder_proc_frame(anim_index_builder *fp, - unsigned char *buffer, + uchar *buffer, int data_size, int frameno, - unsigned long long seek_pos, - unsigned long long seek_pos_dts, - unsigned long long pts) + uint64_t seek_pos, + uint64_t seek_pos_dts, + uint64_t pts) { if (fp->proc_frame) { anim_index_entry e; @@ -186,10 +183,10 @@ struct anim_index *IMB_indexer_open(const char *name) fseek(fp, 0, SEEK_END); - idx->num_entries = (ftell(fp) - 12) / (sizeof(int) + /* framepos */ - sizeof(unsigned long long) + /* seek_pos */ - sizeof(unsigned long long) + /* seek_pos_dts */ - sizeof(unsigned long long) /* pts */ + idx->num_entries = (ftell(fp) - 12) / (sizeof(int) + /* framepos */ + sizeof(uint64_t) + /* seek_pos */ + sizeof(uint64_t) + /* seek_pos_dts */ + sizeof(uint64_t) /* pts */ ); fseek(fp, 12, SEEK_SET); @@ -200,9 +197,9 @@ struct anim_index *IMB_indexer_open(const char *name) for (i = 0; i < idx->num_entries; i++) { size_t items_read = 0; items_read += fread(&idx->entries[i].frameno, sizeof(int), 1, fp); - items_read += fread(&idx->entries[i].seek_pos, sizeof(unsigned long long), 1, fp); - items_read += fread(&idx->entries[i].seek_pos_dts, sizeof(unsigned long long), 1, fp); - items_read += fread(&idx->entries[i].pts, sizeof(unsigned long long), 1, fp); + items_read += fread(&idx->entries[i].seek_pos, sizeof(uint64_t), 1, fp); + items_read += fread(&idx->entries[i].seek_pos_dts, sizeof(uint64_t), 1, fp); + items_read += fread(&idx->entries[i].pts, sizeof(uint64_t), 1, fp); if (items_read < 4) { perror("error reading animation index file"); @@ -227,7 +224,7 @@ struct anim_index *IMB_indexer_open(const char *name) return idx; } -unsigned long long IMB_indexer_get_seek_pos(struct anim_index *idx, int frame_index) +uint64_t IMB_indexer_get_seek_pos(struct anim_index *idx, int frame_index) { if (frame_index < 0) { frame_index = 0; @@ -238,7 +235,7 @@ unsigned long long IMB_indexer_get_seek_pos(struct anim_index *idx, int frame_in return idx->entries[frame_index].seek_pos; } -unsigned long long IMB_indexer_get_seek_pos_dts(struct anim_index *idx, int frame_index) +uint64_t IMB_indexer_get_seek_pos_dts(struct anim_index *idx, int frame_index) { if (frame_index < 0) { frame_index = 0; @@ -281,7 +278,7 @@ int IMB_indexer_get_frame_index(struct anim_index *idx, int frameno) return first; } -unsigned long long IMB_indexer_get_pts(struct anim_index *idx, int frame_index) +uint64_t IMB_indexer_get_pts(struct anim_index *idx, int frame_index) { if (frame_index < 0) { frame_index = 0; @@ -707,12 +704,12 @@ typedef struct FFmpegIndexBuilderContext { IMB_Timecode_Type tcs_in_use; IMB_Proxy_Size proxy_sizes_in_use; - unsigned long long seek_pos; - unsigned long long last_seek_pos; - unsigned long long seek_pos_dts; - unsigned long long seek_pos_pts; - unsigned long long last_seek_pos_dts; - unsigned long long start_pts; + uint64_t seek_pos; + uint64_t last_seek_pos; + uint64_t seek_pos_dts; + uint64_t seek_pos_pts; + uint64_t last_seek_pos_dts; + uint64_t start_pts; double frame_rate; double pts_time_base; int frameno, frameno_gapless; @@ -847,9 +844,9 @@ static void index_rebuild_ffmpeg_proc_decoded_frame(FFmpegIndexBuilderContext *c AVFrame *in_frame) { int i; - unsigned long long s_pos = context->seek_pos; - unsigned long long s_dts = context->seek_pos_dts; - unsigned long long pts = av_get_pts_from_frame(context->iFormatCtx, in_frame); + uint64_t s_pos = context->seek_pos; + uint64_t s_dts = context->seek_pos_dts; + uint64_t pts = av_get_pts_from_frame(context->iFormatCtx, in_frame); for (i = 0; i < context->num_proxy_sizes; i++) { add_to_proxy_output_ffmpeg(context->proxy_ctx[i], in_frame); -- cgit v1.2.3