History

lavc: move AVCodecInternal.last_audio_frame to EncodeContext

It does not need to be visible outside of encode.c.

Anton Khirnov committed 3 years ago

Commit fd915dc1 parent 23270012 files · +10 −9Browse files

Unified · Split

2 files
  1. libavcodec/encode.c +10 −3
  2. libavcodec/internal.h +0 −6
libavcodec/encode.c+10−3
@@ -42,6 +42,12 @@ typedef struct EncodeContext { · 41 unmodified lines
4242 * This is used to set said flag generically for said encoders.
4343 */
4444 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;
4551 } EncodeContext;
4652
4753 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
174180
175181 fail:
176182 av_frame_unref(frame);
177− s->internal->last_audio_frame = 0;
183+ encode_ctx(s->internal)->last_audio_frame = 0;
178184 return ret;
179185 }
180186
@@ -446,6 +452,7 @@ static int encode_generate_icc_profile(av_unused AVCodecContext *c, av_unused AV · 265 unmodified lines
446452 static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src)
447453 {
448454 AVCodecInternal *avci = avctx->internal;
455+ EncodeContext *ec = encode_ctx(avci);
449456 AVFrame *dst = avci->buffer_frame;
450457 int ret;
451458
@@ -458,7 +465,7 @@ static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src) · 6 unmodified lines
458465 /* check for valid frame size */
459466 if (!(avctx->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) {
460467 /* 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) {
462469 av_log(avctx, AV_LOG_ERROR, "frame_size (%d) was not respected for a non-last frame\n", avctx->frame_size);
463470 return AVERROR(EINVAL);
464471 }
@@ -467,7 +474,7 @@ static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src) · 2 unmodified lines
467474 return AVERROR(EINVAL);
468475 }
469476 if (src->nb_samples < avctx->frame_size) {
470− avctx->internal->last_audio_frame = 1;
477+ ec->last_audio_frame = 1;
471478 if (!(avctx->codec->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME)) {
472479 int pad_samples = avci->pad_samples ? avci->pad_samples : avctx->frame_size;
473480 int out_samples = (src->nb_samples + pad_samples - 1) / pad_samples * pad_samples;
libavcodec/internal.h+0−6
@@ -56,12 +56,6 @@ typedef struct AVCodecInternal { · 55 unmodified lines
5656 */
5757 int is_copy;
5858
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−
6559 /**
6660 * Audio encoders can set this flag during init to indicate that they
6761 * want the small last frame to be padded to a multiple of pad_samples.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t