mirror of
				https://github.com/nyanmisaka/ffmpeg-rockchip.git
				synced 2025-10-31 20:42:49 +08:00 
			
		
		
		
	vorbis: convert to new channel layout API
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
						
							eb81c946c1
						
					
				
				
					commit
					457e88fcaf
				
			| @@ -1077,12 +1077,14 @@ static av_cold int vorbis_decode_init(AVCodecContext *avctx) | |||||||
|         return ret; |         return ret; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (vc->audio_channels > 8) |     av_channel_layout_uninit(&avctx->ch_layout); | ||||||
|         avctx->channel_layout = 0; |     if (vc->audio_channels > 8) { | ||||||
|     else |         avctx->ch_layout.order       = AV_CHANNEL_ORDER_UNSPEC; | ||||||
|         avctx->channel_layout = ff_vorbis_channel_layouts[vc->audio_channels - 1]; |         avctx->ch_layout.nb_channels = vc->audio_channels; | ||||||
|  |     } else { | ||||||
|  |         av_channel_layout_copy(&avctx->ch_layout, &ff_vorbis_ch_layouts[vc->audio_channels - 1]); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     avctx->channels    = vc->audio_channels; |  | ||||||
|     avctx->sample_rate = vc->audio_samplerate; |     avctx->sample_rate = vc->audio_samplerate; | ||||||
|  |  | ||||||
|     return 0; |     return 0; | ||||||
| @@ -1788,12 +1790,14 @@ static int vorbis_decode_frame(AVCodecContext *avctx, void *data, | |||||||
|             return ret; |             return ret; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (vc->audio_channels > 8) |         av_channel_layout_uninit(&avctx->ch_layout); | ||||||
|             avctx->channel_layout = 0; |         if (vc->audio_channels > 8) { | ||||||
|         else |             avctx->ch_layout.order       = AV_CHANNEL_ORDER_UNSPEC; | ||||||
|             avctx->channel_layout = ff_vorbis_channel_layouts[vc->audio_channels - 1]; |             avctx->ch_layout.nb_channels = vc->audio_channels; | ||||||
|  |         } else { | ||||||
|  |             av_channel_layout_copy(&avctx->ch_layout, &ff_vorbis_ch_layouts[vc->audio_channels - 1]); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         avctx->channels    = vc->audio_channels; |  | ||||||
|         avctx->sample_rate = vc->audio_samplerate; |         avctx->sample_rate = vc->audio_samplerate; | ||||||
|         return buf_size; |         return buf_size; | ||||||
|     } |     } | ||||||
| @@ -1892,7 +1896,10 @@ const AVCodec ff_vorbis_decoder = { | |||||||
|     .flush           = vorbis_decode_flush, |     .flush           = vorbis_decode_flush, | ||||||
|     .capabilities    = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, |     .capabilities    = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, | ||||||
|     .caps_internal   = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, |     .caps_internal   = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, | ||||||
|  | #if FF_API_OLD_CHANNEL_LAYOUT | ||||||
|     .channel_layouts = ff_vorbis_channel_layouts, |     .channel_layouts = ff_vorbis_channel_layouts, | ||||||
|  | #endif | ||||||
|  |     .ch_layouts      = ff_vorbis_ch_layouts, | ||||||
|     .sample_fmts     = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, |     .sample_fmts     = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, | ||||||
|                                                        AV_SAMPLE_FMT_NONE }, |                                                        AV_SAMPLE_FMT_NONE }, | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -276,7 +276,7 @@ static int create_vorbis_context(vorbis_enc_context *venc, | |||||||
|     const uint8_t *clens, *quant; |     const uint8_t *clens, *quant; | ||||||
|     int i, book, ret; |     int i, book, ret; | ||||||
|  |  | ||||||
|     venc->channels    = avctx->channels; |     venc->channels    = avctx->ch_layout.nb_channels; | ||||||
|     venc->sample_rate = avctx->sample_rate; |     venc->sample_rate = avctx->sample_rate; | ||||||
|     venc->log2_blocksize[0] = venc->log2_blocksize[1] = 11; |     venc->log2_blocksize[0] = venc->log2_blocksize[1] = 11; | ||||||
|  |  | ||||||
| @@ -1038,7 +1038,8 @@ static AVFrame *spawn_empty_frame(AVCodecContext *avctx, int channels) | |||||||
|  |  | ||||||
|     f->format = avctx->sample_fmt; |     f->format = avctx->sample_fmt; | ||||||
|     f->nb_samples = avctx->frame_size; |     f->nb_samples = avctx->frame_size; | ||||||
|     f->channel_layout = avctx->channel_layout; |     f->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC; | ||||||
|  |     f->ch_layout.nb_channels = channels; | ||||||
|  |  | ||||||
|     if (av_frame_get_buffer(f, 4)) { |     if (av_frame_get_buffer(f, 4)) { | ||||||
|         av_frame_free(&f); |         av_frame_free(&f); | ||||||
| @@ -1267,7 +1268,7 @@ static av_cold int vorbis_encode_init(AVCodecContext *avctx) | |||||||
|     vorbis_enc_context *venc = avctx->priv_data; |     vorbis_enc_context *venc = avctx->priv_data; | ||||||
|     int ret; |     int ret; | ||||||
|  |  | ||||||
|     if (avctx->channels != 2) { |     if (avctx->ch_layout.nb_channels != 2) { | ||||||
|         av_log(avctx, AV_LOG_ERROR, "Current FFmpeg Vorbis encoder only supports 2 channels.\n"); |         av_log(avctx, AV_LOG_ERROR, "Current FFmpeg Vorbis encoder only supports 2 channels.\n"); | ||||||
|         return -1; |         return -1; | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user