[Ffmpeg-devel] error in avcodec_open with WMAv2

Osama Khan oskhan
Tue Jul 12 15:34:02 CEST 2005


I am encountering an error while trying to use the WMA v2 decoder. The
problem errors when i try to call avcodec_open(). Here is the piece of
code im trying to run.


#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

//#ifndef UINT8
//#define UINT8 uint8_t
#include "/home/okhan/ffmpeg/libavcodec/avcodec.h"

#define INBUF_SIZE 4096

int main(int argc, char **argv)

    AVCodec *codec;
    AVCodecContext *c= NULL;

    /* must be called before using avcodec lib */

    /* register all the codecs (you can also register only the codec
       you wish to have smaller code */

    printf("%d\n", avcodec_build());

    printf("Audio decoding\n");

    codec = avcodec_find_decoder(CODEC_ID_WMAV2);
    if (!codec) {
        fprintf(stderr, "codec not found\n");

    c= avcodec_alloc_context();

    printf("about to open codec\n");
    /* open it */
    if (avcodec_open(c, codec) < 0) {
        fprintf(stderr, "could not open codec\n");

    printf("opened codec\n");
    return 0;


I tried running it through the debugger and here is the output:


okhan at cable:~$ g++ example2.cpp -lavcodec
-L/home/okhan/ffmpeg/libavcodec -lavformat
-L/home/okhan/ffmpeg/libavformat -g
okhan at cable:~$ gdb a.out
GNU gdb 6.3-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-linux"...Using host libthread_db
library "/lib/tls/libthread_db.so.1".

(gdb) run
Starting program: /home/okhan/a.out
Audio decoding
about to open codec

Program received signal SIGFPE, Arithmetic exception.
0xb7ea8862 in wma_decode_init (avctx=0x19000) at wmadec.c:391
391                             pos = ((block_len * 2 * a)  + (b <<
1)) / (4 * b);
Current language:  auto; currently c
(gdb) quit


Hope thats all that is required to solve this problem. 

Awaiting replies.


More information about the ffmpeg-devel mailing list