f_decoder_wrapper, sd_add: accept "null" codec

This is for easier use with the "delay_open" feature added in the
previous commit. The "null" codec is reported if the codec is unknown
(because the stream was not opened yet at time the tracks were added).
The rest of the timeline mechanism will set the correct codec at
runtime. But this means every time a delay-loaded track is selected, it
wants to initialize a decoder for the "null" codec.

Accept a "null" decoder. But since FFmpeg has no such codec, and out of
my own laziness, just let it fall back to "common" codecs that need no
other initialization data.
This commit is contained in:
wm4 2020-02-15 18:12:12 +01:00
parent c92c08edc6
commit e54ebaec52
2 changed files with 12 additions and 2 deletions

View File

@ -199,13 +199,16 @@ bool mp_decoder_wrapper_reinit(struct mp_decoder_wrapper *d)
const struct mp_decoder_fns *driver = NULL;
struct mp_decoder_list *list = NULL;
char *user_list = NULL;
char *fallback = NULL;
if (p->codec->type == STREAM_VIDEO) {
driver = &vd_lavc;
user_list = opts->video_decoders;
fallback = "h264";
} else if (p->codec->type == STREAM_AUDIO) {
driver = &ad_lavc;
user_list = opts->audio_decoders;
fallback = "aac";
if (p->public.try_spdif && p->codec->codec) {
struct mp_decoder_list *spdif =
@ -223,7 +226,10 @@ bool mp_decoder_wrapper_reinit(struct mp_decoder_wrapper *d)
struct mp_decoder_list *full = talloc_zero(NULL, struct mp_decoder_list);
if (driver)
driver->add_decoders(full);
list = mp_select_decoders(p->log, full, p->codec->codec, user_list);
const char *codec = p->codec->codec;
if (codec && strcmp(codec, "null") == 0)
codec = fallback;
list = mp_select_decoders(p->log, full, codec, user_list);
talloc_free(full);
}

View File

@ -155,7 +155,11 @@ static int init(struct sd *sd)
char *extradata = sd->codec->extradata;
int extradata_size = sd->codec->extradata_size;
if (strcmp(sd->codec->codec, "ass") != 0) {
// Note: accept "null" as alias for "ass", so EDL delay_open subtitle
// streams work.
if (strcmp(sd->codec->codec, "ass") != 0 &&
strcmp(sd->codec->codec, "null") != 0)
{
ctx->is_converted = true;
ctx->converter = lavc_conv_create(sd->log, sd->codec->codec, extradata,
extradata_size);