mirror of
				https://github.com/nyanmisaka/ffmpeg-rockchip.git
				synced 2025-10-31 12:36:41 +08:00 
			
		
		
		
	imc: convert to new channel layout API
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
		 Anton Khirnov
					Anton Khirnov
				
			
				
					committed by
					
						 James Almer
						James Almer
					
				
			
			
				
	
			
			
			 James Almer
						James Almer
					
				
			
						parent
						
							c67dd4eff9
						
					
				
				
					commit
					2c15e1975a
				
			| @@ -206,15 +206,17 @@ static av_cold int imc_decode_init(AVCodecContext *avctx) | |||||||
|         return AVERROR_PATCHWELCOME; |         return AVERROR_PATCHWELCOME; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (avctx->codec_id == AV_CODEC_ID_IMC) |     if (avctx->codec_id == AV_CODEC_ID_IMC) { | ||||||
|         avctx->channels = 1; |         av_channel_layout_uninit(&avctx->ch_layout); | ||||||
|  |         avctx->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     if (avctx->channels > 2) { |     if (avctx->ch_layout.nb_channels > 2) { | ||||||
|         avpriv_request_sample(avctx, "Number of channels > 2"); |         avpriv_request_sample(avctx, "Number of channels > 2"); | ||||||
|         return AVERROR_PATCHWELCOME; |         return AVERROR_PATCHWELCOME; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     for (j = 0; j < avctx->channels; j++) { |     for (j = 0; j < avctx->ch_layout.nb_channels; j++) { | ||||||
|         q->chctx[j].decoder_reset = 1; |         q->chctx[j].decoder_reset = 1; | ||||||
|  |  | ||||||
|         for (i = 0; i < BANDS; i++) |         for (i = 0; i < BANDS; i++) | ||||||
| @@ -270,8 +272,6 @@ static av_cold int imc_decode_init(AVCodecContext *avctx) | |||||||
|     ff_bswapdsp_init(&q->bdsp); |     ff_bswapdsp_init(&q->bdsp); | ||||||
|  |  | ||||||
|     avctx->sample_fmt     = AV_SAMPLE_FMT_FLTP; |     avctx->sample_fmt     = AV_SAMPLE_FMT_FLTP; | ||||||
|     avctx->channel_layout = avctx->channels == 1 ? AV_CH_LAYOUT_MONO |  | ||||||
|                                                  : AV_CH_LAYOUT_STEREO; |  | ||||||
|  |  | ||||||
|     ff_thread_once(&init_static_once, imc_init_static); |     ff_thread_once(&init_static_once, imc_init_static); | ||||||
|  |  | ||||||
| @@ -1013,7 +1013,7 @@ static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch) | |||||||
|  |  | ||||||
|     memset(chctx->skipFlags, 0, sizeof(chctx->skipFlags)); |     memset(chctx->skipFlags, 0, sizeof(chctx->skipFlags)); | ||||||
|  |  | ||||||
|     imc_imdct256(q, chctx, avctx->channels); |     imc_imdct256(q, chctx, avctx->ch_layout.nb_channels); | ||||||
|  |  | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
| @@ -1032,7 +1032,7 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data, | |||||||
|  |  | ||||||
|     q->avctx = avctx; |     q->avctx = avctx; | ||||||
|  |  | ||||||
|     if (buf_size < IMC_BLOCK_SIZE * avctx->channels) { |     if (buf_size < IMC_BLOCK_SIZE * avctx->ch_layout.nb_channels) { | ||||||
|         av_log(avctx, AV_LOG_ERROR, "frame too small!\n"); |         av_log(avctx, AV_LOG_ERROR, "frame too small!\n"); | ||||||
|         return AVERROR_INVALIDDATA; |         return AVERROR_INVALIDDATA; | ||||||
|     } |     } | ||||||
| @@ -1042,7 +1042,7 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data, | |||||||
|     if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) |     if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) | ||||||
|         return ret; |         return ret; | ||||||
|  |  | ||||||
|     for (i = 0; i < avctx->channels; i++) { |     for (i = 0; i < avctx->ch_layout.nb_channels; i++) { | ||||||
|         q->out_samples = (float *)frame->extended_data[i]; |         q->out_samples = (float *)frame->extended_data[i]; | ||||||
|  |  | ||||||
|         q->bdsp.bswap16_buf(buf16, (const uint16_t *) buf, IMC_BLOCK_SIZE / 2); |         q->bdsp.bswap16_buf(buf16, (const uint16_t *) buf, IMC_BLOCK_SIZE / 2); | ||||||
| @@ -1055,14 +1055,14 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data, | |||||||
|             return ret; |             return ret; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (avctx->channels == 2) { |     if (avctx->ch_layout.nb_channels == 2) { | ||||||
|         q->butterflies_float((float *)frame->extended_data[0], |         q->butterflies_float((float *)frame->extended_data[0], | ||||||
|                              (float *)frame->extended_data[1], COEFFS); |                              (float *)frame->extended_data[1], COEFFS); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     *got_frame_ptr = 1; |     *got_frame_ptr = 1; | ||||||
|  |  | ||||||
|     return IMC_BLOCK_SIZE * avctx->channels; |     return IMC_BLOCK_SIZE * avctx->ch_layout.nb_channels; | ||||||
| } | } | ||||||
|  |  | ||||||
| static av_cold int imc_decode_close(AVCodecContext * avctx) | static av_cold int imc_decode_close(AVCodecContext * avctx) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user