1 /*
2 * Interface to libshine for mp3 encoding
3 * Copyright (c) 2012 Paul B Mahol
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <shine/layer3.h>
23
30
31 #define BUFFER_SIZE (4096 * 20)
32
40
42 {
44
48 }
49
50 shine_set_config_mpeg_defaults(&s->
config.mpeg);
55 s->
config.wave.channels = avctx->
channels == 2 ? PCM_STEREO : PCM_MONO;
56 if (shine_check_config(s->
config.wave.samplerate, s->
config.mpeg.bitr) < 0) {
59 }
65 return 0;
66 }
67
70 {
74 long written;
76
77 if (frame)
78 data = shine_encode_buffer(s->
shine, (int16_t **)frame->
data, &written);
79 else
80 data = shine_flush(s->
shine, &written);
81 if (written < 0)
82 return -1;
83 if (written > 0) {
87 }
90 }
91 if (frame) {
94 }
95
97 return 0;
100 return -1;
101 }
102
103 len = hdr.frame_size;
104 if (len <= s->buffer_index) {
110
113
115 *got_packet_ptr = 1;
116 }
117 return 0;
118 }
119
121 {
123
125 shine_close(s->
shine);
126 return 0;
127 }
128
130 44100, 48000, 32000, 0
131 };
132
148 0 },
149 };