Commit e14437f3 authored by Gildas Bazin's avatar Gildas Bazin

* modules/codec/ffmpeg/*: some chroma conversion routines require libavcodec to be initialised.

parent d5e8b5bb
......@@ -2,7 +2,7 @@
* chroma.c: chroma conversion using ffmpeg library
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: chroma.c,v 1.1 2003/04/27 15:25:11 gbazin Exp $
* $Id: chroma.c,v 1.2 2003/09/26 16:10:24 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -38,7 +38,8 @@
#include "ffmpeg.h"
void ChromaConversion( vout_thread_t *, picture_t *, picture_t * );
void E_(ffmpeg_InitLibavcodec) ( vlc_object_t *p_object );
static void ChromaConversion( vout_thread_t *, picture_t *, picture_t * );
/*****************************************************************************
* chroma_sys_t: chroma method descriptor
......@@ -146,13 +147,16 @@ int E_(OpenChroma)( vlc_object_t *p_this )
p_vout->chroma.p_sys->i_src_ffmpeg_chroma = i_ffmpeg_chroma[0];
p_vout->chroma.p_sys->i_dst_ffmpeg_chroma = i_ffmpeg_chroma[1];
/* libavcodec needs to be initialized for some chroma conversions */
E_(ffmpeg_InitLibavcodec)(p_this);
return VLC_SUCCESS;
}
/*****************************************************************************
* ChromaConversion: actual chroma conversion function
*****************************************************************************/
void ChromaConversion( vout_thread_t *p_vout,
static void ChromaConversion( vout_thread_t *p_vout,
picture_t *p_src, picture_t *p_dest )
{
AVPicture src_pic;
......
......@@ -2,7 +2,7 @@
* ffmpeg.c: video decoder using ffmpeg library
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: ffmpeg.c,v 1.50 2003/09/20 01:36:57 hartman Exp $
* $Id: ffmpeg.c,v 1.51 2003/09/26 16:10:24 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -67,13 +67,14 @@
* Local prototypes
*/
int E_(OpenChroma) ( vlc_object_t * );
void E_(ffmpeg_InitLibavcodec) ( vlc_object_t *p_object );
static int OpenDecoder ( vlc_object_t * );
static int RunDecoder ( decoder_fifo_t * );
static int InitThread ( generic_thread_t * );
static void EndThread ( generic_thread_t * );
static int b_ffmpeginit = 0;
static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t, int *, int *, char ** );
......@@ -282,28 +283,8 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
static int InitThread( generic_thread_t *p_decoder )
{
int i_result;
vlc_value_t lockval;
var_Get( p_decoder->p_fifo->p_libvlc, "avcodec", &lockval );
vlc_mutex_lock( lockval.p_address );
/* *** init ffmpeg library (libavcodec) *** */
if( !b_ffmpeginit )
{
avcodec_init();
avcodec_register_all();
b_ffmpeginit = 1;
msg_Dbg( p_decoder->p_fifo, "libavcodec initialized (interface %d )",
LIBAVCODEC_BUILD );
}
else
{
msg_Dbg( p_decoder->p_fifo, "libavcodec already initialized" );
}
vlc_mutex_unlock( lockval.p_address );
E_(ffmpeg_InitLibavcodec)(VLC_OBJECT(p_decoder->p_fifo));
/* *** determine codec type *** */
ffmpeg_GetFfmpegCodec( p_decoder->p_fifo->i_fourcc,
......@@ -645,3 +626,28 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc,
return( VLC_FALSE );
}
void E_ (ffmpeg_InitLibavcodec) ( vlc_object_t *p_object )
{
vlc_value_t lockval;
var_Get( p_object->p_libvlc, "avcodec", &lockval );
vlc_mutex_lock( lockval.p_address );
/* *** init ffmpeg library (libavcodec) *** */
if( !b_ffmpeginit )
{
avcodec_init();
avcodec_register_all();
b_ffmpeginit = 1;
msg_Dbg( p_object, "libavcodec initialized (interface %d )",
LIBAVCODEC_BUILD );
}
else
{
msg_Dbg( p_object, "libavcodec already initialized" );
}
vlc_mutex_unlock( lockval.p_address );
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment