tags 739328 + patch
tags 739328 + pending
thanks

Dear maintainer,

I've prepared an NMU for lightspark (versioned as 0.7.2-3.1) and
uploaded it to DELAYED/02. Please feel free to tell me if I
should delay it longer.

Regards.
diff -Nru lightspark-0.7.2/debian/changelog lightspark-0.7.2/debian/changelog
--- lightspark-0.7.2/debian/changelog	2013-12-02 09:00:25.000000000 -0500
+++ lightspark-0.7.2/debian/changelog	2014-05-14 22:22:50.000000000 -0400
@@ -1,3 +1,10 @@
+lightspark (0.7.2-3.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTBFS against libav10 (Closes: #739328)
+
+ -- Reinhard Tartler <siret...@tauware.de>  Wed, 14 May 2014 22:22:03 -0400
+
 lightspark (0.7.2-3) unstable; urgency=low
 
   [ Sylvestre Ledru ]
diff -Nru lightspark-0.7.2/debian/patches/libav10.patch lightspark-0.7.2/debian/patches/libav10.patch
--- lightspark-0.7.2/debian/patches/libav10.patch	1969-12-31 19:00:00.000000000 -0500
+++ lightspark-0.7.2/debian/patches/libav10.patch	2014-05-14 22:22:44.000000000 -0400
@@ -0,0 +1,285 @@
+Description: Fix FTBFS against libav10
+Bug-Debian: http://bugs.debian.org/739328
+
+Most changes in this patch have been manually cherry-picked from upstream.
+The only missing change are the CODEC_ID -> AV_CODEC_ID renames
+
+Applied upstream git commits:
+
+* 9b20db3 fix compilation without HAVE_AVCODEC_DECODE_AUDIO4
+* e01bb75 Fix audio decoding when using avcodec_decode_audio2
+* e957947 Fix compilation when libavresample is not installed (Ubuntu) or AVCodecID is defined (new libavcodec)
+* 4d2d927 Add an include file (needed on Debian unstable)
+* fff7e63 fix compilation with ffmpeg 2.0 avcodec_decode_audio4 seems not to deliver data in AV_SAMPLE_FMT_S16 format, so we have to use libavresample for resampling
+
+
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -287,12 +287,17 @@ ENDIF(AUDIO_BACKEND)
+ 
+ IF(ENABLE_LIBAVCODEC)
+ 	pkg_check_modules(FFMPEG libavcodec libavutil libavformat)
++	pkg_check_modules(LIBAVRESAMPLE libavresample)
+ 	IF(NOT(FFMPEG_FOUND))
+ 		INCLUDE(FindFFMpeg REQUIRED)
+ 	ENDIF(NOT(FFMPEG_FOUND))
+ 	# Compatibility checks for ffmpeg deprecated functions
+   INCLUDE(CheckFunctionExists REQUIRED)
+-  SET(CMAKE_REQUIRED_FLAGS ${LIBAVCODEC_CFLAGS})
++  INCLUDE(CheckCSourceCompiles)
++  SET(FFMPEG_FLAGS "${LIBAVCODEC_CFLAGS} ${LIBAVRESAMPLE_FLAGS}")
++  SET(FFMPEG_INCLUDE_DIRS "${FFMPEG_INCLUDE_DIRS} ${LIBAVRESAMPLE_INCLUDE_DIRS}")
++  SET(FFMPEG_LIBRARIES "${FFMPEG_LIBRARIES};${LIBAVRESAMPLE_LIBRARIES}")
++  SET(CMAKE_REQUIRED_FLAGS ${FFMPEG_FLAGS})
+   SET(CMAKE_REQUIRED_INCLUDES ${FFMPEG_INCLUDE_DIRS})
+   SET(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES})
+   CHECK_FUNCTION_EXISTS(avcodec_decode_video2 HAVE_AVCODEC_DECODE_VIDEO2)
+@@ -303,7 +308,8 @@ IF(ENABLE_LIBAVCODEC)
+   CHECK_FUNCTION_EXISTS(avcodec_open2 HAVE_AVCODEC_OPEN2)
+   CHECK_FUNCTION_EXISTS(avformat_close_input HAVE_AVFORMAT_CLOSE_INPUT)
+   CHECK_FUNCTION_EXISTS(avformat_find_stream_info HAVE_AVFORMAT_FIND_STREAM_INFO)
+-  
++  CHECK_C_SOURCE_COMPILES("#include <libavcodec/avcodec.h>\nint main() { enum AVCodecID c; return 0; }" HAVE_AVCODECID)
++
+   SET(CMAKE_REQUIRED_FLAGS)
+   SET(CMAKE_REQUIRED_INCLUDES)
+   SET(CMAKE_REQUIRED_LIBRARIES)
+@@ -331,6 +337,12 @@ IF(ENABLE_LIBAVCODEC)
+   IF(HAVE_AVFORMAT_FIND_STREAM_INFO)
+     ADD_DEFINITIONS(-DHAVE_AVFORMAT_FIND_STREAM_INFO)
+   ENDIF(HAVE_AVFORMAT_FIND_STREAM_INFO)
++  IF(HAVE_AVCODECID)
++    ADD_DEFINITIONS(-DHAVE_AVCODECID)
++  ENDIF(HAVE_AVCODECID)
++  IF(LIBAVRESAMPLE_FOUND)
++    ADD_DEFINITIONS(-DHAVE_LIBAVRESAMPLE)
++  ENDIF(LIBAVRESAMPLE_FOUND)
+   ADD_DEFINITIONS(-DENABLE_LIBAVCODEC)
+ ENDIF(ENABLE_LIBAVCODEC)
+ 
+--- a/conf/FindFFMpeg.cmake
++++ b/conf/FindFFMpeg.cmake
+@@ -23,7 +23,11 @@ FIND_LIBRARY(FFMPEG_AVFORMAT_LIBRARY NAM
+     avformat
+ )
+ 
+-SET(FFMPEG_LIBRARY ${FFMPEG_AVCODEC_LIBRARY} ${FFMPEG_AVUTIL_LIBRARY} ${FFMPEG_AVFORMAT_LIBRARY})
++FIND_LIBRARY(FFMPEG_AVRESAMPLE_LIBRARY NAMES
++    avresample
++)
++
++SET(FFMPEG_LIBRARY ${FFMPEG_AVCODEC_LIBRARY} ${FFMPEG_AVUTIL_LIBRARY} ${FFMPEG_AVFORMAT_LIBRARY} ${FFMPEG_AVRESAMPLE_LIBRARY})
+ MARK_AS_ADVANCED(FFMPEG_LIBRARY)
+ 
+ # handle the QUIETLY and REQUIRED arguments and set FFMPEG_FOUND to TRUE if 
+--- a/src/backends/decoder.cpp
++++ b/src/backends/decoder.cpp
+@@ -119,7 +119,7 @@ FFMpegVideoDecoder::FFMpegVideoDecoder(L
+ 	if(codecId==H264)
+ 	{
+ 		//TODO: serialize access to avcodec_open
+-		const enum CodecID FFMPEGcodecId=CODEC_ID_H264;
++		const enum CodecID FFMPEGcodecId=AV_CODEC_ID_H264;
+ 		codec=avcodec_find_decoder(FFMPEGcodecId);
+ 		assert(codec);
+ 		//Ignore the frameRateHint as the rate is gathered from the video data
+@@ -127,7 +127,7 @@ FFMpegVideoDecoder::FFMpegVideoDecoder(L
+ 	else if(codecId==H263)
+ 	{
+ 		//TODO: serialize access to avcodec_open
+-		const enum CodecID FFMPEGcodecId=CODEC_ID_FLV1;
++		const enum CodecID FFMPEGcodecId=AV_CODEC_ID_FLV1;
+ 		codec=avcodec_find_decoder(FFMPEGcodecId);
+ 		assert(codec);
+ 
+@@ -138,7 +138,7 @@ FFMpegVideoDecoder::FFMpegVideoDecoder(L
+ 	else if(codecId==VP6)
+ 	{
+ 		//TODO: serialize access to avcodec_open
+-		const enum CodecID FFMPEGcodecId=CODEC_ID_VP6F;
++		const enum CodecID FFMPEGcodecId=AV_CODEC_ID_VP6F;
+ 		codec=avcodec_find_decoder(FFMPEGcodecId);
+ 		assert(codec);
+ 
+@@ -176,13 +176,13 @@ FFMpegVideoDecoder::FFMpegVideoDecoder(A
+ 	//The tag is the header, initialize decoding
+ 	switch(codecContext->codec_id)
+ 	{
+-		case CODEC_ID_H264:
++		case AV_CODEC_ID_H264:
+ 			videoCodec=H264;
+ 			break;
+-		case CODEC_ID_FLV1:
++		case AV_CODEC_ID_FLV1:
+ 			videoCodec=H263;
+ 			break;
+-		case CODEC_ID_VP6F:
++		case AV_CODEC_ID_VP6F:
+ 			videoCodec=VP6;
+ 			break;
+ 		default:
+@@ -295,6 +295,8 @@ bool FFMpegVideoDecoder::decodePacket(AV
+ #else
+ 	int ret=avcodec_decode_video(codecContext, frameIn, &frameOk, pkt->data, pkt->size);
+ #endif
++	if (ret < 0)
++		return false;
+ 
+ 	assert_and_throw(ret==(int)pkt->size);
+ 	if(frameOk)
+@@ -455,10 +457,10 @@ FFMpegAudioDecoder::FFMpegAudioDecoder(L
+ 	switch(audioCodec)
+ 	{
+ 		case AAC:
+-			codecId=CODEC_ID_AAC;
++			codecId=AV_CODEC_ID_AAC;
+ 			break;
+ 		case MP3:
+-			codecId=CODEC_ID_MP3;
++			codecId=AV_CODEC_ID_MP3;
+ 			break;
+ 		default:
+ 			::abort();
+@@ -566,22 +568,30 @@ uint32_t FFMpegAudioDecoder::decodeData(
+ 		ret=-1;
+ 	else
+ 	{
+-		//This is suboptimal but equivalent to what libavcodec
+-		//does for the compatibility version of avcodec_decode_audio3
+-		memcpy(curTail.samples, frameIn->extended_data[0], frameIn->linesize[0]);
+-		maxLen=frameIn->linesize[0];
++		if (frameIn->format != AV_SAMPLE_FMT_S16)
++		{
++			maxLen = resampleFrameToS16(curTail);
++		}
++		else 
++		{
++			//This is suboptimal but equivalent to what libavcodec
++			//does for the compatibility version of avcodec_decode_audio3
++			memcpy(curTail.samples, frameIn->extended_data[0], frameIn->linesize[0]);
++			maxLen=frameIn->linesize[0];
++		}
+ 	}
+ #else
+ 	int32_t ret=avcodec_decode_audio3(codecContext, curTail.samples, &maxLen, &pkt);
+ #endif
+-#else
+-	int32_t ret=avcodec_decode_audio2(codecContext, curTail.samples, &maxLen, data, datalen);
+-#endif
+ 	assert_and_throw(ret==datalen);
+ 
+ 	if(status==INIT && fillDataAndCheckValidity())
+ 		status=VALID;
+ 
++#else
++	int32_t ret=avcodec_decode_audio2(codecContext, curTail.samples, &maxLen, data, datalen);
++#endif
++
+ 	curTail.len=maxLen;
+ 	assert(!(curTail.len&0x80000000));
+ 	assert(maxLen%2==0);
+@@ -604,10 +614,17 @@ uint32_t FFMpegAudioDecoder::decodePacke
+ 		ret=-1;
+ 	else
+ 	{
+-		//This is suboptimal but equivalent to what libavcodec
+-		//does for the compatibility version of avcodec_decode_audio3
+-		memcpy(curTail.samples, frameIn->extended_data[0], frameIn->linesize[0]);
+-		maxLen=frameIn->linesize[0];
++		if (frameIn->format != AV_SAMPLE_FMT_S16)
++		{
++			maxLen = resampleFrameToS16(curTail);
++		}
++		else 
++		{
++			//This is suboptimal but equivalent to what libavcodec
++			//does for the compatibility version of avcodec_decode_audio3
++			memcpy(curTail.samples, frameIn->extended_data[0], frameIn->linesize[0]);
++			maxLen=frameIn->linesize[0];
++		}
+ 	}
+ #elif HAVE_AVCODEC_DECODE_AUDIO3
+ 	int ret=avcodec_decode_audio3(codecContext, curTail.samples, &maxLen, pkt);
+@@ -639,6 +656,36 @@ uint32_t FFMpegAudioDecoder::decodePacke
+ 	samplesBuffer.commitLast();
+ 	return maxLen;
+ }
++
++int FFMpegAudioDecoder::resampleFrameToS16(FrameSamples& curTail)
++{
++	int maxLen;
++#ifdef HAVE_LIBAVRESAMPLE
++	AVAudioResampleContext * avr = avresample_alloc_context();
++	av_opt_set_int(avr, "in_channel_layout",  frameIn->channel_layout, 0);
++	av_opt_set_int(avr, "out_channel_layout", frameIn->channel_layout,  0);
++	av_opt_set_int(avr, "in_sample_rate",     frameIn->sample_rate,     0);
++	av_opt_set_int(avr, "out_sample_rate",    frameIn->sample_rate,     0);
++	av_opt_set_int(avr, "in_sample_fmt",      frameIn->format,   0);
++	av_opt_set_int(avr, "out_sample_fmt",     AV_SAMPLE_FMT_S16,    0);
++	avresample_open(avr);
++
++	uint8_t *output;
++	int out_linesize;
++	int out_samples = avresample_available(avr) + av_rescale_rnd(avresample_get_delay(avr) + frameIn->linesize[0], frameIn->sample_rate, frameIn->sample_rate, AV_ROUND_UP);
++	av_samples_alloc(&output, &out_linesize, frameIn->nb_samples, out_samples, AV_SAMPLE_FMT_S16, 0);
++	maxLen = avresample_convert(avr, &output, out_linesize, out_samples, frameIn->extended_data, frameIn->linesize[0], frameIn->nb_samples)*4;
++	memcpy(curTail.samples, output, maxLen);
++	av_freep(&output);
++	avresample_free(&avr);
++#else
++	LOG(LOG_ERROR, "unexpected sample format and can't resample, recompile with libavresample");
++	memset(curTail.samples, 0, frameIn->linesize[0]);
++	maxLen = frameIn->linesize[0];
++#endif
++	return maxLen;
++}
++
+ #endif //ENABLE_LIBAVCODEC
+ 
+ StreamDecoder::~StreamDecoder()
+@@ -711,7 +758,7 @@ FFMpegStreamDecoder::FFMpegStreamDecoder
+ 			videoFound=true;
+ 			videoIndex=(int32_t)i;
+ 		}
+-		else if(formatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO && formatCtx->streams[i]->codec->codec_id!=CODEC_ID_NONE && audioFound==false)
++		else if(formatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO && formatCtx->streams[i]->codec->codec_id!=AV_CODEC_ID_NONE && audioFound==false)
+ 		{
+ 			audioFound=true;
+ 			audioIndex=(int32_t)i;
+@@ -721,7 +768,7 @@ FFMpegStreamDecoder::FFMpegStreamDecoder
+ 	if(videoFound)
+ 	{
+ 		//Pass the frame rate from the container, the once from the codec is often wrong
+-		double frameRate=av_q2d(formatCtx->streams[videoIndex]->r_frame_rate);
++		double frameRate=av_q2d(formatCtx->streams[videoIndex]->avg_frame_rate);
+ 		customVideoDecoder=new FFMpegVideoDecoder(formatCtx->streams[videoIndex]->codec,frameRate);
+ 		videoDecoder=customVideoDecoder;
+ 	}
+--- a/src/backends/decoder.h
++++ b/src/backends/decoder.h
+@@ -28,6 +28,17 @@ extern "C"
+ {
+ #include <libavcodec/avcodec.h>
+ #include <libavformat/avformat.h>
++#ifdef HAVE_LIBAVRESAMPLE
++#include <libavresample/avresample.h>
++#endif
++#include <libavutil/opt.h>
++#include <libavutil/mathematics.h>
++#ifndef AVCODEC_MAX_AUDIO_FRAME_SIZE
++#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
++#endif
++#ifdef HAVE_AVCODECID
++#define CodecID AVCodecID
++#endif
+ #define MAX_AUDIO_FRAME_SIZE AVCODEC_MAX_AUDIO_FRAME_SIZE
+ }
+ #else
+@@ -281,6 +292,7 @@ private:
+ #if HAVE_AVCODEC_DECODE_AUDIO4
+ 	AVFrame* frameIn;
+ #endif
++	int resampleFrameToS16(FrameSamples& curTail);
+ public:
+ 	FFMpegAudioDecoder(LS_AUDIO_CODEC codec, uint8_t* initdata, uint32_t datalen);
+ 	/*
diff -Nru lightspark-0.7.2/debian/patches/series lightspark-0.7.2/debian/patches/series
--- lightspark-0.7.2/debian/patches/series	2013-11-29 13:30:28.000000000 -0500
+++ lightspark-0.7.2/debian/patches/series	2014-05-14 22:12:31.000000000 -0400
@@ -1 +1,2 @@
 fix-for-llvm33.patch
+libav10.patch

Reply via email to