Original Commit: r59 | ods15 | 2006-09-24 17:40:40 +0300 (Sun, 24 Sep 2006) | 2 lines
cosmetic, reorganize Originally committed as revision 6464 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
		
							parent
							
								
									8a202cb3a7
								
							
						
					
					
						commit
						6f17618af9
					
				| @ -598,75 +598,6 @@ static int put_main_header(venc_context_t * venc, uint8_t ** out) { | |||||||
|     return p - *out; |     return p - *out; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static int vorbis_encode_init(AVCodecContext * avccontext) |  | ||||||
| { |  | ||||||
|     venc_context_t * venc = avccontext->priv_data; |  | ||||||
| 
 |  | ||||||
|     create_vorbis_context(venc, avccontext); |  | ||||||
| 
 |  | ||||||
|     //if (avccontext->flags & CODEC_FLAG_QSCALE) avccontext->global_quality / (float)FF_QP2LAMBDA); else avccontext->bit_rate;
 |  | ||||||
|     //if(avccontext->cutoff > 0) cfreq = avccontext->cutoff / 1000.0;
 |  | ||||||
| 
 |  | ||||||
|     avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata); |  | ||||||
| 
 |  | ||||||
|     avccontext->frame_size = 1 << (venc->blocksize[0] - 1); |  | ||||||
| 
 |  | ||||||
|     avccontext->coded_frame = avcodec_alloc_frame(); |  | ||||||
|     avccontext->coded_frame->key_frame = 1; |  | ||||||
| 
 |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static int window(venc_context_t * venc, signed short * audio, int samples) { |  | ||||||
|     int i, j, channel; |  | ||||||
|     const float * win = venc->win[0]; |  | ||||||
|     int window_len = 1 << (venc->blocksize[0] - 1); |  | ||||||
|     float n = (float)(1 << venc->blocksize[0]) / 4.; |  | ||||||
|     // FIXME use dsp
 |  | ||||||
| 
 |  | ||||||
|     if (!venc->have_saved && !samples) return 0; |  | ||||||
| 
 |  | ||||||
|     if (venc->have_saved) { |  | ||||||
|         for (channel = 0; channel < venc->channels; channel++) { |  | ||||||
|             memcpy(venc->samples + channel*window_len*2, venc->saved + channel*window_len, sizeof(float)*window_len); |  | ||||||
|         } |  | ||||||
|     } else { |  | ||||||
|         for (channel = 0; channel < venc->channels; channel++) { |  | ||||||
|             memset(venc->samples + channel*window_len*2, 0, sizeof(float)*window_len); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     if (samples) { |  | ||||||
|         for (channel = 0; channel < venc->channels; channel++) { |  | ||||||
|             float * offset = venc->samples + channel*window_len*2 + window_len; |  | ||||||
|             j = channel; |  | ||||||
|             for (i = 0; i < samples; i++, j += venc->channels) |  | ||||||
|                 offset[i] = audio[j] / 32768. * win[window_len - i] / n; |  | ||||||
|         } |  | ||||||
|     } else { |  | ||||||
|         for (channel = 0; channel < venc->channels; channel++) { |  | ||||||
|             memset(venc->samples + channel*window_len*2 + window_len, 0, sizeof(float)*window_len); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     for (channel = 0; channel < venc->channels; channel++) { |  | ||||||
|         ff_mdct_calc(&venc->mdct[0], venc->coeffs + channel*window_len, venc->samples + channel*window_len*2, venc->floor/*tmp*/); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     if (samples) { |  | ||||||
|         for (channel = 0; channel < venc->channels; channel++) { |  | ||||||
|             float * offset = venc->saved + channel*window_len; |  | ||||||
|             j = channel; |  | ||||||
|             for (i = 0; i < samples; i++, j += venc->channels) |  | ||||||
|                 offset[i] = audio[j] / 32768. * win[i] / n; |  | ||||||
|         } |  | ||||||
|         venc->have_saved = 1; |  | ||||||
|     } else { |  | ||||||
|         venc->have_saved = 0; |  | ||||||
|     } |  | ||||||
|     return 1; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static float * put_vector(codebook_t * book, PutBitContext * pb, float * num) { | static float * put_vector(codebook_t * book, PutBitContext * pb, float * num) { | ||||||
|     int i; |     int i; | ||||||
|     int entry = -1; |     int entry = -1; | ||||||
| @ -728,6 +659,75 @@ static void residue_encode(venc_context_t * venc, residue_t * rc, PutBitContext | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static int window(venc_context_t * venc, signed short * audio, int samples) { | ||||||
|  |     int i, j, channel; | ||||||
|  |     const float * win = venc->win[0]; | ||||||
|  |     int window_len = 1 << (venc->blocksize[0] - 1); | ||||||
|  |     float n = (float)(1 << venc->blocksize[0]) / 4.; | ||||||
|  |     // FIXME use dsp
 | ||||||
|  | 
 | ||||||
|  |     if (!venc->have_saved && !samples) return 0; | ||||||
|  | 
 | ||||||
|  |     if (venc->have_saved) { | ||||||
|  |         for (channel = 0; channel < venc->channels; channel++) { | ||||||
|  |             memcpy(venc->samples + channel*window_len*2, venc->saved + channel*window_len, sizeof(float)*window_len); | ||||||
|  |         } | ||||||
|  |     } else { | ||||||
|  |         for (channel = 0; channel < venc->channels; channel++) { | ||||||
|  |             memset(venc->samples + channel*window_len*2, 0, sizeof(float)*window_len); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (samples) { | ||||||
|  |         for (channel = 0; channel < venc->channels; channel++) { | ||||||
|  |             float * offset = venc->samples + channel*window_len*2 + window_len; | ||||||
|  |             j = channel; | ||||||
|  |             for (i = 0; i < samples; i++, j += venc->channels) | ||||||
|  |                 offset[i] = audio[j] / 32768. * win[window_len - i] / n; | ||||||
|  |         } | ||||||
|  |     } else { | ||||||
|  |         for (channel = 0; channel < venc->channels; channel++) { | ||||||
|  |             memset(venc->samples + channel*window_len*2 + window_len, 0, sizeof(float)*window_len); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     for (channel = 0; channel < venc->channels; channel++) { | ||||||
|  |         ff_mdct_calc(&venc->mdct[0], venc->coeffs + channel*window_len, venc->samples + channel*window_len*2, venc->floor/*tmp*/); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     if (samples) { | ||||||
|  |         for (channel = 0; channel < venc->channels; channel++) { | ||||||
|  |             float * offset = venc->saved + channel*window_len; | ||||||
|  |             j = channel; | ||||||
|  |             for (i = 0; i < samples; i++, j += venc->channels) | ||||||
|  |                 offset[i] = audio[j] / 32768. * win[i] / n; | ||||||
|  |         } | ||||||
|  |         venc->have_saved = 1; | ||||||
|  |     } else { | ||||||
|  |         venc->have_saved = 0; | ||||||
|  |     } | ||||||
|  |     return 1; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static int vorbis_encode_init(AVCodecContext * avccontext) | ||||||
|  | { | ||||||
|  |     venc_context_t * venc = avccontext->priv_data; | ||||||
|  | 
 | ||||||
|  |     create_vorbis_context(venc, avccontext); | ||||||
|  | 
 | ||||||
|  |     //if (avccontext->flags & CODEC_FLAG_QSCALE) avccontext->global_quality / (float)FF_QP2LAMBDA); else avccontext->bit_rate;
 | ||||||
|  |     //if(avccontext->cutoff > 0) cfreq = avccontext->cutoff / 1000.0;
 | ||||||
|  | 
 | ||||||
|  |     avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata); | ||||||
|  | 
 | ||||||
|  |     avccontext->frame_size = 1 << (venc->blocksize[0] - 1); | ||||||
|  | 
 | ||||||
|  |     avccontext->coded_frame = avcodec_alloc_frame(); | ||||||
|  |     avccontext->coded_frame->key_frame = 1; | ||||||
|  | 
 | ||||||
|  |     return 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| static int vorbis_encode_frame(AVCodecContext * avccontext, unsigned char * packets, int buf_size, void *data) | static int vorbis_encode_frame(AVCodecContext * avccontext, unsigned char * packets, int buf_size, void *data) | ||||||
| { | { | ||||||
|     venc_context_t * venc = avccontext->priv_data; |     venc_context_t * venc = avccontext->priv_data; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user