Commit 35454585 authored by jehan's avatar jehan

fix compilation issue with ffmpeg from debian7

parent 8cb82e6b
......@@ -123,6 +123,20 @@ AC_DEFUN([MS_CHECK_VIDEO],[
CPPFLAGS_save=$CPPFLAGS
CPPFLAGS="$FFMPEG_CFLAGS $CPPFLAGS -Wno-error"
AC_CHECK_HEADERS(libavcodec/avcodec.h)
AC_MSG_CHECKING([AV_CODEC_ID_SNOW])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libavcodec/avcodec.h>]],
[[AVCodecID toto=AV_CODEC_ID_SNOW;if(toto){}]])]
,[AC_DEFINE(CODEC_ID_SNOW,AV_CODEC_ID_SNOW,[for compatibility purpose with old ffmpeg])
AC_DEFINE(HAVE_AVCODEC_SNOW,1,[for compatibility purpose with old ffmpeg])
AC_MSG_RESULT([found])]
,[AC_MSG_RESULT([not found])])
AC_MSG_CHECKING([CODEC_ID_SNOW])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libavcodec/avcodec.h>]],
[[CodecID toto=CODEC_ID_SNOW;if (toto){}]])]
,[AC_DEFINE(HAVE_CODEC_ID_SNOW,1,[for compatibility purpose with old ffmpeg])
AC_DEFINE(HAVE_AVCODEC_SNOW,1,[for compatibility purpose with old ffmpeg])
AC_MSG_RESULT([found])]
,[AC_MSG_RESULT([not found])])
CPPFLAGS=$CPPFLAGS_save
LIBS_save=$LIBS
......
......@@ -67,12 +67,14 @@ static inline int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
}
#endif
#if (LIBAVCODEC_VERSION_MAJOR >= 56)
#include <libavcodec/old_codec_ids.h>
#endif
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54,25,0)
/*CODEC_ID_* and CodecID have been deprecated for a long time and this release removes it altogether. Please use AV_CODEC_ID_* and AVCodecID instead.*/
#define CodecID AVCodecID
#define CODEC_ID_H264 AV_CODEC_ID_H264
#define CODEC_ID_H263 AV_CODEC_ID_H263
#define CODEC_ID_H263P AV_CODEC_ID_H263P
#define CODEC_ID_MPEG4 AV_CODEC_ID_MPEG4
#define CODEC_ID_MJPEG AV_CODEC_ID_MJPEG
#endif
#ifndef HAVE_FUN_avcodec_encode_video2
......
......@@ -91,11 +91,11 @@ static void dec_mpeg4_init(MSFilter *f){
static void dec_mjpeg_init(MSFilter *f){
dec_init(f,CODEC_ID_MJPEG);
}
static void dec_snow_init(MSFilter *f){
#if HAVE_ACVODEC_SNOW
dec_init(f,CODEC_ID_SNOW);
#endif
}
static void dec_uninit(MSFilter *f){
DecState *s=(DecState*)f->data;
if (s->orig) {
......@@ -142,14 +142,19 @@ static void dec_preprocess(MSFilter *f){
s->first_image_decoded = FALSE;
if (s->av_context.codec==NULL){
/* we must know picture size before initializing snow decoder*/
#if HAVE_AVCODEC_SNOW
if (s->codec!=CODEC_ID_SNOW){
#endif
error=avcodec_open2(&s->av_context, s->av_codec, NULL);
if (error!=0) ms_error("avcodec_open() failed: %i",error);
if (s->codec==CODEC_ID_MPEG4 && s->dci_size>0){
s->av_context.extradata=s->dci;
s->av_context.extradata_size=s->dci_size;
}
#if HAVE_AVCODEC_SNOW
}
#endif
}
}
......@@ -225,7 +230,7 @@ static mblk_t * skip_rfc2429_header(mblk_t *inm){
}else freemsg(inm);
return NULL;
}
#if HAVE_AVCODEC_SNOW
static mblk_t * parse_snow_header(DecState *s,mblk_t *inm){
if (msgdsize(inm) >= 4){
uint32_t h = ntohl(*(uint32_t*)inm->b_rptr);
......@@ -249,7 +254,7 @@ static mblk_t * parse_snow_header(DecState *s,mblk_t *inm){
return NULL;
}
}
#endif
struct jpeghdr {
//unsigned int tspec:8; /* type-specific field */
unsigned int off:32; /* fragment byte offset */
......@@ -651,7 +656,9 @@ static void dec_process_frame(MSFilter *f, mblk_t *inm){
if (f->desc->id==MS_H263_DEC_ID) inm=skip_rfc2429_header(inm);
else if (f->desc->id==MS_H263_OLD_DEC_ID) inm=skip_rfc2190_header(inm);
#if HAVE_AVCODEC_SNOW
else if (s->codec==CODEC_ID_SNOW && s->input==NULL) inm=parse_snow_header(s,inm);
#endif
else if (s->codec==CODEC_ID_MJPEG && f->desc->id==MS_JPEG_DEC_ID) inm=read_rfc2435_header(s,inm);
if (inm){
......@@ -824,7 +831,6 @@ MSFilterDesc ms_mjpeg_dec_desc={
dec_uninit,
methods
};
MSFilterDesc ms_snow_dec_desc={
MS_SNOW_DEC_ID,
"MSSnowDec",
......@@ -840,7 +846,6 @@ MSFilterDesc ms_snow_dec_desc={
dec_uninit,
methods
};
#else
MSFilterDesc ms_h263_dec_desc={
......@@ -923,7 +928,6 @@ MSFilterDesc ms_mjpeg_dec_desc={
.uninit=dec_uninit,
.methods= methods
};
MSFilterDesc ms_snow_dec_desc={
.id=MS_SNOW_DEC_ID,
.name="MSSnowDec",
......@@ -939,7 +943,6 @@ MSFilterDesc ms_snow_dec_desc={
.uninit=dec_uninit,
.methods= methods
};
#endif
MS_FILTER_DESC_EXPORT(ms_mpeg4_dec_desc)
......
......@@ -211,8 +211,10 @@ static const MSVideoConfiguration * get_vconf_list(EncState *s) {
case CODEC_ID_MPEG4:
default:
return &mpeg4_conf_list[0];
#if HAVE_AVCODEC_SNOW
case CODEC_ID_SNOW:
return &snow_conf_list[0];
#endif
}
}
......@@ -241,11 +243,11 @@ static void enc_h263_init(MSFilter *f){
static void enc_mpeg4_init(MSFilter *f){
enc_init(f,CODEC_ID_MPEG4);
}
#if HAVE_AVCODEC_SNOW
static void enc_snow_init(MSFilter *f){
enc_init(f,CODEC_ID_SNOW);
}
#endif
static void enc_mjpeg_init(MSFilter *f){
enc_init(f,CODEC_ID_MJPEG);
}
......@@ -281,7 +283,11 @@ static void prepare(EncState *s){
/* ffmpeg vbv rate control consumes too much cpu above a certain target bitrate.
We don't use it above max_br_vbv */
if (s->codec!=CODEC_ID_SNOW && s->vconf.required_bitrate<max_br_vbv){
if (
#if HAVE_AVCODEC_SNOW
s->codec!=CODEC_ID_SNOW &&
#endif
s->vconf.required_bitrate<max_br_vbv){
/*snow does not like 1st pass rate control*/
c->rc_max_rate=c->bit_rate;
c->rc_min_rate=0;
......@@ -299,10 +305,11 @@ static void prepare(EncState *s){
c->gop_size=(int)s->vconf.fps*10; /*emit I frame every 10 seconds*/
c->pix_fmt=PIX_FMT_YUV420P;
s->comp_buf=allocb(c->bit_rate*2,0);
#if HAVE_AVCODEC_SNOW
if (s->codec==CODEC_ID_SNOW){
c->strict_std_compliance=-2;
}
#endif
ms_message("Codec size set to w=%i/h=%i",c->width, c->height);
}
......@@ -348,9 +355,12 @@ static void enc_preprocess(MSFilter *f){
prepare_h263(s);
else if (s->codec==CODEC_ID_MPEG4)
prepare_mpeg4(s);
#if HAVE_AVCODEC_SNOW
else if (s->codec==CODEC_ID_SNOW){
/**/
}else if (s->codec==CODEC_ID_MJPEG){
}
#endif
else if (s->codec==CODEC_ID_MJPEG){
/**/
}else {
ms_error("Unsupported codec id %i",s->codec);
......@@ -737,7 +747,11 @@ static void split_and_send(MSFilter *f, EncState *s, mblk_t *frame){
uint8_t *psc;
uint32_t timestamp=f->ticker->time*90LL;
if (s->codec==CODEC_ID_MPEG4 || s->codec==CODEC_ID_SNOW)
if (s->codec==CODEC_ID_MPEG4
#if HAVE_AVCODEC_SNOW
|| s->codec==CODEC_ID_SNOW
#endif
)
{
mpeg4_fragment_and_send(f,s,frame,timestamp);
return;
......@@ -804,6 +818,7 @@ static void process_frame(MSFilter *f, mblk_t *inm){
s->req_vfu=FALSE;
}
comp_buf->b_rptr=comp_buf->b_wptr=comp_buf->b_datap->db_base;
#if HAVE_AVCODEC_SNOW
if (s->codec==CODEC_ID_SNOW){
//prepend picture size
uint32_t header=((s->vconf.vsize.width&0xffff)<<16) | (s->vconf.vsize.height&0xffff);
......@@ -811,7 +826,7 @@ static void process_frame(MSFilter *f, mblk_t *inm){
comp_buf->b_wptr+=4;
comp_buf_sz-=4;
}
#endif
packet.data=comp_buf->b_wptr;
packet.size=comp_buf_sz;
error=avcodec_encode_video2(c, &packet, s->pict, &got_packet);
......@@ -999,7 +1014,7 @@ MSFilterDesc ms_mpeg4_enc_desc={
enc_uninit,
methods
};
#if HAVE_AVCODEC_SNOW
MSFilterDesc ms_snow_enc_desc={
MS_SNOW_ENC_ID,
"MSSnowEnc",
......@@ -1015,7 +1030,7 @@ MSFilterDesc ms_snow_enc_desc={
enc_uninit,
methods
};
#endif
MSFilterDesc ms_mjpeg_enc_desc={
MS_JPEG_ENC_ID,
"MSJpegEnc",
......@@ -1081,7 +1096,7 @@ MSFilterDesc ms_mpeg4_enc_desc={
.uninit=enc_uninit,
.methods=methods
};
#if HAVE_AVCODEC_SNOW
MSFilterDesc ms_snow_enc_desc={
.id=MS_SNOW_ENC_ID,
.name="MSSnowEnc",
......@@ -1101,7 +1116,7 @@ MSFilterDesc ms_snow_enc_desc={
.uninit=enc_uninit,
.methods=methods
};
#endif
MSFilterDesc ms_mjpeg_enc_desc={
.id=MS_JPEG_ENC_ID,
.name="MSMJpegEnc",
......@@ -1128,8 +1143,10 @@ void __register_ffmpeg_encoders_if_possible(void){
ms_filter_register(&ms_h263_enc_desc);
ms_filter_register(&ms_h263_old_enc_desc);
}
#if HAVE_AVCODEC_SNOW
if (avcodec_find_encoder(CODEC_ID_SNOW))
ms_filter_register(&ms_snow_enc_desc);
#endif
if (avcodec_find_encoder(CODEC_ID_MJPEG))
{
ms_filter_register(&ms_mjpeg_enc_desc);
......
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