Originally Posted by
laserlight
It sounds like you merely did not define, or incorrectly defined, the function in the source file.
This is my exact function header on my .h file:
Code:
static void video_decode(const char *outfile, const char *infile);
and on my .c file:
Code:
static void video_decode(const char *outfile, const char *infile){
AVCodec *codec;
AVCodecContext *c = NULL;
int movieframe, got_picture, len;
FILE *f;
AVFrame *picture;
uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE];
char buf[1024];
AVPacket avpkt;
av_init_packet(&avpkt);
memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
printf("Decoding in progress\n");
codec = avcodec_find_decoder(CODEC_ID_H263);
if(!codec){
fprintf(stderr, "codec not found\n");
exit(1);
}
c = avcodec_alloc_context();
picture = avcodec_alloc_frame();
if(codec->capabilities & CODEC_CAP_TRUNCATED){
c->flags|= CODEC_FLAG_TRUNCATED;
}
if(avcodec_open(c,codec) < 0){
fprintf(stderr, "could not open codec\n");
exit(1);
}
f = fopen(infile, "rb");
if(!f){
fprintf(stderr, "infile not found\n");
exit(1);
}
movieframe = 0;
for(;;){
avpkt.size = fread(inbuf, 1, INBUF_SIZE, f);
if(avpkt.size == 0)
break;
avpkt.data = inbuf;
while(avpkt.size > 0){
len = avcodec_decode_video2(c, picture, &got_picture, &avpkt);
if(len < 0){
fprintf(stderr, "Error decoding frame\n");
exit(1);
}
if(got_picture){
printf("saving frame %3d\n", movieframe);
fflush(stdout);
#ifdef WIN32
sprintf_s(buf, sizeof(buf), outfile, movieframe);
#else
snprintf(buf, sizeof(buf), outfilename, frame);
#endif
pgm_save(picture->data[0], picture->linesize[0], c->width, c->height, buf);
movieframe++;
}
avpkt.size -= len;
avpkt.data += len;
}
}
avpkt.data = NULL;
avpkt.size = 0;
len = avcodec_decode_video2(c, picture, &got_picture, &avpkt);
if(got_picture){
printf("saving last frame\n");
fflush(stdout);
#ifdef WIN32
sprintf_s(buf, sizeof(buf), outfile, movieframe);
#else
snprintf(buf, sizeof(buf), outfile, movieframe);
#endif
pgm_save(picture->data[0], picture->linesize[0], c->width, c->height, buf);
movieframe++;
}
fclose(f);
avcodec_close(c);
av_free(c);
av_free(picture);
printf("\n");
}
verbatim as they are... What can be wrong?