Attached is an updated ffmpeg patch that supports both the included
ffmpeg version and external ffmpeg. This patch also fixes issues with
fileac3.C.

This patch appears to work on both 2.1.5 and 2.2 versions of Cinelerra.

Regards,
Paul

On Thu, 2011-09-22 at 14:04 +1200, E Chalaron wrote: 

> The patch leads now to  the AC3 problem.
> 
> fileac3.C:255:3: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C: In member function ‘void AC3ConfigAudio::create_objects()’:
> fileac3.C:265:47: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C: In member function ‘void 
> AC3ConfigAudioBitrate::create_objects()’:
> fileac3.C:308:31: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:308:31: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:309:31: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:309:31: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:310:31: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:310:31: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:311:31: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:311:31: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:312:31: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:312:31: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:313:31: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:313:31: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:314:31: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:314:31: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:315:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:315:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:316:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:316:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:317:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:317:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:318:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:318:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:319:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:319:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:320:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:320:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:321:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:321:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:322:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:322:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:323:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:323:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:324:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:324:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:325:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:325:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:326:32: warning: deprecated conversion from string constant to 
> ‘char*’
> fileac3.C:326:32: warning: deprecated conversion from string constant to 
> ‘char*’
> make[3]: *** [fileac3.o] Error 1
> mv -f .deps/dcraw.Tpo .deps/dcraw.Po
> make[3]: Leaving directory `/home/edouard/Desktop/CinelerraCV/cinelerra'
> make[2]: *** [all-recursive] Error 1
> make[2]: Leaving directory `/home/edouard/Desktop/CinelerraCV/cinelerra'
> make[1]: *** [all-recursive] Error 1
> make[1]: Leaving directory `/home/edouard/Desktop/CinelerraCV'
> make: *** [all] Error 2
> 
> 
> 
> _______________________________________________
> Cinelerra mailing list
> Cinelerra@skolelinux.no
> https://init.linpro.no/mailman/skolelinux.no/listinfo/cinelerra


diff -ur cinelerra-cv_orig/cinelerra/ffmpeg.C cinelerra-cv_fixed/cinelerra/ffmpeg.C
--- cinelerra-cv_orig/cinelerra/ffmpeg.C	2011-09-06 12:00:27.000000000 -0400
+++ cinelerra-cv_fixed/cinelerra/ffmpeg.C	2011-09-05 10:52:57.000000000 -0400
@@ -364,12 +364,24 @@
 
 	// NOTE: frame must already have data space allocated
 	
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
 	got_picture = 0;
 	int length = avcodec_decode_video(context,
 					  picture,
 					  &got_picture,
 					  data,
 					  data_size);
+#else	
+	AVPacket pkt;
+	got_picture = 0;
+	av_init_packet( &pkt );
+	pkt.data = data;
+	pkt.size = data_size;
+	int length = avcodec_decode_video2(context,
+					  picture,
+					  &got_picture,
+					  &pkt);
+#endif
 	
 	if (length < 0) {
 		printf("FFMPEG::decode error decoding frame\n");
diff -ur cinelerra-cv_orig/cinelerra/fileac3.C cinelerra-cv_fixed/cinelerra/fileac3.C
--- cinelerra-cv_orig/cinelerra/fileac3.C	2011-09-06 12:00:27.000000000 -0400
+++ cinelerra-cv_fixed/cinelerra/fileac3.C	2011-09-05 15:10:15.000000000 -0400
@@ -96,9 +96,44 @@
 		codec_context->bit_rate = asset->ac3_bitrate * 1000;
 		codec_context->sample_rate = asset->sample_rate;
 		codec_context->channels = asset->channels;
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
+		codec_context->sample_fmt = SAMPLE_FMT_S16;
+#else	
+		codec_context->sample_fmt = AV_SAMPLE_FMT_S16;
+		switch(asset->channels)
+		{
+			case 1:
+				codec_context->channel_layout = AV_CH_LAYOUT_MONO;
+				break;
+			case 2:
+				codec_context->channel_layout = AV_CH_LAYOUT_STEREO;
+				break;
+			case 3:
+				codec_context->channel_layout = AV_CH_LAYOUT_SURROUND;
+				break;
+			case 4:
+				codec_context->channel_layout = AV_CH_LAYOUT_QUAD;
+				break;
+			case 5:
+				codec_context->channel_layout = AV_CH_LAYOUT_5POINT0;
+				break;
+			case 6:
+				codec_context->channel_layout = AV_CH_LAYOUT_5POINT1;
+				break;
+			case 7:
+				codec_context->channel_layout = AV_CH_LAYOUT_7POINT0;
+				break;
+			case 8:
+				codec_context->channel_layout = AV_CH_LAYOUT_7POINT1;
+				break;
+			default:
+				codec_context->channel_layout = AV_CH_LAYOUT_NATIVE;
+				break;
+		}
+#endif
 		if(avcodec_open(codec_context, codec))
 		{
 			eprintf("failed to open codec.\n");
 			return 1;
 		}
 
diff -ur cinelerra-cv_orig/configure.in cinelerra-cv_fixed/configure.in
--- cinelerra-cv_orig/configure.in	2011-09-06 12:00:27.000000000 -0400
+++ cinelerra-cv_fixed/configure.in	2011-09-06 11:32:59.000000000 -0400
@@ -361,6 +361,7 @@
      else
 	     PKG_CHECK_MODULES([FFMPEG], [libavcodec libpostproc])
      fi
+     FFMPEG_CFLAGS="$FFMPEG_CFLAGS -D__STDC_CONSTANT_MACROS"
      FFMPEG_EXTERNALTEXT="External ffmpeg"
 else
      FFMPEG_FOLDER=ffmpeg
diff -ur cinelerra-cv_orig/quicktime/mpeg4.c cinelerra-cv_fixed/quicktime/mpeg4.c
--- cinelerra-cv_orig/quicktime/mpeg4.c	2011-09-06 12:00:29.000000000 -0400
+++ cinelerra-cv_fixed/quicktime/mpeg4.c	2011-09-01 18:05:10.000000000 -0400
@@ -720,7 +720,9 @@
 			         codec->ffmpeg_id == CODEC_ID_H263P || 
 			         codec->ffmpeg_id == CODEC_FLAG_H263P_SLICE_STRUCT))
 			{
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
				avcodec_thread_init(context, file->cpus);
+#endif
 				context->thread_count = file->cpus;
 			}
 
diff -ur cinelerra-cv_orig/quicktime/qtffmpeg.c cinelerra-cv_fixed/quicktime/qtffmpeg.c
--- cinelerra-cv_orig/quicktime/qtffmpeg.c	2011-09-06 12:00:29.000000000 -0400
+++ cinelerra-cv_fixed/quicktime/qtffmpeg.c	2011-09-01 18:03:35.000000000 -0400
@@ -93,7 +93,9 @@
 			         ffmpeg_id == CODEC_ID_H263P || 
 			         ffmpeg_id == CODEC_FLAG_H263P_SLICE_STRUCT))
 		{
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
			avcodec_thread_init(context, cpus);
+#endif
 			context->thread_count = cpus;
 		}
 		if(avcodec_open(context, 
@@ -181,6 +183,9 @@
  
 	if(!result) 
 	{ 
+#if LIBAVCODEC_VERSION_INT > ((52<<16)+(0<<8)+0)
+		AVPacket pkt;
+#endif
 
 
 // No way to determine if there was an error based on nonzero status.
@@ -189,11 +194,21 @@
 			ffmpeg->decoder_context[current_field]->skip_frame = AVDISCARD_NONREF /* AVDISCARD_BIDIR */;
 		else
 			ffmpeg->decoder_context[current_field]->skip_frame = AVDISCARD_DEFAULT;
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
 		result = avcodec_decode_video(ffmpeg->decoder_context[current_field], 
 			&ffmpeg->picture[current_field], 
 			&got_picture, 
 			ffmpeg->work_buffer, 
 			bytes + header_bytes);
+#else
+		av_init_packet( &pkt );
+		pkt.data = ffmpeg->work_buffer;
+		pkt.size = bytes + header_bytes;
+		result = avcodec_decode_video2(ffmpeg->decoder_context[current_field], 
+ 			&ffmpeg->picture[current_field], 
+ 			&got_picture, 
+			&pkt);
+#endif
 
 
 
diff -ur cinelerra-cv_orig/quicktime/wma.c cinelerra-cv_fixed/quicktime/wma.c
--- cinelerra-cv_orig/quicktime/wma.c	2011-09-06 12:00:29.000000000 -0400
+++ cinelerra-cv_fixed/quicktime/wma.c	2011-08-30 13:49:41.000000000 -0400
@@ -187,19 +187,22 @@
 
 // Decode chunk into work buffer.
 		pthread_mutex_lock(&ffmpeg_lock);
-#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
-		result = avcodec_decode_audio(codec->decoder_context, 
-			(int16_t*)(codec->work_buffer + codec->output_size * sample_size), 
-			&bytes_decoded,
-			codec->packet_buffer,
-			chunk_size);
-#else
 		bytes_decoded = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(26<<8)+0)
 		result = avcodec_decode_audio2(codec->decoder_context,
 			(int16_t*)(codec->work_buffer + codec->output_size * sample_size),
 			&bytes_decoded,
 			codec->packet_buffer,
 			chunk_size);
+#else
+		AVPacket pkt;
+		av_init_packet( &pkt );
+		pkt.data = codec->packet_buffer;
+		pkt.size = chunk_size;
+		result = avcodec_decode_audio3(codec->decoder_context,
+			(int16_t*)(codec->work_buffer + codec->output_size * sample_size),
+			&bytes_decoded,
+			&pkt);
 #endif
 
 		pthread_mutex_unlock(&ffmpeg_lock);

Reply via email to