mirror of
https://github.com/mpv-player/mpv
synced 2025-04-07 10:02:50 +00:00
video: remove BITMAPINFOHEADER from internal demuxer API
MPlayer traditionally did this because it made sense: the most important formats (avi, asf/wmv) used Microsoft formats, and many important decoders (win32 binary codecs) also did. But the world has changed, and I've always wanted to get rid of this thing from the codebase. demux_mkv.c internally still uses it, because, guess what, Matroska has a VfW muxing mode, which uses these data structures natively.
This commit is contained in:
parent
e977624d87
commit
fd7dde404d
@ -1250,15 +1250,12 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track)
|
||||
sh_v = sh->video;
|
||||
sh->demuxer_id = track->tnum;
|
||||
sh->title = talloc_strdup(sh_v, track->name);
|
||||
sh_v->bih = talloc_size(sh_v, sizeof(MP_BITMAPINFOHEADER) + extradata_size);
|
||||
if (!sh_v->bih) {
|
||||
MP_FATAL(demuxer, "Memory allocation failure!\n");
|
||||
abort();
|
||||
}
|
||||
*sh_v->bih = *bih;
|
||||
if (extradata_size)
|
||||
memcpy(sh_v->bih + 1, extradata, extradata_size);
|
||||
sh->format = sh_v->bih->biCompression;
|
||||
sh->format = bih->biCompression;
|
||||
sh_v->bits_per_coded_sample = bih->biBitCount;
|
||||
sh_v->coded_width = bih->biWidth;
|
||||
sh_v->coded_height = bih->biHeight;
|
||||
sh_v->extradata = talloc_memdup(sh_v, extradata, extradata_size);
|
||||
sh_v->extradata_len = extradata_size;
|
||||
if (raw) {
|
||||
sh->codec = "rawvideo";
|
||||
} else {
|
||||
@ -1988,7 +1985,7 @@ static void handle_realvideo(demuxer_t *demuxer, mkv_track_t *track,
|
||||
} else {
|
||||
dp->pts =
|
||||
real_fix_timestamp(dp->buffer, dp->len, timestamp,
|
||||
track->stream->video->bih->biCompression,
|
||||
track->stream->format,
|
||||
&track->rv_kf_base, &track->rv_kf_pts) * 0.001;
|
||||
}
|
||||
dp->pos = mkv_d->last_filepos;
|
||||
|
@ -82,10 +82,13 @@ typedef struct sh_video {
|
||||
float fps; // frames per second (set only if constant fps)
|
||||
float aspect; // aspect ratio stored in the file (for prescaling)
|
||||
int bitrate; // compressed bits/sec
|
||||
int bits_per_coded_sample;
|
||||
int coded_width, coded_height;
|
||||
unsigned char *extradata;
|
||||
int extradata_len;
|
||||
int disp_w, disp_h; // display size
|
||||
int rotate; // intended display rotation, in degrees, [0, 359]
|
||||
int stereo_mode; // mp_stereo3d_mode (0 if none/unknown)
|
||||
MP_BITMAPINFOHEADER *bih;
|
||||
} sh_video_t;
|
||||
|
||||
typedef struct sh_sub {
|
||||
|
@ -321,17 +321,6 @@ static int init(struct dec_video *vd, const char *decoder)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void set_from_bih(AVCodecContext *avctx, uint32_t format,
|
||||
MP_BITMAPINFOHEADER *bih)
|
||||
{
|
||||
if (bih->biSize > sizeof(*bih))
|
||||
mp_lavc_set_extradata(avctx, bih + 1, bih->biSize - sizeof(*bih));
|
||||
|
||||
avctx->bits_per_coded_sample = bih->biBitCount;
|
||||
avctx->coded_width = bih->biWidth;
|
||||
avctx->coded_height = bih->biHeight;
|
||||
}
|
||||
|
||||
static void init_avctx(struct dec_video *vd, const char *decoder,
|
||||
struct vd_lavc_hwdec *hwdec)
|
||||
{
|
||||
@ -402,10 +391,14 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
|
||||
avctx->codec_tag = sh->format;
|
||||
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;
|
||||
|
||||
// demux_mkv
|
||||
if (sh->video->bih)
|
||||
set_from_bih(avctx, sh->format, sh->video->bih);
|
||||
if (sh->video->coded_width && sh->video->coded_height) {
|
||||
avctx->coded_width = sh->video->coded_width;
|
||||
avctx->coded_height = sh->video->coded_height;
|
||||
}
|
||||
|
||||
mp_lavc_set_extradata(avctx, sh->video->extradata, sh->video->extradata_len);
|
||||
|
||||
if (mp_rawvideo) {
|
||||
avctx->pix_fmt = imgfmt2pixfmt(sh->format);
|
||||
|
Loading…
Reference in New Issue
Block a user