diff --git a/avidemux/common/ADM_commonUI/myOwnMenu.h b/avidemux/common/ADM_commonUI/myOwnMenu.h index 2c3d2d43e7..9a8b97345c 100644 --- a/avidemux/common/ADM_commonUI/myOwnMenu.h +++ b/avidemux/common/ADM_commonUI/myOwnMenu.h @@ -42,6 +42,7 @@ static const MenuEntry _myMenuFile[] = { {MENU_SUBACTION,QT_TRANSLATE_NOOP("adm","Save as PNG"), NULL,ACT_SAVE_PNG, NULL,"Ctrl+P",0}, {MENU_SUBACTION,QT_TRANSLATE_NOOP("adm","Save as JPEG"), NULL,ACT_SAVE_JPG, NULL,"Ctrl+E",0}, {MENU_SUBACTION,QT_TRANSLATE_NOOP("adm","Save Selection as JPEG"),NULL,ACT_SAVE_BUNCH_OF_JPG,NULL,NULL,0}, + {MENU_SUBACTION,QT_TRANSLATE_NOOP("adm","Save Selection as PNG"),NULL,ACT_SAVE_BUNCH_OF_PNG,NULL,NULL,0}, {MENU_ACTION,QT_TRANSLATE_NOOP("adm","Close"), NULL,ACT_CLOSE, NULL,"Ctrl+W",0}, {MENU_SEPARATOR,"-",NULL,ACT_DUMMY,NULL,NULL,1}, {MENU_ACTION,QT_TRANSLATE_NOOP("adm","Information"), NULL,ACT_VIDEO_PROPERTIES, MKICON(info),"Alt+Return",0}, diff --git a/avidemux/common/A_functions.h b/avidemux/common/A_functions.h index 1a74504143..491d77fd6c 100644 --- a/avidemux/common/A_functions.h +++ b/avidemux/common/A_functions.h @@ -43,6 +43,7 @@ void A_queueJob (void); int A_saveAudioCopy (const char *name); bool A_saveJpg (const char *name); int A_saveBunchJpg(const char *name); +int A_saveBunchPng(const char *name); bool A_saveImg (const char *name); bool A_savePng(const char *name); int ADM_saveRaw (const char *name); diff --git a/avidemux/common/gui_action.names b/avidemux/common/gui_action.names index 495feeffa8..0eb39e23e3 100644 --- a/avidemux/common/gui_action.names +++ b/avidemux/common/gui_action.names @@ -21,6 +21,7 @@ ACT(SAVE_BMP) ACT(SAVE_PNG) ACT(SAVE_JPG) ACT(SAVE_BUNCH_OF_JPG) +ACT(SAVE_BUNCH_OF_PNG) ACT(SAVE_VIDEO) ACT(SAVE_AUDIO) ACT(SAVE_QUEUE) diff --git a/avidemux/common/gui_save.cpp b/avidemux/common/gui_save.cpp index 25071ad6ee..dbda5ba402 100644 --- a/avidemux/common/gui_save.cpp +++ b/avidemux/common/gui_save.cpp @@ -170,6 +170,12 @@ void HandleAction_Save(Action action) GUI_FileSelWriteExtension (QT_TRANSLATE_NOOP("adm","Select JPEG Sequence to Save"),defaultExtension,(SELFILE_CB *)A_saveBunchJpg); } break; + case ACT_SAVE_BUNCH_OF_PNG: + { + const char *defaultExtension="png"; + GUI_FileSelWriteExtension (QT_TRANSLATE_NOOP("adm","Select PNG Sequence to Save"),defaultExtension,(SELFILE_CB *)A_saveBunchPng); + } + break; case ACT_SAVE_BMP: { const char *defaultExtension="bmp"; @@ -474,12 +480,7 @@ bool A_saveJpg (const char *name) } -/** - \fn A_saveBunchJpg - \brief Save the selection as a bunch of jpeg 95% qual - -*/ -int A_saveBunchJpg(const char *name) +int saveSelectionAsImages(const char *name, bool saveAsPng) { #if defined(__APPLE__) #define MAX_LEN 1024 @@ -549,7 +550,11 @@ int A_saveBunchJpg(const char *name) uint32_t fn; DIA_workingBase *working; - working=createWorking(QT_TRANSLATE_NOOP("adm","Saving selection as set of JPEG images")); + if (saveAsPng) + working=createWorking(QT_TRANSLATE_NOOP("adm","Saving selection as set of PNG images")); + else + working=createWorking(QT_TRANSLATE_NOOP("adm","Saving selection as set of JPEG images")); + while(true) { if(!filter->getNextFrameAs(hw,&fn,src)) @@ -565,8 +570,15 @@ int A_saveBunchJpg(const char *name) working->update((uint32_t)pts,range); success++; if(!working->isAlive()) break; - sprintf(fullName,"%s-%05d.jpg",baseName.c_str(),success); - if(!src->saveAsJpg(fullName)) break; + sprintf(fullName,"%s-%05d.%s",baseName.c_str(),success, saveAsPng ? "png":"jpg"); + if (saveAsPng) + { + if(!src->saveAsPng(fullName)) break; + } + else + { + if(!src->saveAsJpg(fullName)) break; + } if(success==99999) break; } @@ -590,6 +602,26 @@ int A_saveBunchJpg(const char *name) return success; } +/** + \fn A_saveBunchJpg + \brief Save the selection as a bunch of jpeg 95% qual + +*/ +int A_saveBunchJpg(const char *name) +{ + return saveSelectionAsImages(name, false); +} + +/** + \fn A_saveBunchPng + \brief Save the selection as bunch of png + +*/ +int A_saveBunchPng(const char *name) +{ + return saveSelectionAsImages(name, true); +} + /** \fn A_savePng \brief Save a PNG image from current display buffer or from filter chain diff --git a/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp b/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp index 411c71c078..487671fa7c 100644 --- a/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp +++ b/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp @@ -1081,6 +1081,7 @@ void MainWindow::buildActionLists(void) PUSH_LOADED(File, ACT_SAVE_PNG) PUSH_LOADED(File, ACT_SAVE_JPG) PUSH_LOADED(File, ACT_SAVE_BUNCH_OF_JPG) + PUSH_LOADED(File, ACT_SAVE_BUNCH_OF_PNG) PUSH_LOADED(File, ACT_CLOSE) PUSH_LOADED(File, ACT_VIDEO_PROPERTIES) diff --git a/avidemux_core/ADM_coreImage/src/ADM_imageSave.cpp b/avidemux_core/ADM_coreImage/src/ADM_imageSave.cpp index 7364760e97..14e3259050 100644 --- a/avidemux_core/ADM_coreImage/src/ADM_imageSave.cpp +++ b/avidemux_core/ADM_coreImage/src/ADM_imageSave.cpp @@ -303,6 +303,7 @@ bool ADMImage::saveAsPngInternal(const char *filename) AVCodecContext *context=NULL; AVFrame *frame=NULL; AVCodec *codec=NULL; + AVDictionary * options = NULL; FILE *f=NULL; bool result=false; const uint32_t sz=ADM_IMAGE_ALIGN(_width*3)*_height; @@ -338,8 +339,10 @@ bool ADMImage::saveAsPngInternal(const char *filename) context->time_base.num=1; context->width=_width; context->height=_height; - - r=avcodec_open2(context, codec, NULL); + context->compression_level=1; // least compression -> faster + + av_dict_set(&options, "pred", "paeth", 0); + r=avcodec_open2(context, codec, &options); if(r<0) { @@ -426,7 +429,11 @@ bool ADMImage::saveAsPngInternal(const char *filename) av_frame_free(&frame); frame=NULL; } - + if (options) + { + av_dict_free(&options); + options=NULL; + } return result; }