1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

avformat/utils: Move ff_stream_add_bitstream_filter to mux.c

It is muxing-only; in fact, it should be considered part of
the core muxing code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2022-05-06 15:01:33 +02:00
parent 5130bbb7ef
commit 7547f13548
10 changed files with 60 additions and 58 deletions

View File

@ -25,13 +25,12 @@
#include "libavutil/avassert.h"
#include "libavutil/mathematics.h"
#include "libavcodec/mpeg4audio.h"
#include "avio_internal.h"
#include "avio.h"
#include "avc.h"
#include "avformat.h"
#include "flv.h"
#include "internal.h"
#include "metadata.h"
#include "mux.h"
#include "libavutil/opt.h"
#include "libavcodec/put_bits.h"

View File

@ -771,17 +771,6 @@ enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags);
*/
int ff_generate_avci_extradata(AVStream *st);
/**
* Add a bitstream filter to a stream.
*
* @param st output stream to add a filter to
* @param name the name of the filter to add
* @param args filter-specific argument string
* @return >0 on success;
* AVERROR code on failure
*/
int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *args);
/**
* Copy encoding parameters from source to destination stream
*

View File

@ -19,6 +19,7 @@
*/
#include "avformat.h"
#include "internal.h"
#include "mux.h"
#include "libavutil/intreadwrite.h"
typedef struct IVFEncContext {

View File

@ -28,6 +28,7 @@
#include "libavutil/opt.h"
#include "avformat.h"
#include "internal.h"
#include "mux.h"
#include "rawenc.h"
#define MAX_EXTRADATA_SIZE 1024

View File

@ -21,7 +21,6 @@
#include <stdint.h>
#include "config.h"
#include "config_components.h"
#include "av1.h"
@ -35,6 +34,7 @@
#include "internal.h"
#include "isom.h"
#include "matroska.h"
#include "mux.h"
#include "riff.h"
#include "version.h"
#include "vorbiscomment.h"

View File

@ -34,6 +34,7 @@
#include "avio_internal.h"
#include "internal.h"
#include "mpegts.h"
#include "mux.h"
#define PCR_TIME_BASE 27000000

View File

@ -1304,6 +1304,49 @@ int av_get_output_timestamp(struct AVFormatContext *s, int stream,
return 0;
}
int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *args)
{
int ret;
const AVBitStreamFilter *bsf;
FFStream *const sti = ffstream(st);
AVBSFContext *bsfc;
av_assert0(!sti->bsfc);
if (!(bsf = av_bsf_get_by_name(name))) {
av_log(NULL, AV_LOG_ERROR, "Unknown bitstream filter '%s'\n", name);
return AVERROR_BSF_NOT_FOUND;
}
if ((ret = av_bsf_alloc(bsf, &bsfc)) < 0)
return ret;
bsfc->time_base_in = st->time_base;
if ((ret = avcodec_parameters_copy(bsfc->par_in, st->codecpar)) < 0) {
av_bsf_free(&bsfc);
return ret;
}
if (args && bsfc->filter->priv_class) {
if ((ret = av_set_options_string(bsfc->priv_data, args, "=", ":")) < 0) {
av_bsf_free(&bsfc);
return ret;
}
}
if ((ret = av_bsf_init(bsfc)) < 0) {
av_bsf_free(&bsfc);
return ret;
}
sti->bsfc = bsfc;
av_log(NULL, AV_LOG_VERBOSE,
"Automatically inserted bitstream filter '%s'; args='%s'\n",
name, args ? args : "");
return 1;
}
int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt,
AVFormatContext *src, int interleave)
{

View File

@ -56,6 +56,17 @@ const AVPacket *ff_interleaved_peek(AVFormatContext *s, int stream);
int ff_get_muxer_ts_offset(AVFormatContext *s, int stream_index, int64_t *offset);
/**
* Add a bitstream filter to a stream.
*
* @param st output stream to add a filter to
* @param name the name of the filter to add
* @param args filter-specific argument string
* @return >0 on success;
* AVERROR code on failure
*/
int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *args);
/**
* Write a packet to another muxer than the one the user originally
* intended. Useful when chaining muxers, where one muxer internally

View File

@ -26,7 +26,7 @@
#include "avformat.h"
#include "rawenc.h"
#include "internal.h"
#include "mux.h"
int ff_raw_write_packet(AVFormatContext *s, AVPacket *pkt)
{

View File

@ -1776,49 +1776,6 @@ uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,
return data;
}
int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *args)
{
int ret;
const AVBitStreamFilter *bsf;
FFStream *const sti = ffstream(st);
AVBSFContext *bsfc;
av_assert0(!sti->bsfc);
if (!(bsf = av_bsf_get_by_name(name))) {
av_log(NULL, AV_LOG_ERROR, "Unknown bitstream filter '%s'\n", name);
return AVERROR_BSF_NOT_FOUND;
}
if ((ret = av_bsf_alloc(bsf, &bsfc)) < 0)
return ret;
bsfc->time_base_in = st->time_base;
if ((ret = avcodec_parameters_copy(bsfc->par_in, st->codecpar)) < 0) {
av_bsf_free(&bsfc);
return ret;
}
if (args && bsfc->filter->priv_class) {
if ((ret = av_set_options_string(bsfc->priv_data, args, "=", ":")) < 0) {
av_bsf_free(&bsfc);
return ret;
}
}
if ((ret = av_bsf_init(bsfc)) < 0) {
av_bsf_free(&bsfc);
return ret;
}
sti->bsfc = bsfc;
av_log(NULL, AV_LOG_VERBOSE,
"Automatically inserted bitstream filter '%s'; args='%s'\n",
name, args ? args : "");
return 1;
}
int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **options)
{
if (!s->oformat)