audio/video: expose codec info as separate field

Preparation for the timeline rewrite. The codec will be able to change,
the stream header not.
This commit is contained in:
wm4 2016-02-15 20:34:45 +01:00
parent f219a48dca
commit f2b039da77
8 changed files with 16 additions and 14 deletions

View File

@ -77,8 +77,7 @@ static int init(struct dec_audio *da, const char *decoder)
struct ad_lavc_params *opts = mpopts->ad_lavc_params;
AVCodecContext *lavc_context;
AVCodec *lavc_codec;
struct sh_stream *sh = da->header;
struct mp_codec_params *c = sh->codec;
struct mp_codec_params *c = da->codec;
struct priv *ctx = talloc_zero(NULL, struct priv);
da->priv = ctx;
@ -216,8 +215,8 @@ static int decode_packet(struct dec_audio *da, struct demux_packet *mpkt,
if (lavc_chmap.num != avctx->channels)
mp_chmap_from_channels(&lavc_chmap, avctx->channels);
if (priv->force_channel_map) {
if (lavc_chmap.num == da->header->codec->channels.num)
lavc_chmap = da->header->codec->channels;
if (lavc_chmap.num == da->codec->channels.num)
lavc_chmap = da->codec->channels;
}
mp_audio_set_channels(mpframe, &lavc_chmap);

View File

@ -86,7 +86,7 @@ struct mp_decoder_list *audio_decoder_list(void)
static struct mp_decoder_list *audio_select_decoders(struct dec_audio *d_audio)
{
struct MPOpts *opts = d_audio->opts;
const char *codec = d_audio->header->codec->codec;
const char *codec = d_audio->codec->codec;
struct mp_decoder_list *list = audio_decoder_list();
struct mp_decoder_list *new =
@ -144,7 +144,7 @@ int audio_init_best_codec(struct dec_audio *d_audio)
MP_VERBOSE(d_audio, "Selected audio codec: %s\n", d_audio->decoder_desc);
} else {
MP_ERR(d_audio, "Failed to initialize an audio decoder for codec '%s'.\n",
d_audio->header->codec->codec);
d_audio->codec->codec);
}
talloc_free(list);

View File

@ -32,6 +32,7 @@ struct dec_audio {
struct mpv_global *global;
const struct ad_functions *ad_driver;
struct sh_stream *header;
struct mp_codec_params *codec;
char *decoder_desc;
bool try_spdif;

View File

@ -389,6 +389,7 @@ int init_audio_decoder(struct MPContext *mpctx, struct track *track)
d_audio->global = mpctx->global;
d_audio->opts = mpctx->opts;
d_audio->header = track->stream;
d_audio->codec = track->stream->codec;
d_audio->try_spdif = true;

View File

@ -325,6 +325,7 @@ int init_video_decoder(struct MPContext *mpctx, struct track *track)
d_video->log = mp_log_new(d_video, mpctx->log, "!vd");
d_video->opts = mpctx->opts;
d_video->header = track->stream;
d_video->codec = track->stream->codec;
d_video->fps = d_video->header->codec->fps;
if (mpctx->vo_chain)
d_video->hwdec_info = mpctx->vo_chain->hwdec_info;

View File

@ -136,7 +136,7 @@ bool video_init_best_codec(struct dec_video *d_video)
struct mp_decoder_entry *decoder = NULL;
struct mp_decoder_list *list =
mp_select_video_decoders(d_video->header->codec->codec, opts->video_decoders);
mp_select_video_decoders(d_video->codec->codec, opts->video_decoders);
mp_print_decoders(d_video->log, MSGL_V, "Codec list:", list);
@ -164,7 +164,7 @@ bool video_init_best_codec(struct dec_video *d_video)
MP_VERBOSE(d_video, "Selected video codec: %s\n", d_video->decoder_desc);
} else {
MP_ERR(d_video, "Failed to initialize a video decoder for codec '%s'.\n",
d_video->header->codec->codec);
d_video->codec->codec);
}
if (d_video->header->missing_timestamps) {
@ -182,7 +182,7 @@ static void fix_image_params(struct dec_video *d_video,
{
struct MPOpts *opts = d_video->opts;
struct mp_image_params p = *params;
struct mp_codec_params *c = d_video->header->codec;
struct mp_codec_params *c = d_video->codec;
MP_VERBOSE(d_video, "Decoder format: %s\n", mp_image_params_to_str(params));
@ -241,7 +241,7 @@ static struct mp_image *decode_packet(struct dec_video *d_video,
int drop_frame)
{
struct MPOpts *opts = d_video->opts;
bool avi_pts = d_video->header->codec->avi_dts && opts->correct_pts;
bool avi_pts = d_video->codec->avi_dts && opts->correct_pts;
struct demux_packet packet_copy;
if (packet && packet->dts == MP_NOPTS_VALUE && !avi_pts) {

View File

@ -34,6 +34,7 @@ struct dec_video {
const struct vd_functions *vd_driver;
struct mp_hwdec_info *hwdec_info; // video output hwdec handles
struct sh_stream *header;
struct mp_codec_params *codec;
char *decoder_desc;

View File

@ -359,8 +359,7 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
vd_ffmpeg_ctx *ctx = vd->priv;
struct vd_lavc_params *lavc_param = vd->opts->vd_lavc_params;
bool mp_rawvideo = false;
struct sh_stream *sh = vd->header;
struct mp_codec_params *c = sh->codec;
struct mp_codec_params *c = vd->codec;
assert(!ctx->avctx);
@ -522,8 +521,8 @@ static void update_image_params(struct dec_video *vd, AVFrame *frame,
.gamma = avcol_trc_to_mp_csp_trc(ctx->avctx->color_trc),
.chroma_location =
avchroma_location_to_mp(ctx->avctx->chroma_sample_location),
.rotate = vd->header->codec->rotate,
.stereo_in = vd->header->codec->stereo_mode,
.rotate = vd->codec->rotate,
.stereo_in = vd->codec->stereo_mode,
};
if (opts->video_rotate < 0) {