You've already forked FFmpeg
							
							
				mirror of
				https://github.com/FFmpeg/FFmpeg.git
				synced 2025-10-30 23:18:11 +02:00 
			
		
		
		
	avcodec/nvenc: let preset decide default gop size
Default GOP size is now set by preset and tuning info. This GOP size is only overwriten if -g value is provided. Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
This commit is contained in:
		
				
					committed by
					
						 Timo Rothenpieler
						Timo Rothenpieler
					
				
			
			
				
	
			
			
			
						parent
						
							997d8a7e73
						
					
				
				
					commit
					99dfdb45a8
				
			| @@ -1171,8 +1171,8 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx) | ||||
|  | ||||
|     if (ctx->intra_refresh) { | ||||
|         h264->enableIntraRefresh = 1; | ||||
|         h264->intraRefreshPeriod = avctx->gop_size; | ||||
|         h264->intraRefreshCnt = avctx->gop_size - 1; | ||||
|         h264->intraRefreshPeriod = cc->gopLength; | ||||
|         h264->intraRefreshCnt = cc->gopLength - 1; | ||||
| #ifdef NVENC_HAVE_SINGLE_SLICE_INTRA_REFRESH | ||||
|         h264->singleSliceIntraRefresh = ctx->single_slice_intra_refresh; | ||||
| #endif | ||||
| @@ -1192,8 +1192,8 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx) | ||||
|  | ||||
|     if (ctx->intra_refresh) { | ||||
|         h264->idrPeriod = NVENC_INFINITE_GOPLENGTH; | ||||
|     } else if (avctx->gop_size >= 0) { | ||||
|         h264->idrPeriod = avctx->gop_size; | ||||
|     } else if (cc->gopLength > 0) { | ||||
|         h264->idrPeriod = cc->gopLength; | ||||
|     } | ||||
|  | ||||
|     if (IS_CBR(cc->rcParams.rateControlMode)) { | ||||
| @@ -1295,8 +1295,8 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx) | ||||
|  | ||||
|     if (ctx->intra_refresh) { | ||||
|         hevc->enableIntraRefresh = 1; | ||||
|         hevc->intraRefreshPeriod = avctx->gop_size; | ||||
|         hevc->intraRefreshCnt = avctx->gop_size - 1; | ||||
|         hevc->intraRefreshPeriod = cc->gopLength; | ||||
|         hevc->intraRefreshCnt = cc->gopLength - 1; | ||||
| #ifdef NVENC_HAVE_SINGLE_SLICE_INTRA_REFRESH | ||||
|         hevc->singleSliceIntraRefresh = ctx->single_slice_intra_refresh; | ||||
| #endif | ||||
| @@ -1318,8 +1318,8 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx) | ||||
|  | ||||
|     if (ctx->intra_refresh) { | ||||
|         hevc->idrPeriod = NVENC_INFINITE_GOPLENGTH; | ||||
|     } else if (avctx->gop_size >= 0) { | ||||
|         hevc->idrPeriod = avctx->gop_size; | ||||
|     } else if (cc->gopLength > 0) { | ||||
|         hevc->idrPeriod = cc->gopLength; | ||||
|     } | ||||
|  | ||||
|     if (IS_CBR(cc->rcParams.rateControlMode)) { | ||||
| @@ -1413,12 +1413,12 @@ static av_cold int nvenc_setup_av1_config(AVCodecContext *avctx) | ||||
|  | ||||
|     if (ctx->intra_refresh) { | ||||
|         av1->enableIntraRefresh = 1; | ||||
|         av1->intraRefreshPeriod = avctx->gop_size; | ||||
|         av1->intraRefreshCnt = avctx->gop_size - 1; | ||||
|         av1->intraRefreshPeriod = cc->gopLength; | ||||
|         av1->intraRefreshCnt = cc->gopLength - 1; | ||||
|  | ||||
|         av1->idrPeriod = NVENC_INFINITE_GOPLENGTH; | ||||
|     } else if (avctx->gop_size >= 0) { | ||||
|         av1->idrPeriod = avctx->gop_size; | ||||
|     } else if (cc->gopLength > 0) { | ||||
|         av1->idrPeriod = cc->gopLength; | ||||
|     } | ||||
|  | ||||
|     if (IS_CBR(cc->rcParams.rateControlMode)) { | ||||
| @@ -1603,17 +1603,18 @@ FF_ENABLE_DEPRECATION_WARNINGS | ||||
|     } | ||||
|  | ||||
|     if (avctx->gop_size > 0) { | ||||
|         if (avctx->max_b_frames >= 0) { | ||||
|             /* 0 is intra-only, 1 is I/P only, 2 is one B-Frame, 3 two B-frames, and so on. */ | ||||
|             ctx->encode_config.frameIntervalP = avctx->max_b_frames + 1; | ||||
|         } | ||||
|  | ||||
|         // only overwrite preset if a GOP size was selected as input | ||||
|         ctx->encode_config.gopLength = avctx->gop_size; | ||||
|     } else if (avctx->gop_size == 0) { | ||||
|         ctx->encode_config.frameIntervalP = 0; | ||||
|         ctx->encode_config.gopLength = 1; | ||||
|     } | ||||
|  | ||||
|     if (avctx->max_b_frames >= 0 && ctx->encode_config.gopLength > 1) { | ||||
|         /* 0 is intra-only, 1 is I/P only, 2 is one B-Frame, 3 two B-frames, and so on. */ | ||||
|         ctx->encode_config.frameIntervalP = avctx->max_b_frames + 1; | ||||
|     } | ||||
|  | ||||
|     /* force to enable intra refresh */ | ||||
|     if(ctx->single_slice_intra_refresh) | ||||
|         ctx->intra_refresh = 1; | ||||
|   | ||||
| @@ -154,7 +154,7 @@ static const FFCodecDefault defaults[] = { | ||||
|     { "qdiff", "-1" }, | ||||
|     { "qblur", "-1" }, | ||||
|     { "qcomp", "-1" }, | ||||
|     { "g", "250" }, | ||||
|     { "g", "-1" }, | ||||
|     { "bf", "-1" }, | ||||
|     { "refs", "0" }, | ||||
|     { NULL }, | ||||
|   | ||||
| @@ -218,7 +218,7 @@ static const FFCodecDefault defaults[] = { | ||||
|     { "qdiff", "-1" }, | ||||
|     { "qblur", "-1" }, | ||||
|     { "qcomp", "-1" }, | ||||
|     { "g", "250" }, | ||||
|     { "g", "-1" }, | ||||
|     { "bf", "-1" }, | ||||
|     { "refs", "0" }, | ||||
|     { NULL }, | ||||
|   | ||||
| @@ -199,7 +199,7 @@ static const FFCodecDefault defaults[] = { | ||||
|     { "qdiff", "-1" }, | ||||
|     { "qblur", "-1" }, | ||||
|     { "qcomp", "-1" }, | ||||
|     { "g", "250" }, | ||||
|     { "g", "-1" }, | ||||
|     { "bf", "-1" }, | ||||
|     { "refs", "0" }, | ||||
|     { NULL }, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user