Mercurial > mplayer.hg
annotate libmpcodecs/vd_theora.c @ 22872:f206b9a19192
mention most RTSP changes
author | cehoyos |
---|---|
date | Sun, 01 Apr 2007 13:16:54 +0000 |
parents | 2e6ebc42fa9a |
children | 0f1b5b68af32 |
rev | line source |
---|---|
10094
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
1 #include <stdio.h> |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
2 #include <stdlib.h> |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
3 #include <stdarg.h> |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
4 #include <assert.h> |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
5 |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
6 #include "config.h" |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
7 #include "mp_msg.h" |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
8 #include "help_mp.h" |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
9 |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
10 #include "vd_internal.h" |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
11 |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
12 static vd_info_t info = { |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
13 "Theora/VP3", |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
14 "theora", |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
15 "David Kuehling", |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
16 "www.theora.org", |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
17 "Theora project's VP3 codec" |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
18 }; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
19 |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
20 LIBVD_EXTERN(theora) |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
21 |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
22 #include <theora/theora.h> |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
23 |
10658
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
24 #define THEORA_NUM_HEADER_PACKETS 3 |
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
25 |
10094
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
26 // to set/get/query special features/parameters |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
27 static int control(sh_video_t *sh,int cmd,void* arg,...){ |
14763 | 28 switch(cmd) { |
29 case VDCTRL_QUERY_FORMAT: | |
30 if ((*((int*)arg)) == IMGFMT_YV12) | |
31 return CONTROL_TRUE; | |
32 return CONTROL_FALSE; | |
33 } | |
34 | |
10094
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
35 return CONTROL_UNKNOWN; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
36 } |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
37 |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
38 typedef struct theora_struct_st { |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
39 theora_state st; |
10658
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
40 theora_comment cc; |
10094
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
41 theora_info inf; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
42 } theora_struct_t; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
43 |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
44 /* |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
45 * init driver |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
46 */ |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
47 static int init(sh_video_t *sh){ |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
48 theora_struct_t *context = NULL; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
49 int failed = 1; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
50 int errorCode = 0; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
51 ogg_packet op; |
10658
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
52 int i; |
10094
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
53 |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
54 /* check whether video output format is supported */ |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
55 switch(sh->codec->outfmt[sh->outfmtidx]) |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
56 { |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
57 case IMGFMT_YV12: /* well, this should work... */ break; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
58 default: |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
59 mp_msg (MSGT_DECVIDEO,MSGL_ERR,"Unsupported out_fmt: 0x%X\n", |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
60 sh->codec->outfmt[sh->outfmtidx]); |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
61 return 0; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
62 } |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
63 |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
64 /* this is not a loop, just a context, from which we can break on error */ |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
65 do |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
66 { |
18879 | 67 context = calloc (sizeof (theora_struct_t), 1); |
10094
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
68 sh->context = context; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
69 if (!context) |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
70 break; |
10658
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
71 |
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
72 theora_info_init(&context->inf); |
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
73 theora_comment_init(&context->cc); |
10094
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
74 |
10658
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
75 /* Read all header packets, pass them to theora_decode_header. */ |
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
76 for (i = 0; i < THEORA_NUM_HEADER_PACKETS; i++) |
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
77 { |
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
78 op.bytes = ds_get_packet (sh->ds, &op.packet); |
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
79 op.b_o_s = 1; |
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
80 if ( (errorCode = theora_decode_header (&context->inf, &context->cc, &op)) ) |
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
81 { |
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
82 mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Broken Theora header; errorCode=%i!\n", errorCode); |
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
83 break; |
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
84 } |
10094
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
85 } |
10658
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
86 if (errorCode) |
c5e7b34bfc19
Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents:
10251
diff
changeset
|
87 break; |
10251
95dc2037fb27
just updated vd_theora.c to decode the additional header packets,
arpi
parents:
10094
diff
changeset
|
88 |
95dc2037fb27
just updated vd_theora.c to decode the additional header packets,
arpi
parents:
10094
diff
changeset
|
89 /* now init codec */ |
10094
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
90 errorCode = theora_decode_init (&context->st, &context->inf); |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
91 if (errorCode) |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
92 { |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
93 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Theora decode init failed: %i \n", |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
94 errorCode); |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
95 break; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
96 } |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
97 failed = 0; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
98 } while (0); |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
99 |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
100 if (failed) |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
101 { |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
102 if (context) |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
103 { |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
104 free (context); |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
105 sh->context = NULL; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
106 } |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
107 return 0; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
108 } |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
109 |
12761
236b49c548a5
Use aspect ratio from Theora context. Patch by j at v2v dot cc
mosu
parents:
10658
diff
changeset
|
110 if(sh->aspect==0.0 && context->inf.aspect_denominator!=0) |
236b49c548a5
Use aspect ratio from Theora context. Patch by j at v2v dot cc
mosu
parents:
10658
diff
changeset
|
111 { |
14763 | 112 sh->aspect = (float)(context->inf.aspect_numerator * context->inf.frame_width)/ |
113 (context->inf.aspect_denominator * context->inf.frame_height); | |
12761
236b49c548a5
Use aspect ratio from Theora context. Patch by j at v2v dot cc
mosu
parents:
10658
diff
changeset
|
114 } |
236b49c548a5
Use aspect ratio from Theora context. Patch by j at v2v dot cc
mosu
parents:
10658
diff
changeset
|
115 |
10094
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
116 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Theora video init ok!\n"); |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
117 |
14763 | 118 return mpcodecs_config_vo (sh,context->inf.frame_width,context->inf.frame_height,IMGFMT_YV12); |
10094
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
119 } |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
120 |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
121 /* |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
122 * uninit driver |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
123 */ |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
124 static void uninit(sh_video_t *sh) |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
125 { |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
126 theora_struct_t *context = (theora_struct_t *)sh->context; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
127 |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
128 if (context) |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
129 { |
21499
2e6ebc42fa9a
Fix memleak in theora decoder due to missing theora_comment_/theora_info_clear on uninit
reimar
parents:
18976
diff
changeset
|
130 theora_info_clear(&context->inf); |
2e6ebc42fa9a
Fix memleak in theora decoder due to missing theora_comment_/theora_info_clear on uninit
reimar
parents:
18976
diff
changeset
|
131 theora_comment_clear(&context->cc); |
10094
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
132 theora_clear (&context->st); |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
133 free (context); |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
134 } |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
135 } |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
136 |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
137 /* |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
138 * decode frame |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
139 */ |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
140 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags) |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
141 { |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
142 theora_struct_t *context = (theora_struct_t *)sh->context; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
143 int errorCode = 0; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
144 ogg_packet op; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
145 yuv_buffer yuv; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
146 mp_image_t* mpi; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
147 |
14642
38572280e8e7
bzero is deprecated patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents:
12761
diff
changeset
|
148 memset (&op, 0, sizeof (op)); |
10094
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
149 op.bytes = len; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
150 op.packet = data; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
151 op.granulepos = -1; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
152 |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
153 errorCode = theora_decode_packetin (&context->st, &op); |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
154 if (errorCode) |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
155 { |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
156 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Theora decode packetin failed: %i \n", |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
157 errorCode); |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
158 return NULL; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
159 } |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
160 |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
161 errorCode = theora_decode_YUVout (&context->st, &yuv); |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
162 if (errorCode) |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
163 { |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
164 mp_msg(MSGT_DEMUX,MSGL_ERR,"Theora decode YUVout failed: %i \n", |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
165 errorCode); |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
166 return 0; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
167 } |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
168 |
14781 | 169 mpi = mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, yuv.y_width, yuv.y_height); |
10094
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
170 if(!mpi) return NULL; |
14781 | 171 |
172 mpi->planes[0]=yuv.y; | |
173 mpi->stride[0]=yuv.y_stride; | |
174 mpi->planes[1]=yuv.u; | |
175 mpi->stride[1]=yuv.uv_stride; | |
176 mpi->planes[2]=yuv.v; | |
177 mpi->stride[2]=yuv.uv_stride; | |
14763 | 178 |
10094
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
179 return mpi; |
5730f6098f98
theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff
changeset
|
180 } |