diff --git a/src/driver/pictureviewer/jpeg.cpp b/src/driver/pictureviewer/jpeg.cpp index 34a604bdf..3d3898f86 100644 --- a/src/driver/pictureviewer/jpeg.cpp +++ b/src/driver/pictureviewer/jpeg.cpp @@ -63,87 +63,7 @@ void jpeg_cb_error_exit(j_common_ptr cinfo) // dbout("jpeg_cd_error_exit }\n"); } -#define BUFFERLEN 8192 -int fh_jpeg_load_via_server(const char *filename,unsigned char *buffer,int x,int y) -{ - struct sockaddr_in si_other; - int s, slen=sizeof(si_other); - int bytes, port; - char path[PICV_CLIENT_SERVER_PATHLEN]; - struct pic_data pd; - - strncpy(path, filename, PICV_CLIENT_SERVER_PATHLEN-1); - path[PICV_CLIENT_SERVER_PATHLEN - 1] = 0; - - dbout("fh_jpeg_load_via_server (%s/%d/%d) {\n",basename(filename),x,y); - if ((s=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))==-1) - { - perror("socket:"); - return(FH_ERROR_FILE); - } - port=atoi(g_settings.picviewer_decode_server_port); - printf("Server %s [%d]\n",g_settings.picviewer_decode_server_ip.c_str(),port); - - memset((char *) &si_other, 0, sizeof(si_other)); - si_other.sin_family = AF_INET; - si_other.sin_port = htons(port); - if (inet_aton(g_settings.picviewer_decode_server_ip.c_str(), - &si_other.sin_addr)==0) - { - fprintf(stderr, "inet_aton() failed\n"); - return(FH_ERROR_FILE); - } - if (connect(s, (struct sockaddr *) &si_other, slen)==-1) - { - perror("connect()"); - return(FH_ERROR_FILE); - } - if (send(s, path, PICV_CLIENT_SERVER_PATHLEN, 0)==-1) - { - perror("send()"); - return(FH_ERROR_FILE); - } - pd.width=htonl(x); - pd.height=htonl(y); - if (send(s, &pd, sizeof(pd), 0)==-1) - { - perror("send()"); - return(FH_ERROR_FILE); - } - if (recv(s, &pd, sizeof(pd), 0) < (int)sizeof(pd)) - { - perror("recv pic desc"); - return(FH_ERROR_FILE); - } - if ((int)ntohl(pd.width) != x || (int)ntohl(pd.height) != y) - { - fprintf(stderr,"ugh, decoded pic has wrong size [%d/%d]<>[%d/%d]\n", ntohl(pd.width), ntohl(pd.height), x, y); - return(FH_ERROR_FILE); - } - unsigned char buf2[BUFFERLEN]; - unsigned char* workptr=buffer; - int rest = x*y*2; - while (rest > 0) - { - bytes=recv(s, buf2, MIN(BUFFERLEN,rest), 0); - if(bytes % 2 ==1) - bytes+=recv(s, buf2+bytes, 1, 0); - - for(int i=0 ; i < bytes ; i+=2) - { - *workptr = (buf2[i] >> 2) << 3; - workptr++; - *workptr = (buf2[i] << 6) | ((buf2[i+1] >> 5) << 3); - workptr++; - *workptr = (buf2[i+1] << 3); - workptr++; - } - rest-=bytes; - } - dbout("fh_jpeg_load_via_server }\n"); - return(FH_ERROR_OK); -} -int fh_jpeg_load_local(const char *filename,unsigned char **buffer,int* x,int* y) +int fh_jpeg_load(const char *filename,unsigned char **buffer,int* x,int* y) { //dbout("fh_jpeg_load_local (%s/%d/%d) {\n",basename(filename),*x,*y); struct jpeg_decompress_struct cinfo; @@ -215,98 +135,46 @@ int fh_jpeg_load_local(const char *filename,unsigned char **buffer,int* x,int* y return(FH_ERROR_OK); } -int fh_jpeg_load(const char *filename,unsigned char **buffer,int* x,int* y) -{ - int ret=FH_ERROR_FILE; -#if 1 - if(!g_settings.picviewer_decode_server_ip.empty()) - ret=fh_jpeg_load_via_server(filename, *buffer, *x, *y); - if(ret!=FH_ERROR_OK) -#endif - ret=fh_jpeg_load_local(filename, buffer, x, y); - return ret; -} - int fh_jpeg_getsize(const char *filename,int *x,int *y, int wanted_width, int wanted_height) { // dbout("fh_jpeg_getsize {\n"); struct jpeg_decompress_struct cinfo; - struct jpeg_decompress_struct *ciptr; struct r_jpeg_error_mgr emgr; - int px,py/*,c*/; FILE *fh; - ciptr=&cinfo; if(!(fh=fopen(filename,"rb"))) return(FH_ERROR_FILE); - ciptr->err=jpeg_std_error(&emgr.pub); + cinfo.err=jpeg_std_error(&emgr.pub); emgr.pub.error_exit=jpeg_cb_error_exit; if(setjmp(emgr.envbuffer)==1) { // FATAL ERROR - Free the object and return... - jpeg_destroy_decompress(ciptr); + jpeg_destroy_decompress(&cinfo); fclose(fh); // dbout("fh_jpeg_getsize } - FATAL ERROR\n"); return(FH_ERROR_FORMAT); } - jpeg_create_decompress(ciptr); - jpeg_stdio_src(ciptr,fh); - jpeg_read_header(ciptr,TRUE); - ciptr->out_color_space=JCS_RGB; + jpeg_create_decompress(&cinfo); + jpeg_stdio_src(&cinfo,fh); + jpeg_read_header(&cinfo,TRUE); + cinfo.out_color_space=JCS_RGB; // should be more flexible... - if((int)ciptr->image_width/8 >= wanted_width || - (int)ciptr->image_height/8 >= wanted_height) - ciptr->scale_denom=8; - else if((int)ciptr->image_width/4 >= wanted_width || - (int)ciptr->image_height/4 >= wanted_height) - ciptr->scale_denom=4; - else if((int)ciptr->image_width/2 >= wanted_width || - (int)ciptr->image_height/2 >= wanted_height) - ciptr->scale_denom=2; + if((int)cinfo.image_width/8 >= wanted_width || + (int)cinfo.image_height/8 >= wanted_height) + cinfo.scale_denom=8; + else if((int)cinfo.image_width/4 >= wanted_width || + (int)cinfo.image_height/4 >= wanted_height) + cinfo.scale_denom=4; + else if((int)cinfo.image_width/2 >= wanted_width || + (int)cinfo.image_height/2 >= wanted_height) + cinfo.scale_denom=2; else - ciptr->scale_denom=1; + cinfo.scale_denom=1; - jpeg_start_decompress(ciptr); - px=ciptr->output_width; py=ciptr->output_height; -// c=ciptr->output_components; -#if 1 - if(!g_settings.picviewer_decode_server_ip.empty()) - { - // jpeg server resizes pic to desired size - if( px > wanted_width || py > wanted_height) - { - if( (CPictureViewer::m_aspect_ratio_correction*py*wanted_width/px) <= wanted_height) - { - *x=wanted_width; - *y=(int)(CPictureViewer::m_aspect_ratio_correction*py*wanted_width/px); - } - else - { - *x=(int)((1.0/CPictureViewer::m_aspect_ratio_correction)*px*wanted_height/py); - *y=wanted_height; - } - } - else if(CPictureViewer::m_aspect_ratio_correction >=1) - { - *x=px; - *y=(int)(py/CPictureViewer::m_aspect_ratio_correction); - } - else - { - *x=(int)(px/CPictureViewer::m_aspect_ratio_correction); - *y=py; - } - - } - else -#endif - { - *x=px; - *y=py; - } -// jpeg_finish_decompress(ciptr); - jpeg_destroy_decompress(ciptr); + jpeg_start_decompress(&cinfo); + *x=cinfo.output_width; *y=cinfo.output_height; + jpeg_destroy_decompress(&cinfo); fclose(fh); // dbout("fh_jpeg_getsize }\n"); return(FH_ERROR_OK); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 5a8fe00fa..7bfc413a2 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -737,7 +737,6 @@ int CNeutrinoApp::loadSetup(const char * fname) //Picture-Viewer g_settings.picviewer_slide_time = configfile.getInt32( "picviewer_slide_time", 10); g_settings.picviewer_scaling = configfile.getInt32("picviewer_scaling", 1 /*(int)CPictureViewer::SIMPLE*/); - g_settings.picviewer_decode_server_ip = configfile.getString("picviewer_decode_server_ip", ""); //Audio-Player g_settings.audioplayer_display = configfile.getInt32("audioplayer_display",(int)CAudioPlayerGui::ARTIST_TITLE); @@ -1177,8 +1176,6 @@ void CNeutrinoApp::saveSetup(const char * fname) //Picture-Viewer configfile.setInt32( "picviewer_slide_time", g_settings.picviewer_slide_time); configfile.setInt32( "picviewer_scaling", g_settings.picviewer_scaling ); - configfile.setString( "picviewer_decode_server_ip", g_settings.picviewer_decode_server_ip ); - configfile.setString( "picviewer_decode_server_port", g_settings.picviewer_decode_server_port); //Audio-Player configfile.setInt32( "audioplayer_display", g_settings.audioplayer_display ); diff --git a/src/nhttpd/web/Y_neutrino_Blocks.txt b/src/nhttpd/web/Y_neutrino_Blocks.txt index 714a573cc..1ef19390f 100644 --- a/src/nhttpd/web/Y_neutrino_Blocks.txt +++ b/src/nhttpd/web/Y_neutrino_Blocks.txt @@ -870,16 +870,6 @@ start-block~neutrino_form-data_pictureviewer {=L:set.pv.start_dir=} - {=if-not-equal:{=global-var-get:boxtype=}~coolstream~ - - {=L:set.pv.decoding_server_ip=} - - - - {=L:set.pv.decoding_server_port=} - - - =}
@@ -916,8 +906,6 @@ start-block~neutrino_pictureviewer_save_settings {=ini-set:/var/tuxbox/config/neutrino.conf;picviewer_scaling;{=picviewer_scaling=}~open=} {=ini-set:/var/tuxbox/config/neutrino.conf;picviewer_slide_time;{=picviewer_slide_time=}~cache=} {=ini-set:/var/tuxbox/config/neutrino.conf;network_nfs_picturedir;{=network_nfs_picturedir=}~cache=} -{=ini-set:/var/tuxbox/config/neutrino.conf;picviewer_decode_server_ip;{=picviewer_decode_server_ip=}~cache=} -{=ini-set:/var/tuxbox/config/neutrino.conf;picviewer_decode_server_port;{=picviewer_decode_server_port=}~save=} end-block~neutrino_pictureviewer_save_settings # ------- Neutrino form-data: audioplayer ------------------------------- diff --git a/src/system/settings.h b/src/system/settings.h index 92d32cb43..e168ac7af 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -638,8 +638,6 @@ struct SNeutrinoSettings // pictureviewer int picviewer_slide_time; int picviewer_scaling; - std::string picviewer_decode_server_ip; - char picviewer_decode_server_port[6]; //audioplayer int audioplayer_display;