]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/wmaenc.c
Add support for Acelp.net fourcc and codecid, remuxing wav to avi should work
[ffmpeg] / libavcodec / wmaenc.c
index f1b5529d2f5212ec2f4a482890b84e3e5908b6e5..4558947cb3522f05a3610c7f3fec3c5390d16d0e 100644 (file)
@@ -36,25 +36,22 @@ static int encode_init(AVCodecContext * avctx){
     if(avctx->channels > MAX_CHANNELS)
         return -1;
 
+    if(avctx->bit_rate < 24*1000)
+        return -1;
+
     /* extract flag infos */
     flags1 = 0;
     flags2 = 1;
     if (avctx->codec->id == CODEC_ID_WMAV1) {
         extradata= av_malloc(4);
         avctx->extradata_size= 4;
-        extradata[0] = flags1;
-        extradata[1] = flags1>>8;
-        extradata[2] = flags2;
-        extradata[3] = flags2>>8;
+        AV_WL16(extradata, flags1);
+        AV_WL16(extradata+2, flags2);
     } else if (avctx->codec->id == CODEC_ID_WMAV2) {
         extradata= av_mallocz(10);
         avctx->extradata_size= 10;
-        extradata[0] = flags1;
-        extradata[1] = flags1>>8;
-        extradata[2] = flags1>>16;
-        extradata[3] = flags1>>24;
-        extradata[4] = flags2;
-        extradata[5] = flags2>>8;
+        AV_WL32(extradata, flags1);
+        AV_WL16(extradata+4, flags2);
     }else
         assert(0);
     avctx->extradata= extradata;
@@ -89,15 +86,15 @@ static void apply_window_and_mdct(AVCodecContext * avctx, signed short * audio,
         memcpy(s->output, s->frame_out[channel], sizeof(float)*window_len);
         j = channel;
         for (i = 0; i < len; i++, j += avctx->channels){
-            s->output[i+window_len]  = audio[j] / n * win[i];
-            s->frame_out[channel][i] = audio[j] / n * win[window_len - i - 1];
+            s->output[i+window_len]  = audio[j] / n * win[window_len - i - 1];
+            s->frame_out[channel][i] = audio[j] / n * win[i];
         }
-        ff_mdct_calc(&s->mdct_ctx[window_index], s->coefs[channel], s->output, s->mdct_tmp);
+        ff_mdct_calc(&s->mdct_ctx[window_index], s->coefs[channel], s->output);
     }
 }
 
 //FIXME use for decoding too
-static void init_exp(WMACodecContext *s, int ch, int *exp_param){
+static void init_exp(WMACodecContext *s, int ch, const int *exp_param){
     int n;
     const uint16_t *ptr;
     float v, *q, max_scale, *q_end;
@@ -181,7 +178,7 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
     }
 
     for(ch = 0; ch < s->nb_channels; ch++) {
-        if (s->channel_coded[ch]= 1) { //FIXME
+        if ((s->channel_coded[ch]= 1)) { //FIXME only set channel_coded when needed, instead of always
             init_exp(s, ch, fixed_exp);
         }
     }
@@ -327,7 +324,7 @@ static int encode_superframe(AVCodecContext *avctx,
                             unsigned char *buf, int buf_size, void *data){
     WMACodecContext *s = avctx->priv_data;
     short *samples = data;
-    int i, total_gain, best;
+    int i, total_gain;
 
     s->block_len_bits= s->frame_len_bits; //required by non variable block len
     s->block_len = 1 << s->block_len_bits;
@@ -390,6 +387,8 @@ AVCodec wmav1_encoder =
     encode_init,
     encode_superframe,
     ff_wma_end,
+    .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+    .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"),
 };
 
 AVCodec wmav2_encoder =
@@ -401,4 +400,6 @@ AVCodec wmav2_encoder =
     encode_init,
     encode_superframe,
     ff_wma_end,
+    .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
+    .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"),
 };