annotate libmpcodecs/vd_theora.c @ 30504:cc27da5d7286

Mark all ad_info_t/vd_info_t structure declarations as const.
author diego
date Fri, 12 Feb 2010 16:29:34 +0000
parents bbb6ebec87a0
children 9c07a0af62d8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
5 * it under the terms of the GNU General Public License as published by
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
14 * You should have received a copy of the GNU General Public License along
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
17 */
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
18
10094
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
19 #include <stdio.h>
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
20 #include <stdlib.h>
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
21 #include <stdarg.h>
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
22 #include <assert.h>
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
23
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
24 #include "config.h"
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
25 #include "mp_msg.h"
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
26 #include "help_mp.h"
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
27
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
28 #include "vd_internal.h"
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
29
30504
cc27da5d7286 Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents: 30421
diff changeset
30 static const vd_info_t info = {
10094
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
31 "Theora/VP3",
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
32 "theora",
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
33 "David Kuehling",
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
34 "www.theora.org",
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
35 "Theora project's VP3 codec"
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 LIBVD_EXTERN(theora)
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
39
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
40 #include <theora/theora.h>
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
41
10658
c5e7b34bfc19 Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents: 10251
diff changeset
42 #define THEORA_NUM_HEADER_PACKETS 3
c5e7b34bfc19 Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents: 10251
diff changeset
43
10094
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
44 // to set/get/query special features/parameters
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
45 static int control(sh_video_t *sh,int cmd,void* arg,...){
14763
2c4e30f37773 Theora fixes:
henry
parents: 14642
diff changeset
46 switch(cmd) {
2c4e30f37773 Theora fixes:
henry
parents: 14642
diff changeset
47 case VDCTRL_QUERY_FORMAT:
2c4e30f37773 Theora fixes:
henry
parents: 14642
diff changeset
48 if ((*((int*)arg)) == IMGFMT_YV12)
2c4e30f37773 Theora fixes:
henry
parents: 14642
diff changeset
49 return CONTROL_TRUE;
2c4e30f37773 Theora fixes:
henry
parents: 14642
diff changeset
50 return CONTROL_FALSE;
2c4e30f37773 Theora fixes:
henry
parents: 14642
diff changeset
51 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21499
diff changeset
52
10094
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
53 return CONTROL_UNKNOWN;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
54 }
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
55
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
56 typedef struct theora_struct_st {
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
57 theora_state st;
10658
c5e7b34bfc19 Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents: 10251
diff changeset
58 theora_comment cc;
10094
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
59 theora_info inf;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
60 } theora_struct_t;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
61
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 * init driver
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
64 */
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
65 static int init(sh_video_t *sh){
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
66 theora_struct_t *context = NULL;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
67 int failed = 1;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
68 int errorCode = 0;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
69 ogg_packet op;
10658
c5e7b34bfc19 Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents: 10251
diff changeset
70 int i;
10094
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
71
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
72 /* check whether video output format is supported */
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
73 switch(sh->codec->outfmt[sh->outfmtidx])
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
74 {
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
75 case IMGFMT_YV12: /* well, this should work... */ break;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21499
diff changeset
76 default:
10094
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
77 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
78 sh->codec->outfmt[sh->outfmtidx]);
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
79 return 0;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
80 }
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
81
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
82 /* 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
83 do
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
84 {
18879
cc65a585fdcc rm unnecesary casts from void* - part 3
reynaldo
parents: 18771
diff changeset
85 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
86 sh->context = context;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
87 if (!context)
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
88 break;
10658
c5e7b34bfc19 Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents: 10251
diff changeset
89
c5e7b34bfc19 Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents: 10251
diff changeset
90 theora_info_init(&context->inf);
c5e7b34bfc19 Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents: 10251
diff changeset
91 theora_comment_init(&context->cc);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21499
diff changeset
92
10658
c5e7b34bfc19 Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents: 10251
diff changeset
93 /* 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
94 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
95 {
c5e7b34bfc19 Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents: 10251
diff changeset
96 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
97 op.b_o_s = 1;
c5e7b34bfc19 Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents: 10251
diff changeset
98 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
99 {
c5e7b34bfc19 Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents: 10251
diff changeset
100 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
101 break;
c5e7b34bfc19 Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents: 10251
diff changeset
102 }
10094
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
103 }
10658
c5e7b34bfc19 Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents: 10251
diff changeset
104 if (errorCode)
c5e7b34bfc19 Theora-CVS update patch by Martin Drab <drab@kepler.fjfi.cvut.cz>
alex
parents: 10251
diff changeset
105 break;
10251
95dc2037fb27 just updated vd_theora.c to decode the additional header packets,
arpi
parents: 10094
diff changeset
106
95dc2037fb27 just updated vd_theora.c to decode the additional header packets,
arpi
parents: 10094
diff changeset
107 /* now init codec */
10094
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
108 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
109 if (errorCode)
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
110 {
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
111 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
112 errorCode);
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
113 break;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
114 }
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
115 failed = 0;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
116 } while (0);
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
117
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
118 if (failed)
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 if (context)
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 free (context);
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
123 sh->context = NULL;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
124 }
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
125 return 0;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
126 }
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
127
12761
236b49c548a5 Use aspect ratio from Theora context. Patch by j at v2v dot cc
mosu
parents: 10658
diff changeset
128 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
129 {
14763
2c4e30f37773 Theora fixes:
henry
parents: 14642
diff changeset
130 sh->aspect = (float)(context->inf.aspect_numerator * context->inf.frame_width)/
2c4e30f37773 Theora fixes:
henry
parents: 14642
diff changeset
131 (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
132 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21499
diff changeset
133
10094
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
134 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
135
14763
2c4e30f37773 Theora fixes:
henry
parents: 14642
diff changeset
136 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
137 }
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
138
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21499
diff changeset
139 /*
10094
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
140 * uninit driver
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 static void uninit(sh_video_t *sh)
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
143 {
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
144 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
145
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
146 if (context)
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
147 {
21499
2e6ebc42fa9a Fix memleak in theora decoder due to missing theora_comment_/theora_info_clear on uninit
reimar
parents: 18976
diff changeset
148 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
149 theora_comment_clear(&context->cc);
10094
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
150 theora_clear (&context->st);
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
151 free (context);
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 }
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
154
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 * decode frame
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
157 */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21499
diff changeset
158 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags)
10094
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 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
161 int errorCode = 0;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
162 ogg_packet op;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
163 yuv_buffer yuv;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
164 mp_image_t* mpi;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
165
14642
38572280e8e7 bzero is deprecated patch by Gianluigi Tiesi <mplayer at netfarm.it>
faust3
parents: 12761
diff changeset
166 memset (&op, 0, sizeof (op));
10094
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
167 op.bytes = len;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
168 op.packet = data;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
169 op.granulepos = -1;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
170
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
171 errorCode = theora_decode_packetin (&context->st, &op);
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
172 if (errorCode)
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
173 {
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
174 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
175 errorCode);
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
176 return NULL;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
177 }
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
178
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
179 errorCode = theora_decode_YUVout (&context->st, &yuv);
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
180 if (errorCode)
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
181 {
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
182 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
183 errorCode);
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
184 return 0;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
185 }
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
186
14781
28e19750b448 revert the flip part of vd_theora fix
henry
parents: 14763
diff changeset
187 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
188 if(!mpi) return NULL;
14781
28e19750b448 revert the flip part of vd_theora fix
henry
parents: 14763
diff changeset
189
28e19750b448 revert the flip part of vd_theora fix
henry
parents: 14763
diff changeset
190 mpi->planes[0]=yuv.y;
28e19750b448 revert the flip part of vd_theora fix
henry
parents: 14763
diff changeset
191 mpi->stride[0]=yuv.y_stride;
28e19750b448 revert the flip part of vd_theora fix
henry
parents: 14763
diff changeset
192 mpi->planes[1]=yuv.u;
28e19750b448 revert the flip part of vd_theora fix
henry
parents: 14763
diff changeset
193 mpi->stride[1]=yuv.uv_stride;
28e19750b448 revert the flip part of vd_theora fix
henry
parents: 14763
diff changeset
194 mpi->planes[2]=yuv.v;
28e19750b448 revert the flip part of vd_theora fix
henry
parents: 14763
diff changeset
195 mpi->stride[2]=yuv.uv_stride;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 21499
diff changeset
196
10094
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
197 return mpi;
5730f6098f98 theora video decoder, based on patch by David Kuehling <dvdkhlng@gmx.de>
arpi
parents:
diff changeset
198 }