File fix_ffmpeg.diff of Package xdtv

--- xdtv-2.4.1cvs15.old/src/container-avi.c     2008-12-21 10:37:44.000000000 +0100
+++ xdtv-2.4.1cvs15/src/container-avi.c 2011-09-21 21:18:54.000000000 +0200
@@ -66,7 +66,7 @@
 #endif
 #ifdef HAVE_FFMPEG
 #if LIBAVCODEC_BUILD >= 4719
-  {FFMPEG_XVID,     "FFMpeg XviD"},
+//  {FFMPEG_XVID,     "FFMpeg XviD"},
 #endif
   {FFMPEG_MPEG4,     "FFMpeg Mpeg4"},
 #if LIBAVCODEC_BUILD >= 4676
--- xdtv-2.4.1cvs15.old/src/container-common.c	2008-12-07 12:43:23.000000000 +0100
+++ xdtv-2.4.1cvs15/src/container-common.c	2012-05-29 11:20:46.000000000 +0200
@@ -85,7 +85,7 @@
 void   containers_init(){
         int k;
 #ifdef HAVE_FFMPEG
-        avcodec_init();
+//        avcodec_init();
         avcodec_register_all();
 #endif
         for(k=0;containers[k]!=NULL;k++){
--- xdtv-2.4.1cvs15.old/src/container-ffmpeg.c	2008-12-07 12:43:23.000000000 +0100
+++ xdtv-2.4.1cvs15/src/container-ffmpeg.c	2015-03-09 21:42:16.000000000 +0100
@@ -47,7 +47,7 @@
 static  int open_ofile (struct CONTAINER* This, char* filename ,int maxsize)
 {
     av_register_all();
-    av_output_fmt = guess_format(This->shortname,NULL, NULL);
+    av_output_fmt = av_guess_format(This->shortname,NULL, NULL);
 
     if (!av_output_fmt) {
       fprintf(stderr, "Could not find suitable output format\n");
@@ -55,7 +55,7 @@
     }
 
     /* allocate the output media context */
-    oc = av_alloc_format_context();
+    oc = avformat_alloc_context();
     if (!oc) {
 	fprintf(stderr, "Memory error\n");
 	return -1;
@@ -66,48 +66,48 @@
 	       and initialize the codecs */
     video_st = NULL;
     audio_st = NULL;
-    if (av_output_fmt->video_codec != CODEC_ID_NONE) {
+    if (av_output_fmt->video_codec != AV_CODEC_ID_NONE) {
 //	int o_codec=-1;
 /*	if (-1 == (o_codec =xdtv_to_ffmpeg(divx.codec) )){
 		fprintf(stderr,"the video codec must be a ffmpeg codec ! \n");
 		return NULL;
 	}
 */	// we suppose that its ok...
-	video_st = av_new_stream(oc,0); 
+	video_st = avformat_new_stream(oc,NULL); 
 	video_st->codec = codec_context;	
     }
 
 
-    if (av_output_fmt->audio_codec != CODEC_ID_NONE) {
+    if (av_output_fmt->audio_codec != AV_CODEC_ID_NONE) {
 //	int o_codec=-1;
 /*	if (-1 == (o_codec = xdtv_to_audioffmpeg(divx.audio_codec) )){
 		fprintf(stderr,"the audio codec must be a ffmpeg codec ! \n");
 		return NULL;
 	}
 */
-	audio_st = av_new_stream(oc,0); 
+	audio_st = avformat_new_stream(oc,NULL); 
 	audio_st->codec = audio_codec_context;	
     }
 
     /* set the output parameters (must be done even if no
 	       parameters). */
-    if (av_set_parameters(oc, NULL) < 0) {
+/*    if (av_set_parameters(oc, NULL) < 0) {
 	fprintf(stderr, "Invalid output format parameters\n");
 	return -1;
-    }
+    } */
 
-    dump_format(oc, 0, filename, 1);
+    av_dump_format(oc, 0, filename, 1);
 
     /* open the output file, if needed */
     if (!(av_output_fmt->flags & AVFMT_NOFILE)) {
-       	if (url_fopen(&oc->pb, filename, URL_WRONLY) < 0) {
+       	if (avio_open(&oc->pb, filename, AVIO_FLAG_WRITE) < 0) {
        		fprintf(stderr, "Could not open '%s'\n", filename);
        		return -1;
        	}
     }
     
     /* write the stream header, if any */
-    av_write_header(oc);
+    avformat_write_header(oc, NULL);
 
     /* now we just have to contruct an avi_t struct */
     if (NULL == (This->avfile = (avi_t *) malloc(sizeof(avi_t)))){
@@ -131,7 +131,7 @@
   av_init_packet(&pkt);
   pkt.pts= av_rescale_q(video_st->codec->coded_frame->pts,video_st->codec->time_base, video_st->time_base);
   if(video_st->codec->coded_frame->key_frame)
-	pkt.flags |= PKT_FLAG_KEY;
+	pkt.flags |= AV_PKT_FLAG_KEY;
   pkt.stream_index= video_st->index;
   pkt.data= (uint8_t *) data;
   pkt.size= bytes;
@@ -160,7 +160,7 @@
    av_init_packet(&pkt);
    pkt.size=bytes;
    pkt.pts= av_rescale_q(audio_st->codec->coded_frame->pts, audio_st->codec->time_base, audio_st->time_base);
-   pkt.flags |= PKT_FLAG_KEY;
+   pkt.flags |= AV_PKT_FLAG_KEY;
    pkt.stream_index= audio_st->index;
    pkt.data= (uint8_t*) data;
 
@@ -193,7 +193,7 @@
    /* close the output file */
 // <=> 51.49.0
 #if LIBAVCODEC_BUILD >= 3354880
-    url_fclose(oc->pb);
+    avio_close(oc->pb);
 #else
     url_fclose(&oc->pb);
 #endif
@@ -227,19 +227,19 @@
     /* open a new header file */
     fprintf(stderr,"create new header stream : %s\n",file_header);
     snprintf(header_oc.filename, sizeof(header_oc.filename), "%s", file_header);
-    if (url_fopen(&header_oc.pb, file_header, URL_WRONLY) < 0) {
+    if (avio_open(&header_oc.pb, file_header, AVIO_FLAG_WRITE) < 0) {
             fprintf(stderr, "Could not open '%s'\n", file_header);
 	    return NULL;
     }
     fprintf(stderr,"write stream header\n");
     /* write the stream header, if any */
-    av_write_header(&header_oc);
+    avformat_write_header(&header_oc, NULL);
 
     fprintf(stderr,"close file\n");
     /* close the output file */
 // <=> 51.49.0
 #if LIBAVCODEC_BUILD >= 3354880
-    url_fclose(header_oc.pb);
+    avio_close(header_oc.pb);
 #else
     url_fclose(&header_oc.pb);
 #endif
--- xdtv-2.4.1cvs15.old/src/divx.c	2008-12-21 16:42:00.000000000 +0100
+++ xdtv-2.4.1cvs15/src/divx.c	2011-09-21 12:51:45.000000000 +0200
@@ -259,7 +259,7 @@
 #endif
 #ifdef HAVE_FFMPEG
 #if LIBAVCODEC_BUILD >= 4719
-  {FFMPEG_XVID,     "FFMpeg XviD"},
+//  {FFMPEG_XVID,     "FFMpeg XviD"},
 #endif
   {FFMPEG_MPEG4,     "FFMpeg Mpeg4"},
 #if LIBAVCODEC_BUILD >= 4676
@@ -354,13 +354,13 @@
 
 int xdtv_to_audioffmpeg(int x) {
   switch(x) {
-  case FFMPEG_MP2: return CODEC_ID_MP2;
-  case FFMPEG_MP3: return CODEC_ID_MP3;
-  case FFMPEG_AC3: return CODEC_ID_AC3;
-  case FFMPEG_AAC: return CODEC_ID_AAC;
-  case FFMPEG_PCMS16LE: return CODEC_ID_PCM_S16LE;
-  case FFMPEG_AMR_NB : return CODEC_ID_AMR_NB;
-  case FFMPEG_AMR_WB : return CODEC_ID_AMR_WB;
+  case FFMPEG_MP2: return AV_CODEC_ID_MP2;
+  case FFMPEG_MP3: return AV_CODEC_ID_MP3;
+  case FFMPEG_AC3: return AV_CODEC_ID_AC3;
+  case FFMPEG_AAC: return AV_CODEC_ID_AAC;
+  case FFMPEG_PCMS16LE: return AV_CODEC_ID_PCM_S16LE;
+  case FFMPEG_AMR_NB : return AV_CODEC_ID_AMR_NB;
+  case FFMPEG_AMR_WB : return AV_CODEC_ID_AMR_WB;
   }
   return -1;
 }
@@ -442,63 +442,63 @@
 int xdtv_to_ffmpeg(int x) {
   switch(x) {
 #if LIBAVCODEC_BUILD >= 4719
-  case FFMPEG_XVID: return CODEC_ID_XVID;
+//  case FFMPEG_XVID: return AV_CODEC_ID_XVID;
 #endif
-  case FFMPEG_MPEG4: return CODEC_ID_MPEG4;
-  case FFMPEG_MPEG1: return CODEC_ID_MPEG1VIDEO;
+  case FFMPEG_MPEG4: return AV_CODEC_ID_MPEG4;
+  case FFMPEG_MPEG1: return AV_CODEC_ID_MPEG1VIDEO;
 #if LIBAVCODEC_BUILD >= 4676
-  case FFMPEG_MPEG2: return CODEC_ID_MPEG2VIDEO;
+  case FFMPEG_MPEG2: return AV_CODEC_ID_MPEG2VIDEO;
 #endif
-  case FFMPEG_MJPEG: return CODEC_ID_MJPEG;
+  case FFMPEG_MJPEG: return AV_CODEC_ID_MJPEG;
 #if LIBAVCODEC_BUILD >= 4670
-  case FFMPEG_LJPEG: return CODEC_ID_LJPEG;
-  case FFMPEG_FLV1: return CODEC_ID_FLV1;
+  case FFMPEG_LJPEG: return AV_CODEC_ID_LJPEG;
+  case FFMPEG_FLV1: return AV_CODEC_ID_FLV1;
 #endif
 #if LIBAVCODEC_BUILD >= 4735
-  case FFMPEG_RV20: return CODEC_ID_RV20;
+  case FFMPEG_RV20: return AV_CODEC_ID_RV20;
 #endif
-  case FFMPEG_RV10: return CODEC_ID_RV10;
+  case FFMPEG_RV10: return AV_CODEC_ID_RV10;
 #if LIBAVCODEC_BUILD >= 4748
-  case FFMPEG_X264: return CODEC_ID_H264;
+  case FFMPEG_X264: return AV_CODEC_ID_H264;
 #endif
-  case FFMPEG_H263P: return CODEC_ID_H263P;
-  case FFMPEG_H263: return CODEC_ID_H263;
+  case FFMPEG_H263P: return AV_CODEC_ID_H263P;
+  case FFMPEG_H263: return AV_CODEC_ID_H263;
 #if LIBAVCODEC_BUILD >= 4729
-  case FFMPEG_H261: return CODEC_ID_H261;
+  case FFMPEG_H261: return AV_CODEC_ID_H261;
 #endif
-  case FFMPEG_MSMPEG4V3: return CODEC_ID_MSMPEG4V3;
-  case FFMPEG_MSMPEG4V2: return CODEC_ID_MSMPEG4V2;
+  case FFMPEG_MSMPEG4V3: return AV_CODEC_ID_MSMPEG4V3;
+  case FFMPEG_MSMPEG4V2: return AV_CODEC_ID_MSMPEG4V2;
 /* Already implemented into the 0.4.6 version 
 but only work correctly with the 0.4.7 version */
 #if LIBAVCODEC_BUILD >= 4675
-  case FFMPEG_WMV2: return CODEC_ID_WMV2;
+  case FFMPEG_WMV2: return AV_CODEC_ID_WMV2;
 #endif
-  case FFMPEG_WMV1: return CODEC_ID_WMV1;
+  case FFMPEG_WMV1: return AV_CODEC_ID_WMV1;
 #if LIBAVCODEC_BUILD >= 4677
-  case FFMPEG_ASV2: return CODEC_ID_ASV2;
+  case FFMPEG_ASV2: return AV_CODEC_ID_ASV2;
 #endif
 #if LIBAVCODEC_BUILD >= 4668
-  case FFMPEG_ASV1: return CODEC_ID_ASV1;
+  case FFMPEG_ASV1: return AV_CODEC_ID_ASV1;
 #endif
 /* appeared with the 4719 version
 but don't work correctly actually */
 #if LIBAVCODEC_BUILD >= 16777215
-  case FFMPEG_SVQ1: return CODEC_ID_SVQ1;
+  case FFMPEG_SVQ1: return AV_CODEC_ID_SVQ1;
 #endif
 /* appeared with the 4669 version
 but only work correctly with the 4755 version */
 #if LIBAVCODEC_BUILD >= 4755
-  case FFMPEG_FFV1: return CODEC_ID_FFV1;
+  case FFMPEG_FFV1: return AV_CODEC_ID_FFV1;
 #endif
 #if LIBAVCODEC_BUILD >= 4719
-  case FFMPEG_SNOW: return CODEC_ID_SNOW;
+  case FFMPEG_SNOW: return AV_CODEC_ID_SNOW;
 #endif
 #if LIBAVCODEC_BUILD >= 4734
-  case FFMPEG_FFVHUFF: return CODEC_ID_FFVHUFF;
+  case FFMPEG_FFVHUFF: return AV_CODEC_ID_FFVHUFF;
 #endif
-  case FFMPEG_HUFFYUV: return CODEC_ID_HUFFYUV;
+  case FFMPEG_HUFFYUV: return AV_CODEC_ID_HUFFYUV;
 #if LIBAVCODEC_BUILD >= 4707
-  case FFMPEG_DVVIDEO: return CODEC_ID_DVVIDEO;
+  case FFMPEG_DVVIDEO: return AV_CODEC_ID_DVVIDEO;
 #endif
   default: return -1;
   }
@@ -667,7 +667,7 @@
   {THEORA,             "theo"},
 #endif
 #if LIBAVCODEC_BUILD >= 4719
-  {FFMPEG_XVID,      "XVID"},
+//  {FFMPEG_XVID,      "XVID"},
 #endif
 #ifdef HAVE_FFMPEG
   {FFMPEG_MPEG4,     "DIVX"},
@@ -1152,7 +1152,7 @@
 
 #ifdef HAVE_FFMPEG
   else if(xdtv_to_ffmpeg(divx.codec)!=-1) {
-    avcodec_init();
+//    avcodec_init();
     avcodec_register_all();
 #if LIBAVCODEC_BUILD <= 4759
     sprintf(xawmesstmp, translate("divx_init: initializing %s version %d (build %d)\n"), codec_name, avcodec_version(), avcodec_build());
@@ -1173,21 +1173,21 @@
       return;
     }
 
-    if (codec_context == NULL) codec_context = handle = avcodec_alloc_context();
-    picture_420p = avcodec_alloc_frame();
+    if (codec_context == NULL) codec_context = handle = avcodec_alloc_context3(codec);
+    picture_420p = av_frame_alloc();
 
 // FFMpeg Parameters from MPlayer libmpcodecs/ve_lavc.c -------------------------------------
 
     codec_context->codec_id              = xdtv_to_ffmpeg(divx.codec);
-    codec_context->codec_type            = CODEC_TYPE_VIDEO;
+    codec_context->codec_type            = AVMEDIA_TYPE_VIDEO;
     codec_context->bit_rate              = divx.bitrate;
     codec_context->bit_rate_tolerance    = divx.bitrate*10;
     codec_context->flags                 = 0;
-    codec_context->me_method             = ME_ZERO+ divx.quality;
+//    codec_context->me_method             = ME_ZERO+ divx.quality;
     codec_context->width                 = width;
     codec_context->height                = height;
     codec_context->gop_size              = ffmpeg.keyint;
-    codec_context->pix_fmt               = PIX_FMT_YUV420P;
+    codec_context->pix_fmt               = AV_PIX_FMT_YUV420P;
     fmt_conv                             = VIDEO_YUV420;
 #if LIBAVCODEC_BUILD >= 4754
     codec_context->time_base             = (AVRational){fps_den,fps_num};
@@ -1204,25 +1204,25 @@
     codec_context->max_qdiff             = 3;
     codec_context->max_b_frames          = ffmpeg.vmax_b_frames;
     codec_context->b_quant_factor        = 1.25;
-    codec_context->rc_strategy           = 2;
+//    codec_context->rc_strategy           = 2;
     codec_context->b_frame_strategy      = 0;
     codec_context->rtp_payload_size      = 0;
-    codec_context->luma_elim_threshold   = ffmpeg.vlelim;
-    codec_context->chroma_elim_threshold = ffmpeg.vcelim;
+/*    codec_context->luma_elim_threshold   = ffmpeg.vlelim;
+    codec_context->chroma_elim_threshold = ffmpeg.vcelim;*/
     codec_context->strict_std_compliance = -1; // To follow strictly the standard
     codec_context->b_quant_offset        = (int)(FF_QP2LAMBDA * 1.25 + 0.5);
     codec_context->mpeg_quant            = 0;
-    codec_context->rc_qsquish            = 1.0;
+/*    codec_context->rc_qsquish            = 1.0;
     codec_context->rc_qmod_amp           = 0;
     codec_context->rc_qmod_freq          = 0;
-    codec_context->rc_eq                 = "tex^qComp";
+    codec_context->rc_eq                 = strdup("tex^qComp");*/
     codec_context->rc_max_rate           = 0*1000;
     codec_context->rc_min_rate           = 0*1000;
     codec_context->rc_buffer_size        = 0*1000;
-    codec_context->rc_buffer_aggressivity= 1.0;
+//    codec_context->rc_buffer_aggressivity= 1.0;
     codec_context->i_quant_factor        = 0.8;
     codec_context->i_quant_offset        = (int)(FF_QP2LAMBDA * 0.0 + 0.5);
-    codec_context->rc_initial_cplx       = 0;
+//    codec_context->rc_initial_cplx       = 0;
     codec_context->dct_algo              = 0; // Auto Mode ON
     codec_context->lumi_masking          = ffmpeg.lumi_mask;
     codec_context->temporal_cplx_masking = ffmpeg.tcplx_mask;
@@ -1236,8 +1236,8 @@
     codec_context->debug                 = 0;
 #endif    
 #if LIBAVCODEC_BUILD >= 4646
-    codec_context->mb_qmin               = divx.min_quantizer;
-    codec_context->mb_qmax               = divx.max_quantizer;
+//    codec_context->mb_qmin               = divx.min_quantizer;
+//    codec_context->mb_qmax               = divx.max_quantizer;
 #endif 
 #if LIBAVCODEC_BUILD >= 4647
     codec_context->me_cmp                = ffmpeg.cmp;
@@ -1264,7 +1264,7 @@
 #if LIBAVCODEC_BUILD >= 4659
     codec_context->me_range              = 0;
 #endif
-#if LIBAVCODEC_BUILD >= 4663
+#if 0
     codec_context->intra_quant_bias      = FF_DEFAULT_QUANT_BIAS;
     codec_context->inter_quant_bias      = FF_DEFAULT_QUANT_BIAS;
 #endif
@@ -1278,7 +1278,7 @@
 #if LIBAVCODEC_BUILD >= 4680
     codec_context->scenechange_threshold = 0;
 #endif
-#if LIBAVCODEC_BUILD >= 4684
+#if 0
     codec_context->lmin                     = (int)(FF_QP2LAMBDA * divx.min_quantizer + 0.5);
     codec_context->lmax                     = (int)(FF_QP2LAMBDA * divx.max_quantizer + 0.5);
 #endif
@@ -1287,9 +1287,9 @@
 #endif
 #if LIBAVCODEC_BUILD >= 4694
     codec_context->rc_initial_buffer_occupancy = codec_context->rc_buffer_size * 0.9;
-    codec_context->inter_threshold       = 0;
+//    codec_context->inter_threshold       = 0;
 #endif
-#if LIBAVCODEC_BUILD >= 4700
+#if 0
     codec_context->quantizer_noise_shaping= 0; // Realtime encoding
 #endif
 #if LIBAVCODEC_BUILD >= 4711
@@ -1298,7 +1298,7 @@
 #if LIBAVCODEC_BUILD >= 4716
     codec_context->nsse_weight           = 8;
 #endif
-#if LIBAVCODEC_BUILD >= 4741
+#if 0
     codec_context->border_masking        = 0.0;
 #endif
 
@@ -1307,7 +1307,7 @@
 codec_context->brd_scale                 = 0;
 #endif
 // <=> 51.2.0
-#if LIBAVCODEC_BUILD >= 3342848
+#if 0
       codec_context->scenechange_factor = 1;
 #endif
 // <=> 51.10.0
@@ -1327,25 +1327,25 @@
     ))
 #endif
     {
-      codec_context->flags |= CODEC_FLAG_4MV;
+      codec_context->flags |= AV_CODEC_FLAG_4MV;
       activated_mess("V4mv : 4 Motion Vector");}
 
-    if (ffmpeg.naq == 1) {
+/*    if (ffmpeg.naq == 1) {
       codec_context->flags |= CODEC_FLAG_NORMALIZE_AQP;
-      activated_mess("Normalize Quantization");}
+      activated_mess("Normalize Quantization");} */
 
 // Bad color with ASV2 ASV1 & RV20 but no segfault.
 // I Hope it will be fixed in future.
     if (ffmpeg.gray == 1) {
-      codec_context->flags |= CODEC_FLAG_GRAY;
+      codec_context->flags |= AV_CODEC_FLAG_GRAY;
       activated_mess("Grayscale Encoding");}
 
     if (ffmpeg.gmc == 1) {
-      codec_context->flags |= CODEC_FLAG_GMC;
-      activated_mess("Global Motion Compensation");}
+/*      codec_context->flags |= CODEC_FLAG_GMC;
+      activated_mess("Global Motion Compensation");*/}
 
     if (ffmpeg.qpel == 1 && divx.codec == FFMPEG_MPEG4) {
-      codec_context->flags |= CODEC_FLAG_QPEL;
+      codec_context->flags |= AV_CODEC_FLAG_QPEL;
       activated_mess("Quarter PixEL");}
 
     if (ffmpeg.ildct == 1 && (divx.codec == FFMPEG_MPEG4 
@@ -1355,7 +1355,7 @@
     ))
 #endif
     {
-      codec_context->flags |= CODEC_FLAG_INTERLACED_DCT;
+      codec_context->flags |= AV_CODEC_FLAG_INTERLACED_DCT;
       activated_mess("InterLaced DCT Encoding");}
 
 #if LIBAVCODEC_BUILD >= 4698
@@ -1366,7 +1366,7 @@
     ))
 #endif
     {
-      codec_context->flags |= CODEC_FLAG_INTERLACED_ME;
+      codec_context->flags |= AV_CODEC_FLAG_INTERLACED_ME;
       activated_mess("InterLaced Motion Estimation");}
 #endif
 
@@ -1401,8 +1401,8 @@
 #else
       codec_context->trellis = 1;
 #endif
-      codec_context->flags |= CODEC_FLAG_CBP_RD;
-      activated_mess("Coded Block Pattern");}
+/*      codec_context->flags |= CODEC_FLAG_CBP_RD;
+      activated_mess("Coded Block Pattern");*/}
 #endif
 
 #if LIBAVCODEC_BUILD >= 4647
@@ -1432,7 +1432,7 @@
     if (ffmpeg.vmax_b_frames != 0) {
 #if LIBAVCODEC_BUILD >= 4700
       codec_context->scenechange_threshold = 1000000000;
-      codec_context->flags |= CODEC_FLAG_CLOSED_GOP;
+      codec_context->flags |= AV_CODEC_FLAG_CLOSED_GOP;
 #endif
       equal_int_mess("MAX B-Frames", ffmpeg.vmax_b_frames);}
 
@@ -1442,9 +1442,9 @@
 // Switchs only used by the H263+ codec!!!!!
     if (divx.codec == FFMPEG_H263P) {
 #if LIBAVCODEC_BUILD >= 4661
-      if (ffmpeg.umv == 1) {
+/*      if (ffmpeg.umv == 1) {
         codec_context->flags |= CODEC_FLAG_H263P_UMV;
-        activated_mess("UMV");}
+        activated_mess("UMV");} */
 
       if (ffmpeg.aic == 1) {
         if (divx.min_quantizer < 8) codec_context->qmin = 8;
@@ -1451,12 +1451,12 @@
 #if LIBAVCODEC_BUILD < ((52<<16)+(0<<8)+0)
         codec_context->flags |= CODEC_FLAG_H263P_AIC;
 #else
-        codec_context->flags |= CODEC_FLAG_AC_PRED;
+        codec_context->flags |= AV_CODEC_FLAG_AC_PRED;
 #endif
         activated_mess("AIC");}
 #endif
 #if LIBAVCODEC_BUILD >= 4694
-      if (ffmpeg.obmc == 1) {
+/*      if (ffmpeg.obmc == 1) {
         codec_context->flags |= CODEC_FLAG_OBMC;
         activated_mess("OBMC");  }
 
@@ -1466,10 +1466,10 @@
 
       if (ffmpeg.aiv == 1) {
         codec_context->flags |= CODEC_FLAG_H263P_AIV;
-        activated_mess("AIV");}
+        activated_mess("AIV");} */
 
       if (ffmpeg.loop == 1) {
-        codec_context->flags |= CODEC_FLAG_LOOP_FILTER;
+        codec_context->flags |= AV_CODEC_FLAG_LOOP_FILTER;
         activated_mess("LOOP");}
 #endif
     }
@@ -1487,7 +1487,7 @@
       if(divx.bitrate < 5000000) codec_context->context_model = 1;}
     if (divx.codec == FFMPEG_HUFFYUV) {
       fmt_conv = VIDEO_YUV422P;
-      codec_context->pix_fmt=PIX_FMT_YUV422P;
+      codec_context->pix_fmt=AV_PIX_FMT_YUV422P;
       codec_context->prediction_method = FF_PRED_MEDIAN;}
 #else
     if (divx.codec == FFMPEG_HUFFYUV) {
@@ -1507,7 +1507,7 @@
 // 3) SVQ Codec
 /* appeared with the 4719 version but don't work correctly actually */
 #if LIBAVCODEC_BUILD >= 16777215
-    if (divx.codec == FFMPEG_SVQ1) codec_context->pix_fmt=PIX_FMT_YUV410P;
+    if (divx.codec == FFMPEG_SVQ1) codec_context->pix_fmt=PIX_FMT_YUV410P;
 #endif
 
 // 4) Experimental video Codecs
@@ -1532,7 +1532,7 @@
      && divx.codec != FFMPEG_MPEG2 
 #endif
 #if LIBAVCODEC_BUILD >= 4719
-     && divx.codec != FFMPEG_XVID
+//     && divx.codec != FFMPEG_XVID
 #endif
 #if LIBAVCODEC_BUILD >= 4748
      && divx.codec != FFMPEG_X264 
@@ -1586,7 +1586,7 @@
 
 // 9 for XviD
 // <=> 51.2.0
-#if LIBAVCODEC_BUILD >= 3342848
+#if 0
     if(divx.codec == FFMPEG_XVID) {
       codec_context->rc_strategy = 0;
       codec_context->sample_aspect_ratio.num = 1;
@@ -1601,13 +1601,13 @@
 #else
     if (divx.codec != FFMPEG_HUFFYUV)
 #endif
-      codec_context->flags |= CODEC_FLAG_PASS1;
+      codec_context->flags |= AV_CODEC_FLAG_PASS1;
 
     picture_420p->linesize[0] = codec_context->width;
     picture_420p->linesize[1] = codec_context->width / 2;
     picture_420p->linesize[2] = codec_context->width / 2;
 
-    if (avcodec_open(codec_context, codec) < 0)
+    if (avcodec_open2(codec_context, codec, NULL) < 0)
     {
       sprintf(xawmesstmp, translate("divx_init: couldn't open %s codec\n"), codec_name);
       strcat(xawmessage,xawmesstmp);
@@ -1615,9 +1615,9 @@
       return;
     }
 
-    if (codec_context->codec->encode == NULL)
+    if (codec_context->codec->encode2 == NULL)
     {
-      sprintf(xawmesstmp, translate("divx_init: %s codec initialization failed (ctx->codec->encode == NULL)!\n"), codec_name);
+      sprintf(xawmesstmp, translate("divx_init: %s codec initialization failed (ctx->codec->encode2 == NULL)!\n"), codec_name);
       strcat(xawmessage,xawmesstmp);
       divx_stop();
       return;
@@ -1999,13 +1999,15 @@
       divx_stop();
       return;
     }
-    avcodec_init();
+//    avcodec_init();
     avcodec_register_all();
 
+    av_codec = avcodec_find_encoder(xdtv_to_audioffmpeg(divx.audio_codec));
     if (audio_codec_context == NULL)
-      audio_codec_context = avcodec_alloc_context();
+      audio_codec_context = avcodec_alloc_context3(av_codec);
     audio_codec_context->codec_id = xdtv_to_audioffmpeg(divx.audio_codec);
-    audio_codec_context->codec_type= CODEC_TYPE_AUDIO;
+    audio_codec_context->codec_type= AVMEDIA_TYPE_AUDIO;
+    audio_codec_context->sample_fmt= AV_SAMPLE_FMT_S16;
     switch(divx.audio_codec) {
       // we force to the maximum bitrate as it's not possible to configure it through the GUI
       case FFMPEG_AMR_NB: audio_codec_context->bit_rate = 12200; break;
@@ -2016,17 +2018,18 @@
     }
     audio_codec_context->sample_rate = divx.audio_freq;
     audio_codec_context->channels = achans;
-    av_codec = avcodec_find_encoder(audio_codec_context->codec_id);
     if (av_codec==NULL
-       || avcodec_open(audio_codec_context, av_codec) < 0
-       || audio_codec_context->codec->encode == NULL) {
+       || avcodec_open2(audio_codec_context, av_codec, NULL) < 0
+       || audio_codec_context->codec->encode2 == NULL) {
       strcat(xawmessage,translate("divx_init: audio: problem with ffmpeg\n"));
       sprintf(xawmesstmp, translate("divx_init: audio: av_codec = %p\n"),av_codec);
       strcat(xawmessage,xawmesstmp);
-      sprintf(xawmesstmp, translate("divx_init: audio: avcodec_open = %d\n"),avcodec_open(audio_codec_context, av_codec));
+      sprintf(xawmesstmp, translate("divx_init: audio: avcodec_open2 = %d\n"),avcodec_open2(audio_codec_context, av_codec, NULL));
       strcat(xawmessage,xawmesstmp);
-      sprintf(xawmesstmp, translate("divx_init: audio: audio_codec_context->codec->encode = %p\n"),audio_codec_context->codec->encode);
+      if(audio_codec_context->codec) {
+      sprintf(xawmesstmp, translate("divx_init: audio: audio_codec_context->codec->encode2 = %p\n"),audio_codec_context->codec->encode2);
       strcat(xawmessage,xawmesstmp);
+      }
       divx_stop();
       return;
     }
@@ -2250,8 +2252,26 @@
       if(fmt_conv==VIDEO_YUV422P)
 	picture_420p->data[2] += width_rec*height_rec / 4;
       picture_420p->key_frame = -1;
-      enc_size = avcodec_encode_video(codec_context, enc_frame, ENC_FRAME_SIZE, picture_420p);
-      if (enc_size > 0) {
+      AVPacket pkt;
+      av_init_packet(&pkt);
+      pkt.data = enc_frame;
+      pkt.size = ENC_FRAME_SIZE;
+      picture_420p->width = width_rec;
+      picture_420p->height = height_rec;
+      picture_420p->format =  AV_PIX_FMT_YUV420P;
+      if (avcodec_encode_video2(codec_context, &pkt, picture_420p, &enc_size)==0) {
+	if (enc_size && codec_context->coded_frame) {
+         codec_context->coded_frame->pts       = pkt.pts;
+         codec_context->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY);
+   }     
+	if (pkt.side_data_elems > 0) {
+         int i;
+         for (i = 0; i < pkt.side_data_elems; i++)
+             av_free(pkt.side_data[i].data);
+         av_freep(&pkt.side_data);
+         pkt.side_data_elems = 0;
+	}
+	enc_size = pkt.size;
 	flag = codec_context->coded_frame->key_frame ? AVI_FLAG_KEYFRAME : AVI_FLAG_NONE;
 	slw = cont_handler->write_frame(cont_handler, (char*)enc_frame, enc_size, flag);
       } else {
@@ -2734,9 +2740,23 @@
 		  2*achans*ll);
       i+=ll;
       lremain-=ll;
-      nsamples = 
-	avcodec_encode_audio(audio_codec_context, (unsigned char*)av_buffer,
-			     av_buffer_size, (short*) av_buffer0);
+      AVPacket pkt;
+      av_init_packet(&pkt);
+      pkt.data = av_buffer;
+      pkt.size = av_buffer_size;
+      AVFrame *frame = av_frame_alloc();
+      frame->nb_samples = audio_codec_context->frame_size;
+      int samples_size = av_samples_get_buffer_size(NULL, audio_codec_context->channels, frame->nb_samples, audio_codec_context->sample_fmt, 1);
+      avcodec_fill_audio_frame(frame, audio_codec_context->channels, audio_codec_context->sample_fmt, (const uint8_t *)av_buffer0, samples_size, 1);
+      if (audio_codec_context->sample_rate && audio_codec_context->time_base.num) printf("Wolfi: samplerate && time_base.num\n");
+  //           frame->pts = ff_samples_to_time_base(audio_codec_context, audio_codec_context->internal->sample_count);
+  //    else
+  //           frame->pts = AV_NOPTS_VALUE;
+  //    audio_codec_context->internal->sample_count += frame->nb_samples
+      if (avcodec_encode_audio2(audio_codec_context, &pkt, frame, &nsamples)==0)
+	nsamples = pkt.size;
+      else nsamples = 0;
+      av_free(frame);
       if(nsamples) {
 	slw = cont_handler->write_audio(cont_handler, av_buffer, nsamples);
 	if(slw) return;
openSUSE Build Service is sponsored by