Commit 10f0332f authored by Limin Wang's avatar Limin Wang Committed by Michael Niedermayer

avcodec/decode: replace avctx->internal with avci for better readability

Signed-off-by: 's avatarLimin Wang <lance.lmwang@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent f907eea8
...@@ -479,32 +479,32 @@ static int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame) ...@@ -479,32 +479,32 @@ static int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame)
side= av_packet_get_side_data(avci->last_pkt_props, AV_PKT_DATA_SKIP_SAMPLES, &side_size); side= av_packet_get_side_data(avci->last_pkt_props, AV_PKT_DATA_SKIP_SAMPLES, &side_size);
if(side && side_size>=10) { if(side && side_size>=10) {
avctx->internal->skip_samples = AV_RL32(side) * avctx->internal->skip_samples_multiplier; avci->skip_samples = AV_RL32(side) * avci->skip_samples_multiplier;
discard_padding = AV_RL32(side + 4); discard_padding = AV_RL32(side + 4);
av_log(avctx, AV_LOG_DEBUG, "skip %d / discard %d samples due to side data\n", av_log(avctx, AV_LOG_DEBUG, "skip %d / discard %d samples due to side data\n",
avctx->internal->skip_samples, (int)discard_padding); avci->skip_samples, (int)discard_padding);
skip_reason = AV_RL8(side + 8); skip_reason = AV_RL8(side + 8);
discard_reason = AV_RL8(side + 9); discard_reason = AV_RL8(side + 9);
} }
if ((frame->flags & AV_FRAME_FLAG_DISCARD) && got_frame && if ((frame->flags & AV_FRAME_FLAG_DISCARD) && got_frame &&
!(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) { !(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) {
avctx->internal->skip_samples = FFMAX(0, avctx->internal->skip_samples - frame->nb_samples); avci->skip_samples = FFMAX(0, avci->skip_samples - frame->nb_samples);
got_frame = 0; got_frame = 0;
} }
if (avctx->internal->skip_samples > 0 && got_frame && if (avci->skip_samples > 0 && got_frame &&
!(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) { !(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) {
if(frame->nb_samples <= avctx->internal->skip_samples){ if(frame->nb_samples <= avci->skip_samples){
got_frame = 0; got_frame = 0;
avctx->internal->skip_samples -= frame->nb_samples; avci->skip_samples -= frame->nb_samples;
av_log(avctx, AV_LOG_DEBUG, "skip whole frame, skip left: %d\n", av_log(avctx, AV_LOG_DEBUG, "skip whole frame, skip left: %d\n",
avctx->internal->skip_samples); avci->skip_samples);
} else { } else {
av_samples_copy(frame->extended_data, frame->extended_data, 0, avctx->internal->skip_samples, av_samples_copy(frame->extended_data, frame->extended_data, 0, avci->skip_samples,
frame->nb_samples - avctx->internal->skip_samples, avctx->channels, frame->format); frame->nb_samples - avci->skip_samples, avctx->channels, frame->format);
if(avctx->pkt_timebase.num && avctx->sample_rate) { if(avctx->pkt_timebase.num && avctx->sample_rate) {
int64_t diff_ts = av_rescale_q(avctx->internal->skip_samples, int64_t diff_ts = av_rescale_q(avci->skip_samples,
(AVRational){1, avctx->sample_rate}, (AVRational){1, avctx->sample_rate},
avctx->pkt_timebase); avctx->pkt_timebase);
if(frame->pts!=AV_NOPTS_VALUE) if(frame->pts!=AV_NOPTS_VALUE)
...@@ -523,9 +523,9 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -523,9 +523,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for skipped samples.\n"); av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for skipped samples.\n");
} }
av_log(avctx, AV_LOG_DEBUG, "skip %d/%d samples\n", av_log(avctx, AV_LOG_DEBUG, "skip %d/%d samples\n",
avctx->internal->skip_samples, frame->nb_samples); avci->skip_samples, frame->nb_samples);
frame->nb_samples -= avctx->internal->skip_samples; frame->nb_samples -= avci->skip_samples;
avctx->internal->skip_samples = 0; avci->skip_samples = 0;
} }
} }
...@@ -551,11 +551,11 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -551,11 +551,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
if ((avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL) && got_frame) { if ((avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL) && got_frame) {
AVFrameSideData *fside = av_frame_new_side_data(frame, AV_FRAME_DATA_SKIP_SAMPLES, 10); AVFrameSideData *fside = av_frame_new_side_data(frame, AV_FRAME_DATA_SKIP_SAMPLES, 10);
if (fside) { if (fside) {
AV_WL32(fside->data, avctx->internal->skip_samples); AV_WL32(fside->data, avci->skip_samples);
AV_WL32(fside->data + 4, discard_padding); AV_WL32(fside->data + 4, discard_padding);
AV_WL8(fside->data + 8, skip_reason); AV_WL8(fside->data + 8, skip_reason);
AV_WL8(fside->data + 9, discard_reason); AV_WL8(fside->data + 9, discard_reason);
avctx->internal->skip_samples = 0; avci->skip_samples = 0;
} }
} }
} }
...@@ -580,7 +580,7 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -580,7 +580,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
/* do not stop draining when actual_got_frame != 0 or ret < 0 */ /* do not stop draining when actual_got_frame != 0 or ret < 0 */
/* got_frame == 0 but actual_got_frame != 0 when frame is discarded */ /* got_frame == 0 but actual_got_frame != 0 when frame is discarded */
if (avctx->internal->draining && !actual_got_frame) { if (avci->draining && !actual_got_frame) {
if (ret < 0) { if (ret < 0) {
/* prevent infinite loop if a decoder wrongly always return error on draining */ /* prevent infinite loop if a decoder wrongly always return error on draining */
/* reasonable nb_errors_max = maximum b frames + thread count */ /* reasonable nb_errors_max = maximum b frames + thread count */
...@@ -2030,15 +2030,17 @@ static void bsfs_flush(AVCodecContext *avctx) ...@@ -2030,15 +2030,17 @@ static void bsfs_flush(AVCodecContext *avctx)
void avcodec_flush_buffers(AVCodecContext *avctx) void avcodec_flush_buffers(AVCodecContext *avctx)
{ {
avctx->internal->draining = 0; AVCodecInternal *avci = avctx->internal;
avctx->internal->draining_done = 0;
avctx->internal->nb_draining_errors = 0; avci->draining = 0;
av_frame_unref(avctx->internal->buffer_frame); avci->draining_done = 0;
av_frame_unref(avctx->internal->compat_decode_frame); avci->nb_draining_errors = 0;
av_packet_unref(avctx->internal->buffer_pkt); av_frame_unref(avci->buffer_frame);
avctx->internal->buffer_pkt_valid = 0; av_frame_unref(avci->compat_decode_frame);
av_packet_unref(avci->buffer_pkt);
avci->buffer_pkt_valid = 0;
av_packet_unref(avctx->internal->ds.in_pkt); av_packet_unref(avci->ds.in_pkt);
if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
ff_thread_flush(avctx); ff_thread_flush(avctx);
...@@ -2051,7 +2053,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx) ...@@ -2051,7 +2053,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
bsfs_flush(avctx); bsfs_flush(avctx);
if (!avctx->refcounted_frames) if (!avctx->refcounted_frames)
av_frame_unref(avctx->internal->to_free); av_frame_unref(avci->to_free);
} }
void ff_decode_bsfs_uninit(AVCodecContext *avctx) void ff_decode_bsfs_uninit(AVCodecContext *avctx)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment