1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-30 11:42:04 +00:00

demux_mkv: use new EBML parser to read Video element

This commit is contained in:
Uoti Urpala 2010-01-26 14:55:06 +02:00
parent db41501f23
commit 7ecafde34f

View File

@ -628,69 +628,41 @@ static int demux_mkv_read_trackaudio(demuxer_t *demuxer, mkv_track_t *track)
static int demux_mkv_read_trackvideo(demuxer_t *demuxer, mkv_track_t *track) static int demux_mkv_read_trackvideo(demuxer_t *demuxer, mkv_track_t *track)
{ {
stream_t *s = demuxer->stream; stream_t *s = demuxer->stream;
uint64_t len, length, l;
uint64_t num;
double fnum;
int il;
len = length = ebml_read_length(s, &il); struct ebml_video video = {};
len += il; struct ebml_parse_ctx parse_ctx = {};
while (length > 0) { if (ebml_read_element(s, &parse_ctx, &video, &ebml_video_desc) < 0)
switch (ebml_read_id(s, &il)) { return 0;
case MATROSKA_ID_FRAMERATE: if (video.n_frame_rate) {
fnum = ebml_read_float(s, &l); track->v_frate = video.frame_rate;
if (fnum == EBML_FLOAT_INVALID) mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Frame rate: %f\n",
return 0; track->v_frate);
track->v_frate = fnum; // XXX default_duration should take priority
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Frame rate: %f\n", if (track->v_frate > 0)
track->v_frate); track->default_duration = 1 / track->v_frate;
if (track->v_frate > 0)
track->default_duration = 1 / track->v_frate;
break;
case MATROSKA_ID_DISPLAYWIDTH:
num = ebml_read_uint(s, &l);
if (num == EBML_UINT_INVALID)
return 0;
track->v_dwidth = num;
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Display width: %u\n",
track->v_dwidth);
break;
case MATROSKA_ID_DISPLAYHEIGHT:
num = ebml_read_uint(s, &l);
if (num == EBML_UINT_INVALID)
return 0;
track->v_dheight = num;
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Display height: %u\n",
track->v_dheight);
break;
case MATROSKA_ID_PIXELWIDTH:
num = ebml_read_uint(s, &l);
if (num == EBML_UINT_INVALID)
return 0;
track->v_width = num;
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Pixel width: %u\n",
track->v_width);
break;
case MATROSKA_ID_PIXELHEIGHT:
num = ebml_read_uint(s, &l);
if (num == EBML_UINT_INVALID)
return 0;
track->v_height = num;
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Pixel height: %u\n",
track->v_height);
break;
default:
ebml_read_skip(s, &l);
break;
}
length -= l + il;
} }
return len; if (video.n_display_width) {
track->v_dwidth = video.display_width;
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Display width: %u\n",
track->v_dwidth);
}
if (video.n_display_height) {
track->v_dheight = video.display_height;
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Display height: %u\n",
track->v_dheight);
}
if (video.n_pixel_width) {
track->v_width = video.pixel_width;
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Pixel width: %u\n",
track->v_width);
}
if (video.n_pixel_height) {
track->v_height = video.pixel_height;
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Pixel height: %u\n",
track->v_height);
}
talloc_free(parse_ctx.talloc_ctx);
return parse_ctx.bytes_read;
} }
/** /**