1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-30 19:52:14 +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)) {
case MATROSKA_ID_FRAMERATE:
fnum = ebml_read_float(s, &l);
if (fnum == EBML_FLOAT_INVALID)
return 0; return 0;
track->v_frate = fnum; if (video.n_frame_rate) {
track->v_frate = video.frame_rate;
mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Frame rate: %f\n", mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Frame rate: %f\n",
track->v_frate); track->v_frate);
// XXX default_duration should take priority
if (track->v_frate > 0) if (track->v_frate > 0)
track->default_duration = 1 / track->v_frate; track->default_duration = 1 / track->v_frate;
break; }
if (video.n_display_width) {
case MATROSKA_ID_DISPLAYWIDTH: track->v_dwidth = video.display_width;
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", mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Display width: %u\n",
track->v_dwidth); track->v_dwidth);
break; }
if (video.n_display_height) {
case MATROSKA_ID_DISPLAYHEIGHT: track->v_dheight = video.display_height;
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", mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Display height: %u\n",
track->v_dheight); track->v_dheight);
break; }
if (video.n_pixel_width) {
case MATROSKA_ID_PIXELWIDTH: track->v_width = video.pixel_width;
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", mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Pixel width: %u\n",
track->v_width); track->v_width);
break; }
if (video.n_pixel_height) {
case MATROSKA_ID_PIXELHEIGHT: track->v_height = video.pixel_height;
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", mp_msg(MSGT_DEMUX, MSGL_V, "[mkv] | + Pixel height: %u\n",
track->v_height); track->v_height);
break;
default:
ebml_read_skip(s, &l);
break;
} }
length -= l + il; talloc_free(parse_ctx.talloc_ctx);
} return parse_ctx.bytes_read;
return len;
} }
/** /**