mirror of
https://github.com/zoriya/Kyoo.Transcoder.git
synced 2025-12-06 06:26:11 +00:00
Fixing an invalid read & font detection
This commit is contained in:
@@ -13,4 +13,4 @@ int open_input_context(AVFormatContext **inputContext, const char *path);
|
||||
AVStream *copy_stream_to_output(AVFormatContext *out_ctx, AVStream *in_stream);
|
||||
int open_output_file_for_write(AVFormatContext *out_ctx, const char *out_path, AVDictionary **options);
|
||||
void process_packet(AVPacket *pkt, AVStream *in_stream, AVStream *out_stream);
|
||||
type type_fromffmpeg(int type);
|
||||
type type_fromffmpeg(AVStream *stream);
|
||||
@@ -62,9 +62,9 @@ void process_packet(AVPacket *pkt, AVStream *in_stream, AVStream *out_stream)
|
||||
pkt->pos = -1;
|
||||
}
|
||||
|
||||
type type_fromffmpeg(int type)
|
||||
type type_fromffmpeg(AVStream *stream)
|
||||
{
|
||||
switch (type)
|
||||
switch (stream->codecpar->codec_type)
|
||||
{
|
||||
case AVMEDIA_TYPE_VIDEO:
|
||||
return video;
|
||||
@@ -73,7 +73,9 @@ type type_fromffmpeg(int type)
|
||||
case AVMEDIA_TYPE_SUBTITLE:
|
||||
return subtitle;
|
||||
case AVMEDIA_TYPE_ATTACHMENT:
|
||||
return font;
|
||||
if (!strcmp(avcodec_get_name(stream->codecpar->codec_id), "ttf"))
|
||||
return font;
|
||||
return none;
|
||||
default:
|
||||
return none;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ stream *extract_infos(const char *path, const char *out_path, unsigned *stream_c
|
||||
if (output_list && streams) {
|
||||
for (unsigned i = 0; i < *stream_count; i++) {
|
||||
AVStream *stream = ctx->streams[i];
|
||||
type stream_type = type_fromffmpeg(stream->codecpar->codec_type);
|
||||
type stream_type = type_fromffmpeg(stream);
|
||||
|
||||
if (stream_type != none) {
|
||||
*track_count += 1;
|
||||
|
||||
@@ -80,7 +80,7 @@ void extract_font(stream *font, const char *out_path, AVStream *stream)
|
||||
if (!filename)
|
||||
return;
|
||||
free(font->path);
|
||||
font->path = malloc((strlen(out_path) + 7 + strlen(filename->value)) * sizeof(char));
|
||||
font->path = malloc((strlen(out_path) + 8 + strlen(filename->value)) * sizeof(char));
|
||||
if (!font->path)
|
||||
return;
|
||||
strcpy(font->path, out_path);
|
||||
|
||||
Reference in New Issue
Block a user