It does not need to be visible outside of encode.c.
Showing the changes to libavcodec (2 of 2 files). Show all
Unified · Split
| @@ -42,6 +42,12 @@ typedef struct EncodeContext { · 41 unmodified lines | |||
| 42 | * This is used to set said flag generically for said encoders. | 42 | * This is used to set said flag generically for said encoders. |
| 43 | */ | 43 | */ |
| 44 | int intra_only_flag; | 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 | } EncodeContext; | 51 | } EncodeContext; |
| 46 | 52 | ||
| 47 | static EncodeContext *encode_ctx(AVCodecInternal *avci) | 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 | fail: | 181 | fail: |
| 176 | av_frame_unref(frame); | 182 | av_frame_unref(frame); |
| 177 | s->internal->last_audio_frame = 0; | 183 | encode_ctx(s->internal)->last_audio_frame = 0; |
| 178 | return ret; | 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 | static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src) | 452 | static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src) |
| 447 | { | 453 | { |
| 448 | AVCodecInternal *avci = avctx->internal; | 454 | AVCodecInternal *avci = avctx->internal; |
| 455 | EncodeContext *ec = encode_ctx(avci); | ||
| 449 | AVFrame *dst = avci->buffer_frame; | 456 | AVFrame *dst = avci->buffer_frame; |
| 450 | int ret; | 457 | int ret; |
| 451 | 458 | ||
| @@ -458,7 +465,7 @@ static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src) · 6 unmodified lines | |||
| 458 | /* check for valid frame size */ | 465 | /* check for valid frame size */ |
| 459 | if (!(avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) { | 466 | if (!(avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) { |
| 460 | /* if we already got an undersized frame, that must have been the last */ | 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 | av_log(avctx, AV_LOG_ERROR, "frame_size (%d) was not respected for a non-last frame\n", avctx->frame_size); | 469 | av_log(avctx, AV_LOG_ERROR, "frame_size (%d) was not respected for a non-last frame\n", avctx->frame_size); |
| 463 | return AVERROR(EINVAL); | 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 | return AVERROR(EINVAL); | 474 | return AVERROR(EINVAL); |
| 468 | } | 475 | } |
| 469 | if (src->nb_samples < avctx->frame_size) { | 476 | if (src->nb_samples < avctx->frame_size) { |
| 470 | avctx->internal->last_audio_frame = 1; | 477 | ec->last_audio_frame = 1; |
| 471 | if (!(avctx->codec->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME)) { | 478 | if (!(avctx->codec->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME)) { |
| 472 | int pad_samples = avci->pad_samples ? avci->pad_samples : avctx->frame_size; | 479 | int pad_samples = avci->pad_samples ? avci->pad_samples : avctx->frame_size; |
| 473 | int out_samples = (src->nb_samples + pad_samples - 1) / pad_samples * pad_samples; | 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 | int is_copy; | 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 | * Audio encoders can set this flag during init to indicate that they | 60 | * Audio encoders can set this flag during init to indicate that they |
| 67 | * want the small last frame to be padded to a multiple of pad_samples. | 61 | * want the small last frame to be padded to a multiple of pad_samples. |