It does not need to be visible outside of encode.c.
Unified · Split
| @@ -42,6 +42,12 @@ typedef struct EncodeContext { · 41 unmodified lines | ||
| 42 | 42 | * This is used to set said flag generically for said encoders. |
| 43 | 43 | */ |
| 44 | 44 | int intra_only_flag; |
| 45 | + | |
| 46 | + /** | |
| 47 | + * An audio frame with less than required samples has been submitted (and | |
| 48 | + * potentially padded with silence). Reject all subsequent frames. | |
| 49 | + */ | |
| 50 | + int last_audio_frame; | |
| 45 | 51 | } EncodeContext; |
| 46 | 52 | |
| 47 | 53 | static EncodeContext *encode_ctx(AVCodecInternal *avci) |
| @@ -174,7 +180,7 @@ static int pad_last_frame(AVCodecContext *s, AVFrame *frame, const AVFrame *src, · 126 unmodified lines | ||
| 174 | 180 | |
| 175 | 181 | fail: |
| 176 | 182 | av_frame_unref(frame); |
| 177 | − s->internal->last_audio_frame = 0; | |
| 183 | + encode_ctx(s->internal)->last_audio_frame = 0; | |
| 178 | 184 | return ret; |
| 179 | 185 | } |
| 180 | 186 | |
| @@ -446,6 +452,7 @@ static int encode_generate_icc_profile(av_unused AVCodecContext *c, av_unused AV · 265 unmodified lines | ||
| 446 | 452 | static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src) |
| 447 | 453 | { |
| 448 | 454 | AVCodecInternal *avci = avctx->internal; |
| 455 | + EncodeContext *ec = encode_ctx(avci); | |
| 449 | 456 | AVFrame *dst = avci->buffer_frame; |
| 450 | 457 | int ret; |
| 451 | 458 | |
| @@ -458,7 +465,7 @@ static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src) · 6 unmodified lines | ||
| 458 | 465 | /* check for valid frame size */ |
| 459 | 466 | if (!(avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) { |
| 460 | 467 | /* if we already got an undersized frame, that must have been the last */ |
| 461 | − if (avctx->internal->last_audio_frame) { | |
| 468 | + if (ec->last_audio_frame) { | |
| 462 | 469 | av_log(avctx, AV_LOG_ERROR, "frame_size (%d) was not respected for a non-last frame\n", avctx->frame_size); |
| 463 | 470 | return AVERROR(EINVAL); |
| 464 | 471 | } |
| @@ -467,7 +474,7 @@ static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src) · 2 unmodified lines | ||
| 467 | 474 | return AVERROR(EINVAL); |
| 468 | 475 | } |
| 469 | 476 | if (src->nb_samples < avctx->frame_size) { |
| 470 | − avctx->internal->last_audio_frame = 1; | |
| 477 | + ec->last_audio_frame = 1; | |
| 471 | 478 | if (!(avctx->codec->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME)) { |
| 472 | 479 | int pad_samples = avci->pad_samples ? avci->pad_samples : avctx->frame_size; |
| 473 | 480 | int out_samples = (src->nb_samples + pad_samples - 1) / pad_samples * pad_samples; |
| @@ -56,12 +56,6 @@ typedef struct AVCodecInternal { · 55 unmodified lines | ||
| 56 | 56 | */ |
| 57 | 57 | int is_copy; |
| 58 | 58 | |
| 59 | − /** | |
| 60 | − * An audio frame with less than required samples has been submitted (and | |
| 61 | − * potentially padded with silence). Reject all subsequent frames. | |
| 62 | − */ | |
| 63 | − int last_audio_frame; | |
| 64 | − | |
| 65 | 59 | /** |
| 66 | 60 | * Audio encoders can set this flag during init to indicate that they |
| 67 | 61 | * want the small last frame to be padded to a multiple of pad_samples. |