mirror of https://github.com/mpv-player/mpv
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:
parent
c92c08edc6
commit
e54ebaec52
|
@ -199,13 +199,16 @@ bool mp_decoder_wrapper_reinit(struct mp_decoder_wrapper *d)
|
||||||
const struct mp_decoder_fns *driver = NULL;
|
const struct mp_decoder_fns *driver = NULL;
|
||||||
struct mp_decoder_list *list = NULL;
|
struct mp_decoder_list *list = NULL;
|
||||||
char *user_list = NULL;
|
char *user_list = NULL;
|
||||||
|
char *fallback = NULL;
|
||||||
|
|
||||||
if (p->codec->type == STREAM_VIDEO) {
|
if (p->codec->type == STREAM_VIDEO) {
|
||||||
driver = &vd_lavc;
|
driver = &vd_lavc;
|
||||||
user_list = opts->video_decoders;
|
user_list = opts->video_decoders;
|
||||||
|
fallback = "h264";
|
||||||
} else if (p->codec->type == STREAM_AUDIO) {
|
} else if (p->codec->type == STREAM_AUDIO) {
|
||||||
driver = &ad_lavc;
|
driver = &ad_lavc;
|
||||||
user_list = opts->audio_decoders;
|
user_list = opts->audio_decoders;
|
||||||
|
fallback = "aac";
|
||||||
|
|
||||||
if (p->public.try_spdif && p->codec->codec) {
|
if (p->public.try_spdif && p->codec->codec) {
|
||||||
struct mp_decoder_list *spdif =
|
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);
|
struct mp_decoder_list *full = talloc_zero(NULL, struct mp_decoder_list);
|
||||||
if (driver)
|
if (driver)
|
||||||
driver->add_decoders(full);
|
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);
|
talloc_free(full);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,11 @@ static int init(struct sd *sd)
|
||||||
char *extradata = sd->codec->extradata;
|
char *extradata = sd->codec->extradata;
|
||||||
int extradata_size = sd->codec->extradata_size;
|
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->is_converted = true;
|
||||||
ctx->converter = lavc_conv_create(sd->log, sd->codec->codec, extradata,
|
ctx->converter = lavc_conv_create(sd->log, sd->codec->codec, extradata,
|
||||||
extradata_size);
|
extradata_size);
|
||||||
|
|
Loading…
Reference in New Issue