aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/lib/acinerella/acinerella.c
diff options
context:
space:
mode:
Diffstat (limited to 'Game/Code/lib/acinerella/acinerella.c')
-rw-r--r--Game/Code/lib/acinerella/acinerella.c58
1 files changed, 35 insertions, 23 deletions
diff --git a/Game/Code/lib/acinerella/acinerella.c b/Game/Code/lib/acinerella/acinerella.c
index 05c52232..bae6b0e8 100644
--- a/Game/Code/lib/acinerella/acinerella.c
+++ b/Game/Code/lib/acinerella/acinerella.c
@@ -129,11 +129,7 @@ void init_info(lp_ac_file_info info)
info->bitrate = -1;
}
-lp_ac_instance CALL_CONVT ac_init(void) {
- //Initialize FFMpeg libraries
- avcodec_register_all();
- av_register_all();
-
+lp_ac_instance CALL_CONVT ac_init(void) {
//Allocate a new instance of the videoplayer data and return it
lp_ac_data ptmp;
ptmp = (lp_ac_data)mgr_malloc(sizeof(ac_data));
@@ -181,7 +177,7 @@ static int64_t io_seek(void *opaque, int64_t pos, int whence)
return -1;
}
-static AVInputFormat *av_probe_input_format2(AVProbeData *pd, int *score_max)
+static AVInputFormat *_av_probe_input_format2(AVProbeData *pd, int *score_max)
{
AVInputFormat *fmt1, *fmt;
int score;
@@ -227,7 +223,7 @@ void ac_release_buffer(struct AVCodecContext *c, AVFrame *pic){
avcodec_default_release_buffer(c, pic);
}
-AVInputFormat* ac_probe_input_buffer(
+lp_ac_proberesult CALL_CONVT ac_probe_input_buffer(
char* buf,
int bufsize,
char* filename,
@@ -235,6 +231,10 @@ AVInputFormat* ac_probe_input_buffer(
{
AVProbeData pd;
+ //Initialize FFMpeg libraries
+ avcodec_register_all();
+ av_register_all();
+
//Set the filename
pd.filename = "";
if (filename) {
@@ -246,7 +246,7 @@ AVInputFormat* ac_probe_input_buffer(
pd.buf_size = bufsize;
//Test it
- return av_probe_input_format2(&pd, score_max);
+ return (lp_ac_proberesult) _av_probe_input_format2(&pd, score_max);
}
#define PROBE_BUF_MIN 2048
@@ -291,7 +291,7 @@ AVInputFormat* ac_probe_input_stream(
}
//Probe it
- fmt = ac_probe_input_buffer(tmp_buf, probe_size, filename, &score);
+ fmt = (AVInputFormat*)ac_probe_input_buffer(tmp_buf, probe_size, filename, &score);
//Set the new buffer
*buf = tmp_buf;
@@ -308,7 +308,8 @@ int CALL_CONVT ac_open(
ac_openclose_callback open_proc,
ac_read_callback read_proc,
ac_seek_callback seek_proc,
- ac_openclose_callback close_proc)
+ ac_openclose_callback close_proc,
+ lp_ac_proberesult proberesult)
{
pacInstance->opened = 0;
@@ -327,13 +328,21 @@ int CALL_CONVT ac_open(
open_proc(sender);
}
- //Probe the input format
+ AVInputFormat* fmt = NULL;
int probe_size = 0;
- AVInputFormat* fmt = ac_probe_input_stream(sender, read_proc, "",
+
+ //Probe the input format, if no probe result is specified
+ if(proberesult == NULL)
+ {
+ fmt = ac_probe_input_stream(sender, read_proc, "",
(void*)&((lp_ac_data)pacInstance)->buffer, &probe_size);
-
- if (!fmt) return -1;
+ }
+ else
+ {
+ fmt = (AVInputFormat*)proberesult;
+ }
+ if (!fmt) return -1;
if (!seek_proc) {
init_put_byte(
@@ -428,16 +437,19 @@ void CALL_CONVT ac_get_stream_info(lp_ac_instance pacInstance, int nb, lp_ac_str
((lp_ac_data)pacInstance)->pFormatCtx->streams[nb]->codec->width;
info->additional_info.video_info.frame_height =
((lp_ac_data)pacInstance)->pFormatCtx->streams[nb]->codec->height;
- info->additional_info.video_info.pixel_aspect =
- av_q2d(((lp_ac_data)pacInstance)->pFormatCtx->streams[nb]->codec->sample_aspect_ratio);
- //Sometime "pixel aspect" may be zero. Correct this.
- if (info->additional_info.video_info.pixel_aspect == 0.0) {
+
+ double pixel_aspect_num = ((lp_ac_data)pacInstance)->pFormatCtx->streams[nb]->codec->sample_aspect_ratio.num;
+ double pixel_aspect_den = ((lp_ac_data)pacInstance)->pFormatCtx->streams[nb]->codec->sample_aspect_ratio.den;
+
+ //Sometime "pixel aspect" may be zero or have other invalid values. Correct this.
+ if (pixel_aspect_num <= 0.0 || pixel_aspect_den <= 0.0)
info->additional_info.video_info.pixel_aspect = 1.0;
- }
+ else
+ info->additional_info.video_info.pixel_aspect = pixel_aspect_num / pixel_aspect_den;
- info->additional_info.video_info.frames_per_second =
- (double)((lp_ac_data)pacInstance)->pFormatCtx->streams[nb]->r_frame_rate.num /
- (double)((lp_ac_data)pacInstance)->pFormatCtx->streams[nb]->r_frame_rate.den;
+ info->additional_info.video_info.frames_per_second =
+ (double)((lp_ac_data)pacInstance)->pFormatCtx->streams[nb]->r_frame_rate.num /
+ (double)((lp_ac_data)pacInstance)->pFormatCtx->streams[nb]->r_frame_rate.den;
break;
case CODEC_TYPE_AUDIO:
//Set stream type to "AUDIO"
@@ -689,7 +701,7 @@ int ac_decode_video_package(lp_ac_package pPackage, lp_ac_video_decoder pDecoder
sws_scale(
pDecoder->pSwsCtx,
- (uint8_t*)(pDecoder->pFrame->data),
+ (const uint8_t* const*)(pDecoder->pFrame->data),
pDecoder->pFrame->linesize,
0, //?
pDecoder->pCodecCtx->height,