Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 393 lines (327 sloc) 13.819 kB
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
1 /*
2 * Dirac decoder support via Schroedinger libraries
3 * Copyright (c) 2008 BBC, Anuradha Suraparaju <asuraparaju at gmail dot com >
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
ba87f08 @DonDiego Remove explicit filename from Doxygen @file commands.
DonDiego authored
23 * @file
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
24 * Dirac decoder support via libschroedinger-1.0 libraries. More details about
25 * the Schroedinger project can be found at http://www.diracvideo.org/.
26 * The library implements Dirac Specification Version 2.2.
27 * (http://dirac.sourceforge.net/specification.html).
28 */
29
7ffe76e Merge libavcore into libavutil
Reinhard Tartler authored
30 #include "libavutil/imgutils.h"
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
31 #include "libavutil/intreadwrite.h"
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
32 #include "avcodec.h"
33 #include "libschroedinger.h"
34
35 #include <schroedinger/schro.h>
36 #include <schroedinger/schrodebug.h>
37 #include <schroedinger/schrovideoformat.h>
38
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
39 /** SchroFrame and Pts relation */
40 typedef struct LibSchroFrameContext {
41 SchroFrame *frame;
42 int64_t pts;
43 } LibSchroFrameContext;
44
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
45 /** libschroedinger decoder private data */
45235d6 @DonDiego libdirac/libschroedinger: Drop unnecessary symbol prefixes.
DonDiego authored
46 typedef struct SchroDecoderParams {
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
47 /** Schroedinger video format */
48 SchroVideoFormat *format;
49
50 /** Schroedinger frame format */
51 SchroFrameFormat frame_format;
52
53 /** decoder handle */
54 SchroDecoder* decoder;
55
56 /** queue storing decoded frames */
9cef066 @DonDiego Move code shared between libdirac and libschroedinger to libschroedin…
DonDiego authored
57 FFSchroQueue dec_frame_queue;
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
58
59 /** end of sequence signalled */
60 int eos_signalled;
61
62 /** end of sequence pulled */
63 int eos_pulled;
64
65 /** decoded picture */
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
66 AVFrame dec_frame;
45235d6 @DonDiego libdirac/libschroedinger: Drop unnecessary symbol prefixes.
DonDiego authored
67 } SchroDecoderParams;
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
68
45235d6 @DonDiego libdirac/libschroedinger: Drop unnecessary symbol prefixes.
DonDiego authored
69 typedef struct SchroParseUnitContext {
733cec1 Parse frames to feed the decoder with individual parse units.
Anuradha Suraparaju authored
70 const uint8_t *buf;
71 int buf_size;
45235d6 @DonDiego libdirac/libschroedinger: Drop unnecessary symbol prefixes.
DonDiego authored
72 } SchroParseUnitContext;
733cec1 Parse frames to feed the decoder with individual parse units.
Anuradha Suraparaju authored
73
74
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
75 static void libschroedinger_decode_buffer_free(SchroBuffer *schro_buf,
1f4f752 @DonDiego libschroedinger: Move a function to avoid a forward declaration.
DonDiego authored
76 void *priv)
77 {
78 av_freep(&priv);
79 }
733cec1 Parse frames to feed the decoder with individual parse units.
Anuradha Suraparaju authored
80
fdc9186 @DonDiego libschroedinger: Switch to function names more in line with Libav style.
DonDiego authored
81 static void parse_context_init(SchroParseUnitContext *parse_ctx,
82 const uint8_t *buf, int buf_size)
733cec1 Parse frames to feed the decoder with individual parse units.
Anuradha Suraparaju authored
83 {
84 parse_ctx->buf = buf;
85 parse_ctx->buf_size = buf_size;
86 }
87
fdc9186 @DonDiego libschroedinger: Switch to function names more in line with Libav style.
DonDiego authored
88 static SchroBuffer *find_next_parse_unit(SchroParseUnitContext *parse_ctx)
733cec1 Parse frames to feed the decoder with individual parse units.
Anuradha Suraparaju authored
89 {
90 SchroBuffer *enc_buf = NULL;
91 int next_pu_offset = 0;
92 unsigned char *in_buf;
93
94 if (parse_ctx->buf_size < 13 ||
95 parse_ctx->buf[0] != 'B' ||
96 parse_ctx->buf[1] != 'B' ||
97 parse_ctx->buf[2] != 'C' ||
98 parse_ctx->buf[3] != 'D')
99 return NULL;
100
101 next_pu_offset = (parse_ctx->buf[5] << 24) +
102 (parse_ctx->buf[6] << 16) +
103 (parse_ctx->buf[7] << 8) +
104 parse_ctx->buf[8];
105
106 if (next_pu_offset == 0 &&
107 SCHRO_PARSE_CODE_IS_END_OF_SEQUENCE(parse_ctx->buf[4]))
108 next_pu_offset = 13;
109
110 if (next_pu_offset <= 0 || parse_ctx->buf_size < next_pu_offset)
111 return NULL;
112
113 in_buf = av_malloc(next_pu_offset);
a7fa5ce @nenjordi libschroedingerdec: check malloc
nenjordi authored
114 if (!in_buf) {
115 av_log(parse_ctx, AV_LOG_ERROR, "Unable to allocate input buffer\n");
116 return NULL;
117 }
118
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
119 memcpy(in_buf, parse_ctx->buf, next_pu_offset);
120 enc_buf = schro_buffer_new_with_data(in_buf, next_pu_offset);
733cec1 Parse frames to feed the decoder with individual parse units.
Anuradha Suraparaju authored
121 enc_buf->free = libschroedinger_decode_buffer_free;
122 enc_buf->priv = in_buf;
123
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
124 parse_ctx->buf += next_pu_offset;
733cec1 Parse frames to feed the decoder with individual parse units.
Anuradha Suraparaju authored
125 parse_ctx->buf_size -= next_pu_offset;
126
127 return enc_buf;
128 }
129
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
130 /**
2d2b5a1 @michaelni 10l, commit that should have been stashed into the merge.
michaelni authored
131 * Returns FFmpeg chroma format.
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
132 */
45235d6 @DonDiego libdirac/libschroedinger: Drop unnecessary symbol prefixes.
DonDiego authored
133 static enum PixelFormat get_chroma_format(SchroChromaFormat schro_pix_fmt)
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
134 {
45235d6 @DonDiego libdirac/libschroedinger: Drop unnecessary symbol prefixes.
DonDiego authored
135 int num_formats = sizeof(schro_pixel_format_map) /
136 sizeof(schro_pixel_format_map[0]);
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
137 int idx;
138
735a380 @DonDiego Remove useless braces around if/for/while expressions.
DonDiego authored
139 for (idx = 0; idx < num_formats; ++idx)
45235d6 @DonDiego libdirac/libschroedinger: Drop unnecessary symbol prefixes.
DonDiego authored
140 if (schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt)
141 return schro_pixel_format_map[idx].ff_pix_fmt;
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
142 return PIX_FMT_NONE;
143 }
144
5ef251e @danielverkamp Add missing av_cold in static init/close functions.
danielverkamp authored
145 static av_cold int libschroedinger_decode_init(AVCodecContext *avccontext)
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
146 {
147
45235d6 @DonDiego libdirac/libschroedinger: Drop unnecessary symbol prefixes.
DonDiego authored
148 SchroDecoderParams *p_schro_params = avccontext->priv_data;
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
149 /* First of all, initialize our supporting libraries. */
150 schro_init();
151
152 schro_debug_set_level(avccontext->debug);
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
153 p_schro_params->decoder = schro_decoder_new();
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
154 schro_decoder_set_skip_ratio(p_schro_params->decoder, 1);
155
156 if (!p_schro_params->decoder)
157 return -1;
158
159 /* Initialize the decoded frame queue. */
9cef066 @DonDiego Move code shared between libdirac and libschroedinger to libschroedin…
DonDiego authored
160 ff_schro_queue_init(&p_schro_params->dec_frame_queue);
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
161 return 0;
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
162 }
163
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
164 static void libschroedinger_decode_frame_free(void *frame)
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
165 {
166 schro_frame_unref(frame);
167 }
168
169 static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext)
170 {
45235d6 @DonDiego libdirac/libschroedinger: Drop unnecessary symbol prefixes.
DonDiego authored
171 SchroDecoderParams *p_schro_params = avccontext->priv_data;
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
172 SchroDecoder *decoder = p_schro_params->decoder;
173
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
174 p_schro_params->format = schro_decoder_get_video_format(decoder);
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
175
2d2b5a1 @michaelni 10l, commit that should have been stashed into the merge.
michaelni authored
176 /* Tell FFmpeg about sequence details. */
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
177 if (av_image_check_size(p_schro_params->format->width,
178 p_schro_params->format->height, 0, avccontext) < 0) {
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
179 av_log(avccontext, AV_LOG_ERROR, "invalid dimensions (%dx%d)\n",
180 p_schro_params->format->width, p_schro_params->format->height);
181 avccontext->height = avccontext->width = 0;
35027ed Do not return -1 from void functions.
Carl Eugen Hoyos authored
182 return;
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
183 }
184 avccontext->height = p_schro_params->format->height;
185 avccontext->width = p_schro_params->format->width;
45235d6 @DonDiego libdirac/libschroedinger: Drop unnecessary symbol prefixes.
DonDiego authored
186 avccontext->pix_fmt = get_chroma_format(p_schro_params->format->chroma_format);
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
187
188 if (ff_get_schro_frame_format(p_schro_params->format->chroma_format,
189 &p_schro_params->frame_format) == -1) {
190 av_log(avccontext, AV_LOG_ERROR,
191 "This codec currently only supports planar YUV 4:2:0, 4:2:2 "
192 "and 4:4:4 formats.\n");
35027ed Do not return -1 from void functions.
Carl Eugen Hoyos authored
193 return;
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
194 }
195
196 avccontext->time_base.den = p_schro_params->format->frame_rate_numerator;
197 avccontext->time_base.num = p_schro_params->format->frame_rate_denominator;
198 }
199
200 static int libschroedinger_decode_frame(AVCodecContext *avccontext,
201 void *data, int *data_size,
7a00bba Implement avcodec_decode_video2(), _audio3() and _subtitle2() which t…
Thilo Borgmann authored
202 AVPacket *avpkt)
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
203 {
7a00bba Implement avcodec_decode_video2(), _audio3() and _subtitle2() which t…
Thilo Borgmann authored
204 const uint8_t *buf = avpkt->data;
205 int buf_size = avpkt->size;
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
206 int64_t pts = avpkt->pts;
207 SchroTag *tag;
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
208
45235d6 @DonDiego libdirac/libschroedinger: Drop unnecessary symbol prefixes.
DonDiego authored
209 SchroDecoderParams *p_schro_params = avccontext->priv_data;
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
210 SchroDecoder *decoder = p_schro_params->decoder;
211 SchroBuffer *enc_buf;
212 SchroFrame* frame;
213 int state;
214 int go = 1;
733cec1 Parse frames to feed the decoder with individual parse units.
Anuradha Suraparaju authored
215 int outer = 1;
45235d6 @DonDiego libdirac/libschroedinger: Drop unnecessary symbol prefixes.
DonDiego authored
216 SchroParseUnitContext parse_ctx;
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
217 LibSchroFrameContext *framewithpts = NULL;
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
218
219 *data_size = 0;
220
fdc9186 @DonDiego libschroedinger: Switch to function names more in line with Libav style.
DonDiego authored
221 parse_context_init(&parse_ctx, buf, buf_size);
7c809dc @DonDiego Simplify 'if' condition statements.
DonDiego authored
222 if (!buf_size) {
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
223 if (!p_schro_params->eos_signalled) {
224 state = schro_decoder_push_end_of_stream(decoder);
225 p_schro_params->eos_signalled = 1;
226 }
227 }
228
733cec1 Parse frames to feed the decoder with individual parse units.
Anuradha Suraparaju authored
229 /* Loop through all the individual parse units in the input buffer */
230 do {
fdc9186 @DonDiego libschroedinger: Switch to function names more in line with Libav style.
DonDiego authored
231 if ((enc_buf = find_next_parse_unit(&parse_ctx))) {
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
232 /* Set Schrotag with the pts to be recovered after decoding*/
233 enc_buf->tag = schro_tag_new(av_malloc(sizeof(int64_t)), av_free);
234 if (!enc_buf->tag->value) {
235 av_log(avccontext, AV_LOG_ERROR, "Unable to allocate SchroTag\n");
236 return AVERROR(ENOMEM);
237 }
238 AV_WN(64, enc_buf->tag->value, pts);
733cec1 Parse frames to feed the decoder with individual parse units.
Anuradha Suraparaju authored
239 /* Push buffer into decoder. */
64bfc58 Fix incorrectly constructed Dirac parse units that caused A/V sync loss.
Anuradha Suraparaju authored
240 if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) &&
241 SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0)
242 avccontext->has_b_frames = 1;
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
243 state = schro_decoder_push(decoder, enc_buf);
733cec1 Parse frames to feed the decoder with individual parse units.
Anuradha Suraparaju authored
244 if (state == SCHRO_DECODER_FIRST_ACCESS_UNIT)
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
245 libschroedinger_handle_first_access_unit(avccontext);
733cec1 Parse frames to feed the decoder with individual parse units.
Anuradha Suraparaju authored
246 go = 1;
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
247 } else
733cec1 Parse frames to feed the decoder with individual parse units.
Anuradha Suraparaju authored
248 outer = 0;
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
249
250 while (go) {
251 /* Parse data and process result. */
252 state = schro_decoder_wait(decoder);
253 switch (state) {
254 case SCHRO_DECODER_FIRST_ACCESS_UNIT:
255 libschroedinger_handle_first_access_unit(avccontext);
256 break;
257
258 case SCHRO_DECODER_NEED_BITS:
259 /* Need more input data - stop iterating over what we have. */
260 go = 0;
261 break;
262
263 case SCHRO_DECODER_NEED_FRAME:
264 /* Decoder needs a frame - create one and push it in. */
d15f2e0 Fix bug caused by difference in stride and picture width.
Anuradha Suraparaju authored
265 frame = ff_create_schro_frame(avccontext,
266 p_schro_params->frame_format);
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
267 schro_decoder_add_output_picture(decoder, frame);
268 break;
269
270 case SCHRO_DECODER_OK:
271 /* Pull a frame out of the decoder. */
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
272 tag = schro_decoder_get_picture_tag(decoder);
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
273 frame = schro_decoder_pull(decoder);
274
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
275 if (frame) {
276 /* Add relation between schroframe and pts. */
277 framewithpts = av_malloc(sizeof(LibSchroFrameContext));
278 if (!framewithpts) {
279 av_log(avccontext, AV_LOG_ERROR, "Unable to allocate FrameWithPts\n");
280 return AVERROR(ENOMEM);
281 }
282 framewithpts->frame = frame;
283 framewithpts->pts = AV_RN64(tag->value);
9cef066 @DonDiego Move code shared between libdirac and libschroedinger to libschroedin…
DonDiego authored
284 ff_schro_queue_push_back(&p_schro_params->dec_frame_queue,
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
285 framewithpts);
286 }
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
287 break;
288 case SCHRO_DECODER_EOS:
289 go = 0;
290 p_schro_params->eos_pulled = 1;
291 schro_decoder_reset(decoder);
292 outer = 0;
293 break;
294
295 case SCHRO_DECODER_ERROR:
296 return -1;
297 break;
298 }
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
299 }
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
300 } while (outer);
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
301
302 /* Grab next frame to be returned from the top of the queue. */
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
303 framewithpts = ff_schro_queue_pop(&p_schro_params->dec_frame_queue);
304
305 if (framewithpts && framewithpts->frame) {
306 if (p_schro_params->dec_frame.data[0])
307 avccontext->release_buffer(avccontext, &p_schro_params->dec_frame);
308 if (avccontext->get_buffer(avccontext, &p_schro_params->dec_frame) < 0) {
309 av_log(avccontext, AV_LOG_ERROR, "Unable to allocate buffer\n");
310 return AVERROR(ENOMEM);
311 }
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
312
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
313 memcpy(p_schro_params->dec_frame.data[0],
314 framewithpts->frame->components[0].data,
315 framewithpts->frame->components[0].length);
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
316
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
317 memcpy(p_schro_params->dec_frame.data[1],
318 framewithpts->frame->components[1].data,
319 framewithpts->frame->components[1].length);
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
320
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
321 memcpy(p_schro_params->dec_frame.data[2],
322 framewithpts->frame->components[2].data,
323 framewithpts->frame->components[2].length);
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
324
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
325 /* Fill frame with current buffer data from Schroedinger. */
326 p_schro_params->dec_frame.format = -1; /* Unknown -1 */
327 p_schro_params->dec_frame.width = framewithpts->frame->width;
328 p_schro_params->dec_frame.height = framewithpts->frame->height;
329 p_schro_params->dec_frame.pkt_pts = framewithpts->pts;
330 p_schro_params->dec_frame.linesize[0] = framewithpts->frame->components[0].stride;
331 p_schro_params->dec_frame.linesize[1] = framewithpts->frame->components[1].stride;
332 p_schro_params->dec_frame.linesize[2] = framewithpts->frame->components[2].stride;
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
333
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
334 *(AVFrame*)data = p_schro_params->dec_frame;
335 *data_size = sizeof(AVFrame);
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
336
337 /* Now free the frame resources. */
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
338 libschroedinger_decode_frame_free(framewithpts->frame);
339 av_free(framewithpts);
340 } else {
341 data = NULL;
342 *data_size = 0;
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
343 }
344 return buf_size;
345 }
346
347
5ef251e @danielverkamp Add missing av_cold in static init/close functions.
danielverkamp authored
348 static av_cold int libschroedinger_decode_close(AVCodecContext *avccontext)
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
349 {
45235d6 @DonDiego libdirac/libschroedinger: Drop unnecessary symbol prefixes.
DonDiego authored
350 SchroDecoderParams *p_schro_params = avccontext->priv_data;
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
351 /* Free the decoder. */
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
352 schro_decoder_free(p_schro_params->decoder);
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
353 av_freep(&p_schro_params->format);
354
38f06a1 @nenjordi libschroedingerdec: Change AVPicture to AVFrame and use SchroTag to s…
nenjordi authored
355 if (p_schro_params->dec_frame.data[0])
356 avccontext->release_buffer(avccontext, &p_schro_params->dec_frame);
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
357
358 /* Free data in the output frame queue. */
9cef066 @DonDiego Move code shared between libdirac and libschroedinger to libschroedin…
DonDiego authored
359 ff_schro_queue_free(&p_schro_params->dec_frame_queue,
360 libschroedinger_decode_frame_free);
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
361
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
362 return 0;
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
363 }
364
0ebe3b8 @DonDiego cosmetics: indentation, prettyprinting, K&R coding style
DonDiego authored
365 static void libschroedinger_flush(AVCodecContext *avccontext)
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
366 {
367 /* Got a seek request. Free the decoded frames queue and then reset
368 * the decoder */
45235d6 @DonDiego libdirac/libschroedinger: Drop unnecessary symbol prefixes.
DonDiego authored
369 SchroDecoderParams *p_schro_params = avccontext->priv_data;
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
370
371 /* Free data in the output frame queue. */
9cef066 @DonDiego Move code shared between libdirac and libschroedinger to libschroedin…
DonDiego authored
372 ff_schro_queue_free(&p_schro_params->dec_frame_queue,
373 libschroedinger_decode_frame_free);
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
374
9cef066 @DonDiego Move code shared between libdirac and libschroedinger to libschroedin…
DonDiego authored
375 ff_schro_queue_init(&p_schro_params->dec_frame_queue);
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
376 schro_decoder_reset(p_schro_params->decoder);
377 p_schro_params->eos_pulled = 0;
378 p_schro_params->eos_signalled = 0;
379 }
380
e7e2df2 @Flameeyes Add ff_ prefix to data symbols of encoders, decoders, hwaccel, parser…
Flameeyes authored
381 AVCodec ff_libschroedinger_decoder = {
ec6402b @elenril lavc: use designated initialisers for all codecs.
elenril authored
382 .name = "libschroedinger",
383 .type = AVMEDIA_TYPE_VIDEO,
36ef536 @elenril Replace all CODEC_ID_* with AV_CODEC_ID_*
elenril authored
384 .id = AV_CODEC_ID_DIRAC,
45235d6 @DonDiego libdirac/libschroedinger: Drop unnecessary symbol prefixes.
DonDiego authored
385 .priv_data_size = sizeof(SchroDecoderParams),
ec6402b @elenril lavc: use designated initialisers for all codecs.
elenril authored
386 .init = libschroedinger_decode_init,
387 .close = libschroedinger_decode_close,
388 .decode = libschroedinger_decode_frame,
389 .capabilities = CODEC_CAP_DELAY,
00c3b67 @mstorsjo cosmetics: Align codec declarations
mstorsjo authored
390 .flush = libschroedinger_flush,
391 .long_name = NULL_IF_CONFIG_SMALL("libschroedinger Dirac 2.2"),
f7cd9ee Add Dirac support through libschroedinger.
Anuradha Suraparaju authored
392 };
Something went wrong with that request. Please try again.