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 @@ ...@@ -2,7 +2,7 @@
* chroma.c: chroma conversion using ffmpeg library * chroma.c: chroma conversion using ffmpeg library
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * 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> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -38,7 +38,8 @@ ...@@ -38,7 +38,8 @@
#include "ffmpeg.h" #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 * chroma_sys_t: chroma method descriptor
...@@ -146,14 +147,17 @@ int E_(OpenChroma)( vlc_object_t *p_this ) ...@@ -146,14 +147,17 @@ 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_src_ffmpeg_chroma = i_ffmpeg_chroma[0];
p_vout->chroma.p_sys->i_dst_ffmpeg_chroma = i_ffmpeg_chroma[1]; 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; return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
* ChromaConversion: actual chroma conversion function * 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 ) picture_t *p_src, picture_t *p_dest )
{ {
AVPicture src_pic; AVPicture src_pic;
AVPicture dest_pic; AVPicture dest_pic;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ffmpeg.c: video decoder using ffmpeg library * ffmpeg.c: video decoder using ffmpeg library
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * 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> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -67,13 +67,14 @@ ...@@ -67,13 +67,14 @@
* Local prototypes * Local prototypes
*/ */
int E_(OpenChroma) ( vlc_object_t * ); int E_(OpenChroma) ( vlc_object_t * );
void E_(ffmpeg_InitLibavcodec) ( vlc_object_t *p_object );
static int OpenDecoder ( vlc_object_t * ); static int OpenDecoder ( vlc_object_t * );
static int RunDecoder ( decoder_fifo_t * ); static int RunDecoder ( decoder_fifo_t * );
static int InitThread ( generic_thread_t * ); static int InitThread ( generic_thread_t * );
static void EndThread ( generic_thread_t * ); static void EndThread ( generic_thread_t * );
static int b_ffmpeginit = 0; static int b_ffmpeginit = 0;
static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t, int *, int *, char ** ); static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t, int *, int *, char ** );
...@@ -282,28 +283,8 @@ static int RunDecoder( decoder_fifo_t *p_fifo ) ...@@ -282,28 +283,8 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
static int InitThread( generic_thread_t *p_decoder ) static int InitThread( generic_thread_t *p_decoder )
{ {
int i_result; int i_result;
vlc_value_t lockval;
E_(ffmpeg_InitLibavcodec)(VLC_OBJECT(p_decoder->p_fifo));
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 );
/* *** determine codec type *** */ /* *** determine codec type *** */
ffmpeg_GetFfmpegCodec( p_decoder->p_fifo->i_fourcc, ffmpeg_GetFfmpegCodec( p_decoder->p_fifo->i_fourcc,
...@@ -601,7 +582,7 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc, ...@@ -601,7 +582,7 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc,
#if( ( LIBAVCODEC_BUILD >= 4663 ) && ( !defined( WORDS_BIGENDIAN ) ) ) #if( ( LIBAVCODEC_BUILD >= 4663 ) && ( !defined( WORDS_BIGENDIAN ) ) )
/* Quality of this decoder on ppc is not good */ /* Quality of this decoder on ppc is not good */
case FOURCC_IV31: case FOURCC_IV31:
case FOURCC_iv31: case FOURCC_iv31:
case FOURCC_IV32: case FOURCC_IV32:
case FOURCC_iv32: case FOURCC_iv32:
...@@ -612,13 +593,13 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc, ...@@ -612,13 +593,13 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc,
#endif #endif
#if LIBAVCODEC_BUILD >= 4668 #if LIBAVCODEC_BUILD >= 4668
/* Not yet finished /* Not yet finished
case FOURCC_vp31: case FOURCC_vp31:
case FOURCC_VP31: case FOURCC_VP31:
i_cat = VIDEO_ES; i_cat = VIDEO_ES;
i_codec = CODEC_ID_VP3; i_codec = CODEC_ID_VP3;
psz_name = "On2's VP3 Video"; psz_name = "On2's VP3 Video";
break; break;
case FOURCC_asv1: case FOURCC_asv1:
case FOURCC_ASV1: case FOURCC_ASV1:
...@@ -645,3 +626,28 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc, ...@@ -645,3 +626,28 @@ static int ffmpeg_GetFfmpegCodec( vlc_fourcc_t i_fourcc,
return( VLC_FALSE ); 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