diff options
author | Anton Khirnov <anton@khirnov.net> | 2024-02-19 10:27:44 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2024-03-13 08:01:27 +0100 |
commit | a9193f7b7d65aafa326e25571c6672636a8ee3d2 (patch) | |
tree | 3db4310d628d166d97df3972ad395776fa59d08b /fftools/ffmpeg.c | |
parent | b98af440c575c1f9a706bd57ee5f1dd8b9ff82cc (diff) | |
download | ffmpeg-a9193f7b7d65aafa326e25571c6672636a8ee3d2.tar.gz |
fftools/ffmpeg: add loopback decoding
This allows to send an encoder's output back to decoding and feed the
result into a complex filtergraph.
Diffstat (limited to 'fftools/ffmpeg.c')
-rw-r--r-- | fftools/ffmpeg.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index ffd25f4c5b..d4e5f978f1 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -131,6 +131,9 @@ int nb_output_files = 0; FilterGraph **filtergraphs; int nb_filtergraphs; +Decoder **decoders; +int nb_decoders; + #if HAVE_TERMIOS_H /* init terminal so that we can grab keys */ @@ -340,6 +343,10 @@ static void ffmpeg_cleanup(int ret) for (int i = 0; i < nb_input_files; i++) ifile_close(&input_files[i]); + for (int i = 0; i < nb_decoders; i++) + dec_free(&decoders[i]); + av_freep(&decoders); + if (vstats_file) { if (fclose(vstats_file)) av_log(NULL, AV_LOG_ERROR, @@ -404,6 +411,10 @@ InputStream *ist_iter(InputStream *prev) static void frame_data_free(void *opaque, uint8_t *data) { + FrameData *fd = (FrameData *)data; + + avcodec_parameters_free(&fd->par_enc); + av_free(data); } @@ -430,6 +441,21 @@ static int frame_data_ensure(AVBufferRef **dst, int writable) const FrameData *fd_src = (const FrameData *)src->data; memcpy(fd, fd_src, sizeof(*fd)); + fd->par_enc = NULL; + + if (fd_src->par_enc) { + int ret = 0; + + fd->par_enc = avcodec_parameters_alloc(); + ret = fd->par_enc ? + avcodec_parameters_copy(fd->par_enc, fd_src->par_enc) : + AVERROR(ENOMEM); + if (ret < 0) { + av_buffer_unref(dst); + av_buffer_unref(&src); + return ret; + } + } av_buffer_unref(&src); } else { |