1 /*****************************************************************************
2 * theora.c: theora decoder module making use of libtheora.
3 *****************************************************************************
4 * Copyright (C) 1999-2001 VideoLAN
7 * Authors: Gildas Bazin <gbazin@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
28 #include <vlc/decoder.h>
29 #include <vlc/input.h>
34 #include <theora/theora.h>
36 /*****************************************************************************
37 * decoder_sys_t : theora decoder descriptor
38 *****************************************************************************/
42 vlc_bool_t b_packetizer;
52 theora_info ti; /* theora bitstream settings */
53 theora_comment tc; /* theora comment header */
54 theora_state td; /* theora bitstream user comments */
62 /*****************************************************************************
64 *****************************************************************************/
65 static int OpenDecoder ( vlc_object_t * );
66 static int OpenPacketizer( vlc_object_t * );
67 static void CloseDecoder ( vlc_object_t * );
69 static void *DecodeBlock ( decoder_t *, block_t ** );
70 static int ProcessHeaders( decoder_t * );
71 static void *ProcessPacket ( decoder_t *, ogg_packet *, block_t ** );
73 static picture_t *DecodePacket( decoder_t *, ogg_packet * );
75 static void ParseTheoraComments( decoder_t * );
76 static void theora_CopyPicture( decoder_t *, picture_t *, yuv_buffer * );
78 static int OpenEncoder( vlc_object_t *p_this );
79 static void CloseEncoder( vlc_object_t *p_this );
80 static block_t *Encode( encoder_t *p_enc, picture_t *p_pict );
82 /*****************************************************************************
84 *****************************************************************************/
85 #define ENC_QUALITY_TEXT N_("Encoding quality")
86 #define ENC_QUALITY_LONGTEXT N_( \
87 "Allows you to specify a quality between 1 (low) and 10 (high), instead " \
88 "of specifying a particular bitrate. This will produce a VBR stream." )
91 set_description( _("Theora video decoder") );
92 set_capability( "decoder", 100 );
93 set_callbacks( OpenDecoder, CloseDecoder );
94 add_shortcut( "theora" );
97 set_description( _("Theora video packetizer") );
98 set_capability( "packetizer", 100 );
99 set_callbacks( OpenPacketizer, CloseDecoder );
100 add_shortcut( "theora" );
103 set_description( _("Theora video encoder") );
104 set_capability( "encoder", 100 );
105 set_callbacks( OpenEncoder, CloseEncoder );
106 add_shortcut( "theora" );
108 # define ENC_CFG_PREFIX "sout-theora-"
109 add_integer( ENC_CFG_PREFIX "quality", 2, NULL, ENC_QUALITY_TEXT,
110 ENC_QUALITY_LONGTEXT, VLC_FALSE );
113 static const char *ppsz_enc_options[] = {
117 /*****************************************************************************
118 * OpenDecoder: probe the decoder and return score
119 *****************************************************************************/
120 static int OpenDecoder( vlc_object_t *p_this )
122 decoder_t *p_dec = (decoder_t*)p_this;
123 decoder_sys_t *p_sys;
125 if( p_dec->fmt_in.i_codec != VLC_FOURCC('t','h','e','o') )
130 /* Allocate the memory needed to store the decoder's structure */
131 if( ( p_dec->p_sys = p_sys =
132 (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
134 msg_Err( p_dec, "out of memory" );
137 p_dec->p_sys->b_packetizer = VLC_FALSE;
141 /* Set output properties */
142 p_dec->fmt_out.i_cat = VIDEO_ES;
143 p_dec->fmt_out.i_codec = VLC_FOURCC('I','4','2','0');
146 p_dec->pf_decode_video = (picture_t *(*)(decoder_t *, block_t **))
148 p_dec->pf_packetize = (block_t *(*)(decoder_t *, block_t **))
151 /* Init supporting Theora structures needed in header parsing */
152 theora_comment_init( &p_sys->tc );
153 theora_info_init( &p_sys->ti );
155 p_sys->i_headers = 0;
160 static int OpenPacketizer( vlc_object_t *p_this )
162 decoder_t *p_dec = (decoder_t*)p_this;
164 int i_ret = OpenDecoder( p_this );
166 if( i_ret == VLC_SUCCESS )
168 p_dec->p_sys->b_packetizer = VLC_TRUE;
169 p_dec->fmt_out.i_codec = VLC_FOURCC( 't', 'h', 'e', 'o' );
175 /****************************************************************************
176 * DecodeBlock: the whole thing
177 ****************************************************************************
178 * This function must be fed with ogg packets.
179 ****************************************************************************/
180 static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
182 decoder_sys_t *p_sys = p_dec->p_sys;
184 ogg_packet oggpacket;
186 if( !pp_block || !*pp_block ) return NULL;
190 /* Block to Ogg packet */
191 oggpacket.packet = p_block->p_buffer;
192 oggpacket.bytes = p_block->i_buffer;
193 oggpacket.granulepos = p_block->i_dts;
196 oggpacket.packetno = 0;
198 /* Check for headers */
199 if( p_sys->i_headers == 0 && p_dec->fmt_in.i_extra )
201 /* Headers already available as extra data */
202 p_sys->i_headers = 3;
204 else if( oggpacket.bytes && p_sys->i_headers < 3 )
206 /* Backup headers as extra data */
209 p_dec->fmt_in.p_extra =
210 realloc( p_dec->fmt_in.p_extra, p_dec->fmt_in.i_extra +
211 oggpacket.bytes + 2 );
212 p_extra = p_dec->fmt_in.p_extra + p_dec->fmt_in.i_extra;
213 *(p_extra++) = oggpacket.bytes >> 8;
214 *(p_extra++) = oggpacket.bytes & 0xFF;
216 memcpy( p_extra, oggpacket.packet, oggpacket.bytes );
217 p_dec->fmt_in.i_extra += oggpacket.bytes + 2;
219 block_Release( *pp_block );
224 if( p_sys->i_headers == 3 )
226 if( ProcessHeaders( p_dec ) != VLC_SUCCESS )
228 p_sys->i_headers = 0;
229 p_dec->fmt_in.i_extra = 0;
230 block_Release( *pp_block );
233 else p_sys->i_headers++;
236 return ProcessPacket( p_dec, &oggpacket, pp_block );
239 /*****************************************************************************
240 * ProcessHeaders: process Theora headers.
241 *****************************************************************************/
242 static int ProcessHeaders( decoder_t *p_dec )
244 decoder_sys_t *p_sys = p_dec->p_sys;
245 ogg_packet oggpacket;
249 if( !p_dec->fmt_in.i_extra ) return VLC_EGENERIC;
251 oggpacket.granulepos = -1;
252 oggpacket.b_o_s = 1; /* yes this actually is a b_o_s packet :) */
254 oggpacket.packetno = 0;
255 p_extra = p_dec->fmt_in.p_extra;
256 i_extra = p_dec->fmt_in.i_extra;
258 /* Take care of the initial Vorbis header */
259 oggpacket.bytes = *(p_extra++) << 8;
260 oggpacket.bytes |= (*(p_extra++) & 0xFF);
261 oggpacket.packet = p_extra;
262 p_extra += oggpacket.bytes;
263 i_extra -= (oggpacket.bytes + 2);
266 msg_Err( p_dec, "header data corrupted");
270 if( theora_decode_header( &p_sys->ti, &p_sys->tc, &oggpacket ) < 0 )
272 msg_Err( p_dec, "This bitstream does not contain Theora video data" );
276 /* Set output properties */
277 p_dec->fmt_out.video.i_width = p_sys->ti.width;
278 p_dec->fmt_out.video.i_height = p_sys->ti.height;
279 if( p_sys->ti.frame_width && p_sys->ti.frame_height )
281 p_dec->fmt_out.video.i_width = p_sys->ti.frame_width;
282 p_dec->fmt_out.video.i_height = p_sys->ti.frame_height;
285 if( p_sys->ti.aspect_denominator && p_sys->ti.aspect_numerator )
287 p_dec->fmt_out.video.i_aspect = ((int64_t)VOUT_ASPECT_FACTOR) *
288 ( p_sys->ti.aspect_numerator * p_sys->ti.width ) /
289 ( p_sys->ti.aspect_denominator * p_sys->ti.height );
293 p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR *
294 p_sys->ti.frame_width / p_sys->ti.frame_height;
297 msg_Dbg( p_dec, "%dx%d %.02f fps video, frame content "
298 "is %dx%d with offset (%d,%d)",
299 p_sys->ti.width, p_sys->ti.height,
300 (double)p_sys->ti.fps_numerator/p_sys->ti.fps_denominator,
301 p_sys->ti.frame_width, p_sys->ti.frame_height,
302 p_sys->ti.offset_x, p_sys->ti.offset_y );
304 /* The next packet in order is the comments header */
306 oggpacket.bytes = *(p_extra++) << 8;
307 oggpacket.bytes |= (*(p_extra++) & 0xFF);
308 oggpacket.packet = p_extra;
309 p_extra += oggpacket.bytes;
310 i_extra -= (oggpacket.bytes + 2);
313 msg_Err( p_dec, "header data corrupted");
317 /* The next packet in order is the comments header */
318 if( theora_decode_header( &p_sys->ti, &p_sys->tc, &oggpacket ) < 0 )
320 msg_Err( p_dec, "2nd Theora header is corrupted" );
324 ParseTheoraComments( p_dec );
326 /* The next packet in order is the codebooks header
327 * We need to watch out that this packet is not missing as a
328 * missing or corrupted header is fatal. */
329 oggpacket.bytes = *(p_extra++) << 8;
330 oggpacket.bytes |= (*(p_extra++) & 0xFF);
331 oggpacket.packet = p_extra;
332 i_extra -= (oggpacket.bytes + 2);
335 msg_Err( p_dec, "header data corrupted");
339 /* The next packet in order is the codebooks header
340 * We need to watch out that this packet is not missing as a
341 * missing or corrupted header is fatal */
342 if( theora_decode_header( &p_sys->ti, &p_sys->tc, &oggpacket ) < 0 )
344 msg_Err( p_dec, "3rd Theora header is corrupted" );
348 if( !p_sys->b_packetizer )
350 /* We have all the headers, initialize decoder */
351 theora_decode_init( &p_sys->td, &p_sys->ti );
355 p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
356 p_dec->fmt_out.p_extra =
357 realloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
358 memcpy( p_dec->fmt_out.p_extra,
359 p_dec->fmt_in.p_extra, p_dec->fmt_out.i_extra );
365 /*****************************************************************************
366 * ProcessPacket: processes a theora packet.
367 *****************************************************************************/
368 static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
371 decoder_sys_t *p_sys = p_dec->p_sys;
372 block_t *p_block = *pp_block;
375 /* Date management */
376 if( p_block->i_pts > 0 && p_block->i_pts != p_sys->i_pts )
378 p_sys->i_pts = p_block->i_pts;
381 *pp_block = NULL; /* To avoid being fed the same packet again */
383 if( p_sys->b_packetizer )
385 /* Date management */
386 p_block->i_dts = p_block->i_pts = p_sys->i_pts;
388 if( p_sys->i_headers >= 3 )
389 p_block->i_length = p_sys->i_pts - p_block->i_pts;
391 p_block->i_length = 0;
397 if( p_sys->i_headers >= 3 )
398 p_buf = DecodePacket( p_dec, p_oggpacket );
402 if( p_block ) block_Release( p_block );
405 /* Date management */
406 p_sys->i_pts += ( I64C(1000000) * p_sys->ti.fps_denominator /
407 p_sys->ti.fps_numerator ); /* 1 frame per packet */
412 /*****************************************************************************
413 * DecodePacket: decodes a Theora packet.
414 *****************************************************************************/
415 static picture_t *DecodePacket( decoder_t *p_dec, ogg_packet *p_oggpacket )
417 decoder_sys_t *p_sys = p_dec->p_sys;
421 theora_decode_packetin( &p_sys->td, p_oggpacket );
424 theora_decode_YUVout( &p_sys->td, &yuv );
426 /* Get a new picture */
427 p_pic = p_dec->pf_vout_buffer_new( p_dec );
428 if( !p_pic ) return NULL;
430 theora_CopyPicture( p_dec, p_pic, &yuv );
432 p_pic->date = p_sys->i_pts;
437 /*****************************************************************************
438 * ParseTheoraComments: FIXME should be done in demuxer
439 *****************************************************************************/
440 static void ParseTheoraComments( decoder_t *p_dec )
442 input_thread_t *p_input = (input_thread_t *)p_dec->p_parent;
443 char *psz_name, *psz_value, *psz_comment;
446 if( p_input->i_object_type != VLC_OBJECT_INPUT ) return;
448 while ( i < p_dec->p_sys->tc.comments )
450 psz_comment = strdup( p_dec->p_sys->tc.user_comments[i] );
453 msg_Warn( p_dec, "out of memory" );
456 psz_name = psz_comment;
457 psz_value = strchr( psz_comment, '=' );
462 input_Control( p_input, INPUT_ADD_INFO, _("Theora comment"),
463 psz_name, psz_value );
470 /*****************************************************************************
471 * CloseDecoder: theora decoder destruction
472 *****************************************************************************/
473 static void CloseDecoder( vlc_object_t *p_this )
475 decoder_t *p_dec = (decoder_t *)p_this;
476 decoder_sys_t *p_sys = p_dec->p_sys;
478 theora_info_clear( &p_sys->ti );
479 theora_comment_clear( &p_sys->tc );
484 /*****************************************************************************
485 * theora_CopyPicture: copy a picture from theora internal buffers to a
486 * picture_t structure.
487 *****************************************************************************/
488 static void theora_CopyPicture( decoder_t *p_dec, picture_t *p_pic,
491 int i_plane, i_line, i_width, i_dst_stride, i_src_stride;
492 int i_src_xoffset, i_src_yoffset;
493 uint8_t *p_dst, *p_src;
495 for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
497 p_dst = p_pic->p[i_plane].p_pixels;
498 p_src = i_plane ? (i_plane - 1 ? yuv->v : yuv->u ) : yuv->y;
499 i_width = p_pic->p[i_plane].i_visible_pitch;
500 i_dst_stride = p_pic->p[i_plane].i_pitch;
501 i_src_stride = i_plane ? yuv->uv_stride : yuv->y_stride;
502 i_src_xoffset = p_dec->p_sys->ti.offset_x;
503 i_src_yoffset = p_dec->p_sys->ti.offset_y;
510 p_src += (i_src_yoffset * i_src_stride + i_src_yoffset);
512 for( i_line = 0; i_line < p_pic->p[i_plane].i_visible_lines; i_line++ )
514 p_dec->p_vlc->pf_memcpy( p_dst, p_src, i_width );
515 p_src += i_src_stride;
516 p_dst += i_dst_stride;
521 /*****************************************************************************
522 * encoder_sys_t : theora encoder descriptor
523 *****************************************************************************/
529 vlc_bool_t b_headers;
534 theora_info ti; /* theora bitstream settings */
535 theora_comment tc; /* theora comment header */
536 theora_state td; /* theora bitstream user comments */
538 int i_width, i_height;
541 /*****************************************************************************
542 * OpenEncoder: probe the encoder and return score
543 *****************************************************************************/
544 static int OpenEncoder( vlc_object_t *p_this )
546 encoder_t *p_enc = (encoder_t *)p_this;
547 encoder_sys_t *p_sys = p_enc->p_sys;
553 if( p_enc->fmt_out.i_codec != VLC_FOURCC('t','h','e','o') &&
559 /* Allocate the memory needed to store the decoder's structure */
560 if( ( p_sys = (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
562 msg_Err( p_enc, "out of memory" );
565 p_enc->p_sys = p_sys;
567 p_enc->pf_encode_video = Encode;
568 p_enc->fmt_in.i_codec = VLC_FOURCC('I','4','2','0');
569 p_enc->fmt_out.i_codec = VLC_FOURCC('t','h','e','o');
571 sout_CfgParse( p_enc, ENC_CFG_PREFIX, ppsz_enc_options, p_enc->p_cfg );
573 var_Get( p_enc, ENC_CFG_PREFIX "quality", &val );
574 i_quality = val.i_int;
575 if( i_quality > 10 ) i_quality = 10;
576 if( i_quality < 0 ) i_quality = 0;
578 theora_info_init( &p_sys->ti );
580 p_sys->ti.width = p_enc->fmt_in.video.i_width;
581 p_sys->ti.height = p_enc->fmt_in.video.i_height;
583 if( p_sys->ti.width % 16 || p_sys->ti.height % 16 )
585 /* Pictures from the transcoder should always have a pitch
586 * which is a multiple of 16 */
587 p_sys->ti.width = (p_sys->ti.width + 15) >> 4 << 4;
588 p_sys->ti.height = (p_sys->ti.height + 15) >> 4 << 4;
590 msg_Dbg( p_enc, "padding video from %dx%d to %dx%d",
591 p_enc->fmt_in.video.i_width, p_enc->fmt_in.video.i_height,
592 p_sys->ti.width, p_sys->ti.height );
595 p_sys->ti.frame_width = p_enc->fmt_in.video.i_width;
596 p_sys->ti.frame_height = p_enc->fmt_in.video.i_height;
597 p_sys->ti.offset_x = 0 /*frame_x_offset*/;
598 p_sys->ti.offset_y = 0 /*frame_y_offset*/;
600 p_sys->i_width = p_sys->ti.width;
601 p_sys->i_height = p_sys->ti.height;
603 if( !p_enc->fmt_in.video.i_frame_rate ||
604 !p_enc->fmt_in.video.i_frame_rate_base )
606 p_sys->ti.fps_numerator = 25;
607 p_sys->ti.fps_denominator = 1;
611 p_sys->ti.fps_numerator = p_enc->fmt_in.video.i_frame_rate;
612 p_sys->ti.fps_denominator = p_enc->fmt_in.video.i_frame_rate_base;
615 if( p_enc->fmt_in.video.i_aspect )
617 int64_t i_num, i_den;
618 int i_dst_num, i_dst_den;
620 i_num = p_enc->fmt_in.video.i_aspect * (int64_t)p_sys->ti.height;
621 i_den = VOUT_ASPECT_FACTOR * p_sys->ti.width;
622 vlc_reduce( &i_dst_num, &i_dst_den, i_num, i_den, 0 );
623 p_sys->ti.aspect_numerator = i_dst_num;
624 p_sys->ti.aspect_denominator = i_dst_den;
628 p_sys->ti.aspect_numerator = 4;
629 p_sys->ti.aspect_denominator = 3;
632 p_sys->ti.target_bitrate = p_enc->fmt_out.i_bitrate;
633 p_sys->ti.quality = ((float)i_quality) * 6.3;
635 p_sys->ti.dropframes_p = 0;
636 p_sys->ti.quick_p = 1;
637 p_sys->ti.keyframe_auto_p = 1;
638 p_sys->ti.keyframe_frequency = 64;
639 p_sys->ti.keyframe_frequency_force = 64;
640 p_sys->ti.keyframe_data_target_bitrate = p_enc->fmt_out.i_bitrate * 1.5;
641 p_sys->ti.keyframe_auto_threshold = 80;
642 p_sys->ti.keyframe_mindistance = 8;
643 p_sys->ti.noise_sensitivity = 1;
645 theora_encode_init( &p_sys->td, &p_sys->ti );
646 theora_info_clear( &p_sys->ti );
647 theora_comment_init( &p_sys->tc );
649 /* Create and store headers */
650 p_enc->fmt_out.i_extra = 3 * 2;
651 for( i = 0; i < 3; i++ )
653 if( i == 0 ) theora_encode_header( &p_sys->td, &header );
654 else if( i == 1 ) theora_encode_comment( &p_sys->tc, &header );
655 else if( i == 2 ) theora_encode_tables( &p_sys->td, &header );
657 p_enc->fmt_out.p_extra =
658 realloc( p_enc->fmt_out.p_extra,
659 p_enc->fmt_out.i_extra + header.bytes );
660 p_extra = p_enc->fmt_out.p_extra;
661 p_extra += p_enc->fmt_out.i_extra + (i-3)*2;
662 p_enc->fmt_out.i_extra += header.bytes;
664 *(p_extra++) = header.bytes >> 8;
665 *(p_extra++) = header.bytes & 0xFF;
667 memcpy( p_extra, header.packet, header.bytes );
673 /****************************************************************************
674 * Encode: the whole thing
675 ****************************************************************************
676 * This function spits out ogg packets.
677 ****************************************************************************/
678 static block_t *Encode( encoder_t *p_enc, picture_t *p_pict )
680 encoder_sys_t *p_sys = p_enc->p_sys;
681 ogg_packet oggpacket;
687 if( p_pict->p[0].i_pitch < (int)p_sys->i_width ||
688 p_pict->p[0].i_lines < (int)p_sys->i_height )
690 msg_Warn( p_enc, "frame is smaller than encoding size"
691 "(%ix%i->%ix%i) -> dropping frame",
692 p_pict->p[0].i_pitch, p_pict->p[0].i_lines,
693 p_sys->i_width, p_sys->i_height );
698 if( p_pict->p[0].i_visible_pitch < (int)p_sys->i_width )
700 for( i = 0; i < p_sys->i_height; i++ )
702 memset( p_pict->p[0].p_pixels + i * p_pict->p[0].i_pitch +
703 p_pict->p[0].i_visible_pitch,
704 *( p_pict->p[0].p_pixels + i * p_pict->p[0].i_pitch +
705 p_pict->p[0].i_visible_pitch - 1 ),
706 p_sys->i_width - p_pict->p[0].i_visible_pitch );
708 for( i = 0; i < p_sys->i_height / 2; i++ )
710 memset( p_pict->p[1].p_pixels + i * p_pict->p[1].i_pitch +
711 p_pict->p[1].i_visible_pitch,
712 *( p_pict->p[1].p_pixels + i * p_pict->p[1].i_pitch +
713 p_pict->p[1].i_visible_pitch - 1 ),
714 p_sys->i_width / 2 - p_pict->p[1].i_visible_pitch );
715 memset( p_pict->p[2].p_pixels + i * p_pict->p[2].i_pitch +
716 p_pict->p[2].i_visible_pitch,
717 *( p_pict->p[2].p_pixels + i * p_pict->p[2].i_pitch +
718 p_pict->p[2].i_visible_pitch - 1 ),
719 p_sys->i_width / 2 - p_pict->p[2].i_visible_pitch );
723 if( p_pict->p[0].i_visible_lines < (int)p_sys->i_height )
725 for( i = p_pict->p[0].i_visible_lines; i < p_sys->i_height; i++ )
727 memset( p_pict->p[0].p_pixels + i * p_pict->p[0].i_pitch, 0,
730 for( i = p_pict->p[1].i_visible_lines; i < p_sys->i_height / 2; i++ )
732 memset( p_pict->p[1].p_pixels + i * p_pict->p[1].i_pitch, 0x80,
733 p_sys->i_width / 2 );
734 memset( p_pict->p[2].p_pixels + i * p_pict->p[2].i_pitch, 0x80,
735 p_sys->i_width / 2 );
739 /* Theora is a one-frame-in, one-frame-out system. Submit a frame
740 * for compression and pull out the packet. */
742 yuv.y_width = p_sys->i_width;
743 yuv.y_height = p_sys->i_height;
744 yuv.y_stride = p_pict->p[0].i_pitch;
746 yuv.uv_width = p_sys->i_width / 2;
747 yuv.uv_height = p_sys->i_height / 2;
748 yuv.uv_stride = p_pict->p[1].i_pitch;
750 yuv.y = p_pict->p[0].p_pixels;
751 yuv.u = p_pict->p[1].p_pixels;
752 yuv.v = p_pict->p[2].p_pixels;
754 if( theora_encode_YUVin( &p_sys->td, &yuv ) < 0 )
756 msg_Warn( p_enc, "failed encoding a frame" );
760 theora_encode_packetout( &p_sys->td, 0, &oggpacket );
762 /* Ogg packet to block */
763 p_block = block_New( p_enc, oggpacket.bytes );
764 memcpy( p_block->p_buffer, oggpacket.packet, oggpacket.bytes );
765 p_block->i_dts = p_block->i_pts = p_pict->date;
770 /*****************************************************************************
771 * CloseEncoder: theora encoder destruction
772 *****************************************************************************/
773 static void CloseEncoder( vlc_object_t *p_this )
775 encoder_t *p_enc = (encoder_t *)p_this;
776 encoder_sys_t *p_sys = p_enc->p_sys;
778 theora_info_clear( &p_sys->ti );
779 theora_comment_clear( &p_sys->tc );