static AVCodec *AVCodecInitialize(enum AVCodecID codec_id)
{
AVCodec *res;
- av_register_all();
+
av_log_set_level(AV_LOG_PANIC);
res = avcodec_find_decoder(codec_id);
if (!res)
int *got_picture_ptr,
const AVPacket *avpkt) = NULL;
- if (!c)
+ if (!c) {
+#ifdef FFMPEG_DECODER
+#define DECODER_SYMBOL0(CODEC) ff_##CODEC##_decoder
+#define DECODER_SYMBOL(CODEC) DECODER_SYMBOL0(CODEC)
+ extern AVCodec DECODER_SYMBOL(FFMPEG_DECODER);
+ avcodec_register(&DECODER_SYMBOL(FFMPEG_DECODER));
+ int codec_id = DECODER_SYMBOL(FFMPEG_DECODER).id;
+
+ c = AVCodecInitialize(codec_id); // Done once.
+#else
+ avcodec_register_all();
c = AVCodecInitialize(FFMPEG_CODEC); // Done once.
+#endif
+ }
switch (c->type) {
case AVMEDIA_TYPE_AUDIO : decode_handler = avcodec_decode_audio4; break;
}
int res = avcodec_open2(ctx, c, NULL);
- if (res < 0)
+ if (res < 0) {
+ av_free(ctx);
return 0; // Failure of avcodec_open2() does not imply that a issue was found
+ }
FDBCreate(&buffer);
int got_frame;