when opening an image, check list of supported image formats. add error messages when openining AVI file fails, add fixme

This commit is contained in:
c0ntrol
2019-01-11 18:53:06 +01:00
parent 383e259be2
commit ff9fd1ca8f
4 changed files with 91 additions and 18 deletions

View File

@@ -63,6 +63,34 @@ static char id_str[MAX_INFO_STRLEN];
#define FRAME_RATE_SCALE 1000000 #define FRAME_RATE_SCALE 1000000
static char *avi_error_list[] = {
"Unknown",
"The write of the data would exceed", // AVI_ERR_SIZELIM
"Error opening the AVI file - wrong path", // AVI_ERR_OPEN
"Error reading from AVI file", // AVI_ERR_READ
"Error writing to AVI file",
"Could not write index to AVI file",
"Could not write header to AVI file",
"Operation not permitted",
"Memory allocation failed",
"Not an AVI file",
"AVI file has no header list",
"AVI file has no MOVI list",
"AVI file contains no video data",
"AVI file has no index",
"AVI file is empty (header only)", // AVI_ERR_EMPTY
NULL
};
static void avierror(long AVI_errno) {
if(AVI_errno < 0 || AVI_errno > 14) {
veejay_msg(0, "AVI Error: %s", avi_error_list[0]);
}
veejay_msg(0, "AVI Error: %s", avi_error_list[ AVI_errno ] );
}
/******************************************************************* /*******************************************************************
* * * *
* Utilities for writing an AVI File * * Utilities for writing an AVI File *
@@ -1972,6 +2000,7 @@ avi_t *AVI_open_input_indexfile(char *filename, int getIndex, char *indexfile)
if(AVI==NULL) if(AVI==NULL)
{ {
AVI_errno = AVI_ERR_NO_MEM; AVI_errno = AVI_ERR_NO_MEM;
avierror(AVI_errno);
return 0; return 0;
} }
veejay_memset((void *)AVI,0,sizeof(avi_t)); veejay_memset((void *)AVI,0,sizeof(avi_t));
@@ -1989,6 +2018,7 @@ avi_t *AVI_open_input_indexfile(char *filename, int getIndex, char *indexfile)
{ {
AVI_errno = AVI_ERR_OPEN; AVI_errno = AVI_ERR_OPEN;
free(AVI); free(AVI);
avierror(AVI_errno);
return 0; return 0;
} }
@@ -1997,6 +2027,7 @@ avi_t *AVI_open_input_indexfile(char *filename, int getIndex, char *indexfile)
{ {
AVI_errno = AVI_ERR_EMPTY; AVI_errno = AVI_ERR_EMPTY;
free(AVI); free(AVI);
avierror(AVI_errno);
return 0; return 0;
} }
lseek( AVI->fdes,0,SEEK_SET ); lseek( AVI->fdes,0,SEEK_SET );
@@ -2010,8 +2041,10 @@ avi_t *AVI_open_input_indexfile(char *filename, int getIndex, char *indexfile)
AVI->aptr=0; //reset AVI->aptr=0; //reset
} }
if (AVI_errno) if (AVI_errno) {
avierror(AVI_errno);
return AVI=NULL; return AVI=NULL;
}
else else
return AVI; return AVI;
} }
@@ -2078,6 +2111,7 @@ avi_t *AVI_open_input_file(char *filename, int getIndex, long mmap_size)
if(AVI==NULL) if(AVI==NULL)
{ {
AVI_errno = AVI_ERR_NO_MEM; AVI_errno = AVI_ERR_NO_MEM;
avierror(AVI_errno);
return 0; return 0;
} }
@@ -2090,6 +2124,7 @@ avi_t *AVI_open_input_file(char *filename, int getIndex, long mmap_size)
{ {
AVI_errno = AVI_ERR_OPEN; AVI_errno = AVI_ERR_OPEN;
free(AVI); free(AVI);
avierror(AVI_errno);
return 0; return 0;
} }
@@ -2101,11 +2136,10 @@ avi_t *AVI_open_input_file(char *filename, int getIndex, long mmap_size)
} }
if (AVI_errno) { if (AVI_errno) {
avierror(AVI_errno);
return 0; return 0;
} }
if(!AVI_errno) if(!AVI_errno)
{ {
if( AVI_mmap_file(AVI,mmap_size) == 0 ) { if( AVI_mmap_file(AVI,mmap_size) == 0 ) {

View File

@@ -34,6 +34,8 @@
//#include <veejay/vj-lib.h> //#include <veejay/vj-lib.h>
#include <libvjmsg/vj-msg.h> #include <libvjmsg/vj-msg.h>
#ifdef USE_GDK_PIXBUF #ifdef USE_GDK_PIXBUF
#include <gmodule.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libel/pixbuf.h> #include <libel/pixbuf.h>
#endif #endif
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
@@ -67,6 +69,37 @@ static int output_scale_height = 0;
static float output_fps = 25.0; static float output_fps = 25.0;
static int output_yuv = 1; // 422 static int output_yuv = 1; // 422
char *get_filename_ext(char *filename) {
char *dot = strrchr(filename, '.');
if(!dot || dot == filename)
return NULL;
return dot + 1;
}
int lav_is_supported_image_file(char *filename)
{
GSList *list = gdk_pixbuf_get_formats();
GSList *iter;
int i;
char *ext = get_filename_ext(filename);
for( iter = list; iter->next != NULL; iter = iter->next ) {
gchar **extensions = gdk_pixbuf_format_get_extensions (list->data);
for( i = 0; extensions[i] != NULL; i ++ ) {
if( strncasecmp(ext, extensions[i], strlen(ext)) == 0 ) {
g_strfreev(extensions);
g_slist_free(list);
return 1;
}
}
g_strfreev (extensions);
}
g_slist_free(list);
return 0;
}
void lav_set_project(int w, int h, float f, int fmt) void lav_set_project(int w, int h, float f, int fmt)
{ {
output_scale_width = w; output_scale_width = w;
@@ -997,18 +1030,24 @@ lav_file_t *lav_open_input_file(char *filename, long mmap_size)
} }
#ifdef USE_GDK_PIXBUF #ifdef USE_GDK_PIXBUF
lav_fd->picture = vj_picture_open( (const char*) filename, int is_picture = lav_is_supported_image_file( filename );
output_scale_width, output_scale_height, get_ffmpeg_pixfmt(output_yuv) ); #else
int is_picture = 0;
#endif
if( is_picture ) {
#ifdef USE_GDK_PIXBUF
lav_fd->picture = vj_picture_open( (const char*) filename, output_scale_width, output_scale_height, get_ffmpeg_pixfmt(output_yuv) );
if(lav_fd->picture) if(lav_fd->picture)
{ {
lav_fd->format = 'x'; lav_fd->format = 'x';
lav_fd->bogus_len = (int) output_fps; lav_fd->bogus_len = (int) output_fps;
video_comp = pict; video_comp = pict;
ret = 1;
veejay_msg(VEEJAY_MSG_DEBUG,"\tLoaded image file"); veejay_msg(VEEJAY_MSG_DEBUG,"\tLoaded image file");
return lav_fd; return lav_fd;
} }
#endif #endif
}
else else
{ {
lav_fd->avi_fd = AVI_open_input_file(filename,1,mmap_size); lav_fd->avi_fd = AVI_open_input_file(filename,1,mmap_size);

View File

@@ -220,7 +220,7 @@ filelist_t *find_media_files( veejay_t *info )
return fl; return fl;
} }
/* FIXME: issue #78 /* TODO: libvevosample
* fx state is currently global, damage control is to check fx chain of current playing sample * fx state is currently global, damage control is to check fx chain of current playing sample
* for FX that needs a background frame. * for FX that needs a background frame.
* before: apply on all FX * before: apply on all FX

View File

@@ -3296,7 +3296,7 @@ static void vj_perform_render_osd( veejay_t *info, video_playback_setup *setting
frame->data[1] = primary_buffer[destination]->Cb; frame->data[1] = primary_buffer[destination]->Cb;
frame->data[2] = primary_buffer[destination]->Cr; frame->data[2] = primary_buffer[destination]->Cr;
if( !frame->ssm) if( !frame->ssm) //FIXME this is costly just to render OSD
{ {
chroma_supersample( chroma_supersample(
settings->sample_mode, settings->sample_mode,