Author: Reinhard Tartler <siretart@tauware.de>
Description: Allow compilation against libav10

---
 applications/dashcast/video_decoder.c |    2 -
 modules/ffmpeg_in/ffmpeg_decode.c     |   56 +++++++++++++++++-----------------
 modules/ffmpeg_in/ffmpeg_demux.c      |   22 +++++--------
 3 files changed, 38 insertions(+), 42 deletions(-)

--- gpac.orig/applications/dashcast/video_decoder.c
+++ gpac/applications/dashcast/video_decoder.c
@@ -347,7 +347,7 @@ int dc_video_decoder_read(VideoInputFile
 				//But if the input is raw and there is no need to decode then
 				// the packet is directly passed for decoded frame. We must wait until rescale is done before freeing it
 
-				if (codec_ctx->codec->id == CODEC_ID_RAWVIDEO) {
+				if (codec_ctx->codec->id == AV_CODEC_ID_RAWVIDEO) {
 					video_data_node->nb_raw_frames_ref = video_input_file->nb_consumers;
 
 					video_data_node->raw_packet = packet;
--- gpac.orig/modules/ffmpeg_in/ffmpeg_decode.c
+++ gpac/modules/ffmpeg_in/ffmpeg_decode.c
@@ -102,7 +102,7 @@ static void FFDEC_LoadDSI(FFDec *ffd, GF
 	}
 
 	switch (codec->id) {
-	case CODEC_ID_SVQ3:
+	case AV_CODEC_ID_SVQ3:
 	{
 		u32 at_type, size;
 		size = gf_bs_read_u32(bs);
@@ -240,10 +240,10 @@ static GF_Err FFDEC_AttachStream(GF_Base
 			(*ctx)->codec_type = AVMEDIA_TYPE_VIDEO;
 			switch (ffd->oti) {
 			case GPAC_OTI_VIDEO_MPEG4_PART2:
-				codec_id = CODEC_ID_MPEG4;
+				codec_id = AV_CODEC_ID_MPEG4;
 				break;
 			case GPAC_OTI_VIDEO_AVC:
-				codec_id = CODEC_ID_H264;
+				codec_id = AV_CODEC_ID_H264;
 				break;
 #ifdef HAS_HEVC
 			case GPAC_OTI_VIDEO_HEVC:
@@ -257,14 +257,14 @@ static GF_Err FFDEC_AttachStream(GF_Base
 			case GPAC_OTI_VIDEO_MPEG2_SPATIAL:
 			case GPAC_OTI_VIDEO_MPEG2_HIGH:
 			case GPAC_OTI_VIDEO_MPEG2_422:
-				codec_id = CODEC_ID_MPEG2VIDEO;
+				codec_id = AV_CODEC_ID_MPEG2VIDEO;
 				break;
 			case GPAC_OTI_IMAGE_JPEG:
-				codec_id = CODEC_ID_MJPEG;
+				codec_id = AV_CODEC_ID_MJPEG;
 				ffd->is_image=1;
 				break;
 			case 0xFF:
-				codec_id = CODEC_ID_SVQ3;
+				codec_id = AV_CODEC_ID_SVQ3;
 				break;
 			}
 		} else if (ffd->st==GF_STREAM_AUDIO) {
@@ -273,18 +273,18 @@ static GF_Err FFDEC_AttachStream(GF_Base
 			case GPAC_OTI_AUDIO_MPEG2_PART3:
 			case GPAC_OTI_AUDIO_MPEG1:
 				(*ctx)->frame_size = 1152;
-				codec_id = CODEC_ID_MP2;
+				codec_id = AV_CODEC_ID_MP2;
 				break;
 			case GPAC_OTI_AUDIO_AC3:
-				codec_id = CODEC_ID_AC3;
+				codec_id = AV_CODEC_ID_AC3;
 				break;
 			case GPAC_OTI_AUDIO_EAC3:
-				codec_id = CODEC_ID_EAC3;
+				codec_id = AV_CODEC_ID_EAC3;
 				break;
 			}
 		}
 		else if ((ffd->st==GF_STREAM_ND_SUBPIC) && (ffd->oti==0xe0)) {
-			codec_id = CODEC_ID_DVD_SUBTITLE;
+			codec_id = AV_CODEC_ID_DVD_SUBTITLE;
 		}
 		*codec = avcodec_find_decoder(codec_id);
 	}
@@ -375,8 +375,8 @@ static GF_Err FFDEC_AttachStream(GF_Base
 #endif //HAS_HEVC
 	if (!ffd->output_cb_size) ffd->output_cb_size = 4;
 
-	if (codec_id == CODEC_ID_RAWVIDEO) {
-		(*ctx)->codec_id = CODEC_ID_RAWVIDEO;
+	if (codec_id == AV_CODEC_ID_RAWVIDEO) {
+		(*ctx)->codec_id = AV_CODEC_ID_RAWVIDEO;
 		(*ctx)->pix_fmt = ffd->raw_pix_fmt;
 		if ((*ctx)->extradata && strstr((char *) (*ctx)->extradata, "BottomUp")) ffd->flipped = 1;
 	} else {
@@ -388,7 +388,7 @@ static GF_Err FFDEC_AttachStream(GF_Base
 	}
 	/*setup audio streams*/
 	if (ffd->st==GF_STREAM_AUDIO) {
-		if ((*codec)->id == CODEC_ID_MP2) {
+		if ((*codec)->id == AV_CODEC_ID_MP2) {
 			(*ctx)->frame_size = ((*ctx)->sample_rate > 24000) ? 1152 : 576;
 		}
 		/*may be 0 (cfg not known yet)*/
@@ -408,17 +408,17 @@ static GF_Err FFDEC_AttachStream(GF_Base
 
 	} else {
 		switch ((*codec)->id) {
-		case CODEC_ID_MJPEG:
-		case CODEC_ID_MJPEGB:
-		case CODEC_ID_LJPEG:
+		case AV_CODEC_ID_MJPEG:
+		case AV_CODEC_ID_MJPEGB:
+		case AV_CODEC_ID_LJPEG:
 #if (LIBAVCODEC_VERSION_INT > AV_VERSION_INT(51, 20, 0))
-		case CODEC_ID_GIF:
+		case AV_CODEC_ID_GIF:
 #endif
-		case CODEC_ID_RAWVIDEO:
+		case AV_CODEC_ID_RAWVIDEO:
 			ffd->pix_fmt = GF_PIXEL_RGB_24;
 			break;
 
-		case CODEC_ID_DVD_SUBTITLE:
+		case AV_CODEC_ID_DVD_SUBTITLE:
 #ifndef FF_API_AVFRAME_LAVC
 			*frame = avcodec_alloc_frame();
 #else
@@ -816,7 +816,7 @@ redecode:
 	}
 
 
-	if ( ctx->codec_id == CODEC_ID_RAWVIDEO) {
+	if ( ctx->codec_id == AV_CODEC_ID_RAWVIDEO) {
 		if (*outBufferLength != ffd->out_size) {
 			*outBufferLength = ffd->out_size;
 			return GF_BUFFER_TOO_SMALL;
@@ -913,7 +913,7 @@ redecode:
 				/*OK we loose the DSI stored in the codec context, but H263 doesn't need any, and if we're
 				here this means the DSI was broken, so no big deal*/
 				avcodec_close(ctx);
-				*codec = avcodec_find_decoder(CODEC_ID_H263);
+				*codec = avcodec_find_decoder(AV_CODEC_ID_H263);
 
 #ifdef USE_AVCTX3
 				if (! (*codec) || (avcodec_open2(ctx, *codec, NULL)<0)) return GF_NON_COMPLIANT_BITSTREAM;
@@ -1236,13 +1236,13 @@ static u32 FFDEC_CanHandleStream(GF_Base
 		switch (ffd->oti) {
 		case GPAC_OTI_AUDIO_MPEG2_PART3:
 		case GPAC_OTI_AUDIO_MPEG1:
-			codec_id = CODEC_ID_MP2;
+			codec_id = AV_CODEC_ID_MP2;
 			break;
 		case GPAC_OTI_AUDIO_AC3:
-			codec_id = CODEC_ID_AC3;
+			codec_id = AV_CODEC_ID_AC3;
 			break;
 		case GPAC_OTI_AUDIO_EAC3:
-			codec_id = CODEC_ID_EAC3;
+			codec_id = AV_CODEC_ID_EAC3;
 			break;
 		}
 	}
@@ -1282,11 +1282,11 @@ static u32 FFDEC_CanHandleStream(GF_Base
 		switch (ffd->oti) {
 		/*MPEG-4 v1 simple profile*/
 		case GPAC_OTI_VIDEO_MPEG4_PART2:
-			codec_id = CODEC_ID_MPEG4;
+			codec_id = AV_CODEC_ID_MPEG4;
 			break;
 		/*H264 (not std OTI, just the way we use it internally)*/
 		case GPAC_OTI_VIDEO_AVC:
-			codec_id = CODEC_ID_H264;
+			codec_id = AV_CODEC_ID_H264;
 			break;
 #ifdef HAS_HEVC
 		case GPAC_OTI_VIDEO_HEVC:
@@ -1302,11 +1302,11 @@ static u32 FFDEC_CanHandleStream(GF_Base
 		case GPAC_OTI_VIDEO_MPEG2_SPATIAL:
 		case GPAC_OTI_VIDEO_MPEG2_HIGH:
 		case GPAC_OTI_VIDEO_MPEG2_422:
-			codec_id = CODEC_ID_MPEG2VIDEO;
+			codec_id = AV_CODEC_ID_MPEG2VIDEO;
 			break;
 		/*JPEG*/
 		case GPAC_OTI_IMAGE_JPEG:
-			codec_id = CODEC_ID_MJPEG;
+			codec_id = AV_CODEC_ID_MJPEG;
 			/*return maybe supported as FFMPEG JPEG decoder has some issues with many files, so let's use it only if no
 			other dec is available*/
 			if (avcodec_find_decoder(codec_id) != NULL)
--- gpac.orig/modules/ffmpeg_in/ffmpeg_demux.c
+++ gpac/modules/ffmpeg_in/ffmpeg_demux.c
@@ -54,7 +54,7 @@
 #endif /* AVERROR_NOFMT */
 
 
-#if (LIBAVFORMAT_VERSION_MAJOR >= 54) && (LIBAVFORMAT_VERSION_MINOR >= 20)
+#if ((LIBAVFORMAT_VERSION_MAJOR >= 54) && (LIBAVFORMAT_VERSION_MINOR >= 20)) || (LIBAVFORMAT_VERSION_MAJOR >= 55)
 
 #define av_find_stream_info(__c)	avformat_find_stream_info(__c, NULL)
 #ifndef FF_API_FORMAT_PARAMETERS
@@ -337,13 +337,13 @@ static GF_ESD *FFD_GetESDescriptor(FFDem
 		AVCodecContext *dec = ffd->ctx->streams[ffd->audio_st]->codec;
 		esd->slConfig->timestampResolution = ffd->audio_tscale.den;
 		switch (dec->codec_id) {
-		case CODEC_ID_MP2:
+		case AV_CODEC_ID_MP2:
 			esd->decoderConfig->objectTypeIndication = GPAC_OTI_AUDIO_MPEG1;
 			break;
-		case CODEC_ID_MP3:
+		case AV_CODEC_ID_MP3:
 			esd->decoderConfig->objectTypeIndication = GPAC_OTI_AUDIO_MPEG2_PART3;
 			break;
-		case CODEC_ID_AAC:
+		case AV_CODEC_ID_AAC:
 			if (!dec->extradata_size) goto opaque_audio;
 			esd->decoderConfig->objectTypeIndication = GPAC_OTI_AUDIO_AAC_MPEG4;
 			esd->decoderConfig->decoderSpecificInfo->dataLength = dec->extradata_size;
@@ -378,25 +378,25 @@ opaque_audio:
 		AVCodecContext *dec = ffd->ctx->streams[ffd->video_st]->codec;
 		esd->slConfig->timestampResolution = ffd->video_tscale.den;
 		switch (dec->codec_id) {
-		case CODEC_ID_MPEG4:
+		case AV_CODEC_ID_MPEG4:
 			/*there is a bug in fragmentation of raw H264 in ffmpeg, the NALU startcode (0x00000001) is split across
 			two frames - we therefore force internal ffmpeg codec ID to avoid NALU size recompute
 			at the decoder level*/
-//		case CODEC_ID_H264:
+//		case AV_CODEC_ID_H264:
 			/*if dsi not detected force use ffmpeg*/
 			if (!dec->extradata_size) goto opaque_video;
 			/*otherwise use any MPEG-4 Visual*/
-			esd->decoderConfig->objectTypeIndication = (dec->codec_id==CODEC_ID_H264) ? GPAC_OTI_VIDEO_AVC : GPAC_OTI_VIDEO_MPEG4_PART2;
+			esd->decoderConfig->objectTypeIndication = (dec->codec_id==AV_CODEC_ID_H264) ? GPAC_OTI_VIDEO_AVC : GPAC_OTI_VIDEO_MPEG4_PART2;
 			esd->decoderConfig->decoderSpecificInfo->dataLength = dec->extradata_size;
 			esd->decoderConfig->decoderSpecificInfo->data = gf_malloc(sizeof(char)*dec->extradata_size);
 			memcpy(esd->decoderConfig->decoderSpecificInfo->data,
 			       dec->extradata,
 			       sizeof(char)*dec->extradata_size);
 			break;
-		case CODEC_ID_MPEG1VIDEO:
+		case AV_CODEC_ID_MPEG1VIDEO:
 			esd->decoderConfig->objectTypeIndication = GPAC_OTI_VIDEO_MPEG1;
 			break;
-		case CODEC_ID_MPEG2VIDEO:
+		case AV_CODEC_ID_MPEG2VIDEO:
 			esd->decoderConfig->objectTypeIndication = GPAC_OTI_VIDEO_MPEG2_422;
 			break;
 		default:
@@ -594,11 +594,7 @@ static GF_Err FFD_ConnectService(GF_Inpu
 			}
 			/*setup downloader*/
 			av_in->flags |= AVFMT_NOFILE;
-#if FF_API_FORMAT_PARAMETERS /*commit ffmpeg 603b8bc2a109978c8499b06d2556f1433306eca7*/
 			res = avformat_open_input(&ffd->ctx, szName, av_in, NULL);
-#else
-			res = av_open_input_stream(&ffd->ctx, &ffd->io, szName, av_in, NULL);
-#endif
 		}
 	} else {
 		res = open_file(&ffd->ctx, szName, av_in);
