~ubuntu-branches/ubuntu/edgy/gstreamer0.10-ffmpeg/edgy

« back to all changes in this revision

Viewing changes to gst-libs/ext/ffmpeg/libavcodec/resample.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-04-01 16:13:43 UTC
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20060401161343-n621cgjlujio0otg
Tags: upstream-0.10.1
Import upstream version 0.10.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 *
15
15
 * You should have received a copy of the GNU Lesser General Public
16
16
 * License along with this library; if not, write to the Free Software
17
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 */
19
19
 
20
20
/**
124
124
    }
125
125
}
126
126
 
127
 
ReSampleContext *audio_resample_init(int output_channels, int input_channels, 
 
127
ReSampleContext *audio_resample_init(int output_channels, int input_channels,
128
128
                                      int output_rate, int input_rate)
129
129
{
130
130
    ReSampleContext *s;
131
 
    
 
131
 
132
132
    if ( input_channels > 2)
133
133
      {
134
 
        av_log(NULL, AV_LOG_ERROR, "Resampling with input channels greater than 2 unsupported.");
135
 
        return NULL;
 
134
        av_log(NULL, AV_LOG_ERROR, "Resampling with input channels greater than 2 unsupported.");
 
135
        return NULL;
136
136
      }
137
137
 
138
138
    s = av_mallocz(sizeof(ReSampleContext));
139
139
    if (!s)
140
140
      {
141
 
        av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for resample context.");
142
 
        return NULL;
 
141
        av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for resample context.");
 
142
        return NULL;
143
143
      }
144
144
 
145
145
    s->ratio = (float)output_rate / (float)input_rate;
146
 
    
 
146
 
147
147
    s->input_channels = input_channels;
148
148
    s->output_channels = output_channels;
149
 
    
 
149
 
150
150
    s->filter_channels = s->input_channels;
151
151
    if (s->output_channels < s->filter_channels)
152
152
        s->filter_channels = s->output_channels;
160
160
      s->filter_channels = 2;
161
161
 
162
162
    s->resample_context= av_resample_init(output_rate, input_rate, 16, 10, 0, 1.0);
163
 
    
 
163
 
164
164
    return s;
165
165
}
166
166
 
186
186
        memcpy(bufin[i], s->temp[i], s->temp_len * sizeof(short));
187
187
        buftmp2[i] = bufin[i] + s->temp_len;
188
188
    }
189
 
    
 
189
 
190
190
    /* make some zoom to avoid round pb */
191
191
    lenout= (int)(nb_samples * s->ratio) + 16;
192
192
    bufout[0]= (short*) av_malloc( lenout * sizeof(short) );