Commit cc3e2794 authored by Simon Morlat's avatar Simon Morlat
Browse files

fix compilation and behavior with old ffmpeg

parent 235af313
......@@ -23,7 +23,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HAVE_FUN_avcodec_encode_video2
int avcodec_encode_video2 (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) {
return avcodec_encode_video(avctx, avpkt->data, avpkt->size);
int error=avcodec_encode_video(avctx, avpkt->data, avpkt->size,frame);
if (error<0){
return error;
}else{
if (error>0) {
*got_packet_ptr=1;
avpkt->size=error;
}else *got_packet_ptr=0;
}
return 0;
}
#endif
......@@ -39,7 +48,7 @@ int avcodec_get_context_defaults3 (AVCodecContext *s, const AVCodec *codec) {
#ifndef HAVE_FUN_avcodec_open2 /**/
int avcodec_open2 (AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options) {
return avcodec_open(avctx, codec);
int avcodec_open2 (AVCodecContext *avctx, const AVCodec *codec, /*AVDictionary*/ void **options) {
return avcodec_open(avctx, (AVCodec*)codec);
}
#endif
\ No newline at end of file
......@@ -78,7 +78,7 @@ int avcodec_get_context_defaults3 (AVCodecContext *s, const AVCodec *codec);
#endif
#ifndef HAVE_FUN_avcodec_open2 /**/
int avcodec_open2 (AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
int avcodec_open2 (AVCodecContext *avctx, const AVCodec *codec, /*AVDictionary*/ void **options);
#endif
#endif /*iHAVE_LIBAVCODEC_AVCODEC_H*/
......
......@@ -838,11 +838,12 @@ static void process_frame(MSFilter *f, mblk_t *inm){
comp_buf_sz-=4;
}
packet.data=comp_buf->b_wptr; packet.size=comp_buf_sz;
packet.data=comp_buf->b_wptr;
packet.size=comp_buf_sz;
error=avcodec_encode_video2(c, &packet, &pict, &got_packet);
if (error<=0) ms_warning("ms_AVencoder_process: error %i.",error);
else{
if (error<0) ms_warning("ms_AVencoder_process: error %i.",error);
else if (got_packet){
s->framenum++;
if (s->framenum==1){
video_starter_first_frame (&s->starter,f->ticker->time);
......@@ -850,7 +851,7 @@ static void process_frame(MSFilter *f, mblk_t *inm){
if (c->coded_frame->pict_type==FF_I_TYPE){
ms_message("Emitting I-frame");
}
comp_buf->b_wptr+=error;
comp_buf->b_wptr+=packet.size;
split_and_send(f,s,comp_buf);
}
freemsg(inm);
......
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