comparison mpegaudioenc.c @ 12034:f6ae68a7b1fd libavcodec

mpegaudioenc: Remove write-only variables from the context. Patch by Rafa¸«³l Carr¸«± (rafael <dot> carre <at> gmail).
author jai_menon
date Thu, 01 Jul 2010 05:17:02 +0000
parents fe105c6d28c7
children dde20597f15e
comparison
equal deleted inserted replaced
12033:5de2b84a1fc3 12034:f6ae68a7b1fd
38 #define SAMPLES_BUF_SIZE 4096 38 #define SAMPLES_BUF_SIZE 4096
39 39
40 typedef struct MpegAudioContext { 40 typedef struct MpegAudioContext {
41 PutBitContext pb; 41 PutBitContext pb;
42 int nb_channels; 42 int nb_channels;
43 int freq, bit_rate;
44 int lsf; /* 1 if mpeg2 low bitrate selected */ 43 int lsf; /* 1 if mpeg2 low bitrate selected */
45 int bitrate_index; /* bit rate */ 44 int bitrate_index; /* bit rate */
46 int freq_index; 45 int freq_index;
47 int frame_size; /* frame size, in bits, without padding */ 46 int frame_size; /* frame size, in bits, without padding */
48 int64_t nb_samples; /* total number of samples encoded */
49 /* padding computation */ 47 /* padding computation */
50 int frame_frac, frame_frac_incr, do_padding; 48 int frame_frac, frame_frac_incr, do_padding;
51 short samples_buf[MPA_MAX_CHANNELS][SAMPLES_BUF_SIZE]; /* buffer for filter */ 49 short samples_buf[MPA_MAX_CHANNELS][SAMPLES_BUF_SIZE]; /* buffer for filter */
52 int samples_offset[MPA_MAX_CHANNELS]; /* offset in samples_buf */ 50 int samples_offset[MPA_MAX_CHANNELS]; /* offset in samples_buf */
53 int sb_samples[MPA_MAX_CHANNELS][3][12][SBLIMIT]; 51 int sb_samples[MPA_MAX_CHANNELS][3][12][SBLIMIT];
77 av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed in mp2\n", channels); 75 av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed in mp2\n", channels);
78 return -1; 76 return -1;
79 } 77 }
80 bitrate = bitrate / 1000; 78 bitrate = bitrate / 1000;
81 s->nb_channels = channels; 79 s->nb_channels = channels;
82 s->freq = freq;
83 s->bit_rate = bitrate * 1000;
84 avctx->frame_size = MPA_FRAME_SIZE; 80 avctx->frame_size = MPA_FRAME_SIZE;
85 81
86 /* encoding freq */ 82 /* encoding freq */
87 s->lsf = 0; 83 s->lsf = 0;
88 for(i=0;i<3;i++) { 84 for(i=0;i<3;i++) {
776 772
777 init_put_bits(&s->pb, frame, MPA_MAX_CODED_FRAME_SIZE); 773 init_put_bits(&s->pb, frame, MPA_MAX_CODED_FRAME_SIZE);
778 774
779 encode_frame(s, bit_alloc, padding); 775 encode_frame(s, bit_alloc, padding);
780 776
781 s->nb_samples += MPA_FRAME_SIZE;
782 return put_bits_ptr(&s->pb) - s->pb.buf; 777 return put_bits_ptr(&s->pb) - s->pb.buf;
783 } 778 }
784 779
785 static av_cold int MPA_encode_close(AVCodecContext *avctx) 780 static av_cold int MPA_encode_close(AVCodecContext *avctx)
786 { 781 {