mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-19 13:30:03 +01:00
fftools/ffmpeg_dec: pass decoder name through DecoderOpts
Do not build it from InputStream values. This is a step towards decoupling Decoder and InputStream.
This commit is contained in:
@@ -295,6 +295,8 @@ enum DecoderFlags {
|
|||||||
typedef struct DecoderOpts {
|
typedef struct DecoderOpts {
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
|
char *name;
|
||||||
|
|
||||||
/* hwaccel options */
|
/* hwaccel options */
|
||||||
enum HWAccelID hwaccel_id;
|
enum HWAccelID hwaccel_id;
|
||||||
enum AVHWDeviceType hwaccel_device_type;
|
enum AVHWDeviceType hwaccel_device_type;
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ typedef struct DecoderPriv {
|
|||||||
|
|
||||||
void *log_parent;
|
void *log_parent;
|
||||||
char log_name[32];
|
char log_name[32];
|
||||||
|
char *parent_name;
|
||||||
} DecoderPriv;
|
} DecoderPriv;
|
||||||
|
|
||||||
static DecoderPriv *dp_from_dec(Decoder *d)
|
static DecoderPriv *dp_from_dec(Decoder *d)
|
||||||
@@ -104,6 +105,8 @@ void dec_free(Decoder **pdec)
|
|||||||
av_frame_free(&dp->sub_prev[i]);
|
av_frame_free(&dp->sub_prev[i]);
|
||||||
av_frame_free(&dp->sub_heartbeat);
|
av_frame_free(&dp->sub_heartbeat);
|
||||||
|
|
||||||
|
av_freep(&dp->parent_name);
|
||||||
|
|
||||||
av_freep(pdec);
|
av_freep(pdec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,7 +502,6 @@ static int transcode_subtitles(InputStream *ist, const AVPacket *pkt,
|
|||||||
|
|
||||||
static int packet_decode(InputStream *ist, AVPacket *pkt, AVFrame *frame)
|
static int packet_decode(InputStream *ist, AVPacket *pkt, AVFrame *frame)
|
||||||
{
|
{
|
||||||
const InputFile *ifile = ist->file;
|
|
||||||
DecoderPriv *dp = dp_from_dec(ist->decoder);
|
DecoderPriv *dp = dp_from_dec(ist->decoder);
|
||||||
AVCodecContext *dec = dp->dec_ctx;
|
AVCodecContext *dec = dp->dec_ctx;
|
||||||
const char *type_desc = av_get_media_type_string(dec->codec_type);
|
const char *type_desc = av_get_media_type_string(dec->codec_type);
|
||||||
@@ -554,8 +556,7 @@ static int packet_decode(InputStream *ist, AVPacket *pkt, AVFrame *frame)
|
|||||||
|
|
||||||
update_benchmark(NULL);
|
update_benchmark(NULL);
|
||||||
ret = avcodec_receive_frame(dec, frame);
|
ret = avcodec_receive_frame(dec, frame);
|
||||||
update_benchmark("decode_%s %d.%d", type_desc,
|
update_benchmark("decode_%s %s", type_desc, dp->parent_name);
|
||||||
ifile->index, ist->index);
|
|
||||||
|
|
||||||
if (ret == AVERROR(EAGAIN)) {
|
if (ret == AVERROR(EAGAIN)) {
|
||||||
av_assert0(pkt); // should never happen during flushing
|
av_assert0(pkt); // should never happen during flushing
|
||||||
@@ -616,10 +617,10 @@ static int packet_decode(InputStream *ist, AVPacket *pkt, AVFrame *frame)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dec_thread_set_name(const InputStream *ist, const DecoderPriv *dp)
|
static void dec_thread_set_name(const DecoderPriv *dp)
|
||||||
{
|
{
|
||||||
char name[16];
|
char name[16];
|
||||||
snprintf(name, sizeof(name), "dec%d:%d:%s", ist->file->index, ist->index,
|
snprintf(name, sizeof(name), "dec%s:%s", dp->parent_name,
|
||||||
dp->dec_ctx->codec->name);
|
dp->dec_ctx->codec->name);
|
||||||
ff_thread_setname(name);
|
ff_thread_setname(name);
|
||||||
}
|
}
|
||||||
@@ -662,7 +663,7 @@ void *decoder_thread(void *arg)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
dec_thread_set_name(ist, dp);
|
dec_thread_set_name(dp);
|
||||||
|
|
||||||
while (!input_status) {
|
while (!input_status) {
|
||||||
int flush_buffers, have_data;
|
int flush_buffers, have_data;
|
||||||
@@ -972,6 +973,10 @@ int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx,
|
|||||||
|
|
||||||
snprintf(dp->log_name, sizeof(dp->log_name), "dec:%s", codec->name);
|
snprintf(dp->log_name, sizeof(dp->log_name), "dec:%s", codec->name);
|
||||||
|
|
||||||
|
dp->parent_name = av_strdup(o->name ? o->name : "");
|
||||||
|
if (!dp->parent_name)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
if (codec->type == AVMEDIA_TYPE_SUBTITLE &&
|
if (codec->type == AVMEDIA_TYPE_SUBTITLE &&
|
||||||
(dp->flags & DECODER_FLAG_FIX_SUB_DURATION)) {
|
(dp->flags & DECODER_FLAG_FIX_SUB_DURATION)) {
|
||||||
for (int i = 0; i < FF_ARRAY_ELEMS(dp->sub_prev); i++) {
|
for (int i = 0; i < FF_ARRAY_ELEMS(dp->sub_prev); i++) {
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ typedef struct DemuxStream {
|
|||||||
const AVCodecDescriptor *codec_desc;
|
const AVCodecDescriptor *codec_desc;
|
||||||
|
|
||||||
DecoderOpts dec_opts;
|
DecoderOpts dec_opts;
|
||||||
|
char dec_name[16];
|
||||||
|
|
||||||
AVBSFContext *bsf;
|
AVBSFContext *bsf;
|
||||||
|
|
||||||
@@ -926,6 +927,9 @@ static int ist_use(InputStream *ist, int decoding_needed)
|
|||||||
"same time is not fully supported, also see -compute_edt [0|1]\n");
|
"same time is not fully supported, also see -compute_edt [0|1]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snprintf(ds->dec_name, sizeof(ds->dec_name), "%d:%d", ist->file->index, ist->index);
|
||||||
|
ds->dec_opts.name = ds->dec_name;
|
||||||
|
|
||||||
ret = dec_open(ist, d->sch, ds->sch_idx_dec,
|
ret = dec_open(ist, d->sch, ds->sch_idx_dec,
|
||||||
&ist->decoder_opts, &ds->dec_opts);
|
&ist->decoder_opts, &ds->dec_opts);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user