demux: rename sh_stream.format to sh_stream.codec_tag

Why not. "format" sounds too misleading for the actual importance and
meaning of this field.
This commit is contained in:
wm4 2015-06-21 16:56:35 +02:00
parent 991af7dfb1
commit 2b64eee8d5
9 changed files with 16 additions and 18 deletions

View File

@ -116,7 +116,7 @@ static int init(struct dec_audio *da, const char *decoder)
mp_set_avopts(da->log, lavc_context, opts->avopts);
lavc_context->codec_tag = sh->format;
lavc_context->codec_tag = sh->codec_tag;
lavc_context->sample_rate = sh_audio->samplerate;
lavc_context->bit_rate = sh_audio->bitrate;
lavc_context->block_align = sh_audio->block_align;

View File

@ -72,11 +72,11 @@ static const char *map_audio_pcm_tag(uint32_t tag, int bits)
void mp_set_codec_from_tag(struct sh_stream *sh)
{
sh->codec = lookup_tag(sh->type, sh->format);
sh->codec = lookup_tag(sh->type, sh->codec_tag);
if (sh->audio && sh->audio->bits_per_coded_sample) {
const char *codec =
map_audio_pcm_tag(sh->format, sh->audio->bits_per_coded_sample);
map_audio_pcm_tag(sh->codec_tag, sh->audio->bits_per_coded_sample);
if (codec)
sh->codec = codec;
}

View File

@ -141,7 +141,7 @@ static void add_streams(demuxer_t *demuxer)
MP_TARRAY_APPEND(p, p->streams, p->num_streams, sh);
// Copy all stream fields that might be relevant
sh->codec = talloc_strdup(sh, src->codec);
sh->format = src->format;
sh->codec_tag = src->codec_tag;
sh->lav_headers = src->lav_headers;
sh->demuxer_id = src->demuxer_id;
if (src->video) {

View File

@ -521,8 +521,6 @@ static void handle_stream(demuxer_t *demuxer, int i)
break;
sh_audio_t *sh_audio = sh->audio;
sh->format = codec->codec_tag;
// probably unneeded
mp_chmap_set_unknown(&sh_audio->channels, codec->channels);
if (codec->channel_layout)
@ -550,7 +548,6 @@ static void handle_stream(demuxer_t *demuxer, int i)
}
}
sh->format = codec->codec_tag;
sh_video->disp_w = codec->width;
sh_video->disp_h = codec->height;
/* Try to make up some frame rate value, even if it's not reliable.
@ -636,6 +633,7 @@ static void handle_stream(demuxer_t *demuxer, int i)
if (sh) {
sh->ff_index = st->index;
sh->codec = mp_codec_from_av_codec_id(codec->codec_id);
sh->codec_tag = codec->codec_tag;
sh->lav_headers = codec;
if (st->disposition & AV_DISPOSITION_DEFAULT)

View File

@ -1238,7 +1238,7 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
if (track->v_height == 0)
track->v_height = AV_RL32(h + 8); // biHeight
sh_v->bits_per_coded_sample = AV_RL16(h + 14); // biBitCount
sh->format = AV_RL32(h + 16); // biCompression
sh->codec_tag = AV_RL32(h + 16); // biCompression
extradata = track->private_data + 40;
extradata_size = track->private_size - 40;
@ -1270,7 +1270,7 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
track->parse_timebase = 1e3;
} else if (strcmp(track->codec_id, "V_UNCOMPRESSED") == 0) {
// raw video, "like AVI" - this is a FourCC
sh->format = track->colorspace;
sh->codec_tag = track->colorspace;
sh->codec = "rawvideo";
} else if (strcmp(track->codec_id, "V_QUICKTIME") == 0) {
uint32_t fourcc1 = 0, fourcc2 = 0;
@ -1302,7 +1302,7 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
track->parse = true;
track->parse_timebase = 1e9;
} else if (!strcmp(codec, "mjpeg")) {
sh->format = MP_FOURCC('m', 'j', 'p', 'g');
sh->codec_tag = MP_FOURCC('m', 'j', 'p', 'g');
}
if (extradata_size > 0x1000000) {
@ -1391,7 +1391,7 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track)
goto error;
MP_VERBOSE(demuxer, "track with MS compat audio.\n");
unsigned char *h = track->private_data;
sh->format = AV_RL16(h + 0); // wFormatTag
sh->codec_tag = AV_RL16(h + 0); // wFormatTag
if (track->a_channels == 0)
track->a_channels = AV_RL16(h + 2); // nChannels
if (sh_a->samplerate == 0)

View File

@ -222,7 +222,7 @@ static int demux_rawvideo_open(demuxer_t *demuxer, enum demux_check check)
sh = new_sh_stream(demuxer, STREAM_VIDEO);
sh_video = sh->video;
sh->codec = decoder;
sh->format = imgfmt;
sh->codec_tag = imgfmt;
sh_video->fps = opts->fps;
sh_video->disp_w = width;
sh_video->disp_h = height;

View File

@ -60,7 +60,7 @@ static int demux_open_tv(demuxer_t *demuxer, enum demux_check check)
sh_v->codec = "mjpeg";
} else {
sh_v->codec = "rawvideo";
sh_v->format = fourcc;
sh_v->codec_tag = fourcc;
}
/* set FPS and FRAMETIME */

View File

@ -47,7 +47,7 @@ struct sh_stream {
const char *codec;
// Usually a FourCC, exact meaning depends on codec.
unsigned int format;
unsigned int codec_tag;
// Codec specific header data (set by demux_lavf.c only)
struct AVCodecContext *lav_headers;

View File

@ -399,7 +399,7 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
// Do this after the above avopt handling in case it changes values
ctx->skip_frame = avctx->skip_frame;
avctx->codec_tag = sh->format;
avctx->codec_tag = sh->codec_tag;
avctx->coded_width = sh->video->disp_w;
avctx->coded_height = sh->video->disp_h;
avctx->bits_per_coded_sample = sh->video->bits_per_coded_sample;
@ -407,11 +407,11 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
mp_lavc_set_extradata(avctx, sh->video->extradata, sh->video->extradata_len);
if (mp_rawvideo) {
avctx->pix_fmt = imgfmt2pixfmt(sh->format);
avctx->pix_fmt = imgfmt2pixfmt(sh->codec_tag);
avctx->codec_tag = 0;
if (avctx->pix_fmt == AV_PIX_FMT_NONE && sh->format)
if (avctx->pix_fmt == AV_PIX_FMT_NONE && sh->codec_tag)
MP_ERR(vd, "Image format %s not supported by lavc.\n",
mp_imgfmt_to_name(sh->format));
mp_imgfmt_to_name(sh->codec_tag));
}
if (sh->lav_headers)