Mercurial > mplayer.hg
comparison libmpcodecs/vd_theora.c @ 30890:1c92dce71f3d
add support for lavf style extradata in vd_theora
author | aurel |
---|---|
date | Thu, 18 Mar 2010 21:53:02 +0000 |
parents | ee0b9c3bbf29 |
children | fdcf76890a16 |
comparison
equal
deleted
inserted
replaced
30889:c0fe89cf9803 | 30890:1c92dce71f3d |
---|---|
25 #include "mp_msg.h" | 25 #include "mp_msg.h" |
26 #include "help_mp.h" | 26 #include "help_mp.h" |
27 | 27 |
28 #include "vd_internal.h" | 28 #include "vd_internal.h" |
29 | 29 |
30 #include "libavutil/intreadwrite.h" | |
31 | |
30 static const vd_info_t info = { | 32 static const vd_info_t info = { |
31 "Theora/VP3", | 33 "Theora/VP3", |
32 "theora", | 34 "theora", |
33 "David Kuehling", | 35 "David Kuehling", |
34 "www.theora.org", | 36 "www.theora.org", |
73 /* | 75 /* |
74 * init driver | 76 * init driver |
75 */ | 77 */ |
76 static int init(sh_video_t *sh){ | 78 static int init(sh_video_t *sh){ |
77 theora_struct_t *context = NULL; | 79 theora_struct_t *context = NULL; |
80 uint8_t *extradata = (uint8_t *)(sh->bih + 1); | |
81 int extradata_size = sh->bih->biSize - sizeof(*sh->bih); | |
78 int errorCode = 0; | 82 int errorCode = 0; |
79 ogg_packet op; | 83 ogg_packet op; |
80 int i; | 84 int i; |
81 | 85 |
82 context = calloc (sizeof (theora_struct_t), 1); | 86 context = calloc (sizeof (theora_struct_t), 1); |
88 theora_comment_init(&context->cc); | 92 theora_comment_init(&context->cc); |
89 | 93 |
90 /* Read all header packets, pass them to theora_decode_header. */ | 94 /* Read all header packets, pass them to theora_decode_header. */ |
91 for (i = 0; i < THEORA_NUM_HEADER_PACKETS; i++) | 95 for (i = 0; i < THEORA_NUM_HEADER_PACKETS; i++) |
92 { | 96 { |
97 if (extradata_size > 2) { | |
98 op.bytes = AV_RB16(extradata); | |
99 op.packet = extradata + 2; | |
100 op.b_o_s = 1; | |
101 if (extradata_size < op.bytes + 2) { | |
102 mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Theora header too small\n"); | |
103 goto err_out; | |
104 } | |
105 extradata += op.bytes + 2; | |
106 extradata_size -= op.bytes + 2; | |
107 } else { | |
93 op.bytes = ds_get_packet (sh->ds, &op.packet); | 108 op.bytes = ds_get_packet (sh->ds, &op.packet); |
94 op.b_o_s = 1; | 109 op.b_o_s = 1; |
110 } | |
111 | |
95 if ( (errorCode = theora_decode_header (&context->inf, &context->cc, &op)) ) | 112 if ( (errorCode = theora_decode_header (&context->inf, &context->cc, &op)) ) |
96 { | 113 { |
97 mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Broken Theora header; errorCode=%i!\n", errorCode); | 114 mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Broken Theora header; errorCode=%i!\n", errorCode); |
98 goto err_out; | 115 goto err_out; |
99 } | 116 } |