summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demux/demux_mkv.c17
-rw-r--r--demux/stheader.h5
-rw-r--r--video/decode/vd_lavc.c21
3 files changed, 18 insertions, 25 deletions
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c
index c20a1aa999..27be3a169f 100644
--- a/demux/demux_mkv.c
+++ b/demux/demux_mkv.c
@@ -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;
diff --git a/demux/stheader.h b/demux/stheader.h
index a2740f0189..a368074d99 100644
--- a/demux/stheader.h
+++ b/demux/stheader.h
@@ -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 {
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index 45ae9fce94..abed77dd2c 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -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;
+
+ if (sh->video->coded_width && sh->video->coded_height) {
+ avctx->coded_width = sh->video->coded_width;
+ avctx->coded_height = sh->video->coded_height;
+ }
- // demux_mkv
- if (sh->video->bih)
- set_from_bih(avctx, sh->format, sh->video->bih);
+ mp_lavc_set_extradata(avctx, sh->video->extradata, sh->video->extradata_len);
if (mp_rawvideo) {
avctx->pix_fmt = imgfmt2pixfmt(sh->format);