Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/anim_movie.c
| Show First 20 Lines • Show All 933 Lines • ▼ Show 20 Lines | if (need_aligned_ffmpeg_buffer(anim)) { | ||||
| } | } | ||||
| } | } | ||||
| if (filter_y) { | if (filter_y) { | ||||
| IMB_filtery(ibuf); | IMB_filtery(ibuf); | ||||
| } | } | ||||
| } | } | ||||
| /* decode one video frame also considering the packet read into cur_packet */ | static void ffmpeg_decode_store_frame_pts(struct anim *anim) | ||||
| { | |||||
| anim->cur_pts = av_get_pts_from_frame(anim->pFrame); | |||||
| if (anim->pFrame->key_frame) { | |||||
| anim->cur_key_frame_pts = anim->cur_pts; | |||||
| } | |||||
| av_log(anim->pFormatCtx, | |||||
| AV_LOG_DEBUG, | |||||
| " FRAME DONE: cur_pts=%" PRId64 ", guessed_pts=%" PRId64 "\n", | |||||
| (anim->pFrame->pts == AV_NOPTS_VALUE) ? -1 : (int64_t)anim->pFrame->pts, | |||||
| (int64_t)anim->cur_pts); | |||||
| } | |||||
| /* decode one video frame also considering the packet read into cur_packet */ | |||||
| static int ffmpeg_decode_video_frame(struct anim *anim) | static int ffmpeg_decode_video_frame(struct anim *anim) | ||||
| { | { | ||||
| int rval = 0; | |||||
| av_log(anim->pFormatCtx, AV_LOG_DEBUG, " DECODE VIDEO FRAME\n"); | av_log(anim->pFormatCtx, AV_LOG_DEBUG, " DECODE VIDEO FRAME\n"); | ||||
| /* Sometimes, decoder returns more than one frame per sent packet. Check if frames are available. | |||||
| * This frames must be read, otherwise decoding will fail. See T91405. */ | |||||
| anim->pFrameComplete = avcodec_receive_frame(anim->pCodecCtx, anim->pFrame) == 0; | |||||
| if (anim->pFrameComplete) { | |||||
| av_log(anim->pFormatCtx, AV_LOG_DEBUG, " DECODE FROM CODEC BUFFER\n"); | |||||
| ffmpeg_decode_store_frame_pts(anim); | |||||
| return 1; | |||||
| } | |||||
| int rval = 0; | |||||
| if (anim->cur_packet->stream_index == anim->videoStream) { | if (anim->cur_packet->stream_index == anim->videoStream) { | ||||
| av_packet_unref(anim->cur_packet); | av_packet_unref(anim->cur_packet); | ||||
| anim->cur_packet->stream_index = -1; | anim->cur_packet->stream_index = -1; | ||||
| } | } | ||||
| while ((rval = av_read_frame(anim->pFormatCtx, anim->cur_packet)) >= 0) { | while ((rval = av_read_frame(anim->pFormatCtx, anim->cur_packet)) >= 0) { | ||||
| av_log(anim->pFormatCtx, | av_log(anim->pFormatCtx, | ||||
| AV_LOG_DEBUG, | AV_LOG_DEBUG, | ||||
| "%sREAD: strID=%d (VID: %d) dts=%" PRId64 " pts=%" PRId64 " %s\n", | "%sREAD: strID=%d (VID: %d) dts=%" PRId64 " pts=%" PRId64 " %s\n", | ||||
| (anim->cur_packet->stream_index == anim->videoStream) ? "->" : " ", | (anim->cur_packet->stream_index == anim->videoStream) ? "->" : " ", | ||||
| anim->cur_packet->stream_index, | anim->cur_packet->stream_index, | ||||
| anim->videoStream, | anim->videoStream, | ||||
| (anim->cur_packet->dts == AV_NOPTS_VALUE) ? -1 : (int64_t)anim->cur_packet->dts, | (anim->cur_packet->dts == AV_NOPTS_VALUE) ? -1 : (int64_t)anim->cur_packet->dts, | ||||
| (anim->cur_packet->pts == AV_NOPTS_VALUE) ? -1 : (int64_t)anim->cur_packet->pts, | (anim->cur_packet->pts == AV_NOPTS_VALUE) ? -1 : (int64_t)anim->cur_packet->pts, | ||||
| (anim->cur_packet->flags & AV_PKT_FLAG_KEY) ? " KEY" : ""); | (anim->cur_packet->flags & AV_PKT_FLAG_KEY) ? " KEY" : ""); | ||||
| if (anim->cur_packet->stream_index == anim->videoStream) { | if (anim->cur_packet->stream_index == anim->videoStream) { | ||||
| anim->pFrameComplete = 0; | anim->pFrameComplete = 0; | ||||
zeddb: Somewhat unrelated to the patch, but I guess you can remove this as this statement doesn't… | |||||
| avcodec_send_packet(anim->pCodecCtx, anim->cur_packet); | avcodec_send_packet(anim->pCodecCtx, anim->cur_packet); | ||||
| anim->pFrameComplete = avcodec_receive_frame(anim->pCodecCtx, anim->pFrame) == 0; | anim->pFrameComplete = avcodec_receive_frame(anim->pCodecCtx, anim->pFrame) == 0; | ||||
| if (anim->pFrameComplete) { | if (anim->pFrameComplete) { | ||||
| anim->cur_pts = av_get_pts_from_frame(anim->pFrame); | ffmpeg_decode_store_frame_pts(anim); | ||||
| if (anim->pFrame->key_frame) { | |||||
| anim->cur_key_frame_pts = anim->cur_pts; | |||||
| } | |||||
| av_log(anim->pFormatCtx, | |||||
| AV_LOG_DEBUG, | |||||
| " FRAME DONE: cur_pts=%" PRId64 ", guessed_pts=%" PRId64 "\n", | |||||
| (anim->pFrame->pts == AV_NOPTS_VALUE) ? -1 : (int64_t)anim->pFrame->pts, | |||||
| (int64_t)anim->cur_pts); | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| av_packet_unref(anim->cur_packet); | av_packet_unref(anim->cur_packet); | ||||
| anim->cur_packet->stream_index = -1; | anim->cur_packet->stream_index = -1; | ||||
| } | } | ||||
| if (rval == AVERROR_EOF) { | if (rval == AVERROR_EOF) { | ||||
| /* Flush any remaining frames out of the decoder. */ | /* Flush any remaining frames out of the decoder. */ | ||||
| anim->pFrameComplete = 0; | anim->pFrameComplete = 0; | ||||
zeddbUnsubmitted Not Done Inline ActionsSame as above. zeddb: Same as above. | |||||
| avcodec_send_packet(anim->pCodecCtx, NULL); | avcodec_send_packet(anim->pCodecCtx, NULL); | ||||
| anim->pFrameComplete = avcodec_receive_frame(anim->pCodecCtx, anim->pFrame) == 0; | anim->pFrameComplete = avcodec_receive_frame(anim->pCodecCtx, anim->pFrame) == 0; | ||||
| if (anim->pFrameComplete) { | if (anim->pFrameComplete) { | ||||
| anim->cur_pts = av_get_pts_from_frame(anim->pFrame); | ffmpeg_decode_store_frame_pts(anim); | ||||
| if (anim->pFrame->key_frame) { | |||||
| anim->cur_key_frame_pts = anim->cur_pts; | |||||
| } | |||||
| av_log(anim->pFormatCtx, | |||||
| AV_LOG_DEBUG, | |||||
| " FRAME DONE (after EOF): cur_pts=%" PRId64 ", guessed_pts=%" PRId64 "\n", | |||||
| (anim->pFrame->pts == AV_NOPTS_VALUE) ? -1 : (int64_t)anim->pFrame->pts, | |||||
| (int64_t)anim->cur_pts); | |||||
| rval = 0; | rval = 0; | ||||
| } | } | ||||
| } | } | ||||
| if (rval < 0) { | if (rval < 0) { | ||||
| av_packet_unref(anim->cur_packet); | av_packet_unref(anim->cur_packet); | ||||
| anim->cur_packet->stream_index = -1; | anim->cur_packet->stream_index = -1; | ||||
| ▲ Show 20 Lines • Show All 708 Lines • Show Last 20 Lines | |||||
Somewhat unrelated to the patch, but I guess you can remove this as this statement doesn't really do anything?
The value will be overwritten below.