From ff9fd1ca8f12e602e2b0de2596e90d50e6617209 Mon Sep 17 00:00:00 2001 From: c0ntrol Date: Fri, 11 Jan 2019 18:53:06 +0100 Subject: [PATCH] when opening an image, check list of supported image formats. add error messages when openining AVI file fails, add fixme --- veejay-current/veejay-server/libel/avilib.c | 44 +++++++++++-- veejay-current/veejay-server/libel/lav_io.c | 61 +++++++++++++++---- veejay-current/veejay-server/veejay/vj-misc.c | 2 +- .../veejay-server/veejay/vj-perform.c | 2 +- 4 files changed, 91 insertions(+), 18 deletions(-) diff --git a/veejay-current/veejay-server/libel/avilib.c b/veejay-current/veejay-server/libel/avilib.c index 4d2171fa..c48c8f5c 100644 --- a/veejay-current/veejay-server/libel/avilib.c +++ b/veejay-current/veejay-server/libel/avilib.c @@ -63,6 +63,34 @@ static char id_str[MAX_INFO_STRLEN]; #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 * @@ -1972,6 +2000,7 @@ avi_t *AVI_open_input_indexfile(char *filename, int getIndex, char *indexfile) if(AVI==NULL) { AVI_errno = AVI_ERR_NO_MEM; + avierror(AVI_errno); return 0; } 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; free(AVI); + avierror(AVI_errno); return 0; } @@ -1997,6 +2027,7 @@ avi_t *AVI_open_input_indexfile(char *filename, int getIndex, char *indexfile) { AVI_errno = AVI_ERR_EMPTY; free(AVI); + avierror(AVI_errno); return 0; } 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 } - if (AVI_errno) - return AVI=NULL; + if (AVI_errno) { + avierror(AVI_errno); + return AVI=NULL; + } else return AVI; } @@ -2078,6 +2111,7 @@ avi_t *AVI_open_input_file(char *filename, int getIndex, long mmap_size) if(AVI==NULL) { AVI_errno = AVI_ERR_NO_MEM; + avierror(AVI_errno); return 0; } @@ -2090,6 +2124,7 @@ avi_t *AVI_open_input_file(char *filename, int getIndex, long mmap_size) { AVI_errno = AVI_ERR_OPEN; free(AVI); + avierror(AVI_errno); return 0; } @@ -2101,11 +2136,10 @@ avi_t *AVI_open_input_file(char *filename, int getIndex, long mmap_size) } if (AVI_errno) { - return 0; + avierror(AVI_errno); + return 0; } - - if(!AVI_errno) { if( AVI_mmap_file(AVI,mmap_size) == 0 ) { diff --git a/veejay-current/veejay-server/libel/lav_io.c b/veejay-current/veejay-server/libel/lav_io.c index d55bf4a4..e2e24dfd 100644 --- a/veejay-current/veejay-server/libel/lav_io.c +++ b/veejay-current/veejay-server/libel/lav_io.c @@ -34,6 +34,8 @@ //#include #include #ifdef USE_GDK_PIXBUF +#include +#include #include #endif #include @@ -67,6 +69,37 @@ static int output_scale_height = 0; static float output_fps = 25.0; 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) { output_scale_width = w; @@ -997,18 +1030,24 @@ lav_file_t *lav_open_input_file(char *filename, long mmap_size) } #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) - { - lav_fd->format = 'x'; - lav_fd->bogus_len = (int) output_fps; - video_comp = pict; - ret = 1; - veejay_msg(VEEJAY_MSG_DEBUG,"\tLoaded image file"); - return lav_fd; - } + int is_picture = lav_is_supported_image_file( filename ); +#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) + { + lav_fd->format = 'x'; + lav_fd->bogus_len = (int) output_fps; + video_comp = pict; + veejay_msg(VEEJAY_MSG_DEBUG,"\tLoaded image file"); + return lav_fd; + } +#endif + } else { lav_fd->avi_fd = AVI_open_input_file(filename,1,mmap_size); diff --git a/veejay-current/veejay-server/veejay/vj-misc.c b/veejay-current/veejay-server/veejay/vj-misc.c index c60d3c7f..1e621c68 100644 --- a/veejay-current/veejay-server/veejay/vj-misc.c +++ b/veejay-current/veejay-server/veejay/vj-misc.c @@ -220,7 +220,7 @@ filelist_t *find_media_files( veejay_t *info ) return fl; } -/* FIXME: issue #78 +/* TODO: libvevosample * fx state is currently global, damage control is to check fx chain of current playing sample * for FX that needs a background frame. * before: apply on all FX diff --git a/veejay-current/veejay-server/veejay/vj-perform.c b/veejay-current/veejay-server/veejay/vj-perform.c index 19291f22..c0411b5e 100644 --- a/veejay-current/veejay-server/veejay/vj-perform.c +++ b/veejay-current/veejay-server/veejay/vj-perform.c @@ -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[2] = primary_buffer[destination]->Cr; - if( !frame->ssm) + if( !frame->ssm) //FIXME this is costly just to render OSD { chroma_supersample( settings->sample_mode,