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;
@@ -73,7 +73,7 @@
 		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;	
     }
 
@@ -85,29 +85,29 @@
 		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
@@ -442,7 +442,7 @@
 int xdtv_to_ffmpeg(int x) {
   switch(x) {
 #if LIBAVCODEC_BUILD >= 4719
-  case FFMPEG_XVID: return CODEC_ID_XVID;
+//  case FFMPEG_XVID: return CODEC_ID_XVID;
 #endif
   case FFMPEG_MPEG4: return CODEC_ID_MPEG4;
   case FFMPEG_MPEG1: return CODEC_ID_MPEG1VIDEO;
@@ -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,13 +1173,13 @@
       return;
     }
 
-    if (codec_context == NULL) codec_context = handle = avcodec_alloc_context();
+    if (codec_context == NULL) codec_context = handle = avcodec_alloc_context3(codec);
     picture_420p = avcodec_alloc_frame();
 
 // 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;
@@ -1207,15 +1207,15 @@
     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_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;
@@ -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;
@@ -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
@@ -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
@@ -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;
@@ -1456,7 +1456,7 @@
         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,7 +1466,7 @@
 
       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;
@@ -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;
@@ -1607,7 +1607,7 @@
     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;
     }
openSUSE Build Service is sponsored by