mirror of
				https://github.com/nyanmisaka/ffmpeg-rockchip.git
				synced 2025-10-31 12:36:41 +08:00 
			
		
		
		
	oma: 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:
		 Vittorio Giovara
					Vittorio Giovara
				
			
				
					committed by
					
						 James Almer
						James Almer
					
				
			
			
				
	
			
			
			 James Almer
						James Almer
					
				
			
						parent
						
							5b51e6771c
						
					
				
				
					commit
					68559225a2
				
			| @@ -23,6 +23,8 @@ | |||||||
|  |  | ||||||
| #include <stdint.h> | #include <stdint.h> | ||||||
|  |  | ||||||
|  | #include "libavutil/channel_layout.h" | ||||||
|  |  | ||||||
| #include "internal.h" | #include "internal.h" | ||||||
|  |  | ||||||
| #define EA3_HEADER_SIZE 96 | #define EA3_HEADER_SIZE 96 | ||||||
|   | |||||||
| @@ -60,19 +60,16 @@ static const uint64_t leaf_table[] = { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| /** map ATRAC-X channel id to internal channel layout */ | /** map ATRAC-X channel id to internal channel layout */ | ||||||
| static const uint64_t oma_chid_to_native_layout[7] = { | static const AVChannelLayout  oma_chid_to_native_layout[7] = { | ||||||
|     AV_CH_LAYOUT_MONO, |     AV_CHANNEL_LAYOUT_MONO, | ||||||
|     AV_CH_LAYOUT_STEREO, |     AV_CHANNEL_LAYOUT_STEREO, | ||||||
|     AV_CH_LAYOUT_SURROUND, |     AV_CHANNEL_LAYOUT_SURROUND, | ||||||
|     AV_CH_LAYOUT_4POINT0, |     AV_CHANNEL_LAYOUT_4POINT0, | ||||||
|     AV_CH_LAYOUT_5POINT1_BACK, |     AV_CHANNEL_LAYOUT_5POINT1_BACK, | ||||||
|     AV_CH_LAYOUT_6POINT1_BACK, |     AV_CHANNEL_LAYOUT_6POINT1_BACK, | ||||||
|     AV_CH_LAYOUT_7POINT1 |     AV_CHANNEL_LAYOUT_7POINT1 | ||||||
| }; | }; | ||||||
|  |  | ||||||
| /** map ATRAC-X channel id to total number of channels */ |  | ||||||
| static const int oma_chid_to_num_channels[7] = { 1, 2, 3, 4, 6, 7, 8 }; |  | ||||||
|  |  | ||||||
| typedef struct OMAContext { | typedef struct OMAContext { | ||||||
|     uint64_t content_start; |     uint64_t content_start; | ||||||
|     int encrypted; |     int encrypted; | ||||||
| @@ -474,8 +471,7 @@ static int oma_read_header(AVFormatContext *s) | |||||||
|         /* get stereo coding mode, 1 for joint-stereo */ |         /* get stereo coding mode, 1 for joint-stereo */ | ||||||
|         jsflag = (codec_params >> 17) & 1; |         jsflag = (codec_params >> 17) & 1; | ||||||
|  |  | ||||||
|         st->codecpar->channels    = 2; |         st->codecpar->ch_layout   = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; | ||||||
|         st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO; |  | ||||||
|         st->codecpar->sample_rate = samplerate; |         st->codecpar->sample_rate = samplerate; | ||||||
|         st->codecpar->bit_rate    = st->codecpar->sample_rate * framesize / (1024 / 8); |         st->codecpar->bit_rate    = st->codecpar->sample_rate * framesize / (1024 / 8); | ||||||
|  |  | ||||||
| @@ -501,8 +497,8 @@ static int oma_read_header(AVFormatContext *s) | |||||||
|                    "Invalid ATRAC-X channel id: %"PRIu32"\n", channel_id); |                    "Invalid ATRAC-X channel id: %"PRIu32"\n", channel_id); | ||||||
|             return AVERROR_INVALIDDATA; |             return AVERROR_INVALIDDATA; | ||||||
|         } |         } | ||||||
|         st->codecpar->channel_layout = oma_chid_to_native_layout[channel_id - 1]; |         av_channel_layout_copy(&st->codecpar->ch_layout, | ||||||
|         st->codecpar->channels       = oma_chid_to_num_channels[channel_id - 1]; |                                &oma_chid_to_native_layout[channel_id - 1]); | ||||||
|         framesize = ((codec_params & 0x3FF) * 8) + 8; |         framesize = ((codec_params & 0x3FF) * 8) + 8; | ||||||
|         samplerate = ff_oma_srate_tab[(codec_params >> 13) & 7] * 100; |         samplerate = ff_oma_srate_tab[(codec_params >> 13) & 7] * 100; | ||||||
|         if (!samplerate) { |         if (!samplerate) { | ||||||
| @@ -519,8 +515,7 @@ static int oma_read_header(AVFormatContext *s) | |||||||
|         break; |         break; | ||||||
|     case OMA_CODECID_LPCM: |     case OMA_CODECID_LPCM: | ||||||
|         /* PCM 44.1 kHz 16 bit stereo big-endian */ |         /* PCM 44.1 kHz 16 bit stereo big-endian */ | ||||||
|         st->codecpar->channels = 2; |         st->codecpar->ch_layout   = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; | ||||||
|         st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO; |  | ||||||
|         st->codecpar->sample_rate = 44100; |         st->codecpar->sample_rate = 44100; | ||||||
|         framesize = 1024; |         framesize = 1024; | ||||||
|         /* bit rate = sample rate x PCM block align (= 4) x 8 */ |         /* bit rate = sample rate x PCM block align (= 4) x 8 */ | ||||||
| @@ -530,16 +525,14 @@ static int oma_read_header(AVFormatContext *s) | |||||||
|         avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); |         avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); | ||||||
|         break; |         break; | ||||||
|     case OMA_CODECID_ATRAC3AL: |     case OMA_CODECID_ATRAC3AL: | ||||||
|         st->codecpar->channels    = 2; |         st->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; | ||||||
|         st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO; |  | ||||||
|         st->codecpar->sample_rate = 44100; |         st->codecpar->sample_rate = 44100; | ||||||
|         avpriv_set_pts_info(st, 64, 1, 44100); |         avpriv_set_pts_info(st, 64, 1, 44100); | ||||||
|         oc->read_packet = aal_read_packet; |         oc->read_packet = aal_read_packet; | ||||||
|         framesize = 4096; |         framesize = 4096; | ||||||
|         break; |         break; | ||||||
|     case OMA_CODECID_ATRAC3PAL: |     case OMA_CODECID_ATRAC3PAL: | ||||||
|         st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO; |         st->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; | ||||||
|         st->codecpar->channels       = 2; |  | ||||||
|         st->codecpar->sample_rate = 44100; |         st->codecpar->sample_rate = 44100; | ||||||
|         avpriv_set_pts_info(st, 64, 1, 44100); |         avpriv_set_pts_info(st, 64, 1, 44100); | ||||||
|         oc->read_packet = aal_read_packet; |         oc->read_packet = aal_read_packet; | ||||||
|   | |||||||
| @@ -58,7 +58,7 @@ static av_cold int oma_write_header(AVFormatContext *s) | |||||||
|  |  | ||||||
|     switch (par->codec_tag) { |     switch (par->codec_tag) { | ||||||
|     case OMA_CODECID_ATRAC3: |     case OMA_CODECID_ATRAC3: | ||||||
|         if (par->channels != 2) { |         if (par->ch_layout.nb_channels != 2) { | ||||||
|             av_log(s, AV_LOG_ERROR, "ATRAC3 in OMA is only supported with 2 channels\n"); |             av_log(s, AV_LOG_ERROR, "ATRAC3 in OMA is only supported with 2 channels\n"); | ||||||
|             return AVERROR(EINVAL); |             return AVERROR(EINVAL); | ||||||
|         } |         } | ||||||
| @@ -78,7 +78,7 @@ static av_cold int oma_write_header(AVFormatContext *s) | |||||||
|     case OMA_CODECID_ATRAC3P: |     case OMA_CODECID_ATRAC3P: | ||||||
|         avio_wb32(s->pb, (OMA_CODECID_ATRAC3P << 24) | |         avio_wb32(s->pb, (OMA_CODECID_ATRAC3P << 24) | | ||||||
|                          (srate_index << 13) | |                          (srate_index << 13) | | ||||||
|                          (par->channels << 10) | |                          (par->ch_layout.nb_channels << 10) | | ||||||
|                          (par->block_align/8 - 1)); |                          (par->block_align/8 - 1)); | ||||||
|         break; |         break; | ||||||
|     default: |     default: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user