Commit 46b7347d authored by jehan's avatar jehan
Browse files

Revert "Drop some very old ffmpeg API."

This reverts commit 5c33fb5f.
parent 5c33fb5f
......@@ -27,12 +27,8 @@ mediastreamer2.spec
missing
stamp-h1
*.gmo
java/bin/
java/libs/
java/gen/
libs
*.dirstamp
*.kdev4
tools/test_x11window
tools/tones
......@@ -20,3 +20,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "ffmpeg-priv.h"
#ifdef FF_API_ALLOC_CONTEXT
#if !FF_API_ALLOC_CONTEXT
AVCodecContext *avcodec_alloc_context(void) {
return avcodec_alloc_context3(NULL);
}
void avcodec_get_context_defaults(AVCodecContext *s) {
avcodec_get_context_defaults3(s, NULL);
}
#endif
#endif
#ifdef FF_API_AVCODEC_OPEN
#if !FF_API_AVCODEC_OPEN
int avcodec_open(AVCodecContext *avctx, AVCodec *codec) {
return avcodec_open2(avctx, codec, NULL);
}
#endif
#endif
......@@ -35,7 +35,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/* new layout */
# include <libavcodec/avcodec.h>
# include <libavutil/avutil.h>
# include <libavutil/mem.h>
#endif
#if defined(HAVE_LIBSWSCALE_SWSCALE_H)
......@@ -60,14 +59,22 @@ static inline int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
return avcodec_decode_video(avctx,picture, got_picture_ptr,avpkt->data,avpkt->size);
}
#endif
#if (LIBAVCODEC_VERSION_MAJOR >= 56)
#include <libavcodec/old_codec_ids.h>
#endif
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54,25,0)
#define CodecID AVCodecID
#endif
#ifdef FF_API_ALLOC_CONTEXT
#if !FF_API_ALLOC_CONTEXT
AVCodecContext *avcodec_alloc_context(void);
void avcodec_get_context_defaults(AVCodecContext *s);
#endif
#endif
#ifdef FF_API_AVCODEC_OPEN
#if !FF_API_AVCODEC_OPEN
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
#endif
#endif
#endif /*iHAVE_LIBAVCODEC_AVCODEC_H*/
#endif /* FFMPEG_PRIV_H */
......@@ -58,8 +58,8 @@ static void dec_open(DecData *d){
int error;
codec=avcodec_find_decoder(CODEC_ID_H264);
if (codec==NULL) ms_fatal("Could not find H264 decoder in ffmpeg.");
avcodec_get_context_defaults3(&d->av_context, NULL);
error=avcodec_open2(&d->av_context,codec, NULL);
avcodec_get_context_defaults(&d->av_context);
error=avcodec_open(&d->av_context,codec);
if (error!=0){
ms_fatal("avcodec_open() failed.");
}
......
......@@ -90,7 +90,7 @@ static void jpg_process(MSFilter *f){
mblk_t *jpegm;
struct SwsContext *sws_ctx;
AVCodecContext *avctx=avcodec_alloc_context3(NULL);
AVCodecContext *avctx=avcodec_alloc_context();
avctx->width=yuvbuf.w;
avctx->height=yuvbuf.h;
......@@ -98,7 +98,7 @@ static void jpg_process(MSFilter *f){
avctx->time_base.den =1;
avctx->pix_fmt=PIX_FMT_YUVJ420P;
error=avcodec_open2(avctx,s->codec,NULL);
error=avcodec_open(avctx,s->codec);
if (error!=0) {
ms_error("avcodec_open() failed: %i",error);
cleanup(s,NULL);
......
......@@ -68,8 +68,8 @@ static mblk_t *jpeg2yuv(uint8_t *jpgbuf, int bufsize, MSVideoSize *reqsize){
return NULL;
}
avcodec_get_context_defaults3(&av_context,NULL);
if (avcodec_open2(&av_context,codec,NULL)<0){
avcodec_get_context_defaults(&av_context);
if (avcodec_open(&av_context,codec)<0){
ms_error("jpeg2yuv: avcodec_open failed");
return NULL;
}
......
......@@ -53,7 +53,7 @@ static void dec_init(MSFilter *f, enum CodecID cid){
DecState *s=(DecState *)ms_new0(DecState,1);
ms_ffmpeg_check_init();
avcodec_get_context_defaults3(&s->av_context, NULL);
avcodec_get_context_defaults(&s->av_context);
s->av_codec=NULL;
s->codec=cid;
s->input=NULL;
......@@ -135,7 +135,7 @@ static void dec_preprocess(MSFilter *f){
if (s->av_context.codec==NULL){
/* we must know picture size before initializing snow decoder*/
if (s->codec!=CODEC_ID_SNOW){
error=avcodec_open2(&s->av_context, s->av_codec, NULL);
error=avcodec_open(&s->av_context, s->av_codec);
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;
......@@ -225,7 +225,7 @@ static mblk_t * parse_snow_header(DecState *s,mblk_t *inm){
int error;
s->av_context.width=h>>16;
s->av_context.height=h&0xffff;
error=avcodec_open2(&s->av_context, s->av_codec, NULL);
error=avcodec_open(&s->av_context, s->av_codec);
if (error!=0) ms_error("avcodec_open() failed for snow: %i",error);
else {
s->snow_initialized=TRUE;
......
......@@ -281,7 +281,7 @@ static void prepare(EncState *s){
AVCodecContext *c=&s->av_context;
const int max_br_vbv=128000;
avcodec_get_context_defaults3(c, NULL);
avcodec_get_context_defaults(c);
if (s->codec==CODEC_ID_MJPEG)
{
ms_message("Codec bitrate set to %i",c->bit_rate);
......@@ -387,7 +387,7 @@ static void enc_preprocess(MSFilter *f){
ms_error("could not find encoder for codec id %i",s->codec);
return;
}
error=avcodec_open2(&s->av_context, s->av_codec, NULL);
error=avcodec_open(&s->av_context, s->av_codec);
if (error!=0) {
ms_error("avcodec_open() failed: %i",error);
return;
......
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