annotate libmpcodecs/ae.c @ 20725:873f7484ccdd

Initial (partially, about 40%) translation. Patch from Andrew Savchenko birkoph at list ru with small fixes. Translated sections: menc-feat-dvd-mpeg4 Sections to translate: menc-feat-telecine menc-feat-enc-libavcodec menc-feat-xvid menc-feat-x264 menc-feat-video-for-windows menc-feat-vcd-dvd
author voroshil
date Tue, 07 Nov 2006 12:31:37 +0000
parents d9474f04cce5
children ca9da45d13e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
1 #include <stdio.h>
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
2 #include <string.h>
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
3 #include <stdlib.h>
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
4 #include <inttypes.h>
15238
2cc48c37a7eb FreeBSD fix
nexus
parents: 15234
diff changeset
5 #include <unistd.h>
15240
6d6792c02b6f macosx compilation fix
nicodvb
parents: 15238
diff changeset
6 #include <sys/types.h>
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
7 #include <math.h>
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
8 #include "aviheader.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
9 #include "ms_hdr.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
10 #include "muxer.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
11 #include "ae.h"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16616
diff changeset
12 #include "config.h"
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
13
16616
d9b74d27974d forgotten include; patch by Jan Knutar (jknutar ad nic puntum fi)
nicodvb
parents: 15359
diff changeset
14 #include "ae_pcm.h"
d9b74d27974d forgotten include; patch by Jan Knutar (jknutar ad nic puntum fi)
nicodvb
parents: 15359
diff changeset
15
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
16 #ifdef HAVE_TOOLAME
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
17 #include "ae_toolame.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
18 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
19
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
20 #ifdef HAVE_MP3LAME
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
21 #include "ae_lame.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
22 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
23
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
24 #ifdef USE_LIBAVCODEC
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
25 #include "ae_lavc.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
26 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
27
15259
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
28 #ifdef HAVE_FAAC
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
29 #include "ae_faac.h"
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
30 #endif
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
31
15359
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
32 #ifdef HAVE_TWOLAME
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
33 #include "ae_twolame.h"
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
34 #endif
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
35
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
36 audio_encoder_t *new_audio_encoder(muxer_stream_t *stream, audio_encoding_params_t *params)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
37 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
38 int ris;
15242
f27a3f8d3241 gcc 2.95 compilation fix
reimar
parents: 15240
diff changeset
39 audio_encoder_t *encoder;
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
40 if(! params)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
41 return NULL;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
42
15242
f27a3f8d3241 gcc 2.95 compilation fix
reimar
parents: 15240
diff changeset
43 encoder = (audio_encoder_t *) calloc(1, sizeof(audio_encoder_t));
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
44 memcpy(&encoder->params, params, sizeof(audio_encoding_params_t));
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
45 encoder->stream = stream;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
46
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
47 switch(stream->codec)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
48 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
49 case ACODEC_PCM:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
50 ris = mpae_init_pcm(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
51 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
52 #ifdef HAVE_TOOLAME
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
53 case ACODEC_TOOLAME:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
54 ris = mpae_init_toolame(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
55 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
56 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
57 #ifdef USE_LIBAVCODEC
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
58 case ACODEC_LAVC:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
59 ris = mpae_init_lavc(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
60 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
61 #endif
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
62 #ifdef HAVE_MP3LAME
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
63 case ACODEC_VBRMP3:
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
64 ris = mpae_init_lame(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
65 break;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
66 #endif
15259
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
67 #ifdef HAVE_FAAC
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
68 case ACODEC_FAAC:
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
69 ris = mpae_init_faac(encoder);
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
70 break;
854990f357ee added faac audio encoder
nicodvb
parents: 15242
diff changeset
71 #endif
15359
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
72 #ifdef HAVE_TWOLAME
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
73 case ACODEC_TWOLAME:
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
74 ris = mpae_init_twolame(encoder);
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
75 break;
af245d15f502 added twolame mp2 audio encoder
nicodvb
parents: 15259
diff changeset
76 #endif
17781
d9474f04cce5 add default case to encoder switch-case (maybe an error message would be good as well).
reimar
parents: 17122
diff changeset
77 default:
d9474f04cce5 add default case to encoder switch-case (maybe an error message would be good as well).
reimar
parents: 17122
diff changeset
78 ris = 0;
d9474f04cce5 add default case to encoder switch-case (maybe an error message would be good as well).
reimar
parents: 17122
diff changeset
79 break;
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
80 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
81
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
82 if(! ris)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
83 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
84 free(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
85 return NULL;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
86 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
87 encoder->bind(encoder, stream);
17122
c23ca41ad996 more warning fixes
ods15
parents: 17012
diff changeset
88 encoder->decode_buffer = malloc(encoder->decode_buffer_size);
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
89 if(! encoder->decode_buffer)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
90 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
91 free(encoder);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
92 return NULL;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
93 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
94
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
95 encoder->codec = stream->codec;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
96 return encoder;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
97 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
98
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
99