diff options
| author | Andreas Rheinhardt <[email protected]> | 2021-11-26 19:44:21 +0100 | 
|---|---|---|
| committer | Andreas Rheinhardt <[email protected]> | 2021-11-30 11:53:22 +0100 | 
| commit | 4913f05ccf70dc1470f284b9a32c0e66991f6029 (patch) | |
| tree | c27b72ca676e67d2791a5b19bc9a71be2b4a00c6 /fftools/ffmpeg_opt.c | |
| parent | d9f07a506d230321f826dcb50828e1d10e852b44 (diff) | |
fftools/ffmpeg_opt: Don't duplicate array unnecessarily
Signed-off-by: Andreas Rheinhardt <[email protected]>
Diffstat (limited to 'fftools/ffmpeg_opt.c')
| -rw-r--r-- | fftools/ffmpeg_opt.c | 43 | 
1 files changed, 8 insertions, 35 deletions
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index debd13f3bd..4845dd18a3 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2614,7 +2614,6 @@ loop_end:          /* set the filter output constraints */          if (ost->filter) {              OutputFilter *f = ost->filter; -            int count;              switch (ost->enc_ctx->codec_type) {              case AVMEDIA_TYPE_VIDEO:                  f->frame_rate = ost->frame_rate; @@ -2622,51 +2621,25 @@ loop_end:                  f->height     = ost->enc_ctx->height;                  if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {                      f->format = ost->enc_ctx->pix_fmt; -                } else if (ost->enc->pix_fmts) { -                    count = 0; -                    while (ost->enc->pix_fmts[count] != AV_PIX_FMT_NONE) -                        count++; -                    f->formats = av_calloc(count + 1, sizeof(*f->formats)); -                    if (!f->formats) -                        exit_program(1); -                    memcpy(f->formats, ost->enc->pix_fmts, (count + 1) * sizeof(*f->formats)); +                } else { +                    f->formats = ost->enc->pix_fmts;                  }                  break;              case AVMEDIA_TYPE_AUDIO:                  if (ost->enc_ctx->sample_fmt != AV_SAMPLE_FMT_NONE) {                      f->format = ost->enc_ctx->sample_fmt; -                } else if (ost->enc->sample_fmts) { -                    count = 0; -                    while (ost->enc->sample_fmts[count] != AV_SAMPLE_FMT_NONE) -                        count++; -                    f->formats = av_calloc(count + 1, sizeof(*f->formats)); -                    if (!f->formats) -                        exit_program(1); -                    memcpy(f->formats, ost->enc->sample_fmts, (count + 1) * sizeof(*f->formats)); +                } else { +                    f->formats = ost->enc->sample_fmts;                  }                  if (ost->enc_ctx->sample_rate) {                      f->sample_rate = ost->enc_ctx->sample_rate; -                } else if (ost->enc->supported_samplerates) { -                    count = 0; -                    while (ost->enc->supported_samplerates[count]) -                        count++; -                    f->sample_rates = av_calloc(count + 1, sizeof(*f->sample_rates)); -                    if (!f->sample_rates) -                        exit_program(1); -                    memcpy(f->sample_rates, ost->enc->supported_samplerates, -                           (count + 1) * sizeof(*f->sample_rates)); +                } else { +                    f->sample_rates = ost->enc->supported_samplerates;                  }                  if (ost->enc_ctx->channels) {                      f->channel_layout = av_get_default_channel_layout(ost->enc_ctx->channels); -                } else if (ost->enc->channel_layouts) { -                    count = 0; -                    while (ost->enc->channel_layouts[count]) -                        count++; -                    f->channel_layouts = av_calloc(count + 1, sizeof(*f->channel_layouts)); -                    if (!f->channel_layouts) -                        exit_program(1); -                    memcpy(f->channel_layouts, ost->enc->channel_layouts, -                           (count + 1) * sizeof(*f->channel_layouts)); +                } else { +                    f->channel_layouts = ost->enc->channel_layouts;                  }                  break;              }  | 
